浏览代码

Renamed toolbarItems to items.

Maciej Bukowski 7 年之前
父节点
当前提交
602dde5776

+ 5 - 5
packages/ckeditor5-widget/src/widgettoolbarrepository.js

@@ -32,7 +32,7 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  *				const widgetToolbarRepository = editor.plugins.get( WidgetToolbarRepository );
  *
  *				widgetToolbarRepository.register( 'image', {
- *					toolbarItems: editor.config.get( 'image.toolbar' ),
+ *					items: editor.config.get( 'image.toolbar' ),
  *					visibleWhen: viewSelection => isImageWidgetSelected( viewSelection )
  *				} );
  *			}
@@ -94,7 +94,7 @@ export default class WidgetToolbarRepository extends Plugin {
 
 	/**
 	 * Registers toolbar in the WidgetToolbarRepository. It renders it in the `ContextualBalloon` based on the value of the invoked
-	 * `visibleWhen` function. Toolbar items are gathered from `toolbarItems` array.
+	 * `visibleWhen` function. Toolbar items are gathered from `items` array.
 	 * The balloon's CSS class is by default `ck-toolbar-container` and may be override with the `balloonClassName` option.
 	 *
 	 * Note: This method should be called in the {@link module:core/plugin~PluginInterface#afterInit `Plugin#afterInit()`}
@@ -102,11 +102,11 @@ export default class WidgetToolbarRepository extends Plugin {
 	 *
 	 * @param {String} toolbarId An id for the toolbar. Used to
 	 * @param {Object} options
-	 * @param {Array.<String>} options.toolbarItems Array of toolbar items.
+	 * @param {Array.<String>} options.items Array of toolbar items.
 	 * @param {Function} options.visibleWhen Callback which specifies when the toolbar should be visible for the widget.
 	 * @param {String} [options.balloonClassName='ck-toolbar-container'] CSS class for the widget balloon.
 	 */
-	register( toolbarId, { toolbarItems, visibleWhen, balloonClassName = 'ck-toolbar-container' } ) {
+	register( toolbarId, { items, visibleWhen, balloonClassName = 'ck-toolbar-container' } ) {
 		const editor = this.editor;
 		const toolbarView = new ToolbarView();
 
@@ -120,7 +120,7 @@ export default class WidgetToolbarRepository extends Plugin {
 			throw new CKEditorError( 'widget-toolbar-duplicated: Toolbar with the given id was already added.', { toolbarId } );
 		}
 
-		toolbarView.fillFromConfig( toolbarItems, editor.ui.componentFactory );
+		toolbarView.fillFromConfig( items, editor.ui.componentFactory );
 
 		this._toolbars.set( toolbarId, {
 			view: toolbarView,

+ 11 - 11
packages/ckeditor5-widget/tests/widgettoolbarrepository.js

@@ -59,7 +59,7 @@ describe( 'WidgetToolbarRepository', () => {
 	describe( 'register()', () => {
 		it( 'should create a widget toolbar and add it to the collection', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: () => false,
 			} );
 
@@ -69,13 +69,13 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'should throw when adding two times widget with the same id', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: () => false
 			} );
 
 			expect( () => {
 				widgetToolbarRepository.register( 'fake', {
-					toolbarItems: editor.config.get( 'fake.toolbar' ),
+					items: editor.config.get( 'fake.toolbar' ),
 					visibleWhen: () => false
 				} );
 			} ).to.throw( CKEditorError, /^widget-toolbar-duplicated/ );
@@ -89,7 +89,7 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'toolbar should be visible when the `visibleWhen` callback returns true', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: isFakeWidgetSelected
 			} );
 
@@ -102,7 +102,7 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'toolbar should be hidden when the `visibleWhen` callback returns false', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: isFakeWidgetSelected
 			} );
 
@@ -113,7 +113,7 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'toolbar should be hidden when the `visibleWhen` callback returns false #2', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: isFakeWidgetSelected
 			} );
 
@@ -129,7 +129,7 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'toolbar should update its position when other widget is selected', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: isFakeWidgetSelected
 			} );
 
@@ -147,7 +147,7 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'it should be possible to create a widget toolbar for content inside the widget', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: isFakeWidgetContentSelected
 			} );
 
@@ -160,7 +160,7 @@ describe( 'WidgetToolbarRepository', () => {
 
 		it( 'toolbar should not engage when is in the balloon yet invisible', () => {
 			widgetToolbarRepository.register( 'fake', {
-				toolbarItems: editor.config.get( 'fake.toolbar' ),
+				items: editor.config.get( 'fake.toolbar' ),
 				visibleWhen: isFakeWidgetSelected
 			} );
 
@@ -226,7 +226,7 @@ describe( 'WidgetToolbarRepository - integration with the BalloonToolbar', () =>
 
 	it( 'balloon toolbar should be hidden when the widget is selected', () => {
 		widgetToolbarRepository.register( 'fake', {
-			toolbarItems: editor.config.get( 'fake.toolbar' ),
+			items: editor.config.get( 'fake.toolbar' ),
 			visibleWhen: isFakeWidgetSelected,
 		} );
 
@@ -242,7 +242,7 @@ describe( 'WidgetToolbarRepository - integration with the BalloonToolbar', () =>
 
 	it( 'balloon toolbar should be visible when the widget is not selected', () => {
 		widgetToolbarRepository.register( 'fake', {
-			toolbarItems: editor.config.get( 'fake.toolbar' ),
+			items: editor.config.get( 'fake.toolbar' ),
 			visibleWhen: isFakeWidgetSelected
 		} );