@ohhwells/bridge 0.1.29-next.21 → 0.1.29-next.24
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.cjs +246 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +246 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5418,6 +5418,15 @@ function getHrefKeyFromElement(el) {
|
|
|
5418
5418
|
if (!key) return null;
|
|
5419
5419
|
return { anchor, key };
|
|
5420
5420
|
}
|
|
5421
|
+
function isNavbarButton(el) {
|
|
5422
|
+
return Boolean(el.closest('[data-ohw-role="navbar-button"]'));
|
|
5423
|
+
}
|
|
5424
|
+
function clearHrefKeyHover(anchor) {
|
|
5425
|
+
anchor.removeAttribute("data-ohw-hovered");
|
|
5426
|
+
anchor.querySelectorAll("[data-ohw-hovered]").forEach((el) => {
|
|
5427
|
+
el.removeAttribute("data-ohw-hovered");
|
|
5428
|
+
});
|
|
5429
|
+
}
|
|
5421
5430
|
function collectSections() {
|
|
5422
5431
|
return collectSectionsFromDom();
|
|
5423
5432
|
}
|
|
@@ -5579,19 +5588,24 @@ function GlowFrame({ rect, elRef }) {
|
|
|
5579
5588
|
}
|
|
5580
5589
|
);
|
|
5581
5590
|
}
|
|
5582
|
-
function calcToolbarPos(rect, parentScroll) {
|
|
5591
|
+
function calcToolbarPos(rect, parentScroll, approxW = 330) {
|
|
5583
5592
|
const GAP = 8;
|
|
5584
5593
|
const APPROX_H = 36;
|
|
5585
|
-
const APPROX_W =
|
|
5594
|
+
const APPROX_W = approxW;
|
|
5586
5595
|
const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
|
|
5587
5596
|
const visibleTop = rect.top - canvasTopInIframe;
|
|
5588
5597
|
const visibleBottom = rect.bottom - canvasTopInIframe;
|
|
5589
5598
|
const isTall = rect.height > APPROX_H + GAP;
|
|
5599
|
+
const spaceAbove = rect.top - (canvasTopInIframe + GAP);
|
|
5600
|
+
const fitsAbove = spaceAbove >= APPROX_H + GAP;
|
|
5590
5601
|
let top;
|
|
5591
5602
|
let transform;
|
|
5592
|
-
if (visibleTop > 0 || !isTall) {
|
|
5603
|
+
if ((visibleTop > 0 || !isTall) && fitsAbove) {
|
|
5593
5604
|
top = rect.top - GAP;
|
|
5594
5605
|
transform = "translateX(-50%) translateY(-100%)";
|
|
5606
|
+
} else if (visibleTop > 0 || !isTall) {
|
|
5607
|
+
top = rect.bottom + GAP;
|
|
5608
|
+
transform = "translateX(-50%)";
|
|
5595
5609
|
} else if (visibleBottom > APPROX_H + GAP) {
|
|
5596
5610
|
top = canvasTopInIframe + GAP;
|
|
5597
5611
|
transform = "translateX(-50%)";
|
|
@@ -5603,16 +5617,114 @@ function calcToolbarPos(rect, parentScroll) {
|
|
|
5603
5617
|
const left = Math.max(GAP + APPROX_W / 2, Math.min(rawLeft, window.innerWidth - GAP - APPROX_W / 2));
|
|
5604
5618
|
return { top, left, transform };
|
|
5605
5619
|
}
|
|
5620
|
+
var EDIT_LINK_ICON = /* @__PURE__ */ jsxs8("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
5621
|
+
/* @__PURE__ */ jsx16("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
5622
|
+
/* @__PURE__ */ jsx16("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
5623
|
+
] });
|
|
5606
5624
|
function FloatingToolbar({
|
|
5607
5625
|
rect,
|
|
5608
5626
|
parentScroll,
|
|
5609
5627
|
elRef,
|
|
5628
|
+
variant = "rich-text",
|
|
5610
5629
|
onCommand,
|
|
5611
5630
|
activeCommands,
|
|
5612
5631
|
showEditLink,
|
|
5613
5632
|
onEditLink
|
|
5614
5633
|
}) {
|
|
5615
|
-
const
|
|
5634
|
+
const approxW = variant === "link-action" ? 120 : 330;
|
|
5635
|
+
const { top, left, transform } = calcToolbarPos(rect, parentScroll, approxW);
|
|
5636
|
+
if (variant === "link-action") {
|
|
5637
|
+
return /* @__PURE__ */ jsxs8(
|
|
5638
|
+
"div",
|
|
5639
|
+
{
|
|
5640
|
+
ref: elRef,
|
|
5641
|
+
"data-ohw-toolbar": "",
|
|
5642
|
+
style: {
|
|
5643
|
+
position: "fixed",
|
|
5644
|
+
top,
|
|
5645
|
+
left,
|
|
5646
|
+
transform,
|
|
5647
|
+
zIndex: 2147483647,
|
|
5648
|
+
background: "#fff",
|
|
5649
|
+
border: "1px solid #E7E5E4",
|
|
5650
|
+
borderRadius: 6,
|
|
5651
|
+
boxShadow: "0px 2px 4px -2px rgba(0,0,0,.1),0px 4px 6px -1px rgba(0,0,0,.1)",
|
|
5652
|
+
display: "flex",
|
|
5653
|
+
alignItems: "center",
|
|
5654
|
+
padding: 4,
|
|
5655
|
+
gap: 6,
|
|
5656
|
+
fontFamily: "sans-serif",
|
|
5657
|
+
pointerEvents: "auto",
|
|
5658
|
+
whiteSpace: "nowrap"
|
|
5659
|
+
},
|
|
5660
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
5661
|
+
children: [
|
|
5662
|
+
/* @__PURE__ */ jsx16(
|
|
5663
|
+
"button",
|
|
5664
|
+
{
|
|
5665
|
+
type: "button",
|
|
5666
|
+
title: "Edit link",
|
|
5667
|
+
onMouseDown: (e) => {
|
|
5668
|
+
e.preventDefault();
|
|
5669
|
+
e.stopPropagation();
|
|
5670
|
+
onEditLink?.();
|
|
5671
|
+
},
|
|
5672
|
+
onClick: (e) => {
|
|
5673
|
+
e.preventDefault();
|
|
5674
|
+
e.stopPropagation();
|
|
5675
|
+
},
|
|
5676
|
+
onMouseEnter: (e) => {
|
|
5677
|
+
e.currentTarget.style.background = "#F5F5F4";
|
|
5678
|
+
},
|
|
5679
|
+
onMouseLeave: (e) => {
|
|
5680
|
+
e.currentTarget.style.background = "transparent";
|
|
5681
|
+
},
|
|
5682
|
+
style: {
|
|
5683
|
+
display: "flex",
|
|
5684
|
+
alignItems: "center",
|
|
5685
|
+
justifyContent: "center",
|
|
5686
|
+
border: "none",
|
|
5687
|
+
background: "transparent",
|
|
5688
|
+
borderRadius: 4,
|
|
5689
|
+
cursor: "pointer",
|
|
5690
|
+
color: "#1C1917",
|
|
5691
|
+
flexShrink: 0,
|
|
5692
|
+
padding: 6
|
|
5693
|
+
},
|
|
5694
|
+
children: EDIT_LINK_ICON
|
|
5695
|
+
}
|
|
5696
|
+
),
|
|
5697
|
+
/* @__PURE__ */ jsx16("span", { style: { display: "block", width: 1, height: 24, background: "#E7E5E4", flexShrink: 0 } }),
|
|
5698
|
+
/* @__PURE__ */ jsx16(
|
|
5699
|
+
"button",
|
|
5700
|
+
{
|
|
5701
|
+
type: "button",
|
|
5702
|
+
title: "Coming soon",
|
|
5703
|
+
disabled: true,
|
|
5704
|
+
style: {
|
|
5705
|
+
display: "flex",
|
|
5706
|
+
alignItems: "center",
|
|
5707
|
+
justifyContent: "center",
|
|
5708
|
+
border: "none",
|
|
5709
|
+
background: "transparent",
|
|
5710
|
+
borderRadius: 4,
|
|
5711
|
+
cursor: "not-allowed",
|
|
5712
|
+
color: "#A8A29E",
|
|
5713
|
+
flexShrink: 0,
|
|
5714
|
+
padding: 6,
|
|
5715
|
+
opacity: 0.6
|
|
5716
|
+
},
|
|
5717
|
+
children: /* @__PURE__ */ jsxs8("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: [
|
|
5718
|
+
/* @__PURE__ */ jsx16("circle", { cx: "5", cy: "12", r: "1.5" }),
|
|
5719
|
+
/* @__PURE__ */ jsx16("circle", { cx: "12", cy: "12", r: "1.5" }),
|
|
5720
|
+
/* @__PURE__ */ jsx16("circle", { cx: "19", cy: "12", r: "1.5" })
|
|
5721
|
+
] })
|
|
5722
|
+
}
|
|
5723
|
+
)
|
|
5724
|
+
]
|
|
5725
|
+
}
|
|
5726
|
+
);
|
|
5727
|
+
}
|
|
5616
5728
|
return /* @__PURE__ */ jsxs8(
|
|
5617
5729
|
"div",
|
|
5618
5730
|
{
|
|
@@ -5720,10 +5832,7 @@ function FloatingToolbar({
|
|
|
5720
5832
|
flexShrink: 0,
|
|
5721
5833
|
padding: 6
|
|
5722
5834
|
},
|
|
5723
|
-
children:
|
|
5724
|
-
/* @__PURE__ */ jsx16("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
5725
|
-
/* @__PURE__ */ jsx16("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
5726
|
-
] })
|
|
5835
|
+
children: EDIT_LINK_ICON
|
|
5727
5836
|
}
|
|
5728
5837
|
) : null
|
|
5729
5838
|
]
|
|
@@ -5814,6 +5923,7 @@ function OhhwellsBridge() {
|
|
|
5814
5923
|
const [fetchState, setFetchState] = useState5("idle");
|
|
5815
5924
|
const autoSaveTimers = useRef3(/* @__PURE__ */ new Map());
|
|
5816
5925
|
const activeElRef = useRef3(null);
|
|
5926
|
+
const selectedElRef = useRef3(null);
|
|
5817
5927
|
const originalContentRef = useRef3(null);
|
|
5818
5928
|
const activeStateElRef = useRef3(null);
|
|
5819
5929
|
const parentScrollRef = useRef3(null);
|
|
@@ -5829,6 +5939,10 @@ function OhhwellsBridge() {
|
|
|
5829
5939
|
});
|
|
5830
5940
|
const deactivateRef = useRef3(() => {
|
|
5831
5941
|
});
|
|
5942
|
+
const selectRef = useRef3(() => {
|
|
5943
|
+
});
|
|
5944
|
+
const deselectRef = useRef3(() => {
|
|
5945
|
+
});
|
|
5832
5946
|
const refreshActiveCommandsRef = useRef3(() => {
|
|
5833
5947
|
});
|
|
5834
5948
|
const postToParentRef = useRef3(postToParent);
|
|
@@ -5836,9 +5950,13 @@ function OhhwellsBridge() {
|
|
|
5836
5950
|
const sectionsLoadedRef = useRef3(false);
|
|
5837
5951
|
const pendingScheduleConfigRequests = useRef3([]);
|
|
5838
5952
|
const [toolbarRect, setToolbarRect] = useState5(null);
|
|
5953
|
+
const [toolbarVariant, setToolbarVariant] = useState5("none");
|
|
5954
|
+
const toolbarVariantRef = useRef3("none");
|
|
5955
|
+
toolbarVariantRef.current = toolbarVariant;
|
|
5839
5956
|
const [toggleState, setToggleState] = useState5(null);
|
|
5840
5957
|
const [maxBadge, setMaxBadge] = useState5(null);
|
|
5841
5958
|
const [activeCommands, setActiveCommands] = useState5(/* @__PURE__ */ new Set());
|
|
5959
|
+
const [sectionGap, setSectionGap] = useState5(null);
|
|
5842
5960
|
const [toolbarShowEditLink, setToolbarShowEditLink] = useState5(false);
|
|
5843
5961
|
const [linkPopover, setLinkPopover] = useState5(null);
|
|
5844
5962
|
const [sitePages, setSitePages] = useState5([]);
|
|
@@ -5905,7 +6023,6 @@ function OhhwellsBridge() {
|
|
|
5905
6023
|
if (!useFixtures) postToParent({ type: "ow:request-site-pages" });
|
|
5906
6024
|
return () => window.removeEventListener("message", onSitePages);
|
|
5907
6025
|
}, [isEditMode, postToParent]);
|
|
5908
|
-
const [sectionGap, setSectionGap] = useState5(null);
|
|
5909
6026
|
useEffect3(() => {
|
|
5910
6027
|
if (!isEditMode || shouldUseDevFixtures()) return;
|
|
5911
6028
|
void loadAllSectionsManifest().then((manifest) => {
|
|
@@ -5915,7 +6032,7 @@ function OhhwellsBridge() {
|
|
|
5915
6032
|
}, [isEditMode]);
|
|
5916
6033
|
useEffect3(() => {
|
|
5917
6034
|
const update = () => {
|
|
5918
|
-
const el = activeElRef.current;
|
|
6035
|
+
const el = activeElRef.current ?? selectedElRef.current;
|
|
5919
6036
|
if (el) setToolbarRect(el.getBoundingClientRect());
|
|
5920
6037
|
setToggleState((prev) => {
|
|
5921
6038
|
if (!prev || !activeStateElRef.current) return prev;
|
|
@@ -5983,19 +6100,41 @@ function OhhwellsBridge() {
|
|
|
5983
6100
|
}
|
|
5984
6101
|
el.removeAttribute("contenteditable");
|
|
5985
6102
|
activeElRef.current = null;
|
|
5986
|
-
|
|
6103
|
+
if (!selectedElRef.current) {
|
|
6104
|
+
setToolbarRect(null);
|
|
6105
|
+
setToolbarVariant("none");
|
|
6106
|
+
}
|
|
5987
6107
|
setMaxBadge(null);
|
|
5988
6108
|
setActiveCommands(/* @__PURE__ */ new Set());
|
|
5989
6109
|
setToolbarShowEditLink(false);
|
|
5990
6110
|
postToParent({ type: "ow:exit-edit" });
|
|
5991
6111
|
}, [postToParent]);
|
|
6112
|
+
const deselect = useCallback2(() => {
|
|
6113
|
+
selectedElRef.current = null;
|
|
6114
|
+
if (!activeElRef.current) {
|
|
6115
|
+
setToolbarRect(null);
|
|
6116
|
+
setToolbarVariant("none");
|
|
6117
|
+
}
|
|
6118
|
+
}, []);
|
|
6119
|
+
const select = useCallback2((anchor) => {
|
|
6120
|
+
if (!isNavbarButton(anchor)) return;
|
|
6121
|
+
if (activeElRef.current) deactivate();
|
|
6122
|
+
selectedElRef.current = anchor;
|
|
6123
|
+
clearHrefKeyHover(anchor);
|
|
6124
|
+
setToolbarVariant("link-action");
|
|
6125
|
+
setToolbarRect(anchor.getBoundingClientRect());
|
|
6126
|
+
setToolbarShowEditLink(false);
|
|
6127
|
+
setActiveCommands(/* @__PURE__ */ new Set());
|
|
6128
|
+
}, [deactivate]);
|
|
5992
6129
|
const activate = useCallback2((el) => {
|
|
5993
6130
|
if (activeElRef.current === el) return;
|
|
6131
|
+
selectedElRef.current = null;
|
|
5994
6132
|
deactivate();
|
|
5995
6133
|
if (hoveredImageRef.current) {
|
|
5996
6134
|
hoveredImageRef.current = null;
|
|
5997
6135
|
postToParentRef.current({ type: "ow:image-unhover" });
|
|
5998
6136
|
}
|
|
6137
|
+
setToolbarVariant("rich-text");
|
|
5999
6138
|
el.setAttribute("contenteditable", "true");
|
|
6000
6139
|
el.removeAttribute("data-ohw-hovered");
|
|
6001
6140
|
activeElRef.current = el;
|
|
@@ -6008,6 +6147,8 @@ function OhhwellsBridge() {
|
|
|
6008
6147
|
}, [deactivate, postToParent]);
|
|
6009
6148
|
activateRef.current = activate;
|
|
6010
6149
|
deactivateRef.current = deactivate;
|
|
6150
|
+
selectRef.current = select;
|
|
6151
|
+
deselectRef.current = deselect;
|
|
6011
6152
|
useLayoutEffect(() => {
|
|
6012
6153
|
if (!subdomain || isEditMode) {
|
|
6013
6154
|
setFetchState("done");
|
|
@@ -6221,6 +6362,7 @@ function OhhwellsBridge() {
|
|
|
6221
6362
|
if (editable.dataset.ohwEditable === "link") {
|
|
6222
6363
|
e.preventDefault();
|
|
6223
6364
|
e.stopPropagation();
|
|
6365
|
+
deselectRef.current();
|
|
6224
6366
|
deactivateRef.current();
|
|
6225
6367
|
bumpLinkPopoverGrace();
|
|
6226
6368
|
setLinkPopoverRef.current({
|
|
@@ -6236,11 +6378,31 @@ function OhhwellsBridge() {
|
|
|
6236
6378
|
postToParentRef.current({ type: "ow:image-pick", key: editable.dataset.ohwKey ?? "" });
|
|
6237
6379
|
return;
|
|
6238
6380
|
}
|
|
6381
|
+
const hrefCtx = getHrefKeyFromElement(editable);
|
|
6382
|
+
if (hrefCtx && isNavbarButton(hrefCtx.anchor)) {
|
|
6383
|
+
e.preventDefault();
|
|
6384
|
+
e.stopPropagation();
|
|
6385
|
+
const { anchor: anchor2 } = hrefCtx;
|
|
6386
|
+
if (selectedElRef.current === anchor2) {
|
|
6387
|
+
activateRef.current(editable);
|
|
6388
|
+
return;
|
|
6389
|
+
}
|
|
6390
|
+
selectRef.current(anchor2);
|
|
6391
|
+
return;
|
|
6392
|
+
}
|
|
6239
6393
|
e.preventDefault();
|
|
6240
6394
|
e.stopPropagation();
|
|
6241
6395
|
activateRef.current(editable);
|
|
6242
6396
|
return;
|
|
6243
6397
|
}
|
|
6398
|
+
const hrefAnchor = target.closest("[data-ohw-href-key]");
|
|
6399
|
+
if (hrefAnchor && isNavbarButton(hrefAnchor)) {
|
|
6400
|
+
e.preventDefault();
|
|
6401
|
+
e.stopPropagation();
|
|
6402
|
+
if (selectedElRef.current === hrefAnchor) return;
|
|
6403
|
+
selectRef.current(hrefAnchor);
|
|
6404
|
+
return;
|
|
6405
|
+
}
|
|
6244
6406
|
if (activeElRef.current) {
|
|
6245
6407
|
const sel = window.getSelection();
|
|
6246
6408
|
if (sel && !sel.isCollapsed) {
|
|
@@ -6255,15 +6417,22 @@ function OhhwellsBridge() {
|
|
|
6255
6417
|
const hrefCtx = getHrefKeyFromElement(activeElRef.current);
|
|
6256
6418
|
if (hrefCtx && (hrefCtx.anchor === target || hrefCtx.anchor.contains(target))) return;
|
|
6257
6419
|
}
|
|
6420
|
+
if (linkPopoverOpenRef.current && selectedElRef.current) {
|
|
6421
|
+
const selected = selectedElRef.current;
|
|
6422
|
+
if (selected === target || selected.contains(target)) return;
|
|
6423
|
+
}
|
|
6258
6424
|
if (linkPopoverOpenRef.current) {
|
|
6259
6425
|
setLinkPopoverRef.current(null);
|
|
6260
6426
|
return;
|
|
6261
6427
|
}
|
|
6428
|
+
deselectRef.current();
|
|
6262
6429
|
deactivateRef.current();
|
|
6263
6430
|
};
|
|
6264
6431
|
const handleMouseOver = (e) => {
|
|
6265
6432
|
const editable = e.target.closest("[data-ohw-editable]");
|
|
6266
6433
|
if (!editable) return;
|
|
6434
|
+
const selected = selectedElRef.current;
|
|
6435
|
+
if (selected && (selected === editable || selected.contains(editable))) return;
|
|
6267
6436
|
if (editable.dataset.ohwEditable !== "image" && editable.dataset.ohwEditable !== "bg-image" && !editable.hasAttribute("contenteditable")) {
|
|
6268
6437
|
editable.setAttribute("data-ohw-hovered", "");
|
|
6269
6438
|
}
|
|
@@ -6750,6 +6919,7 @@ function OhhwellsBridge() {
|
|
|
6750
6919
|
setLinkPopoverRef.current(null);
|
|
6751
6920
|
return;
|
|
6752
6921
|
}
|
|
6922
|
+
deselectRef.current();
|
|
6753
6923
|
deactivateRef.current();
|
|
6754
6924
|
};
|
|
6755
6925
|
window.addEventListener("message", handleDeactivate);
|
|
@@ -6758,6 +6928,10 @@ function OhhwellsBridge() {
|
|
|
6758
6928
|
setLinkPopoverRef.current(null);
|
|
6759
6929
|
return;
|
|
6760
6930
|
}
|
|
6931
|
+
if (e.key === "Escape" && selectedElRef.current && !activeElRef.current) {
|
|
6932
|
+
deselectRef.current();
|
|
6933
|
+
return;
|
|
6934
|
+
}
|
|
6761
6935
|
if (e.key !== "Escape") return;
|
|
6762
6936
|
const el = activeElRef.current;
|
|
6763
6937
|
if (el && originalContentRef.current !== null) {
|
|
@@ -6767,13 +6941,16 @@ function OhhwellsBridge() {
|
|
|
6767
6941
|
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: originalContentRef.current }] });
|
|
6768
6942
|
}
|
|
6769
6943
|
}
|
|
6944
|
+
deselectRef.current();
|
|
6770
6945
|
deactivateRef.current();
|
|
6771
6946
|
};
|
|
6772
6947
|
const handleScroll = () => {
|
|
6773
|
-
|
|
6774
|
-
|
|
6948
|
+
const focusEl = activeElRef.current ?? selectedElRef.current;
|
|
6949
|
+
if (focusEl) {
|
|
6950
|
+
const r2 = focusEl.getBoundingClientRect();
|
|
6775
6951
|
applyToolbarPos(r2);
|
|
6776
|
-
|
|
6952
|
+
setToolbarRect(r2);
|
|
6953
|
+
setMaxBadge((prev) => prev && activeElRef.current ? { ...prev, rect: r2 } : prev);
|
|
6777
6954
|
}
|
|
6778
6955
|
if (activeStateElRef.current) {
|
|
6779
6956
|
const rect = activeStateElRef.current.getBoundingClientRect();
|
|
@@ -6898,8 +7075,9 @@ function OhhwellsBridge() {
|
|
|
6898
7075
|
};
|
|
6899
7076
|
const applyToolbarPos = (rect) => {
|
|
6900
7077
|
const ps = parentScrollRef.current;
|
|
7078
|
+
const approxW = toolbarVariantRef.current === "link-action" ? 120 : 330;
|
|
6901
7079
|
if (toolbarElRef.current) {
|
|
6902
|
-
const { top, left, transform } = calcToolbarPos(rect, ps);
|
|
7080
|
+
const { top, left, transform } = calcToolbarPos(rect, ps, approxW);
|
|
6903
7081
|
toolbarElRef.current.style.top = `${top}px`;
|
|
6904
7082
|
toolbarElRef.current.style.left = `${left}px`;
|
|
6905
7083
|
toolbarElRef.current.style.transform = transform;
|
|
@@ -6914,7 +7092,8 @@ function OhhwellsBridge() {
|
|
|
6914
7092
|
if (e.data?.type !== "ow:parent-scroll") return;
|
|
6915
7093
|
const { iframeOffsetTop, headerH, canvasH } = e.data;
|
|
6916
7094
|
parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
|
|
6917
|
-
|
|
7095
|
+
const focusEl = activeElRef.current ?? selectedElRef.current;
|
|
7096
|
+
if (focusEl) applyToolbarPos(focusEl.getBoundingClientRect());
|
|
6918
7097
|
};
|
|
6919
7098
|
const handleClickAt = (e) => {
|
|
6920
7099
|
if (e.data?.type !== "ow:click-at") return;
|
|
@@ -7092,6 +7271,18 @@ function OhhwellsBridge() {
|
|
|
7092
7271
|
rect: hrefCtx.anchor.getBoundingClientRect()
|
|
7093
7272
|
});
|
|
7094
7273
|
}, []);
|
|
7274
|
+
const openLinkPopoverForSelected = useCallback2(() => {
|
|
7275
|
+
const anchor = selectedElRef.current;
|
|
7276
|
+
if (!anchor) return;
|
|
7277
|
+
const key = anchor.getAttribute("data-ohw-href-key");
|
|
7278
|
+
if (!key) return;
|
|
7279
|
+
bumpLinkPopoverGrace();
|
|
7280
|
+
setLinkPopover({
|
|
7281
|
+
key,
|
|
7282
|
+
target: getLinkHref(anchor),
|
|
7283
|
+
rect: anchor.getBoundingClientRect()
|
|
7284
|
+
});
|
|
7285
|
+
}, []);
|
|
7095
7286
|
const handleLinkPopoverSubmit = useCallback2(
|
|
7096
7287
|
(target) => {
|
|
7097
7288
|
if (!linkPopover) return;
|
|
@@ -7109,9 +7300,10 @@ function OhhwellsBridge() {
|
|
|
7109
7300
|
/* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
7110
7301
|
toolbarRect && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
7111
7302
|
/* @__PURE__ */ jsx16(GlowFrame, { rect: toolbarRect, elRef: glowElRef }),
|
|
7112
|
-
/* @__PURE__ */ jsx16(
|
|
7303
|
+
toolbarVariant === "rich-text" && /* @__PURE__ */ jsx16(
|
|
7113
7304
|
FloatingToolbar,
|
|
7114
7305
|
{
|
|
7306
|
+
variant: "rich-text",
|
|
7115
7307
|
rect: toolbarRect,
|
|
7116
7308
|
parentScroll: parentScrollRef.current,
|
|
7117
7309
|
elRef: toolbarElRef,
|
|
@@ -7120,6 +7312,18 @@ function OhhwellsBridge() {
|
|
|
7120
7312
|
showEditLink,
|
|
7121
7313
|
onEditLink: openLinkPopoverForActive
|
|
7122
7314
|
}
|
|
7315
|
+
),
|
|
7316
|
+
toolbarVariant === "link-action" && /* @__PURE__ */ jsx16(
|
|
7317
|
+
FloatingToolbar,
|
|
7318
|
+
{
|
|
7319
|
+
variant: "link-action",
|
|
7320
|
+
rect: toolbarRect,
|
|
7321
|
+
parentScroll: parentScrollRef.current,
|
|
7322
|
+
elRef: toolbarElRef,
|
|
7323
|
+
onCommand: handleCommand,
|
|
7324
|
+
activeCommands,
|
|
7325
|
+
onEditLink: openLinkPopoverForSelected
|
|
7326
|
+
}
|
|
7123
7327
|
)
|
|
7124
7328
|
] }),
|
|
7125
7329
|
maxBadge && /* @__PURE__ */ jsxs8(
|
|
@@ -7157,6 +7361,31 @@ function OhhwellsBridge() {
|
|
|
7157
7361
|
onStateChange: handleStateChange
|
|
7158
7362
|
}
|
|
7159
7363
|
),
|
|
7364
|
+
sectionGap && /* @__PURE__ */ jsxs8(
|
|
7365
|
+
"div",
|
|
7366
|
+
{
|
|
7367
|
+
"data-ohw-section-insert-line": "",
|
|
7368
|
+
className: "fixed left-0 w-full z-2147483646 flex items-center pointer-events-none",
|
|
7369
|
+
style: { top: sectionGap.y, transform: "translateY(-50%)" },
|
|
7370
|
+
children: [
|
|
7371
|
+
/* @__PURE__ */ jsx16("div", { className: "flex-1 bg-primary", style: { height: 3 } }),
|
|
7372
|
+
/* @__PURE__ */ jsx16(
|
|
7373
|
+
Badge,
|
|
7374
|
+
{
|
|
7375
|
+
className: "px-8 py-1 bg-primary hover:bg-primary text-primary-foreground text-xs font-medium shrink-0 rounded-full cursor-pointer pointer-events-auto",
|
|
7376
|
+
onClick: () => {
|
|
7377
|
+
window.parent.postMessage(
|
|
7378
|
+
{ type: "ow:add-section", insertAfter: sectionGap.insertAfter, insertBefore: sectionGap.insertBefore },
|
|
7379
|
+
"*"
|
|
7380
|
+
);
|
|
7381
|
+
},
|
|
7382
|
+
children: "Add Section"
|
|
7383
|
+
}
|
|
7384
|
+
),
|
|
7385
|
+
/* @__PURE__ */ jsx16("div", { className: "flex-1 bg-primary", style: { height: 3 } })
|
|
7386
|
+
]
|
|
7387
|
+
}
|
|
7388
|
+
),
|
|
7160
7389
|
linkPopover ? /* @__PURE__ */ jsx16(
|
|
7161
7390
|
LinkPopover,
|
|
7162
7391
|
{
|