Browse Source

Remove SelectParent and improve ComponentExit

pull/2031/head
Artur Arseniev 8 years ago
parent
commit
6760ce54b1
  1. 7
      docs/modules/Commands.md
  2. 1
      src/commands/index.js
  3. 8
      src/commands/view/ComponentExit.js
  4. 13
      src/commands/view/SelectParent.js
  5. 2
      src/dom_components/model/Component.js

7
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 * `core:redo` - Call redo operation
export-template export-template
move-comp
my-command-id
open-assets open-assets
open-blocks: open-blocks
open-layers: open-layers
open-sm open-sm
open-tm open-tm
select-comp select-comp
select-parent
show-offset show-offset
sw-visibility sw-visibility
tlb-clone tlb-clone

1
src/commands/index.js

@ -88,7 +88,6 @@ module.exports = () => {
defaultCommands['open-blocks'] = require('./view/OpenBlocks'); defaultCommands['open-blocks'] = require('./view/OpenBlocks');
defaultCommands['open-assets'] = require('./view/OpenAssets'); defaultCommands['open-assets'] = require('./view/OpenAssets');
defaultCommands['show-offset'] = require('./view/ShowOffset'); defaultCommands['show-offset'] = require('./view/ShowOffset');
defaultCommands['select-parent'] = require('./view/SelectParent');
defaultCommands['tlb-delete'] = { defaultCommands['tlb-delete'] = {
run(ed) { run(ed) {

8
src/commands/view/ComponentExit.js

@ -4,7 +4,13 @@ module.exports = {
const toSelect = []; const toSelect = [];
ed.getSelectedAll().forEach(component => { 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); next && toSelect.push(next);
}); });

13
src/commands/view/SelectParent.js

@ -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);
}
};

2
src/dom_components/model/Component.js

@ -611,7 +611,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
if (model.collection) { if (model.collection) {
tb.push({ tb.push({
attributes: { class: 'fa fa-arrow-up' }, attributes: { class: 'fa fa-arrow-up' },
command: 'select-parent' command: 'core:component-exit'
}); });
} }
if (model.get('draggable')) { if (model.get('draggable')) {

Loading…
Cancel
Save