replacing space with non breakable space on selecting text via a button in Rich Text Editor in CQ | Community
Skip to main content
Level 2
October 16, 2015
Solved

replacing space with non breakable space on selecting text via a button in Rich Text Editor in CQ

  • October 16, 2015
  • 2 replies
  • 1170 views

Hi All,

I have a requirement, In which what should be done is- whenever user selects some text and clicks a button(customized) that button should convert all the white space in Selected text to non breakable space.

Till now I am able to add the button via MiscToolPlugin.js. But after that I do not know how to proceed.

MiscToolPlugin.js uses method     execute: function(id, value, options) .

I will call my method from this method. and My thinking is to somehow get the selected Text and replace all white space in this selected Text to non breakable space.

But I do not know How to get the selected Text and how to save the new Text back after replacing.

I searched on internet but couldn't find anything useful. 

Please help asap.

Thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Check the reference docs for the Rich Text Editor. I am thinking that your use case should be achieved by using JavaScript and methods that belong to the Rich Text Editor. 

http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.form.RichText

2 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Check the reference docs for the Rich Text Editor. I am thinking that your use case should be achieved by using JavaScript and methods that belong to the Rich Text Editor. 

http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.form.RichText

Level 2
October 16, 2015

hi smacdonald2008

thanks for responding back. You always reply to my query thats great. and i really appreciate that.

Coming to question can you be lil more specific. 

like Which method should I use in this case. (I have already see that link, but i didn't found anything)

I am adding a button via misctoolsplugin.js. 

so adding of the button is happening. 

Now i need to put my whole code inside Execute method of Misctoolplugin.js.  execute: function(id, value, options) .

please guide me further. I am new to CQ. 

I need to get the selected text and then replace the space by   and then save it back. 

please help.