@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 +50 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7014,6 +7014,22 @@ function placeCaretAtPoint(el, x, y) {
|
|
|
7014
7014
|
}
|
|
7015
7015
|
}
|
|
7016
7016
|
}
|
|
7017
|
+
function selectAllTextInEditable(el) {
|
|
7018
|
+
const selection = window.getSelection();
|
|
7019
|
+
if (!selection) return;
|
|
7020
|
+
const range = document.createRange();
|
|
7021
|
+
range.selectNodeContents(el);
|
|
7022
|
+
selection.removeAllRanges();
|
|
7023
|
+
selection.addRange(range);
|
|
7024
|
+
}
|
|
7025
|
+
function getNavigationLabelEditable(target) {
|
|
7026
|
+
const editable = target.closest('[data-ohw-editable="text"]');
|
|
7027
|
+
if (!editable) return null;
|
|
7028
|
+
const hrefCtx = getHrefKeyFromElement(editable);
|
|
7029
|
+
const navAnchor = hrefCtx ? getNavigationItemAnchor(hrefCtx.anchor) : null;
|
|
7030
|
+
if (!navAnchor) return null;
|
|
7031
|
+
return { editable, navAnchor };
|
|
7032
|
+
}
|
|
7017
7033
|
function collectSections() {
|
|
7018
7034
|
return collectSectionsFromDom();
|
|
7019
7035
|
}
|
|
@@ -8158,6 +8174,7 @@ function OhhwellsBridge() {
|
|
|
8158
8174
|
e.preventDefault();
|
|
8159
8175
|
e.stopPropagation();
|
|
8160
8176
|
if (selectedElRef.current === navAnchor) {
|
|
8177
|
+
if (e.detail >= 2) return;
|
|
8161
8178
|
activateRef.current(editable, { caretX: e.clientX, caretY: e.clientY });
|
|
8162
8179
|
return;
|
|
8163
8180
|
}
|
|
@@ -8218,6 +8235,28 @@ function OhhwellsBridge() {
|
|
|
8218
8235
|
deselectRef.current();
|
|
8219
8236
|
deactivateRef.current();
|
|
8220
8237
|
};
|
|
8238
|
+
const handleDblClick = (e) => {
|
|
8239
|
+
const target = e.target;
|
|
8240
|
+
if (target.closest("[data-ohw-toolbar]")) return;
|
|
8241
|
+
if (target.closest("[data-ohw-state-toggle]")) return;
|
|
8242
|
+
if (target.closest("[data-ohw-max-badge]")) return;
|
|
8243
|
+
if (isInsideLinkEditor(target)) return;
|
|
8244
|
+
if (target.closest('[data-ohw-edit-chrome], [data-ohw-item-interaction], [data-ohw-drag-handle-container], [data-slot="drag-handle"]')) {
|
|
8245
|
+
return;
|
|
8246
|
+
}
|
|
8247
|
+
const navLabel = getNavigationLabelEditable(target);
|
|
8248
|
+
if (!navLabel) return;
|
|
8249
|
+
const { editable } = navLabel;
|
|
8250
|
+
e.preventDefault();
|
|
8251
|
+
e.stopPropagation();
|
|
8252
|
+
if (activeElRef.current !== editable) {
|
|
8253
|
+
activateRef.current(editable);
|
|
8254
|
+
}
|
|
8255
|
+
requestAnimationFrame(() => {
|
|
8256
|
+
selectAllTextInEditable(editable);
|
|
8257
|
+
refreshActiveCommandsRef.current();
|
|
8258
|
+
});
|
|
8259
|
+
};
|
|
8221
8260
|
const handleMouseOver = (e) => {
|
|
8222
8261
|
if (document.documentElement.hasAttribute("data-ohw-section-picking")) return;
|
|
8223
8262
|
const target = e.target;
|
|
@@ -8939,6 +8978,15 @@ function OhhwellsBridge() {
|
|
|
8939
8978
|
window.addEventListener("message", handleUiEscape);
|
|
8940
8979
|
const handleKeyDown = (e) => {
|
|
8941
8980
|
if (e.key === "Escape" && document.querySelector("[data-ohw-section-picker]")) return;
|
|
8981
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a" && activeElRef.current) {
|
|
8982
|
+
const navAnchor = getNavigationItemAnchor(activeElRef.current);
|
|
8983
|
+
if (navAnchor) {
|
|
8984
|
+
e.preventDefault();
|
|
8985
|
+
selectAllTextInEditable(activeElRef.current);
|
|
8986
|
+
refreshActiveCommandsRef.current();
|
|
8987
|
+
return;
|
|
8988
|
+
}
|
|
8989
|
+
}
|
|
8942
8990
|
if (e.key === "Escape" && linkPopoverOpenRef.current) {
|
|
8943
8991
|
setLinkPopoverRef.current(null);
|
|
8944
8992
|
return;
|
|
@@ -9271,6 +9319,7 @@ function OhhwellsBridge() {
|
|
|
9271
9319
|
};
|
|
9272
9320
|
window.addEventListener("resize", handleViewportResize, { passive: true });
|
|
9273
9321
|
document.addEventListener("click", handleClick, true);
|
|
9322
|
+
document.addEventListener("dblclick", handleDblClick, true);
|
|
9274
9323
|
document.addEventListener("paste", handlePaste, true);
|
|
9275
9324
|
document.addEventListener("input", handleInput, true);
|
|
9276
9325
|
document.addEventListener("mouseover", handleMouseOver, true);
|
|
@@ -9285,6 +9334,7 @@ function OhhwellsBridge() {
|
|
|
9285
9334
|
window.addEventListener("scroll", handleScroll, true);
|
|
9286
9335
|
return () => {
|
|
9287
9336
|
document.removeEventListener("click", handleClick, true);
|
|
9337
|
+
document.removeEventListener("dblclick", handleDblClick, true);
|
|
9288
9338
|
document.removeEventListener("paste", handlePaste, true);
|
|
9289
9339
|
document.removeEventListener("input", handleInput, true);
|
|
9290
9340
|
document.removeEventListener("mouseover", handleMouseOver, true);
|