@ohhwells/bridge 0.1.30 → 0.1.31

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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  // src/OhhwellsBridge.tsx
4
- import React5, { useCallback as useCallback2, useEffect as useEffect3, useLayoutEffect, useRef as useRef3, useState as useState5 } from "react";
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/link-modal/calcPopoverPos.ts
4445
- function calcPopoverPos(rect, parentScroll, approxW = 483, approxH = 320) {
4446
- const GAP = 8;
4447
- const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
4448
- const visibleTop = rect.top - canvasTopInIframe;
4449
- let top = rect.top - GAP;
4450
- let transform = "translateX(-50%) translateY(-100%)";
4451
- if (visibleTop < approxH + GAP) {
4452
- top = rect.bottom + GAP;
4453
- transform = "translateX(-50%)";
4454
- }
4455
- const rawLeft = rect.left + rect.width / 2;
4456
- const left = Math.max(GAP + approxW / 2, Math.min(rawLeft, window.innerWidth - GAP - approxW / 2));
4457
- return { top, left, transform };
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 React3 from "react";
4570
+ import * as React4 from "react";
4462
4571
  import { Slot } from "radix-ui";
4463
- import { jsx as jsx5 } from "react/jsx-runtime";
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 = React3.forwardRef(
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__ */ jsx5(
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 jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
4610
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
4540
4611
  function DestinationBreadcrumb({ pageTitle, sectionLabel }) {
4541
- return /* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col gap-2", children: [
4542
- /* @__PURE__ */ jsx7("p", { className: "text-sm font-medium text-foreground", children: "Destination" }),
4543
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-3", children: [
4544
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
4545
- /* @__PURE__ */ jsx7(IconFile, { className: "shrink-0 text-foreground", "aria-hidden": true }),
4546
- /* @__PURE__ */ jsx7("span", { className: "text-sm font-medium leading-none text-foreground", children: pageTitle })
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__ */ jsx7(IconArrowRight, { className: "shrink-0 text-muted-foreground", "aria-hidden": true }),
4549
- /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
4550
- /* @__PURE__ */ jsx7(IconSection, { className: "shrink-0 text-foreground", "aria-hidden": true }),
4551
- /* @__PURE__ */ jsx7("span", { className: "truncate text-sm font-medium leading-none text-foreground", children: sectionLabel })
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 jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
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__ */ jsxs5("div", { className: "flex h-9 w-full items-end pl-3", children: [
4562
- /* @__PURE__ */ jsx8(
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__ */ jsxs5(
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__ */ jsx8(IconSection, { className: "shrink-0 text-foreground", "aria-hidden": true }),
4588
- /* @__PURE__ */ jsx8("span", { className: "truncate text-sm font-normal leading-5 text-foreground", children: section.label })
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__ */ jsx8("p", { className: "text-sm text-muted-foreground", children: "No sections found on this page." });
4667
+ return /* @__PURE__ */ jsx9("p", { className: "text-sm text-muted-foreground", children: "No sections found on this page." });
4597
4668
  }
4598
- return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1", children: [
4599
- /* @__PURE__ */ jsx8("p", { className: "text-sm text-muted-foreground", children: "Pick a section this link should scroll to." }),
4600
- sections.map((section) => /* @__PURE__ */ jsx8(SectionTreeItem, { section, onSelect }, section.id))
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 React4 from "react";
4609
- import { jsx as jsx9 } from "react/jsx-runtime";
4610
- var Input = React4.forwardRef(
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__ */ jsx9(
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 jsx10 } from "react/jsx-runtime";
4702
+ import { jsx as jsx11 } from "react/jsx-runtime";
4632
4703
  function Label({ className, ...props }) {
4633
- return /* @__PURE__ */ jsx10(
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 jsxs6 } from "react/jsx-runtime";
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__ */ jsxs6("div", { className: "flex w-full flex-col gap-2 p-0", children: [
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__ */ jsxs6(Popover, { open: dropdownOpen && !readOnly, onOpenChange: onDropdownOpenChange, children: [
4726
- /* @__PURE__ */ jsx12(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs6("div", { "data-ohw-link-field": true, className: fieldClassName, children: [
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 && /* @__PURE__ */ jsx12(PopoverContent, { "data-ohw-link-popover-root": "", onOpenAutoFocus: (e) => e.preventDefault(), children: filteredPages.map((page) => /* @__PURE__ */ jsxs6(
4761
- "button",
4800
+ ] }),
4801
+ dropdownOpen && !readOnly && filteredPages.length > 0 ? /* @__PURE__ */ jsx12(
4802
+ "div",
4762
4803
  {
4763
- type: "button",
4764
- 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",
4765
- onClick: () => onPageSelect(page),
4766
- children: [
4767
- /* @__PURE__ */ jsx12(IconFile, { className: "shrink-0", "aria-hidden": true }),
4768
- /* @__PURE__ */ jsx12("span", { className: "truncate", children: page.title })
4769
- ]
4770
- },
4771
- page.path
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 jsxs7 } from "react/jsx-runtime";
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__ */ jsxs7(Fragment2, { children: [
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("header", { className: "flex w-full flex-col gap-1.5 p-6 pr-12", children: /* @__PURE__ */ jsx13("h2", { className: "m-0 w-full break-words text-lg font-semibold leading-none tracking-tight text-card-foreground", children: state.title }) }),
4978
- /* @__PURE__ */ jsxs7("div", { className: "flex w-full flex-col gap-3 px-6 pb-8 pt-1", children: [
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__ */ jsxs7("div", { className: "flex flex-col justify-center gap-2", children: [
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__ */ jsxs7("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
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__ */ jsxs7("footer", { className: "flex w-full items-center justify-end gap-2 px-6 pb-6", children: [
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
- rect,
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
- "div",
5100
+ Dialog2,
5053
5101
  {
5054
- ref: panelRef,
5055
- "data-ohw-link-popover-root": "",
5056
- "data-ohw-link-modal-root": "",
5057
- "data-ohw-bridge": "",
5058
- className: cn(
5059
- "pointer-events-auto fixed z-[2147483647] flex w-[483px] max-w-[calc(100vw-16px)] flex-col overflow-hidden",
5060
- "rounded-xl border border-border bg-background font-sans shadow-lg outline-none"
5061
- ),
5062
- style: { top, left, transform },
5063
- onMouseDown: (e) => e.stopPropagation(),
5064
- children: /* @__PURE__ */ jsx14(LinkEditorPanel, { ...editorProps, open: true })
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 jsxs8 } from "react/jsx-runtime";
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
  }
@@ -5579,41 +5642,191 @@ function GlowFrame({ rect, elRef }) {
5579
5642
  }
5580
5643
  );
5581
5644
  }
5582
- function calcToolbarPos(rect, parentScroll) {
5645
+ function getIframeVisibleClip(parentScroll) {
5646
+ if (!parentScroll) return null;
5647
+ const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH } = parentScroll;
5648
+ const clipTop = Math.max(0, visibleCanvasTop - iframeOffsetTop);
5649
+ const clipBottom = Math.min(
5650
+ window.innerHeight,
5651
+ visibleCanvasTop + canvasH - iframeOffsetTop
5652
+ );
5653
+ return { top: clipTop, bottom: Math.max(clipTop, clipBottom) };
5654
+ }
5655
+ function applyVisibleViewport(el, parentScroll) {
5656
+ const clip = getIframeVisibleClip(parentScroll);
5657
+ const top = clip?.top ?? 0;
5658
+ const height = clip ? clip.bottom - clip.top : window.innerHeight;
5659
+ el.style.top = `${top}px`;
5660
+ el.style.height = `${height}px`;
5661
+ }
5662
+ function clampToolbarToClip(top, transform, rect, clip, approxH, gap) {
5663
+ const isAbove = transform.includes("translateY(-100%)");
5664
+ let visualTop = isAbove ? top - approxH : top;
5665
+ let visualBottom = isAbove ? top : top + approxH;
5666
+ const minTop = clip.top + gap;
5667
+ const maxBottom = clip.bottom - gap;
5668
+ if (visualTop >= minTop && visualBottom <= maxBottom) {
5669
+ return { top, transform };
5670
+ }
5671
+ const belowTop = rect.bottom + gap;
5672
+ if (belowTop + approxH <= maxBottom && belowTop >= minTop) {
5673
+ return { top: belowTop, transform: "translateX(-50%)" };
5674
+ }
5675
+ const aboveTop = rect.top - gap;
5676
+ if (aboveTop - approxH >= minTop && aboveTop <= maxBottom) {
5677
+ return { top: aboveTop, transform: "translateX(-50%) translateY(-100%)" };
5678
+ }
5679
+ if (belowTop + approxH <= maxBottom) {
5680
+ return { top: belowTop, transform: "translateX(-50%)" };
5681
+ }
5682
+ const pinnedTop = Math.min(maxBottom - approxH, Math.max(minTop, clip.top + gap));
5683
+ return { top: pinnedTop + approxH, transform: "translateX(-50%) translateY(-100%)" };
5684
+ }
5685
+ function calcToolbarPos(rect, parentScroll, approxW = 330) {
5583
5686
  const GAP = 8;
5584
5687
  const APPROX_H = 36;
5585
- const APPROX_W = 330;
5688
+ const APPROX_W = approxW;
5689
+ const clip = getIframeVisibleClip(parentScroll);
5690
+ const clipTop = clip?.top ?? 0;
5586
5691
  const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
5587
5692
  const visibleTop = rect.top - canvasTopInIframe;
5588
5693
  const visibleBottom = rect.bottom - canvasTopInIframe;
5589
5694
  const isTall = rect.height > APPROX_H + GAP;
5695
+ const spaceAbove = rect.top - (clipTop + GAP);
5696
+ const fitsAbove = spaceAbove >= APPROX_H + GAP;
5590
5697
  let top;
5591
5698
  let transform;
5592
- if (visibleTop > 0 || !isTall) {
5699
+ if ((visibleTop > 0 || !isTall) && fitsAbove) {
5593
5700
  top = rect.top - GAP;
5594
5701
  transform = "translateX(-50%) translateY(-100%)";
5702
+ } else if (visibleTop > 0 || !isTall) {
5703
+ top = rect.bottom + GAP;
5704
+ transform = "translateX(-50%)";
5595
5705
  } else if (visibleBottom > APPROX_H + GAP) {
5596
- top = canvasTopInIframe + GAP;
5706
+ top = clipTop + GAP;
5597
5707
  transform = "translateX(-50%)";
5598
5708
  } else {
5599
5709
  top = rect.bottom + GAP;
5600
5710
  transform = "translateX(-50%)";
5601
5711
  }
5712
+ if (clip) {
5713
+ const clamped = clampToolbarToClip(top, transform, rect, clip, APPROX_H, GAP);
5714
+ top = clamped.top;
5715
+ transform = clamped.transform;
5716
+ }
5602
5717
  const rawLeft = rect.left + rect.width / 2;
5603
5718
  const left = Math.max(GAP + APPROX_W / 2, Math.min(rawLeft, window.innerWidth - GAP - APPROX_W / 2));
5604
5719
  return { top, left, transform };
5605
5720
  }
5721
+ 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: [
5722
+ /* @__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" }),
5723
+ /* @__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" })
5724
+ ] });
5606
5725
  function FloatingToolbar({
5607
5726
  rect,
5608
5727
  parentScroll,
5609
5728
  elRef,
5729
+ variant = "rich-text",
5610
5730
  onCommand,
5611
5731
  activeCommands,
5612
5732
  showEditLink,
5613
5733
  onEditLink
5614
5734
  }) {
5615
- const { top, left, transform } = calcToolbarPos(rect, parentScroll);
5616
- return /* @__PURE__ */ jsxs8(
5735
+ const approxW = variant === "link-action" ? 120 : 330;
5736
+ const { top, left, transform } = calcToolbarPos(rect, parentScroll, approxW);
5737
+ if (variant === "link-action") {
5738
+ return /* @__PURE__ */ jsxs9(
5739
+ "div",
5740
+ {
5741
+ ref: elRef,
5742
+ "data-ohw-toolbar": "",
5743
+ style: {
5744
+ position: "fixed",
5745
+ top,
5746
+ left,
5747
+ transform,
5748
+ zIndex: 2147483647,
5749
+ background: "#fff",
5750
+ border: "1px solid #E7E5E4",
5751
+ borderRadius: 6,
5752
+ boxShadow: "0px 2px 4px -2px rgba(0,0,0,.1),0px 4px 6px -1px rgba(0,0,0,.1)",
5753
+ display: "flex",
5754
+ alignItems: "center",
5755
+ padding: 4,
5756
+ gap: 6,
5757
+ fontFamily: "sans-serif",
5758
+ pointerEvents: "auto",
5759
+ whiteSpace: "nowrap"
5760
+ },
5761
+ onMouseDown: (e) => e.stopPropagation(),
5762
+ children: [
5763
+ /* @__PURE__ */ jsx16(
5764
+ "button",
5765
+ {
5766
+ type: "button",
5767
+ title: "Edit link",
5768
+ onMouseDown: (e) => {
5769
+ e.preventDefault();
5770
+ e.stopPropagation();
5771
+ onEditLink?.();
5772
+ },
5773
+ onClick: (e) => {
5774
+ e.preventDefault();
5775
+ e.stopPropagation();
5776
+ },
5777
+ onMouseEnter: (e) => {
5778
+ e.currentTarget.style.background = "#F5F5F4";
5779
+ },
5780
+ onMouseLeave: (e) => {
5781
+ e.currentTarget.style.background = "transparent";
5782
+ },
5783
+ style: {
5784
+ display: "flex",
5785
+ alignItems: "center",
5786
+ justifyContent: "center",
5787
+ border: "none",
5788
+ background: "transparent",
5789
+ borderRadius: 4,
5790
+ cursor: "pointer",
5791
+ color: "#1C1917",
5792
+ flexShrink: 0,
5793
+ padding: 6
5794
+ },
5795
+ children: EDIT_LINK_ICON
5796
+ }
5797
+ ),
5798
+ /* @__PURE__ */ jsx16("span", { style: { display: "block", width: 1, height: 24, background: "#E7E5E4", flexShrink: 0 } }),
5799
+ /* @__PURE__ */ jsx16(
5800
+ "button",
5801
+ {
5802
+ type: "button",
5803
+ title: "Coming soon",
5804
+ disabled: true,
5805
+ style: {
5806
+ display: "flex",
5807
+ alignItems: "center",
5808
+ justifyContent: "center",
5809
+ border: "none",
5810
+ background: "transparent",
5811
+ borderRadius: 4,
5812
+ cursor: "not-allowed",
5813
+ color: "#A8A29E",
5814
+ flexShrink: 0,
5815
+ padding: 6,
5816
+ opacity: 0.6
5817
+ },
5818
+ children: /* @__PURE__ */ jsxs9("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: [
5819
+ /* @__PURE__ */ jsx16("circle", { cx: "5", cy: "12", r: "1.5" }),
5820
+ /* @__PURE__ */ jsx16("circle", { cx: "12", cy: "12", r: "1.5" }),
5821
+ /* @__PURE__ */ jsx16("circle", { cx: "19", cy: "12", r: "1.5" })
5822
+ ] })
5823
+ }
5824
+ )
5825
+ ]
5826
+ }
5827
+ );
5828
+ }
5829
+ return /* @__PURE__ */ jsxs9(
5617
5830
  "div",
5618
5831
  {
5619
5832
  ref: elRef,
@@ -5638,7 +5851,7 @@ function FloatingToolbar({
5638
5851
  },
5639
5852
  onMouseDown: (e) => e.stopPropagation(),
5640
5853
  children: [
5641
- TOOLBAR_GROUPS.map((btns, gi) => /* @__PURE__ */ jsxs8(React5.Fragment, { children: [
5854
+ TOOLBAR_GROUPS.map((btns, gi) => /* @__PURE__ */ jsxs9(React6.Fragment, { children: [
5642
5855
  gi > 0 && /* @__PURE__ */ jsx16("span", { style: { display: "block", width: 1, height: 24, background: "#E7E5E4", flexShrink: 0 } }),
5643
5856
  btns.map((btn) => {
5644
5857
  const isActive = activeCommands.has(btn.cmd);
@@ -5720,10 +5933,7 @@ function FloatingToolbar({
5720
5933
  flexShrink: 0,
5721
5934
  padding: 6
5722
5935
  },
5723
- children: /* @__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: [
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
- ] })
5936
+ children: EDIT_LINK_ICON
5727
5937
  }
5728
5938
  ) : null
5729
5939
  ]
@@ -5814,9 +6024,17 @@ function OhhwellsBridge() {
5814
6024
  const [fetchState, setFetchState] = useState5("idle");
5815
6025
  const autoSaveTimers = useRef3(/* @__PURE__ */ new Map());
5816
6026
  const activeElRef = useRef3(null);
6027
+ const selectedElRef = useRef3(null);
5817
6028
  const originalContentRef = useRef3(null);
5818
6029
  const activeStateElRef = useRef3(null);
5819
6030
  const parentScrollRef = useRef3(null);
6031
+ const visibleViewportRef = useRef3(null);
6032
+ const [dialogPortalContainer, setDialogPortalContainer] = useState5(null);
6033
+ const attachVisibleViewport = useCallback2((node) => {
6034
+ visibleViewportRef.current = node;
6035
+ setDialogPortalContainer(node);
6036
+ if (node) applyVisibleViewport(node, parentScrollRef.current);
6037
+ }, []);
5820
6038
  const toolbarElRef = useRef3(null);
5821
6039
  const glowElRef = useRef3(null);
5822
6040
  const hoveredImageRef = useRef3(null);
@@ -5829,6 +6047,10 @@ function OhhwellsBridge() {
5829
6047
  });
5830
6048
  const deactivateRef = useRef3(() => {
5831
6049
  });
6050
+ const selectRef = useRef3(() => {
6051
+ });
6052
+ const deselectRef = useRef3(() => {
6053
+ });
5832
6054
  const refreshActiveCommandsRef = useRef3(() => {
5833
6055
  });
5834
6056
  const postToParentRef = useRef3(postToParent);
@@ -5836,6 +6058,9 @@ function OhhwellsBridge() {
5836
6058
  const sectionsLoadedRef = useRef3(false);
5837
6059
  const pendingScheduleConfigRequests = useRef3([]);
5838
6060
  const [toolbarRect, setToolbarRect] = useState5(null);
6061
+ const [toolbarVariant, setToolbarVariant] = useState5("none");
6062
+ const toolbarVariantRef = useRef3("none");
6063
+ toolbarVariantRef.current = toolbarVariant;
5839
6064
  const [toggleState, setToggleState] = useState5(null);
5840
6065
  const [maxBadge, setMaxBadge] = useState5(null);
5841
6066
  const [activeCommands, setActiveCommands] = useState5(/* @__PURE__ */ new Set());
@@ -5880,7 +6105,33 @@ function OhhwellsBridge() {
5880
6105
  hoveredImageRef.current = null;
5881
6106
  hoveredImageHasTextOverlapRef.current = false;
5882
6107
  }
6108
+ hoveredGapRef.current = null;
6109
+ setSectionGap(null);
5883
6110
  postToParent({ type: "ow:image-unhover" });
6111
+ postToParent({ type: "ow:link-modal-lock", locked: true });
6112
+ const html = document.documentElement;
6113
+ const body = document.body;
6114
+ const prevHtmlOverflow = html.style.overflow;
6115
+ const prevBodyOverflow = body.style.overflow;
6116
+ html.style.overflow = "hidden";
6117
+ body.style.overflow = "hidden";
6118
+ const preventBackgroundScroll = (e) => {
6119
+ const target = e.target;
6120
+ if (target instanceof Element && target.closest('[data-ohw-link-modal-root], [data-slot="dialog-overlay"]')) {
6121
+ return;
6122
+ }
6123
+ e.preventDefault();
6124
+ };
6125
+ const scrollOpts = { passive: false, capture: true };
6126
+ document.addEventListener("wheel", preventBackgroundScroll, scrollOpts);
6127
+ document.addEventListener("touchmove", preventBackgroundScroll, scrollOpts);
6128
+ return () => {
6129
+ postToParent({ type: "ow:link-modal-lock", locked: false });
6130
+ html.style.overflow = prevHtmlOverflow;
6131
+ body.style.overflow = prevBodyOverflow;
6132
+ document.removeEventListener("wheel", preventBackgroundScroll, scrollOpts);
6133
+ document.removeEventListener("touchmove", preventBackgroundScroll, scrollOpts);
6134
+ };
5884
6135
  }, [linkPopover, postToParent]);
5885
6136
  useEffect3(() => {
5886
6137
  if (!isEditMode) return;
@@ -5915,7 +6166,7 @@ function OhhwellsBridge() {
5915
6166
  }, [isEditMode]);
5916
6167
  useEffect3(() => {
5917
6168
  const update = () => {
5918
- const el = activeElRef.current;
6169
+ const el = activeElRef.current ?? selectedElRef.current;
5919
6170
  if (el) setToolbarRect(el.getBoundingClientRect());
5920
6171
  setToggleState((prev) => {
5921
6172
  if (!prev || !activeStateElRef.current) return prev;
@@ -5983,19 +6234,41 @@ function OhhwellsBridge() {
5983
6234
  }
5984
6235
  el.removeAttribute("contenteditable");
5985
6236
  activeElRef.current = null;
5986
- setToolbarRect(null);
6237
+ if (!selectedElRef.current) {
6238
+ setToolbarRect(null);
6239
+ setToolbarVariant("none");
6240
+ }
5987
6241
  setMaxBadge(null);
5988
6242
  setActiveCommands(/* @__PURE__ */ new Set());
5989
6243
  setToolbarShowEditLink(false);
5990
6244
  postToParent({ type: "ow:exit-edit" });
5991
6245
  }, [postToParent]);
6246
+ const deselect = useCallback2(() => {
6247
+ selectedElRef.current = null;
6248
+ if (!activeElRef.current) {
6249
+ setToolbarRect(null);
6250
+ setToolbarVariant("none");
6251
+ }
6252
+ }, []);
6253
+ const select = useCallback2((anchor) => {
6254
+ if (!isNavbarButton(anchor)) return;
6255
+ if (activeElRef.current) deactivate();
6256
+ selectedElRef.current = anchor;
6257
+ clearHrefKeyHover(anchor);
6258
+ setToolbarVariant("link-action");
6259
+ setToolbarRect(anchor.getBoundingClientRect());
6260
+ setToolbarShowEditLink(false);
6261
+ setActiveCommands(/* @__PURE__ */ new Set());
6262
+ }, [deactivate]);
5992
6263
  const activate = useCallback2((el) => {
5993
6264
  if (activeElRef.current === el) return;
6265
+ selectedElRef.current = null;
5994
6266
  deactivate();
5995
6267
  if (hoveredImageRef.current) {
5996
6268
  hoveredImageRef.current = null;
5997
6269
  postToParentRef.current({ type: "ow:image-unhover" });
5998
6270
  }
6271
+ setToolbarVariant("rich-text");
5999
6272
  el.setAttribute("contenteditable", "true");
6000
6273
  el.removeAttribute("data-ohw-hovered");
6001
6274
  activeElRef.current = el;
@@ -6008,6 +6281,8 @@ function OhhwellsBridge() {
6008
6281
  }, [deactivate, postToParent]);
6009
6282
  activateRef.current = activate;
6010
6283
  deactivateRef.current = deactivate;
6284
+ selectRef.current = select;
6285
+ deselectRef.current = deselect;
6011
6286
  useLayoutEffect(() => {
6012
6287
  if (!subdomain || isEditMode) {
6013
6288
  setFetchState("done");
@@ -6111,6 +6386,12 @@ function OhhwellsBridge() {
6111
6386
  useEffect3(() => {
6112
6387
  postToParent({ type: "ow:navigation", path: pathname });
6113
6388
  }, [pathname, postToParent]);
6389
+ useEffect3(() => {
6390
+ if (!isEditMode) return;
6391
+ setLinkPopover(null);
6392
+ deselectRef.current();
6393
+ deactivateRef.current();
6394
+ }, [pathname, isEditMode]);
6114
6395
  useEffect3(() => {
6115
6396
  if (!isEditMode) return;
6116
6397
  const measure = () => {
@@ -6221,12 +6502,12 @@ function OhhwellsBridge() {
6221
6502
  if (editable.dataset.ohwEditable === "link") {
6222
6503
  e.preventDefault();
6223
6504
  e.stopPropagation();
6505
+ deselectRef.current();
6224
6506
  deactivateRef.current();
6225
6507
  bumpLinkPopoverGrace();
6226
6508
  setLinkPopoverRef.current({
6227
6509
  key: editable.dataset.ohwKey ?? "",
6228
- target: getLinkHref(editable),
6229
- rect: editable.getBoundingClientRect()
6510
+ target: getLinkHref(editable)
6230
6511
  });
6231
6512
  return;
6232
6513
  }
@@ -6236,11 +6517,31 @@ function OhhwellsBridge() {
6236
6517
  postToParentRef.current({ type: "ow:image-pick", key: editable.dataset.ohwKey ?? "" });
6237
6518
  return;
6238
6519
  }
6520
+ const hrefCtx = getHrefKeyFromElement(editable);
6521
+ if (hrefCtx && isNavbarButton(hrefCtx.anchor)) {
6522
+ e.preventDefault();
6523
+ e.stopPropagation();
6524
+ const { anchor: anchor2 } = hrefCtx;
6525
+ if (selectedElRef.current === anchor2) {
6526
+ activateRef.current(editable);
6527
+ return;
6528
+ }
6529
+ selectRef.current(anchor2);
6530
+ return;
6531
+ }
6239
6532
  e.preventDefault();
6240
6533
  e.stopPropagation();
6241
6534
  activateRef.current(editable);
6242
6535
  return;
6243
6536
  }
6537
+ const hrefAnchor = target.closest("[data-ohw-href-key]");
6538
+ if (hrefAnchor && isNavbarButton(hrefAnchor)) {
6539
+ e.preventDefault();
6540
+ e.stopPropagation();
6541
+ if (selectedElRef.current === hrefAnchor) return;
6542
+ selectRef.current(hrefAnchor);
6543
+ return;
6544
+ }
6244
6545
  if (activeElRef.current) {
6245
6546
  const sel = window.getSelection();
6246
6547
  if (sel && !sel.isCollapsed) {
@@ -6255,15 +6556,22 @@ function OhhwellsBridge() {
6255
6556
  const hrefCtx = getHrefKeyFromElement(activeElRef.current);
6256
6557
  if (hrefCtx && (hrefCtx.anchor === target || hrefCtx.anchor.contains(target))) return;
6257
6558
  }
6559
+ if (linkPopoverOpenRef.current && selectedElRef.current) {
6560
+ const selected = selectedElRef.current;
6561
+ if (selected === target || selected.contains(target)) return;
6562
+ }
6258
6563
  if (linkPopoverOpenRef.current) {
6259
6564
  setLinkPopoverRef.current(null);
6260
6565
  return;
6261
6566
  }
6567
+ deselectRef.current();
6262
6568
  deactivateRef.current();
6263
6569
  };
6264
6570
  const handleMouseOver = (e) => {
6265
6571
  const editable = e.target.closest("[data-ohw-editable]");
6266
6572
  if (!editable) return;
6573
+ const selected = selectedElRef.current;
6574
+ if (selected && (selected === editable || selected.contains(editable))) return;
6267
6575
  if (editable.dataset.ohwEditable !== "image" && editable.dataset.ohwEditable !== "bg-image" && !editable.hasAttribute("contenteditable")) {
6268
6576
  editable.setAttribute("data-ohw-hovered", "");
6269
6577
  }
@@ -6399,7 +6707,7 @@ function OhhwellsBridge() {
6399
6707
  }
6400
6708
  return;
6401
6709
  }
6402
- if (topEl?.closest("[data-ohw-link-popover-root]") || topEl?.closest("[data-ohw-link-modal-root]")) {
6710
+ if (topEl?.closest("[data-ohw-link-popover-root]") || topEl?.closest("[data-ohw-link-modal-root]") || topEl?.closest("[data-ohw-link-page-dropdown]")) {
6403
6711
  if (hoveredImageRef.current) {
6404
6712
  hoveredImageRef.current = null;
6405
6713
  hoveredImageHasTextOverlapRef.current = false;
@@ -6527,6 +6835,13 @@ function OhhwellsBridge() {
6527
6835
  }
6528
6836
  };
6529
6837
  const probeSectionGapAt = (clientX, clientY, fromParentViewport = false) => {
6838
+ if (linkPopoverOpenRef.current) {
6839
+ if (hoveredGapRef.current) {
6840
+ hoveredGapRef.current = null;
6841
+ setSectionGap(null);
6842
+ }
6843
+ return;
6844
+ }
6530
6845
  const { y } = toProbeCoords(clientX, clientY, fromParentViewport);
6531
6846
  const sections = Array.from(document.querySelectorAll("[data-ohw-section]")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
6532
6847
  const ZONE = 20;
@@ -6750,6 +7065,7 @@ function OhhwellsBridge() {
6750
7065
  setLinkPopoverRef.current(null);
6751
7066
  return;
6752
7067
  }
7068
+ deselectRef.current();
6753
7069
  deactivateRef.current();
6754
7070
  };
6755
7071
  window.addEventListener("message", handleDeactivate);
@@ -6758,6 +7074,10 @@ function OhhwellsBridge() {
6758
7074
  setLinkPopoverRef.current(null);
6759
7075
  return;
6760
7076
  }
7077
+ if (e.key === "Escape" && selectedElRef.current && !activeElRef.current) {
7078
+ deselectRef.current();
7079
+ return;
7080
+ }
6761
7081
  if (e.key !== "Escape") return;
6762
7082
  const el = activeElRef.current;
6763
7083
  if (el && originalContentRef.current !== null) {
@@ -6767,13 +7087,16 @@ function OhhwellsBridge() {
6767
7087
  postToParentRef.current({ type: "ow:change", nodes: [{ key, text: originalContentRef.current }] });
6768
7088
  }
6769
7089
  }
7090
+ deselectRef.current();
6770
7091
  deactivateRef.current();
6771
7092
  };
6772
7093
  const handleScroll = () => {
6773
- if (activeElRef.current) {
6774
- const r2 = activeElRef.current.getBoundingClientRect();
7094
+ const focusEl = activeElRef.current ?? selectedElRef.current;
7095
+ if (focusEl) {
7096
+ const r2 = focusEl.getBoundingClientRect();
6775
7097
  applyToolbarPos(r2);
6776
- setMaxBadge((prev) => prev ? { ...prev, rect: r2 } : null);
7098
+ setToolbarRect(r2);
7099
+ setMaxBadge((prev) => prev && activeElRef.current ? { ...prev, rect: r2 } : prev);
6777
7100
  }
6778
7101
  if (activeStateElRef.current) {
6779
7102
  const rect = activeStateElRef.current.getBoundingClientRect();
@@ -6898,8 +7221,9 @@ function OhhwellsBridge() {
6898
7221
  };
6899
7222
  const applyToolbarPos = (rect) => {
6900
7223
  const ps = parentScrollRef.current;
7224
+ const approxW = toolbarVariantRef.current === "link-action" ? 120 : 330;
6901
7225
  if (toolbarElRef.current) {
6902
- const { top, left, transform } = calcToolbarPos(rect, ps);
7226
+ const { top, left, transform } = calcToolbarPos(rect, ps, approxW);
6903
7227
  toolbarElRef.current.style.top = `${top}px`;
6904
7228
  toolbarElRef.current.style.left = `${left}px`;
6905
7229
  toolbarElRef.current.style.transform = transform;
@@ -6914,7 +7238,11 @@ function OhhwellsBridge() {
6914
7238
  if (e.data?.type !== "ow:parent-scroll") return;
6915
7239
  const { iframeOffsetTop, headerH, canvasH } = e.data;
6916
7240
  parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
6917
- if (activeElRef.current) applyToolbarPos(activeElRef.current.getBoundingClientRect());
7241
+ if (visibleViewportRef.current) {
7242
+ applyVisibleViewport(visibleViewportRef.current, parentScrollRef.current);
7243
+ }
7244
+ const focusEl = activeElRef.current ?? selectedElRef.current;
7245
+ if (focusEl) applyToolbarPos(focusEl.getBoundingClientRect());
6918
7246
  };
6919
7247
  const handleClickAt = (e) => {
6920
7248
  if (e.data?.type !== "ow:click-at") return;
@@ -6964,6 +7292,12 @@ function OhhwellsBridge() {
6964
7292
  window.addEventListener("message", handleParentScroll);
6965
7293
  window.addEventListener("message", handlePointerSync);
6966
7294
  window.addEventListener("message", handleClickAt);
7295
+ const handleViewportResize = () => {
7296
+ if (visibleViewportRef.current) {
7297
+ applyVisibleViewport(visibleViewportRef.current, parentScrollRef.current);
7298
+ }
7299
+ };
7300
+ window.addEventListener("resize", handleViewportResize, { passive: true });
6967
7301
  document.addEventListener("click", handleClick, true);
6968
7302
  document.addEventListener("paste", handlePaste, true);
6969
7303
  document.addEventListener("input", handleInput, true);
@@ -7001,6 +7335,7 @@ function OhhwellsBridge() {
7001
7335
  window.removeEventListener("message", handleAnimLock);
7002
7336
  window.removeEventListener("message", handleCanvasHeight);
7003
7337
  window.removeEventListener("message", handleParentScroll);
7338
+ window.removeEventListener("resize", handleViewportResize);
7004
7339
  window.removeEventListener("message", handlePointerSync);
7005
7340
  window.removeEventListener("message", handleClickAt);
7006
7341
  window.removeEventListener("message", handleHydrate);
@@ -7088,10 +7423,22 @@ function OhhwellsBridge() {
7088
7423
  bumpLinkPopoverGrace();
7089
7424
  setLinkPopover({
7090
7425
  key: hrefCtx.key,
7091
- target: getLinkHref(hrefCtx.anchor),
7092
- rect: hrefCtx.anchor.getBoundingClientRect()
7426
+ target: getLinkHref(hrefCtx.anchor)
7093
7427
  });
7094
- }, []);
7428
+ deactivate();
7429
+ }, [deactivate]);
7430
+ const openLinkPopoverForSelected = useCallback2(() => {
7431
+ const anchor = selectedElRef.current;
7432
+ if (!anchor) return;
7433
+ const key = anchor.getAttribute("data-ohw-href-key");
7434
+ if (!key) return;
7435
+ bumpLinkPopoverGrace();
7436
+ setLinkPopover({
7437
+ key,
7438
+ target: getLinkHref(anchor)
7439
+ });
7440
+ deselect();
7441
+ }, [deselect]);
7095
7442
  const handleLinkPopoverSubmit = useCallback2(
7096
7443
  (target) => {
7097
7444
  if (!linkPopover) return;
@@ -7106,12 +7453,14 @@ function OhhwellsBridge() {
7106
7453
  const currentSections = sectionsByPath[pathname] ?? [];
7107
7454
  linkPopoverOpenRef.current = linkPopover !== null;
7108
7455
  return bridgeRoot ? createPortal(
7109
- /* @__PURE__ */ jsxs8(Fragment3, { children: [
7110
- toolbarRect && /* @__PURE__ */ jsxs8(Fragment3, { children: [
7456
+ /* @__PURE__ */ jsxs9(Fragment3, { children: [
7457
+ /* @__PURE__ */ jsx16("div", { ref: attachVisibleViewport, "data-ohw-visible-viewport": "", "aria-hidden": true }),
7458
+ toolbarRect && /* @__PURE__ */ jsxs9(Fragment3, { children: [
7111
7459
  /* @__PURE__ */ jsx16(GlowFrame, { rect: toolbarRect, elRef: glowElRef }),
7112
- /* @__PURE__ */ jsx16(
7460
+ toolbarVariant === "rich-text" && /* @__PURE__ */ jsx16(
7113
7461
  FloatingToolbar,
7114
7462
  {
7463
+ variant: "rich-text",
7115
7464
  rect: toolbarRect,
7116
7465
  parentScroll: parentScrollRef.current,
7117
7466
  elRef: toolbarElRef,
@@ -7120,9 +7469,21 @@ function OhhwellsBridge() {
7120
7469
  showEditLink,
7121
7470
  onEditLink: openLinkPopoverForActive
7122
7471
  }
7472
+ ),
7473
+ toolbarVariant === "link-action" && /* @__PURE__ */ jsx16(
7474
+ FloatingToolbar,
7475
+ {
7476
+ variant: "link-action",
7477
+ rect: toolbarRect,
7478
+ parentScroll: parentScrollRef.current,
7479
+ elRef: toolbarElRef,
7480
+ onCommand: handleCommand,
7481
+ activeCommands,
7482
+ onEditLink: openLinkPopoverForSelected
7483
+ }
7123
7484
  )
7124
7485
  ] }),
7125
- maxBadge && /* @__PURE__ */ jsxs8(
7486
+ maxBadge && /* @__PURE__ */ jsxs9(
7126
7487
  "div",
7127
7488
  {
7128
7489
  "data-ohw-max-badge": "",
@@ -7157,7 +7518,7 @@ function OhhwellsBridge() {
7157
7518
  onStateChange: handleStateChange
7158
7519
  }
7159
7520
  ),
7160
- sectionGap && /* @__PURE__ */ jsxs8(
7521
+ sectionGap && /* @__PURE__ */ jsxs9(
7161
7522
  "div",
7162
7523
  {
7163
7524
  "data-ohw-section-insert-line": "",
@@ -7182,12 +7543,11 @@ function OhhwellsBridge() {
7182
7543
  ]
7183
7544
  }
7184
7545
  ),
7185
- linkPopover ? /* @__PURE__ */ jsx16(
7546
+ linkPopover && dialogPortalContainer ? /* @__PURE__ */ jsx16(
7186
7547
  LinkPopover,
7187
7548
  {
7188
- rect: linkPopover.rect,
7189
- parentScroll: parentScrollRef.current,
7190
7549
  panelRef: linkPopoverPanelRef,
7550
+ portalContainer: dialogPortalContainer,
7191
7551
  open: true,
7192
7552
  mode: "edit",
7193
7553
  pages: sitePages,
@@ -7196,7 +7556,8 @@ function OhhwellsBridge() {
7196
7556
  initialTarget: linkPopover.target,
7197
7557
  onClose: closeLinkPopover,
7198
7558
  onSubmit: handleLinkPopoverSubmit
7199
- }
7559
+ },
7560
+ `${linkPopover.key}-${pathname}`
7200
7561
  ) : null
7201
7562
  ] }),
7202
7563
  bridgeRoot