@measured/puck-plugin-heading-analyzer 0.14.2-canary.78047de → 0.14.2-canary.ba01fb0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +102 -34
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -35956,20 +35956,22 @@ function offsetPoint(x, y, win) {
|
|
35956
35956
|
let offsetY = 0;
|
35957
35957
|
if (win.parent !== win.self) {
|
35958
35958
|
const iframe = win.frameElement;
|
35959
|
-
|
35960
|
-
|
35961
|
-
|
35962
|
-
|
35963
|
-
|
35964
|
-
|
35965
|
-
|
35966
|
-
|
35967
|
-
|
35968
|
-
|
35969
|
-
|
35970
|
-
|
35971
|
-
|
35972
|
-
|
35959
|
+
if (iframe) {
|
35960
|
+
const rect = iframe.getBoundingClientRect();
|
35961
|
+
const transform = getTransform(iframe);
|
35962
|
+
offsetX = rect.left;
|
35963
|
+
offsetY = rect.top;
|
35964
|
+
if (transform) {
|
35965
|
+
const {
|
35966
|
+
x: transformedX,
|
35967
|
+
y: transformedY
|
35968
|
+
} = applyTransformPoint(x, y, transform.matrix, transform.origin);
|
35969
|
+
const point2 = {
|
35970
|
+
x: transformedX + offsetX,
|
35971
|
+
y: transformedY + offsetY
|
35972
|
+
};
|
35973
|
+
return point2;
|
35974
|
+
}
|
35973
35975
|
}
|
35974
35976
|
}
|
35975
35977
|
const point = {
|
@@ -41050,7 +41052,7 @@ var init_dnd_esm = __esm({
|
|
41050
41052
|
}
|
41051
41053
|
if (!el.parentElement) {
|
41052
41054
|
const refWindow = el.ownerDocument.defaultView;
|
41053
|
-
if (refWindow && refWindow.self !== refWindow.parent) {
|
41055
|
+
if (refWindow && refWindow.self !== refWindow.parent && refWindow.frameElement) {
|
41054
41056
|
const iframe = refWindow.frameElement;
|
41055
41057
|
return findNearestTransform(iframe);
|
41056
41058
|
}
|
@@ -41172,7 +41174,7 @@ var init_dnd_esm = __esm({
|
|
41172
41174
|
}) => {
|
41173
41175
|
const el = querySelectorAllIframe(`[data-rfd-draggable-id="${state.critical.draggable.id}"]`)[0];
|
41174
41176
|
const win = (el == null ? void 0 : el.ownerDocument.defaultView) || window;
|
41175
|
-
const isInIframe = win !== window;
|
41177
|
+
const isInIframe = win !== window && win.frameElement;
|
41176
41178
|
if (isInIframe) {
|
41177
41179
|
const iframe = win.frameElement;
|
41178
41180
|
const viewportBox = getBox(iframe);
|
@@ -45866,6 +45868,26 @@ var require_dist = __commonJS({
|
|
45866
45868
|
mod
|
45867
45869
|
));
|
45868
45870
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
45871
|
+
var __async2 = (__this, __arguments, generator) => {
|
45872
|
+
return new Promise((resolve, reject) => {
|
45873
|
+
var fulfilled = (value) => {
|
45874
|
+
try {
|
45875
|
+
step(generator.next(value));
|
45876
|
+
} catch (e2) {
|
45877
|
+
reject(e2);
|
45878
|
+
}
|
45879
|
+
};
|
45880
|
+
var rejected = (value) => {
|
45881
|
+
try {
|
45882
|
+
step(generator.throw(value));
|
45883
|
+
} catch (e2) {
|
45884
|
+
reject(e2);
|
45885
|
+
}
|
45886
|
+
};
|
45887
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
45888
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
45889
|
+
});
|
45890
|
+
};
|
45869
45891
|
var auto_frame_component_exports = {};
|
45870
45892
|
__export2(auto_frame_component_exports, {
|
45871
45893
|
default: () => AutoFrameComponent_default
|
@@ -45884,6 +45906,23 @@ var require_dist = __commonJS({
|
|
45884
45906
|
});
|
45885
45907
|
return collected;
|
45886
45908
|
};
|
45909
|
+
var getStyleSheet = (el) => {
|
45910
|
+
return Array.from(document.styleSheets).find((ss) => ss.ownerNode === el);
|
45911
|
+
};
|
45912
|
+
var getStyles2 = (styleSheet) => {
|
45913
|
+
if (styleSheet) {
|
45914
|
+
try {
|
45915
|
+
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
|
45916
|
+
} catch (e2) {
|
45917
|
+
console.warn(
|
45918
|
+
"Access to stylesheet %s is denied. Ignoring\u2026",
|
45919
|
+
styleSheet.href
|
45920
|
+
);
|
45921
|
+
}
|
45922
|
+
}
|
45923
|
+
return "";
|
45924
|
+
};
|
45925
|
+
var defer = (fn) => setTimeout(fn, 0);
|
45887
45926
|
var CopyHostStyles = ({
|
45888
45927
|
children,
|
45889
45928
|
debug = false,
|
@@ -45898,7 +45937,7 @@ var require_dist = __commonJS({
|
|
45898
45937
|
const elements = [];
|
45899
45938
|
const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
|
45900
45939
|
const addEl = (el, onLoad = () => {
|
45901
|
-
}) => {
|
45940
|
+
}) => __async2(void 0, null, function* () {
|
45902
45941
|
const index = lookupEl(el);
|
45903
45942
|
if (index > -1) {
|
45904
45943
|
if (debug)
|
@@ -45909,10 +45948,34 @@ var require_dist = __commonJS({
|
|
45909
45948
|
onLoad();
|
45910
45949
|
return;
|
45911
45950
|
}
|
45912
|
-
|
45951
|
+
let mirror;
|
45952
|
+
if (el.nodeName === "LINK") {
|
45953
|
+
mirror = document.createElement("style");
|
45954
|
+
mirror.type = "text/css";
|
45955
|
+
let styleSheet = getStyleSheet(el);
|
45956
|
+
if (!styleSheet) {
|
45957
|
+
yield new Promise((resolve) => el.onload = resolve);
|
45958
|
+
styleSheet = getStyleSheet(el);
|
45959
|
+
}
|
45960
|
+
const styles = getStyles2(styleSheet);
|
45961
|
+
if (!styles) {
|
45962
|
+
if (debug) {
|
45963
|
+
console.warn(
|
45964
|
+
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
45965
|
+
);
|
45966
|
+
}
|
45967
|
+
onLoad();
|
45968
|
+
return;
|
45969
|
+
}
|
45970
|
+
mirror.innerHTML = styles;
|
45971
|
+
mirror.setAttribute("data-href", el.getAttribute("href"));
|
45972
|
+
} else {
|
45973
|
+
mirror = el.cloneNode(true);
|
45974
|
+
}
|
45975
|
+
const elHash = (0, import_object_hash.default)(mirror.outerHTML);
|
45913
45976
|
const existingHashes = collectStyles(doc).map(
|
45914
|
-
(existingStyle) => (0, import_object_hash.default)(existingStyle.outerHTML)
|
45915
|
-
);
|
45977
|
+
(existingStyle) => existingStyle !== mirror && (0, import_object_hash.default)(existingStyle.outerHTML)
|
45978
|
+
).filter(Boolean);
|
45916
45979
|
if (existingHashes.indexOf(elHash) > -1) {
|
45917
45980
|
if (debug)
|
45918
45981
|
console.log(
|
@@ -45921,13 +45984,12 @@ var require_dist = __commonJS({
|
|
45921
45984
|
onLoad();
|
45922
45985
|
return;
|
45923
45986
|
}
|
45924
|
-
const mirror = el.cloneNode(true);
|
45925
45987
|
mirror.onload = onLoad;
|
45926
45988
|
doc.head.append(mirror);
|
45927
45989
|
elements.push({ original: el, mirror });
|
45928
45990
|
if (debug)
|
45929
45991
|
console.log(`Added style node ${el.outerHTML}`);
|
45930
|
-
};
|
45992
|
+
});
|
45931
45993
|
const removeEl = (el) => {
|
45932
45994
|
const index = lookupEl(el);
|
45933
45995
|
if (index === -1) {
|
@@ -45948,7 +46010,7 @@ var require_dist = __commonJS({
|
|
45948
46010
|
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
45949
46011
|
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
45950
46012
|
if (el && el.matches(styleSelector)) {
|
45951
|
-
addEl(el);
|
46013
|
+
defer(() => addEl(el));
|
45952
46014
|
}
|
45953
46015
|
}
|
45954
46016
|
});
|
@@ -45956,7 +46018,7 @@ var require_dist = __commonJS({
|
|
45956
46018
|
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
45957
46019
|
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
45958
46020
|
if (el && el.matches(styleSelector)) {
|
45959
|
-
removeEl(el);
|
46021
|
+
defer(() => removeEl(el));
|
45960
46022
|
}
|
45961
46023
|
}
|
45962
46024
|
});
|
@@ -45967,12 +46029,14 @@ var require_dist = __commonJS({
|
|
45967
46029
|
const collectedStyles = collectStyles(parentDocument);
|
45968
46030
|
let mountedCounter = 0;
|
45969
46031
|
collectedStyles.forEach((styleNode) => {
|
45970
|
-
|
45971
|
-
|
45972
|
-
|
45973
|
-
|
45974
|
-
|
45975
|
-
|
46032
|
+
defer(
|
46033
|
+
() => addEl(styleNode, () => {
|
46034
|
+
mountedCounter += 1;
|
46035
|
+
if (mountedCounter === collectedStyles.length) {
|
46036
|
+
onStylesLoaded();
|
46037
|
+
}
|
46038
|
+
})
|
46039
|
+
);
|
45976
46040
|
});
|
45977
46041
|
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
45978
46042
|
return () => {
|
@@ -45981,10 +46045,14 @@ var require_dist = __commonJS({
|
|
45981
46045
|
}, []);
|
45982
46046
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
|
45983
46047
|
};
|
45984
|
-
var
|
45985
|
-
|
45986
|
-
|
45987
|
-
|
46048
|
+
var AutoFrameComponent = import_react22.default.forwardRef(
|
46049
|
+
function(_a3, ref2) {
|
46050
|
+
var _b = _a3, { children, debug, onStylesLoaded } = _b, props = __objRest2(_b, ["children", "debug", "onStylesLoaded"]);
|
46051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_frame_component.default, __spreadProps2(__spreadValues2({}, props), { ref: ref2, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopyHostStyles, { debug, onStylesLoaded, children }) }));
|
46052
|
+
}
|
46053
|
+
);
|
46054
|
+
AutoFrameComponent.displayName = "AutoFrameComponent";
|
46055
|
+
var AutoFrameComponent_default = AutoFrameComponent;
|
45988
46056
|
}
|
45989
46057
|
});
|
45990
46058
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
3
|
-
"version": "0.14.2-canary.
|
3
|
+
"version": "0.14.2-canary.ba01fb0",
|
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.14.2-canary.
|
21
|
+
"@measured/puck": "^0.14.2-canary.ba01fb0",
|
22
22
|
"@types/react": "^18.2.0",
|
23
23
|
"@types/react-dom": "^18.2.0",
|
24
24
|
"eslint": "^7.32.0",
|