I'm working on adding a button to the Tinymce editor toolbar in an app that will paste in the html code for a table of content's customized for the content in the editor.
For example, for every h level tag (h1-h3) found in the editor I would like to insert a snippet of html (a div containing the table of contents*) along with pasting a <!--nextpage--> comment tag into the source markup just before the table of contents html fragment.
Can anyone suggest an example tutorial on how to interact with the tinyMCE API in order to add a button to the editor that fires a local jQuery function to interact with the editor's contents?
My html fragment will be:
<!--nextpage-->
<div class="toc">
<h3>Table of Contents</h3>
<ul>
<li><a href="http://mysite.com/article-slug/">Introduction</a></li>
<li><a href="http://mysite.com/article-slug/2">First h1-h3 heading</a></li>
<li><a href="http://mysite.com/article-slug/3">Next h1-h3 heading</a></li>
</ul>
</div>
But the contents would be dynamically generated specifically for this page by jQuery based on the page URL and the number of h1-h3 elements, so that the TOC is dynamically generated for the user based on the page structure.
tinyMCE
editor and also can insert new text or short code via that button, but I'm confused about your question. – The Alpha