Skip to content

Commit

Permalink
client: Respect editor type choice
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Nov 9, 2024
1 parent 89420ea commit c421e75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/public/app/widgets/type_widgets/editable_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import utils from "../../../../services/utils.js";
import OptionsWidget from "../options_widget.js";

const TPL = `
Expand All @@ -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");
});
}

Expand Down

0 comments on commit c421e75

Please sign in to comment.