@measured/puck-plugin-heading-analyzer 0.14.2-canary.25a7c4b → 0.14.2-canary.2743a73
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +92 -48
- 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);
|
@@ -45905,7 +45907,10 @@ var require_dist = __commonJS({
|
|
45905
45907
|
return collected;
|
45906
45908
|
};
|
45907
45909
|
var getStyleSheet = (el) => {
|
45908
|
-
return Array.from(document.styleSheets).find((ss) =>
|
45910
|
+
return Array.from(document.styleSheets).find((ss) => {
|
45911
|
+
const ownerNode = ss.ownerNode;
|
45912
|
+
return ownerNode.href === el.href;
|
45913
|
+
});
|
45909
45914
|
};
|
45910
45915
|
var getStyles2 = (styleSheet) => {
|
45911
45916
|
if (styleSheet) {
|
@@ -45920,38 +45925,36 @@ var require_dist = __commonJS({
|
|
45920
45925
|
}
|
45921
45926
|
return "";
|
45922
45927
|
};
|
45928
|
+
var defer = (fn) => setTimeout(fn, 0);
|
45923
45929
|
var CopyHostStyles = ({
|
45924
45930
|
children,
|
45925
45931
|
debug = false,
|
45926
45932
|
onStylesLoaded = () => null
|
45927
45933
|
}) => {
|
45928
45934
|
const { document: doc, window: win } = (0, import_react_frame_component.useFrame)();
|
45929
|
-
(0, import_react22.
|
45935
|
+
(0, import_react22.useEffect)(() => {
|
45930
45936
|
if (!win || !doc) {
|
45931
45937
|
return () => {
|
45932
45938
|
};
|
45933
45939
|
}
|
45934
|
-
|
45940
|
+
let elements = [];
|
45941
|
+
const hashes = {};
|
45935
45942
|
const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
|
45936
|
-
const
|
45943
|
+
const mirrorEl = (el, onLoad = () => {
|
45937
45944
|
}) => __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
45945
|
let mirror;
|
45949
45946
|
if (el.nodeName === "LINK") {
|
45950
45947
|
mirror = document.createElement("style");
|
45951
45948
|
mirror.type = "text/css";
|
45952
45949
|
let styleSheet = getStyleSheet(el);
|
45953
45950
|
if (!styleSheet) {
|
45954
|
-
yield new Promise((resolve) =>
|
45951
|
+
yield new Promise((resolve) => {
|
45952
|
+
const fn = () => {
|
45953
|
+
resolve();
|
45954
|
+
el.removeEventListener("load", fn);
|
45955
|
+
};
|
45956
|
+
el.addEventListener("load", fn);
|
45957
|
+
});
|
45955
45958
|
styleSheet = getStyleSheet(el);
|
45956
45959
|
}
|
45957
45960
|
const styles = getStyles2(styleSheet);
|
@@ -45961,7 +45964,6 @@ var require_dist = __commonJS({
|
|
45961
45964
|
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
45962
45965
|
);
|
45963
45966
|
}
|
45964
|
-
onLoad();
|
45965
45967
|
return;
|
45966
45968
|
}
|
45967
45969
|
mirror.innerHTML = styles;
|
@@ -45969,11 +45971,28 @@ var require_dist = __commonJS({
|
|
45969
45971
|
} else {
|
45970
45972
|
mirror = el.cloneNode(true);
|
45971
45973
|
}
|
45974
|
+
mirror.onload = onLoad;
|
45975
|
+
return mirror;
|
45976
|
+
});
|
45977
|
+
const addEl = (el, onLoad = () => {
|
45978
|
+
}) => __async2(void 0, null, function* () {
|
45979
|
+
const index = lookupEl(el);
|
45980
|
+
if (index > -1) {
|
45981
|
+
if (debug)
|
45982
|
+
console.log(
|
45983
|
+
`Tried to add an element that was already mirrored. Updating instead...`
|
45984
|
+
);
|
45985
|
+
elements[index].mirror.innerText = el.innerText;
|
45986
|
+
onLoad();
|
45987
|
+
return;
|
45988
|
+
}
|
45989
|
+
const mirror = yield mirrorEl(el, onLoad);
|
45990
|
+
if (!mirror) {
|
45991
|
+
onLoad();
|
45992
|
+
return;
|
45993
|
+
}
|
45972
45994
|
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) {
|
45995
|
+
if (hashes[elHash]) {
|
45977
45996
|
if (debug)
|
45978
45997
|
console.log(
|
45979
45998
|
`iframe already contains element that is being mirrored. Skipping...`
|
@@ -45981,6 +46000,7 @@ var require_dist = __commonJS({
|
|
45981
46000
|
onLoad();
|
45982
46001
|
return;
|
45983
46002
|
}
|
46003
|
+
hashes[elHash] = true;
|
45984
46004
|
mirror.onload = onLoad;
|
45985
46005
|
doc.head.append(mirror);
|
45986
46006
|
elements.push({ original: el, mirror });
|
@@ -45988,6 +46008,7 @@ var require_dist = __commonJS({
|
|
45988
46008
|
console.log(`Added style node ${el.outerHTML}`);
|
45989
46009
|
});
|
45990
46010
|
const removeEl = (el) => {
|
46011
|
+
var _a3, _b;
|
45991
46012
|
const index = lookupEl(el);
|
45992
46013
|
if (index === -1) {
|
45993
46014
|
if (debug)
|
@@ -45996,7 +46017,9 @@ var require_dist = __commonJS({
|
|
45996
46017
|
);
|
45997
46018
|
return;
|
45998
46019
|
}
|
45999
|
-
|
46020
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
46021
|
+
(_b = (_a3 = elements[index]) == null ? void 0 : _a3.mirror) == null ? void 0 : _b.remove();
|
46022
|
+
delete hashes[elHash];
|
46000
46023
|
if (debug)
|
46001
46024
|
console.log(`Removed style node ${el.outerHTML}`);
|
46002
46025
|
};
|
@@ -46007,7 +46030,7 @@ var require_dist = __commonJS({
|
|
46007
46030
|
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
46008
46031
|
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
46009
46032
|
if (el && el.matches(styleSelector)) {
|
46010
|
-
addEl(el);
|
46033
|
+
defer(() => addEl(el));
|
46011
46034
|
}
|
46012
46035
|
}
|
46013
46036
|
});
|
@@ -46015,7 +46038,7 @@ var require_dist = __commonJS({
|
|
46015
46038
|
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
46016
46039
|
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
46017
46040
|
if (el && el.matches(styleSelector)) {
|
46018
|
-
removeEl(el);
|
46041
|
+
defer(() => removeEl(el));
|
46019
46042
|
}
|
46020
46043
|
}
|
46021
46044
|
});
|
@@ -46024,16 +46047,35 @@ var require_dist = __commonJS({
|
|
46024
46047
|
});
|
46025
46048
|
const parentDocument = win.parent.document;
|
46026
46049
|
const collectedStyles = collectStyles(parentDocument);
|
46027
|
-
|
46028
|
-
|
46029
|
-
|
46030
|
-
|
46031
|
-
|
46032
|
-
|
46050
|
+
const hrefs = [];
|
46051
|
+
Promise.all(
|
46052
|
+
collectedStyles.map((styleNode, i2) => __async2(void 0, null, function* () {
|
46053
|
+
if (styleNode.nodeName === "LINK") {
|
46054
|
+
const linkHref = styleNode.href;
|
46055
|
+
if (hrefs.indexOf(linkHref) > -1) {
|
46056
|
+
return;
|
46057
|
+
}
|
46058
|
+
hrefs.push(linkHref);
|
46033
46059
|
}
|
46060
|
+
const mirror = yield mirrorEl(styleNode);
|
46061
|
+
if (!mirror)
|
46062
|
+
return;
|
46063
|
+
elements.push({ original: styleNode, mirror });
|
46064
|
+
return mirror;
|
46065
|
+
}))
|
46066
|
+
).then((mirrorStyles) => {
|
46067
|
+
const filtered = mirrorStyles.filter(
|
46068
|
+
(el) => typeof el !== "undefined"
|
46069
|
+
);
|
46070
|
+
doc.head.innerHTML = "";
|
46071
|
+
doc.head.append(...filtered);
|
46072
|
+
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
46073
|
+
filtered.forEach((el) => {
|
46074
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
46075
|
+
hashes[elHash] = true;
|
46034
46076
|
});
|
46077
|
+
onStylesLoaded();
|
46035
46078
|
});
|
46036
|
-
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
46037
46079
|
return () => {
|
46038
46080
|
observer.disconnect();
|
46039
46081
|
};
|
@@ -78320,7 +78362,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
78320
78362
|
onChange(e2.currentTarget.value);
|
78321
78363
|
},
|
78322
78364
|
disabled: readOnly,
|
78323
|
-
|
78365
|
+
checked: value === option.value
|
78324
78366
|
}
|
78325
78367
|
),
|
78326
78368
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName14("radioInner"), children: option.label || option.value })
|
@@ -79615,7 +79657,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
79615
79657
|
viewports = defaultViewports2,
|
79616
79658
|
iframe = {
|
79617
79659
|
enabled: true
|
79618
|
-
}
|
79660
|
+
},
|
79661
|
+
dnd
|
79619
79662
|
}) {
|
79620
79663
|
var _a3;
|
79621
79664
|
const historyStore = useHistoryStore();
|
@@ -79815,6 +79858,7 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
|
|
79815
79858
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
79816
79859
|
DragDropContext2,
|
79817
79860
|
{
|
79861
|
+
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
79818
79862
|
onDragUpdate: (update2) => {
|
79819
79863
|
setDraggedItem(__spreadValues2(__spreadValues2({}, draggedItem), update2));
|
79820
79864
|
onDragStartOrUpdate(update2);
|
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.2743a73",
|
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.2743a73",
|
22
22
|
"@types/react": "^18.2.0",
|
23
23
|
"@types/react-dom": "^18.2.0",
|
24
24
|
"eslint": "^7.32.0",
|