diff --git a/src/tabletoolbar.js b/src/tabletoolbar.js index 28f2bc3e..1e5f25eb 100644 --- a/src/tabletoolbar.js +++ b/src/tabletoolbar.js @@ -15,14 +15,11 @@ import WidgetToolbarRepository from '@ckeditor/ckeditor5-widget/src/widgettoolba * The table toolbar class. It creates toolbars for the table feature and its content (for now only for a table cell content). * * Table toolbar shows up when a table widget is selected. Its components (e.g. buttons) are created based on the - * {@link module:table/table~TableConfig#toolbar `table.tableToolbar` configuration option}. + * {@link module:table/table~TableConfig#tableToolbar `table.tableToolbar` configuration option}. * * Table content toolbar shows up when the selection is inside the content of a table. It creates its component based on the * {@link module:table/table~TableConfig#contentToolbar `table.contentToolbar` configuration option}. * - * Note that the old {@link module:table/table~TableConfig#toolbar `table.toolbar` configuration option} is deprecated - * and will be removed in the next major release. - * * @extends module:core/plugin~Plugin */ export default class TableToolbar extends Plugin { @@ -48,21 +45,12 @@ export default class TableToolbar extends Plugin { const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository ); const tableContentToolbarItems = editor.config.get( 'table.contentToolbar' ); - const deprecatedTableContentToolbarItems = editor.config.get( 'table.toolbar' ); const tableToolbarItems = editor.config.get( 'table.tableToolbar' ); - if ( deprecatedTableContentToolbarItems ) { - // eslint-disable-next-line - console.warn( - '`config.table.toolbar` is deprecated and will be removed in the next major release.' + - ' Use `config.table.contentToolbar` instead.' - ); - } - - if ( tableContentToolbarItems || deprecatedTableContentToolbarItems ) { + if ( tableContentToolbarItems ) { widgetToolbarRepository.register( 'tableContent', { - items: tableContentToolbarItems || deprecatedTableContentToolbarItems, + items: tableContentToolbarItems, getRelatedElement: getTableWidgetAncestor } ); } @@ -76,17 +64,6 @@ export default class TableToolbar extends Plugin { } } -/** - * Items to be placed in the table content toolbar. - * - * **Note:** This configuration option is deprecated! Use {@link module:table/table~TableConfig#contentToolbar} instead. - * - * Read more about configuring toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}. - * - * @deprecated - * @member {Array.} module:table/table~TableConfig#toolbar - */ - /** * Items to be placed in the table content toolbar. * The {@link module:table/tabletoolbar~TableToolbar} plugin is required to make this toolbar working. diff --git a/tests/tabletoolbar.js b/tests/tabletoolbar.js index aeed55cf..21f90a96 100644 --- a/tests/tabletoolbar.js +++ b/tests/tabletoolbar.js @@ -3,7 +3,7 @@ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ -/* global document, window */ +/* global document */ import ClassicTestEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; import TableToolbar from '../src/tabletoolbar'; @@ -77,7 +77,7 @@ describe( 'TableToolbar', () => { } ); describe( 'toolbar', () => { - it( 'should use the config.table.toolbar to create items', () => { + it( 'should use the config.table.contenToolbar to create items', () => { expect( toolbar.items ).to.have.length( 1 ); expect( toolbar.items.get( 0 ).label ).to.equal( 'fake button' ); } ); @@ -238,69 +238,6 @@ describe( 'TableToolbar', () => { } ); } ); - describe( 'deprecated toolbar', () => { - let editor, editorElement, warnMock; - - it( 'table.toolbar should work as table.contentToolbar', () => { - editorElement = global.document.createElement( 'div' ); - global.document.body.appendChild( editorElement ); - warnMock = sinon.stub( window.console, 'warn' ); - - return ClassicTestEditor - .create( editorElement, { - plugins: [ Paragraph, Table, TableToolbar, FakeButton ], - table: { - toolbar: [ 'fake_button' ] - } - } ) - .then( newEditor => { - editor = newEditor; - - const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository ); - const toolbarView = widgetToolbarRepository._toolbarDefinitions.get( 'tableContent' ).view; - - expect( toolbarView.items ).to.have.length( 1 ); - expect( toolbarView.items.get( 0 ).label ).to.equal( 'fake button' ); - - sinon.assert.calledWith( - warnMock, - '`config.table.toolbar` is deprecated and will be removed in the next major release.' + - ' Use `config.table.contentToolbar` instead.' - ); - } ); - } ); - - it( 'table.contentToolbar should be used if both toolbars options are provided', () => { - editorElement = global.document.createElement( 'div' ); - global.document.body.appendChild( editorElement ); - warnMock = sinon.stub( window.console, 'warn' ); - - return ClassicTestEditor - .create( editorElement, { - plugins: [ Paragraph, Table, TableToolbar, FakeButton, FooButton ], - table: { - toolbar: [ 'fake_button' ], - contentToolbar: [ 'foo_button' ], - } - } ) - .then( newEditor => { - editor = newEditor; - - const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository ); - const toolbarView = widgetToolbarRepository._toolbarDefinitions.get( 'tableContent' ).view; - - expect( toolbarView.items ).to.have.length( 1 ); - expect( toolbarView.items.get( 0 ).label ).to.equal( 'foo button' ); - } ); - } ); - - afterEach( () => { - editorElement.remove(); - - return editor.destroy(); - } ); - } ); - describe( 'tableToolbar', () => { let editor, element, widgetToolbarRepository, balloon, toolbar, model; @@ -482,18 +419,3 @@ class FakeButton extends Plugin { } ); } } - -// Plugin that adds foo_button to editor's component factory. -class FooButton extends Plugin { - init() { - this.editor.ui.componentFactory.add( 'foo_button', locale => { - const view = new ButtonView( locale ); - - view.set( { - label: 'foo button' - } ); - - return view; - } ); - } -}