How to find and replace text in CKEditor using Javascript?

How do I find and replace text in CKEditor using Javascript? Thank you for your offer!

+4
source share
1 answer

try it

editor = CKEDITOR.instances.fck; //fck is just my instance name you will need to replace that with yours var edata = editor.getData(); var replaced_text = edata.replace("idontwant", "iwant this instead"); // you could also use a regex in the replace editor.setData(replaced_text); 

you may want to put this in a blur event or soemthing

+12
source

Source: https://habr.com/ru/post/1347716/


All Articles