diff --git a/src/editor/index.js b/src/editor/index.js index 652d11774..0e1065a1e 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -64,11 +64,6 @@ * * `canvas:dragend` - When a drag operation is ended, `DataTransfer` instance passed as an argument * * `canvas:dragdata` - On any dataTransfer parse, `DataTransfer` instance and the `result` are passed as arguments. * By changing `result.content` you're able to customize what is dropped - * ### Selectors - * * `selector:add` - New selector is add. Passes the new selector as an argument - * * `selector:remove` - Selector removed. Passes the removed selector as an argument - * * `selector:update` - Selector updated. Passes the updated selector as an argument - * * `selector:state` - State changed. Passes the new state value as an argument * ### RTE * * `rte:enable` - RTE enabled. The view, on which RTE is enabled, is passed as an argument * * `rte:disable` - RTE disabled. The view, on which RTE is disabled, is passed as an argument @@ -80,6 +75,8 @@ * * `abort:{commandName}` - Triggered when the command execution is aborted (`editor.on(`run:preview:before`, opts => opts.abort = 1);`) * * `run` - Triggered on run of any command. The id and the result are passed as arguments to the callback * * `stop` - Triggered on stop of any command. The id and the result are passed as arguments to the callback + * ### Selectors + * Check the [Selectors](/api/selector_manager.html) module. * ### Blocks * Check the [Blocks](/api/block_manager.html) module. * ### Assets diff --git a/src/selector_manager/index.js b/src/selector_manager/index.js index f3e5acfee..f5bf26054 100644 --- a/src/selector_manager/index.js +++ b/src/selector_manager/index.js @@ -29,12 +29,25 @@ * }) * ``` * - * Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance + * Once the editor is instantiated you can use its API and listen to its events. Before using these methods, you should get the module from the instance. * * ```js - * const selectorManager = editor.SelectorManager; + * // Listen to events + * editor.on('selector:add', (selector) => { ... }); + * + * // Use the API + * const sm = editor.Selectors; + * sm.add(...); * ``` * + * ## Available Events + * * `selector:add` - Selector added. The [Selector] is passed as an argument to the callback. + * * `selector:remove` - Selector removed. The [Selector] is passed as an argument to the callback. + * * `selector:update` - Selector updated. The [Selector] and the object containing changes are passed as arguments to the callback. + * * `selector:state` - State changed. Passes the new state value as an argument. + * * `selector` - Catch-all event for all the events mentioned above. An object containing all the available data about the triggered event is passed as an argument to the callback. + * + * ## Methods * * [getConfig](#getconfig) * * [add](#add) * * [addClass](#addclass) @@ -43,6 +56,8 @@ * * [setState](#setstate) * * [getState](#getstate) * + * [Selector]: selector.html + * * @module SelectorManager */ @@ -110,17 +125,6 @@ export default () => { this.all = new Selectors(config.selectors); this.model = new Model({ _undo: true }); this.__initListen(); - - // selectors.on('add', model => em.trigger('selector:add', model)); - // selectors.on('remove', model => em.trigger('selector:remove', model)); - // selectors.on('change', model => - // em.trigger( - // 'selector:update', - // model, - // model.previousAttributes(), - // model.changedAttributes() - // ) - // ); em.on('change:state', (m, value) => em.trigger('selector:state', value)); return this; @@ -301,6 +305,8 @@ export default () => { /** * Get all selectors + * @name getAll + * @function * @return {Collection} * */