import { copyAndPast } from '../diagram/group-select-applay.js'; import { copySvg, delSvg } from '../infrastructure/assets.js'; import { clickForAll, listen, classSingleAdd, evtTargetAttr } from '../infrastructure/util.js'; import { modalChangeTop, modalCreate } from './modal-create.js'; import { ShapeSmbl } from './shape-smbl.js'; /** * @param {import('../infrastructure/canvas-smbl').CanvasElement} canvas * @param {import('./shape-smbl').ShapeElement} shapeElement * @param {number} bottomX positon of the bottom left corner of the panel * @param {number} bottomY positon of the bottom left corner of the panel */ export function settingsPnlCreate(canvas, shapeElement, bottomX, bottomY) { const shapeSettings = new ShapeEdit(); listen(shapeSettings, 'cmd', /** @param {CustomEvent<{cmd:string, arg:string}>} evt */ evt => { switch (evt.detail.cmd) { case 'style': classSingleAdd(shapeElement, shapeElement[ShapeSmbl].data, 'cl-', evt.detail.arg); break; case 'del': shapeElement[ShapeSmbl].del(); break; case 'copy': copyAndPast(canvas, [shapeElement]); break; } }); return modalCreate(bottomX, bottomY, shapeSettings); } class ShapeEdit extends HTMLElement { connectedCallback() { const shadow = this.attachShadow({ mode: 'closed' }); shadow.innerHTML = `