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