how to check classes of node inside TinyMCE? -


I want to see if the node inside the TinyMCE starts with the word 'border' I reclaim the sections of the node Tried,

  using tinyMCE.activeEditor.dom.getClasses ();  

But this blank returned

Is there any way to do this? I need to know that there is any class staring with the word 'boundary' in the node, if the class is replaced with the other in it.

There is no problem Assuming there is only one node inside your editor:

< Pre> class_string = tinyMCE.activeEditor.getBody (). FirstChild.class; Class_string_array = class_string.split (""); (I = 0; i & lt; class_string_array.length; i ++) {if (class_string_array [i] search ("border")! == -1) {Warning ("got class!"); Class_string_array [i] = "new class"; Class_string = class_string_array.join (""); . TinyMCE.activeEditor.getBody () firstChild.setAttribute ('class', class_string); break; }}

This is easy to use jQuery:

  node = tinyMCE.activeEditor.getBody (). FirstChild; If ($ (node) .hasClass ("border_xxx")) {// must check for the explicit classname $ (node) .removeClass ("border_xxx"); $ (Node) .addClass ("new_class"); }  

Edit: If you want to check each node inside the material, then you will need to go through the body-to-door and check each node: < /remoteClass ("border_xxx") /p>

  function getTextNodesValues ​​(tinymce, node) {if ($ (node) .hasClass ("border_xxx")) {// clear className $ (node) Needs to be checked; $ (Node) .addClass ("new_class"); } (Var i = 0; i & lt; node.childNodes.length; i ++) {el = node.childNodes [i]; If ($ (node) .hasClass ("border_xxx")) {// must explicitly check the classname $ (node) .removeClass ("border_xxx"); $ (Node) .addClass ("new_class"); } If (L. Chindo.Lambi> 0) getTextNodesValues ​​(tinymce, el); }} GetTextNodesValues ​​(tinymce, getTextNodesValues ​​(tinymce, node));  

You should get all the classes inside the editor:

  tinyMCE.activeEditor.dom.getClasses ();  

But with that information, it is not easy to change them.


Comments