From 1cadbb94bd938135401da7c14ea7c44a9cddac7e Mon Sep 17 00:00:00 2001 From: Monica Kozbial <6621618+moniika@users.noreply.github.com> Date: Thu, 27 May 2021 16:14:33 -0700 Subject: [PATCH] Rename PluginManager and related elements (#4857) * Rename PluginManager and related elements to use component instead of plugin * Rename types to capabilities --- blockly_uncompressed.js | 9 +- core/component_manager.js | 138 ++++++++++++++++++++++++++ core/interfaces/i_component.js | 24 +++++ core/interfaces/i_plugin.js | 22 ---- core/interfaces/i_positionable.js | 6 +- core/interfaces/i_workspace_plugin.js | 20 ---- core/plugin_manager.js | 136 ------------------------- core/trashcan.js | 2 +- core/workspace_svg.js | 32 +++--- core/zoom_controls.js | 2 +- 10 files changed, 187 insertions(+), 204 deletions(-) create mode 100644 core/component_manager.js create mode 100644 core/interfaces/i_component.js delete mode 100644 core/interfaces/i_plugin.js delete mode 100644 core/interfaces/i_workspace_plugin.js delete mode 100644 core/plugin_manager.js diff --git a/blockly_uncompressed.js b/blockly_uncompressed.js index 1407d8793..e2e7f96ac 100644 --- a/blockly_uncompressed.js +++ b/blockly_uncompressed.js @@ -32,6 +32,7 @@ goog.addDependency('../../core/browser_events.js', ['Blockly.browserEvents'], [' goog.addDependency('../../core/bubble.js', ['Blockly.Bubble'], ['Blockly.IBubble', 'Blockly.Scrollbar', 'Blockly.Touch', 'Blockly.Workspace', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.userAgent']); goog.addDependency('../../core/bubble_dragger.js', ['Blockly.BubbleDragger'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.CommentMove', 'Blockly.constants', 'Blockly.utils', 'Blockly.utils.Coordinate']); goog.addDependency('../../core/comment.js', ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.Warning', 'Blockly.browserEvents', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent']); +goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], []); goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.utils.deprecation']); goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.IConnectionChecker', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.registry']); goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Blockly.RenderedConnection', 'Blockly.connectionTypes', 'Blockly.constants']); @@ -87,6 +88,7 @@ goog.addDependency('../../core/insertion_marker_manager.js', ['Blockly.Insertion goog.addDependency('../../core/interfaces/i_accessibility.js', ['Blockly.IASTNodeLocation', 'Blockly.IASTNodeLocationSvg', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.IKeyboardAccessible'], []); goog.addDependency('../../core/interfaces/i_bounded_element.js', ['Blockly.IBoundedElement'], []); goog.addDependency('../../core/interfaces/i_bubble.js', ['Blockly.IBubble'], ['Blockly.IContextMenu', 'Blockly.IDeletable']); +goog.addDependency('../../core/interfaces/i_component.js', ['Blockly.IComponent'], []); goog.addDependency('../../core/interfaces/i_connection_checker.js', ['Blockly.IConnectionChecker'], []); goog.addDependency('../../core/interfaces/i_contextmenu.js', ['Blockly.IContextMenu'], []); goog.addDependency('../../core/interfaces/i_copyable.js', ['Blockly.ICopyable'], []); @@ -95,15 +97,13 @@ goog.addDependency('../../core/interfaces/i_deletearea.js', ['Blockly.IDeleteAre goog.addDependency('../../core/interfaces/i_flyout.js', ['Blockly.IFlyout'], []); goog.addDependency('../../core/interfaces/i_metrics_manager.js', ['Blockly.IMetricsManager'], []); goog.addDependency('../../core/interfaces/i_movable.js', ['Blockly.IMovable'], []); -goog.addDependency('../../core/interfaces/i_plugin.js', ['Blockly.IPlugin'], []); -goog.addDependency('../../core/interfaces/i_positionable.js', ['Blockly.IPositionable'], ['Blockly.IPlugin']); +goog.addDependency('../../core/interfaces/i_positionable.js', ['Blockly.IPositionable'], ['Blockly.IComponent']); goog.addDependency('../../core/interfaces/i_registrable.js', ['Blockly.IRegistrable'], []); goog.addDependency('../../core/interfaces/i_registrable_field.js', ['Blockly.IRegistrableField'], []); goog.addDependency('../../core/interfaces/i_selectable.js', ['Blockly.ISelectable'], []); goog.addDependency('../../core/interfaces/i_styleable.js', ['Blockly.IStyleable'], []); goog.addDependency('../../core/interfaces/i_toolbox.js', ['Blockly.IToolbox'], []); goog.addDependency('../../core/interfaces/i_toolbox_item.js', ['Blockly.ICollapsibleToolboxItem', 'Blockly.ISelectableToolboxItem', 'Blockly.IToolboxItem'], []); -goog.addDependency('../../core/interfaces/i_workspace_plugin.js', ['Blockly.IWorkspacePlugin'], []); goog.addDependency('../../core/keyboard_nav/ast_node.js', ['Blockly.ASTNode'], ['Blockly.connectionTypes', 'Blockly.constants', 'Blockly.utils.Coordinate'], {'lang': 'es5'}); goog.addDependency('../../core/keyboard_nav/basic_cursor.js', ['Blockly.BasicCursor'], ['Blockly.ASTNode', 'Blockly.Cursor', 'Blockly.registry'], {'lang': 'es5'}); goog.addDependency('../../core/keyboard_nav/cursor.js', ['Blockly.Cursor'], ['Blockly.ASTNode', 'Blockly.Marker', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es5'}); @@ -117,7 +117,6 @@ goog.addDependency('../../core/msg.js', ['Blockly.Msg'], ['Blockly.utils.global' goog.addDependency('../../core/mutator.js', ['Blockly.Mutator'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.Options', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.utils', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox', 'Blockly.utils.xml']); goog.addDependency('../../core/names.js', ['Blockly.Names'], ['Blockly.Msg', 'Blockly.constants']); goog.addDependency('../../core/options.js', ['Blockly.Options'], ['Blockly.Theme', 'Blockly.Themes.Classic', 'Blockly.registry', 'Blockly.utils.IdGenerator', 'Blockly.utils.Metrics', 'Blockly.utils.toolbox']); -goog.addDependency('../../core/plugin_manager.js', ['Blockly.PluginManager'], []); goog.addDependency('../../core/positionable_helpers.js', ['Blockly.uiPosition'], ['Blockly.Scrollbar', 'Blockly.utils.Rect', 'Blockly.utils.toolbox']); goog.addDependency('../../core/procedures.js', ['Blockly.Procedures'], ['Blockly.Blocks', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.Names', 'Blockly.Workspace', 'Blockly.Xml', 'Blockly.constants', 'Blockly.utils.xml']); goog.addDependency('../../core/registry.js', ['Blockly.registry'], []); @@ -214,7 +213,7 @@ goog.addDependency('../../core/workspace_comment_render_svg.js', ['Blockly.Works goog.addDependency('../../core/workspace_comment_svg.js', ['Blockly.WorkspaceCommentSvg'], ['Blockly.Css', 'Blockly.Events', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.Events.Selected', 'Blockly.WorkspaceComment', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object']); goog.addDependency('../../core/workspace_drag_surface_svg.js', ['Blockly.WorkspaceDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.Svg', 'Blockly.utils.dom']); goog.addDependency('../../core/workspace_dragger.js', ['Blockly.WorkspaceDragger'], ['Blockly.utils.Coordinate']); -goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.IASTNodeLocationSvg', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.PluginManager', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.TouchGesture', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Metrics', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es5'}); +goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ComponentManager', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.IASTNodeLocationSvg', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.TouchGesture', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Metrics', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es5'}); goog.addDependency('../../core/xml.js', ['Blockly.Xml'], ['Blockly.Events', 'Blockly.constants', 'Blockly.inputTypes', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.xml']); goog.addDependency('../../core/zoom_controls.js', ['Blockly.ZoomControls'], ['Blockly.Css', 'Blockly.Events', 'Blockly.Events.Click', 'Blockly.IPositionable', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.uiPosition', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es5'}); goog.addDependency("base.js", [], []); diff --git a/core/component_manager.js b/core/component_manager.js new file mode 100644 index 000000000..691b573bd --- /dev/null +++ b/core/component_manager.js @@ -0,0 +1,138 @@ +/** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Manager for all items registered with the workspace. + * @author kozbial@google.com (Monica Kozbial) + */ + +'use strict'; + +goog.provide('Blockly.ComponentManager'); + + +/** + * Manager for all items registered with the workspace. + * @constructor + */ +Blockly.ComponentManager = function() { + /** + * A map of the components registered with the workspace, mapped to id. + * @type {!Object} + * @private + */ + this.componentData_ = {}; + + /** + * A map of capabilities to component ids. + * @type {!Object>} + * @private + */ + this.capabilityToComponentIds_ = {}; +}; + +/** + * An object storing component information. + * @typedef {{ + * id: string, + * component: !Blockly.IComponent, + * capabilities: ( + * !Array>), + * weight: number + * }} + */ +Blockly.ComponentManager.ComponentDatum; + +/** + * Adds a component. + * @param {!Blockly.ComponentManager.ComponentDatum} componentInfo The data for + * the component to register. + * @template T + */ +Blockly.ComponentManager.prototype.addComponent = function(componentInfo) { + this.componentData_[componentInfo.id] = componentInfo; + for (var i = 0, type; (type = componentInfo.capabilities[i]); i++) { + var typeKey = String(type).toLowerCase(); + if (this.capabilityToComponentIds_[typeKey] === undefined) { + this.capabilityToComponentIds_[typeKey] = [componentInfo.id]; + } else { + this.capabilityToComponentIds_[typeKey].push(componentInfo.id); + } + } +}; + +/** + * Gets the component with the given ID and the given type. + * @param {string} id The ID of the component to get. + * @return {!Blockly.IComponent|undefined} The component with the given name + * or undefined if not found. + */ +Blockly.ComponentManager.prototype.getComponent = function(id) { + return this.componentData_[id] && this.componentData_[id].component; +}; + +/** + * Gets all the components of the specified type. + * @param {!Blockly.ComponentManager.Capability} capability The capability of the + * component. + * @param {boolean} sorted Whether to return list ordered by weights. + * @return {!Array} The components that match the specified capability. + * @template T + */ +Blockly.ComponentManager.prototype.getComponents = function(capability, sorted) { + var typeKey = String(capability).toLowerCase(); + var componentIds = this.capabilityToComponentIds_[typeKey]; + if (!componentIds) { + return []; + } + var components = []; + if (sorted) { + var componentDataList = []; + var componentData = this.componentData_; + componentIds.forEach(function(id) { + componentDataList.push(componentData[id]); + }); + componentDataList.sort(function(a, b) { + return a.weight - b.weight; + }); + componentDataList.forEach(function(ComponentDatum) { + components.push(ComponentDatum.component); + }); + } else { + var componentData = this.componentData_; + componentIds.forEach(function(id) { + components.push(componentData[id].component); + }); + } + return components; +}; + +/** + * A name with the capability of the element stored in the generic. + * @param {string} name The name of the component capability. + * @constructor + * @template T + */ +Blockly.ComponentManager.Capability = function(name) { + /** + * @type {string} + * @private + */ + this.name_ = name; +}; + +/** + * Returns the name of the capability. + * @return {string} The name. + * @override + */ +Blockly.ComponentManager.Capability.prototype.toString = function() { + return this.name_; +}; + +/** @type {!Blockly.ComponentManager.Capability} */ +Blockly.ComponentManager.Capability.POSITIONABLE = + new Blockly.ComponentManager.Capability('positionable'); diff --git a/core/interfaces/i_component.js b/core/interfaces/i_component.js new file mode 100644 index 000000000..093f5b64c --- /dev/null +++ b/core/interfaces/i_component.js @@ -0,0 +1,24 @@ +/** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Interface for a workspace component that can be registered with + * the ComponentManager. + * @author kozbial@google.com (Monica Kozbial) + */ + +'use strict'; + +goog.provide('Blockly.IComponent'); + + +/** + * The interface for a workspace component that can be registered with the + * ComponentManager. + * @interface + */ +Blockly.IComponent = function() {}; + diff --git a/core/interfaces/i_plugin.js b/core/interfaces/i_plugin.js deleted file mode 100644 index 4fc9b8c51..000000000 --- a/core/interfaces/i_plugin.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Interface for a plugin. - * @author kozbial@google.com (Monica Kozbial) - */ - -'use strict'; - -goog.provide('Blockly.IPlugin'); - - -/** - * The interface for a workspace plugin. - * @interface - */ -Blockly.IPlugin = function() {}; - diff --git a/core/interfaces/i_positionable.js b/core/interfaces/i_positionable.js index 67f5ba76e..64679bcc9 100644 --- a/core/interfaces/i_positionable.js +++ b/core/interfaces/i_positionable.js @@ -13,12 +13,12 @@ goog.provide('Blockly.IPositionable'); -goog.require('Blockly.IPlugin'); +goog.require('Blockly.IComponent'); /** * Interface for a component that is positioned on top of the workspace. - * @extends {Blockly.IPlugin} + * @extends {Blockly.IComponent} * @interface */ Blockly.IPositionable = function() {}; @@ -34,6 +34,6 @@ Blockly.IPositionable.prototype.position; /** * Returns the bounding rectangle of the UI element in pixel units relative to * the Blockly injection div. - * @return {!Blockly.utils.Rect} The plugin’s bounding box. + * @return {!Blockly.utils.Rect} The UI elements’s bounding box. */ Blockly.IPositionable.prototype.getBoundingRectangle; diff --git a/core/interfaces/i_workspace_plugin.js b/core/interfaces/i_workspace_plugin.js deleted file mode 100644 index dea62c122..000000000 --- a/core/interfaces/i_workspace_plugin.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Interface for plugins that can be registered on the workspace. - * @author kozbial@google.com (Monica Kozbial) - */ - -'use strict'; - -goog.provide('Blockly.IWorkspacePlugin'); - -/** - * Base interface for a plugin that can be registered on the workspace. - * @interface - */ -Blockly.IWorkspacePlugin = function() {}; diff --git a/core/plugin_manager.js b/core/plugin_manager.js deleted file mode 100644 index ec13cef02..000000000 --- a/core/plugin_manager.js +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Manager for all items registered with the workspace. - * @author kozbial@google.com (Monica Kozbial) - */ - -'use strict'; - -goog.provide('Blockly.PluginManager'); - - -/** - * Manager for all items registered with the workspace. - * @constructor - */ -Blockly.PluginManager = function() { - /** - * A map of the plugins registered with the workspace, mapped to id. - * @type {!Object} - * @private - */ - this.pluginData_ = {}; - - /** - * A map of types to plugin ids. - * @type {!Object>} - * @private - */ - this.typeToPluginIds_ = {}; -}; - -/** - * An object storing plugin information. - * @typedef {{ - * id: string, - * plugin: !Blockly.IPlugin, - * types: !Array>, - * weight: number - * }} - */ -Blockly.PluginManager.PluginDatum; - -/** - * Adds a plugin. - * @param {!Blockly.PluginManager.PluginDatum} pluginDataObject The plugin. - * @template T - */ -Blockly.PluginManager.prototype.addPlugin = function(pluginDataObject) { - this.pluginData_[pluginDataObject.id] = pluginDataObject; - for (var i = 0, type; (type = pluginDataObject.types[i]); i++) { - var typeKey = String(type).toLowerCase(); - if (this.typeToPluginIds_[typeKey] === undefined) { - this.typeToPluginIds_[typeKey] = [pluginDataObject.id]; - } else { - this.typeToPluginIds_[typeKey].push(pluginDataObject.id); - } - } -}; - -/** - * Gets the plugin with the given ID and the given type. - * @param {string} id The ID of the plugin to get. - * @return {!Blockly.IPlugin|undefined} The plugin with the given name - * or undefined if not found. - */ -Blockly.PluginManager.prototype.getPlugin = function(id) { - return this.pluginData_[id] && this.pluginData_[id].plugin; -}; - -/** - * Gets all the plugins of the specified type. - * @param {!Blockly.PluginManager.Type} type The type of the plugin. - * @param {boolean} sorted Whether to return list ordered by weights. - * @return {!Array} The plugins that match the - * specified type. - * @template T - */ -Blockly.PluginManager.prototype.getPlugins = function(type, sorted) { - var typeKey = String(type).toLowerCase(); - var pluginIds = this.typeToPluginIds_[typeKey]; - if (!pluginIds) { - return []; - } - var plugins = []; - if (sorted) { - var pluginDataList = []; - var pluginData = this.pluginData_; - pluginIds.forEach(function(id) { - pluginDataList.push(pluginData[id]); - }); - pluginDataList.sort(function(a, b) { - return a.weight - b.weight; - }); - pluginDataList.forEach(function(pluginDatum) { - plugins.push(pluginDatum.plugin); - }); - } else { - var pluginData = this.pluginData_; - pluginIds.forEach(function(id) { - plugins.push(pluginData[id].plugin); - }); - } - return plugins; -}; - -/** - * A name with the type of the element stored in the generic. - * @param {string} name The name of the plugin type. - * @constructor - * @template T - */ -Blockly.PluginManager.Type = function(name) { - /** - * @type {string} - * @private - */ - this.name_ = name; -}; - -/** - * Returns the name of the type. - * @return {string} The name. - * @override - */ -Blockly.PluginManager.Type.prototype.toString = function() { - return this.name_; -}; - -/** @type {!Blockly.PluginManager.Type} */ -Blockly.PluginManager.Type.POSITIONABLE = - new Blockly.PluginManager.Type('positionable'); diff --git a/core/trashcan.js b/core/trashcan.js index f826541c8..c825aa358 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -474,7 +474,7 @@ Blockly.Trashcan.prototype.position = function(metrics, savedPositions) { /** * Returns the bounding rectangle of the UI element in pixel units relative to * the Blockly injection div. - * @return {!Blockly.utils.Rect} The plugin’s bounding box. + * @return {!Blockly.utils.Rect} The UI elements’s bounding box. */ Blockly.Trashcan.prototype.getBoundingRectangle = function() { var bottom = this.top_ + this.BODY_HEIGHT_ + this.LID_HEIGHT_; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 706b82ea6..1946f8bfc 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -36,7 +36,7 @@ goog.require('Blockly.MetricsManager'); /** @suppress {extraRequire} */ goog.require('Blockly.Msg'); goog.require('Blockly.Options'); -goog.require('Blockly.PluginManager'); +goog.require('Blockly.ComponentManager'); goog.require('Blockly.registry'); goog.require('Blockly.ThemeManager'); goog.require('Blockly.Themes.Classic'); @@ -114,10 +114,10 @@ Blockly.WorkspaceSvg = function( options.setMetrics || Blockly.WorkspaceSvg.setTopLevelWorkspaceMetrics_; /** - * @type {!Blockly.PluginManager} + * @type {!Blockly.ComponentManager} * @private */ - this.pluginManager_ = new Blockly.PluginManager(); + this.componentManager_ = new Blockly.ComponentManager(); this.connectionDBList = Blockly.ConnectionDB.init(this.connectionChecker); @@ -541,13 +541,13 @@ Blockly.WorkspaceSvg.prototype.setMetricsManager = function(metricsManager) { this.getMetrics = this.metricsManager_.getMetrics.bind(this.metricsManager_); }; -/* - * Gets the plugin manager for this workspace. - * @return {!Blockly.PluginManager} The plugin manager. +/** + * Gets the component manager for this workspace. + * @return {!Blockly.ComponentManager} The component manager. * @public */ -Blockly.WorkspaceSvg.prototype.getPluginManager = function() { - return this.pluginManager_; +Blockly.WorkspaceSvg.prototype.getComponentManager = function() { + return this.componentManager_; }; /** @@ -1003,11 +1003,11 @@ Blockly.WorkspaceSvg.prototype.addTrashcan = function() { this.trashcan = new Blockly.Trashcan(this); var svgTrashcan = this.trashcan.createDom(); this.svgGroup_.insertBefore(svgTrashcan, this.svgBlockCanvas_); - this.pluginManager_.addPlugin({ + this.componentManager_.addComponent({ id: 'trashcan', - plugin: this.trashcan, + component: this.trashcan, weight: 1, - types: [Blockly.PluginManager.Type.POSITIONABLE] + capabilities: [Blockly.ComponentManager.Capability.POSITIONABLE] }); }; @@ -1023,11 +1023,11 @@ Blockly.WorkspaceSvg.prototype.addZoomControls = function() { this.zoomControls_ = new Blockly.ZoomControls(this); var svgZoomControls = this.zoomControls_.createDom(); this.svgGroup_.appendChild(svgZoomControls); - this.pluginManager_.addPlugin({ + this.componentManager_.addComponent({ id: 'zoomControls', - plugin: this.zoomControls_, + component: this.zoomControls_, weight: 2, - types: [Blockly.PluginManager.Type.POSITIONABLE] + capabilities: [Blockly.ComponentManager.Capability.POSITIONABLE] }); }; @@ -1141,8 +1141,8 @@ Blockly.WorkspaceSvg.prototype.resize = function() { this.flyout_.position(); } - var positionables = this.pluginManager_.getPlugins( - Blockly.PluginManager.Type.POSITIONABLE, true); + var positionables = this.componentManager_.getComponents( + Blockly.ComponentManager.Capability.POSITIONABLE, true); var metrics = this.getMetricsManager().getUiMetrics(); var savedPositions = []; for (var i = 0, positionable; (positionable = positionables[i]); i++) { diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 15a578678..84e84febb 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -214,7 +214,7 @@ Blockly.ZoomControls.prototype.dispose = function() { /** * Returns the bounding rectangle of the UI element in pixel units relative to * the Blockly injection div. - * @return {!Blockly.utils.Rect} The plugin’s bounding box. + * @return {!Blockly.utils.Rect} The UI elements’s bounding box. */ Blockly.ZoomControls.prototype.getBoundingRectangle = function() { var height = this.SMALL_SPACING_ + 2 * this.HEIGHT_;