diff --git a/src/tableediting.js b/src/tableediting.js index fccabd79..2b68f4e9 100644 --- a/src/tableediting.js +++ b/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 ) ); } /** diff --git a/src/tableselection.js b/src/tableselection.js index d631d682..0cad9041 100644 --- a/src/tableselection.js +++ b/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; diff --git a/tests/manual/tableselection.js b/tests/manual/tableselection.js index d9317902..eb841fdf 100644 --- a/tests/manual/tableselection.js +++ b/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' ],