From c2502f82365584ace421fb49421b8b1151e7303d Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 30 Dec 2021 13:16:16 +0100 Subject: [PATCH] Move storage manager events --- src/editor/index.js | 14 ++------------ src/storage_manager/index.js | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/editor/index.js b/src/editor/index.js index cb5353998..cfc208253 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -45,18 +45,8 @@ * * `styleManager:update:target` - The target (Component or CSSRule) is changed * * `styleManager:change` - Triggered on style property change from new selected component, the view of the property is passed as an argument to the callback * * `styleManager:change:{propertyName}` - As above but for a specific style property - * ### Storages - * * `storage:start` - Before the storage request is started - * * `storage:start:store` - Before the store request. The object to store is passed as an argumnet (which you can edit) - * * `storage:start:load` - Before the load request. Items to load are passed as an argumnet (which you can edit) - * * `storage:load` - Triggered when something was loaded from the storage, loaded object passed as an argumnet - * * `storage:store` - Triggered when something is stored to the storage, stored object passed as an argumnet - * * `storage:end` - After the storage request is ended - * * `storage:end:store` - After the store request - * * `storage:end:load` - After the load request - * * `storage:error` - On any error on storage request, passes the error as an argument - * * `storage:error:store` - Error on store request, passes the error as an argument - * * `storage:error:load` - Error on load request, passes the error as an argument + * ### Storage + * Check the [Storage](/api/storage_manager.html) module. * ### Canvas * Check the [Canvas](/api/canvas.html) module. * ### RTE diff --git a/src/storage_manager/index.js b/src/storage_manager/index.js index 07027b95e..4936034d2 100644 --- a/src/storage_manager/index.js +++ b/src/storage_manager/index.js @@ -8,12 +8,31 @@ * }) * ``` * - * 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 + * // Listen to events + * editor.on('storage:start', () => { ... }); + * + * // Use the API * const storageManager = editor.StorageManager; + * storageManager.add(...); * ``` * + * ## Available Events + * * `storage:start` - Before the storage request is started + * * `storage:start:store` - Before the store request. The object to store is passed as an argumnet (which you can edit) + * * `storage:start:load` - Before the load request. Items to load are passed as an argumnet (which you can edit) + * * `storage:load` - Triggered when something was loaded from the storage, loaded object passed as an argumnet + * * `storage:store` - Triggered when something is stored to the storage, stored object passed as an argumnet + * * `storage:end` - After the storage request is ended + * * `storage:end:store` - After the store request + * * `storage:end:load` - After the load request + * * `storage:error` - On any error on storage request, passes the error as an argument + * * `storage:error:store` - Error on store request, passes the error as an argument + * * `storage:error:load` - Error on load request, passes the error as an argument + * + * ## Methods * * [getConfig](#getconfig) * * [isAutosave](#isautosave) * * [setAutosave](#setautosave) @@ -362,6 +381,6 @@ export default () => { destroy() { [c, em, storages, defaultStorages].forEach(i => (i = {})); - } + }, }; };