8
0
Просмотр исходного кода

Passing elements' names that should have separate selection ranges through config.

Kuba Niegowski 5 лет назад
Родитель
Сommit
8177d62046

+ 8 - 0
packages/ckeditor5-table/src/tableediting.js

@@ -146,6 +146,14 @@ export default class TableEditing extends Plugin {
 		injectTableLayoutPostFixer( model );
 		injectTableCellRefreshPostFixer( model );
 		injectTableCellParagraphPostFixer( model );
+
+		const undoElementsWithSeparateSelectionRanges = editor.config.get( 'undo.elementsWithSeparateSelectionRanges' ) || [];
+
+		if ( !undoElementsWithSeparateSelectionRanges.includes( 'tableCell' ) ) {
+			undoElementsWithSeparateSelectionRanges.push( 'tableCell' );
+
+			editor.config.set( 'undo.elementsWithSeparateSelectionRanges', undoElementsWithSeparateSelectionRanges );
+		}
 	}
 
 	/**

+ 1 - 1
packages/ckeditor5-undo/src/basecommand.js

@@ -96,7 +96,7 @@ export default class BaseCommand extends Command {
 			.sort( ( a, b ) => a.start.isBefore( b.start ) ? -1 : 1 );
 
 		normalizeRanges( selectionRanges );
-		normalizeRanges( selectionRanges, [ 'tableCell' ] );
+		normalizeRanges( selectionRanges, this.editor.config.get( 'undo.elementsWithSeparateSelectionRanges' ) || [] );
 
 		// @if CK_DEBUG_ENGINE // console.log( `Restored selection from undo: ${ selectionRanges.join( ', ' ) }` );
 

+ 2 - 0
packages/ckeditor5-undo/src/undoediting.js

@@ -55,6 +55,8 @@ export default class UndoEditing extends Plugin {
 		 * @member {WeakSet.<module:engine/model/batch~Batch>}
 		 */
 		this._batchRegistry = new WeakSet();
+
+		editor.config.define( 'undo.elementsWithSeparateSelectionRanges', [] );
 	}
 
 	/**