How Do I Add Auto Enumerating Headings ? #914
-
First of all, thank you SO MUCH for an editor like this. It literally makes my life much easier. 🚀 What I am trying to achieve:I am trying to implement auto enumerating headings for the headings inside of the editor content. Right now I am using DOM Manipulation to achieve the behavior to convert <h1> The First H1 </h1>
<h2> The First H2 </h2>
<h3> The First H3 </h3>
<h1> The Second H1 </h1> to <h1> 1. The First H1 </h1>
<h2> 1.1. The First H2 </h2>
<h3> 1.1.1. The First H3 </h3>
<h1> 2. The Second H1 </h1>
Problem:The algorithm that I am using for it is that whenever the editor content is updated, remove all the numbers from heading elements first and then recalculate the order and then prepend the newly computed numbers before the Asking For Help:
or
Any help would be very much appreciated and once again, thank you TipTap team and Community for such an amazing text editor, I'm eagerly waiting for version 2.0 🚀 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can create a nodeView for headings and prepend that numbers. Wrap them with |
Beta Was this translation helpful? Give feedback.
-
I had the same issue, are CSS counters enough for you? h1 {
counter-increment: h1;
counter-reset: h2;
}
h2 {
counter-increment: h2;
counter-reset: h3;
}
h3 {
counter-increment: h3;
}
h1::before {
content: counter(h1)'. ';
}
h2::before {
content: counter(h1)'.'counter(h2)'. ';
}
h3::before {
content: counter(h1)'.'counter(h2)'.'counter(h3)'. ';
} |
Beta Was this translation helpful? Give feedback.
I had the same issue, are CSS counters enough for you?