Use CKEditor 5 for description editing.

This commit is contained in:
Jan Böhmer 2022-07-26 01:20:58 +02:00
parent a4f07e9b82
commit 63b7e0458c
11 changed files with 527 additions and 75 deletions

View file

@ -2,6 +2,10 @@ import {Controller} from "@hotwired/stimulus";
import { default as FullEditor } from "../../ckeditor/markdown_full";
import { default as SingleLineEditor} from "../../ckeditor/markdown_single_line";
import { default as HTMLEditor } from "../../ckeditor/html_full";
import EditorWatchdog from '@ckeditor/ckeditor5-watchdog/src/editorwatchdog';
/* stimulusFetch: 'lazy' */
export default class extends Controller {
@ -13,23 +17,46 @@ export default class extends Controller {
if(output_format == 'markdown') {
if(mode == 'full') {
EDITOR_TYPE = FullEditor;
EDITOR_TYPE = FullEditor['Editor'];
} else if(mode == 'single_line') {
EDITOR_TYPE = SingleLineEditor;
EDITOR_TYPE = SingleLineEditor['Editor'];
}
} else if(output_format == 'html') {
EDITOR_TYPE = HTMLEditor['Editor'];
} else {
console.error("Unknown output format: " + output-format);
return;
}
this.editor = EDITOR_TYPE.create(this.element, {
})
EDITOR_TYPE.create(this.element)
.then(editor => {
if(this.element.disabled) {
editor.enableReadOnlyMode("readonly");
}
console.log(editor);
})
.catch(error => {
console.error(error);
});
/* const watchdog = new EditorWatchdog();
watchdog.setCreator((elementOrData, editorConfig) => {
return EDITOR_TYPE.create(elementOrData, editorConfig)
.then(editor => {
if(this.element.disabled) {
editor.enableReadOnlyMode("readonly");
}
console.log(editor);
})
.catch(error => {
console.error(error);
});
});
watchdog.create(this.element, {
});*/
}
}