mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +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 { initSyntaxHighlighting } from "./ckeditor/syntax_highlight.js";
|
||||
import options from "../../services/options.js";
|
||||
import { isSyntaxHighlightEnabled } from "../../services/syntax_highlight.js";
|
||||
|
||||
const ENABLE_INSPECTOR = false;
|
||||
|
||||
@ -131,7 +130,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
|
||||
async initEditor() {
|
||||
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();
|
||||
|
||||
@ -180,10 +180,12 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
|
||||
await initSyntaxHighlighting(editor);
|
||||
|
||||
const $parentSplit = this.$widget.parents(".note-split.type-text");
|
||||
const $classicToolbarWidget = $parentSplit.find("> .ribbon-container .classic-toolbar-widget");
|
||||
$classicToolbarWidget.empty();
|
||||
$classicToolbarWidget[0].appendChild(editor.ui.view.toolbar.element);
|
||||
if (isClassicEditor) {
|
||||
const $parentSplit = this.$widget.parents(".note-split.type-text");
|
||||
const $classicToolbarWidget = $parentSplit.find("> .ribbon-container .classic-toolbar-widget");
|
||||
$classicToolbarWidget.empty();
|
||||
$classicToolbarWidget[0].appendChild(editor.ui.view.toolbar.element);
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
const TPL = `
|
||||
@ -20,9 +21,10 @@ export default class EditorOptions extends OptionsWidget {
|
||||
this.$widget = $(TPL);
|
||||
this.$body = $("body");
|
||||
this.$editorType = this.$widget.find(".editor-type-select");
|
||||
this.$editorType.on('change', () => {
|
||||
this.$editorType.on('change', async () => {
|
||||
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