Files
iTop/js/ckeditor/src/plugins/update-input-on-change/update-input-on-change.plugin.ts
Benjamin Dalsass d3b39048d8 N°5298 - Upgrade CKEditor to version 5
- remove fired event UPDATE in plugin update-input-on-change
effect: alert dialog on portal when adding image
known impact: validation on portal not triggered on textarea modification
2024-06-07 08:16:29 +02:00

32 lines
970 B
TypeScript

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) => {
// only when input and textarea are different
if(oInputElement.value !== oEditor.getData()) {
oInputElement.value = oEditor.getData();
// const oEvent = new Event('change');
// oInputElement.dispatchEvent(oEvent);
}
});
}
}
}