mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-12 20:02:28 +08:00
feat(code): move preview to apperance
This commit is contained in:
parent
21a72ab265
commit
4e18798850
@ -10,30 +10,19 @@ const TPL = /*html*/`
|
|||||||
${t("vim_key_bindings.use_vim_keybindings_in_code_notes")}
|
${t("vim_key_bindings.use_vim_keybindings_in_code_notes")}
|
||||||
</label>
|
</label>
|
||||||
<p class="form-text">${t("vim_key_bindings.enable_vim_keybindings")}</p>
|
<p class="form-text">${t("vim_key_bindings.enable_vim_keybindings")}</p>
|
||||||
|
|
||||||
<label class="tn-checkbox">
|
|
||||||
<input type="checkbox" class="line-wrap-enabled form-check-input">
|
|
||||||
${t("wrap_lines.wrap_lines_in_code_notes")}
|
|
||||||
</label>
|
|
||||||
<p class="form-text">${t("wrap_lines.enable_line_wrap")}</p>
|
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class CodeEditorOptions extends OptionsWidget {
|
export default class CodeEditorOptions extends OptionsWidget {
|
||||||
|
|
||||||
private $vimKeymapEnabled!: JQuery<HTMLElement>;
|
private $vimKeymapEnabled!: JQuery<HTMLElement>;
|
||||||
private $codeLineWrapEnabled!: JQuery<HTMLElement>;
|
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.$vimKeymapEnabled = this.$widget.find(".vim-keymap-enabled");
|
this.$vimKeymapEnabled = this.$widget.find(".vim-keymap-enabled");
|
||||||
this.$vimKeymapEnabled.on("change", () => this.updateCheckboxOption("vimKeymapEnabled", this.$vimKeymapEnabled));
|
this.$vimKeymapEnabled.on("change", () => this.updateCheckboxOption("vimKeymapEnabled", this.$vimKeymapEnabled));
|
||||||
|
|
||||||
this.$codeLineWrapEnabled = this.$widget.find(".line-wrap-enabled");
|
|
||||||
this.$codeLineWrapEnabled.on("change", () => this.updateCheckboxOption("codeLineWrapEnabled", this.$codeLineWrapEnabled));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async optionsLoaded(options: OptionMap) {
|
async optionsLoaded(options: OptionMap) {
|
||||||
this.setCheckboxState(this.$vimKeymapEnabled, options.vimKeymapEnabled);
|
this.setCheckboxState(this.$vimKeymapEnabled, options.vimKeymapEnabled);
|
||||||
this.setCheckboxState(this.$codeLineWrapEnabled, options.codeLineWrapEnabled);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,13 @@ const TPL = /*html*/`\
|
|||||||
<label for="color-theme">Color scheme</label>
|
<label for="color-theme">Color scheme</label>
|
||||||
<select id="color-theme" class="theme-select form-select"></select>
|
<select id="color-theme" class="theme-select form-select"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 side-checkbox">
|
||||||
|
<label class="form-check tn-checkbox">
|
||||||
|
<input type="checkbox" class="word-wrap form-check-input" />
|
||||||
|
Word Wrapping
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="note-detail-readonly-code-content">
|
<div class="note-detail-readonly-code-content">
|
||||||
@ -111,6 +118,7 @@ export default class CodeTheme extends OptionsWidget {
|
|||||||
|
|
||||||
private $themeSelect!: JQuery<HTMLElement>;
|
private $themeSelect!: JQuery<HTMLElement>;
|
||||||
private $sampleEl!: JQuery<HTMLElement>;
|
private $sampleEl!: JQuery<HTMLElement>;
|
||||||
|
private $lineWrapEnabled!: JQuery<HTMLElement>;
|
||||||
private editor?: CodeMirror;
|
private editor?: CodeMirror;
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
@ -121,6 +129,8 @@ export default class CodeTheme extends OptionsWidget {
|
|||||||
await server.put(`options/codeNoteTheme/${newTheme}`);
|
await server.put(`options/codeNoteTheme/${newTheme}`);
|
||||||
});
|
});
|
||||||
this.$sampleEl = this.$widget.find(".note-detail-readonly-code-content");
|
this.$sampleEl = this.$widget.find(".note-detail-readonly-code-content");
|
||||||
|
this.$lineWrapEnabled = this.$widget.find(".word-wrap");
|
||||||
|
this.$lineWrapEnabled.on("change", () => this.updateCheckboxOption("codeLineWrapEnabled", this.$lineWrapEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
async #setupPreview(options: OptionMap) {
|
async #setupPreview(options: OptionMap) {
|
||||||
@ -153,6 +163,7 @@ export default class CodeTheme extends OptionsWidget {
|
|||||||
|
|
||||||
this.$themeSelect.val(options.codeNoteTheme);
|
this.$themeSelect.val(options.codeNoteTheme);
|
||||||
this.#setupPreview(options);
|
this.#setupPreview(options);
|
||||||
|
this.setCheckboxState(this.$lineWrapEnabled, options.codeLineWrapEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user