Reputation: 6826
I wrote a TinyMCE plugin for Wordpress that drops a prepared bit of HTML into the textarea when a button on the toolbar is clicked. This is to assist in formatting some relatively complicated elements.
I would like for this piece of HTML to be wrapped in some sort of container that TinyMCE recognizes and allows for easy selection or deletion if needed.
Currently, the only way to delete an individual element is by erasing all of the information each individual "sub element" contains. I can't seem to find any information in the API regarding manually assigning an element as a singular combined object. As far as behavior goes, think "resize frame"
or something similar (only this won't need to have any resizing capabilities).
Any ideas?
Upvotes: 2
Views: 175
Reputation: 50832
If you want to wrap text/html inside an element of your choice (i used a span here) at the current cursor position of tinymce editor instance ed
you can simply do
ed.execCommand('insertHTML', false, '<span class="custom_to_delete">My_Text</span>');
Upvotes: 1