@measured/puck-plugin-heading-analyzer 0.14.2-canary.25a7c4b → 0.14.2-canary.276d0f8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +70 -45
- 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);
|
@@ -45920,31 +45922,23 @@ var require_dist = __commonJS({
|
|
45920
45922
|
}
|
45921
45923
|
return "";
|
45922
45924
|
};
|
45925
|
+
var defer = (fn) => setTimeout(fn, 0);
|
45923
45926
|
var CopyHostStyles = ({
|
45924
45927
|
children,
|
45925
45928
|
debug = false,
|
45926
45929
|
onStylesLoaded = () => null
|
45927
45930
|
}) => {
|
45928
45931
|
const { document: doc, window: win } = (0, import_react_frame_component.useFrame)();
|
45929
|
-
(0, import_react22.
|
45932
|
+
(0, import_react22.useEffect)(() => {
|
45930
45933
|
if (!win || !doc) {
|
45931
45934
|
return () => {
|
45932
45935
|
};
|
45933
45936
|
}
|
45934
|
-
|
45937
|
+
let elements = [];
|
45938
|
+
const hashes = {};
|
45935
45939
|
const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
|
45936
|
-
const
|
45940
|
+
const mirrorEl = (el, onLoad = () => {
|
45937
45941
|
}) => __async2(void 0, null, function* () {
|
45938
|
-
const index = lookupEl(el);
|
45939
|
-
if (index > -1) {
|
45940
|
-
if (debug)
|
45941
|
-
console.log(
|
45942
|
-
`Tried to add an element that was already mirrored. Updating instead...`
|
45943
|
-
);
|
45944
|
-
elements[index].mirror.innerText = el.innerText;
|
45945
|
-
onLoad();
|
45946
|
-
return;
|
45947
|
-
}
|
45948
45942
|
let mirror;
|
45949
45943
|
if (el.nodeName === "LINK") {
|
45950
45944
|
mirror = document.createElement("style");
|
@@ -45961,7 +45955,6 @@ var require_dist = __commonJS({
|
|
45961
45955
|
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
45962
45956
|
);
|
45963
45957
|
}
|
45964
|
-
onLoad();
|
45965
45958
|
return;
|
45966
45959
|
}
|
45967
45960
|
mirror.innerHTML = styles;
|
@@ -45969,11 +45962,28 @@ var require_dist = __commonJS({
|
|
45969
45962
|
} else {
|
45970
45963
|
mirror = el.cloneNode(true);
|
45971
45964
|
}
|
45965
|
+
mirror.onload = onLoad;
|
45966
|
+
return mirror;
|
45967
|
+
});
|
45968
|
+
const addEl = (el, onLoad = () => {
|
45969
|
+
}) => __async2(void 0, null, function* () {
|
45970
|
+
const index = lookupEl(el);
|
45971
|
+
if (index > -1) {
|
45972
|
+
if (debug)
|
45973
|
+
console.log(
|
45974
|
+
`Tried to add an element that was already mirrored. Updating instead...`
|
45975
|
+
);
|
45976
|
+
elements[index].mirror.innerText = el.innerText;
|
45977
|
+
onLoad();
|
45978
|
+
return;
|
45979
|
+
}
|
45980
|
+
const mirror = yield mirrorEl(el, onLoad);
|
45981
|
+
if (!mirror) {
|
45982
|
+
onLoad();
|
45983
|
+
return;
|
45984
|
+
}
|
45972
45985
|
const elHash = (0, import_object_hash.default)(mirror.outerHTML);
|
45973
|
-
|
45974
|
-
(existingStyle) => existingStyle !== mirror && (0, import_object_hash.default)(existingStyle.outerHTML)
|
45975
|
-
).filter(Boolean);
|
45976
|
-
if (existingHashes.indexOf(elHash) > -1) {
|
45986
|
+
if (hashes[elHash]) {
|
45977
45987
|
if (debug)
|
45978
45988
|
console.log(
|
45979
45989
|
`iframe already contains element that is being mirrored. Skipping...`
|
@@ -45981,6 +45991,7 @@ var require_dist = __commonJS({
|
|
45981
45991
|
onLoad();
|
45982
45992
|
return;
|
45983
45993
|
}
|
45994
|
+
hashes[elHash] = true;
|
45984
45995
|
mirror.onload = onLoad;
|
45985
45996
|
doc.head.append(mirror);
|
45986
45997
|
elements.push({ original: el, mirror });
|
@@ -45988,6 +45999,7 @@ var require_dist = __commonJS({
|
|
45988
45999
|
console.log(`Added style node ${el.outerHTML}`);
|
45989
46000
|
});
|
45990
46001
|
const removeEl = (el) => {
|
46002
|
+
var _a3, _b;
|
45991
46003
|
const index = lookupEl(el);
|
45992
46004
|
if (index === -1) {
|
45993
46005
|
if (debug)
|
@@ -45996,7 +46008,9 @@ var require_dist = __commonJS({
|
|
45996
46008
|
);
|
45997
46009
|
return;
|
45998
46010
|
}
|
45999
|
-
|
46011
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
46012
|
+
(_b = (_a3 = elements[index]) == null ? void 0 : _a3.mirror) == null ? void 0 : _b.remove();
|
46013
|
+
delete hashes[elHash];
|
46000
46014
|
if (debug)
|
46001
46015
|
console.log(`Removed style node ${el.outerHTML}`);
|
46002
46016
|
};
|
@@ -46007,7 +46021,7 @@ var require_dist = __commonJS({
|
|
46007
46021
|
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
46008
46022
|
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
46009
46023
|
if (el && el.matches(styleSelector)) {
|
46010
|
-
addEl(el);
|
46024
|
+
defer(() => addEl(el));
|
46011
46025
|
}
|
46012
46026
|
}
|
46013
46027
|
});
|
@@ -46015,7 +46029,7 @@ var require_dist = __commonJS({
|
|
46015
46029
|
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
46016
46030
|
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
46017
46031
|
if (el && el.matches(styleSelector)) {
|
46018
|
-
removeEl(el);
|
46032
|
+
defer(() => removeEl(el));
|
46019
46033
|
}
|
46020
46034
|
}
|
46021
46035
|
});
|
@@ -46024,16 +46038,27 @@ var require_dist = __commonJS({
|
|
46024
46038
|
});
|
46025
46039
|
const parentDocument = win.parent.document;
|
46026
46040
|
const collectedStyles = collectStyles(parentDocument);
|
46027
|
-
|
46028
|
-
|
46029
|
-
|
46030
|
-
|
46031
|
-
|
46032
|
-
|
46033
|
-
|
46041
|
+
Promise.all(
|
46042
|
+
collectedStyles.map((styleNode) => __async2(void 0, null, function* () {
|
46043
|
+
const mirror = yield mirrorEl(styleNode);
|
46044
|
+
if (!mirror)
|
46045
|
+
return;
|
46046
|
+
elements.push({ original: styleNode, mirror });
|
46047
|
+
return mirror;
|
46048
|
+
}))
|
46049
|
+
).then((mirrorStyles) => {
|
46050
|
+
const filtered = mirrorStyles.filter(
|
46051
|
+
(el) => typeof el !== "undefined"
|
46052
|
+
);
|
46053
|
+
doc.head.innerHTML = "";
|
46054
|
+
doc.head.append(...filtered);
|
46055
|
+
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
46056
|
+
filtered.forEach((el) => {
|
46057
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
46058
|
+
hashes[elHash] = true;
|
46034
46059
|
});
|
46060
|
+
onStylesLoaded();
|
46035
46061
|
});
|
46036
|
-
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
46037
46062
|
return () => {
|
46038
46063
|
observer.disconnect();
|
46039
46064
|
};
|
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.276d0f8",
|
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.276d0f8",
|
22
22
|
"@types/react": "^18.2.0",
|
23
23
|
"@types/react-dom": "^18.2.0",
|
24
24
|
"eslint": "^7.32.0",
|