@particle-academy/fancy-cms-ui 0.6.0 → 0.7.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/{chunk-TG5O4K75.js → chunk-LY6ID2J2.js} +21 -8
- package/dist/chunk-LY6ID2J2.js.map +1 -0
- package/dist/{chunk-W525ACX7.js → chunk-R7HDS4VG.js} +3 -3
- package/dist/{chunk-W525ACX7.js.map → chunk-R7HDS4VG.js.map} +1 -1
- package/dist/{chunk-LVOBZ2OO.js → chunk-SYRU2X45.js} +3 -3
- package/dist/{chunk-LVOBZ2OO.js.map → chunk-SYRU2X45.js.map} +1 -1
- package/dist/editor.cjs +40 -25
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.d.cts +2 -2
- package/dist/editor.d.ts +2 -2
- package/dist/editor.js +3 -3
- package/dist/index.cjs +54 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -5
- package/dist/index.d.ts +57 -5
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +36 -11
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +2 -2
- package/dist/{registry-CvzbUd5E.d.cts → registry-CUNaBqTs.d.cts} +17 -1
- package/dist/{registry-CvzbUd5E.d.ts → registry-CUNaBqTs.d.ts} +17 -1
- package/dist/{useEditor-DFHy1dWc.d.ts → useEditor-aPH5falI.d.ts} +1 -1
- package/dist/{useEditor-DLBWS6j0.d.cts → useEditor-wdlYQMHg.d.cts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-TG5O4K75.js.map +0 -1
package/dist/editor.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-
|
|
1
|
+
export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-wdlYQMHg.cjs';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, q as StyleProps, L as LayoutMode } from './registry-
|
|
3
|
+
import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, q as StyleProps, L as LayoutMode } from './registry-CUNaBqTs.cjs';
|
|
4
4
|
import '@particle-academy/fancy-doc-commons';
|
|
5
5
|
|
|
6
6
|
/** Animatable per-node transform (mirrors fancy-motion's NodeState, kept local to avoid a hard dep). */
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-
|
|
1
|
+
export { C as Canvas, a as CanvasProps, E as Editor, b as EditorAction, c as EditorApi, d as EditorProps, e as EditorState, I as Inspector, f as InspectorProps, L as LayersPanel, g as LayersPanelProps, i as editorReduce, j as initEditor, u as useEditor } from './useEditor-aPH5falI.js';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, q as StyleProps, L as LayoutMode } from './registry-
|
|
3
|
+
import { P as PageDoc, h as ElementRegistry, g as DataContext, N as Node, q as StyleProps, L as LayoutMode } from './registry-CUNaBqTs.js';
|
|
4
4
|
import '@particle-academy/fancy-doc-commons';
|
|
5
5
|
|
|
6
6
|
/** Animatable per-node transform (mirrors fancy-motion's NodeState, kept local to avoid a hard dep). */
|
package/dist/editor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useEditor, useLatestRef, CONTAINER_TYPES, ADD_DEFAULTS, ADD_MENU } from './chunk-
|
|
2
|
-
export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-
|
|
3
|
-
import { isBinding, lastRootId, childrenOf, CmsPage, defaultRegistry } from './chunk-
|
|
1
|
+
import { useEditor, useLatestRef, CONTAINER_TYPES, ADD_DEFAULTS, ADD_MENU } from './chunk-SYRU2X45.js';
|
|
2
|
+
export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-SYRU2X45.js';
|
|
3
|
+
import { isBinding, lastRootId, childrenOf, CmsPage, defaultRegistry } from './chunk-LY6ID2J2.js';
|
|
4
4
|
import { useState, useRef, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
5
5
|
import { ContextMenu } from '@particle-academy/react-fancy';
|
|
6
6
|
import { fractionalKey } from '@particle-academy/fancy-doc-commons';
|
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,11 @@ var react = require('react');
|
|
|
8
8
|
function isBinding(v) {
|
|
9
9
|
return typeof v === "object" && v !== null && typeof v.$bind === "string";
|
|
10
10
|
}
|
|
11
|
+
function hasNodeMap(value) {
|
|
12
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
13
|
+
const nodes = value.nodes;
|
|
14
|
+
return typeof nodes === "object" && nodes !== null && !Array.isArray(nodes);
|
|
15
|
+
}
|
|
11
16
|
var DEFAULT_BREAKPOINTS = {
|
|
12
17
|
base: 0,
|
|
13
18
|
md: 768,
|
|
@@ -23,10 +28,44 @@ function emptyDoc(id, slug = "/") {
|
|
|
23
28
|
nodes: {}
|
|
24
29
|
};
|
|
25
30
|
}
|
|
31
|
+
|
|
32
|
+
// src/document/bindings.ts
|
|
33
|
+
function isSource(v) {
|
|
34
|
+
return Array.isArray(v) && v.length > 0 && v.every((seg) => typeof seg === "string" || typeof seg === "number");
|
|
35
|
+
}
|
|
36
|
+
function isLiveBinding(v) {
|
|
37
|
+
return isBinding(v) && isSource(v.$source);
|
|
38
|
+
}
|
|
39
|
+
function eachBinding(value, visit) {
|
|
40
|
+
if (isBinding(value)) {
|
|
41
|
+
visit(value);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
for (const item of value) eachBinding(item, visit);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === "object" && value !== null) {
|
|
49
|
+
for (const item of Object.values(value)) eachBinding(item, visit);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function bindingSources(doc) {
|
|
53
|
+
const seen = /* @__PURE__ */ new Map();
|
|
54
|
+
const take = (b) => {
|
|
55
|
+
if (!isLiveBinding(b)) return;
|
|
56
|
+
seen.set(JSON.stringify(b.$source), b.$source);
|
|
57
|
+
};
|
|
58
|
+
for (const node of Object.values(doc.nodes)) {
|
|
59
|
+
eachBinding(node.props, take);
|
|
60
|
+
if (node.repeat?.each) eachBinding(node.repeat.each, take);
|
|
61
|
+
}
|
|
62
|
+
return [...seen.values()];
|
|
63
|
+
}
|
|
26
64
|
function childrenOf(doc, parent) {
|
|
27
65
|
return fancyDocCommons.childrenOf(doc, parent);
|
|
28
66
|
}
|
|
29
67
|
function rootIds(doc) {
|
|
68
|
+
if (!hasNodeMap(doc)) return [];
|
|
30
69
|
return childrenOf(doc, null).map((n) => n.id);
|
|
31
70
|
}
|
|
32
71
|
function lastRootId(doc) {
|
|
@@ -221,17 +260,23 @@ function pick(obj, keys) {
|
|
|
221
260
|
for (const k of keys) out[k] = obj[k];
|
|
222
261
|
return out;
|
|
223
262
|
}
|
|
263
|
+
function normalizeDoc(input2) {
|
|
264
|
+
if (hasNodeMap(input2)) return input2;
|
|
265
|
+
const id = typeof input2 === "object" && input2 !== null && !Array.isArray(input2) && typeof input2.id === "string" ? input2.id : "malformed";
|
|
266
|
+
return emptyDoc(id);
|
|
267
|
+
}
|
|
224
268
|
function migrateDocVerbose(input2) {
|
|
225
|
-
const
|
|
269
|
+
const normalized = normalizeDoc(input2);
|
|
270
|
+
const legacy = normalized;
|
|
226
271
|
const sections = legacy.sections;
|
|
227
272
|
if (!Array.isArray(sections)) {
|
|
228
|
-
return { doc:
|
|
273
|
+
return { doc: normalized, migrated: false, danglingIds: [], unlistedRootIds: [] };
|
|
229
274
|
}
|
|
230
275
|
const danglingIds = [];
|
|
231
276
|
const ordered = [];
|
|
232
277
|
const seen = /* @__PURE__ */ new Set();
|
|
233
278
|
for (const id of sections) {
|
|
234
|
-
if (!
|
|
279
|
+
if (!normalized.nodes[id]) {
|
|
235
280
|
danglingIds.push(id);
|
|
236
281
|
continue;
|
|
237
282
|
}
|
|
@@ -239,9 +284,9 @@ function migrateDocVerbose(input2) {
|
|
|
239
284
|
seen.add(id);
|
|
240
285
|
ordered.push(id);
|
|
241
286
|
}
|
|
242
|
-
const unlistedRootIds = Object.values(
|
|
287
|
+
const unlistedRootIds = Object.values(normalized.nodes).filter((n) => n.parent === null && !seen.has(n.id)).sort((a, b) => a.order < b.order ? -1 : a.order > b.order ? 1 : 0).map((n) => n.id);
|
|
243
288
|
const finalOrder = [...ordered, ...unlistedRootIds];
|
|
244
|
-
const nodes = { ...
|
|
289
|
+
const nodes = { ...normalized.nodes };
|
|
245
290
|
let prev = null;
|
|
246
291
|
for (const id of finalOrder) {
|
|
247
292
|
const key = fancyDocCommons.fractionalKey(prev, null);
|
|
@@ -359,6 +404,7 @@ ${body}
|
|
|
359
404
|
${indent}}`;
|
|
360
405
|
}
|
|
361
406
|
function emitDocCss(doc) {
|
|
407
|
+
if (!hasNodeMap(doc)) return "";
|
|
362
408
|
const breakpointPx = DEFAULT_BREAKPOINTS;
|
|
363
409
|
const blocks = [];
|
|
364
410
|
for (const id of Object.keys(doc.nodes).sort()) {
|
|
@@ -1079,6 +1125,7 @@ exports.Editor = Editor;
|
|
|
1079
1125
|
exports.Inspector = Inspector;
|
|
1080
1126
|
exports.LayersPanel = LayersPanel;
|
|
1081
1127
|
exports.RenderNode = RenderNode;
|
|
1128
|
+
exports.bindingSources = bindingSources;
|
|
1082
1129
|
exports.buildInsertOp = buildInsertOp;
|
|
1083
1130
|
exports.childrenOf = childrenOf;
|
|
1084
1131
|
exports.defaultRegistry = defaultRegistry;
|
|
@@ -1087,9 +1134,11 @@ exports.editorReduce = editorReduce;
|
|
|
1087
1134
|
exports.emitDocCss = emitDocCss;
|
|
1088
1135
|
exports.emptyDoc = emptyDoc;
|
|
1089
1136
|
exports.getPath = getPath;
|
|
1137
|
+
exports.hasNodeMap = hasNodeMap;
|
|
1090
1138
|
exports.initEditor = initEditor;
|
|
1091
1139
|
exports.invert = invert;
|
|
1092
1140
|
exports.isBinding = isBinding;
|
|
1141
|
+
exports.isLiveBinding = isLiveBinding;
|
|
1093
1142
|
exports.lastRootId = lastRootId;
|
|
1094
1143
|
exports.migrateDoc = migrateDoc;
|
|
1095
1144
|
exports.migrateDocVerbose = migrateDocVerbose;
|