[hack] correct insertion of the "more" tag
-
this is my first post on WP forum so hello to all.
one thing i’ve found unfortunate and needing-the-fix about the WYSIWYG editor is the way the “more” tag is inserted into the content of the post. the JS code puts it inside current HTML block element and this could account to breaking of the layout while displaying only the first part of the post. i’ve searched the forum and it seems to be considered as an TinyMCE issue. after reviewing the code i’m not sure if this is (still?) the case. to me it rather seems to be related to the way WP extends original TinyMCE code.
anyway, what i did was to modify
wp-includes/js/tinymce/wp-tinymce.js
. there’s a piece of code looking like this:c.addCommand("WP_More", function () { c.execCommand("mceInsertContent", 0, f); });
the “WP_More” command can be extended as follows:
c.addCommand("WP_More", function () { node = c.selection.getNode(); if(node.nodeName != 'BODY') { p = node; while(p.parentNode.nodeName != 'BODY') p = p.parentNode; var div = c.dom.create('div', {}, f); c.dom.insertAfter(div.firstChild, p); } });
now, instead of just inserting a proper string at the cursor position, new DOM element is created and inserted after current root block element (such as ‘p’ or ‘div’). of course the file needs to be “gunzipped” and probably re-formatted before editing.
i’ve also found necessary to disable ‘forced_root_block’ option in the TinyMCE configuration. luckily this can be done via a simple plugin, using ‘tiny_mce_before_init’ hook.
i’m curious if there is some way to implement this fix as a plugin? i guess it would require replacing the whole editor.
hope it’ll be helpful to someone. any comments appreciated ??
(PS. not sure if my english is fine enough so i’m sorry for all potential vagueness in my posts)
- The topic ‘[hack] correct insertion of the "more" tag’ is closed to new replies.