@measured/puck-plugin-heading-analyzer 0.19.0-canary.8d459e4e → 0.19.0-canary.91cb9cee
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.js +120 -38
- package/dist/index.mjs +120 -38
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -680,15 +680,113 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
680
680
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
681
681
|
};
|
682
682
|
|
683
|
+
// ../core/lib/data/populate-ids.ts
|
684
|
+
init_react_import();
|
685
|
+
|
686
|
+
// ../core/lib/data/walk-tree.ts
|
687
|
+
init_react_import();
|
688
|
+
|
689
|
+
// ../core/lib/data/map-slots.ts
|
690
|
+
init_react_import();
|
691
|
+
function mapSlotsAsync(_0, _1) {
|
692
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
693
|
+
const props = __spreadValues({}, item.props);
|
694
|
+
const propKeys = Object.keys(props);
|
695
|
+
for (let i = 0; i < propKeys.length; i++) {
|
696
|
+
const propKey = propKeys[i];
|
697
|
+
const itemType = "type" in item ? item.type : "root";
|
698
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
699
|
+
const content = props[propKey];
|
700
|
+
const mappedContent = recursive ? yield Promise.all(
|
701
|
+
content.map((item2) => __async(this, null, function* () {
|
702
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
703
|
+
}))
|
704
|
+
) : content;
|
705
|
+
props[propKey] = yield map(mappedContent, propKey);
|
706
|
+
}
|
707
|
+
}
|
708
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
709
|
+
});
|
710
|
+
}
|
711
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
712
|
+
var _a, _b;
|
713
|
+
const props = __spreadValues({}, item.props);
|
714
|
+
const propKeys = Object.keys(props);
|
715
|
+
for (let i = 0; i < propKeys.length; i++) {
|
716
|
+
const propKey = propKeys[i];
|
717
|
+
const itemType = "type" in item ? item.type : "root";
|
718
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
719
|
+
const content = props[propKey];
|
720
|
+
const mappedContent = content.map((item2) => {
|
721
|
+
return mapSlotsSync(item2, map, isSlot2);
|
722
|
+
});
|
723
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
724
|
+
}
|
725
|
+
}
|
726
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
727
|
+
}
|
728
|
+
|
729
|
+
// ../core/lib/data/walk-tree.ts
|
730
|
+
function walkTree(data, config, callbackFn) {
|
731
|
+
var _a, _b;
|
732
|
+
const isSlot2 = createIsSlotConfig(config);
|
733
|
+
const walkItem = (item) => {
|
734
|
+
return mapSlotsSync(
|
735
|
+
item,
|
736
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
737
|
+
isSlot2
|
738
|
+
);
|
739
|
+
};
|
740
|
+
if ("props" in data) {
|
741
|
+
return walkItem(data);
|
742
|
+
}
|
743
|
+
const _data = data;
|
744
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
745
|
+
const mappedContent = _data.content.map(walkItem);
|
746
|
+
return {
|
747
|
+
root: walkItem(_data.root),
|
748
|
+
content: (_b = callbackFn(mappedContent, {
|
749
|
+
parentId: "root",
|
750
|
+
propName: "default-zone"
|
751
|
+
})) != null ? _b : mappedContent,
|
752
|
+
zones: Object.keys(zones).reduce(
|
753
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
754
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
755
|
+
}),
|
756
|
+
{}
|
757
|
+
)
|
758
|
+
};
|
759
|
+
}
|
760
|
+
|
761
|
+
// ../core/lib/data/populate-ids.ts
|
762
|
+
var populateIds = (data, config, override = false) => {
|
763
|
+
const id = generateId(data.type);
|
764
|
+
return walkTree(
|
765
|
+
__spreadProps(__spreadValues({}, data), {
|
766
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
767
|
+
}),
|
768
|
+
config,
|
769
|
+
(contents) => contents.map((item) => {
|
770
|
+
const id2 = generateId(item.type);
|
771
|
+
return __spreadProps(__spreadValues({}, item), {
|
772
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
773
|
+
});
|
774
|
+
})
|
775
|
+
);
|
776
|
+
};
|
777
|
+
|
683
778
|
// ../core/reducer/actions/insert.ts
|
684
779
|
function insertAction(state, action, appStore) {
|
685
780
|
const id = action.id || generateId(action.componentType);
|
686
|
-
const emptyComponentData =
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
781
|
+
const emptyComponentData = populateIds(
|
782
|
+
{
|
783
|
+
type: action.componentType,
|
784
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
785
|
+
id
|
786
|
+
})
|
787
|
+
},
|
788
|
+
appStore.config
|
789
|
+
);
|
692
790
|
const [parentId] = action.destinationZone.split(":");
|
693
791
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
694
792
|
return walkAppState(
|
@@ -729,25 +827,26 @@ var replaceAction = (state, action, appStore) => {
|
|
729
827
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
730
828
|
);
|
731
829
|
}
|
830
|
+
const data = populateIds(action.data, appStore.config);
|
732
831
|
return walkAppState(
|
733
832
|
state,
|
734
833
|
appStore.config,
|
735
834
|
(content, zoneCompound) => {
|
736
835
|
const newContent = [...content];
|
737
836
|
if (zoneCompound === action.destinationZone) {
|
738
|
-
newContent[action.destinationIndex] =
|
837
|
+
newContent[action.destinationIndex] = data;
|
739
838
|
}
|
740
839
|
return newContent;
|
741
840
|
},
|
742
841
|
(childItem, path) => {
|
743
842
|
const pathIds = path.map((p) => p.split(":")[0]);
|
744
|
-
if (childItem.props.id ===
|
745
|
-
return
|
843
|
+
if (childItem.props.id === data.props.id) {
|
844
|
+
return data;
|
746
845
|
} else if (childItem.props.id === parentId) {
|
747
846
|
return childItem;
|
748
847
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
749
848
|
return childItem;
|
750
|
-
} else if (pathIds.indexOf(
|
849
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
751
850
|
return childItem;
|
752
851
|
}
|
753
852
|
return null;
|
@@ -1321,7 +1420,11 @@ var createNodesSlice = (set, get) => ({
|
|
1321
1420
|
const s = get().nodes;
|
1322
1421
|
const emptyNode = {
|
1323
1422
|
id,
|
1324
|
-
methods: {
|
1423
|
+
methods: {
|
1424
|
+
sync: () => null,
|
1425
|
+
hideOverlay: () => null,
|
1426
|
+
showOverlay: () => null
|
1427
|
+
},
|
1325
1428
|
element: null
|
1326
1429
|
};
|
1327
1430
|
const existingNode = s.nodes[id];
|
@@ -1495,37 +1598,13 @@ var createFieldsSlice = (_set, _get) => {
|
|
1495
1598
|
return {
|
1496
1599
|
fields: {},
|
1497
1600
|
loading: false,
|
1498
|
-
lastResolvedData: {}
|
1601
|
+
lastResolvedData: {},
|
1602
|
+
id: void 0
|
1499
1603
|
};
|
1500
1604
|
};
|
1501
1605
|
|
1502
1606
|
// ../core/lib/resolve-component-data.ts
|
1503
1607
|
init_react_import();
|
1504
|
-
|
1505
|
-
// ../core/lib/data/map-slots.ts
|
1506
|
-
init_react_import();
|
1507
|
-
function mapSlotsAsync(_0, _1) {
|
1508
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1509
|
-
const props = __spreadValues({}, item.props);
|
1510
|
-
const propKeys = Object.keys(props);
|
1511
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1512
|
-
const propKey = propKeys[i];
|
1513
|
-
const itemType = "type" in item ? item.type : "root";
|
1514
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1515
|
-
const content = props[propKey];
|
1516
|
-
const mappedContent = recursive ? yield Promise.all(
|
1517
|
-
content.map((item2) => __async(this, null, function* () {
|
1518
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1519
|
-
}))
|
1520
|
-
) : content;
|
1521
|
-
props[propKey] = yield map(mappedContent, propKey);
|
1522
|
-
}
|
1523
|
-
}
|
1524
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1525
|
-
});
|
1526
|
-
}
|
1527
|
-
|
1528
|
-
// ../core/lib/resolve-component-data.ts
|
1529
1608
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1530
1609
|
var cache = { lastChange: {} };
|
1531
1610
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -1605,7 +1684,8 @@ var toRoot = (item) => {
|
|
1605
1684
|
return { props: {}, readOnly };
|
1606
1685
|
};
|
1607
1686
|
|
1608
|
-
// ../core/store/
|
1687
|
+
// ../core/store/default-app-state.ts
|
1688
|
+
init_react_import();
|
1609
1689
|
var defaultAppState = {
|
1610
1690
|
data: { content: [], root: {}, zones: {} },
|
1611
1691
|
ui: {
|
@@ -1631,6 +1711,8 @@ var defaultAppState = {
|
|
1631
1711
|
zones: {}
|
1632
1712
|
}
|
1633
1713
|
};
|
1714
|
+
|
1715
|
+
// ../core/store/index.ts
|
1634
1716
|
var defaultPageFields = {
|
1635
1717
|
title: { type: "text" }
|
1636
1718
|
};
|
package/dist/index.mjs
CHANGED
@@ -668,15 +668,113 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
668
668
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
669
669
|
};
|
670
670
|
|
671
|
+
// ../core/lib/data/populate-ids.ts
|
672
|
+
init_react_import();
|
673
|
+
|
674
|
+
// ../core/lib/data/walk-tree.ts
|
675
|
+
init_react_import();
|
676
|
+
|
677
|
+
// ../core/lib/data/map-slots.ts
|
678
|
+
init_react_import();
|
679
|
+
function mapSlotsAsync(_0, _1) {
|
680
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
681
|
+
const props = __spreadValues({}, item.props);
|
682
|
+
const propKeys = Object.keys(props);
|
683
|
+
for (let i = 0; i < propKeys.length; i++) {
|
684
|
+
const propKey = propKeys[i];
|
685
|
+
const itemType = "type" in item ? item.type : "root";
|
686
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
687
|
+
const content = props[propKey];
|
688
|
+
const mappedContent = recursive ? yield Promise.all(
|
689
|
+
content.map((item2) => __async(this, null, function* () {
|
690
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
691
|
+
}))
|
692
|
+
) : content;
|
693
|
+
props[propKey] = yield map(mappedContent, propKey);
|
694
|
+
}
|
695
|
+
}
|
696
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
697
|
+
});
|
698
|
+
}
|
699
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
700
|
+
var _a, _b;
|
701
|
+
const props = __spreadValues({}, item.props);
|
702
|
+
const propKeys = Object.keys(props);
|
703
|
+
for (let i = 0; i < propKeys.length; i++) {
|
704
|
+
const propKey = propKeys[i];
|
705
|
+
const itemType = "type" in item ? item.type : "root";
|
706
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
707
|
+
const content = props[propKey];
|
708
|
+
const mappedContent = content.map((item2) => {
|
709
|
+
return mapSlotsSync(item2, map, isSlot2);
|
710
|
+
});
|
711
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
712
|
+
}
|
713
|
+
}
|
714
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
715
|
+
}
|
716
|
+
|
717
|
+
// ../core/lib/data/walk-tree.ts
|
718
|
+
function walkTree(data, config, callbackFn) {
|
719
|
+
var _a, _b;
|
720
|
+
const isSlot2 = createIsSlotConfig(config);
|
721
|
+
const walkItem = (item) => {
|
722
|
+
return mapSlotsSync(
|
723
|
+
item,
|
724
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
725
|
+
isSlot2
|
726
|
+
);
|
727
|
+
};
|
728
|
+
if ("props" in data) {
|
729
|
+
return walkItem(data);
|
730
|
+
}
|
731
|
+
const _data = data;
|
732
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
733
|
+
const mappedContent = _data.content.map(walkItem);
|
734
|
+
return {
|
735
|
+
root: walkItem(_data.root),
|
736
|
+
content: (_b = callbackFn(mappedContent, {
|
737
|
+
parentId: "root",
|
738
|
+
propName: "default-zone"
|
739
|
+
})) != null ? _b : mappedContent,
|
740
|
+
zones: Object.keys(zones).reduce(
|
741
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
742
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
743
|
+
}),
|
744
|
+
{}
|
745
|
+
)
|
746
|
+
};
|
747
|
+
}
|
748
|
+
|
749
|
+
// ../core/lib/data/populate-ids.ts
|
750
|
+
var populateIds = (data, config, override = false) => {
|
751
|
+
const id = generateId(data.type);
|
752
|
+
return walkTree(
|
753
|
+
__spreadProps(__spreadValues({}, data), {
|
754
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
755
|
+
}),
|
756
|
+
config,
|
757
|
+
(contents) => contents.map((item) => {
|
758
|
+
const id2 = generateId(item.type);
|
759
|
+
return __spreadProps(__spreadValues({}, item), {
|
760
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
761
|
+
});
|
762
|
+
})
|
763
|
+
);
|
764
|
+
};
|
765
|
+
|
671
766
|
// ../core/reducer/actions/insert.ts
|
672
767
|
function insertAction(state, action, appStore) {
|
673
768
|
const id = action.id || generateId(action.componentType);
|
674
|
-
const emptyComponentData =
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
769
|
+
const emptyComponentData = populateIds(
|
770
|
+
{
|
771
|
+
type: action.componentType,
|
772
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
773
|
+
id
|
774
|
+
})
|
775
|
+
},
|
776
|
+
appStore.config
|
777
|
+
);
|
680
778
|
const [parentId] = action.destinationZone.split(":");
|
681
779
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
682
780
|
return walkAppState(
|
@@ -717,25 +815,26 @@ var replaceAction = (state, action, appStore) => {
|
|
717
815
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
718
816
|
);
|
719
817
|
}
|
818
|
+
const data = populateIds(action.data, appStore.config);
|
720
819
|
return walkAppState(
|
721
820
|
state,
|
722
821
|
appStore.config,
|
723
822
|
(content, zoneCompound) => {
|
724
823
|
const newContent = [...content];
|
725
824
|
if (zoneCompound === action.destinationZone) {
|
726
|
-
newContent[action.destinationIndex] =
|
825
|
+
newContent[action.destinationIndex] = data;
|
727
826
|
}
|
728
827
|
return newContent;
|
729
828
|
},
|
730
829
|
(childItem, path) => {
|
731
830
|
const pathIds = path.map((p) => p.split(":")[0]);
|
732
|
-
if (childItem.props.id ===
|
733
|
-
return
|
831
|
+
if (childItem.props.id === data.props.id) {
|
832
|
+
return data;
|
734
833
|
} else if (childItem.props.id === parentId) {
|
735
834
|
return childItem;
|
736
835
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
737
836
|
return childItem;
|
738
|
-
} else if (pathIds.indexOf(
|
837
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
739
838
|
return childItem;
|
740
839
|
}
|
741
840
|
return null;
|
@@ -1309,7 +1408,11 @@ var createNodesSlice = (set, get) => ({
|
|
1309
1408
|
const s = get().nodes;
|
1310
1409
|
const emptyNode = {
|
1311
1410
|
id,
|
1312
|
-
methods: {
|
1411
|
+
methods: {
|
1412
|
+
sync: () => null,
|
1413
|
+
hideOverlay: () => null,
|
1414
|
+
showOverlay: () => null
|
1415
|
+
},
|
1313
1416
|
element: null
|
1314
1417
|
};
|
1315
1418
|
const existingNode = s.nodes[id];
|
@@ -1483,37 +1586,13 @@ var createFieldsSlice = (_set, _get) => {
|
|
1483
1586
|
return {
|
1484
1587
|
fields: {},
|
1485
1588
|
loading: false,
|
1486
|
-
lastResolvedData: {}
|
1589
|
+
lastResolvedData: {},
|
1590
|
+
id: void 0
|
1487
1591
|
};
|
1488
1592
|
};
|
1489
1593
|
|
1490
1594
|
// ../core/lib/resolve-component-data.ts
|
1491
1595
|
init_react_import();
|
1492
|
-
|
1493
|
-
// ../core/lib/data/map-slots.ts
|
1494
|
-
init_react_import();
|
1495
|
-
function mapSlotsAsync(_0, _1) {
|
1496
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1497
|
-
const props = __spreadValues({}, item.props);
|
1498
|
-
const propKeys = Object.keys(props);
|
1499
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1500
|
-
const propKey = propKeys[i];
|
1501
|
-
const itemType = "type" in item ? item.type : "root";
|
1502
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1503
|
-
const content = props[propKey];
|
1504
|
-
const mappedContent = recursive ? yield Promise.all(
|
1505
|
-
content.map((item2) => __async(this, null, function* () {
|
1506
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1507
|
-
}))
|
1508
|
-
) : content;
|
1509
|
-
props[propKey] = yield map(mappedContent, propKey);
|
1510
|
-
}
|
1511
|
-
}
|
1512
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1513
|
-
});
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
// ../core/lib/resolve-component-data.ts
|
1517
1596
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1518
1597
|
var cache = { lastChange: {} };
|
1519
1598
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -1593,7 +1672,8 @@ var toRoot = (item) => {
|
|
1593
1672
|
return { props: {}, readOnly };
|
1594
1673
|
};
|
1595
1674
|
|
1596
|
-
// ../core/store/
|
1675
|
+
// ../core/store/default-app-state.ts
|
1676
|
+
init_react_import();
|
1597
1677
|
var defaultAppState = {
|
1598
1678
|
data: { content: [], root: {}, zones: {} },
|
1599
1679
|
ui: {
|
@@ -1619,6 +1699,8 @@ var defaultAppState = {
|
|
1619
1699
|
zones: {}
|
1620
1700
|
}
|
1621
1701
|
};
|
1702
|
+
|
1703
|
+
// ../core/store/index.ts
|
1622
1704
|
var defaultPageFields = {
|
1623
1705
|
title: { type: "text" }
|
1624
1706
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
3
|
-
"version": "0.19.0-canary.
|
3
|
+
"version": "0.19.0-canary.91cb9cee",
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"dist"
|
26
26
|
],
|
27
27
|
"devDependencies": {
|
28
|
-
"@measured/puck": "^0.19.0-canary.
|
28
|
+
"@measured/puck": "^0.19.0-canary.91cb9cee",
|
29
29
|
"@types/react": "^19.0.1",
|
30
30
|
"@types/react-dom": "^19.0.2",
|
31
31
|
"eslint": "^7.32.0",
|