8
0
Quellcode durchsuchen

Make TableSelection an editor plugin.

Maciej Gołaszewski vor 5 Jahren
Ursprung
Commit
810e61164c

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

@@ -36,7 +36,6 @@ import injectTableCellParagraphPostFixer from './converters/table-cell-paragraph
 import injectTableCellRefreshPostFixer from './converters/table-cell-refresh-post-fixer';
 
 import '../theme/tableediting.css';
-import TableSelection from './tableselection';
 
 /**
  * The table editing feature.
@@ -145,9 +144,6 @@ export default class TableEditing extends Plugin {
 		this.editor.keystrokes.set( 'Tab', ( ...args ) => this._handleTabOnSelectedTable( ...args ), { priority: 'low' } );
 		this.editor.keystrokes.set( 'Tab', this._getTabHandler( true ), { priority: 'low' } );
 		this.editor.keystrokes.set( 'Shift+Tab', this._getTabHandler( false ), { priority: 'low' } );
-
-		this.tableSelection = new TableSelection();
-		this.tableSelection.attach( editor, this.editor.plugins.get( TableUtils ) );
 	}
 
 	/**

+ 8 - 7
packages/ckeditor5-table/src/tableselection.js

@@ -11,19 +11,20 @@ import TableWalker from './tablewalker';
 import { findAncestor } from './commands/utils';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
 // TODO: refactor to an Observer
-export default class TableSelection {
-	constructor() {
+export default class TableSelection extends Plugin {
+	constructor( editor ) {
+		super( editor );
+
 		this._isSelecting = false;
 		this._highlighted = new Set();
 	}
 
-	// OWN mouse events?
-	attach( editor, tableUtils ) {
-		// table selection observer...?
-		this.tableUtils = tableUtils;
-		this.editor = editor;
+	init() {
+		const editor = this.editor;
+		this.tableUtils = editor.plugins.get( 'TableUtils' );
 
 		const viewDocument = editor.editing.view.document;
 

+ 2 - 1
packages/ckeditor5-table/tests/manual/tableselection.js

@@ -10,10 +10,11 @@ import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articleplugi
 import Table from '../../src/table';
 import TableToolbar from '../../src/tabletoolbar';
 import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import TableSelection from '../../src/tableselection';
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
-		plugins: [ ArticlePluginSet, Table, TableToolbar ],
+		plugins: [ ArticlePluginSet, Table, TableToolbar, TableSelection ],
 		toolbar: [
 			'heading', '|', 'insertTable', '|', 'bold', 'italic', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo'
 		],