on 06-25-2021 3:51 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
dep Thanks a lot for the help. Its working absolutely wonderful. 🙂
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.