Saturday, 6 November 2021

DraftJs : Custom button to add custom HTML + CSS

Using DraftJs with WYSWYG : I need to create a custom button in the toolbar. On clicking the button, some custom HTML is added to the content itself.

I know how to add custom button, the docs are there. The button gets added and onclick I call the defined method insertText. But with insertText(a method in the DraftModifier class of draft.js) it only seems to add my HTML code as a string. Is there a different method I should use to add custom HTML into the content. I want to add real HTML.

Here is the TS declarations:

static insertText(
                    contentState: ContentState,
                    targetRange: SelectionState,
                    text: string,
                    inlineStyle?: DraftInlineStyle,
                    entityKey?: string,
                ): ContentState;


from DraftJs : Custom button to add custom HTML + CSS

No comments:

Post a Comment