@ohhwells/bridge 0.1.30 → 0.1.31-next.29
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/README.md +2 -2
- package/dist/index.cjs +571 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -9
- package/dist/index.d.ts +4 -9
- package/dist/index.js +582 -194
- package/dist/index.js.map +1 -1
- package/dist/styles.css +53 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/OhhwellsBridge.tsx
|
|
4
|
-
import
|
|
4
|
+
import React6, { useCallback as useCallback2, useEffect as useEffect3, useLayoutEffect, useRef as useRef3, useState as useState5 } from "react";
|
|
5
5
|
import { createRoot } from "react-dom/client";
|
|
6
6
|
import { flushSync } from "react-dom";
|
|
7
7
|
|
|
@@ -4441,26 +4441,135 @@ function scrollToHashSectionWhenReady(behavior = "smooth") {
|
|
|
4441
4441
|
tick();
|
|
4442
4442
|
}
|
|
4443
4443
|
|
|
4444
|
-
// src/ui/
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
}
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
return {
|
|
4444
|
+
// src/ui/dialog.tsx
|
|
4445
|
+
import * as React3 from "react";
|
|
4446
|
+
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
4447
|
+
|
|
4448
|
+
// src/ui/icons.tsx
|
|
4449
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4450
|
+
function IconX({ className, ...props }) {
|
|
4451
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4452
|
+
/* @__PURE__ */ jsx5("path", { d: "M18 6 6 18" }),
|
|
4453
|
+
/* @__PURE__ */ jsx5("path", { d: "m6 6 12 12" })
|
|
4454
|
+
] });
|
|
4455
|
+
}
|
|
4456
|
+
function IconChevronDown({ className, ...props }) {
|
|
4457
|
+
return /* @__PURE__ */ jsx5("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: /* @__PURE__ */ jsx5("path", { d: "m6 9 6 6 6-6" }) });
|
|
4458
|
+
}
|
|
4459
|
+
function IconFile({ className, ...props }) {
|
|
4460
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4461
|
+
/* @__PURE__ */ jsx5("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
4462
|
+
/* @__PURE__ */ jsx5("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" })
|
|
4463
|
+
] });
|
|
4464
|
+
}
|
|
4465
|
+
function IconInfo({ className, ...props }) {
|
|
4466
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4467
|
+
/* @__PURE__ */ jsx5("circle", { cx: "12", cy: "12", r: "10" }),
|
|
4468
|
+
/* @__PURE__ */ jsx5("path", { d: "M12 16v-4" }),
|
|
4469
|
+
/* @__PURE__ */ jsx5("path", { d: "M12 8h.01" })
|
|
4470
|
+
] });
|
|
4471
|
+
}
|
|
4472
|
+
function IconArrowRight({ className, ...props }) {
|
|
4473
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4474
|
+
/* @__PURE__ */ jsx5("path", { d: "M5 12h14" }),
|
|
4475
|
+
/* @__PURE__ */ jsx5("path", { d: "m12 5 7 7-7 7" })
|
|
4476
|
+
] });
|
|
4477
|
+
}
|
|
4478
|
+
function IconSection({ className, ...props }) {
|
|
4479
|
+
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4480
|
+
/* @__PURE__ */ jsx5("rect", { width: "18", height: "7", x: "3", y: "3", rx: "1" }),
|
|
4481
|
+
/* @__PURE__ */ jsx5("rect", { width: "9", height: "7", x: "3", y: "14", rx: "1" }),
|
|
4482
|
+
/* @__PURE__ */ jsx5("rect", { width: "5", height: "7", x: "16", y: "14", rx: "1" })
|
|
4483
|
+
] });
|
|
4458
4484
|
}
|
|
4459
4485
|
|
|
4486
|
+
// src/ui/dialog.tsx
|
|
4487
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4488
|
+
function Dialog2({ ...props }) {
|
|
4489
|
+
return /* @__PURE__ */ jsx6(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
4490
|
+
}
|
|
4491
|
+
function DialogPortal({ ...props }) {
|
|
4492
|
+
return /* @__PURE__ */ jsx6(DialogPrimitive.Portal, { ...props });
|
|
4493
|
+
}
|
|
4494
|
+
function DialogOverlay({
|
|
4495
|
+
className,
|
|
4496
|
+
...props
|
|
4497
|
+
}) {
|
|
4498
|
+
return /* @__PURE__ */ jsx6(
|
|
4499
|
+
DialogPrimitive.Overlay,
|
|
4500
|
+
{
|
|
4501
|
+
"data-slot": "dialog-overlay",
|
|
4502
|
+
"data-ohw-link-modal-root": "",
|
|
4503
|
+
className: cn("fixed inset-0 z-[2147483646] bg-black/50", className),
|
|
4504
|
+
...props
|
|
4505
|
+
}
|
|
4506
|
+
);
|
|
4507
|
+
}
|
|
4508
|
+
var DialogContent = React3.forwardRef(({ className, children, showCloseButton = true, container, ...props }, ref) => {
|
|
4509
|
+
const positionMode = container ? "absolute" : "fixed";
|
|
4510
|
+
return /* @__PURE__ */ jsxs4(DialogPortal, { container: container ?? void 0, children: [
|
|
4511
|
+
/* @__PURE__ */ jsx6(DialogOverlay, { className: cn(positionMode, "inset-0") }),
|
|
4512
|
+
/* @__PURE__ */ jsxs4(
|
|
4513
|
+
DialogPrimitive.Content,
|
|
4514
|
+
{
|
|
4515
|
+
ref,
|
|
4516
|
+
"data-slot": "dialog-content",
|
|
4517
|
+
className: cn(
|
|
4518
|
+
positionMode,
|
|
4519
|
+
"left-1/2 top-1/2 z-[2147483647] flex w-full max-w-[483px] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden",
|
|
4520
|
+
"rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
|
|
4521
|
+
container ? "max-h-[calc(100%-32px)] max-w-[calc(100%-16px)]" : "max-h-[calc(100vh-32px)] max-w-[calc(100vw-16px)]",
|
|
4522
|
+
className
|
|
4523
|
+
),
|
|
4524
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
4525
|
+
...props,
|
|
4526
|
+
children: [
|
|
4527
|
+
children,
|
|
4528
|
+
showCloseButton ? /* @__PURE__ */ jsx6(
|
|
4529
|
+
DialogPrimitive.Close,
|
|
4530
|
+
{
|
|
4531
|
+
type: "button",
|
|
4532
|
+
className: "absolute right-[9px] top-[9px] rounded-sm p-1.5 text-foreground hover:bg-muted/50",
|
|
4533
|
+
"aria-label": "Close",
|
|
4534
|
+
children: /* @__PURE__ */ jsx6(IconX, { "aria-hidden": true })
|
|
4535
|
+
}
|
|
4536
|
+
) : null
|
|
4537
|
+
]
|
|
4538
|
+
}
|
|
4539
|
+
)
|
|
4540
|
+
] });
|
|
4541
|
+
});
|
|
4542
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
4543
|
+
function DialogHeader({ className, ...props }) {
|
|
4544
|
+
return /* @__PURE__ */ jsx6("div", { className: cn("flex flex-col gap-1.5", className), ...props });
|
|
4545
|
+
}
|
|
4546
|
+
function DialogFooter({ className, ...props }) {
|
|
4547
|
+
return /* @__PURE__ */ jsx6("div", { className: cn("flex items-center justify-end gap-2", className), ...props });
|
|
4548
|
+
}
|
|
4549
|
+
var DialogTitle = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
|
|
4550
|
+
DialogPrimitive.Title,
|
|
4551
|
+
{
|
|
4552
|
+
ref,
|
|
4553
|
+
className: cn("text-lg font-semibold leading-none tracking-tight text-card-foreground", className),
|
|
4554
|
+
...props
|
|
4555
|
+
}
|
|
4556
|
+
));
|
|
4557
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
4558
|
+
var DialogDescription = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
|
|
4559
|
+
DialogPrimitive.Description,
|
|
4560
|
+
{
|
|
4561
|
+
ref,
|
|
4562
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
4563
|
+
...props
|
|
4564
|
+
}
|
|
4565
|
+
));
|
|
4566
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
4567
|
+
var DialogClose = DialogPrimitive.Close;
|
|
4568
|
+
|
|
4460
4569
|
// src/ui/button.tsx
|
|
4461
|
-
import * as
|
|
4570
|
+
import * as React4 from "react";
|
|
4462
4571
|
import { Slot } from "radix-ui";
|
|
4463
|
-
import { jsx as
|
|
4572
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
4464
4573
|
var buttonVariants = cva(
|
|
4465
4574
|
"inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-md text-sm font-medium transition-colors outline-none disabled:pointer-events-none disabled:opacity-50 min-w-[80px] px-3 py-2",
|
|
4466
4575
|
{
|
|
@@ -4481,10 +4590,10 @@ var buttonVariants = cva(
|
|
|
4481
4590
|
}
|
|
4482
4591
|
}
|
|
4483
4592
|
);
|
|
4484
|
-
var Button =
|
|
4593
|
+
var Button = React4.forwardRef(
|
|
4485
4594
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
4486
4595
|
const Comp = asChild ? Slot.Root : "button";
|
|
4487
|
-
return /* @__PURE__ */
|
|
4596
|
+
return /* @__PURE__ */ jsx7(
|
|
4488
4597
|
Comp,
|
|
4489
4598
|
{
|
|
4490
4599
|
ref,
|
|
@@ -4497,76 +4606,38 @@ var Button = React3.forwardRef(
|
|
|
4497
4606
|
);
|
|
4498
4607
|
Button.displayName = "Button";
|
|
4499
4608
|
|
|
4500
|
-
// src/ui/icons.tsx
|
|
4501
|
-
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4502
|
-
function IconX({ className, ...props }) {
|
|
4503
|
-
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4504
|
-
/* @__PURE__ */ jsx6("path", { d: "M18 6 6 18" }),
|
|
4505
|
-
/* @__PURE__ */ jsx6("path", { d: "m6 6 12 12" })
|
|
4506
|
-
] });
|
|
4507
|
-
}
|
|
4508
|
-
function IconChevronDown({ className, ...props }) {
|
|
4509
|
-
return /* @__PURE__ */ jsx6("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: /* @__PURE__ */ jsx6("path", { d: "m6 9 6 6 6-6" }) });
|
|
4510
|
-
}
|
|
4511
|
-
function IconFile({ className, ...props }) {
|
|
4512
|
-
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4513
|
-
/* @__PURE__ */ jsx6("path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }),
|
|
4514
|
-
/* @__PURE__ */ jsx6("path", { d: "M14 2v4a2 2 0 0 0 2 2h4" })
|
|
4515
|
-
] });
|
|
4516
|
-
}
|
|
4517
|
-
function IconInfo({ className, ...props }) {
|
|
4518
|
-
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4519
|
-
/* @__PURE__ */ jsx6("circle", { cx: "12", cy: "12", r: "10" }),
|
|
4520
|
-
/* @__PURE__ */ jsx6("path", { d: "M12 16v-4" }),
|
|
4521
|
-
/* @__PURE__ */ jsx6("path", { d: "M12 8h.01" })
|
|
4522
|
-
] });
|
|
4523
|
-
}
|
|
4524
|
-
function IconArrowRight({ className, ...props }) {
|
|
4525
|
-
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4526
|
-
/* @__PURE__ */ jsx6("path", { d: "M5 12h14" }),
|
|
4527
|
-
/* @__PURE__ */ jsx6("path", { d: "m12 5 7 7-7 7" })
|
|
4528
|
-
] });
|
|
4529
|
-
}
|
|
4530
|
-
function IconSection({ className, ...props }) {
|
|
4531
|
-
return /* @__PURE__ */ jsxs3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className, ...props, children: [
|
|
4532
|
-
/* @__PURE__ */ jsx6("rect", { width: "18", height: "7", x: "3", y: "3", rx: "1" }),
|
|
4533
|
-
/* @__PURE__ */ jsx6("rect", { width: "9", height: "7", x: "3", y: "14", rx: "1" }),
|
|
4534
|
-
/* @__PURE__ */ jsx6("rect", { width: "5", height: "7", x: "16", y: "14", rx: "1" })
|
|
4535
|
-
] });
|
|
4536
|
-
}
|
|
4537
|
-
|
|
4538
4609
|
// src/ui/link-modal/DestinationBreadcrumb.tsx
|
|
4539
|
-
import { jsx as
|
|
4610
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4540
4611
|
function DestinationBreadcrumb({ pageTitle, sectionLabel }) {
|
|
4541
|
-
return /* @__PURE__ */
|
|
4542
|
-
/* @__PURE__ */
|
|
4543
|
-
/* @__PURE__ */
|
|
4544
|
-
/* @__PURE__ */
|
|
4545
|
-
/* @__PURE__ */
|
|
4546
|
-
/* @__PURE__ */
|
|
4612
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex w-full flex-col gap-2", children: [
|
|
4613
|
+
/* @__PURE__ */ jsx8("p", { className: "text-sm font-medium text-foreground", children: "Destination" }),
|
|
4614
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3", children: [
|
|
4615
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
4616
|
+
/* @__PURE__ */ jsx8(IconFile, { className: "shrink-0 text-foreground", "aria-hidden": true }),
|
|
4617
|
+
/* @__PURE__ */ jsx8("span", { className: "text-sm font-medium leading-none text-foreground", children: pageTitle })
|
|
4547
4618
|
] }),
|
|
4548
|
-
/* @__PURE__ */
|
|
4549
|
-
/* @__PURE__ */
|
|
4550
|
-
/* @__PURE__ */
|
|
4551
|
-
/* @__PURE__ */
|
|
4619
|
+
/* @__PURE__ */ jsx8(IconArrowRight, { className: "shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
4620
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
4621
|
+
/* @__PURE__ */ jsx8(IconSection, { className: "shrink-0 text-foreground", "aria-hidden": true }),
|
|
4622
|
+
/* @__PURE__ */ jsx8("span", { className: "truncate text-sm font-medium leading-none text-foreground", children: sectionLabel })
|
|
4552
4623
|
] })
|
|
4553
4624
|
] })
|
|
4554
4625
|
] });
|
|
4555
4626
|
}
|
|
4556
4627
|
|
|
4557
4628
|
// src/ui/link-modal/SectionTreeItem.tsx
|
|
4558
|
-
import { jsx as
|
|
4629
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
4559
4630
|
function SectionTreeItem({ section, onSelect, selected }) {
|
|
4560
4631
|
const interactive = Boolean(onSelect);
|
|
4561
|
-
return /* @__PURE__ */
|
|
4562
|
-
/* @__PURE__ */
|
|
4632
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex h-9 w-full items-end pl-3", children: [
|
|
4633
|
+
/* @__PURE__ */ jsx9(
|
|
4563
4634
|
"div",
|
|
4564
4635
|
{
|
|
4565
4636
|
className: "mr-[-1px] h-9 w-2 shrink-0 rounded-bl-sm border-b border-l border-border mb-4",
|
|
4566
4637
|
"aria-hidden": true
|
|
4567
4638
|
}
|
|
4568
4639
|
),
|
|
4569
|
-
/* @__PURE__ */
|
|
4640
|
+
/* @__PURE__ */ jsxs6(
|
|
4570
4641
|
"div",
|
|
4571
4642
|
{
|
|
4572
4643
|
role: interactive ? "button" : void 0,
|
|
@@ -4584,8 +4655,8 @@ function SectionTreeItem({ section, onSelect, selected }) {
|
|
|
4584
4655
|
interactive && selected && "border-primary"
|
|
4585
4656
|
),
|
|
4586
4657
|
children: [
|
|
4587
|
-
/* @__PURE__ */
|
|
4588
|
-
/* @__PURE__ */
|
|
4658
|
+
/* @__PURE__ */ jsx9(IconSection, { className: "shrink-0 text-foreground", "aria-hidden": true }),
|
|
4659
|
+
/* @__PURE__ */ jsx9("span", { className: "truncate text-sm font-normal leading-5 text-foreground", children: section.label })
|
|
4589
4660
|
]
|
|
4590
4661
|
}
|
|
4591
4662
|
)
|
|
@@ -4593,11 +4664,11 @@ function SectionTreeItem({ section, onSelect, selected }) {
|
|
|
4593
4664
|
}
|
|
4594
4665
|
function SectionPickerList({ sections, onSelect }) {
|
|
4595
4666
|
if (sections.length === 0) {
|
|
4596
|
-
return /* @__PURE__ */
|
|
4667
|
+
return /* @__PURE__ */ jsx9("p", { className: "text-sm text-muted-foreground", children: "No sections found on this page." });
|
|
4597
4668
|
}
|
|
4598
|
-
return /* @__PURE__ */
|
|
4599
|
-
/* @__PURE__ */
|
|
4600
|
-
sections.map((section) => /* @__PURE__ */
|
|
4669
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1", children: [
|
|
4670
|
+
/* @__PURE__ */ jsx9("p", { className: "text-sm text-muted-foreground", children: "Pick a section this link should scroll to." }),
|
|
4671
|
+
sections.map((section) => /* @__PURE__ */ jsx9(SectionTreeItem, { section, onSelect }, section.id))
|
|
4601
4672
|
] });
|
|
4602
4673
|
}
|
|
4603
4674
|
|
|
@@ -4605,11 +4676,11 @@ function SectionPickerList({ sections, onSelect }) {
|
|
|
4605
4676
|
import { useId as useId2, useRef as useRef2, useState as useState3 } from "react";
|
|
4606
4677
|
|
|
4607
4678
|
// src/ui/input.tsx
|
|
4608
|
-
import * as
|
|
4609
|
-
import { jsx as
|
|
4610
|
-
var Input =
|
|
4679
|
+
import * as React5 from "react";
|
|
4680
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
4681
|
+
var Input = React5.forwardRef(
|
|
4611
4682
|
({ className, type, ...props }, ref) => {
|
|
4612
|
-
return /* @__PURE__ */
|
|
4683
|
+
return /* @__PURE__ */ jsx10(
|
|
4613
4684
|
"input",
|
|
4614
4685
|
{
|
|
4615
4686
|
type,
|
|
@@ -4628,9 +4699,9 @@ Input.displayName = "Input";
|
|
|
4628
4699
|
|
|
4629
4700
|
// src/ui/label.tsx
|
|
4630
4701
|
import { Label as LabelPrimitive } from "radix-ui";
|
|
4631
|
-
import { jsx as
|
|
4702
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
4632
4703
|
function Label({ className, ...props }) {
|
|
4633
|
-
return /* @__PURE__ */
|
|
4704
|
+
return /* @__PURE__ */ jsx11(
|
|
4634
4705
|
LabelPrimitive.Root,
|
|
4635
4706
|
{
|
|
4636
4707
|
"data-slot": "label",
|
|
@@ -4640,38 +4711,8 @@ function Label({ className, ...props }) {
|
|
|
4640
4711
|
);
|
|
4641
4712
|
}
|
|
4642
4713
|
|
|
4643
|
-
// src/ui/popover.tsx
|
|
4644
|
-
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
4645
|
-
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
4646
|
-
function Popover({ ...props }) {
|
|
4647
|
-
return /* @__PURE__ */ jsx11(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
4648
|
-
}
|
|
4649
|
-
function PopoverTrigger({ ...props }) {
|
|
4650
|
-
return /* @__PURE__ */ jsx11(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
4651
|
-
}
|
|
4652
|
-
function PopoverContent({
|
|
4653
|
-
className,
|
|
4654
|
-
align = "start",
|
|
4655
|
-
sideOffset = 6,
|
|
4656
|
-
...props
|
|
4657
|
-
}) {
|
|
4658
|
-
return /* @__PURE__ */ jsx11(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx11(
|
|
4659
|
-
PopoverPrimitive.Content,
|
|
4660
|
-
{
|
|
4661
|
-
"data-slot": "popover-content",
|
|
4662
|
-
align,
|
|
4663
|
-
sideOffset,
|
|
4664
|
-
className: cn(
|
|
4665
|
-
"z-[2147483647] w-[var(--radix-popover-trigger-width)] overflow-auto rounded-lg border border-border bg-popover py-1 shadow-lg outline-none",
|
|
4666
|
-
className
|
|
4667
|
-
),
|
|
4668
|
-
...props
|
|
4669
|
-
}
|
|
4670
|
-
) });
|
|
4671
|
-
}
|
|
4672
|
-
|
|
4673
4714
|
// src/ui/link-modal/UrlOrPageInput.tsx
|
|
4674
|
-
import { jsx as jsx12, jsxs as
|
|
4715
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4675
4716
|
function FieldChevron({ onClick }) {
|
|
4676
4717
|
return /* @__PURE__ */ jsx12(
|
|
4677
4718
|
"button",
|
|
@@ -4720,10 +4761,10 @@ function UrlOrPageInput({
|
|
|
4720
4761
|
"data-ohw-link-field flex h-10 w-full items-center overflow-hidden rounded-md border bg-background pl-3 pr-3 py-2 outline-none transition-[border-color,box-shadow]",
|
|
4721
4762
|
urlError ? "border-destructive shadow-[0_0_0_1px_var(--ohw-destructive)]" : isFocused ? "border-primary shadow-[0_0_0_1px_var(--ohw-primary)]" : "border-input"
|
|
4722
4763
|
);
|
|
4723
|
-
return /* @__PURE__ */
|
|
4764
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex w-full flex-col gap-2 p-0", children: [
|
|
4724
4765
|
/* @__PURE__ */ jsx12(Label, { htmlFor: inputId, className: cn(urlError && "text-destructive"), children: "Destination" }),
|
|
4725
|
-
/* @__PURE__ */
|
|
4726
|
-
/* @__PURE__ */
|
|
4766
|
+
/* @__PURE__ */ jsxs7("div", { className: "relative w-full", children: [
|
|
4767
|
+
/* @__PURE__ */ jsxs7("div", { "data-ohw-link-field": true, className: fieldClassName, children: [
|
|
4727
4768
|
selectedPage ? /* @__PURE__ */ jsx12("div", { className: "flex shrink-0 items-center pr-2", children: /* @__PURE__ */ jsx12(IconFile, { className: "text-foreground", "aria-hidden": true }) }) : null,
|
|
4728
4769
|
readOnly ? /* @__PURE__ */ jsx12("span", { className: "min-w-0 flex-1 truncate text-sm leading-5 text-foreground", children: selectedPage?.title ?? value }) : /* @__PURE__ */ jsx12(
|
|
4729
4770
|
Input,
|
|
@@ -4756,20 +4797,28 @@ function UrlOrPageInput({
|
|
|
4756
4797
|
}
|
|
4757
4798
|
) : null,
|
|
4758
4799
|
!readOnly ? /* @__PURE__ */ jsx12(FieldChevron, { onClick: toggleDropdown }) : null
|
|
4759
|
-
] })
|
|
4760
|
-
filteredPages.length > 0
|
|
4761
|
-
"
|
|
4800
|
+
] }),
|
|
4801
|
+
dropdownOpen && !readOnly && filteredPages.length > 0 ? /* @__PURE__ */ jsx12(
|
|
4802
|
+
"div",
|
|
4762
4803
|
{
|
|
4763
|
-
|
|
4764
|
-
className: "
|
|
4765
|
-
|
|
4766
|
-
children:
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4804
|
+
"data-ohw-link-page-dropdown": "",
|
|
4805
|
+
className: "absolute left-0 right-0 h-20 top-[calc(100%+4px)] z-10 max-h-48 overflow-auto rounded-lg border border-border bg-popover py-1 shadow-lg",
|
|
4806
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4807
|
+
children: filteredPages.map((page) => /* @__PURE__ */ jsxs7(
|
|
4808
|
+
"button",
|
|
4809
|
+
{
|
|
4810
|
+
type: "button",
|
|
4811
|
+
className: "flex h-9 w-full items-center gap-2 border-0 bg-transparent px-3 text-left text-sm leading-5 text-foreground outline-none hover:bg-muted",
|
|
4812
|
+
onClick: () => onPageSelect(page),
|
|
4813
|
+
children: [
|
|
4814
|
+
/* @__PURE__ */ jsx12(IconFile, { className: "shrink-0", "aria-hidden": true }),
|
|
4815
|
+
/* @__PURE__ */ jsx12("span", { className: "truncate", children: page.title })
|
|
4816
|
+
]
|
|
4817
|
+
},
|
|
4818
|
+
page.path
|
|
4819
|
+
))
|
|
4820
|
+
}
|
|
4821
|
+
) : null
|
|
4773
4822
|
] }),
|
|
4774
4823
|
urlError ? /* @__PURE__ */ jsx12("p", { className: "text-sm font-medium text-destructive", children: urlError }) : null
|
|
4775
4824
|
] });
|
|
@@ -4939,7 +4988,7 @@ function useLinkModalState({
|
|
|
4939
4988
|
}
|
|
4940
4989
|
|
|
4941
4990
|
// src/ui/link-modal/LinkEditorPanel.tsx
|
|
4942
|
-
import { Fragment as Fragment2, jsx as jsx13, jsxs as
|
|
4991
|
+
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4943
4992
|
function LinkEditorPanel({
|
|
4944
4993
|
open = true,
|
|
4945
4994
|
mode = "create",
|
|
@@ -4963,19 +5012,18 @@ function LinkEditorPanel({
|
|
|
4963
5012
|
onSubmit
|
|
4964
5013
|
});
|
|
4965
5014
|
const isCancel = state.secondaryLabel === "Cancel";
|
|
4966
|
-
return /* @__PURE__ */
|
|
4967
|
-
/* @__PURE__ */ jsx13(
|
|
5015
|
+
return /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
5016
|
+
/* @__PURE__ */ jsx13(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx13(
|
|
4968
5017
|
"button",
|
|
4969
5018
|
{
|
|
4970
5019
|
type: "button",
|
|
4971
5020
|
className: "absolute right-[9px] top-[9px] rounded-sm p-1.5 text-foreground hover:bg-muted/50",
|
|
4972
|
-
onClick: state.handleClose,
|
|
4973
5021
|
"aria-label": "Close",
|
|
4974
5022
|
children: /* @__PURE__ */ jsx13(IconX, { "aria-hidden": true })
|
|
4975
5023
|
}
|
|
4976
|
-
),
|
|
4977
|
-
/* @__PURE__ */ jsx13(
|
|
4978
|
-
/* @__PURE__ */
|
|
5024
|
+
) }),
|
|
5025
|
+
/* @__PURE__ */ jsx13(DialogHeader, { className: "w-full gap-1.5 p-6 pr-12", children: /* @__PURE__ */ jsx13(DialogTitle, { className: "m-0 w-full break-words", children: state.title }) }),
|
|
5026
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex w-full flex-col gap-3 px-6 pb-8 pt-1", children: [
|
|
4979
5027
|
state.showBreadcrumb && state.selectedPage && state.selectedSection ? /* @__PURE__ */ jsx13(
|
|
4980
5028
|
DestinationBreadcrumb,
|
|
4981
5029
|
{
|
|
@@ -4995,9 +5043,9 @@ function LinkEditorPanel({
|
|
|
4995
5043
|
urlError: state.urlError
|
|
4996
5044
|
}
|
|
4997
5045
|
),
|
|
4998
|
-
state.showChooseSection ? /* @__PURE__ */
|
|
5046
|
+
state.showChooseSection ? /* @__PURE__ */ jsxs8("div", { className: "flex flex-col justify-center gap-2", children: [
|
|
4999
5047
|
/* @__PURE__ */ jsx13(Button, { type: "button", variant: "outline", className: "w-fit cursor-pointer", size: "sm", onClick: state.handleChooseSection, children: "Choose a section" }),
|
|
5000
|
-
/* @__PURE__ */
|
|
5048
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
|
|
5001
5049
|
/* @__PURE__ */ jsx13(IconInfo, { className: "shrink-0", "aria-hidden": true }),
|
|
5002
5050
|
/* @__PURE__ */ jsx13("span", { children: "Pick a section this link should scroll to." })
|
|
5003
5051
|
] })
|
|
@@ -5005,7 +5053,7 @@ function LinkEditorPanel({
|
|
|
5005
5053
|
state.showSectionPicker ? /* @__PURE__ */ jsx13(SectionPickerList, { sections: state.activeSections, onSelect: state.handleSectionSelect }) : null,
|
|
5006
5054
|
state.showSectionRow && state.selectedSection ? /* @__PURE__ */ jsx13(SectionTreeItem, { section: state.selectedSection, selected: true }) : null
|
|
5007
5055
|
] }),
|
|
5008
|
-
/* @__PURE__ */
|
|
5056
|
+
/* @__PURE__ */ jsxs8(DialogFooter, { className: "w-full px-6 pb-6", children: [
|
|
5009
5057
|
/* @__PURE__ */ jsx13(
|
|
5010
5058
|
Button,
|
|
5011
5059
|
{
|
|
@@ -5042,26 +5090,32 @@ function LinkEditorPanel({
|
|
|
5042
5090
|
// src/ui/link-modal/LinkPopover.tsx
|
|
5043
5091
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
5044
5092
|
function LinkPopover({
|
|
5045
|
-
|
|
5046
|
-
parentScroll,
|
|
5093
|
+
open = true,
|
|
5047
5094
|
panelRef,
|
|
5095
|
+
portalContainer,
|
|
5096
|
+
onClose,
|
|
5048
5097
|
...editorProps
|
|
5049
5098
|
}) {
|
|
5050
|
-
const { top, left, transform } = calcPopoverPos(rect, parentScroll);
|
|
5051
5099
|
return /* @__PURE__ */ jsx14(
|
|
5052
|
-
|
|
5100
|
+
Dialog2,
|
|
5053
5101
|
{
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5102
|
+
open,
|
|
5103
|
+
onOpenChange: (next) => {
|
|
5104
|
+
if (!next) onClose?.();
|
|
5105
|
+
},
|
|
5106
|
+
children: /* @__PURE__ */ jsx14(
|
|
5107
|
+
DialogContent,
|
|
5108
|
+
{
|
|
5109
|
+
ref: panelRef,
|
|
5110
|
+
container: portalContainer,
|
|
5111
|
+
"data-ohw-link-popover-root": "",
|
|
5112
|
+
"data-ohw-link-modal-root": "",
|
|
5113
|
+
"data-ohw-bridge": "",
|
|
5114
|
+
showCloseButton: false,
|
|
5115
|
+
className: "gap-0 p-0 w-full md:w-md pointer-events-auto",
|
|
5116
|
+
children: /* @__PURE__ */ jsx14(LinkEditorPanel, { ...editorProps, open, onClose })
|
|
5117
|
+
}
|
|
5118
|
+
)
|
|
5065
5119
|
}
|
|
5066
5120
|
);
|
|
5067
5121
|
}
|
|
@@ -5147,7 +5201,7 @@ function Badge({ className, variant, ...props }) {
|
|
|
5147
5201
|
}
|
|
5148
5202
|
|
|
5149
5203
|
// src/OhhwellsBridge.tsx
|
|
5150
|
-
import { Fragment as Fragment3, jsx as jsx16, jsxs as
|
|
5204
|
+
import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
5151
5205
|
var PRIMARY = "#0885FE";
|
|
5152
5206
|
var IMAGE_FADE_MS = 300;
|
|
5153
5207
|
function runOpacityFade(el, onDone) {
|
|
@@ -5407,7 +5461,7 @@ function applyLinkByKey(key, val) {
|
|
|
5407
5461
|
}
|
|
5408
5462
|
function isInsideLinkEditor(target) {
|
|
5409
5463
|
return Boolean(
|
|
5410
|
-
target.closest("[data-ohw-link-popover-root]") || target.closest("[data-ohw-link-modal-root]") || target.closest('[data-slot="popover-content"]')
|
|
5464
|
+
target.closest("[data-ohw-link-popover-root]") || target.closest("[data-ohw-link-modal-root]") || target.closest("[data-ohw-link-page-dropdown]") || target.closest('[data-slot="popover-content"]') || target.closest('[data-slot="dialog-content"]') || target.closest('[data-slot="dialog-overlay"]')
|
|
5411
5465
|
);
|
|
5412
5466
|
}
|
|
5413
5467
|
function getHrefKeyFromElement(el) {
|
|
@@ -5418,6 +5472,15 @@ function getHrefKeyFromElement(el) {
|
|
|
5418
5472
|
if (!key) return null;
|
|
5419
5473
|
return { anchor, key };
|
|
5420
5474
|
}
|
|
5475
|
+
function isNavbarButton(el) {
|
|
5476
|
+
return Boolean(el.closest('[data-ohw-role="navbar-button"]'));
|
|
5477
|
+
}
|
|
5478
|
+
function clearHrefKeyHover(anchor) {
|
|
5479
|
+
anchor.removeAttribute("data-ohw-hovered");
|
|
5480
|
+
anchor.querySelectorAll("[data-ohw-hovered]").forEach((el) => {
|
|
5481
|
+
el.removeAttribute("data-ohw-hovered");
|
|
5482
|
+
});
|
|
5483
|
+
}
|
|
5421
5484
|
function collectSections() {
|
|
5422
5485
|
return collectSectionsFromDom();
|
|
5423
5486
|
}
|
|
@@ -5541,6 +5604,8 @@ var ICONS = {
|
|
|
5541
5604
|
insertUnorderedList: '<line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>',
|
|
5542
5605
|
insertOrderedList: '<line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/>'
|
|
5543
5606
|
};
|
|
5607
|
+
var TOOLBAR_PILL_PADDING = 2;
|
|
5608
|
+
var TOOLBAR_TOGGLE_GAP = 4;
|
|
5544
5609
|
var TOOLBAR_GROUPS = [
|
|
5545
5610
|
[
|
|
5546
5611
|
{ cmd: "bold", title: "Bold" },
|
|
@@ -5579,41 +5644,191 @@ function GlowFrame({ rect, elRef }) {
|
|
|
5579
5644
|
}
|
|
5580
5645
|
);
|
|
5581
5646
|
}
|
|
5582
|
-
function
|
|
5647
|
+
function getIframeVisibleClip(parentScroll) {
|
|
5648
|
+
if (!parentScroll) return null;
|
|
5649
|
+
const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH } = parentScroll;
|
|
5650
|
+
const clipTop = Math.max(0, visibleCanvasTop - iframeOffsetTop);
|
|
5651
|
+
const clipBottom = Math.min(
|
|
5652
|
+
window.innerHeight,
|
|
5653
|
+
visibleCanvasTop + canvasH - iframeOffsetTop
|
|
5654
|
+
);
|
|
5655
|
+
return { top: clipTop, bottom: Math.max(clipTop, clipBottom) };
|
|
5656
|
+
}
|
|
5657
|
+
function applyVisibleViewport(el, parentScroll) {
|
|
5658
|
+
const clip = getIframeVisibleClip(parentScroll);
|
|
5659
|
+
const top = clip?.top ?? 0;
|
|
5660
|
+
const height = clip ? clip.bottom - clip.top : window.innerHeight;
|
|
5661
|
+
el.style.top = `${top}px`;
|
|
5662
|
+
el.style.height = `${height}px`;
|
|
5663
|
+
}
|
|
5664
|
+
function clampToolbarToClip(top, transform, rect, clip, approxH, gap) {
|
|
5665
|
+
const isAbove = transform.includes("translateY(-100%)");
|
|
5666
|
+
let visualTop = isAbove ? top - approxH : top;
|
|
5667
|
+
let visualBottom = isAbove ? top : top + approxH;
|
|
5668
|
+
const minTop = clip.top + gap;
|
|
5669
|
+
const maxBottom = clip.bottom - gap;
|
|
5670
|
+
if (visualTop >= minTop && visualBottom <= maxBottom) {
|
|
5671
|
+
return { top, transform };
|
|
5672
|
+
}
|
|
5673
|
+
const belowTop = rect.bottom + gap;
|
|
5674
|
+
if (belowTop + approxH <= maxBottom && belowTop >= minTop) {
|
|
5675
|
+
return { top: belowTop, transform: "translateX(-50%)" };
|
|
5676
|
+
}
|
|
5677
|
+
const aboveTop = rect.top - gap;
|
|
5678
|
+
if (aboveTop - approxH >= minTop && aboveTop <= maxBottom) {
|
|
5679
|
+
return { top: aboveTop, transform: "translateX(-50%) translateY(-100%)" };
|
|
5680
|
+
}
|
|
5681
|
+
if (belowTop + approxH <= maxBottom) {
|
|
5682
|
+
return { top: belowTop, transform: "translateX(-50%)" };
|
|
5683
|
+
}
|
|
5684
|
+
const pinnedTop = Math.min(maxBottom - approxH, Math.max(minTop, clip.top + gap));
|
|
5685
|
+
return { top: pinnedTop + approxH, transform: "translateX(-50%) translateY(-100%)" };
|
|
5686
|
+
}
|
|
5687
|
+
function calcToolbarPos(rect, parentScroll, approxW = 306) {
|
|
5583
5688
|
const GAP = 8;
|
|
5584
|
-
const APPROX_H =
|
|
5585
|
-
const APPROX_W =
|
|
5689
|
+
const APPROX_H = 32;
|
|
5690
|
+
const APPROX_W = approxW;
|
|
5691
|
+
const clip = getIframeVisibleClip(parentScroll);
|
|
5692
|
+
const clipTop = clip?.top ?? 0;
|
|
5586
5693
|
const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
|
|
5587
5694
|
const visibleTop = rect.top - canvasTopInIframe;
|
|
5588
5695
|
const visibleBottom = rect.bottom - canvasTopInIframe;
|
|
5589
5696
|
const isTall = rect.height > APPROX_H + GAP;
|
|
5697
|
+
const spaceAbove = rect.top - (clipTop + GAP);
|
|
5698
|
+
const fitsAbove = spaceAbove >= APPROX_H + GAP;
|
|
5590
5699
|
let top;
|
|
5591
5700
|
let transform;
|
|
5592
|
-
if (visibleTop > 0 || !isTall) {
|
|
5701
|
+
if ((visibleTop > 0 || !isTall) && fitsAbove) {
|
|
5593
5702
|
top = rect.top - GAP;
|
|
5594
5703
|
transform = "translateX(-50%) translateY(-100%)";
|
|
5704
|
+
} else if (visibleTop > 0 || !isTall) {
|
|
5705
|
+
top = rect.bottom + GAP;
|
|
5706
|
+
transform = "translateX(-50%)";
|
|
5595
5707
|
} else if (visibleBottom > APPROX_H + GAP) {
|
|
5596
|
-
top =
|
|
5708
|
+
top = clipTop + GAP;
|
|
5597
5709
|
transform = "translateX(-50%)";
|
|
5598
5710
|
} else {
|
|
5599
5711
|
top = rect.bottom + GAP;
|
|
5600
5712
|
transform = "translateX(-50%)";
|
|
5601
5713
|
}
|
|
5714
|
+
if (clip) {
|
|
5715
|
+
const clamped = clampToolbarToClip(top, transform, rect, clip, APPROX_H, GAP);
|
|
5716
|
+
top = clamped.top;
|
|
5717
|
+
transform = clamped.transform;
|
|
5718
|
+
}
|
|
5602
5719
|
const rawLeft = rect.left + rect.width / 2;
|
|
5603
5720
|
const left = Math.max(GAP + APPROX_W / 2, Math.min(rawLeft, window.innerWidth - GAP - APPROX_W / 2));
|
|
5604
5721
|
return { top, left, transform };
|
|
5605
5722
|
}
|
|
5723
|
+
var EDIT_LINK_ICON = /* @__PURE__ */ jsxs9("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: [
|
|
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
|
+
] });
|
|
5606
5727
|
function FloatingToolbar({
|
|
5607
5728
|
rect,
|
|
5608
5729
|
parentScroll,
|
|
5609
5730
|
elRef,
|
|
5731
|
+
variant = "rich-text",
|
|
5610
5732
|
onCommand,
|
|
5611
5733
|
activeCommands,
|
|
5612
5734
|
showEditLink,
|
|
5613
5735
|
onEditLink
|
|
5614
5736
|
}) {
|
|
5615
|
-
const
|
|
5616
|
-
|
|
5737
|
+
const approxW = variant === "link-action" ? 112 : 306;
|
|
5738
|
+
const { top, left, transform } = calcToolbarPos(rect, parentScroll, approxW);
|
|
5739
|
+
if (variant === "link-action") {
|
|
5740
|
+
return /* @__PURE__ */ jsxs9(
|
|
5741
|
+
"div",
|
|
5742
|
+
{
|
|
5743
|
+
ref: elRef,
|
|
5744
|
+
"data-ohw-toolbar": "",
|
|
5745
|
+
style: {
|
|
5746
|
+
position: "fixed",
|
|
5747
|
+
top,
|
|
5748
|
+
left,
|
|
5749
|
+
transform,
|
|
5750
|
+
zIndex: 2147483647,
|
|
5751
|
+
background: "#fff",
|
|
5752
|
+
border: "1px solid #E7E5E4",
|
|
5753
|
+
borderRadius: 6,
|
|
5754
|
+
boxShadow: "0px 2px 4px -2px rgba(0,0,0,.1),0px 4px 6px -1px rgba(0,0,0,.1)",
|
|
5755
|
+
display: "flex",
|
|
5756
|
+
alignItems: "center",
|
|
5757
|
+
padding: TOOLBAR_PILL_PADDING,
|
|
5758
|
+
gap: TOOLBAR_TOGGLE_GAP,
|
|
5759
|
+
fontFamily: "sans-serif",
|
|
5760
|
+
pointerEvents: "auto",
|
|
5761
|
+
whiteSpace: "nowrap"
|
|
5762
|
+
},
|
|
5763
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
5764
|
+
children: [
|
|
5765
|
+
/* @__PURE__ */ jsx16(
|
|
5766
|
+
"button",
|
|
5767
|
+
{
|
|
5768
|
+
type: "button",
|
|
5769
|
+
title: "Edit link",
|
|
5770
|
+
onMouseDown: (e) => {
|
|
5771
|
+
e.preventDefault();
|
|
5772
|
+
e.stopPropagation();
|
|
5773
|
+
onEditLink?.();
|
|
5774
|
+
},
|
|
5775
|
+
onClick: (e) => {
|
|
5776
|
+
e.preventDefault();
|
|
5777
|
+
e.stopPropagation();
|
|
5778
|
+
},
|
|
5779
|
+
onMouseEnter: (e) => {
|
|
5780
|
+
e.currentTarget.style.background = "#F5F5F4";
|
|
5781
|
+
},
|
|
5782
|
+
onMouseLeave: (e) => {
|
|
5783
|
+
e.currentTarget.style.background = "transparent";
|
|
5784
|
+
},
|
|
5785
|
+
style: {
|
|
5786
|
+
display: "flex",
|
|
5787
|
+
alignItems: "center",
|
|
5788
|
+
justifyContent: "center",
|
|
5789
|
+
border: "none",
|
|
5790
|
+
background: "transparent",
|
|
5791
|
+
borderRadius: 4,
|
|
5792
|
+
cursor: "pointer",
|
|
5793
|
+
color: "#1C1917",
|
|
5794
|
+
flexShrink: 0,
|
|
5795
|
+
padding: 6
|
|
5796
|
+
},
|
|
5797
|
+
children: EDIT_LINK_ICON
|
|
5798
|
+
}
|
|
5799
|
+
),
|
|
5800
|
+
/* @__PURE__ */ jsx16("span", { style: { display: "block", width: 1, height: 24, background: "#E7E5E4", flexShrink: 0 } }),
|
|
5801
|
+
/* @__PURE__ */ jsx16(
|
|
5802
|
+
"button",
|
|
5803
|
+
{
|
|
5804
|
+
type: "button",
|
|
5805
|
+
title: "Coming soon",
|
|
5806
|
+
disabled: true,
|
|
5807
|
+
style: {
|
|
5808
|
+
display: "flex",
|
|
5809
|
+
alignItems: "center",
|
|
5810
|
+
justifyContent: "center",
|
|
5811
|
+
border: "none",
|
|
5812
|
+
background: "transparent",
|
|
5813
|
+
borderRadius: 4,
|
|
5814
|
+
cursor: "not-allowed",
|
|
5815
|
+
color: "#A8A29E",
|
|
5816
|
+
flexShrink: 0,
|
|
5817
|
+
padding: 6,
|
|
5818
|
+
opacity: 0.6
|
|
5819
|
+
},
|
|
5820
|
+
children: /* @__PURE__ */ jsxs9("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: [
|
|
5821
|
+
/* @__PURE__ */ jsx16("circle", { cx: "5", cy: "12", r: "1.5" }),
|
|
5822
|
+
/* @__PURE__ */ jsx16("circle", { cx: "12", cy: "12", r: "1.5" }),
|
|
5823
|
+
/* @__PURE__ */ jsx16("circle", { cx: "19", cy: "12", r: "1.5" })
|
|
5824
|
+
] })
|
|
5825
|
+
}
|
|
5826
|
+
)
|
|
5827
|
+
]
|
|
5828
|
+
}
|
|
5829
|
+
);
|
|
5830
|
+
}
|
|
5831
|
+
return /* @__PURE__ */ jsxs9(
|
|
5617
5832
|
"div",
|
|
5618
5833
|
{
|
|
5619
5834
|
ref: elRef,
|
|
@@ -5630,15 +5845,15 @@ function FloatingToolbar({
|
|
|
5630
5845
|
boxShadow: "0px 2px 4px -2px rgba(0,0,0,.1),0px 4px 6px -1px rgba(0,0,0,.1)",
|
|
5631
5846
|
display: "flex",
|
|
5632
5847
|
alignItems: "center",
|
|
5633
|
-
padding:
|
|
5634
|
-
gap:
|
|
5848
|
+
padding: TOOLBAR_PILL_PADDING,
|
|
5849
|
+
gap: TOOLBAR_TOGGLE_GAP,
|
|
5635
5850
|
fontFamily: "sans-serif",
|
|
5636
5851
|
pointerEvents: "auto",
|
|
5637
5852
|
whiteSpace: "nowrap"
|
|
5638
5853
|
},
|
|
5639
5854
|
onMouseDown: (e) => e.stopPropagation(),
|
|
5640
5855
|
children: [
|
|
5641
|
-
TOOLBAR_GROUPS.map((btns, gi) => /* @__PURE__ */
|
|
5856
|
+
TOOLBAR_GROUPS.map((btns, gi) => /* @__PURE__ */ jsxs9(React6.Fragment, { children: [
|
|
5642
5857
|
gi > 0 && /* @__PURE__ */ jsx16("span", { style: { display: "block", width: 1, height: 24, background: "#E7E5E4", flexShrink: 0 } }),
|
|
5643
5858
|
btns.map((btn) => {
|
|
5644
5859
|
const isActive = activeCommands.has(btn.cmd);
|
|
@@ -5720,10 +5935,7 @@ function FloatingToolbar({
|
|
|
5720
5935
|
flexShrink: 0,
|
|
5721
5936
|
padding: 6
|
|
5722
5937
|
},
|
|
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
|
-
] })
|
|
5938
|
+
children: EDIT_LINK_ICON
|
|
5727
5939
|
}
|
|
5728
5940
|
) : null
|
|
5729
5941
|
]
|
|
@@ -5814,9 +6026,17 @@ function OhhwellsBridge() {
|
|
|
5814
6026
|
const [fetchState, setFetchState] = useState5("idle");
|
|
5815
6027
|
const autoSaveTimers = useRef3(/* @__PURE__ */ new Map());
|
|
5816
6028
|
const activeElRef = useRef3(null);
|
|
6029
|
+
const selectedElRef = useRef3(null);
|
|
5817
6030
|
const originalContentRef = useRef3(null);
|
|
5818
6031
|
const activeStateElRef = useRef3(null);
|
|
5819
6032
|
const parentScrollRef = useRef3(null);
|
|
6033
|
+
const visibleViewportRef = useRef3(null);
|
|
6034
|
+
const [dialogPortalContainer, setDialogPortalContainer] = useState5(null);
|
|
6035
|
+
const attachVisibleViewport = useCallback2((node) => {
|
|
6036
|
+
visibleViewportRef.current = node;
|
|
6037
|
+
setDialogPortalContainer(node);
|
|
6038
|
+
if (node) applyVisibleViewport(node, parentScrollRef.current);
|
|
6039
|
+
}, []);
|
|
5820
6040
|
const toolbarElRef = useRef3(null);
|
|
5821
6041
|
const glowElRef = useRef3(null);
|
|
5822
6042
|
const hoveredImageRef = useRef3(null);
|
|
@@ -5829,6 +6049,10 @@ function OhhwellsBridge() {
|
|
|
5829
6049
|
});
|
|
5830
6050
|
const deactivateRef = useRef3(() => {
|
|
5831
6051
|
});
|
|
6052
|
+
const selectRef = useRef3(() => {
|
|
6053
|
+
});
|
|
6054
|
+
const deselectRef = useRef3(() => {
|
|
6055
|
+
});
|
|
5832
6056
|
const refreshActiveCommandsRef = useRef3(() => {
|
|
5833
6057
|
});
|
|
5834
6058
|
const postToParentRef = useRef3(postToParent);
|
|
@@ -5836,6 +6060,9 @@ function OhhwellsBridge() {
|
|
|
5836
6060
|
const sectionsLoadedRef = useRef3(false);
|
|
5837
6061
|
const pendingScheduleConfigRequests = useRef3([]);
|
|
5838
6062
|
const [toolbarRect, setToolbarRect] = useState5(null);
|
|
6063
|
+
const [toolbarVariant, setToolbarVariant] = useState5("none");
|
|
6064
|
+
const toolbarVariantRef = useRef3("none");
|
|
6065
|
+
toolbarVariantRef.current = toolbarVariant;
|
|
5839
6066
|
const [toggleState, setToggleState] = useState5(null);
|
|
5840
6067
|
const [maxBadge, setMaxBadge] = useState5(null);
|
|
5841
6068
|
const [activeCommands, setActiveCommands] = useState5(/* @__PURE__ */ new Set());
|
|
@@ -5880,7 +6107,33 @@ function OhhwellsBridge() {
|
|
|
5880
6107
|
hoveredImageRef.current = null;
|
|
5881
6108
|
hoveredImageHasTextOverlapRef.current = false;
|
|
5882
6109
|
}
|
|
6110
|
+
hoveredGapRef.current = null;
|
|
6111
|
+
setSectionGap(null);
|
|
5883
6112
|
postToParent({ type: "ow:image-unhover" });
|
|
6113
|
+
postToParent({ type: "ow:link-modal-lock", locked: true });
|
|
6114
|
+
const html = document.documentElement;
|
|
6115
|
+
const body = document.body;
|
|
6116
|
+
const prevHtmlOverflow = html.style.overflow;
|
|
6117
|
+
const prevBodyOverflow = body.style.overflow;
|
|
6118
|
+
html.style.overflow = "hidden";
|
|
6119
|
+
body.style.overflow = "hidden";
|
|
6120
|
+
const preventBackgroundScroll = (e) => {
|
|
6121
|
+
const target = e.target;
|
|
6122
|
+
if (target instanceof Element && target.closest('[data-ohw-link-modal-root], [data-slot="dialog-overlay"]')) {
|
|
6123
|
+
return;
|
|
6124
|
+
}
|
|
6125
|
+
e.preventDefault();
|
|
6126
|
+
};
|
|
6127
|
+
const scrollOpts = { passive: false, capture: true };
|
|
6128
|
+
document.addEventListener("wheel", preventBackgroundScroll, scrollOpts);
|
|
6129
|
+
document.addEventListener("touchmove", preventBackgroundScroll, scrollOpts);
|
|
6130
|
+
return () => {
|
|
6131
|
+
postToParent({ type: "ow:link-modal-lock", locked: false });
|
|
6132
|
+
html.style.overflow = prevHtmlOverflow;
|
|
6133
|
+
body.style.overflow = prevBodyOverflow;
|
|
6134
|
+
document.removeEventListener("wheel", preventBackgroundScroll, scrollOpts);
|
|
6135
|
+
document.removeEventListener("touchmove", preventBackgroundScroll, scrollOpts);
|
|
6136
|
+
};
|
|
5884
6137
|
}, [linkPopover, postToParent]);
|
|
5885
6138
|
useEffect3(() => {
|
|
5886
6139
|
if (!isEditMode) return;
|
|
@@ -5915,7 +6168,7 @@ function OhhwellsBridge() {
|
|
|
5915
6168
|
}, [isEditMode]);
|
|
5916
6169
|
useEffect3(() => {
|
|
5917
6170
|
const update = () => {
|
|
5918
|
-
const el = activeElRef.current;
|
|
6171
|
+
const el = activeElRef.current ?? selectedElRef.current;
|
|
5919
6172
|
if (el) setToolbarRect(el.getBoundingClientRect());
|
|
5920
6173
|
setToggleState((prev) => {
|
|
5921
6174
|
if (!prev || !activeStateElRef.current) return prev;
|
|
@@ -5983,19 +6236,41 @@ function OhhwellsBridge() {
|
|
|
5983
6236
|
}
|
|
5984
6237
|
el.removeAttribute("contenteditable");
|
|
5985
6238
|
activeElRef.current = null;
|
|
5986
|
-
|
|
6239
|
+
if (!selectedElRef.current) {
|
|
6240
|
+
setToolbarRect(null);
|
|
6241
|
+
setToolbarVariant("none");
|
|
6242
|
+
}
|
|
5987
6243
|
setMaxBadge(null);
|
|
5988
6244
|
setActiveCommands(/* @__PURE__ */ new Set());
|
|
5989
6245
|
setToolbarShowEditLink(false);
|
|
5990
6246
|
postToParent({ type: "ow:exit-edit" });
|
|
5991
6247
|
}, [postToParent]);
|
|
6248
|
+
const deselect = useCallback2(() => {
|
|
6249
|
+
selectedElRef.current = null;
|
|
6250
|
+
if (!activeElRef.current) {
|
|
6251
|
+
setToolbarRect(null);
|
|
6252
|
+
setToolbarVariant("none");
|
|
6253
|
+
}
|
|
6254
|
+
}, []);
|
|
6255
|
+
const select = useCallback2((anchor) => {
|
|
6256
|
+
if (!isNavbarButton(anchor)) return;
|
|
6257
|
+
if (activeElRef.current) deactivate();
|
|
6258
|
+
selectedElRef.current = anchor;
|
|
6259
|
+
clearHrefKeyHover(anchor);
|
|
6260
|
+
setToolbarVariant("link-action");
|
|
6261
|
+
setToolbarRect(anchor.getBoundingClientRect());
|
|
6262
|
+
setToolbarShowEditLink(false);
|
|
6263
|
+
setActiveCommands(/* @__PURE__ */ new Set());
|
|
6264
|
+
}, [deactivate]);
|
|
5992
6265
|
const activate = useCallback2((el) => {
|
|
5993
6266
|
if (activeElRef.current === el) return;
|
|
6267
|
+
selectedElRef.current = null;
|
|
5994
6268
|
deactivate();
|
|
5995
6269
|
if (hoveredImageRef.current) {
|
|
5996
6270
|
hoveredImageRef.current = null;
|
|
5997
6271
|
postToParentRef.current({ type: "ow:image-unhover" });
|
|
5998
6272
|
}
|
|
6273
|
+
setToolbarVariant("rich-text");
|
|
5999
6274
|
el.setAttribute("contenteditable", "true");
|
|
6000
6275
|
el.removeAttribute("data-ohw-hovered");
|
|
6001
6276
|
activeElRef.current = el;
|
|
@@ -6008,6 +6283,8 @@ function OhhwellsBridge() {
|
|
|
6008
6283
|
}, [deactivate, postToParent]);
|
|
6009
6284
|
activateRef.current = activate;
|
|
6010
6285
|
deactivateRef.current = deactivate;
|
|
6286
|
+
selectRef.current = select;
|
|
6287
|
+
deselectRef.current = deselect;
|
|
6011
6288
|
useLayoutEffect(() => {
|
|
6012
6289
|
if (!subdomain || isEditMode) {
|
|
6013
6290
|
setFetchState("done");
|
|
@@ -6111,6 +6388,12 @@ function OhhwellsBridge() {
|
|
|
6111
6388
|
useEffect3(() => {
|
|
6112
6389
|
postToParent({ type: "ow:navigation", path: pathname });
|
|
6113
6390
|
}, [pathname, postToParent]);
|
|
6391
|
+
useEffect3(() => {
|
|
6392
|
+
if (!isEditMode) return;
|
|
6393
|
+
setLinkPopover(null);
|
|
6394
|
+
deselectRef.current();
|
|
6395
|
+
deactivateRef.current();
|
|
6396
|
+
}, [pathname, isEditMode]);
|
|
6114
6397
|
useEffect3(() => {
|
|
6115
6398
|
if (!isEditMode) return;
|
|
6116
6399
|
const measure = () => {
|
|
@@ -6221,12 +6504,12 @@ function OhhwellsBridge() {
|
|
|
6221
6504
|
if (editable.dataset.ohwEditable === "link") {
|
|
6222
6505
|
e.preventDefault();
|
|
6223
6506
|
e.stopPropagation();
|
|
6507
|
+
deselectRef.current();
|
|
6224
6508
|
deactivateRef.current();
|
|
6225
6509
|
bumpLinkPopoverGrace();
|
|
6226
6510
|
setLinkPopoverRef.current({
|
|
6227
6511
|
key: editable.dataset.ohwKey ?? "",
|
|
6228
|
-
target: getLinkHref(editable)
|
|
6229
|
-
rect: editable.getBoundingClientRect()
|
|
6512
|
+
target: getLinkHref(editable)
|
|
6230
6513
|
});
|
|
6231
6514
|
return;
|
|
6232
6515
|
}
|
|
@@ -6236,11 +6519,31 @@ function OhhwellsBridge() {
|
|
|
6236
6519
|
postToParentRef.current({ type: "ow:image-pick", key: editable.dataset.ohwKey ?? "" });
|
|
6237
6520
|
return;
|
|
6238
6521
|
}
|
|
6522
|
+
const hrefCtx = getHrefKeyFromElement(editable);
|
|
6523
|
+
if (hrefCtx && isNavbarButton(hrefCtx.anchor)) {
|
|
6524
|
+
e.preventDefault();
|
|
6525
|
+
e.stopPropagation();
|
|
6526
|
+
const { anchor: anchor2 } = hrefCtx;
|
|
6527
|
+
if (selectedElRef.current === anchor2) {
|
|
6528
|
+
activateRef.current(editable);
|
|
6529
|
+
return;
|
|
6530
|
+
}
|
|
6531
|
+
selectRef.current(anchor2);
|
|
6532
|
+
return;
|
|
6533
|
+
}
|
|
6239
6534
|
e.preventDefault();
|
|
6240
6535
|
e.stopPropagation();
|
|
6241
6536
|
activateRef.current(editable);
|
|
6242
6537
|
return;
|
|
6243
6538
|
}
|
|
6539
|
+
const hrefAnchor = target.closest("[data-ohw-href-key]");
|
|
6540
|
+
if (hrefAnchor && isNavbarButton(hrefAnchor)) {
|
|
6541
|
+
e.preventDefault();
|
|
6542
|
+
e.stopPropagation();
|
|
6543
|
+
if (selectedElRef.current === hrefAnchor) return;
|
|
6544
|
+
selectRef.current(hrefAnchor);
|
|
6545
|
+
return;
|
|
6546
|
+
}
|
|
6244
6547
|
if (activeElRef.current) {
|
|
6245
6548
|
const sel = window.getSelection();
|
|
6246
6549
|
if (sel && !sel.isCollapsed) {
|
|
@@ -6255,15 +6558,22 @@ function OhhwellsBridge() {
|
|
|
6255
6558
|
const hrefCtx = getHrefKeyFromElement(activeElRef.current);
|
|
6256
6559
|
if (hrefCtx && (hrefCtx.anchor === target || hrefCtx.anchor.contains(target))) return;
|
|
6257
6560
|
}
|
|
6561
|
+
if (linkPopoverOpenRef.current && selectedElRef.current) {
|
|
6562
|
+
const selected = selectedElRef.current;
|
|
6563
|
+
if (selected === target || selected.contains(target)) return;
|
|
6564
|
+
}
|
|
6258
6565
|
if (linkPopoverOpenRef.current) {
|
|
6259
6566
|
setLinkPopoverRef.current(null);
|
|
6260
6567
|
return;
|
|
6261
6568
|
}
|
|
6569
|
+
deselectRef.current();
|
|
6262
6570
|
deactivateRef.current();
|
|
6263
6571
|
};
|
|
6264
6572
|
const handleMouseOver = (e) => {
|
|
6265
6573
|
const editable = e.target.closest("[data-ohw-editable]");
|
|
6266
6574
|
if (!editable) return;
|
|
6575
|
+
const selected = selectedElRef.current;
|
|
6576
|
+
if (selected && (selected === editable || selected.contains(editable))) return;
|
|
6267
6577
|
if (editable.dataset.ohwEditable !== "image" && editable.dataset.ohwEditable !== "bg-image" && !editable.hasAttribute("contenteditable")) {
|
|
6268
6578
|
editable.setAttribute("data-ohw-hovered", "");
|
|
6269
6579
|
}
|
|
@@ -6399,7 +6709,7 @@ function OhhwellsBridge() {
|
|
|
6399
6709
|
}
|
|
6400
6710
|
return;
|
|
6401
6711
|
}
|
|
6402
|
-
if (topEl?.closest("[data-ohw-link-popover-root]") || topEl?.closest("[data-ohw-link-modal-root]")) {
|
|
6712
|
+
if (topEl?.closest("[data-ohw-link-popover-root]") || topEl?.closest("[data-ohw-link-modal-root]") || topEl?.closest("[data-ohw-link-page-dropdown]")) {
|
|
6403
6713
|
if (hoveredImageRef.current) {
|
|
6404
6714
|
hoveredImageRef.current = null;
|
|
6405
6715
|
hoveredImageHasTextOverlapRef.current = false;
|
|
@@ -6527,6 +6837,13 @@ function OhhwellsBridge() {
|
|
|
6527
6837
|
}
|
|
6528
6838
|
};
|
|
6529
6839
|
const probeSectionGapAt = (clientX, clientY, fromParentViewport = false) => {
|
|
6840
|
+
if (linkPopoverOpenRef.current) {
|
|
6841
|
+
if (hoveredGapRef.current) {
|
|
6842
|
+
hoveredGapRef.current = null;
|
|
6843
|
+
setSectionGap(null);
|
|
6844
|
+
}
|
|
6845
|
+
return;
|
|
6846
|
+
}
|
|
6530
6847
|
const { y } = toProbeCoords(clientX, clientY, fromParentViewport);
|
|
6531
6848
|
const sections = Array.from(document.querySelectorAll("[data-ohw-section]")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
|
|
6532
6849
|
const ZONE = 20;
|
|
@@ -6750,6 +7067,7 @@ function OhhwellsBridge() {
|
|
|
6750
7067
|
setLinkPopoverRef.current(null);
|
|
6751
7068
|
return;
|
|
6752
7069
|
}
|
|
7070
|
+
deselectRef.current();
|
|
6753
7071
|
deactivateRef.current();
|
|
6754
7072
|
};
|
|
6755
7073
|
window.addEventListener("message", handleDeactivate);
|
|
@@ -6758,6 +7076,10 @@ function OhhwellsBridge() {
|
|
|
6758
7076
|
setLinkPopoverRef.current(null);
|
|
6759
7077
|
return;
|
|
6760
7078
|
}
|
|
7079
|
+
if (e.key === "Escape" && selectedElRef.current && !activeElRef.current) {
|
|
7080
|
+
deselectRef.current();
|
|
7081
|
+
return;
|
|
7082
|
+
}
|
|
6761
7083
|
if (e.key !== "Escape") return;
|
|
6762
7084
|
const el = activeElRef.current;
|
|
6763
7085
|
if (el && originalContentRef.current !== null) {
|
|
@@ -6767,13 +7089,16 @@ function OhhwellsBridge() {
|
|
|
6767
7089
|
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: originalContentRef.current }] });
|
|
6768
7090
|
}
|
|
6769
7091
|
}
|
|
7092
|
+
deselectRef.current();
|
|
6770
7093
|
deactivateRef.current();
|
|
6771
7094
|
};
|
|
6772
7095
|
const handleScroll = () => {
|
|
6773
|
-
|
|
6774
|
-
|
|
7096
|
+
const focusEl = activeElRef.current ?? selectedElRef.current;
|
|
7097
|
+
if (focusEl) {
|
|
7098
|
+
const r2 = focusEl.getBoundingClientRect();
|
|
6775
7099
|
applyToolbarPos(r2);
|
|
6776
|
-
|
|
7100
|
+
setToolbarRect(r2);
|
|
7101
|
+
setMaxBadge((prev) => prev && activeElRef.current ? { ...prev, rect: r2 } : prev);
|
|
6777
7102
|
}
|
|
6778
7103
|
if (activeStateElRef.current) {
|
|
6779
7104
|
const rect = activeStateElRef.current.getBoundingClientRect();
|
|
@@ -6898,8 +7223,9 @@ function OhhwellsBridge() {
|
|
|
6898
7223
|
};
|
|
6899
7224
|
const applyToolbarPos = (rect) => {
|
|
6900
7225
|
const ps = parentScrollRef.current;
|
|
7226
|
+
const approxW = toolbarVariantRef.current === "link-action" ? 112 : 306;
|
|
6901
7227
|
if (toolbarElRef.current) {
|
|
6902
|
-
const { top, left, transform } = calcToolbarPos(rect, ps);
|
|
7228
|
+
const { top, left, transform } = calcToolbarPos(rect, ps, approxW);
|
|
6903
7229
|
toolbarElRef.current.style.top = `${top}px`;
|
|
6904
7230
|
toolbarElRef.current.style.left = `${left}px`;
|
|
6905
7231
|
toolbarElRef.current.style.transform = transform;
|
|
@@ -6914,7 +7240,11 @@ function OhhwellsBridge() {
|
|
|
6914
7240
|
if (e.data?.type !== "ow:parent-scroll") return;
|
|
6915
7241
|
const { iframeOffsetTop, headerH, canvasH } = e.data;
|
|
6916
7242
|
parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
|
|
6917
|
-
if (
|
|
7243
|
+
if (visibleViewportRef.current) {
|
|
7244
|
+
applyVisibleViewport(visibleViewportRef.current, parentScrollRef.current);
|
|
7245
|
+
}
|
|
7246
|
+
const focusEl = activeElRef.current ?? selectedElRef.current;
|
|
7247
|
+
if (focusEl) applyToolbarPos(focusEl.getBoundingClientRect());
|
|
6918
7248
|
};
|
|
6919
7249
|
const handleClickAt = (e) => {
|
|
6920
7250
|
if (e.data?.type !== "ow:click-at") return;
|
|
@@ -6964,6 +7294,12 @@ function OhhwellsBridge() {
|
|
|
6964
7294
|
window.addEventListener("message", handleParentScroll);
|
|
6965
7295
|
window.addEventListener("message", handlePointerSync);
|
|
6966
7296
|
window.addEventListener("message", handleClickAt);
|
|
7297
|
+
const handleViewportResize = () => {
|
|
7298
|
+
if (visibleViewportRef.current) {
|
|
7299
|
+
applyVisibleViewport(visibleViewportRef.current, parentScrollRef.current);
|
|
7300
|
+
}
|
|
7301
|
+
};
|
|
7302
|
+
window.addEventListener("resize", handleViewportResize, { passive: true });
|
|
6967
7303
|
document.addEventListener("click", handleClick, true);
|
|
6968
7304
|
document.addEventListener("paste", handlePaste, true);
|
|
6969
7305
|
document.addEventListener("input", handleInput, true);
|
|
@@ -7001,6 +7337,7 @@ function OhhwellsBridge() {
|
|
|
7001
7337
|
window.removeEventListener("message", handleAnimLock);
|
|
7002
7338
|
window.removeEventListener("message", handleCanvasHeight);
|
|
7003
7339
|
window.removeEventListener("message", handleParentScroll);
|
|
7340
|
+
window.removeEventListener("resize", handleViewportResize);
|
|
7004
7341
|
window.removeEventListener("message", handlePointerSync);
|
|
7005
7342
|
window.removeEventListener("message", handleClickAt);
|
|
7006
7343
|
window.removeEventListener("message", handleHydrate);
|
|
@@ -7088,10 +7425,22 @@ function OhhwellsBridge() {
|
|
|
7088
7425
|
bumpLinkPopoverGrace();
|
|
7089
7426
|
setLinkPopover({
|
|
7090
7427
|
key: hrefCtx.key,
|
|
7091
|
-
target: getLinkHref(hrefCtx.anchor)
|
|
7092
|
-
rect: hrefCtx.anchor.getBoundingClientRect()
|
|
7428
|
+
target: getLinkHref(hrefCtx.anchor)
|
|
7093
7429
|
});
|
|
7094
|
-
|
|
7430
|
+
deactivate();
|
|
7431
|
+
}, [deactivate]);
|
|
7432
|
+
const openLinkPopoverForSelected = useCallback2(() => {
|
|
7433
|
+
const anchor = selectedElRef.current;
|
|
7434
|
+
if (!anchor) return;
|
|
7435
|
+
const key = anchor.getAttribute("data-ohw-href-key");
|
|
7436
|
+
if (!key) return;
|
|
7437
|
+
bumpLinkPopoverGrace();
|
|
7438
|
+
setLinkPopover({
|
|
7439
|
+
key,
|
|
7440
|
+
target: getLinkHref(anchor)
|
|
7441
|
+
});
|
|
7442
|
+
deselect();
|
|
7443
|
+
}, [deselect]);
|
|
7095
7444
|
const handleLinkPopoverSubmit = useCallback2(
|
|
7096
7445
|
(target) => {
|
|
7097
7446
|
if (!linkPopover) return;
|
|
@@ -7106,12 +7455,14 @@ function OhhwellsBridge() {
|
|
|
7106
7455
|
const currentSections = sectionsByPath[pathname] ?? [];
|
|
7107
7456
|
linkPopoverOpenRef.current = linkPopover !== null;
|
|
7108
7457
|
return bridgeRoot ? createPortal(
|
|
7109
|
-
/* @__PURE__ */
|
|
7110
|
-
|
|
7458
|
+
/* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
7459
|
+
/* @__PURE__ */ jsx16("div", { ref: attachVisibleViewport, "data-ohw-visible-viewport": "", "aria-hidden": true }),
|
|
7460
|
+
toolbarRect && /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
7111
7461
|
/* @__PURE__ */ jsx16(GlowFrame, { rect: toolbarRect, elRef: glowElRef }),
|
|
7112
|
-
/* @__PURE__ */ jsx16(
|
|
7462
|
+
toolbarVariant === "rich-text" && /* @__PURE__ */ jsx16(
|
|
7113
7463
|
FloatingToolbar,
|
|
7114
7464
|
{
|
|
7465
|
+
variant: "rich-text",
|
|
7115
7466
|
rect: toolbarRect,
|
|
7116
7467
|
parentScroll: parentScrollRef.current,
|
|
7117
7468
|
elRef: toolbarElRef,
|
|
@@ -7120,9 +7471,21 @@ function OhhwellsBridge() {
|
|
|
7120
7471
|
showEditLink,
|
|
7121
7472
|
onEditLink: openLinkPopoverForActive
|
|
7122
7473
|
}
|
|
7474
|
+
),
|
|
7475
|
+
toolbarVariant === "link-action" && /* @__PURE__ */ jsx16(
|
|
7476
|
+
FloatingToolbar,
|
|
7477
|
+
{
|
|
7478
|
+
variant: "link-action",
|
|
7479
|
+
rect: toolbarRect,
|
|
7480
|
+
parentScroll: parentScrollRef.current,
|
|
7481
|
+
elRef: toolbarElRef,
|
|
7482
|
+
onCommand: handleCommand,
|
|
7483
|
+
activeCommands,
|
|
7484
|
+
onEditLink: openLinkPopoverForSelected
|
|
7485
|
+
}
|
|
7123
7486
|
)
|
|
7124
7487
|
] }),
|
|
7125
|
-
maxBadge && /* @__PURE__ */
|
|
7488
|
+
maxBadge && /* @__PURE__ */ jsxs9(
|
|
7126
7489
|
"div",
|
|
7127
7490
|
{
|
|
7128
7491
|
"data-ohw-max-badge": "",
|
|
@@ -7157,7 +7520,7 @@ function OhhwellsBridge() {
|
|
|
7157
7520
|
onStateChange: handleStateChange
|
|
7158
7521
|
}
|
|
7159
7522
|
),
|
|
7160
|
-
sectionGap && /* @__PURE__ */
|
|
7523
|
+
sectionGap && /* @__PURE__ */ jsxs9(
|
|
7161
7524
|
"div",
|
|
7162
7525
|
{
|
|
7163
7526
|
"data-ohw-section-insert-line": "",
|
|
@@ -7182,12 +7545,11 @@ function OhhwellsBridge() {
|
|
|
7182
7545
|
]
|
|
7183
7546
|
}
|
|
7184
7547
|
),
|
|
7185
|
-
linkPopover ? /* @__PURE__ */ jsx16(
|
|
7548
|
+
linkPopover && dialogPortalContainer ? /* @__PURE__ */ jsx16(
|
|
7186
7549
|
LinkPopover,
|
|
7187
7550
|
{
|
|
7188
|
-
rect: linkPopover.rect,
|
|
7189
|
-
parentScroll: parentScrollRef.current,
|
|
7190
7551
|
panelRef: linkPopoverPanelRef,
|
|
7552
|
+
portalContainer: dialogPortalContainer,
|
|
7191
7553
|
open: true,
|
|
7192
7554
|
mode: "edit",
|
|
7193
7555
|
pages: sitePages,
|
|
@@ -7196,8 +7558,34 @@ function OhhwellsBridge() {
|
|
|
7196
7558
|
initialTarget: linkPopover.target,
|
|
7197
7559
|
onClose: closeLinkPopover,
|
|
7198
7560
|
onSubmit: handleLinkPopoverSubmit
|
|
7561
|
+
},
|
|
7562
|
+
`${linkPopover.key}-${pathname}`
|
|
7563
|
+
) : null,
|
|
7564
|
+
sectionGap && /* @__PURE__ */ jsxs9(
|
|
7565
|
+
"div",
|
|
7566
|
+
{
|
|
7567
|
+
"data-ohw-section-insert-line": "",
|
|
7568
|
+
className: "fixed left-0 w-full z-2147483646 flex items-center pointer-events-none",
|
|
7569
|
+
style: { top: sectionGap.y, transform: "translateY(-50%)" },
|
|
7570
|
+
children: [
|
|
7571
|
+
/* @__PURE__ */ jsx16("div", { className: "flex-1 bg-primary", style: { height: 3 } }),
|
|
7572
|
+
/* @__PURE__ */ jsx16(
|
|
7573
|
+
Badge,
|
|
7574
|
+
{
|
|
7575
|
+
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",
|
|
7576
|
+
onClick: () => {
|
|
7577
|
+
window.parent.postMessage(
|
|
7578
|
+
{ type: "ow:add-section", insertAfter: sectionGap.insertAfter, insertBefore: sectionGap.insertBefore },
|
|
7579
|
+
"*"
|
|
7580
|
+
);
|
|
7581
|
+
},
|
|
7582
|
+
children: "Add Section"
|
|
7583
|
+
}
|
|
7584
|
+
),
|
|
7585
|
+
/* @__PURE__ */ jsx16("div", { className: "flex-1 bg-primary", style: { height: 3 } })
|
|
7586
|
+
]
|
|
7199
7587
|
}
|
|
7200
|
-
)
|
|
7588
|
+
)
|
|
7201
7589
|
] }),
|
|
7202
7590
|
bridgeRoot
|
|
7203
7591
|
) : null;
|