@puckeditor/plugin-heading-analyzer 0.23.0-canary.9bf3e00a → 0.23.0-canary.db035ce5

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
@@ -545,6 +545,8 @@ type UiState = {
545
545
  expanded?: boolean;
546
546
  }>;
547
547
  isDragging: boolean;
548
+ /** Outline items whose children are shown, keyed by item id */
549
+ itemExpanded?: Record<string, boolean>;
548
550
  viewports: {
549
551
  current: {
550
552
  width: number | "100%";
package/dist/index.d.ts CHANGED
@@ -545,6 +545,8 @@ type UiState = {
545
545
  expanded?: boolean;
546
546
  }>;
547
547
  isDragging: boolean;
548
+ /** Outline items whose children are shown, keyed by item id */
549
+ itemExpanded?: Record<string, boolean>;
548
550
  viewports: {
549
551
  current: {
550
552
  width: number | "100%";
package/dist/index.js CHANGED
@@ -1258,16 +1258,13 @@ var reorderAction = (state, action, appStore) => {
1258
1258
  init_react_import();
1259
1259
  var removeAction = (state, action, appStore) => {
1260
1260
  const item = getItem({ index: action.index, zone: action.zone }, state);
1261
- const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1262
- (acc, [nodeId, nodeData]) => {
1263
- const pathIds = nodeData.path.map((p) => p.split(":")[0]);
1264
- if (pathIds.includes(item.props.id)) {
1265
- return [...acc, nodeId];
1266
- }
1267
- return acc;
1268
- },
1269
- [item.props.id]
1270
- );
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
+ });
1271
1268
  const newState = walkAppState(
1272
1269
  state,
1273
1270
  appStore.config,
@@ -1280,19 +1277,22 @@ var removeAction = (state, action, appStore) => {
1280
1277
  );
1281
1278
  Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1282
1279
  const parentId = zoneCompound.split(":")[0];
1283
- if (nodesToDelete.includes(parentId) && newState.data.zones) {
1280
+ if (nodesToDelete.has(parentId) && newState.data.zones) {
1284
1281
  delete newState.data.zones[zoneCompound];
1285
1282
  }
1286
1283
  });
1287
1284
  Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1288
1285
  const parentId = zoneCompound.split(":")[0];
1289
- if (nodesToDelete.includes(parentId)) {
1286
+ if (nodesToDelete.has(parentId)) {
1290
1287
  delete newState.indexes.zones[zoneCompound];
1291
1288
  }
1292
1289
  });
1290
+ const newItemExpanded = __spreadValues({}, newState.ui.itemExpanded);
1293
1291
  nodesToDelete.forEach((id) => {
1294
1292
  delete newState.indexes.nodes[id];
1293
+ delete newItemExpanded[id];
1295
1294
  });
1295
+ newState.ui = __spreadProps(__spreadValues({}, newState.ui), { itemExpanded: newItemExpanded });
1296
1296
  return newState;
1297
1297
  };
1298
1298
 
@@ -1376,14 +1376,36 @@ var setDataAction = (state, action, appStore) => {
1376
1376
 
1377
1377
  // ../core/reducer/actions/set-ui.ts
1378
1378
  init_react_import();
1379
- var setUiAction = (state, action) => {
1380
- if (typeof action.ui === "object") {
1381
- return __spreadProps(__spreadValues({}, state), {
1382
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1383
- });
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;
1384
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);
1385
1407
  return __spreadProps(__spreadValues({}, state), {
1386
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1408
+ ui: __spreadValues(__spreadValues({}, state.ui), revealSelectedItem(state, partialUi))
1387
1409
  });
1388
1410
  };
1389
1411
 
@@ -2377,6 +2399,7 @@ var defaultAppState = {
2377
2399
  itemSelector: null,
2378
2400
  componentList: {},
2379
2401
  isDragging: false,
2402
+ itemExpanded: {},
2380
2403
  previewMode: "edit",
2381
2404
  viewports: {
2382
2405
  current: {
@@ -2421,6 +2444,7 @@ var createAppStore = (initialAppStore) => create()(
2421
2444
  _experimentalVirtualization: false,
2422
2445
  metadata: {},
2423
2446
  dictionary: {},
2447
+ dnd: {},
2424
2448
  fieldTransforms: {}
2425
2449
  }, initialAppStore), {
2426
2450
  fields: createFieldsSlice(set, get),
package/dist/index.mjs CHANGED
@@ -1246,16 +1246,13 @@ var reorderAction = (state, action, appStore) => {
1246
1246
  init_react_import();
1247
1247
  var removeAction = (state, action, appStore) => {
1248
1248
  const item = getItem({ index: action.index, zone: action.zone }, state);
1249
- const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1250
- (acc, [nodeId, nodeData]) => {
1251
- const pathIds = nodeData.path.map((p) => p.split(":")[0]);
1252
- if (pathIds.includes(item.props.id)) {
1253
- return [...acc, nodeId];
1254
- }
1255
- return acc;
1256
- },
1257
- [item.props.id]
1258
- );
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
+ });
1259
1256
  const newState = walkAppState(
1260
1257
  state,
1261
1258
  appStore.config,
@@ -1268,19 +1265,22 @@ var removeAction = (state, action, appStore) => {
1268
1265
  );
1269
1266
  Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1270
1267
  const parentId = zoneCompound.split(":")[0];
1271
- if (nodesToDelete.includes(parentId) && newState.data.zones) {
1268
+ if (nodesToDelete.has(parentId) && newState.data.zones) {
1272
1269
  delete newState.data.zones[zoneCompound];
1273
1270
  }
1274
1271
  });
1275
1272
  Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1276
1273
  const parentId = zoneCompound.split(":")[0];
1277
- if (nodesToDelete.includes(parentId)) {
1274
+ if (nodesToDelete.has(parentId)) {
1278
1275
  delete newState.indexes.zones[zoneCompound];
1279
1276
  }
1280
1277
  });
1278
+ const newItemExpanded = __spreadValues({}, newState.ui.itemExpanded);
1281
1279
  nodesToDelete.forEach((id) => {
1282
1280
  delete newState.indexes.nodes[id];
1281
+ delete newItemExpanded[id];
1283
1282
  });
1283
+ newState.ui = __spreadProps(__spreadValues({}, newState.ui), { itemExpanded: newItemExpanded });
1284
1284
  return newState;
1285
1285
  };
1286
1286
 
@@ -1364,14 +1364,36 @@ var setDataAction = (state, action, appStore) => {
1364
1364
 
1365
1365
  // ../core/reducer/actions/set-ui.ts
1366
1366
  init_react_import();
1367
- var setUiAction = (state, action) => {
1368
- if (typeof action.ui === "object") {
1369
- return __spreadProps(__spreadValues({}, state), {
1370
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1371
- });
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;
1372
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);
1373
1395
  return __spreadProps(__spreadValues({}, state), {
1374
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1396
+ ui: __spreadValues(__spreadValues({}, state.ui), revealSelectedItem(state, partialUi))
1375
1397
  });
1376
1398
  };
1377
1399
 
@@ -2365,6 +2387,7 @@ var defaultAppState = {
2365
2387
  itemSelector: null,
2366
2388
  componentList: {},
2367
2389
  isDragging: false,
2390
+ itemExpanded: {},
2368
2391
  previewMode: "edit",
2369
2392
  viewports: {
2370
2393
  current: {
@@ -2409,6 +2432,7 @@ var createAppStore = (initialAppStore) => create()(
2409
2432
  _experimentalVirtualization: false,
2410
2433
  metadata: {},
2411
2434
  dictionary: {},
2435
+ dnd: {},
2412
2436
  fieldTransforms: {}
2413
2437
  }, initialAppStore), {
2414
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.23.0-canary.9bf3e00a",
3
+ "version": "0.23.0-canary.db035ce5",
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.23.0-canary.9bf3e00a",
28
+ "@puckeditor/core": "^0.23.0-canary.db035ce5",
29
29
  "@types/minimatch": "3.0.5",
30
30
  "@types/react": "^19.0.1",
31
31
  "@types/react-dom": "^19.0.2",