Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Make TableSelection an editor plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Jan 23, 2020
1 parent 9f91cf7 commit 844cc27
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ) );
}

/**
Expand Down
15 changes: 8 additions & 7 deletions src/tableselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion tests/manual/tableselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
],
Expand Down

0 comments on commit 844cc27

Please sign in to comment.