From 34af18d2e9a7f19ec97428c2aa44162f5fde9c2e Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 5 Apr 2019 07:53:36 +0200 Subject: [PATCH] Refactor init in Commands --- docs/modules/Commands.md | 22 +++++++++++++--------- src/commands/index.js | 22 ++++++++++------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/docs/modules/Commands.md b/docs/modules/Commands.md index 96ecfec16..e9de5204d 100644 --- a/docs/modules/Commands.md +++ b/docs/modules/Commands.md @@ -98,26 +98,30 @@ GrapesJS comes along with some default set of commands and you can get a list of * [`core:component-exit`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/ComponentExit.js) - Select the parent component of the current selected one * [`core:component-next`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/ComponentNext.js) - Select the next sibling component * [`core:component-prev`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/ComponentPrev.js) - Select the previous sibling component +* [`core:component-outline`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/SwitchVisibility.js) - Enable outline border on components +* [`core:component-offset`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/ShowOffset.js) - Enable components offset (margins, paddings) +* [`core:component-select`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/SelectComponent.js) - Enable the process of selecting components in the canvas * [`core:copy`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/CopyComponent.js) - Copy the current selected component * [`core:paste`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/PasteComponent.js) - Paste copied component * [`core:preview`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/Preview.js) - Show the preview of the template in canvas * [`core:fullscreen`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/Fullscreen.js) - Set the editor fullscreen +* [`core:open-code`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/ExportTemplate.js) - Open a default panel with the template code +* [`core:open-layers`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/OpenLayers.js) - Open a default panel with layers +* [`core:open-styles`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/OpenStyleManager.js) - Open a default panel with the style manager +* [`core:open-traits`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/OpenTraitManager.js) - Open a default panel with the trait manager +* [`core:open-blocks`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/OpenBlocks.js) - Open a default panel with the blocks +* [`core:open-assets`](https://github.com/artf/grapesjs/blob/dev/src/commands/view/OpenAssets.js) - Open a default panel with the assets * `core:undo` - Call undo operation * `core:redo` - Call redo operation -export-template -open-assets -open-blocks -open-layers -open-sm -open-tm -select-comp -show-offset -sw-visibility tlb-clone tlb-delete tlb-move + + + + ## Statefull commands diff --git a/src/commands/index.js b/src/commands/index.js index 5a3b1246f..ed7b59184 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -77,18 +77,6 @@ module.exports = () => { if (obj.id) this.add(obj.id, obj); } - const ViewCode = require('./view/ExportTemplate'); - defaultCommands['select-comp'] = require('./view/SelectComponent'); - defaultCommands['move-comp'] = require('./view/MoveComponent'); - defaultCommands['export-template'] = ViewCode; - defaultCommands['sw-visibility'] = require('./view/SwitchVisibility'); - defaultCommands['open-layers'] = require('./view/OpenLayers'); - defaultCommands['open-sm'] = require('./view/OpenStyleManager'); - defaultCommands['open-tm'] = require('./view/OpenTraitManager'); - defaultCommands['open-blocks'] = require('./view/OpenBlocks'); - defaultCommands['open-assets'] = require('./view/OpenAssets'); - defaultCommands['show-offset'] = require('./view/ShowOffset'); - defaultCommands['tlb-delete'] = { run(ed) { return ed.runCommand('core:component-delete'); @@ -171,6 +159,16 @@ module.exports = () => { ['paste', 'PasteComponent'], ['canvas-move', 'CanvasMove'], ['canvas-clear', 'CanvasClear'], + ['open-code', 'ExportTemplate', 'export-template'], + ['open-layers', 'OpenLayers', 'open-layers'], + ['open-styles', 'OpenStyleManager', 'open-sm'], + ['open-traits', 'OpenTraitManager', 'open-tm'], + ['open-blocks', 'OpenBlocks', 'open-blocks'], + ['open-assets', 'OpenAssets', 'open-assets'], + ['component-select', 'SelectComponent', 'select-comp'], + ['component-outline', 'SwitchVisibility', 'sw-visibility'], + ['component-offset', 'ShowOffset', 'show-offset'], + ['component-move', 'MoveComponent', 'move-comp'], ['component-next', 'ComponentNext'], ['component-prev', 'ComponentPrev'], ['component-enter', 'ComponentEnter'],