Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

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

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

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

Avatar

Level 2

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.