Hi there,
we want to render the custom field description, which can be written using Markdown and WikiMarkup, in HTML.
Is there any library or service method for that in Forge? I tried to to it with @atlaskit/editor-wikimarkup-transformer
without success.
Thanks in advance!
Cheers,
paul
1 Like
ppasler
2
We ended up using the Rich-Text-Editor with a Tranformer
Transforming
import {WikiMarkupTransformer} from "@atlaskit/editor-wikimarkup-transformer";
export function transformFieldDescription(rawFieldDescription: string) {
if (!rawFieldDescription) return;
try {
const wikiMarkupTransformer = new WikiMarkupTransformer();
const adfFieldDescription = wikiMarkupTransformer.parse(rawFieldDescription);
// TODO workaround to get rid of object properties
const content = JSON.parse(JSON.stringify(adfFieldDescription.content));
return {type: "doc", version: 1, content};
} catch (e: any) {
console.error("unable to render field description", rawFieldDescription, e);
}
}
Rendering
...
const fieldDescriptionADF = transformFieldDescription(rawFieldDescription);
return <Editor appearance={"chromeless"} disabled={true} defaultValue={fieldDescriptionADF}/>
Hope this helps