@fabwcie/free-drawing / plugins/PluginCollection
plugins/PluginCollection
Classes
PluginCollection
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:102
Plugins of a drawer (drawer.plugins): created from the plugins option before the toolbar, after the plugins they require, initialized once the drawer is created. Holds widgets and commands added by plugins
Constructors
Constructor
new PluginCollection(
drawer):PluginCollection
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:124
Plugins of a drawer, created by _create
Parameters
drawer
Drawer of the plugins
Returns
Properties
commands
commands:
RegisteredCommand[] =[]
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:112
Commands added by plugins (Plugin.addCommand)
drawer
drawer:
Drawer
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:104
Drawer of the plugins
ready
ready:
Promise<void>
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:116
Resolved once every plugin is initialized (init, afterInit), waited by drawer.ready
shapeTypes
shapeTypes:
Map<string,PluginShapeType>
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:114
Types of the shapes of plugins (Plugin.addShapeType), by name of their shapes
widgets
widgets:
Map<string,WidgetClass>
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:110
Widgets added by plugins (Plugin.addWidget), by id, created by the toolbar
Methods
_addCommand()
_addCommand(
plugin,command):void
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:285
Register a command of a plugin (see Plugin.addCommand), a second command of the same id is ignored
Parameters
plugin
Plugin adding it
command
The command
Returns
void
_addShapeType()
_addShapeType(
plugin,type):void
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:256
Register the type of the shapes of a plugin (see Plugin.addShapeType)
Parameters
plugin
Plugin adding it
type
Name of the shapes, label and icon
Returns
void
Throws
name of the library (drawer-*, names of its layers), not one word, or of another type
_addToMenus()
_addToMenus():
void
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:340
Commands of plugins in the context menu (one section) and help, once plugins are initialized
Returns
void
_addWidget()
_addWidget(
plugin,id,widget):void
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:243
Register a widget of a plugin, created by the toolbar (see Plugin.addWidget)
Parameters
plugin
Plugin adding it
id
string
Id of the widget
widget
Class of the widget
Returns
void
Throws
id of another widget
_create()
_create(
entries):void
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:134
Create the plugins of the plugins option and the ones they require, required ones first (their constructor can use drawer.plugins and their options). Called by the drawer
Parameters
entries
readonly PluginEntry[]
Plugins of the plugins option: classes, or classes with their options
Returns
void
Throws
invalid plugins (see resolvePlugins)
_fitsMenu()
private_fitsMenu(menu):boolean
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:359
Context menu shown for the selection or for the drawing
Parameters
menu
Menu of a command
Returns
boolean
true for selection with shapes selected (not locked), for drawing without selection
_getOptions()
_getOptions(
name):object
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:158
Options given to a plugin by the app: with its class in the plugins option, over the ones of the deprecated pluginOptions option. Read by Plugin.getOptions
Parameters
name
string
Name of the plugin
Returns
object
options of the app, empty without them
_getPaletteCommands()
_getPaletteCommands():
Omit<Command,"group">[]
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:307
Available commands of plugins for the command palette, labels translated
Returns
Omit<Command, "group">[]
commands without group (added to the editor one by the palette)
_init()
_init():
void
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:195
Initialize plugins once the drawer is created: init of each plugin (in creation order, a promise is waited before the next one), then afterInit, then their commands added to the context menu and help. Errors are logged, other plugins are still initialized; nothing more once destroyed. Called by the drawer
Returns
void
_isAvailable()
_isAvailable(
registered):boolean
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:299
Command can be run now: its plugin is enabled (not read only, not disabled by forceDisabled), unless the command does not modify the drawing (readOnly), and it is available for the command
Parameters
registered
Command and its plugin
Returns
boolean
true when the command is shown and its shortcut runs it
_runShortcut()
_runShortcut(
e):boolean
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:324
Run the available command of plugins whose shortcut is pressed
Parameters
e
KeyboardEvent
Key pressed in the drawer (not in a field)
Returns
boolean
true if a command ran
[iterator]()
[iterator]():
IterableIterator<Plugin>
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:186
Plugins of the drawer, required ones first
Returns
IterableIterator<Plugin>
iterator of the plugins
destroy()
destroy():
Promise<void>
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:225
Destroy plugins, last created first (listeners of listenTo removed), e.g. when the app removes the drawer
Returns
Promise<void>
promise resolved once every plugin is destroyed
get()
get<
T>(plugin):T|undefined
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:167
Plugin of the drawer
Type Parameters
T
T extends Plugin
Parameters
plugin
string | PluginClass<T>
Class of the plugin or its name
Returns
T | undefined
the plugin, undefined when the drawer does not have it
getShapeType()
getShapeType(
shape):PluginShapeType|undefined
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:275
Type of a shape of a plugin (see Plugin.addShapeType)
Parameters
shape
Node
Drawing shape or group
Returns
PluginShapeType | undefined
type of the first name of a plugin it has, undefined for other shapes
has()
has(
plugin):boolean
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:178
Drawer has a plugin
Parameters
plugin
string | PluginClass
Class of the plugin or its name
Returns
boolean
true when the plugin was created
Functions
resolvePlugins()
resolvePlugins(
classes):PluginClass[]
Defined in: packages/free-drawing/src/plugins/PluginCollection.ts:37
Plugin classes in creation order: required plugins before the ones requiring them, classes required by others added
Parameters
classes
readonly PluginEntry[]
Plugins of the plugins drawer option: classes, or classes with their options
Returns
every plugin class once, required ones first
Throws
plugin without name, two plugins of the same name, required plugin missing, plugins requiring each other