added an option to define a "min TOC headings", #2985

This commit is contained in:
zadam
2022-07-16 00:15:45 +02:00
parent 377922eccf
commit 57c5b6d61f
6 changed files with 81 additions and 31 deletions

View File

@@ -16,6 +16,7 @@
import attributeService from "../services/attributes.js";
import CollapsibleWidget from "./collapsible_widget.js";
import options from "../services/options.js";
const TPL = `<div class="toc-widget">
<style>
@@ -67,8 +68,6 @@ function findHeadingNodeByIndex(parent, headingIndex) {
return headingNode;
}
const MIN_HEADING_COUNT = 3;
export default class TocWidget extends CollapsibleWidget {
get widgetTitle() {
return "Table of Contents";
@@ -94,7 +93,7 @@ export default class TocWidget extends CollapsibleWidget {
}
this.$toc.html($toc);
this.toggleInt(headingCount >= MIN_HEADING_COUNT);
this.toggleInt(headingCount >= options.getInt('minTocHeadings'));
this.triggerCommand("reevaluateIsEnabled");
}