import server from "../../../services/server.js"; const TPL = `

Settings on this options tab are saved automatically after each change.

Heading style


Table of contents

Table of contents will appear in text notes when the note has more than a defined number of headings. You can customize this number:

You can also use this option to effectively disable TOC by setting a very high number.

`; export default class TextNotesOptions { constructor() { $("#options-text-notes").html(TPL); this.$body = $("body"); this.$headingStyle = $("#heading-style"); this.$headingStyle.on('change', () => { const newHeadingStyle = this.$headingStyle.val(); this.toggleBodyClass("heading-style-", newHeadingStyle); server.put('options/headingStyle/' + newHeadingStyle); }); this.$minTocHeadings = $("#min-toc-headings"); this.$minTocHeadings.on('change', () => { const minTocHeadings = this.$minTocHeadings.val(); server.put('options/minTocHeadings/' + minTocHeadings); }); } toggleBodyClass(prefix, value) { for (const clazz of Array.from(this.$body[0].classList)) { // create copy to safely iterate over while removing classes if (clazz.startsWith(prefix)) { this.$body.removeClass(clazz); } } this.$body.addClass(prefix + value); } async optionsLoaded(options) { this.$headingStyle.val(options.headingStyle); this.$minTocHeadings.val(options.minTocHeadings); } }