mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 11:02:27 +08:00
client: Respect editor type choice
This commit is contained in:
parent
89420eafa3
commit
c421e75f55
@ -12,7 +12,6 @@ import appContext from "../../components/app_context.js";
|
|||||||
import dialogService from "../../services/dialog.js";
|
import dialogService from "../../services/dialog.js";
|
||||||
import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";
|
import { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";
|
||||||
import options from "../../services/options.js";
|
import options from "../../services/options.js";
|
||||||
import { isSyntaxHighlightEnabled } from "../../services/syntax_highlight.js";
|
|
||||||
|
|
||||||
const ENABLE_INSPECTOR = false;
|
const ENABLE_INSPECTOR = false;
|
||||||
|
|
||||||
@ -131,7 +130,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
async initEditor() {
|
async initEditor() {
|
||||||
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
||||||
const editorClass = CKEditor.DecoupledEditor;
|
const isClassicEditor = (options.get("textNoteEditorType") === "ckeditor-classic")
|
||||||
|
const editorClass = (isClassicEditor ? CKEditor.DecoupledEditor : CKEditor.BalloonEditor);
|
||||||
|
|
||||||
const codeBlockLanguages = buildListOfLanguages();
|
const codeBlockLanguages = buildListOfLanguages();
|
||||||
|
|
||||||
@ -180,10 +180,12 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
await initSyntaxHighlighting(editor);
|
await initSyntaxHighlighting(editor);
|
||||||
|
|
||||||
const $parentSplit = this.$widget.parents(".note-split.type-text");
|
if (isClassicEditor) {
|
||||||
const $classicToolbarWidget = $parentSplit.find("> .ribbon-container .classic-toolbar-widget");
|
const $parentSplit = this.$widget.parents(".note-split.type-text");
|
||||||
$classicToolbarWidget.empty();
|
const $classicToolbarWidget = $parentSplit.find("> .ribbon-container .classic-toolbar-widget");
|
||||||
$classicToolbarWidget[0].appendChild(editor.ui.view.toolbar.element);
|
$classicToolbarWidget.empty();
|
||||||
|
$classicToolbarWidget[0].appendChild(editor.ui.view.toolbar.element);
|
||||||
|
}
|
||||||
|
|
||||||
editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
|
editor.model.document.on('change:data', () => this.spacedUpdate.scheduleUpdate());
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import utils from "../../../../services/utils.js";
|
||||||
import OptionsWidget from "../options_widget.js";
|
import OptionsWidget from "../options_widget.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
@ -20,9 +21,10 @@ export default class EditorOptions extends OptionsWidget {
|
|||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.$body = $("body");
|
this.$body = $("body");
|
||||||
this.$editorType = this.$widget.find(".editor-type-select");
|
this.$editorType = this.$widget.find(".editor-type-select");
|
||||||
this.$editorType.on('change', () => {
|
this.$editorType.on('change', async () => {
|
||||||
const newEditorType = this.$editorType.val();
|
const newEditorType = this.$editorType.val();
|
||||||
this.updateOption('textNoteEditorType', newEditorType);
|
await this.updateOption('textNoteEditorType', newEditorType);
|
||||||
|
utils.reloadFrontendApp("editor type change");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user