mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +02:00
N°5298 - Upgrade CKEditor to version 5 (#647)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { Plugin } from '@ckeditor/ckeditor5-core';
|
||||
import {ClassicEditor} from "@ckeditor/ckeditor5-editor-classic";
|
||||
|
||||
export default class UpdateInputOnChange extends Plugin {
|
||||
|
||||
static get pluginName() {
|
||||
return 'UpdateInputOnChange';
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
// retrieve editor instance
|
||||
const oEditor:ClassicEditor = this.editor as ClassicEditor;
|
||||
|
||||
if(oEditor.sourceElement !== undefined) {
|
||||
const oInputElement = oEditor.sourceElement as HTMLInputElement;
|
||||
|
||||
// update input when data change
|
||||
oEditor.model.document.on('change:data', (event) => {
|
||||
oInputElement.value = oEditor.getData();
|
||||
const oEvent = new Event('change');
|
||||
oInputElement.dispatchEvent(oEvent);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user