@puckeditor/plugin-heading-analyzer 0.22.1 → 0.23.0-canary.1b6fc858
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +50 -23
- package/dist/index.mjs +50 -23
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -621,10 +621,11 @@ var walkObject = ({
|
|
|
621
621
|
getPropPath,
|
|
622
622
|
config,
|
|
623
623
|
recurseSlots,
|
|
624
|
-
ownedFields
|
|
624
|
+
ownedFields,
|
|
625
|
+
keysToWalk: providedKeys
|
|
625
626
|
}) => {
|
|
626
|
-
const keys2 = Object.keys(value);
|
|
627
|
-
if (ownedFields) {
|
|
627
|
+
const keys2 = providedKeys != null ? providedKeys : Object.keys(value);
|
|
628
|
+
if (!providedKeys && ownedFields) {
|
|
628
629
|
for (const fieldName in fields) {
|
|
629
630
|
const fieldType = fields[fieldName].type;
|
|
630
631
|
if (fieldType !== "slot" && mappers[fieldType] && !(fieldName in value)) {
|
|
@@ -658,7 +659,7 @@ var walkObject = ({
|
|
|
658
659
|
}
|
|
659
660
|
return flatten(newProps);
|
|
660
661
|
};
|
|
661
|
-
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true) {
|
|
662
|
+
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true, fieldsToMap) {
|
|
662
663
|
var _a, _b, _c, _d, _e;
|
|
663
664
|
const itemType = "type" in item ? item.type : "root";
|
|
664
665
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
@@ -670,7 +671,8 @@ function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlo
|
|
|
670
671
|
getPropPath: (k) => k,
|
|
671
672
|
config,
|
|
672
673
|
recurseSlots,
|
|
673
|
-
ownedFields: true
|
|
674
|
+
ownedFields: true,
|
|
675
|
+
keysToWalk: fieldsToMap
|
|
674
676
|
});
|
|
675
677
|
if (isPromise(newProps)) {
|
|
676
678
|
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
|
@@ -1256,16 +1258,13 @@ var reorderAction = (state, action, appStore) => {
|
|
|
1256
1258
|
init_react_import();
|
|
1257
1259
|
var removeAction = (state, action, appStore) => {
|
|
1258
1260
|
const item = getItem({ index: action.index, zone: action.zone }, state);
|
|
1259
|
-
const nodesToDelete =
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
},
|
|
1267
|
-
[item.props.id]
|
|
1268
|
-
);
|
|
1261
|
+
const nodesToDelete = /* @__PURE__ */ new Set([item.props.id]);
|
|
1262
|
+
Object.entries(state.indexes.nodes).forEach(([nodeId, nodeData]) => {
|
|
1263
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
|
1264
|
+
if (pathIds.includes(item.props.id)) {
|
|
1265
|
+
nodesToDelete.add(nodeId);
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1269
1268
|
const newState = walkAppState(
|
|
1270
1269
|
state,
|
|
1271
1270
|
appStore.config,
|
|
@@ -1278,19 +1277,22 @@ var removeAction = (state, action, appStore) => {
|
|
|
1278
1277
|
);
|
|
1279
1278
|
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
|
1280
1279
|
const parentId = zoneCompound.split(":")[0];
|
|
1281
|
-
if (nodesToDelete.
|
|
1280
|
+
if (nodesToDelete.has(parentId) && newState.data.zones) {
|
|
1282
1281
|
delete newState.data.zones[zoneCompound];
|
|
1283
1282
|
}
|
|
1284
1283
|
});
|
|
1285
1284
|
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
|
1286
1285
|
const parentId = zoneCompound.split(":")[0];
|
|
1287
|
-
if (nodesToDelete.
|
|
1286
|
+
if (nodesToDelete.has(parentId)) {
|
|
1288
1287
|
delete newState.indexes.zones[zoneCompound];
|
|
1289
1288
|
}
|
|
1290
1289
|
});
|
|
1290
|
+
const newItemExpanded = __spreadValues({}, newState.ui.itemExpanded);
|
|
1291
1291
|
nodesToDelete.forEach((id) => {
|
|
1292
1292
|
delete newState.indexes.nodes[id];
|
|
1293
|
+
delete newItemExpanded[id];
|
|
1293
1294
|
});
|
|
1295
|
+
newState.ui = __spreadProps(__spreadValues({}, newState.ui), { itemExpanded: newItemExpanded });
|
|
1294
1296
|
return newState;
|
|
1295
1297
|
};
|
|
1296
1298
|
|
|
@@ -1374,14 +1376,36 @@ var setDataAction = (state, action, appStore) => {
|
|
|
1374
1376
|
|
|
1375
1377
|
// ../core/reducer/actions/set-ui.ts
|
|
1376
1378
|
init_react_import();
|
|
1377
|
-
var
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1379
|
+
var revealSelectedItem = (state, partialUi) => {
|
|
1380
|
+
var _a, _b;
|
|
1381
|
+
const itemSelector = partialUi.itemSelector;
|
|
1382
|
+
if (!itemSelector) {
|
|
1383
|
+
return partialUi;
|
|
1384
|
+
}
|
|
1385
|
+
const item = getItem(itemSelector, state);
|
|
1386
|
+
if (!item) {
|
|
1387
|
+
return partialUi;
|
|
1388
|
+
}
|
|
1389
|
+
const path = (_b = (_a = state.indexes.nodes[item.props.id]) == null ? void 0 : _a.path) != null ? _b : [];
|
|
1390
|
+
const collapsedAncestorIds = path.map((zoneCompound) => zoneCompound.split(":")[0]).filter(
|
|
1391
|
+
(ancestorId) => {
|
|
1392
|
+
var _a2, _b2;
|
|
1393
|
+
return ancestorId && ancestorId !== rootAreaId && !((_a2 = state.ui.itemExpanded) == null ? void 0 : _a2[ancestorId]) && !((_b2 = partialUi.itemExpanded) == null ? void 0 : _b2[ancestorId]);
|
|
1394
|
+
}
|
|
1395
|
+
);
|
|
1396
|
+
if (collapsedAncestorIds.length === 0) {
|
|
1397
|
+
return partialUi;
|
|
1382
1398
|
}
|
|
1399
|
+
const itemExpanded = __spreadValues(__spreadValues({}, state.ui.itemExpanded), partialUi.itemExpanded);
|
|
1400
|
+
collapsedAncestorIds.forEach((ancestorId) => {
|
|
1401
|
+
itemExpanded[ancestorId] = true;
|
|
1402
|
+
});
|
|
1403
|
+
return __spreadProps(__spreadValues({}, partialUi), { itemExpanded });
|
|
1404
|
+
};
|
|
1405
|
+
var setUiAction = (state, action) => {
|
|
1406
|
+
const partialUi = typeof action.ui === "object" ? action.ui : action.ui(state.ui);
|
|
1383
1407
|
return __spreadProps(__spreadValues({}, state), {
|
|
1384
|
-
ui: __spreadValues(__spreadValues({}, state.ui),
|
|
1408
|
+
ui: __spreadValues(__spreadValues({}, state.ui), revealSelectedItem(state, partialUi))
|
|
1385
1409
|
});
|
|
1386
1410
|
};
|
|
1387
1411
|
|
|
@@ -2375,6 +2399,7 @@ var defaultAppState = {
|
|
|
2375
2399
|
itemSelector: null,
|
|
2376
2400
|
componentList: {},
|
|
2377
2401
|
isDragging: false,
|
|
2402
|
+
itemExpanded: {},
|
|
2378
2403
|
previewMode: "edit",
|
|
2379
2404
|
viewports: {
|
|
2380
2405
|
current: {
|
|
@@ -2418,6 +2443,8 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2418
2443
|
_experimentalFullScreenCanvas: false,
|
|
2419
2444
|
_experimentalVirtualization: false,
|
|
2420
2445
|
metadata: {},
|
|
2446
|
+
dictionary: {},
|
|
2447
|
+
dnd: {},
|
|
2421
2448
|
fieldTransforms: {}
|
|
2422
2449
|
}, initialAppStore), {
|
|
2423
2450
|
fields: createFieldsSlice(set, get),
|
package/dist/index.mjs
CHANGED
|
@@ -609,10 +609,11 @@ var walkObject = ({
|
|
|
609
609
|
getPropPath,
|
|
610
610
|
config,
|
|
611
611
|
recurseSlots,
|
|
612
|
-
ownedFields
|
|
612
|
+
ownedFields,
|
|
613
|
+
keysToWalk: providedKeys
|
|
613
614
|
}) => {
|
|
614
|
-
const keys2 = Object.keys(value);
|
|
615
|
-
if (ownedFields) {
|
|
615
|
+
const keys2 = providedKeys != null ? providedKeys : Object.keys(value);
|
|
616
|
+
if (!providedKeys && ownedFields) {
|
|
616
617
|
for (const fieldName in fields) {
|
|
617
618
|
const fieldType = fields[fieldName].type;
|
|
618
619
|
if (fieldType !== "slot" && mappers[fieldType] && !(fieldName in value)) {
|
|
@@ -646,7 +647,7 @@ var walkObject = ({
|
|
|
646
647
|
}
|
|
647
648
|
return flatten(newProps);
|
|
648
649
|
};
|
|
649
|
-
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true) {
|
|
650
|
+
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true, fieldsToMap) {
|
|
650
651
|
var _a, _b, _c, _d, _e;
|
|
651
652
|
const itemType = "type" in item ? item.type : "root";
|
|
652
653
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
@@ -658,7 +659,8 @@ function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlo
|
|
|
658
659
|
getPropPath: (k) => k,
|
|
659
660
|
config,
|
|
660
661
|
recurseSlots,
|
|
661
|
-
ownedFields: true
|
|
662
|
+
ownedFields: true,
|
|
663
|
+
keysToWalk: fieldsToMap
|
|
662
664
|
});
|
|
663
665
|
if (isPromise(newProps)) {
|
|
664
666
|
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
|
@@ -1244,16 +1246,13 @@ var reorderAction = (state, action, appStore) => {
|
|
|
1244
1246
|
init_react_import();
|
|
1245
1247
|
var removeAction = (state, action, appStore) => {
|
|
1246
1248
|
const item = getItem({ index: action.index, zone: action.zone }, state);
|
|
1247
|
-
const nodesToDelete =
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
},
|
|
1255
|
-
[item.props.id]
|
|
1256
|
-
);
|
|
1249
|
+
const nodesToDelete = /* @__PURE__ */ new Set([item.props.id]);
|
|
1250
|
+
Object.entries(state.indexes.nodes).forEach(([nodeId, nodeData]) => {
|
|
1251
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
|
1252
|
+
if (pathIds.includes(item.props.id)) {
|
|
1253
|
+
nodesToDelete.add(nodeId);
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1257
1256
|
const newState = walkAppState(
|
|
1258
1257
|
state,
|
|
1259
1258
|
appStore.config,
|
|
@@ -1266,19 +1265,22 @@ var removeAction = (state, action, appStore) => {
|
|
|
1266
1265
|
);
|
|
1267
1266
|
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
|
1268
1267
|
const parentId = zoneCompound.split(":")[0];
|
|
1269
|
-
if (nodesToDelete.
|
|
1268
|
+
if (nodesToDelete.has(parentId) && newState.data.zones) {
|
|
1270
1269
|
delete newState.data.zones[zoneCompound];
|
|
1271
1270
|
}
|
|
1272
1271
|
});
|
|
1273
1272
|
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
|
1274
1273
|
const parentId = zoneCompound.split(":")[0];
|
|
1275
|
-
if (nodesToDelete.
|
|
1274
|
+
if (nodesToDelete.has(parentId)) {
|
|
1276
1275
|
delete newState.indexes.zones[zoneCompound];
|
|
1277
1276
|
}
|
|
1278
1277
|
});
|
|
1278
|
+
const newItemExpanded = __spreadValues({}, newState.ui.itemExpanded);
|
|
1279
1279
|
nodesToDelete.forEach((id) => {
|
|
1280
1280
|
delete newState.indexes.nodes[id];
|
|
1281
|
+
delete newItemExpanded[id];
|
|
1281
1282
|
});
|
|
1283
|
+
newState.ui = __spreadProps(__spreadValues({}, newState.ui), { itemExpanded: newItemExpanded });
|
|
1282
1284
|
return newState;
|
|
1283
1285
|
};
|
|
1284
1286
|
|
|
@@ -1362,14 +1364,36 @@ var setDataAction = (state, action, appStore) => {
|
|
|
1362
1364
|
|
|
1363
1365
|
// ../core/reducer/actions/set-ui.ts
|
|
1364
1366
|
init_react_import();
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1367
|
+
var revealSelectedItem = (state, partialUi) => {
|
|
1368
|
+
var _a, _b;
|
|
1369
|
+
const itemSelector = partialUi.itemSelector;
|
|
1370
|
+
if (!itemSelector) {
|
|
1371
|
+
return partialUi;
|
|
1372
|
+
}
|
|
1373
|
+
const item = getItem(itemSelector, state);
|
|
1374
|
+
if (!item) {
|
|
1375
|
+
return partialUi;
|
|
1376
|
+
}
|
|
1377
|
+
const path = (_b = (_a = state.indexes.nodes[item.props.id]) == null ? void 0 : _a.path) != null ? _b : [];
|
|
1378
|
+
const collapsedAncestorIds = path.map((zoneCompound) => zoneCompound.split(":")[0]).filter(
|
|
1379
|
+
(ancestorId) => {
|
|
1380
|
+
var _a2, _b2;
|
|
1381
|
+
return ancestorId && ancestorId !== rootAreaId && !((_a2 = state.ui.itemExpanded) == null ? void 0 : _a2[ancestorId]) && !((_b2 = partialUi.itemExpanded) == null ? void 0 : _b2[ancestorId]);
|
|
1382
|
+
}
|
|
1383
|
+
);
|
|
1384
|
+
if (collapsedAncestorIds.length === 0) {
|
|
1385
|
+
return partialUi;
|
|
1370
1386
|
}
|
|
1387
|
+
const itemExpanded = __spreadValues(__spreadValues({}, state.ui.itemExpanded), partialUi.itemExpanded);
|
|
1388
|
+
collapsedAncestorIds.forEach((ancestorId) => {
|
|
1389
|
+
itemExpanded[ancestorId] = true;
|
|
1390
|
+
});
|
|
1391
|
+
return __spreadProps(__spreadValues({}, partialUi), { itemExpanded });
|
|
1392
|
+
};
|
|
1393
|
+
var setUiAction = (state, action) => {
|
|
1394
|
+
const partialUi = typeof action.ui === "object" ? action.ui : action.ui(state.ui);
|
|
1371
1395
|
return __spreadProps(__spreadValues({}, state), {
|
|
1372
|
-
ui: __spreadValues(__spreadValues({}, state.ui),
|
|
1396
|
+
ui: __spreadValues(__spreadValues({}, state.ui), revealSelectedItem(state, partialUi))
|
|
1373
1397
|
});
|
|
1374
1398
|
};
|
|
1375
1399
|
|
|
@@ -2363,6 +2387,7 @@ var defaultAppState = {
|
|
|
2363
2387
|
itemSelector: null,
|
|
2364
2388
|
componentList: {},
|
|
2365
2389
|
isDragging: false,
|
|
2390
|
+
itemExpanded: {},
|
|
2366
2391
|
previewMode: "edit",
|
|
2367
2392
|
viewports: {
|
|
2368
2393
|
current: {
|
|
@@ -2406,6 +2431,8 @@ var createAppStore = (initialAppStore) => create()(
|
|
|
2406
2431
|
_experimentalFullScreenCanvas: false,
|
|
2407
2432
|
_experimentalVirtualization: false,
|
|
2408
2433
|
metadata: {},
|
|
2434
|
+
dictionary: {},
|
|
2435
|
+
dnd: {},
|
|
2409
2436
|
fieldTransforms: {}
|
|
2410
2437
|
}, initialAppStore), {
|
|
2411
2438
|
fields: createFieldsSlice(set, get),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puckeditor/plugin-heading-analyzer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0-canary.1b6fc858",
|
|
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.
|
|
28
|
+
"@puckeditor/core": "^0.23.0-canary.1b6fc858",
|
|
29
29
|
"@types/minimatch": "3.0.5",
|
|
30
30
|
"@types/react": "^19.0.1",
|
|
31
31
|
"@types/react-dom": "^19.0.2",
|