How to automatically generate anchor ids to CKEditor added headers How can i automatically generate anchor ids to h2 and h3 added using ck editor ?
I need it for making a table of content.
in JS, id set from the h2 label two first words :
const headings = document.querySelectorAll(
  &quot;.article--full h2, .article--full h3&quot;
);
const tocElements = createTocElementsArray(headings);

function createTocElementsArray(headings) {
  const tocElements = [];   
  for (const item of headings) {
    if (item.id === &quot;&quot;) {
      item.id = item.firstChild.data
        .split(&quot; &quot;)
        .slice(0, 2)
        .join(&quot;-&quot;);
    }
....
}