Przeglądaj źródła

Aligned code to changes in the WidgetToolbarRepository.

Maciej Bukowski 7 lat temu
rodzic
commit
b7d3168832

+ 5 - 5
packages/ckeditor5-table/src/tabletoolbar.js

@@ -9,7 +9,7 @@
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import { isTableContentSelected } from './utils';
-import WidgetToolbar from '@ckeditor/ckeditor5-widget/src/widgettoolbar';
+import WidgetToolbarRepository from '@ckeditor/ckeditor5-widget/src/widgettoolbarrepository';
 
 /**
  * The table toolbar class. It creates a table toolbar that shows up when the table widget is selected.
@@ -27,7 +27,7 @@ export default class TableToolbar extends Plugin {
 	 * @inheritDoc
 	 */
 	static get requires() {
-		return [ WidgetToolbar ];
+		return [ WidgetToolbarRepository ];
 	}
 
 	/**
@@ -42,11 +42,11 @@ export default class TableToolbar extends Plugin {
 	 */
 	afterInit() {
 		const editor = this.editor;
-		const widgetToolbar = editor.plugins.get( 'WidgetToolbar' );
+		const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
 
-		widgetToolbar.add( 'table', {
+		widgetToolbarRepository.register( 'table', {
 			toolbarItems: editor.config.get( 'table.toolbar' ) || [],
-			isVisible: isTableContentSelected,
+			visibleWhen: isTableContentSelected,
 		} );
 	}
 }

+ 3 - 3
packages/ckeditor5-table/tests/tabletoolbar.js

@@ -17,7 +17,7 @@ import View from '@ckeditor/ckeditor5-ui/src/view';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'TableToolbar', () => {
-	let editor, model, doc, widgetToolbar, toolbar, balloon, editorElement;
+	let editor, model, doc, widgetToolbarRepository, toolbar, balloon, editorElement;
 
 	beforeEach( () => {
 		editorElement = global.document.createElement( 'div' );
@@ -34,8 +34,8 @@ describe( 'TableToolbar', () => {
 				editor = newEditor;
 				model = newEditor.model;
 				doc = model.document;
-				widgetToolbar = editor.plugins.get( 'WidgetToolbar' );
-				toolbar = widgetToolbar._toolbars.get( 'table' ).view;
+				widgetToolbarRepository = editor.plugins.get( 'WidgetToolbarRepository' );
+				toolbar = widgetToolbarRepository._toolbars.get( 'table' ).view;
 				balloon = editor.plugins.get( 'ContextualBalloon' );
 			} );
 	} );