@measured/puck-plugin-heading-analyzer 0.16.0-canary.54b5a87 → 0.16.0-canary.958dc25

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.ts CHANGED
@@ -90,7 +90,7 @@ type ObjectField<Props extends {
90
90
  [key: string]: any;
91
91
  }> = BaseField & {
92
92
  type: "object";
93
- objectFields: {
93
+ objectFields: Props extends any[] ? never : {
94
94
  [SubPropName in keyof Props]: Field<Props[SubPropName]>;
95
95
  };
96
96
  };
package/dist/index.js CHANGED
@@ -73709,6 +73709,7 @@ var require_dist = __commonJS({
73709
73709
  init_react_import2();
73710
73710
  init_react_import2();
73711
73711
  init_react_import2();
73712
+ init_react_import2();
73712
73713
  var import_classnames2 = __toESM2(require_classnames2());
73713
73714
  var getClassNameFactory2 = (rootClass, styles, { baseClass = "" } = {}) => (options = {}) => {
73714
73715
  let descendant = false;
@@ -76983,7 +76984,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
76983
76984
  var styleSelector = 'style, link[rel="stylesheet"]';
76984
76985
  var collectStyles = (doc) => {
76985
76986
  const collected = [];
76986
- doc.head.querySelectorAll(styleSelector).forEach((style2) => {
76987
+ doc.querySelectorAll(styleSelector).forEach((style2) => {
76987
76988
  collected.push(style2);
76988
76989
  });
76989
76990
  return collected;
@@ -77007,6 +77008,14 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77007
77008
  }
77008
77009
  return "";
77009
77010
  };
77011
+ var syncAttributes = (sourceElement, targetElement) => {
77012
+ const attributes = sourceElement.attributes;
77013
+ if ((attributes == null ? void 0 : attributes.length) > 0) {
77014
+ Array.from(attributes).forEach((attribute) => {
77015
+ targetElement.setAttribute(attribute.name, attribute.value);
77016
+ });
77017
+ }
77018
+ };
77010
77019
  var defer = (fn) => setTimeout(fn, 0);
77011
77020
  var CopyHostStyles = ({
77012
77021
  children,
@@ -77124,6 +77133,10 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77124
77133
  const collectedStyles = collectStyles(parentDocument);
77125
77134
  const hrefs = [];
77126
77135
  let stylesLoaded = 0;
77136
+ const parentHtml = parentDocument.getElementsByTagName("html")[0];
77137
+ syncAttributes(parentHtml, doc.documentElement);
77138
+ const parentBody = parentDocument.getElementsByTagName("body")[0];
77139
+ syncAttributes(parentBody, doc.body);
77127
77140
  Promise.all(
77128
77141
  collectedStyles.map((styleNode, i2) => __async2(void 0, null, function* () {
77129
77142
  if (styleNode.nodeName === "LINK") {
@@ -77478,26 +77491,50 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77478
77491
  historyStore.forward();
77479
77492
  }
77480
77493
  };
77494
+ const setHistories = (histories) => {
77495
+ var _a3;
77496
+ dispatch({
77497
+ type: "set",
77498
+ state: ((_a3 = histories[histories.length - 1]) == null ? void 0 : _a3.data) || initialAppState
77499
+ });
77500
+ historyStore.setHistories(histories);
77501
+ };
77502
+ const setHistoryIndex = (index) => {
77503
+ var _a3;
77504
+ if (historyStore.histories.length > index) {
77505
+ dispatch({
77506
+ type: "set",
77507
+ state: ((_a3 = historyStore.histories[index]) == null ? void 0 : _a3.data) || initialAppState
77508
+ });
77509
+ historyStore.setHistoryIndex(index);
77510
+ }
77511
+ };
77481
77512
  (0, import_react_hotkeys_hook.useHotkeys)("meta+z", back, { preventDefault: true });
77482
77513
  (0, import_react_hotkeys_hook.useHotkeys)("meta+shift+z", forward, { preventDefault: true });
77483
77514
  (0, import_react_hotkeys_hook.useHotkeys)("meta+y", forward, { preventDefault: true });
77484
77515
  return {
77485
77516
  back,
77486
77517
  forward,
77487
- historyStore
77518
+ historyStore,
77519
+ setHistories,
77520
+ setHistoryIndex
77488
77521
  };
77489
77522
  }
77490
77523
  init_react_import2();
77491
77524
  var import_react27 = require("react");
77492
77525
  var import_use_debounce3 = (init_index_module(), __toCommonJS(index_module_exports));
77493
77526
  var EMPTY_HISTORY_INDEX = -1;
77494
- function useHistoryStore(initialHistories) {
77527
+ function useHistoryStore(initialHistory) {
77495
77528
  var _a3, _b;
77496
77529
  const [histories, setHistories] = (0, import_react27.useState)(
77497
- (_a3 = initialHistories == null ? void 0 : initialHistories.histories) != null ? _a3 : []
77530
+ (_a3 = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a3 : []
77498
77531
  );
77532
+ const updateHistories = (histories2) => {
77533
+ setHistories(histories2);
77534
+ setIndex(histories2.length - 1);
77535
+ };
77499
77536
  const [index, setIndex] = (0, import_react27.useState)(
77500
- (_b = initialHistories == null ? void 0 : initialHistories.index) != null ? _b : EMPTY_HISTORY_INDEX
77537
+ (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
77501
77538
  );
77502
77539
  const hasPast = index > EMPTY_HISTORY_INDEX;
77503
77540
  const hasFuture = index < histories.length - 1;
@@ -77509,11 +77546,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77509
77546
  data,
77510
77547
  id: generateId("history")
77511
77548
  };
77512
- setHistories((prev) => {
77513
- const newVal = [...prev.slice(0, index + 1), history];
77514
- setIndex(newVal.length - 1);
77515
- return newVal;
77516
- });
77549
+ updateHistories([...histories.slice(0, index + 1), history]);
77517
77550
  }, 250);
77518
77551
  const back = () => {
77519
77552
  setIndex(index - 1);
@@ -77531,7 +77564,9 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77531
77564
  forward,
77532
77565
  nextHistory,
77533
77566
  prevHistory,
77534
- histories
77567
+ histories,
77568
+ setHistories: updateHistories,
77569
+ setHistoryIndex: setIndex
77535
77570
  };
77536
77571
  }
77537
77572
  init_react_import2();
@@ -77952,10 +77987,10 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77952
77987
  enabled: true
77953
77988
  },
77954
77989
  dnd,
77955
- initialHistories
77990
+ initialHistory
77956
77991
  }) {
77957
77992
  var _a3;
77958
- const historyStore = useHistoryStore(initialHistories);
77993
+ const historyStore = useHistoryStore(initialHistory);
77959
77994
  const [reducer2] = (0, import_react30.useState)(
77960
77995
  () => createReducer({ config, record: historyStore.record })
77961
77996
  );
@@ -78497,7 +78532,17 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
78497
78532
  appState,
78498
78533
  config,
78499
78534
  dispatch,
78500
- history,
78535
+ history: {
78536
+ back: history.back,
78537
+ forward: history.forward,
78538
+ setHistories: history.setHistories,
78539
+ setHistoryIndex: history.setHistoryIndex,
78540
+ hasPast: history.historyStore.hasPast,
78541
+ hasFuture: history.historyStore.hasFuture,
78542
+ histories: history.historyStore.histories,
78543
+ index: history.historyStore.index,
78544
+ historyStore: history.historyStore
78545
+ },
78501
78546
  selectedItem: selectedItem || null
78502
78547
  };
78503
78548
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.16.0-canary.54b5a87",
3
+ "version": "0.16.0-canary.958dc25",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -18,7 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "devDependencies": {
21
- "@measured/puck": "^0.16.0-canary.54b5a87",
21
+ "@measured/puck": "^0.16.0-canary.958dc25",
22
22
  "@types/react": "^18.2.0",
23
23
  "@types/react-dom": "^18.2.0",
24
24
  "eslint": "^7.32.0",