@node-edit-utils/core 2.1.8 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node-edit-utils.cjs.js +4 -8
- package/dist/node-edit-utils.esm.js +4 -8
- package/dist/node-edit-utils.umd.js +4 -8
- package/dist/node-edit-utils.umd.min.js +1 -1
- package/package.json +1 -1
- package/src/lib/node-tools/createNodeTools.ts +0 -2
- package/src/lib/node-tools/highlight/refreshHighlightFrame.ts +4 -0
- package/src/lib/post-message/processPostMessage.ts +2 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Markup Canvas
|
|
3
3
|
* High-performance markup canvas with zoom and pan capabilities
|
|
4
|
-
* @version 2.1.
|
|
4
|
+
* @version 2.1.9
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
@@ -138,15 +138,11 @@ const isLocked = (node) => {
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
const processPostMessage = (event, onNodeSelected) => {
|
|
141
|
-
// if (event.data.source === "markup-canvas" && event.data.canvasName === "canvas") {
|
|
142
|
-
// if (event.data.action === "zoom") {
|
|
143
|
-
// // Zoom handling can be implemented here if needed
|
|
144
|
-
// }
|
|
145
|
-
// }
|
|
146
141
|
if (event.data.source === "application") {
|
|
147
142
|
if (event.data.action === "selectedNodeChanged") {
|
|
148
143
|
const nodeId = event.data.data;
|
|
149
144
|
const selectedNode = document.querySelector(`[data-node-id="${nodeId}"]`);
|
|
145
|
+
console.log("selectedNode", selectedNode);
|
|
150
146
|
if (isLocked(selectedNode)) {
|
|
151
147
|
onNodeSelected?.(null);
|
|
152
148
|
return;
|
|
@@ -330,6 +326,7 @@ const highlightNode = (node, nodeProvider) => {
|
|
|
330
326
|
const refreshHighlightFrame = (node, nodeProvider) => {
|
|
331
327
|
const frame = getHighlightFrameElement(nodeProvider);
|
|
332
328
|
const zoom = getCanvasWindowValue(["zoom", "current"]) ?? 1;
|
|
329
|
+
console.log("1. refreshHighlightFrame", node);
|
|
333
330
|
if (!frame)
|
|
334
331
|
return;
|
|
335
332
|
if (zoom >= 0.3) {
|
|
@@ -343,6 +340,7 @@ const refreshHighlightFrame = (node, nodeProvider) => {
|
|
|
343
340
|
frame.style.setProperty("--frame-left", `${left}px`);
|
|
344
341
|
frame.style.setProperty("--frame-width", `${width}px`);
|
|
345
342
|
frame.style.setProperty("--frame-height", `${height}px`);
|
|
343
|
+
console.log("2. refreshHighlightFrame", top, left, width, height);
|
|
346
344
|
};
|
|
347
345
|
|
|
348
346
|
const updateHighlightFrameVisibility = (node, nodeProvider) => {
|
|
@@ -537,8 +535,6 @@ const createNodeTools = (element) => {
|
|
|
537
535
|
});
|
|
538
536
|
mutationObserver.observe(node, {
|
|
539
537
|
attributes: true,
|
|
540
|
-
subtree: true,
|
|
541
|
-
childList: true,
|
|
542
538
|
characterData: true,
|
|
543
539
|
});
|
|
544
540
|
nodeResizeObserver = connectResizeObserver(node, () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Markup Canvas
|
|
3
3
|
* High-performance markup canvas with zoom and pan capabilities
|
|
4
|
-
* @version 2.1.
|
|
4
|
+
* @version 2.1.9
|
|
5
5
|
*/
|
|
6
6
|
// biome-ignore lint/suspicious/noExplicitAny: generic constraint requires flexibility
|
|
7
7
|
function withRAFThrottle(func) {
|
|
@@ -136,15 +136,11 @@ const isLocked = (node) => {
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
const processPostMessage = (event, onNodeSelected) => {
|
|
139
|
-
// if (event.data.source === "markup-canvas" && event.data.canvasName === "canvas") {
|
|
140
|
-
// if (event.data.action === "zoom") {
|
|
141
|
-
// // Zoom handling can be implemented here if needed
|
|
142
|
-
// }
|
|
143
|
-
// }
|
|
144
139
|
if (event.data.source === "application") {
|
|
145
140
|
if (event.data.action === "selectedNodeChanged") {
|
|
146
141
|
const nodeId = event.data.data;
|
|
147
142
|
const selectedNode = document.querySelector(`[data-node-id="${nodeId}"]`);
|
|
143
|
+
console.log("selectedNode", selectedNode);
|
|
148
144
|
if (isLocked(selectedNode)) {
|
|
149
145
|
onNodeSelected?.(null);
|
|
150
146
|
return;
|
|
@@ -328,6 +324,7 @@ const highlightNode = (node, nodeProvider) => {
|
|
|
328
324
|
const refreshHighlightFrame = (node, nodeProvider) => {
|
|
329
325
|
const frame = getHighlightFrameElement(nodeProvider);
|
|
330
326
|
const zoom = getCanvasWindowValue(["zoom", "current"]) ?? 1;
|
|
327
|
+
console.log("1. refreshHighlightFrame", node);
|
|
331
328
|
if (!frame)
|
|
332
329
|
return;
|
|
333
330
|
if (zoom >= 0.3) {
|
|
@@ -341,6 +338,7 @@ const refreshHighlightFrame = (node, nodeProvider) => {
|
|
|
341
338
|
frame.style.setProperty("--frame-left", `${left}px`);
|
|
342
339
|
frame.style.setProperty("--frame-width", `${width}px`);
|
|
343
340
|
frame.style.setProperty("--frame-height", `${height}px`);
|
|
341
|
+
console.log("2. refreshHighlightFrame", top, left, width, height);
|
|
344
342
|
};
|
|
345
343
|
|
|
346
344
|
const updateHighlightFrameVisibility = (node, nodeProvider) => {
|
|
@@ -535,8 +533,6 @@ const createNodeTools = (element) => {
|
|
|
535
533
|
});
|
|
536
534
|
mutationObserver.observe(node, {
|
|
537
535
|
attributes: true,
|
|
538
|
-
subtree: true,
|
|
539
|
-
childList: true,
|
|
540
536
|
characterData: true,
|
|
541
537
|
});
|
|
542
538
|
nodeResizeObserver = connectResizeObserver(node, () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Markup Canvas
|
|
3
3
|
* High-performance markup canvas with zoom and pan capabilities
|
|
4
|
-
* @version 2.1.
|
|
4
|
+
* @version 2.1.9
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
@@ -142,15 +142,11 @@
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
const processPostMessage = (event, onNodeSelected) => {
|
|
145
|
-
// if (event.data.source === "markup-canvas" && event.data.canvasName === "canvas") {
|
|
146
|
-
// if (event.data.action === "zoom") {
|
|
147
|
-
// // Zoom handling can be implemented here if needed
|
|
148
|
-
// }
|
|
149
|
-
// }
|
|
150
145
|
if (event.data.source === "application") {
|
|
151
146
|
if (event.data.action === "selectedNodeChanged") {
|
|
152
147
|
const nodeId = event.data.data;
|
|
153
148
|
const selectedNode = document.querySelector(`[data-node-id="${nodeId}"]`);
|
|
149
|
+
console.log("selectedNode", selectedNode);
|
|
154
150
|
if (isLocked(selectedNode)) {
|
|
155
151
|
onNodeSelected?.(null);
|
|
156
152
|
return;
|
|
@@ -334,6 +330,7 @@
|
|
|
334
330
|
const refreshHighlightFrame = (node, nodeProvider) => {
|
|
335
331
|
const frame = getHighlightFrameElement(nodeProvider);
|
|
336
332
|
const zoom = getCanvasWindowValue(["zoom", "current"]) ?? 1;
|
|
333
|
+
console.log("1. refreshHighlightFrame", node);
|
|
337
334
|
if (!frame)
|
|
338
335
|
return;
|
|
339
336
|
if (zoom >= 0.3) {
|
|
@@ -347,6 +344,7 @@
|
|
|
347
344
|
frame.style.setProperty("--frame-left", `${left}px`);
|
|
348
345
|
frame.style.setProperty("--frame-width", `${width}px`);
|
|
349
346
|
frame.style.setProperty("--frame-height", `${height}px`);
|
|
347
|
+
console.log("2. refreshHighlightFrame", top, left, width, height);
|
|
350
348
|
};
|
|
351
349
|
|
|
352
350
|
const updateHighlightFrameVisibility = (node, nodeProvider) => {
|
|
@@ -541,8 +539,6 @@
|
|
|
541
539
|
});
|
|
542
540
|
mutationObserver.observe(node, {
|
|
543
541
|
attributes: true,
|
|
544
|
-
subtree: true,
|
|
545
|
-
childList: true,
|
|
546
542
|
characterData: true,
|
|
547
543
|
});
|
|
548
544
|
nodeResizeObserver = connectResizeObserver(node, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MarkupCanvas={})}(this,function(e){"use strict";function t(e){let t=null,n=null;const o=(...o)=>{n=o,null===t&&(t=requestAnimationFrame(()=>{n&&e(...n),t=null,n=null}))};return o.cleanup=()=>{null!==t&&(cancelAnimationFrame(t),t=null,n=null)},o}const n=e=>{const t=window.canvas;return e.reduce((e,t)=>e?.[t],t)};const o=(e,t)=>{const n=new ResizeObserver(e=>{t(e)});return n.observe(e),n};function r(e){return e.querySelector(".highlight-frame")}const s=e=>{if(!e)return;const t=r(e);t&&t.remove()},l=["path","rect","circle","ellipse","polygon","line","polyline","text","text-noci"];let a=[],i=0;const d=(e,t)=>{let n=null;const o=e.clientX,r=e.clientY,s=e.metaKey||e.ctrlKey,d=((e,t)=>{const n=document.elementsFromPoint(e,t);return Array.from(n).reduce((e,t)=>e.found?e:"node-provider"===t.getAttribute("data-role")?(e.found=!0,e):(e.elements.push(t),e),{elements:[],found:!1}).elements})(o,r).filter(e=>!l.includes(e.tagName.toLowerCase())&&!e.classList.contains("select-none"));if(t&&d.includes(t))return t;if(s)return a=[],n=d[0],n;var c,u;u=d,(c=a).length===u.length&&c.every((e,t)=>e===u[t])?i<=d.length&&i++:i=0;return n=d[d.length-1-i],a=d,n},c=(e,t,n,o)=>{const r=e=>{((e,t)=>{if("application"===e.data.source&&"selectedNodeChanged"===e.data.action){const o=e.data.data,r=document.querySelector(`[data-node-id="${o}"]`);if(n=r,n?.classList.contains("select-none"))return void t?.(null);r&&t?.(r)}var n})(e,t)},l=n=>{((e,t,n,o)=>{if(e.preventDefault(),e.stopPropagation(),t&&!t.contains(e.target))return s(t),void o(null);o(d(e,n))})(n,e,o(),t)},a=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),n?.())};return window.addEventListener("message",r),document.addEventListener("click",l),document.addEventListener("keydown",a),()=>{window.removeEventListener("message",r),document.removeEventListener("click",l),document.removeEventListener("keydown",a)}};function u(e,t){const o=e.getBoundingClientRect(),r=t.getBoundingClientRect(),s=o.top-r.top,l=o.left-r.left,a=n(["zoom","current"])??1;return{top:parseFloat((s/a).toFixed(5)),left:parseFloat((l/a).toFixed(5)),width:Math.max(4,parseFloat((o.width/a).toFixed(5))),height:parseFloat((o.height/a).toFixed(5))}}const m=(e,t)=>{const n=document.createElement("div");n.className="node-tools",t.appendChild(n),((e,t)=>{const n=document.createElement("div");n.className="tag-label",n.textContent=e.tagName.toLowerCase(),t.appendChild(n)})(e,n)},p=(e,t)=>{if(!e)return;const o=r(t);o&&o.remove();const s=((e,t)=>{const{top:o,left:r,width:s,height:l}=u(e,t),a=n(["zoom","current"])??1;document.body.style.setProperty("--zoom",a.toString()),document.body.style.setProperty("--stroke-width",(2/a).toFixed(3));const i=document.createElement("div");i.classList.add("highlight-frame"),i.style.setProperty("--frame-top",`${o}px`),i.style.setProperty("--frame-left",`${r}px`),i.style.setProperty("--frame-width",`${s}px`),i.style.setProperty("--frame-height",`${l}px`);const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.classList.add("highlight-frame-svg");const c=document.createElementNS("http://www.w3.org/2000/svg","rect");return c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.classList.add("highlight-frame-rect"),d.appendChild(c),i.appendChild(d),i})(e,t);"true"===e.contentEditable&&s.classList.add("is-editable"),m(e,s),t.appendChild(s)},h=(e,t)=>{const o=r(t),s=n(["zoom","current"])??1;if(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MarkupCanvas={})}(this,function(e){"use strict";function t(e){let t=null,n=null;const o=(...o)=>{n=o,null===t&&(t=requestAnimationFrame(()=>{n&&e(...n),t=null,n=null}))};return o.cleanup=()=>{null!==t&&(cancelAnimationFrame(t),t=null,n=null)},o}const n=e=>{const t=window.canvas;return e.reduce((e,t)=>e?.[t],t)};const o=(e,t)=>{const n=new ResizeObserver(e=>{t(e)});return n.observe(e),n};function r(e){return e.querySelector(".highlight-frame")}const s=e=>{if(!e)return;const t=r(e);t&&t.remove()},l=["path","rect","circle","ellipse","polygon","line","polyline","text","text-noci"];let a=[],i=0;const d=(e,t)=>{let n=null;const o=e.clientX,r=e.clientY,s=e.metaKey||e.ctrlKey,d=((e,t)=>{const n=document.elementsFromPoint(e,t);return Array.from(n).reduce((e,t)=>e.found?e:"node-provider"===t.getAttribute("data-role")?(e.found=!0,e):(e.elements.push(t),e),{elements:[],found:!1}).elements})(o,r).filter(e=>!l.includes(e.tagName.toLowerCase())&&!e.classList.contains("select-none"));if(t&&d.includes(t))return t;if(s)return a=[],n=d[0],n;var c,u;u=d,(c=a).length===u.length&&c.every((e,t)=>e===u[t])?i<=d.length&&i++:i=0;return n=d[d.length-1-i],a=d,n},c=(e,t,n,o)=>{const r=e=>{((e,t)=>{if("application"===e.data.source&&"selectedNodeChanged"===e.data.action){const o=e.data.data,r=document.querySelector(`[data-node-id="${o}"]`);if(console.log("selectedNode",r),n=r,n?.classList.contains("select-none"))return void t?.(null);r&&t?.(r)}var n})(e,t)},l=n=>{((e,t,n,o)=>{if(e.preventDefault(),e.stopPropagation(),t&&!t.contains(e.target))return s(t),void o(null);o(d(e,n))})(n,e,o(),t)},a=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),n?.())};return window.addEventListener("message",r),document.addEventListener("click",l),document.addEventListener("keydown",a),()=>{window.removeEventListener("message",r),document.removeEventListener("click",l),document.removeEventListener("keydown",a)}};function u(e,t){const o=e.getBoundingClientRect(),r=t.getBoundingClientRect(),s=o.top-r.top,l=o.left-r.left,a=n(["zoom","current"])??1;return{top:parseFloat((s/a).toFixed(5)),left:parseFloat((l/a).toFixed(5)),width:Math.max(4,parseFloat((o.width/a).toFixed(5))),height:parseFloat((o.height/a).toFixed(5))}}const m=(e,t)=>{const n=document.createElement("div");n.className="node-tools",t.appendChild(n),((e,t)=>{const n=document.createElement("div");n.className="tag-label",n.textContent=e.tagName.toLowerCase(),t.appendChild(n)})(e,n)},p=(e,t)=>{if(!e)return;const o=r(t);o&&o.remove();const s=((e,t)=>{const{top:o,left:r,width:s,height:l}=u(e,t),a=n(["zoom","current"])??1;document.body.style.setProperty("--zoom",a.toString()),document.body.style.setProperty("--stroke-width",(2/a).toFixed(3));const i=document.createElement("div");i.classList.add("highlight-frame"),i.style.setProperty("--frame-top",`${o}px`),i.style.setProperty("--frame-left",`${r}px`),i.style.setProperty("--frame-width",`${s}px`),i.style.setProperty("--frame-height",`${l}px`);const d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.classList.add("highlight-frame-svg");const c=document.createElementNS("http://www.w3.org/2000/svg","rect");return c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.classList.add("highlight-frame-rect"),d.appendChild(c),i.appendChild(d),i})(e,t);"true"===e.contentEditable&&s.classList.add("is-editable"),m(e,s),t.appendChild(s)},h=(e,t)=>{const o=r(t),s=n(["zoom","current"])??1;if(console.log("1. refreshHighlightFrame",e),!o)return;s>=.3?t.style.setProperty("--tool-opacity","1"):t.style.setProperty("--tool-opacity","0");const{top:l,left:a,width:i,height:d}=u(e,t);o.style.setProperty("--frame-top",`${l}px`),o.style.setProperty("--frame-left",`${a}px`),o.style.setProperty("--frame-width",`${i}px`),o.style.setProperty("--frame-height",`${d}px`),console.log("2. refreshHighlightFrame",l,a,i,d)},f=(e,t)=>{const n=r(t);if(!n)return;const o=e.classList.contains("hidden")||e.classList.contains("select-none")?"none":"";n.style.display=o;const s=n.querySelector(".tag-label");s&&(s.style.display=o)},v=e=>{const t=e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),(()=>{const e=window.getSelection();if(e&&e.rangeCount>0){const t=e.getRangeAt(0);t.deleteContents();const n=document.createElement("br");t.insertNode(n),t.setStartAfter(n),t.setEndAfter(n),e.removeAllRanges(),e.addRange(t)}})())};return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},y=(e,t)=>{const n=((e,t)=>{const n=new MutationObserver(e=>{t(e)});return n.observe(e,{subtree:!0,childList:!0,characterData:!0}),n})(e,()=>{h(e,t)});return()=>n.disconnect()},g=()=>{let e=null,t=!1,o=null;const r=()=>{if(t||!e)return;t=!0;var r;(r=e).contentEditable="false",r.classList.remove("is-editable"),r.style.outline="none",(()=>{const e=n(["keyboard","disableTextEditMode"]);e?.()})(),o?.(),e=null,t=!1};return{enableEditMode:(t,s)=>{if(e===t)return;e&&e!==t&&r();const l=(e=>Array.from(e.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim()))(t);l&&(e=t,(e=>{e.contentEditable="true",e.classList.add("is-editable"),e.style.outline="none"})(t),(()=>{const e=n(["keyboard","enableTextEditMode"]);e?.()})(),o=((e,t,n)=>{if(!t)return()=>{};e.addEventListener("blur",n);const o=v(e),r=y(e,t);return()=>{e.removeEventListener("blur",n),o(),r?.()}})(t,s,r))},blurEditMode:r,getEditableNode:()=>e,isEditing:()=>null!==e}},b=320,w=1680,E=[{name:"Mobile",rawValue:390,value:"320px"},{name:"Tablet Portrait",rawValue:768,value:"768px"},{name:"Tablet Landscape",rawValue:1024,value:"1024px"},{name:"Notebook",rawValue:1280,value:"1280px"},{name:"Desktop",rawValue:1680,value:"1680px"}],x=(e,t,n)=>{const o=parseFloat(document.body.dataset.zoom||"1"),r=((e,t)=>{const n=e+Math.round(t);return Math.max(b,Math.min(w,n))})(n,(e.clientX-t)/o);return r},L=(e,t)=>{e.style.setProperty("--container-width",`${t}px`),((e,t)=>{e.querySelectorAll(".resize-preset-button").forEach((e,n)=>{n<E.length&&(E[n].rawValue===t?e.classList.add("is-active"):e.classList.remove("is-active"))})})(e,t)};e.createCanvasObserver=function(){const e=document.querySelector(".transform-layer");if(!e)return{disconnect:()=>{}};const o=t(()=>{(()=>{const e=n(["zoom","current"]);document.body.style.setProperty("--zoom",e.toFixed(5)),document.body.style.setProperty("--stroke-width",(2/e).toFixed(3)),document.body.dataset.zoom=e.toFixed(5),document.body.dataset.strokeWidth=(2/e).toFixed(3)})()}),r=new MutationObserver(()=>{o()});return r.observe(e,{attributes:!0,attributeOldValue:!0,subtree:!0,childList:!0}),{disconnect:function(){o.cleanup(),r.disconnect()}}},e.createNodeTools=e=>{const t=e;let n=null,r=null,l=null,a=null;const i=g(),d=function(e){let t=null,n=null,o=null;const r=(...r)=>{o=r,null===t&&(t=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{if(o){const r=o;t=null,n=null,o=null,e(...r)}})}))};return r.cleanup=()=>{null!==t&&(cancelAnimationFrame(t),t=null),null!==n&&(cancelAnimationFrame(n),n=null),o=null},r}(h),u=e=>{if(a!==e){if(i.isEditing()){const t=i.getEditableNode();t&&t!==e&&i.blurEditMode()}var s,c;n?.disconnect(),r?.disconnect(),l?.disconnect(),e&&t&&(i.enableEditMode(e,t),n=o(t,()=>{d(e,t)}),l=new MutationObserver(()=>{d(e,t),f(e,t)}),l.observe(e,{attributes:!0,characterData:!0}),r=o(e,()=>{d(e,t),f(e,t)})),a=e,s="selectedNodeChanged",c=e?.getAttribute("data-node-id")??null,window.parent.postMessage({source:"node-edit-utils",action:s,data:c,timestamp:Date.now()},"*"),p(e,t),e&&t&&f(e,t)}},m=c(t,u,()=>{i.isEditing()&&i.blurEditMode(),a&&t&&(s(t),a=null,n?.disconnect(),r?.disconnect(),l?.disconnect())},i.getEditableNode),v={selectNode:u,getSelectedNode:()=>a,refreshHighlightFrame:()=>{d(a,t)},clearSelectedNode:()=>{s(t),a=null,n?.disconnect(),r?.disconnect(),l?.disconnect()},getEditableNode:()=>i.getEditableNode(),cleanup:()=>{m(),n?.disconnect(),r?.disconnect(),l?.disconnect(),i.blurEditMode(),d.cleanup()}};var y,b;return y="nodeTools",b=v,"undefined"!=typeof window&&(window[y]=b),v},e.createViewport=e=>{const n=document.querySelector(".canvas-container"),o=e.querySelector(".resize-handle");o&&o.remove();const r=(e=>{const t=document.createElement("div");return t.className="resize-handle",e.appendChild(t),t})(e);e.style.setProperty("--container-width","400px"),((e,t,n)=>{const o=document.createElement("div");o.className="resize-presets",E.forEach(e=>{const r=document.createElement("button");r.textContent=e.name,r.className="resize-preset-button",r.addEventListener("click",()=>{n(t,e.rawValue)}),o.appendChild(r)}),e.appendChild(o)})(r,e,L);let s=!1,l=0,a=0;const i=t(t=>{if(!s)return;n&&(n.style.cursor="ew-resize");const o=x(t,l,a);L(e,o)}),d=((e,t,n,o,r)=>(e.addEventListener("mousedown",t),document.addEventListener("mousemove",n),document.addEventListener("mouseup",o),window.addEventListener("blur",r),()=>{e.removeEventListener("mousedown",t),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",o),window.removeEventListener("blur",r)}))(r,t=>{t.preventDefault(),t.stopPropagation(),s=!0,l=t.clientX,a=e.offsetWidth},i,e=>{e.preventDefault(),e.stopPropagation(),n&&(n.style.cursor="default"),s=!1},()=>{s=!1});return{setWidth:t=>{L(e,t)},cleanup:()=>{s=!1,i?.cleanup(),d(),r.remove()}}}});
|
package/package.json
CHANGED
|
@@ -6,6 +6,8 @@ export const refreshHighlightFrame = (node: HTMLElement, nodeProvider: HTMLEleme
|
|
|
6
6
|
const frame = getHighlightFrameElement(nodeProvider);
|
|
7
7
|
const zoom = getCanvasWindowValue(["zoom", "current"]) ?? 1;
|
|
8
8
|
|
|
9
|
+
console.log("1. refreshHighlightFrame", node);
|
|
10
|
+
|
|
9
11
|
if (!frame) return;
|
|
10
12
|
|
|
11
13
|
if (zoom >= 0.3) {
|
|
@@ -20,4 +22,6 @@ export const refreshHighlightFrame = (node: HTMLElement, nodeProvider: HTMLEleme
|
|
|
20
22
|
frame.style.setProperty("--frame-left", `${left}px`);
|
|
21
23
|
frame.style.setProperty("--frame-width", `${width}px`);
|
|
22
24
|
frame.style.setProperty("--frame-height", `${height}px`);
|
|
25
|
+
|
|
26
|
+
console.log("2. refreshHighlightFrame", top, left, width, height);
|
|
23
27
|
};
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { isLocked } from "../node-tools/select/helpers/isLocked";
|
|
2
2
|
|
|
3
3
|
export const processPostMessage = (event: MessageEvent, onNodeSelected?: (node: HTMLElement | null) => void) => {
|
|
4
|
-
// if (event.data.source === "markup-canvas" && event.data.canvasName === "canvas") {
|
|
5
|
-
// if (event.data.action === "zoom") {
|
|
6
|
-
// // Zoom handling can be implemented here if needed
|
|
7
|
-
// }
|
|
8
|
-
// }
|
|
9
|
-
|
|
10
4
|
if (event.data.source === "application") {
|
|
11
5
|
if (event.data.action === "selectedNodeChanged") {
|
|
12
6
|
const nodeId = event.data.data;
|
|
13
7
|
const selectedNode = document.querySelector(`[data-node-id="${nodeId}"]`) as HTMLElement | null;
|
|
14
8
|
|
|
9
|
+
console.log("selectedNode", selectedNode);
|
|
10
|
+
|
|
15
11
|
if (isLocked(selectedNode)) {
|
|
16
12
|
onNodeSelected?.(null);
|
|
17
13
|
return;
|