@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.js CHANGED
@@ -6016,6 +6016,22 @@ function placeCaretAtPoint(el, x, y) {
6016
6016
  }
6017
6017
  }
6018
6018
  }
6019
+ function selectAllTextInEditable(el) {
6020
+ const selection = window.getSelection();
6021
+ if (!selection) return;
6022
+ const range = document.createRange();
6023
+ range.selectNodeContents(el);
6024
+ selection.removeAllRanges();
6025
+ selection.addRange(range);
6026
+ }
6027
+ function getNavigationLabelEditable(target) {
6028
+ const editable = target.closest('[data-ohw-editable="text"]');
6029
+ if (!editable) return null;
6030
+ const hrefCtx = getHrefKeyFromElement(editable);
6031
+ const navAnchor = hrefCtx ? getNavigationItemAnchor(hrefCtx.anchor) : null;
6032
+ if (!navAnchor) return null;
6033
+ return { editable, navAnchor };
6034
+ }
6019
6035
  function collectSections() {
6020
6036
  return collectSectionsFromDom();
6021
6037
  }
@@ -7105,6 +7121,7 @@ function OhhwellsBridge() {
7105
7121
  e.preventDefault();
7106
7122
  e.stopPropagation();
7107
7123
  if (selectedElRef.current === navAnchor) {
7124
+ if (e.detail >= 2) return;
7108
7125
  activateRef.current(editable, { caretX: e.clientX, caretY: e.clientY });
7109
7126
  return;
7110
7127
  }
@@ -7158,6 +7175,28 @@ function OhhwellsBridge() {
7158
7175
  deselectRef.current();
7159
7176
  deactivateRef.current();
7160
7177
  };
7178
+ const handleDblClick = (e) => {
7179
+ const target = e.target;
7180
+ if (target.closest("[data-ohw-toolbar]")) return;
7181
+ if (target.closest("[data-ohw-state-toggle]")) return;
7182
+ if (target.closest("[data-ohw-max-badge]")) return;
7183
+ if (isInsideLinkEditor(target)) return;
7184
+ if (target.closest('[data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-drag-handle-container], [data-slot="drag-handle"]')) {
7185
+ return;
7186
+ }
7187
+ const navLabel = getNavigationLabelEditable(target);
7188
+ if (!navLabel) return;
7189
+ const { editable } = navLabel;
7190
+ e.preventDefault();
7191
+ e.stopPropagation();
7192
+ if (activeElRef.current !== editable) {
7193
+ activateRef.current(editable);
7194
+ }
7195
+ requestAnimationFrame(() => {
7196
+ selectAllTextInEditable(editable);
7197
+ refreshActiveCommandsRef.current();
7198
+ });
7199
+ };
7161
7200
  const handleMouseOver = (e) => {
7162
7201
  const target = e.target;
7163
7202
  const navAnchor = getNavigationItemAnchor(target);
@@ -7731,6 +7770,15 @@ function OhhwellsBridge() {
7731
7770
  };
7732
7771
  window.addEventListener("message", handleDeactivate);
7733
7772
  const handleKeyDown = (e) => {
7773
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" && activeElRef.current) {
7774
+ const navAnchor = getNavigationItemAnchor(activeElRef.current);
7775
+ if (navAnchor) {
7776
+ e.preventDefault();
7777
+ selectAllTextInEditable(activeElRef.current);
7778
+ refreshActiveCommandsRef.current();
7779
+ return;
7780
+ }
7781
+ }
7734
7782
  if (e.key === "Escape" && linkPopoverOpenRef.current) {
7735
7783
  setLinkPopoverRef.current(null);
7736
7784
  return;
@@ -8014,6 +8062,7 @@ function OhhwellsBridge() {
8014
8062
  };
8015
8063
  window.addEventListener("resize", handleViewportResize, { passive: true });
8016
8064
  document.addEventListener("click", handleClick, true);
8065
+ document.addEventListener("dblclick", handleDblClick, true);
8017
8066
  document.addEventListener("paste", handlePaste, true);
8018
8067
  document.addEventListener("input", handleInput, true);
8019
8068
  document.addEventListener("mouseover", handleMouseOver, true);
@@ -8028,6 +8077,7 @@ function OhhwellsBridge() {
8028
8077
  window.addEventListener("scroll", handleScroll, true);
8029
8078
  return () => {
8030
8079
  document.removeEventListener("click", handleClick, true);
8080
+ document.removeEventListener("dblclick", handleDblClick, true);
8031
8081
  document.removeEventListener("paste", handlePaste, true);
8032
8082
  document.removeEventListener("input", handleInput, true);
8033
8083
  document.removeEventListener("mouseover", handleMouseOver, true);