Browse Source

fix: simplify move command by directly assigning command string

carlos/645-absolute-mode-enhancements
Carlos 10 months ago
parent
commit
e78e9e419e
  1. 16
      packages/core/src/dom_components/model/Component.ts

16
packages/core/src/dom_components/model/Component.ts

@ -1146,21 +1146,7 @@ export default class Component extends StyleableModel<ComponentProperties> {
tb.push({ tb.push({
attributes: { class: `${ppfx}no-touch-actions`, draggable: true }, attributes: { class: `${ppfx}no-touch-actions`, draggable: true },
label: em.getIcon('move'), label: em.getIcon('move'),
command: (ed) => { command: 'tlb-move',
const targets = ed.getSelectedAll();
targets.forEach((target) => {
const rect = target?.view?.el.getBoundingClientRect();
const clientX = rect ? rect.left + rect.width / 2 : 0;
const clientY = rect ? rect.top + rect.height / 2 : 0;
// tld-move event needs to be called with a target and a drag event
ed.runCommand('tlb-move', {
target,
event: new DragEvent('dragstart', { clientX, clientY }),
});
});
},
}); });
model.get('copyable') && model.get('copyable') &&
tb.push({ tb.push({

Loading…
Cancel
Save