cancel
Showing results for 
Search instead for 
Did you mean: 

RichTextEditor with SuperScript and SubScript

raina_goyal
Participant

Hello Experts,

I have a requirement in which two custom buttons has to be added in RichtextEditor for SubScript and SuperScript, I am able to add custom buttons but unable to fetch the selected text in richtexteditor. Also once we get the selected text how change it to subscript/superscript.

Please help as I am badly stuck in this and unable to find much on this.

Thanks,

Best Regards,

Raina

Accepted Solutions (1)

Accepted Solutions (1)

LaurensDeprost
Contributor

Hi Raina,

The RichTextEditor-Control implements the third-party TinyMCE editor. As far as I can see, it doesn't expose the necessary public methods or attributes to allow for getting the text selection. Note that accessing private members of SAPUI5 objects is against best practice and not recommended.

That said, I don't immediately see an alternative here apart from developing a custom control.

You can directly access the private TinyMCE editor object (_oEditor). Next, you can use the execcommand method to convert the selected text to super- or subscript.

var oRichTextEditor = sap.ui.getCore().byId("myRTE");
oRichTextEditor._oEditor.editorCommands.execCommand("Superscript");

See this example on Plunker.

Regards,
Laurens

raina_goyal
Participant

dep Thanks a lot for the help. Its working absolutely wonderful. 🙂

Answers (0)