@ohhwells/bridge 0.1.40 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  CustomToolbarButton: () => CustomToolbarButton,
36
36
  CustomToolbarDivider: () => CustomToolbarDivider,
37
37
  DragHandle: () => DragHandle,
38
+ DropIndicator: () => DropIndicator,
38
39
  ItemActionToolbar: () => ItemActionToolbar,
39
40
  ItemInteractionLayer: () => ItemInteractionLayer,
40
41
  LinkEditorPanel: () => LinkEditorPanel,
@@ -49,6 +50,7 @@ __export(index_exports, {
49
50
  TooltipProvider: () => TooltipProvider,
50
51
  TooltipTrigger: () => TooltipTrigger,
51
52
  buildTarget: () => buildTarget,
53
+ dropIndicatorVariants: () => dropIndicatorVariants,
52
54
  filterAvailablePages: () => filterAvailablePages,
53
55
  getEditModeInitialState: () => getEditModeInitialState,
54
56
  isEditSessionActive: () => isEditSessionActive,
@@ -7073,6 +7075,22 @@ function placeCaretAtPoint(el, x, y) {
7073
7075
  }
7074
7076
  }
7075
7077
  }
7078
+ function selectAllTextInEditable(el) {
7079
+ const selection = window.getSelection();
7080
+ if (!selection) return;
7081
+ const range = document.createRange();
7082
+ range.selectNodeContents(el);
7083
+ selection.removeAllRanges();
7084
+ selection.addRange(range);
7085
+ }
7086
+ function getNavigationLabelEditable(target) {
7087
+ const editable = target.closest('[data-ohw-editable="text"]');
7088
+ if (!editable) return null;
7089
+ const hrefCtx = getHrefKeyFromElement(editable);
7090
+ const navAnchor = hrefCtx ? getNavigationItemAnchor(hrefCtx.anchor) : null;
7091
+ if (!navAnchor) return null;
7092
+ return { editable, navAnchor };
7093
+ }
7076
7094
  function collectSections() {
7077
7095
  return collectSectionsFromDom();
7078
7096
  }
@@ -8217,6 +8235,7 @@ function OhhwellsBridge() {
8217
8235
  e.preventDefault();
8218
8236
  e.stopPropagation();
8219
8237
  if (selectedElRef.current === navAnchor) {
8238
+ if (e.detail >= 2) return;
8220
8239
  activateRef.current(editable, { caretX: e.clientX, caretY: e.clientY });
8221
8240
  return;
8222
8241
  }
@@ -8277,6 +8296,28 @@ function OhhwellsBridge() {
8277
8296
  deselectRef.current();
8278
8297
  deactivateRef.current();
8279
8298
  };
8299
+ const handleDblClick = (e) => {
8300
+ const target = e.target;
8301
+ if (target.closest("[data-ohw-toolbar]")) return;
8302
+ if (target.closest("[data-ohw-state-toggle]")) return;
8303
+ if (target.closest("[data-ohw-max-badge]")) return;
8304
+ if (isInsideLinkEditor(target)) return;
8305
+ if (target.closest('[data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-drag-handle-container], [data-slot="drag-handle"]')) {
8306
+ return;
8307
+ }
8308
+ const navLabel = getNavigationLabelEditable(target);
8309
+ if (!navLabel) return;
8310
+ const { editable } = navLabel;
8311
+ e.preventDefault();
8312
+ e.stopPropagation();
8313
+ if (activeElRef.current !== editable) {
8314
+ activateRef.current(editable);
8315
+ }
8316
+ requestAnimationFrame(() => {
8317
+ selectAllTextInEditable(editable);
8318
+ refreshActiveCommandsRef.current();
8319
+ });
8320
+ };
8280
8321
  const handleMouseOver = (e) => {
8281
8322
  if (document.documentElement.hasAttribute("data-ohw-section-picking")) return;
8282
8323
  const target = e.target;
@@ -8998,6 +9039,15 @@ function OhhwellsBridge() {
8998
9039
  window.addEventListener("message", handleUiEscape);
8999
9040
  const handleKeyDown = (e) => {
9000
9041
  if (e.key === "Escape" && document.querySelector("[data-ohw-section-picker]")) return;
9042
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" && activeElRef.current) {
9043
+ const navAnchor = getNavigationItemAnchor(activeElRef.current);
9044
+ if (navAnchor) {
9045
+ e.preventDefault();
9046
+ selectAllTextInEditable(activeElRef.current);
9047
+ refreshActiveCommandsRef.current();
9048
+ return;
9049
+ }
9050
+ }
9001
9051
  if (e.key === "Escape" && linkPopoverOpenRef.current) {
9002
9052
  setLinkPopoverRef.current(null);
9003
9053
  return;
@@ -9330,6 +9380,7 @@ function OhhwellsBridge() {
9330
9380
  };
9331
9381
  window.addEventListener("resize", handleViewportResize, { passive: true });
9332
9382
  document.addEventListener("click", handleClick, true);
9383
+ document.addEventListener("dblclick", handleDblClick, true);
9333
9384
  document.addEventListener("paste", handlePaste, true);
9334
9385
  document.addEventListener("input", handleInput, true);
9335
9386
  document.addEventListener("mouseover", handleMouseOver, true);
@@ -9344,6 +9395,7 @@ function OhhwellsBridge() {
9344
9395
  window.addEventListener("scroll", handleScroll, true);
9345
9396
  return () => {
9346
9397
  document.removeEventListener("click", handleClick, true);
9398
+ document.removeEventListener("dblclick", handleDblClick, true);
9347
9399
  document.removeEventListener("paste", handlePaste, true);
9348
9400
  document.removeEventListener("input", handleInput, true);
9349
9401
  document.removeEventListener("mouseover", handleMouseOver, true);
@@ -9730,12 +9782,55 @@ function OhhwellsBridge() {
9730
9782
  bridgeRoot
9731
9783
  ) : null;
9732
9784
  }
9785
+
9786
+ // src/ui/drop-indicator.tsx
9787
+ var React10 = __toESM(require("react"), 1);
9788
+ var import_jsx_runtime24 = require("react/jsx-runtime");
9789
+ var dropIndicatorVariants = cva(
9790
+ "ov-gap-line pointer-events-none shrink-0 transition-opacity duration-150",
9791
+ {
9792
+ variants: {
9793
+ direction: {
9794
+ vertical: "h-6 w-[3px]",
9795
+ horizontal: "h-[3px] w-[200px]"
9796
+ },
9797
+ state: {
9798
+ default: "opacity-0",
9799
+ hover: "opacity-100",
9800
+ dragIdle: "opacity-40",
9801
+ dragActive: "opacity-100"
9802
+ }
9803
+ },
9804
+ defaultVariants: {
9805
+ direction: "vertical",
9806
+ state: "default"
9807
+ }
9808
+ }
9809
+ );
9810
+ var DropIndicator = React10.forwardRef(
9811
+ ({ className, direction, state, ...props }, ref) => {
9812
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
9813
+ "div",
9814
+ {
9815
+ ref,
9816
+ "data-slot": "drop-indicator",
9817
+ "data-direction": direction ?? "vertical",
9818
+ "data-state": state ?? "default",
9819
+ "aria-hidden": "true",
9820
+ className: cn(dropIndicatorVariants({ direction, state }), className),
9821
+ ...props
9822
+ }
9823
+ );
9824
+ }
9825
+ );
9826
+ DropIndicator.displayName = "DropIndicator";
9733
9827
  // Annotate the CommonJS export names for ESM import in node:
9734
9828
  0 && (module.exports = {
9735
9829
  CustomToolbar,
9736
9830
  CustomToolbarButton,
9737
9831
  CustomToolbarDivider,
9738
9832
  DragHandle,
9833
+ DropIndicator,
9739
9834
  ItemActionToolbar,
9740
9835
  ItemInteractionLayer,
9741
9836
  LinkEditorPanel,
@@ -9750,6 +9845,7 @@ function OhhwellsBridge() {
9750
9845
  TooltipProvider,
9751
9846
  TooltipTrigger,
9752
9847
  buildTarget,
9848
+ dropIndicatorVariants,
9753
9849
  filterAvailablePages,
9754
9850
  getEditModeInitialState,
9755
9851
  isEditSessionActive,