@puckeditor/plugin-heading-analyzer 0.22.0-canary.d4985bc0 → 0.22.0-canary.f4f83ac1

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/index.d.mts CHANGED
@@ -308,7 +308,7 @@ type CustomFieldRender<Value extends any> = (props: {
308
308
  name: string;
309
309
  id: string;
310
310
  value: Value;
311
- onChange: (value: Value) => void;
311
+ onChange: (value: Value, uiState?: Partial<UiState>) => void;
312
312
  readOnly?: boolean;
313
313
  }) => ReactElement;
314
314
  interface CustomField<Value extends any> extends BaseField {
@@ -428,6 +428,7 @@ UserField extends BaseField = {}> = {
428
428
  metadata: ComponentMetadata;
429
429
  trigger: ResolveDataTrigger;
430
430
  parent: ComponentData | null;
431
+ root: ComponentData | null;
431
432
  }) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
432
433
  resolvePermissions?: (data: DataShape, params: {
433
434
  changed: Partial<Record<keyof FieldProps, boolean> & {
package/dist/index.d.ts CHANGED
@@ -308,7 +308,7 @@ type CustomFieldRender<Value extends any> = (props: {
308
308
  name: string;
309
309
  id: string;
310
310
  value: Value;
311
- onChange: (value: Value) => void;
311
+ onChange: (value: Value, uiState?: Partial<UiState>) => void;
312
312
  readOnly?: boolean;
313
313
  }) => ReactElement;
314
314
  interface CustomField<Value extends any> extends BaseField {
@@ -428,6 +428,7 @@ UserField extends BaseField = {}> = {
428
428
  metadata: ComponentMetadata;
429
429
  trigger: ResolveDataTrigger;
430
430
  parent: ComponentData | null;
431
+ root: ComponentData | null;
431
432
  }) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
432
433
  resolvePermissions?: (data: DataShape, params: {
433
434
  changed: Partial<Record<keyof FieldProps, boolean> & {
package/dist/index.js CHANGED
@@ -715,6 +715,15 @@ var flattenNode = (node, config) => {
715
715
  });
716
716
  };
717
717
 
718
+ // ../core/lib/data/to-component.ts
719
+ init_react_import();
720
+ var toComponent = (item) => {
721
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
722
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
723
+ type: "root"
724
+ });
725
+ };
726
+
718
727
  // ../core/lib/data/walk-app-state.ts
719
728
  function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
720
729
  var _a;
@@ -778,7 +787,7 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
778
787
  id
779
788
  });
780
789
  processRelatedZones(item, id, path);
781
- const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
790
+ const newItem = __spreadProps(__spreadValues({}, mappedItem), { props: newProps });
782
791
  const thisZoneCompound = path[path.length - 1];
783
792
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
784
793
  newNodeIndex[id] = {
@@ -818,17 +827,14 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
818
827
  );
819
828
  newZones[zoneCompound] = newContent2;
820
829
  }, newZones);
821
- const processedRoot = processItem(
822
- {
823
- type: "root",
824
- props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
825
- },
826
- [],
827
- -1
828
- );
829
- const root = __spreadProps(__spreadValues({}, state.data.root), {
830
- props: processedRoot.props
830
+ let rootAsComponent = toComponent({
831
+ props: __spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root)
831
832
  });
833
+ if (state.data.root.readOnly) {
834
+ rootAsComponent.readOnly = state.data.root.readOnly;
835
+ }
836
+ const processedRoot = processItem(rootAsComponent, [], -1);
837
+ const root = __spreadValues(__spreadValues({}, state.data.root), processedRoot);
832
838
  return __spreadProps(__spreadValues({}, state), {
833
839
  data: {
834
840
  root,
@@ -1657,44 +1663,39 @@ var createHistorySlice = (set, get) => {
1657
1663
 
1658
1664
  // ../core/store/slices/nodes.ts
1659
1665
  init_react_import();
1660
- var createNodesSlice = (set, get) => ({
1661
- nodes: {},
1662
- registerNode: (id, node) => {
1663
- const s = get().nodes;
1664
- const emptyNode = {
1665
- id,
1666
- methods: {
1667
- sync: () => null,
1668
- hideOverlay: () => null,
1669
- showOverlay: () => null
1670
- },
1671
- element: null
1672
- };
1673
- const existingNode = s.nodes[id];
1674
- set({
1675
- nodes: __spreadProps(__spreadValues({}, s), {
1676
- nodes: __spreadProps(__spreadValues({}, s.nodes), {
1677
- [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
1678
- id
1679
- })
1680
- })
1681
- })
1682
- });
1683
- },
1684
- unregisterNode: (id) => {
1685
- const s = get().nodes;
1686
- const existingNode = s.nodes[id];
1687
- if (existingNode) {
1688
- const newNodes = __spreadValues({}, s.nodes);
1689
- delete newNodes[id];
1690
- set({
1691
- nodes: __spreadProps(__spreadValues({}, s), {
1692
- nodes: newNodes
1693
- })
1666
+ var createNodesSlice = (_set, _get) => {
1667
+ const registry = /* @__PURE__ */ new Map();
1668
+ return {
1669
+ registerNode: (id, handle) => {
1670
+ registry.set(id, handle);
1671
+ },
1672
+ unregisterNode: (id) => {
1673
+ registry.delete(id);
1674
+ },
1675
+ syncNode: (id) => {
1676
+ var _a;
1677
+ if (!id) return;
1678
+ (_a = registry.get(id)) == null ? void 0 : _a.sync();
1679
+ },
1680
+ syncNodes: (ids) => {
1681
+ ids.forEach((id) => {
1682
+ var _a;
1683
+ if (!id) return;
1684
+ (_a = registry.get(id)) == null ? void 0 : _a.sync();
1694
1685
  });
1686
+ },
1687
+ setOverlayVisible: (id, visible) => {
1688
+ if (!id) return;
1689
+ const node = registry.get(id);
1690
+ if (!node) return;
1691
+ if (visible) {
1692
+ node.showOverlay();
1693
+ return;
1694
+ }
1695
+ node.hideOverlay();
1695
1696
  }
1696
- }
1697
- });
1697
+ };
1698
+ };
1698
1699
 
1699
1700
  // ../core/store/slices/permissions.ts
1700
1701
  init_react_import();
@@ -2270,23 +2271,13 @@ var createFieldsSlice = (_set, _get) => {
2270
2271
 
2271
2272
  // ../core/lib/resolve-component-data.ts
2272
2273
  init_react_import();
2273
-
2274
- // ../core/lib/data/to-component.ts
2275
- init_react_import();
2276
- var toComponent = (item) => {
2277
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
2278
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
2279
- type: "root"
2280
- });
2281
- };
2282
-
2283
- // ../core/lib/resolve-component-data.ts
2284
2274
  var cache = { lastChange: {} };
2285
- var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null) {
2275
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null, root = null) {
2286
2276
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2287
2277
  const resolvedItem = __spreadValues({}, item);
2288
2278
  const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2289
2279
  const id = "id" in item.props ? item.props.id : "root";
2280
+ const rootForItem = root != null ? root : "type" in item && item.type === "root" ? toComponent(item) : null;
2290
2281
  if (shouldRunResolver) {
2291
2282
  const {
2292
2283
  item: oldItem = null,
@@ -2309,7 +2300,8 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
2309
2300
  lastData: oldItem,
2310
2301
  metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2311
2302
  trigger,
2312
- parent
2303
+ parent,
2304
+ root: rootForItem
2313
2305
  });
2314
2306
  resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2315
2307
  if (Object.keys(readOnly).length) {
@@ -2317,6 +2309,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
2317
2309
  }
2318
2310
  }
2319
2311
  const itemAsComponentData = toComponent(resolvedItem);
2312
+ const rootForChildren = itemAsComponentData.type === "root" ? itemAsComponentData : rootForItem;
2320
2313
  let itemWithResolvedChildren = yield mapFields(
2321
2314
  resolvedItem,
2322
2315
  {
@@ -2332,7 +2325,8 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
2332
2325
  onResolveStart,
2333
2326
  onResolveEnd,
2334
2327
  trigger,
2335
- itemAsComponentData
2328
+ itemAsComponentData,
2329
+ rootForChildren
2336
2330
  )).node;
2337
2331
  })
2338
2332
  )
@@ -2423,6 +2417,8 @@ var createAppStore = (initialAppStore) => create()(
2423
2417
  },
2424
2418
  status: "LOADING",
2425
2419
  iframe: {},
2420
+ _experimentalFullScreenCanvas: false,
2421
+ _experimentalVirtualization: false,
2426
2422
  metadata: {},
2427
2423
  fieldTransforms: {}
2428
2424
  }, initialAppStore), {
@@ -2530,6 +2526,7 @@ var createAppStore = (initialAppStore) => create()(
2530
2526
  const parentId = (_a2 = state.indexes.nodes[componentId]) == null ? void 0 : _a2.parentId;
2531
2527
  const parentNode = parentId ? state.indexes.nodes[parentId] : null;
2532
2528
  const parentData = (_b2 = parentNode == null ? void 0 : parentNode.data) != null ? _b2 : null;
2529
+ const rootData = componentId === "root" ? toComponent(componentData) : toComponent(state.data.root);
2533
2530
  const timeouts = {};
2534
2531
  return yield resolveComponentData(
2535
2532
  componentData,
@@ -2549,7 +2546,8 @@ var createAppStore = (initialAppStore) => create()(
2549
2546
  timeouts[id]();
2550
2547
  }),
2551
2548
  trigger,
2552
- parentData
2549
+ parentData,
2550
+ rootData
2553
2551
  );
2554
2552
  }),
2555
2553
  resolveAndCommitData: () => __async(null, null, function* () {
@@ -2558,7 +2556,8 @@ var createAppStore = (initialAppStore) => create()(
2558
2556
  state,
2559
2557
  config,
2560
2558
  (content) => content,
2561
- (childItem) => {
2559
+ (childItem, path) => {
2560
+ if (path.length > 1) return childItem;
2562
2561
  resolveComponentData2(childItem, "load").then((resolved) => {
2563
2562
  const { state: state2 } = get();
2564
2563
  const node = state2.indexes.nodes[resolved.node.props.id];
package/dist/index.mjs CHANGED
@@ -703,6 +703,15 @@ var flattenNode = (node, config) => {
703
703
  });
704
704
  };
705
705
 
706
+ // ../core/lib/data/to-component.ts
707
+ init_react_import();
708
+ var toComponent = (item) => {
709
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
710
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
711
+ type: "root"
712
+ });
713
+ };
714
+
706
715
  // ../core/lib/data/walk-app-state.ts
707
716
  function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
708
717
  var _a;
@@ -766,7 +775,7 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
766
775
  id
767
776
  });
768
777
  processRelatedZones(item, id, path);
769
- const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
778
+ const newItem = __spreadProps(__spreadValues({}, mappedItem), { props: newProps });
770
779
  const thisZoneCompound = path[path.length - 1];
771
780
  const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
772
781
  newNodeIndex[id] = {
@@ -806,17 +815,14 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
806
815
  );
807
816
  newZones[zoneCompound] = newContent2;
808
817
  }, newZones);
809
- const processedRoot = processItem(
810
- {
811
- type: "root",
812
- props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
813
- },
814
- [],
815
- -1
816
- );
817
- const root = __spreadProps(__spreadValues({}, state.data.root), {
818
- props: processedRoot.props
818
+ let rootAsComponent = toComponent({
819
+ props: __spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root)
819
820
  });
821
+ if (state.data.root.readOnly) {
822
+ rootAsComponent.readOnly = state.data.root.readOnly;
823
+ }
824
+ const processedRoot = processItem(rootAsComponent, [], -1);
825
+ const root = __spreadValues(__spreadValues({}, state.data.root), processedRoot);
820
826
  return __spreadProps(__spreadValues({}, state), {
821
827
  data: {
822
828
  root,
@@ -1645,44 +1651,39 @@ var createHistorySlice = (set, get) => {
1645
1651
 
1646
1652
  // ../core/store/slices/nodes.ts
1647
1653
  init_react_import();
1648
- var createNodesSlice = (set, get) => ({
1649
- nodes: {},
1650
- registerNode: (id, node) => {
1651
- const s = get().nodes;
1652
- const emptyNode = {
1653
- id,
1654
- methods: {
1655
- sync: () => null,
1656
- hideOverlay: () => null,
1657
- showOverlay: () => null
1658
- },
1659
- element: null
1660
- };
1661
- const existingNode = s.nodes[id];
1662
- set({
1663
- nodes: __spreadProps(__spreadValues({}, s), {
1664
- nodes: __spreadProps(__spreadValues({}, s.nodes), {
1665
- [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
1666
- id
1667
- })
1668
- })
1669
- })
1670
- });
1671
- },
1672
- unregisterNode: (id) => {
1673
- const s = get().nodes;
1674
- const existingNode = s.nodes[id];
1675
- if (existingNode) {
1676
- const newNodes = __spreadValues({}, s.nodes);
1677
- delete newNodes[id];
1678
- set({
1679
- nodes: __spreadProps(__spreadValues({}, s), {
1680
- nodes: newNodes
1681
- })
1654
+ var createNodesSlice = (_set, _get) => {
1655
+ const registry = /* @__PURE__ */ new Map();
1656
+ return {
1657
+ registerNode: (id, handle) => {
1658
+ registry.set(id, handle);
1659
+ },
1660
+ unregisterNode: (id) => {
1661
+ registry.delete(id);
1662
+ },
1663
+ syncNode: (id) => {
1664
+ var _a;
1665
+ if (!id) return;
1666
+ (_a = registry.get(id)) == null ? void 0 : _a.sync();
1667
+ },
1668
+ syncNodes: (ids) => {
1669
+ ids.forEach((id) => {
1670
+ var _a;
1671
+ if (!id) return;
1672
+ (_a = registry.get(id)) == null ? void 0 : _a.sync();
1682
1673
  });
1674
+ },
1675
+ setOverlayVisible: (id, visible) => {
1676
+ if (!id) return;
1677
+ const node = registry.get(id);
1678
+ if (!node) return;
1679
+ if (visible) {
1680
+ node.showOverlay();
1681
+ return;
1682
+ }
1683
+ node.hideOverlay();
1683
1684
  }
1684
- }
1685
- });
1685
+ };
1686
+ };
1686
1687
 
1687
1688
  // ../core/store/slices/permissions.ts
1688
1689
  init_react_import();
@@ -2258,23 +2259,13 @@ var createFieldsSlice = (_set, _get) => {
2258
2259
 
2259
2260
  // ../core/lib/resolve-component-data.ts
2260
2261
  init_react_import();
2261
-
2262
- // ../core/lib/data/to-component.ts
2263
- init_react_import();
2264
- var toComponent = (item) => {
2265
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
2266
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
2267
- type: "root"
2268
- });
2269
- };
2270
-
2271
- // ../core/lib/resolve-component-data.ts
2272
2262
  var cache = { lastChange: {} };
2273
- var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null) {
2263
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null, root = null) {
2274
2264
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2275
2265
  const resolvedItem = __spreadValues({}, item);
2276
2266
  const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
2277
2267
  const id = "id" in item.props ? item.props.id : "root";
2268
+ const rootForItem = root != null ? root : "type" in item && item.type === "root" ? toComponent(item) : null;
2278
2269
  if (shouldRunResolver) {
2279
2270
  const {
2280
2271
  item: oldItem = null,
@@ -2297,7 +2288,8 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
2297
2288
  lastData: oldItem,
2298
2289
  metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
2299
2290
  trigger,
2300
- parent
2291
+ parent,
2292
+ root: rootForItem
2301
2293
  });
2302
2294
  resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
2303
2295
  if (Object.keys(readOnly).length) {
@@ -2305,6 +2297,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
2305
2297
  }
2306
2298
  }
2307
2299
  const itemAsComponentData = toComponent(resolvedItem);
2300
+ const rootForChildren = itemAsComponentData.type === "root" ? itemAsComponentData : rootForItem;
2308
2301
  let itemWithResolvedChildren = yield mapFields(
2309
2302
  resolvedItem,
2310
2303
  {
@@ -2320,7 +2313,8 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
2320
2313
  onResolveStart,
2321
2314
  onResolveEnd,
2322
2315
  trigger,
2323
- itemAsComponentData
2316
+ itemAsComponentData,
2317
+ rootForChildren
2324
2318
  )).node;
2325
2319
  })
2326
2320
  )
@@ -2411,6 +2405,8 @@ var createAppStore = (initialAppStore) => create()(
2411
2405
  },
2412
2406
  status: "LOADING",
2413
2407
  iframe: {},
2408
+ _experimentalFullScreenCanvas: false,
2409
+ _experimentalVirtualization: false,
2414
2410
  metadata: {},
2415
2411
  fieldTransforms: {}
2416
2412
  }, initialAppStore), {
@@ -2518,6 +2514,7 @@ var createAppStore = (initialAppStore) => create()(
2518
2514
  const parentId = (_a2 = state.indexes.nodes[componentId]) == null ? void 0 : _a2.parentId;
2519
2515
  const parentNode = parentId ? state.indexes.nodes[parentId] : null;
2520
2516
  const parentData = (_b2 = parentNode == null ? void 0 : parentNode.data) != null ? _b2 : null;
2517
+ const rootData = componentId === "root" ? toComponent(componentData) : toComponent(state.data.root);
2521
2518
  const timeouts = {};
2522
2519
  return yield resolveComponentData(
2523
2520
  componentData,
@@ -2537,7 +2534,8 @@ var createAppStore = (initialAppStore) => create()(
2537
2534
  timeouts[id]();
2538
2535
  }),
2539
2536
  trigger,
2540
- parentData
2537
+ parentData,
2538
+ rootData
2541
2539
  );
2542
2540
  }),
2543
2541
  resolveAndCommitData: () => __async(null, null, function* () {
@@ -2546,7 +2544,8 @@ var createAppStore = (initialAppStore) => create()(
2546
2544
  state,
2547
2545
  config,
2548
2546
  (content) => content,
2549
- (childItem) => {
2547
+ (childItem, path) => {
2548
+ if (path.length > 1) return childItem;
2550
2549
  resolveComponentData2(childItem, "load").then((resolved) => {
2551
2550
  const { state: state2 } = get();
2552
2551
  const node = state2.indexes.nodes[resolved.node.props.id];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/plugin-heading-analyzer",
3
- "version": "0.22.0-canary.d4985bc0",
3
+ "version": "0.22.0-canary.f4f83ac1",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "devDependencies": {
28
- "@puckeditor/core": "^0.22.0-canary.d4985bc0",
28
+ "@puckeditor/core": "^0.22.0-canary.f4f83ac1",
29
29
  "@types/minimatch": "3.0.5",
30
30
  "@types/react": "^19.0.1",
31
31
  "@types/react-dom": "^19.0.2",