@ohhwells/bridge 0.1.40 → 0.1.41

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
@@ -7073,6 +7073,22 @@ function placeCaretAtPoint(el, x, y) {
7073
7073
  }
7074
7074
  }
7075
7075
  }
7076
+ function selectAllTextInEditable(el) {
7077
+ const selection = window.getSelection();
7078
+ if (!selection) return;
7079
+ const range = document.createRange();
7080
+ range.selectNodeContents(el);
7081
+ selection.removeAllRanges();
7082
+ selection.addRange(range);
7083
+ }
7084
+ function getNavigationLabelEditable(target) {
7085
+ const editable = target.closest('[data-ohw-editable="text"]');
7086
+ if (!editable) return null;
7087
+ const hrefCtx = getHrefKeyFromElement(editable);
7088
+ const navAnchor = hrefCtx ? getNavigationItemAnchor(hrefCtx.anchor) : null;
7089
+ if (!navAnchor) return null;
7090
+ return { editable, navAnchor };
7091
+ }
7076
7092
  function collectSections() {
7077
7093
  return collectSectionsFromDom();
7078
7094
  }
@@ -8217,6 +8233,7 @@ function OhhwellsBridge() {
8217
8233
  e.preventDefault();
8218
8234
  e.stopPropagation();
8219
8235
  if (selectedElRef.current === navAnchor) {
8236
+ if (e.detail >= 2) return;
8220
8237
  activateRef.current(editable, { caretX: e.clientX, caretY: e.clientY });
8221
8238
  return;
8222
8239
  }
@@ -8277,6 +8294,28 @@ function OhhwellsBridge() {
8277
8294
  deselectRef.current();
8278
8295
  deactivateRef.current();
8279
8296
  };
8297
+ const handleDblClick = (e) => {
8298
+ const target = e.target;
8299
+ if (target.closest("[data-ohw-toolbar]")) return;
8300
+ if (target.closest("[data-ohw-state-toggle]")) return;
8301
+ if (target.closest("[data-ohw-max-badge]")) return;
8302
+ if (isInsideLinkEditor(target)) return;
8303
+ if (target.closest('[data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-drag-handle-container], [data-slot="drag-handle"]')) {
8304
+ return;
8305
+ }
8306
+ const navLabel = getNavigationLabelEditable(target);
8307
+ if (!navLabel) return;
8308
+ const { editable } = navLabel;
8309
+ e.preventDefault();
8310
+ e.stopPropagation();
8311
+ if (activeElRef.current !== editable) {
8312
+ activateRef.current(editable);
8313
+ }
8314
+ requestAnimationFrame(() => {
8315
+ selectAllTextInEditable(editable);
8316
+ refreshActiveCommandsRef.current();
8317
+ });
8318
+ };
8280
8319
  const handleMouseOver = (e) => {
8281
8320
  if (document.documentElement.hasAttribute("data-ohw-section-picking")) return;
8282
8321
  const target = e.target;
@@ -8998,6 +9037,15 @@ function OhhwellsBridge() {
8998
9037
  window.addEventListener("message", handleUiEscape);
8999
9038
  const handleKeyDown = (e) => {
9000
9039
  if (e.key === "Escape" && document.querySelector("[data-ohw-section-picker]")) return;
9040
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" && activeElRef.current) {
9041
+ const navAnchor = getNavigationItemAnchor(activeElRef.current);
9042
+ if (navAnchor) {
9043
+ e.preventDefault();
9044
+ selectAllTextInEditable(activeElRef.current);
9045
+ refreshActiveCommandsRef.current();
9046
+ return;
9047
+ }
9048
+ }
9001
9049
  if (e.key === "Escape" && linkPopoverOpenRef.current) {
9002
9050
  setLinkPopoverRef.current(null);
9003
9051
  return;
@@ -9330,6 +9378,7 @@ function OhhwellsBridge() {
9330
9378
  };
9331
9379
  window.addEventListener("resize", handleViewportResize, { passive: true });
9332
9380
  document.addEventListener("click", handleClick, true);
9381
+ document.addEventListener("dblclick", handleDblClick, true);
9333
9382
  document.addEventListener("paste", handlePaste, true);
9334
9383
  document.addEventListener("input", handleInput, true);
9335
9384
  document.addEventListener("mouseover", handleMouseOver, true);
@@ -9344,6 +9393,7 @@ function OhhwellsBridge() {
9344
9393
  window.addEventListener("scroll", handleScroll, true);
9345
9394
  return () => {
9346
9395
  document.removeEventListener("click", handleClick, true);
9396
+ document.removeEventListener("dblclick", handleDblClick, true);
9347
9397
  document.removeEventListener("paste", handlePaste, true);
9348
9398
  document.removeEventListener("input", handleInput, true);
9349
9399
  document.removeEventListener("mouseover", handleMouseOver, true);