mirror of https://github.com/artf/grapesjs.git
committed by
GitHub
45 changed files with 1940 additions and 816 deletions
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@ |
|||
module.exports = { |
|||
run(ed) { |
|||
if (!ed.Canvas.hasFocus() || ed.getModel().isEditing()) return; |
|||
const toSelect = []; |
|||
|
|||
ed.getSelectedAll().forEach(component => { |
|||
const coll = component.components(); |
|||
const next = coll && coll.at(0); |
|||
next && toSelect.push(next); |
|||
}); |
|||
|
|||
toSelect.length && ed.select(toSelect); |
|||
} |
|||
}; |
|||
@ -0,0 +1,13 @@ |
|||
module.exports = { |
|||
run(ed) { |
|||
if (!ed.Canvas.hasFocus() || ed.getModel().isEditing()) return; |
|||
const toSelect = []; |
|||
|
|||
ed.getSelectedAll().forEach(component => { |
|||
const next = component.parent(); |
|||
next && toSelect.push(next); |
|||
}); |
|||
|
|||
toSelect.length && ed.select(toSelect); |
|||
} |
|||
}; |
|||
@ -0,0 +1,15 @@ |
|||
module.exports = { |
|||
run(ed) { |
|||
if (!ed.Canvas.hasFocus() || ed.getModel().isEditing()) return; |
|||
const toSelect = []; |
|||
|
|||
ed.getSelectedAll().forEach(component => { |
|||
const coll = component.collection; |
|||
const at = coll.indexOf(component); |
|||
const next = coll.at(at + 1); |
|||
toSelect.push(next || component); |
|||
}); |
|||
|
|||
toSelect.length && ed.select(toSelect); |
|||
} |
|||
}; |
|||
@ -0,0 +1,15 @@ |
|||
module.exports = { |
|||
run(ed) { |
|||
if (!ed.Canvas.hasFocus() || ed.getModel().isEditing()) return; |
|||
const toSelect = []; |
|||
|
|||
ed.getSelectedAll().forEach(component => { |
|||
const coll = component.collection; |
|||
const at = coll.indexOf(component); |
|||
const next = coll.at(at - 1); |
|||
toSelect.push(next && at - 1 >= 0 ? next : component); |
|||
}); |
|||
|
|||
toSelect.length && ed.select(toSelect); |
|||
} |
|||
}; |
|||
@ -0,0 +1,10 @@ |
|||
module.exports = { |
|||
run(ed) { |
|||
const em = ed.getModel(); |
|||
const models = [...ed.getSelectedAll()]; |
|||
|
|||
if (models.length && !ed.Canvas.isInputFocused()) { |
|||
em.set('clipboard', models); |
|||
} |
|||
} |
|||
}; |
|||
@ -0,0 +1,30 @@ |
|||
import { isArray, contains } from 'underscore'; |
|||
|
|||
module.exports = { |
|||
run(ed) { |
|||
const em = ed.getModel(); |
|||
const clp = em.get('clipboard'); |
|||
const selected = ed.getSelected(); |
|||
|
|||
if (clp && selected && !ed.Canvas.isInputFocused()) { |
|||
ed.getSelectedAll().forEach(comp => { |
|||
if (!comp) return; |
|||
const coll = comp.collection; |
|||
const at = coll.indexOf(comp) + 1; |
|||
const copyable = clp.filter(cop => cop.get('copyable')); |
|||
let added; |
|||
|
|||
if (contains(clp, comp) && comp.get('copyable')) { |
|||
added = coll.add(comp.clone(), { at }); |
|||
} else { |
|||
added = coll.add(copyable.map(cop => cop.clone()), { at }); |
|||
} |
|||
|
|||
added = isArray(added) ? added : [added]; |
|||
added.forEach(add => ed.trigger('component:clone', add)); |
|||
}); |
|||
|
|||
selected.emitUpdate(); |
|||
} |
|||
} |
|||
}; |
|||
Loading…
Reference in new issue