@ohhwells/bridge 0.1.36-next.47 → 0.1.36-next.48

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
@@ -6075,6 +6075,22 @@ function placeCaretAtPoint(el, x, y) {
6075
6075
  }
6076
6076
  }
6077
6077
  }
6078
+ function selectAllTextInEditable(el) {
6079
+ const selection = window.getSelection();
6080
+ if (!selection) return;
6081
+ const range = document.createRange();
6082
+ range.selectNodeContents(el);
6083
+ selection.removeAllRanges();
6084
+ selection.addRange(range);
6085
+ }
6086
+ function getNavigationLabelEditable(target) {
6087
+ const editable = target.closest('[data-ohw-editable="text"]');
6088
+ if (!editable) return null;
6089
+ const hrefCtx = getHrefKeyFromElement(editable);
6090
+ const navAnchor = hrefCtx ? getNavigationItemAnchor(hrefCtx.anchor) : null;
6091
+ if (!navAnchor) return null;
6092
+ return { editable, navAnchor };
6093
+ }
6078
6094
  function collectSections() {
6079
6095
  return collectSectionsFromDom();
6080
6096
  }
@@ -7164,6 +7180,7 @@ function OhhwellsBridge() {
7164
7180
  e.preventDefault();
7165
7181
  e.stopPropagation();
7166
7182
  if (selectedElRef.current === navAnchor) {
7183
+ if (e.detail >= 2) return;
7167
7184
  activateRef.current(editable, { caretX: e.clientX, caretY: e.clientY });
7168
7185
  return;
7169
7186
  }
@@ -7217,6 +7234,28 @@ function OhhwellsBridge() {
7217
7234
  deselectRef.current();
7218
7235
  deactivateRef.current();
7219
7236
  };
7237
+ const handleDblClick = (e) => {
7238
+ const target = e.target;
7239
+ if (target.closest("[data-ohw-toolbar]")) return;
7240
+ if (target.closest("[data-ohw-state-toggle]")) return;
7241
+ if (target.closest("[data-ohw-max-badge]")) return;
7242
+ if (isInsideLinkEditor(target)) return;
7243
+ if (target.closest('[data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-drag-handle-container], [data-slot="drag-handle"]')) {
7244
+ return;
7245
+ }
7246
+ const navLabel = getNavigationLabelEditable(target);
7247
+ if (!navLabel) return;
7248
+ const { editable } = navLabel;
7249
+ e.preventDefault();
7250
+ e.stopPropagation();
7251
+ if (activeElRef.current !== editable) {
7252
+ activateRef.current(editable);
7253
+ }
7254
+ requestAnimationFrame(() => {
7255
+ selectAllTextInEditable(editable);
7256
+ refreshActiveCommandsRef.current();
7257
+ });
7258
+ };
7220
7259
  const handleMouseOver = (e) => {
7221
7260
  const target = e.target;
7222
7261
  const navAnchor = getNavigationItemAnchor(target);
@@ -7790,6 +7829,15 @@ function OhhwellsBridge() {
7790
7829
  };
7791
7830
  window.addEventListener("message", handleDeactivate);
7792
7831
  const handleKeyDown = (e) => {
7832
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" && activeElRef.current) {
7833
+ const navAnchor = getNavigationItemAnchor(activeElRef.current);
7834
+ if (navAnchor) {
7835
+ e.preventDefault();
7836
+ selectAllTextInEditable(activeElRef.current);
7837
+ refreshActiveCommandsRef.current();
7838
+ return;
7839
+ }
7840
+ }
7793
7841
  if (e.key === "Escape" && linkPopoverOpenRef.current) {
7794
7842
  setLinkPopoverRef.current(null);
7795
7843
  return;
@@ -8073,6 +8121,7 @@ function OhhwellsBridge() {
8073
8121
  };
8074
8122
  window.addEventListener("resize", handleViewportResize, { passive: true });
8075
8123
  document.addEventListener("click", handleClick, true);
8124
+ document.addEventListener("dblclick", handleDblClick, true);
8076
8125
  document.addEventListener("paste", handlePaste, true);
8077
8126
  document.addEventListener("input", handleInput, true);
8078
8127
  document.addEventListener("mouseover", handleMouseOver, true);
@@ -8087,6 +8136,7 @@ function OhhwellsBridge() {
8087
8136
  window.addEventListener("scroll", handleScroll, true);
8088
8137
  return () => {
8089
8138
  document.removeEventListener("click", handleClick, true);
8139
+ document.removeEventListener("dblclick", handleDblClick, true);
8090
8140
  document.removeEventListener("paste", handlePaste, true);
8091
8141
  document.removeEventListener("input", handleInput, true);
8092
8142
  document.removeEventListener("mouseover", handleMouseOver, true);