From 972a42917c10daeaae9f1dc0fc89787e4743f0e4 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Fri, 10 May 2019 16:14:48 +0200 Subject: [PATCH 1/4] Remove deprecated configuration option. --- src/tabletoolbar.js | 16 ++-------------- tests/tabletoolbar.js | 18 ++++-------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/tabletoolbar.js b/src/tabletoolbar.js index 28f2bc3e..a230fdaf 100644 --- a/src/tabletoolbar.js +++ b/src/tabletoolbar.js @@ -20,9 +20,6 @@ import WidgetToolbarRepository from '@ckeditor/ckeditor5-widget/src/widgettoolba * 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 } ); } diff --git a/tests/tabletoolbar.js b/tests/tabletoolbar.js index aeed55cf..faca1363 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'; @@ -239,12 +239,11 @@ describe( 'TableToolbar', () => { } ); describe( 'deprecated toolbar', () => { - let editor, editorElement, warnMock; + let editor, editorElement; - it( 'table.toolbar should work as table.contentToolbar', () => { + it( 'table.toolbar should not create toolbar any longer', () => { editorElement = global.document.createElement( 'div' ); global.document.body.appendChild( editorElement ); - warnMock = sinon.stub( window.console, 'warn' ); return ClassicTestEditor .create( editorElement, { @@ -257,23 +256,14 @@ describe( 'TableToolbar', () => { 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.' - ); + expect( widgetToolbarRepository._toolbarDefinitions.get( 'tableContent' ) ).to.be.undefined; } ); } ); 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, { From 4615d23f90878201257283a758207a8cea08ed63 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 14 May 2019 10:10:47 +0200 Subject: [PATCH 2/4] Update docs description and remove deprecated entry completely. --- src/tabletoolbar.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/tabletoolbar.js b/src/tabletoolbar.js index a230fdaf..1e5f25eb 100644 --- a/src/tabletoolbar.js +++ b/src/tabletoolbar.js @@ -15,7 +15,7 @@ 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}. @@ -64,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. From 9333c2a7d8c94b8d6ee1c0c57202161785046470 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 14 May 2019 10:13:07 +0200 Subject: [PATCH 3/4] Remove unit test responsible for testing deprecated entry. --- tests/tabletoolbar.js | 68 ------------------------------------------- 1 file changed, 68 deletions(-) diff --git a/tests/tabletoolbar.js b/tests/tabletoolbar.js index faca1363..0677b441 100644 --- a/tests/tabletoolbar.js +++ b/tests/tabletoolbar.js @@ -238,59 +238,6 @@ describe( 'TableToolbar', () => { } ); } ); - describe( 'deprecated toolbar', () => { - let editor, editorElement; - - it( 'table.toolbar should not create toolbar any longer', () => { - editorElement = global.document.createElement( 'div' ); - global.document.body.appendChild( editorElement ); - - return ClassicTestEditor - .create( editorElement, { - plugins: [ Paragraph, Table, TableToolbar, FakeButton ], - table: { - toolbar: [ 'fake_button' ] - } - } ) - .then( newEditor => { - editor = newEditor; - - const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository ); - - expect( widgetToolbarRepository._toolbarDefinitions.get( 'tableContent' ) ).to.be.undefined; - } ); - } ); - - it( 'table.contentToolbar should be used if both toolbars options are provided', () => { - editorElement = global.document.createElement( 'div' ); - global.document.body.appendChild( editorElement ); - - 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; @@ -472,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; - } ); - } -} From d64c08741e03225b892fd7d8bf26fc8d5e376595 Mon Sep 17 00:00:00 2001 From: Mateusz Samsel Date: Tue, 14 May 2019 10:18:10 +0200 Subject: [PATCH 4/4] Correct unit test name. --- tests/tabletoolbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tabletoolbar.js b/tests/tabletoolbar.js index 0677b441..21f90a96 100644 --- a/tests/tabletoolbar.js +++ b/tests/tabletoolbar.js @@ -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' ); } );