mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 11:02:28 +08:00
chore(client/ts): port options/text_notes
This commit is contained in:
parent
677760282c
commit
7e61af1cc3
@ -1,3 +1,4 @@
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import utils from "../../../../services/utils.js";
|
||||
import OptionsWidget from "../options_widget.js";
|
||||
@ -5,7 +6,7 @@ import OptionsWidget from "../options_widget.js";
|
||||
const TPL = `
|
||||
<div class="options-section formatting-toolbar">
|
||||
<h4>${t("editing.editor_type.label")}</h4>
|
||||
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<input type="radio" name="editor-type" value="ckeditor-balloon" />
|
||||
@ -39,6 +40,10 @@ const TPL = `
|
||||
`;
|
||||
|
||||
export default class EditorOptions extends OptionsWidget {
|
||||
|
||||
private $body!: JQuery<HTMLElement>;
|
||||
private $multilineToolbarCheckbox!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$body = $("body");
|
||||
@ -52,7 +57,7 @@ export default class EditorOptions extends OptionsWidget {
|
||||
this.$multilineToolbarCheckbox.on("change", () => this.updateCheckboxOption("textNoteEditorMultilineToolbar", this.$multilineToolbarCheckbox));
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
async optionsLoaded(options: OptionMap) {
|
||||
this.$widget.find(`input[name="editor-type"][value="${options.textNoteEditorType}"]`).prop("checked", "true");
|
||||
this.setCheckboxState(this.$multilineToolbarCheckbox, options.textNoteEditorMultilineToolbar);
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
import OptionsWidget from "../options_widget.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
<h4>${t("heading_style.title")}</h4>
|
||||
|
||||
|
||||
<select class="heading-style form-select">
|
||||
<option value="plain">${t("heading_style.plain")}</option>
|
||||
<option value="underline">${t("heading_style.underline")}</option>
|
||||
@ -13,12 +14,16 @@ const TPL = `
|
||||
</div>`;
|
||||
|
||||
export default class HeadingStyleOptions extends OptionsWidget {
|
||||
|
||||
private $body!: JQuery<HTMLElement>;
|
||||
private $headingStyle!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$body = $("body");
|
||||
this.$headingStyle = this.$widget.find(".heading-style");
|
||||
this.$headingStyle.on("change", () => {
|
||||
const newHeadingStyle = this.$headingStyle.val();
|
||||
const newHeadingStyle = String(this.$headingStyle.val());
|
||||
|
||||
this.toggleBodyClass("heading-style-", newHeadingStyle);
|
||||
|
||||
@ -26,11 +31,11 @@ export default class HeadingStyleOptions extends OptionsWidget {
|
||||
});
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
async optionsLoaded(options: OptionMap) {
|
||||
this.$headingStyle.val(options.headingStyle);
|
||||
}
|
||||
|
||||
toggleBodyClass(prefix, value) {
|
||||
toggleBodyClass(prefix: string, value: string) {
|
||||
for (const clazz of Array.from(this.$body[0].classList)) {
|
||||
// create copy to safely iterate over while removing classes
|
||||
if (clazz.startsWith(prefix)) {
|
@ -1,5 +1,6 @@
|
||||
import OptionsWidget from "../options_widget.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
@ -20,11 +21,14 @@ const TPL = `
|
||||
<h5>${t("highlights_list.visibility_title")}</h5>
|
||||
|
||||
<p>${t("highlights_list.visibility_description")}</p>
|
||||
|
||||
|
||||
<p>${t("highlights_list.shortcut_info")}</p>
|
||||
</div>`;
|
||||
|
||||
export default class HighlightsListOptions extends OptionsWidget {
|
||||
|
||||
private $hlt!: JQuery<HTMLInputElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$hlt = this.$widget.find("input.highlights-list-check");
|
||||
@ -32,14 +36,14 @@ export default class HighlightsListOptions extends OptionsWidget {
|
||||
const hltVals = this.$widget
|
||||
.find('input.highlights-list-check[type="checkbox"]:checked')
|
||||
.map(function () {
|
||||
return this.value;
|
||||
return (this as HTMLInputElement).value;
|
||||
})
|
||||
.get();
|
||||
this.updateOption("highlightsList", JSON.stringify(hltVals));
|
||||
});
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
async optionsLoaded(options: OptionMap) {
|
||||
const hltVals = JSON.parse(options.highlightsList);
|
||||
this.$widget.find('input.highlights-list-check[type="checkbox"]').each(function () {
|
||||
if ($.inArray($(this).val(), hltVals) !== -1) {
|
@ -1,29 +1,33 @@
|
||||
import OptionsWidget from "../options_widget.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
<h4>${t("table_of_contents.title")}</h4>
|
||||
|
||||
|
||||
${t("table_of_contents.description")}
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<input type="number" class="min-toc-headings form-control options-number-input options-number-input" min="0" max="9999999999999999" step="1" />
|
||||
</div>
|
||||
|
||||
|
||||
<p>${t("table_of_contents.disable_info")}</p>
|
||||
|
||||
|
||||
<p>${t("table_of_contents.shortcut_info")}</p>
|
||||
</div>`;
|
||||
|
||||
export default class TableOfContentsOptions extends OptionsWidget {
|
||||
|
||||
private $minTocHeadings!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$minTocHeadings = this.$widget.find(".min-toc-headings");
|
||||
this.$minTocHeadings.on("change", () => this.updateOption("minTocHeadings", this.$minTocHeadings.val()));
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
async optionsLoaded(options: OptionMap) {
|
||||
this.$minTocHeadings.val(options.minTocHeadings);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import OptionsWidget from "../options_widget.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
@ -14,13 +15,16 @@ const TPL = `
|
||||
</div>`;
|
||||
|
||||
export default class TextAutoReadOnlySizeOptions extends OptionsWidget {
|
||||
|
||||
private $autoReadonlySizeText!: JQuery<HTMLElement>;
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$autoReadonlySizeText = this.$widget.find(".auto-readonly-size-text");
|
||||
this.$autoReadonlySizeText.on("change", () => this.updateOption("autoReadonlySizeText", this.$autoReadonlySizeText.val()));
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
async optionsLoaded(options: OptionMap) {
|
||||
this.$autoReadonlySizeText.val(options.autoReadonlySizeText);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user