@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.cjs
CHANGED
|
@@ -5466,6 +5466,15 @@ function getHrefKeyFromElement(el) {
|
|
|
5466
5466
|
if (!key) return null;
|
|
5467
5467
|
return { anchor, key };
|
|
5468
5468
|
}
|
|
5469
|
+
function isNavbarButton(el) {
|
|
5470
|
+
return Boolean(el.closest('[data-ohw-role="navbar-button"]'));
|
|
5471
|
+
}
|
|
5472
|
+
function clearHrefKeyHover(anchor) {
|
|
5473
|
+
anchor.removeAttribute("data-ohw-hovered");
|
|
5474
|
+
anchor.querySelectorAll("[data-ohw-hovered]").forEach((el) => {
|
|
5475
|
+
el.removeAttribute("data-ohw-hovered");
|
|
5476
|
+
});
|
|
5477
|
+
}
|
|
5469
5478
|
function collectSections() {
|
|
5470
5479
|
return collectSectionsFromDom();
|
|
5471
5480
|
}
|
|
@@ -5627,19 +5636,24 @@ function GlowFrame({ rect, elRef }) {
|
|
|
5627
5636
|
}
|
|
5628
5637
|
);
|
|
5629
5638
|
}
|
|
5630
|
-
function calcToolbarPos(rect, parentScroll) {
|
|
5639
|
+
function calcToolbarPos(rect, parentScroll, approxW = 330) {
|
|
5631
5640
|
const GAP = 8;
|
|
5632
5641
|
const APPROX_H = 36;
|
|
5633
|
-
const APPROX_W =
|
|
5642
|
+
const APPROX_W = approxW;
|
|
5634
5643
|
const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
|
|
5635
5644
|
const visibleTop = rect.top - canvasTopInIframe;
|
|
5636
5645
|
const visibleBottom = rect.bottom - canvasTopInIframe;
|
|
5637
5646
|
const isTall = rect.height > APPROX_H + GAP;
|
|
5647
|
+
const spaceAbove = rect.top - (canvasTopInIframe + GAP);
|
|
5648
|
+
const fitsAbove = spaceAbove >= APPROX_H + GAP;
|
|
5638
5649
|
let top;
|
|
5639
5650
|
let transform;
|
|
5640
|
-
if (visibleTop > 0 || !isTall) {
|
|
5651
|
+
if ((visibleTop > 0 || !isTall) && fitsAbove) {
|
|
5641
5652
|
top = rect.top - GAP;
|
|
5642
5653
|
transform = "translateX(-50%) translateY(-100%)";
|
|
5654
|
+
} else if (visibleTop > 0 || !isTall) {
|
|
5655
|
+
top = rect.bottom + GAP;
|
|
5656
|
+
transform = "translateX(-50%)";
|
|
5643
5657
|
} else if (visibleBottom > APPROX_H + GAP) {
|
|
5644
5658
|
top = canvasTopInIframe + GAP;
|
|
5645
5659
|
transform = "translateX(-50%)";
|
|
@@ -5651,16 +5665,114 @@ function calcToolbarPos(rect, parentScroll) {
|
|
|
5651
5665
|
const left = Math.max(GAP + APPROX_W / 2, Math.min(rawLeft, window.innerWidth - GAP - APPROX_W / 2));
|
|
5652
5666
|
return { top, left, transform };
|
|
5653
5667
|
}
|
|
5668
|
+
var EDIT_LINK_ICON = /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("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: [
|
|
5669
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
5670
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
5671
|
+
] });
|
|
5654
5672
|
function FloatingToolbar({
|
|
5655
5673
|
rect,
|
|
5656
5674
|
parentScroll,
|
|
5657
5675
|
elRef,
|
|
5676
|
+
variant = "rich-text",
|
|
5658
5677
|
onCommand,
|
|
5659
5678
|
activeCommands,
|
|
5660
5679
|
showEditLink,
|
|
5661
5680
|
onEditLink
|
|
5662
5681
|
}) {
|
|
5663
|
-
const
|
|
5682
|
+
const approxW = variant === "link-action" ? 120 : 330;
|
|
5683
|
+
const { top, left, transform } = calcToolbarPos(rect, parentScroll, approxW);
|
|
5684
|
+
if (variant === "link-action") {
|
|
5685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
5686
|
+
"div",
|
|
5687
|
+
{
|
|
5688
|
+
ref: elRef,
|
|
5689
|
+
"data-ohw-toolbar": "",
|
|
5690
|
+
style: {
|
|
5691
|
+
position: "fixed",
|
|
5692
|
+
top,
|
|
5693
|
+
left,
|
|
5694
|
+
transform,
|
|
5695
|
+
zIndex: 2147483647,
|
|
5696
|
+
background: "#fff",
|
|
5697
|
+
border: "1px solid #E7E5E4",
|
|
5698
|
+
borderRadius: 6,
|
|
5699
|
+
boxShadow: "0px 2px 4px -2px rgba(0,0,0,.1),0px 4px 6px -1px rgba(0,0,0,.1)",
|
|
5700
|
+
display: "flex",
|
|
5701
|
+
alignItems: "center",
|
|
5702
|
+
padding: 4,
|
|
5703
|
+
gap: 6,
|
|
5704
|
+
fontFamily: "sans-serif",
|
|
5705
|
+
pointerEvents: "auto",
|
|
5706
|
+
whiteSpace: "nowrap"
|
|
5707
|
+
},
|
|
5708
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
5709
|
+
children: [
|
|
5710
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5711
|
+
"button",
|
|
5712
|
+
{
|
|
5713
|
+
type: "button",
|
|
5714
|
+
title: "Edit link",
|
|
5715
|
+
onMouseDown: (e) => {
|
|
5716
|
+
e.preventDefault();
|
|
5717
|
+
e.stopPropagation();
|
|
5718
|
+
onEditLink?.();
|
|
5719
|
+
},
|
|
5720
|
+
onClick: (e) => {
|
|
5721
|
+
e.preventDefault();
|
|
5722
|
+
e.stopPropagation();
|
|
5723
|
+
},
|
|
5724
|
+
onMouseEnter: (e) => {
|
|
5725
|
+
e.currentTarget.style.background = "#F5F5F4";
|
|
5726
|
+
},
|
|
5727
|
+
onMouseLeave: (e) => {
|
|
5728
|
+
e.currentTarget.style.background = "transparent";
|
|
5729
|
+
},
|
|
5730
|
+
style: {
|
|
5731
|
+
display: "flex",
|
|
5732
|
+
alignItems: "center",
|
|
5733
|
+
justifyContent: "center",
|
|
5734
|
+
border: "none",
|
|
5735
|
+
background: "transparent",
|
|
5736
|
+
borderRadius: 4,
|
|
5737
|
+
cursor: "pointer",
|
|
5738
|
+
color: "#1C1917",
|
|
5739
|
+
flexShrink: 0,
|
|
5740
|
+
padding: 6
|
|
5741
|
+
},
|
|
5742
|
+
children: EDIT_LINK_ICON
|
|
5743
|
+
}
|
|
5744
|
+
),
|
|
5745
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: { display: "block", width: 1, height: 24, background: "#E7E5E4", flexShrink: 0 } }),
|
|
5746
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5747
|
+
"button",
|
|
5748
|
+
{
|
|
5749
|
+
type: "button",
|
|
5750
|
+
title: "Coming soon",
|
|
5751
|
+
disabled: true,
|
|
5752
|
+
style: {
|
|
5753
|
+
display: "flex",
|
|
5754
|
+
alignItems: "center",
|
|
5755
|
+
justifyContent: "center",
|
|
5756
|
+
border: "none",
|
|
5757
|
+
background: "transparent",
|
|
5758
|
+
borderRadius: 4,
|
|
5759
|
+
cursor: "not-allowed",
|
|
5760
|
+
color: "#A8A29E",
|
|
5761
|
+
flexShrink: 0,
|
|
5762
|
+
padding: 6,
|
|
5763
|
+
opacity: 0.6
|
|
5764
|
+
},
|
|
5765
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: [
|
|
5766
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("circle", { cx: "5", cy: "12", r: "1.5" }),
|
|
5767
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("circle", { cx: "12", cy: "12", r: "1.5" }),
|
|
5768
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("circle", { cx: "19", cy: "12", r: "1.5" })
|
|
5769
|
+
] })
|
|
5770
|
+
}
|
|
5771
|
+
)
|
|
5772
|
+
]
|
|
5773
|
+
}
|
|
5774
|
+
);
|
|
5775
|
+
}
|
|
5664
5776
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
5665
5777
|
"div",
|
|
5666
5778
|
{
|
|
@@ -5768,10 +5880,7 @@ function FloatingToolbar({
|
|
|
5768
5880
|
flexShrink: 0,
|
|
5769
5881
|
padding: 6
|
|
5770
5882
|
},
|
|
5771
|
-
children:
|
|
5772
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
5773
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
5774
|
-
] })
|
|
5883
|
+
children: EDIT_LINK_ICON
|
|
5775
5884
|
}
|
|
5776
5885
|
) : null
|
|
5777
5886
|
]
|
|
@@ -5862,6 +5971,7 @@ function OhhwellsBridge() {
|
|
|
5862
5971
|
const [fetchState, setFetchState] = (0, import_react5.useState)("idle");
|
|
5863
5972
|
const autoSaveTimers = (0, import_react5.useRef)(/* @__PURE__ */ new Map());
|
|
5864
5973
|
const activeElRef = (0, import_react5.useRef)(null);
|
|
5974
|
+
const selectedElRef = (0, import_react5.useRef)(null);
|
|
5865
5975
|
const originalContentRef = (0, import_react5.useRef)(null);
|
|
5866
5976
|
const activeStateElRef = (0, import_react5.useRef)(null);
|
|
5867
5977
|
const parentScrollRef = (0, import_react5.useRef)(null);
|
|
@@ -5877,6 +5987,10 @@ function OhhwellsBridge() {
|
|
|
5877
5987
|
});
|
|
5878
5988
|
const deactivateRef = (0, import_react5.useRef)(() => {
|
|
5879
5989
|
});
|
|
5990
|
+
const selectRef = (0, import_react5.useRef)(() => {
|
|
5991
|
+
});
|
|
5992
|
+
const deselectRef = (0, import_react5.useRef)(() => {
|
|
5993
|
+
});
|
|
5880
5994
|
const refreshActiveCommandsRef = (0, import_react5.useRef)(() => {
|
|
5881
5995
|
});
|
|
5882
5996
|
const postToParentRef = (0, import_react5.useRef)(postToParent);
|
|
@@ -5884,9 +5998,13 @@ function OhhwellsBridge() {
|
|
|
5884
5998
|
const sectionsLoadedRef = (0, import_react5.useRef)(false);
|
|
5885
5999
|
const pendingScheduleConfigRequests = (0, import_react5.useRef)([]);
|
|
5886
6000
|
const [toolbarRect, setToolbarRect] = (0, import_react5.useState)(null);
|
|
6001
|
+
const [toolbarVariant, setToolbarVariant] = (0, import_react5.useState)("none");
|
|
6002
|
+
const toolbarVariantRef = (0, import_react5.useRef)("none");
|
|
6003
|
+
toolbarVariantRef.current = toolbarVariant;
|
|
5887
6004
|
const [toggleState, setToggleState] = (0, import_react5.useState)(null);
|
|
5888
6005
|
const [maxBadge, setMaxBadge] = (0, import_react5.useState)(null);
|
|
5889
6006
|
const [activeCommands, setActiveCommands] = (0, import_react5.useState)(/* @__PURE__ */ new Set());
|
|
6007
|
+
const [sectionGap, setSectionGap] = (0, import_react5.useState)(null);
|
|
5890
6008
|
const [toolbarShowEditLink, setToolbarShowEditLink] = (0, import_react5.useState)(false);
|
|
5891
6009
|
const [linkPopover, setLinkPopover] = (0, import_react5.useState)(null);
|
|
5892
6010
|
const [sitePages, setSitePages] = (0, import_react5.useState)([]);
|
|
@@ -5953,7 +6071,6 @@ function OhhwellsBridge() {
|
|
|
5953
6071
|
if (!useFixtures) postToParent({ type: "ow:request-site-pages" });
|
|
5954
6072
|
return () => window.removeEventListener("message", onSitePages);
|
|
5955
6073
|
}, [isEditMode, postToParent]);
|
|
5956
|
-
const [sectionGap, setSectionGap] = (0, import_react5.useState)(null);
|
|
5957
6074
|
(0, import_react5.useEffect)(() => {
|
|
5958
6075
|
if (!isEditMode || shouldUseDevFixtures()) return;
|
|
5959
6076
|
void loadAllSectionsManifest().then((manifest) => {
|
|
@@ -5963,7 +6080,7 @@ function OhhwellsBridge() {
|
|
|
5963
6080
|
}, [isEditMode]);
|
|
5964
6081
|
(0, import_react5.useEffect)(() => {
|
|
5965
6082
|
const update = () => {
|
|
5966
|
-
const el = activeElRef.current;
|
|
6083
|
+
const el = activeElRef.current ?? selectedElRef.current;
|
|
5967
6084
|
if (el) setToolbarRect(el.getBoundingClientRect());
|
|
5968
6085
|
setToggleState((prev) => {
|
|
5969
6086
|
if (!prev || !activeStateElRef.current) return prev;
|
|
@@ -6031,19 +6148,41 @@ function OhhwellsBridge() {
|
|
|
6031
6148
|
}
|
|
6032
6149
|
el.removeAttribute("contenteditable");
|
|
6033
6150
|
activeElRef.current = null;
|
|
6034
|
-
|
|
6151
|
+
if (!selectedElRef.current) {
|
|
6152
|
+
setToolbarRect(null);
|
|
6153
|
+
setToolbarVariant("none");
|
|
6154
|
+
}
|
|
6035
6155
|
setMaxBadge(null);
|
|
6036
6156
|
setActiveCommands(/* @__PURE__ */ new Set());
|
|
6037
6157
|
setToolbarShowEditLink(false);
|
|
6038
6158
|
postToParent({ type: "ow:exit-edit" });
|
|
6039
6159
|
}, [postToParent]);
|
|
6160
|
+
const deselect = (0, import_react5.useCallback)(() => {
|
|
6161
|
+
selectedElRef.current = null;
|
|
6162
|
+
if (!activeElRef.current) {
|
|
6163
|
+
setToolbarRect(null);
|
|
6164
|
+
setToolbarVariant("none");
|
|
6165
|
+
}
|
|
6166
|
+
}, []);
|
|
6167
|
+
const select = (0, import_react5.useCallback)((anchor) => {
|
|
6168
|
+
if (!isNavbarButton(anchor)) return;
|
|
6169
|
+
if (activeElRef.current) deactivate();
|
|
6170
|
+
selectedElRef.current = anchor;
|
|
6171
|
+
clearHrefKeyHover(anchor);
|
|
6172
|
+
setToolbarVariant("link-action");
|
|
6173
|
+
setToolbarRect(anchor.getBoundingClientRect());
|
|
6174
|
+
setToolbarShowEditLink(false);
|
|
6175
|
+
setActiveCommands(/* @__PURE__ */ new Set());
|
|
6176
|
+
}, [deactivate]);
|
|
6040
6177
|
const activate = (0, import_react5.useCallback)((el) => {
|
|
6041
6178
|
if (activeElRef.current === el) return;
|
|
6179
|
+
selectedElRef.current = null;
|
|
6042
6180
|
deactivate();
|
|
6043
6181
|
if (hoveredImageRef.current) {
|
|
6044
6182
|
hoveredImageRef.current = null;
|
|
6045
6183
|
postToParentRef.current({ type: "ow:image-unhover" });
|
|
6046
6184
|
}
|
|
6185
|
+
setToolbarVariant("rich-text");
|
|
6047
6186
|
el.setAttribute("contenteditable", "true");
|
|
6048
6187
|
el.removeAttribute("data-ohw-hovered");
|
|
6049
6188
|
activeElRef.current = el;
|
|
@@ -6056,6 +6195,8 @@ function OhhwellsBridge() {
|
|
|
6056
6195
|
}, [deactivate, postToParent]);
|
|
6057
6196
|
activateRef.current = activate;
|
|
6058
6197
|
deactivateRef.current = deactivate;
|
|
6198
|
+
selectRef.current = select;
|
|
6199
|
+
deselectRef.current = deselect;
|
|
6059
6200
|
(0, import_react5.useLayoutEffect)(() => {
|
|
6060
6201
|
if (!subdomain || isEditMode) {
|
|
6061
6202
|
setFetchState("done");
|
|
@@ -6269,6 +6410,7 @@ function OhhwellsBridge() {
|
|
|
6269
6410
|
if (editable.dataset.ohwEditable === "link") {
|
|
6270
6411
|
e.preventDefault();
|
|
6271
6412
|
e.stopPropagation();
|
|
6413
|
+
deselectRef.current();
|
|
6272
6414
|
deactivateRef.current();
|
|
6273
6415
|
bumpLinkPopoverGrace();
|
|
6274
6416
|
setLinkPopoverRef.current({
|
|
@@ -6284,11 +6426,31 @@ function OhhwellsBridge() {
|
|
|
6284
6426
|
postToParentRef.current({ type: "ow:image-pick", key: editable.dataset.ohwKey ?? "" });
|
|
6285
6427
|
return;
|
|
6286
6428
|
}
|
|
6429
|
+
const hrefCtx = getHrefKeyFromElement(editable);
|
|
6430
|
+
if (hrefCtx && isNavbarButton(hrefCtx.anchor)) {
|
|
6431
|
+
e.preventDefault();
|
|
6432
|
+
e.stopPropagation();
|
|
6433
|
+
const { anchor: anchor2 } = hrefCtx;
|
|
6434
|
+
if (selectedElRef.current === anchor2) {
|
|
6435
|
+
activateRef.current(editable);
|
|
6436
|
+
return;
|
|
6437
|
+
}
|
|
6438
|
+
selectRef.current(anchor2);
|
|
6439
|
+
return;
|
|
6440
|
+
}
|
|
6287
6441
|
e.preventDefault();
|
|
6288
6442
|
e.stopPropagation();
|
|
6289
6443
|
activateRef.current(editable);
|
|
6290
6444
|
return;
|
|
6291
6445
|
}
|
|
6446
|
+
const hrefAnchor = target.closest("[data-ohw-href-key]");
|
|
6447
|
+
if (hrefAnchor && isNavbarButton(hrefAnchor)) {
|
|
6448
|
+
e.preventDefault();
|
|
6449
|
+
e.stopPropagation();
|
|
6450
|
+
if (selectedElRef.current === hrefAnchor) return;
|
|
6451
|
+
selectRef.current(hrefAnchor);
|
|
6452
|
+
return;
|
|
6453
|
+
}
|
|
6292
6454
|
if (activeElRef.current) {
|
|
6293
6455
|
const sel = window.getSelection();
|
|
6294
6456
|
if (sel && !sel.isCollapsed) {
|
|
@@ -6303,15 +6465,22 @@ function OhhwellsBridge() {
|
|
|
6303
6465
|
const hrefCtx = getHrefKeyFromElement(activeElRef.current);
|
|
6304
6466
|
if (hrefCtx && (hrefCtx.anchor === target || hrefCtx.anchor.contains(target))) return;
|
|
6305
6467
|
}
|
|
6468
|
+
if (linkPopoverOpenRef.current && selectedElRef.current) {
|
|
6469
|
+
const selected = selectedElRef.current;
|
|
6470
|
+
if (selected === target || selected.contains(target)) return;
|
|
6471
|
+
}
|
|
6306
6472
|
if (linkPopoverOpenRef.current) {
|
|
6307
6473
|
setLinkPopoverRef.current(null);
|
|
6308
6474
|
return;
|
|
6309
6475
|
}
|
|
6476
|
+
deselectRef.current();
|
|
6310
6477
|
deactivateRef.current();
|
|
6311
6478
|
};
|
|
6312
6479
|
const handleMouseOver = (e) => {
|
|
6313
6480
|
const editable = e.target.closest("[data-ohw-editable]");
|
|
6314
6481
|
if (!editable) return;
|
|
6482
|
+
const selected = selectedElRef.current;
|
|
6483
|
+
if (selected && (selected === editable || selected.contains(editable))) return;
|
|
6315
6484
|
if (editable.dataset.ohwEditable !== "image" && editable.dataset.ohwEditable !== "bg-image" && !editable.hasAttribute("contenteditable")) {
|
|
6316
6485
|
editable.setAttribute("data-ohw-hovered", "");
|
|
6317
6486
|
}
|
|
@@ -6798,6 +6967,7 @@ function OhhwellsBridge() {
|
|
|
6798
6967
|
setLinkPopoverRef.current(null);
|
|
6799
6968
|
return;
|
|
6800
6969
|
}
|
|
6970
|
+
deselectRef.current();
|
|
6801
6971
|
deactivateRef.current();
|
|
6802
6972
|
};
|
|
6803
6973
|
window.addEventListener("message", handleDeactivate);
|
|
@@ -6806,6 +6976,10 @@ function OhhwellsBridge() {
|
|
|
6806
6976
|
setLinkPopoverRef.current(null);
|
|
6807
6977
|
return;
|
|
6808
6978
|
}
|
|
6979
|
+
if (e.key === "Escape" && selectedElRef.current && !activeElRef.current) {
|
|
6980
|
+
deselectRef.current();
|
|
6981
|
+
return;
|
|
6982
|
+
}
|
|
6809
6983
|
if (e.key !== "Escape") return;
|
|
6810
6984
|
const el = activeElRef.current;
|
|
6811
6985
|
if (el && originalContentRef.current !== null) {
|
|
@@ -6815,13 +6989,16 @@ function OhhwellsBridge() {
|
|
|
6815
6989
|
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: originalContentRef.current }] });
|
|
6816
6990
|
}
|
|
6817
6991
|
}
|
|
6992
|
+
deselectRef.current();
|
|
6818
6993
|
deactivateRef.current();
|
|
6819
6994
|
};
|
|
6820
6995
|
const handleScroll = () => {
|
|
6821
|
-
|
|
6822
|
-
|
|
6996
|
+
const focusEl = activeElRef.current ?? selectedElRef.current;
|
|
6997
|
+
if (focusEl) {
|
|
6998
|
+
const r2 = focusEl.getBoundingClientRect();
|
|
6823
6999
|
applyToolbarPos(r2);
|
|
6824
|
-
|
|
7000
|
+
setToolbarRect(r2);
|
|
7001
|
+
setMaxBadge((prev) => prev && activeElRef.current ? { ...prev, rect: r2 } : prev);
|
|
6825
7002
|
}
|
|
6826
7003
|
if (activeStateElRef.current) {
|
|
6827
7004
|
const rect = activeStateElRef.current.getBoundingClientRect();
|
|
@@ -6946,8 +7123,9 @@ function OhhwellsBridge() {
|
|
|
6946
7123
|
};
|
|
6947
7124
|
const applyToolbarPos = (rect) => {
|
|
6948
7125
|
const ps = parentScrollRef.current;
|
|
7126
|
+
const approxW = toolbarVariantRef.current === "link-action" ? 120 : 330;
|
|
6949
7127
|
if (toolbarElRef.current) {
|
|
6950
|
-
const { top, left, transform } = calcToolbarPos(rect, ps);
|
|
7128
|
+
const { top, left, transform } = calcToolbarPos(rect, ps, approxW);
|
|
6951
7129
|
toolbarElRef.current.style.top = `${top}px`;
|
|
6952
7130
|
toolbarElRef.current.style.left = `${left}px`;
|
|
6953
7131
|
toolbarElRef.current.style.transform = transform;
|
|
@@ -6962,7 +7140,8 @@ function OhhwellsBridge() {
|
|
|
6962
7140
|
if (e.data?.type !== "ow:parent-scroll") return;
|
|
6963
7141
|
const { iframeOffsetTop, headerH, canvasH } = e.data;
|
|
6964
7142
|
parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
|
|
6965
|
-
|
|
7143
|
+
const focusEl = activeElRef.current ?? selectedElRef.current;
|
|
7144
|
+
if (focusEl) applyToolbarPos(focusEl.getBoundingClientRect());
|
|
6966
7145
|
};
|
|
6967
7146
|
const handleClickAt = (e) => {
|
|
6968
7147
|
if (e.data?.type !== "ow:click-at") return;
|
|
@@ -7140,6 +7319,18 @@ function OhhwellsBridge() {
|
|
|
7140
7319
|
rect: hrefCtx.anchor.getBoundingClientRect()
|
|
7141
7320
|
});
|
|
7142
7321
|
}, []);
|
|
7322
|
+
const openLinkPopoverForSelected = (0, import_react5.useCallback)(() => {
|
|
7323
|
+
const anchor = selectedElRef.current;
|
|
7324
|
+
if (!anchor) return;
|
|
7325
|
+
const key = anchor.getAttribute("data-ohw-href-key");
|
|
7326
|
+
if (!key) return;
|
|
7327
|
+
bumpLinkPopoverGrace();
|
|
7328
|
+
setLinkPopover({
|
|
7329
|
+
key,
|
|
7330
|
+
target: getLinkHref(anchor),
|
|
7331
|
+
rect: anchor.getBoundingClientRect()
|
|
7332
|
+
});
|
|
7333
|
+
}, []);
|
|
7143
7334
|
const handleLinkPopoverSubmit = (0, import_react5.useCallback)(
|
|
7144
7335
|
(target) => {
|
|
7145
7336
|
if (!linkPopover) return;
|
|
@@ -7157,9 +7348,10 @@ function OhhwellsBridge() {
|
|
|
7157
7348
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
7158
7349
|
toolbarRect && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
7159
7350
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GlowFrame, { rect: toolbarRect, elRef: glowElRef }),
|
|
7160
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7351
|
+
toolbarVariant === "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7161
7352
|
FloatingToolbar,
|
|
7162
7353
|
{
|
|
7354
|
+
variant: "rich-text",
|
|
7163
7355
|
rect: toolbarRect,
|
|
7164
7356
|
parentScroll: parentScrollRef.current,
|
|
7165
7357
|
elRef: toolbarElRef,
|
|
@@ -7168,6 +7360,18 @@ function OhhwellsBridge() {
|
|
|
7168
7360
|
showEditLink,
|
|
7169
7361
|
onEditLink: openLinkPopoverForActive
|
|
7170
7362
|
}
|
|
7363
|
+
),
|
|
7364
|
+
toolbarVariant === "link-action" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7365
|
+
FloatingToolbar,
|
|
7366
|
+
{
|
|
7367
|
+
variant: "link-action",
|
|
7368
|
+
rect: toolbarRect,
|
|
7369
|
+
parentScroll: parentScrollRef.current,
|
|
7370
|
+
elRef: toolbarElRef,
|
|
7371
|
+
onCommand: handleCommand,
|
|
7372
|
+
activeCommands,
|
|
7373
|
+
onEditLink: openLinkPopoverForSelected
|
|
7374
|
+
}
|
|
7171
7375
|
)
|
|
7172
7376
|
] }),
|
|
7173
7377
|
maxBadge && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
@@ -7205,6 +7409,31 @@ function OhhwellsBridge() {
|
|
|
7205
7409
|
onStateChange: handleStateChange
|
|
7206
7410
|
}
|
|
7207
7411
|
),
|
|
7412
|
+
sectionGap && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
7413
|
+
"div",
|
|
7414
|
+
{
|
|
7415
|
+
"data-ohw-section-insert-line": "",
|
|
7416
|
+
className: "fixed left-0 w-full z-2147483646 flex items-center pointer-events-none",
|
|
7417
|
+
style: { top: sectionGap.y, transform: "translateY(-50%)" },
|
|
7418
|
+
children: [
|
|
7419
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex-1 bg-primary", style: { height: 3 } }),
|
|
7420
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7421
|
+
Badge,
|
|
7422
|
+
{
|
|
7423
|
+
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",
|
|
7424
|
+
onClick: () => {
|
|
7425
|
+
window.parent.postMessage(
|
|
7426
|
+
{ type: "ow:add-section", insertAfter: sectionGap.insertAfter, insertBefore: sectionGap.insertBefore },
|
|
7427
|
+
"*"
|
|
7428
|
+
);
|
|
7429
|
+
},
|
|
7430
|
+
children: "Add Section"
|
|
7431
|
+
}
|
|
7432
|
+
),
|
|
7433
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex-1 bg-primary", style: { height: 3 } })
|
|
7434
|
+
]
|
|
7435
|
+
}
|
|
7436
|
+
),
|
|
7208
7437
|
linkPopover ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
7209
7438
|
LinkPopover,
|
|
7210
7439
|
{
|