Skip to content
Snippets Groups Projects

Issue #3468538 by mably, SirClickalot: Flexibility in targeting heading tags

1 file
+ 7
2
Compare changes
  • Side-by-side
  • Inline
+ 7
2
@@ -3,14 +3,19 @@
* Toc.js.
*/
(($, once) => {
function decodeHtml(html) {
const textarea = document.createElement('textarea');
textarea.innerHTML = html;
return textarea.value;
}
Drupal.behaviors.toc_js = {
attach(context, settings) {
once('toc_js', '.toc-js', context).forEach((elt) => {
const $tocEl = $(elt);
const options = {
listType: $tocEl.data('list-type') === 'ol' ? 'ol' : 'ul',
selectors: $tocEl.data('selectors') || 'h2, h3',
container: $tocEl.data('container') || 'body',
selectors: decodeHtml($tocEl.data('selectors')) || 'h2, h3',
container: decodeHtml($tocEl.data('container')) || 'body',
selectorsMinimum: $tocEl.data('selectors-minimum') || 0,
stickyOffset: $tocEl.data('sticky-offset') || 0,
prefix: $tocEl.data('prefix') || '',
Loading