@node-edit-utils/core 2.1.9 → 2.2.0
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/lib/node-tools/highlight/clearHighlightFrame.d.ts +1 -1
- package/dist/lib/node-tools/highlight/createCornerHandles.d.ts +1 -0
- package/dist/lib/node-tools/highlight/createHighlightFrame.d.ts +1 -1
- package/dist/lib/node-tools/highlight/createToolsContainer.d.ts +1 -1
- package/dist/lib/node-tools/highlight/helpers/getHighlightFrameElement.d.ts +1 -1
- package/dist/lib/node-tools/highlight/helpers/getScreenBounds.d.ts +6 -0
- package/dist/lib/node-tools/highlight/highlightNode.d.ts +1 -1
- package/dist/lib/node-tools/highlight/updateHighlightFrameVisibility.d.ts +1 -1
- package/dist/lib/node-tools/select/helpers/isComponentInstance.d.ts +1 -0
- package/dist/lib/node-tools/select/helpers/isInsideComponent.d.ts +1 -0
- package/dist/node-edit-utils.cjs.js +300 -155
- package/dist/node-edit-utils.esm.js +300 -155
- package/dist/node-edit-utils.umd.js +300 -155
- package/dist/node-edit-utils.umd.min.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/lib/canvas/createCanvasObserver.ts +8 -6
- package/src/lib/node-tools/createNodeTools.ts +27 -22
- package/src/lib/node-tools/events/click/handleNodeClick.ts +1 -1
- package/src/lib/node-tools/highlight/clearHighlightFrame.ts +7 -8
- package/src/lib/node-tools/highlight/createCornerHandles.ts +31 -0
- package/src/lib/node-tools/highlight/createHighlightFrame.ts +45 -24
- package/src/lib/node-tools/highlight/createToolsContainer.ts +4 -1
- package/src/lib/node-tools/highlight/helpers/getHighlightFrameElement.ts +2 -4
- package/src/lib/node-tools/highlight/helpers/getScreenBounds.ts +16 -0
- package/src/lib/node-tools/highlight/highlightNode.ts +28 -5
- package/src/lib/node-tools/highlight/refreshHighlightFrame.ts +113 -14
- package/src/lib/node-tools/highlight/updateHighlightFrameVisibility.ts +5 -5
- package/src/lib/node-tools/select/helpers/isComponentInstance.ts +3 -0
- package/src/lib/node-tools/select/helpers/isInsideComponent.ts +18 -0
- package/src/lib/node-tools/select/selectNode.ts +5 -1
- package/src/lib/post-message/processPostMessage.ts +0 -2
- package/src/lib/styles/styles.css +57 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getHighlightFrameElement } from "./helpers/getHighlightFrameElement";
|
|
2
2
|
|
|
3
|
-
export const updateHighlightFrameVisibility = (node: HTMLElement
|
|
4
|
-
const frame = getHighlightFrameElement(
|
|
3
|
+
export const updateHighlightFrameVisibility = (node: HTMLElement): void => {
|
|
4
|
+
const frame = getHighlightFrameElement();
|
|
5
5
|
if (!frame) return;
|
|
6
6
|
|
|
7
7
|
const hasHiddenClass = node.classList.contains("hidden") || node.classList.contains("select-none");
|
|
@@ -9,8 +9,8 @@ export const updateHighlightFrameVisibility = (node: HTMLElement, nodeProvider:
|
|
|
9
9
|
|
|
10
10
|
frame.style.display = displayValue;
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
|
|
12
|
+
const toolsWrapper = document.body.querySelector(".highlight-frame-tools-wrapper") as HTMLElement | null;
|
|
13
|
+
if (toolsWrapper) {
|
|
14
|
+
toolsWrapper.style.display = displayValue;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const isInsideComponent = (element: Element): boolean => {
|
|
2
|
+
let current: Element | null = element.parentElement;
|
|
3
|
+
|
|
4
|
+
while (current) {
|
|
5
|
+
if (current.getAttribute("data-instance") === "true") {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Stop at node-provider to avoid checking beyond the editable area
|
|
10
|
+
if (current.getAttribute("data-role") === "node-provider") {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
current = current.parentElement;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IGNORED_DOM_ELEMENTS } from "./constants";
|
|
2
2
|
import { getElementsFromPoint } from "./helpers/getElementsFromPoint";
|
|
3
|
+
import { isInsideComponent } from "./helpers/isInsideComponent";
|
|
3
4
|
import { targetSameCandidates } from "./helpers/targetSameCandidates";
|
|
4
5
|
|
|
5
6
|
let candidateCache: Element[] = [];
|
|
@@ -14,7 +15,10 @@ export const selectNode = (event: MouseEvent, editableNode: HTMLElement | null):
|
|
|
14
15
|
const clickThrough = event.metaKey || event.ctrlKey;
|
|
15
16
|
|
|
16
17
|
const candidates = getElementsFromPoint(clickX, clickY).filter(
|
|
17
|
-
(element) =>
|
|
18
|
+
(element) =>
|
|
19
|
+
!IGNORED_DOM_ELEMENTS.includes(element.tagName.toLowerCase()) &&
|
|
20
|
+
!element.classList.contains("select-none") &&
|
|
21
|
+
!isInsideComponent(element)
|
|
18
22
|
);
|
|
19
23
|
|
|
20
24
|
if (editableNode && candidates.includes(editableNode)) {
|
|
@@ -6,8 +6,6 @@ export const processPostMessage = (event: MessageEvent, onNodeSelected?: (node:
|
|
|
6
6
|
const nodeId = event.data.data;
|
|
7
7
|
const selectedNode = document.querySelector(`[data-node-id="${nodeId}"]`) as HTMLElement | null;
|
|
8
8
|
|
|
9
|
-
console.log("selectedNode", selectedNode);
|
|
10
|
-
|
|
11
9
|
if (isLocked(selectedNode)) {
|
|
12
10
|
onNodeSelected?.(null);
|
|
13
11
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--primary-color: oklch(0.6235 0.22 294);
|
|
3
3
|
--uncode-color: oklch(45.7% 0.24 277.023);
|
|
4
|
+
--component-color: oklch(65.6% 0.241 354.308);
|
|
4
5
|
|
|
5
6
|
--handle-color: oklch(55.2% 0.016 285.938);
|
|
6
7
|
--handle-color-transparent: oklch(55.2% 0.016 285.938 / 0.7);
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
|
|
9
10
|
--text-color-white: white;
|
|
10
11
|
|
|
12
|
+
--spacing-2xs: 0.1875rem;
|
|
11
13
|
--spacing-xs: 0.25rem;
|
|
12
14
|
--spacing-sm: 0.375rem;
|
|
13
15
|
--spacing-md: 0.5rem;
|
|
@@ -17,6 +19,7 @@
|
|
|
17
19
|
--transition-medium: 0.2s ease-in-out;
|
|
18
20
|
|
|
19
21
|
--z-index-high: 10000;
|
|
22
|
+
--z-index-highlight: 5000;
|
|
20
23
|
--z-index-medium: 1000;
|
|
21
24
|
|
|
22
25
|
--letter-spacing: 0.02em;
|
|
@@ -44,40 +47,68 @@
|
|
|
44
47
|
top: 0;
|
|
45
48
|
gap: var(--spacing-xs);
|
|
46
49
|
z-index: var(--z-index-high);
|
|
47
|
-
transform:
|
|
48
|
-
transform-origin: bottom
|
|
50
|
+
transform: translate3d(0, 100%, 0);
|
|
51
|
+
transform-origin: bottom center;
|
|
49
52
|
transition: opacity var(--transition-fast);
|
|
50
53
|
opacity: var(--tool-opacity);
|
|
51
|
-
padding-top: var(--spacing-
|
|
54
|
+
padding-top: var(--spacing-2xs);
|
|
52
55
|
display: flex;
|
|
53
56
|
justify-content: center;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
.highlight-frame {
|
|
57
|
-
position:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
height: var(--frame-height);
|
|
62
|
-
z-index: var(--z-index-medium);
|
|
59
|
+
.highlight-frame-overlay {
|
|
60
|
+
position: fixed;
|
|
61
|
+
inset: 0;
|
|
62
|
+
width: 100vw;
|
|
63
|
+
height: 100vh;
|
|
63
64
|
pointer-events: none;
|
|
64
|
-
|
|
65
|
-
letter-spacing: var(--letter-spacing);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.highlight-frame-svg {
|
|
69
|
-
position: absolute;
|
|
70
|
-
top: 0;
|
|
71
|
-
left: 0;
|
|
72
|
-
width: 100%;
|
|
73
|
-
height: 100%;
|
|
65
|
+
z-index: var(--z-index-highlight);
|
|
74
66
|
overflow: visible;
|
|
75
67
|
}
|
|
76
68
|
|
|
77
69
|
.highlight-frame-rect {
|
|
78
70
|
fill: none;
|
|
79
71
|
stroke: var(--primary-color);
|
|
80
|
-
stroke-width:
|
|
72
|
+
stroke-width: 2px; /* Fixed width - vector-effect keeps it crisp */
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.highlight-frame-overlay.is-instance .highlight-frame-rect {
|
|
76
|
+
stroke: var(--component-color);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.highlight-frame-handle {
|
|
80
|
+
fill: white;
|
|
81
|
+
stroke: var(--primary-color);
|
|
82
|
+
stroke-width: 1px;
|
|
83
|
+
pointer-events: auto;
|
|
84
|
+
cursor: nwse-resize;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.highlight-frame-overlay.is-instance .highlight-frame-handle {
|
|
88
|
+
stroke: var(--component-color);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.highlight-frame-handle.handle-top-left {
|
|
92
|
+
cursor: nwse-resize;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.highlight-frame-handle.handle-top-right {
|
|
96
|
+
cursor: nesw-resize;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.highlight-frame-handle.handle-bottom-right {
|
|
100
|
+
cursor: nwse-resize;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.highlight-frame-handle.handle-bottom-left {
|
|
104
|
+
cursor: nesw-resize;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.highlight-frame-tools-wrapper {
|
|
108
|
+
position: fixed;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
z-index: var(--z-index-highlight);
|
|
111
|
+
contain: layout style;
|
|
81
112
|
}
|
|
82
113
|
|
|
83
114
|
.tag-label {
|
|
@@ -95,6 +126,11 @@
|
|
|
95
126
|
justify-content: center;
|
|
96
127
|
}
|
|
97
128
|
|
|
129
|
+
.highlight-frame-tools-wrapper.is-instance .tag-label,
|
|
130
|
+
.node-tools.is-instance .tag-label {
|
|
131
|
+
background-color: var(--component-color);
|
|
132
|
+
}
|
|
133
|
+
|
|
98
134
|
.viewport {
|
|
99
135
|
position: relative;
|
|
100
136
|
width: var(--container-width);
|