@nuasite/cms 0.11.0 → 0.11.1
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/editor.js +4903 -4880
- package/package.json +1 -1
- package/src/editor/index.tsx +38 -1
package/package.json
CHANGED
package/src/editor/index.tsx
CHANGED
|
@@ -135,7 +135,44 @@ const CmsUI = () => {
|
|
|
135
135
|
}
|
|
136
136
|
}, [])
|
|
137
137
|
|
|
138
|
-
// Send
|
|
138
|
+
// Send select-mode click selection to parent window via postMessage
|
|
139
|
+
const prevSelectModeRef = useRef<string | null>(null)
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
const selected = signals.selectModeElement.value
|
|
142
|
+
const id = selected?.id ?? null
|
|
143
|
+
if (id === prevSelectModeRef.current) return
|
|
144
|
+
prevSelectModeRef.current = id
|
|
145
|
+
|
|
146
|
+
if (selected) {
|
|
147
|
+
const manifestData = signals.manifest.value
|
|
148
|
+
const isComponent = selected.type === 'component'
|
|
149
|
+
const cmsId = isComponent ? null : selected.id
|
|
150
|
+
const componentId = isComponent ? selected.id : selected.element.getAttribute('data-cms-component-id') ?? undefined
|
|
151
|
+
const entry = cmsId ? manifestData.entries[cmsId] : undefined
|
|
152
|
+
const instance = componentId ? manifestData.components?.[componentId] : undefined
|
|
153
|
+
const rect = selected.element.getBoundingClientRect()
|
|
154
|
+
|
|
155
|
+
const msg: CmsElementSelectedMessage = {
|
|
156
|
+
type: 'cms-element-selected',
|
|
157
|
+
element: buildSelectedElement({
|
|
158
|
+
cmsId,
|
|
159
|
+
isComponent,
|
|
160
|
+
componentName: isComponent ? selected.label : undefined,
|
|
161
|
+
componentId,
|
|
162
|
+
tagName: selected.element.tagName.toLowerCase(),
|
|
163
|
+
rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
164
|
+
entry,
|
|
165
|
+
instance,
|
|
166
|
+
}),
|
|
167
|
+
}
|
|
168
|
+
postToParent(msg)
|
|
169
|
+
} else {
|
|
170
|
+
const msg: CmsElementDeselectedMessage = { type: 'cms-element-deselected' }
|
|
171
|
+
postToParent(msg)
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
// Send hovered element info to parent window via postMessage (when inside an iframe)
|
|
139
176
|
const prevOutlineRef = useRef<{ cmsId: string | null; isComponent: boolean }>({ cmsId: null, isComponent: false })
|
|
140
177
|
useEffect(() => {
|
|
141
178
|
const prev = prevOutlineRef.current
|