getTableOfContentsModelListHTML

Release 3.2.0 and above, Release 2.20.0 and above.

Returns the current editor's table of contents (TOC) model as an HTML List.

Parameters:

<table> <thead> <tr><th>Name</th><th>Type</th><th>Attribute</th><th>Description</th></tr> </thead> <tbody> <tr> <td><code>shouldAssignId</code></td> <td>boolean</td> <td>default: <code>false</code></td> <td>

Sets whether to assign new IDs to the TOC model.

  • When true, IDs with the 'toc_' prefix are applied. To keep the TOC IDs in the content stable across save/load, you must call updateTableOfContentsIds to sync the IDs.
  • When false, the IDs used internally by the editor are applied, and they are refreshed on each save/load. When the IDs are not the editor's internal IDs, the existing IDs are preserved across save/load.
</td> </tr> </tbody> </table>

Return:

TypeDescription
stringTOC model HTML String.

To synchronize the IDs of TOC elements in the content with the TOC model, call updateTableOfContentsIds.

This method updates the IDs of the actual TOC elements in the editor to match the latest TOC model.

ex) editor.updateTableOfContentsIds();

Example:

getTableOfContentsModelListHTML example

// Get the HTML List
var htmlString = editor.getTableOfContentsModelListHTML();
var htmlString = editor.getTableOfContentsModelListHTML(true);
// Synchronize the IDs of TOC elements in the content with the TOC model
editor.getTableOfContentsModelListHTML();
editor.updateTableOfContentsIds();

shouldAssignId: false

'<ol><li><a target="_self" href="#se_011fb8a1-b74d-49a9-a7ef-a16c3eecb939">H1</a><ol><li><a target="_self" href="#se_ab77dbab-8fcc-418a-bdd2-365930aab960">H2</a><ol><li><a target="_self" href="#se_2e4330a5-ef87-404c-99d3-1c6d79937289">H3</a><ol><li><a target="_self" href="#se_19102d03-cb41-430d-b9c9-b7a8ce823525">H4</a><ol><li><a target="_self" href="#se_c45d1628-cc3f-4ab2-b2bc-6cd23ef6fec1">H5</a><ol><li><a target="_self" href="#se_85d9cfed-46af-497d-9670-f85cc467dafa">H6</a></li></ol></li></ol></li></ol></li></ol></li></ol></li></ol>'

shouldAssignId: true

'<ol><li><a target="_self" href="#toc_011fb8a1-b74d-49a9-a7ef-a16c3eecb939">H1</a><ol><li><a target="_self" href="#toc_ab77dbab-8fcc-418a-bdd2-365930aab960">H2</a><ol><li><a target="_self" href="#toc_2e4330a5-ef87-404c-99d3-1c6d79937289">H3</a><ol><li><a target="_self" href="#toc_19102d03-cb41-430d-b9c9-b7a8ce823525">H4</a><ol><li><a target="_self" href="#toc_c45d1628-cc3f-4ab2-b2bc-6cd23ef6fec1">H5</a><ol><li><a target="_self" href="#toc_85d9cfed-46af-497d-9670-f85cc467dafa">H6</a></li></ol></li></ol></li></ol></li></ol></li></ol></li></ol>'