mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Fix CKEditor change detector being misled by insert carriage plugin
This commit is contained in:
2
js/ckeditor/build/ckeditor.js
vendored
2
js/ckeditor/build/ckeditor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,10 +1,13 @@
|
||||
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
||||
import InsertCarriageReturnAfterBlock from "../insert-carriage-return-after-block/insert-carriage-return-after-block.plugin";
|
||||
/**
|
||||
* DetectChanges Plugin.
|
||||
*
|
||||
*/
|
||||
export default class DetectChanges extends Plugin {
|
||||
private readonly _processor;
|
||||
constructor(editor: Editor);
|
||||
init(): void;
|
||||
static get pluginName(): string;
|
||||
static get requires(): (typeof InsertCarriageReturnAfterBlock)[];
|
||||
}
|
||||
|
||||
@@ -212,7 +212,25 @@ class Editor extends ClassicEditor {
|
||||
'tableProperties',
|
||||
'|',
|
||||
'toggleTableCaption'
|
||||
]
|
||||
],
|
||||
tableProperties: {
|
||||
// The default styles for tables in the editor.
|
||||
// They should be synchronized with the content styles.
|
||||
defaultProperties: {
|
||||
borderStyle: 'dashed',
|
||||
borderColor: 'hsl(90, 75%, 60%)',
|
||||
borderWidth: '1px',
|
||||
},
|
||||
},
|
||||
// The default styles for table cells in the editor.
|
||||
// They should be synchronized with the content styles.
|
||||
tableCellProperties: {
|
||||
defaultProperties: {
|
||||
borderStyle: 'dashed',
|
||||
borderColor: 'hsl(90, 75%, 60%)',
|
||||
borderWidth: '1px',
|
||||
}
|
||||
}
|
||||
},
|
||||
htmlSupport: {
|
||||
allow: [
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
||||
import iTopDataProcessor from "./itop-data-processor";
|
||||
import InsertCarriageReturnAfterBlock from "../insert-carriage-return-after-block/insert-carriage-return-after-block.plugin";
|
||||
|
||||
/**
|
||||
* DetectChanges Plugin.
|
||||
*
|
||||
*/
|
||||
export default class DetectChanges extends Plugin {
|
||||
|
||||
private readonly _processor: iTopDataProcessor | undefined;
|
||||
|
||||
constructor( editor: Editor ) {
|
||||
super( editor );
|
||||
const sInitialValue:string = editor.config.get('detectChanges.initialValue') as string;
|
||||
@@ -17,15 +19,23 @@ export default class DetectChanges extends Plugin {
|
||||
// Initialize our own data processor
|
||||
const oProcessor = new iTopDataProcessor( editor.data.viewDocument, sInitialValue, editor.getData() ) as iTopDataProcessor;
|
||||
editor.data.processor = oProcessor;
|
||||
// Listen for the dataReady event only once
|
||||
editor.model.document.once('change:data', () => {
|
||||
oProcessor.setTransformedInitialValue( editor.getData());
|
||||
});
|
||||
this._processor = oProcessor;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const editor = this.editor;// Listen for the dataReady event only once
|
||||
editor.model.document.once('change:data', () => {
|
||||
if(this._processor ) {
|
||||
this._processor.setTransformedInitialValue(editor.getData());
|
||||
}
|
||||
});
|
||||
}
|
||||
static get pluginName() {
|
||||
return 'DetectChanges';
|
||||
}
|
||||
|
||||
// Needed as InsertCarriageReturnAfterBlock will possibly change data on initialization if there's a block in the content, so we need to make sure it's loaded first
|
||||
static get requires() {
|
||||
return [ InsertCarriageReturnAfterBlock ];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user