@particle-academy/fancy-cms-ui 0.7.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/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-CoxNeC53.cjs';
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-CiPir27w.cjs';
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-DAE36OYU.js';
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-CiPir27w.js';
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-YOAZRQKN.js';
2
- export { Canvas, Editor, Inspector, LayersPanel, editorReduce, initEditor, useEditor } from './chunk-YOAZRQKN.js';
3
- import { isBinding, lastRootId, childrenOf, CmsPage, defaultRegistry } from './chunk-IWQQINCF.js';
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,
@@ -60,6 +65,7 @@ function childrenOf(doc, parent) {
60
65
  return fancyDocCommons.childrenOf(doc, parent);
61
66
  }
62
67
  function rootIds(doc) {
68
+ if (!hasNodeMap(doc)) return [];
63
69
  return childrenOf(doc, null).map((n) => n.id);
64
70
  }
65
71
  function lastRootId(doc) {
@@ -254,17 +260,23 @@ function pick(obj, keys) {
254
260
  for (const k of keys) out[k] = obj[k];
255
261
  return out;
256
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
+ }
257
268
  function migrateDocVerbose(input2) {
258
- const legacy = input2;
269
+ const normalized = normalizeDoc(input2);
270
+ const legacy = normalized;
259
271
  const sections = legacy.sections;
260
272
  if (!Array.isArray(sections)) {
261
- return { doc: input2, migrated: false, danglingIds: [], unlistedRootIds: [] };
273
+ return { doc: normalized, migrated: false, danglingIds: [], unlistedRootIds: [] };
262
274
  }
263
275
  const danglingIds = [];
264
276
  const ordered = [];
265
277
  const seen = /* @__PURE__ */ new Set();
266
278
  for (const id of sections) {
267
- if (!input2.nodes[id]) {
279
+ if (!normalized.nodes[id]) {
268
280
  danglingIds.push(id);
269
281
  continue;
270
282
  }
@@ -272,9 +284,9 @@ function migrateDocVerbose(input2) {
272
284
  seen.add(id);
273
285
  ordered.push(id);
274
286
  }
275
- const unlistedRootIds = Object.values(input2.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);
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);
276
288
  const finalOrder = [...ordered, ...unlistedRootIds];
277
- const nodes = { ...input2.nodes };
289
+ const nodes = { ...normalized.nodes };
278
290
  let prev = null;
279
291
  for (const id of finalOrder) {
280
292
  const key = fancyDocCommons.fractionalKey(prev, null);
@@ -392,6 +404,7 @@ ${body}
392
404
  ${indent}}`;
393
405
  }
394
406
  function emitDocCss(doc) {
407
+ if (!hasNodeMap(doc)) return "";
395
408
  const breakpointPx = DEFAULT_BREAKPOINTS;
396
409
  const blocks = [];
397
410
  for (const id of Object.keys(doc.nodes).sort()) {
@@ -1121,6 +1134,7 @@ exports.editorReduce = editorReduce;
1121
1134
  exports.emitDocCss = emitDocCss;
1122
1135
  exports.emptyDoc = emptyDoc;
1123
1136
  exports.getPath = getPath;
1137
+ exports.hasNodeMap = hasNodeMap;
1124
1138
  exports.initEditor = initEditor;
1125
1139
  exports.invert = invert;
1126
1140
  exports.isBinding = isBinding;