From 6760ce54b15fa5a34f1eace436b9332bc248980d Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 4 Apr 2019 23:34:41 +0200 Subject: [PATCH] Remove SelectParent and improve ComponentExit --- docs/modules/Commands.md | 7 ++----- src/commands/index.js | 1 - src/commands/view/ComponentExit.js | 8 +++++++- src/commands/view/SelectParent.js | 13 ------------- src/dom_components/model/Component.js | 2 +- 5 files changed, 10 insertions(+), 21 deletions(-) delete mode 100644 src/commands/view/SelectParent.js diff --git a/docs/modules/Commands.md b/docs/modules/Commands.md index bb8843b62..96ecfec16 100644 --- a/docs/modules/Commands.md +++ b/docs/modules/Commands.md @@ -106,15 +106,12 @@ GrapesJS comes along with some default set of commands and you can get a list of * `core:redo` - Call redo operation export-template -move-comp -my-command-id open-assets -open-blocks: -open-layers: +open-blocks +open-layers open-sm open-tm select-comp -select-parent show-offset sw-visibility tlb-clone diff --git a/src/commands/index.js b/src/commands/index.js index 6f04809de..5a3b1246f 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -88,7 +88,6 @@ module.exports = () => { defaultCommands['open-blocks'] = require('./view/OpenBlocks'); defaultCommands['open-assets'] = require('./view/OpenAssets'); defaultCommands['show-offset'] = require('./view/ShowOffset'); - defaultCommands['select-parent'] = require('./view/SelectParent'); defaultCommands['tlb-delete'] = { run(ed) { diff --git a/src/commands/view/ComponentExit.js b/src/commands/view/ComponentExit.js index d13328704..8d01f9f0e 100644 --- a/src/commands/view/ComponentExit.js +++ b/src/commands/view/ComponentExit.js @@ -4,7 +4,13 @@ module.exports = { const toSelect = []; ed.getSelectedAll().forEach(component => { - const next = component.parent(); + let next = component.parent(); + + // Recurse through the parent() chain until a selectable parent is found + while (next && !next.get('selectable')) { + next = next.parent(); + } + next && toSelect.push(next); }); diff --git a/src/commands/view/SelectParent.js b/src/commands/view/SelectParent.js deleted file mode 100644 index ad6a74249..000000000 --- a/src/commands/view/SelectParent.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - run(editor) { - const sel = editor.getSelected(); - let comp = sel && sel.parent(); - - // Recurse through the parent() chain until a selectable parent is found - while (comp && !comp.get('selectable')) { - comp = comp.parent(); - } - - comp && editor.select(comp); - } -}; diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 4c3f8f0eb..f232ac6fc 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -611,7 +611,7 @@ const Component = Backbone.Model.extend(Styleable).extend( if (model.collection) { tb.push({ attributes: { class: 'fa fa-arrow-up' }, - command: 'select-parent' + command: 'core:component-exit' }); } if (model.get('draggable')) {