@githumbi/grabby 0.3.0 → 0.5.0
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/CHANGELOG.md +20 -0
- package/dist/angular/index.d.ts +8 -0
- package/dist/angular/index.js +640 -47
- package/dist/angular/index.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/core/index.cjs +732 -139
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +640 -47
- package/dist/core/index.js.map +1 -1
- package/dist/export/index.d.cts +8 -0
- package/dist/export/index.d.ts +8 -0
- package/dist/grabby.global.js +231 -87
- package/dist/live/index.d.cts +1 -1
- package/dist/live/index.d.ts +1 -1
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.js +640 -47
- package/dist/react/index.js.map +1 -1
- package/dist/{types-DjpIHekd.d.cts → types-BQDEG-Gl.d.cts} +8 -0
- package/dist/{types-DjpIHekd.d.ts → types-BQDEG-Gl.d.ts} +8 -0
- package/package.json +1 -1
package/dist/angular/index.js
CHANGED
|
@@ -767,6 +767,7 @@ function createCrosshair() {
|
|
|
767
767
|
let hLine = null;
|
|
768
768
|
let vLine = null;
|
|
769
769
|
let listening = false;
|
|
770
|
+
let held = false;
|
|
770
771
|
function injectStyles2() {
|
|
771
772
|
if (hasStyles(CROSSHAIR_STYLE_ID)) return;
|
|
772
773
|
addStyles(CROSSHAIR_STYLE_ID, `
|
|
@@ -789,7 +790,7 @@ function createCrosshair() {
|
|
|
789
790
|
width: 1px;
|
|
790
791
|
}
|
|
791
792
|
`);
|
|
792
|
-
addStyles(CURSOR_STYLE_ID, "body.grabby-crosshair-active { cursor: crosshair !important; }", "document");
|
|
793
|
+
addStyles(CURSOR_STYLE_ID, "body.grabby-crosshair-active:not(.grabby-crosshair-held) { cursor: crosshair !important; }", "document");
|
|
793
794
|
}
|
|
794
795
|
function ensureElements() {
|
|
795
796
|
if (!hLine) {
|
|
@@ -806,7 +807,12 @@ function createCrosshair() {
|
|
|
806
807
|
getUiRoot().appendChild(vLine);
|
|
807
808
|
}
|
|
808
809
|
}
|
|
810
|
+
function hideLines() {
|
|
811
|
+
if (hLine) hLine.style.top = "-10px";
|
|
812
|
+
if (vLine) vLine.style.left = "-10px";
|
|
813
|
+
}
|
|
809
814
|
function handleMouseMove(e) {
|
|
815
|
+
if (held) return;
|
|
810
816
|
if (hLine) {
|
|
811
817
|
hLine.style.top = `${e.clientY}px`;
|
|
812
818
|
}
|
|
@@ -827,13 +833,19 @@ function createCrosshair() {
|
|
|
827
833
|
listening = false;
|
|
828
834
|
document.body.classList.remove("grabby-crosshair-active");
|
|
829
835
|
document.removeEventListener("mousemove", handleMouseMove, true);
|
|
830
|
-
|
|
831
|
-
|
|
836
|
+
hideLines();
|
|
837
|
+
},
|
|
838
|
+
hold(on) {
|
|
839
|
+
if (held === on) return;
|
|
840
|
+
held = on;
|
|
841
|
+
document.body.classList.toggle("grabby-crosshair-held", on);
|
|
842
|
+
if (on) hideLines();
|
|
832
843
|
},
|
|
833
844
|
isCrosshairElement(el) {
|
|
834
845
|
return el === hLine || el === vLine || el.id === H_LINE_ID || el.id === V_LINE_ID;
|
|
835
846
|
},
|
|
836
847
|
dispose() {
|
|
848
|
+
this.hold(false);
|
|
837
849
|
this.deactivate();
|
|
838
850
|
hLine?.remove();
|
|
839
851
|
vLine?.remove();
|
|
@@ -1236,6 +1248,7 @@ function buildUniqueSelector(el) {
|
|
|
1236
1248
|
// src/core/picker/element-picker.ts
|
|
1237
1249
|
function createElementPicker(deps) {
|
|
1238
1250
|
let hoveredElement = null;
|
|
1251
|
+
let heldElement = null;
|
|
1239
1252
|
let listening = false;
|
|
1240
1253
|
function resolveComponentName(el) {
|
|
1241
1254
|
const resolver = deps.getComponentResolver();
|
|
@@ -1266,17 +1279,21 @@ function createElementPicker(deps) {
|
|
|
1266
1279
|
if (!raw || raw.closest(`[${IGNORE_ATTR}]`)) return raw && deps.isToolbarElement?.(raw) ? raw : null;
|
|
1267
1280
|
return exact ? raw : promoteTarget(raw);
|
|
1268
1281
|
}
|
|
1282
|
+
function showOverlay(target) {
|
|
1283
|
+
const componentName = resolveComponentName(target);
|
|
1284
|
+
const sourcePath = resolveSourcePath(target);
|
|
1285
|
+
const cssClasses = filterAngularClasses(target.classList);
|
|
1286
|
+
deps.overlay.show(target, componentName, sourcePath, cssClasses);
|
|
1287
|
+
}
|
|
1269
1288
|
function handleMouseMove(e) {
|
|
1289
|
+
if (heldElement) return;
|
|
1270
1290
|
const target = elementAtPoint(e.clientX, e.clientY, e.shiftKey);
|
|
1271
1291
|
if (!target || deps.overlay.isOverlayElement(target)) return;
|
|
1272
1292
|
if (deps.crosshair.isCrosshairElement(target)) return;
|
|
1273
1293
|
if (deps.isToolbarElement?.(target)) return;
|
|
1274
1294
|
if (target === hoveredElement) return;
|
|
1275
1295
|
hoveredElement = target;
|
|
1276
|
-
|
|
1277
|
-
const sourcePath = resolveSourcePath(target);
|
|
1278
|
-
const cssClasses = filterAngularClasses(target.classList);
|
|
1279
|
-
deps.overlay.show(target, componentName, sourcePath, cssClasses);
|
|
1296
|
+
showOverlay(target);
|
|
1280
1297
|
deps.onHover(target);
|
|
1281
1298
|
}
|
|
1282
1299
|
function handleClick(e) {
|
|
@@ -1286,8 +1303,9 @@ function createElementPicker(deps) {
|
|
|
1286
1303
|
if (target && (deps.isToolbarElement?.(target) || deps.crosshair.isCrosshairElement(target))) return;
|
|
1287
1304
|
e.preventDefault();
|
|
1288
1305
|
e.stopPropagation();
|
|
1306
|
+
if (heldElement) return;
|
|
1289
1307
|
if (hoveredElement) {
|
|
1290
|
-
deps.onSelect(hoveredElement);
|
|
1308
|
+
deps.onSelect(hoveredElement, { x: e.clientX, y: e.clientY });
|
|
1291
1309
|
}
|
|
1292
1310
|
}
|
|
1293
1311
|
return {
|
|
@@ -1302,12 +1320,29 @@ function createElementPicker(deps) {
|
|
|
1302
1320
|
if (!listening) return;
|
|
1303
1321
|
listening = false;
|
|
1304
1322
|
hoveredElement = null;
|
|
1323
|
+
heldElement = null;
|
|
1324
|
+
deps.crosshair.hold(false);
|
|
1305
1325
|
deps.crosshair.deactivate();
|
|
1306
1326
|
document.removeEventListener("mousemove", handleMouseMove, true);
|
|
1307
1327
|
document.removeEventListener("click", handleClick, true);
|
|
1308
1328
|
deps.overlay.hide();
|
|
1309
1329
|
deps.onHover(null);
|
|
1310
1330
|
},
|
|
1331
|
+
hold(element) {
|
|
1332
|
+
if (!listening) return;
|
|
1333
|
+
heldElement = element;
|
|
1334
|
+
hoveredElement = element;
|
|
1335
|
+
deps.crosshair.hold(true);
|
|
1336
|
+
showOverlay(element);
|
|
1337
|
+
},
|
|
1338
|
+
release() {
|
|
1339
|
+
if (!heldElement) return;
|
|
1340
|
+
heldElement = null;
|
|
1341
|
+
deps.crosshair.hold(false);
|
|
1342
|
+
},
|
|
1343
|
+
isHolding() {
|
|
1344
|
+
return heldElement !== null;
|
|
1345
|
+
},
|
|
1311
1346
|
getHoveredElement() {
|
|
1312
1347
|
return hoveredElement;
|
|
1313
1348
|
},
|
|
@@ -1528,7 +1563,8 @@ function createWebhookPlugin(url) {
|
|
|
1528
1563
|
type: "grabby.comment",
|
|
1529
1564
|
version: 1,
|
|
1530
1565
|
origin: typeof location !== "undefined" ? location.origin : null,
|
|
1531
|
-
|
|
1566
|
+
// The marker position is browser-only.
|
|
1567
|
+
comment: { ...comment, pin: void 0 }
|
|
1532
1568
|
})
|
|
1533
1569
|
}).catch(() => {
|
|
1534
1570
|
});
|
|
@@ -1620,6 +1656,9 @@ ${vars.join("\n")}
|
|
|
1620
1656
|
|
|
1621
1657
|
// src/core/toolbar/toolbar-renderer.ts
|
|
1622
1658
|
var TOOLBAR_ID = "__grabby-toolbar__";
|
|
1659
|
+
var COLLAPSED_SIZE = 42;
|
|
1660
|
+
var EASE_OUT_EXPO = "cubic-bezier(0.19, 1, 0.22, 1)";
|
|
1661
|
+
var MORPH_MS = 360;
|
|
1623
1662
|
var STYLE_ID3 = "__grabby-toolbar-styles__";
|
|
1624
1663
|
function syncSummary(comments) {
|
|
1625
1664
|
if (comments.length === 0) return null;
|
|
@@ -1640,6 +1679,14 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1640
1679
|
let allElements = /* @__PURE__ */ new Set();
|
|
1641
1680
|
let badge = null;
|
|
1642
1681
|
let status = null;
|
|
1682
|
+
let expandBadge = null;
|
|
1683
|
+
let content = null;
|
|
1684
|
+
let collapsed = false;
|
|
1685
|
+
let morphTimer = null;
|
|
1686
|
+
function clearMorph() {
|
|
1687
|
+
if (morphTimer) clearTimeout(morphTimer);
|
|
1688
|
+
morphTimer = null;
|
|
1689
|
+
}
|
|
1643
1690
|
function injectStyles2() {
|
|
1644
1691
|
if (hasStyles(STYLE_ID3)) return;
|
|
1645
1692
|
addStyles(STYLE_ID3, `
|
|
@@ -1659,7 +1706,21 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1659
1706
|
box-shadow: 0 4px 16px var(--grabby-toolbar-shadow, rgba(0, 0, 0, 0.12));
|
|
1660
1707
|
pointer-events: auto;
|
|
1661
1708
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
1662
|
-
|
|
1709
|
+
box-sizing: border-box;
|
|
1710
|
+
height: ${COLLAPSED_SIZE}px;
|
|
1711
|
+
overflow: hidden;
|
|
1712
|
+
justify-content: flex-end;
|
|
1713
|
+
transition: opacity 0.2s ease, transform 0.2s ease,
|
|
1714
|
+
left ${MORPH_MS}ms ${EASE_OUT_EXPO}, width ${MORPH_MS}ms ${EASE_OUT_EXPO};
|
|
1715
|
+
}
|
|
1716
|
+
#${TOOLBAR_ID} .grabby-toolbar-content {
|
|
1717
|
+
display: flex;
|
|
1718
|
+
align-items: center;
|
|
1719
|
+
gap: 2px;
|
|
1720
|
+
flex-shrink: 0;
|
|
1721
|
+
transform-origin: right center;
|
|
1722
|
+
transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
|
|
1723
|
+
transform 0.42s ${EASE_OUT_EXPO}, visibility 0s;
|
|
1663
1724
|
}
|
|
1664
1725
|
#${TOOLBAR_ID}.grabby-toolbar-hidden {
|
|
1665
1726
|
opacity: 0;
|
|
@@ -1755,6 +1816,45 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1755
1816
|
background: var(--grabby-accent-hover, #1d4ed8);
|
|
1756
1817
|
color: #fff;
|
|
1757
1818
|
}
|
|
1819
|
+
#${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1820
|
+
position: absolute;
|
|
1821
|
+
left: 50%;
|
|
1822
|
+
top: 50%;
|
|
1823
|
+
translate: -50% -50%;
|
|
1824
|
+
color: var(--grabby-accent, #2563eb);
|
|
1825
|
+
opacity: 0;
|
|
1826
|
+
scale: 0.6;
|
|
1827
|
+
visibility: hidden;
|
|
1828
|
+
pointer-events: none;
|
|
1829
|
+
transition: opacity 0.2s ease-out, scale 0.3s ${EASE_OUT_EXPO}, visibility 0s 0.2s;
|
|
1830
|
+
}
|
|
1831
|
+
#${TOOLBAR_ID} button.grabby-btn-expand .grabby-badge { top: -3px; right: -5px; }
|
|
1832
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed {
|
|
1833
|
+
left: calc(100% - 20px - ${COLLAPSED_SIZE / 2}px);
|
|
1834
|
+
padding: 4px;
|
|
1835
|
+
}
|
|
1836
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed .grabby-toolbar-content {
|
|
1837
|
+
opacity: 0;
|
|
1838
|
+
filter: blur(6px);
|
|
1839
|
+
transform: scale(0.4);
|
|
1840
|
+
pointer-events: none;
|
|
1841
|
+
visibility: hidden;
|
|
1842
|
+
transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
|
|
1843
|
+
transform 0.42s ${EASE_OUT_EXPO}, visibility 0s 0.3s;
|
|
1844
|
+
}
|
|
1845
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed button.grabby-btn-expand {
|
|
1846
|
+
opacity: 1;
|
|
1847
|
+
scale: 1;
|
|
1848
|
+
visibility: visible;
|
|
1849
|
+
pointer-events: auto;
|
|
1850
|
+
transition: opacity 0.24s ease-out 0.08s, scale 0.36s ${EASE_OUT_EXPO} 0.08s, visibility 0s;
|
|
1851
|
+
}
|
|
1852
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1853
|
+
#${TOOLBAR_ID}, #${TOOLBAR_ID} .grabby-toolbar-content, #${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1854
|
+
transition-duration: 0s !important;
|
|
1855
|
+
transition-delay: 0s !important;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1758
1858
|
#${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
|
|
1759
1859
|
max-width: 0;
|
|
1760
1860
|
opacity: 0;
|
|
@@ -1795,6 +1895,12 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1795
1895
|
buttons.history.appendChild(badge);
|
|
1796
1896
|
buttons.enable = createButton("enable", ICON_POWER, "Enable/Disable", callbacks.onEnableToggle);
|
|
1797
1897
|
buttons.dismiss = createButton("dismiss", ICON_DISMISS, options.dismissLabel ?? "Dismiss toolbar", callbacks.onDismiss);
|
|
1898
|
+
buttons.expand = createButton("expand", ICON_GRAB, options.expandLabel ?? "Open Grabby toolbar", () => callbacks.onExpand?.());
|
|
1899
|
+
buttons.expand.classList.add("grabby-btn-expand");
|
|
1900
|
+
expandBadge = document.createElement("span");
|
|
1901
|
+
expandBadge.className = "grabby-badge";
|
|
1902
|
+
expandBadge.hidden = true;
|
|
1903
|
+
buttons.expand.appendChild(expandBadge);
|
|
1798
1904
|
const divider = document.createElement("span");
|
|
1799
1905
|
divider.className = "grabby-toolbar-divider";
|
|
1800
1906
|
leftGroup = document.createElement("div");
|
|
@@ -1802,7 +1908,9 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1802
1908
|
leftGroup.appendChild(buttons.selection);
|
|
1803
1909
|
leftGroup.appendChild(buttons.history);
|
|
1804
1910
|
leftGroup.appendChild(divider);
|
|
1805
|
-
|
|
1911
|
+
content = document.createElement("div");
|
|
1912
|
+
content.className = "grabby-toolbar-content";
|
|
1913
|
+
content.appendChild(leftGroup);
|
|
1806
1914
|
if (options.review) {
|
|
1807
1915
|
status = document.createElement("span");
|
|
1808
1916
|
status.className = "grabby-toolbar-status";
|
|
@@ -1819,16 +1927,22 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1819
1927
|
e.stopPropagation();
|
|
1820
1928
|
callbacks.onFinish?.();
|
|
1821
1929
|
});
|
|
1822
|
-
|
|
1823
|
-
|
|
1930
|
+
content.appendChild(status);
|
|
1931
|
+
content.appendChild(buttons.finish);
|
|
1824
1932
|
allElements.add(status);
|
|
1825
1933
|
}
|
|
1826
|
-
if (!options.hideEnable)
|
|
1827
|
-
|
|
1934
|
+
if (!options.hideEnable) content.appendChild(buttons.enable);
|
|
1935
|
+
content.appendChild(buttons.dismiss);
|
|
1936
|
+
container.append(content, buttons.expand);
|
|
1937
|
+
if (collapsed) {
|
|
1938
|
+
container.classList.add("grabby-toolbar-collapsed");
|
|
1939
|
+
container.style.width = `${COLLAPSED_SIZE}px`;
|
|
1940
|
+
}
|
|
1828
1941
|
getUiRoot().appendChild(container);
|
|
1829
1942
|
allElements.clear();
|
|
1830
1943
|
allElements.add(container);
|
|
1831
1944
|
allElements.add(leftGroup);
|
|
1945
|
+
allElements.add(content);
|
|
1832
1946
|
allElements.add(divider);
|
|
1833
1947
|
for (const btn of Object.values(buttons)) {
|
|
1834
1948
|
allElements.add(btn);
|
|
@@ -1852,9 +1966,10 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1852
1966
|
buttons.selection.classList.remove("grabby-btn-active");
|
|
1853
1967
|
}
|
|
1854
1968
|
const count = state.toolbar.comments.length;
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1969
|
+
for (const b of [badge, expandBadge]) {
|
|
1970
|
+
if (!b) continue;
|
|
1971
|
+
b.hidden = count === 0;
|
|
1972
|
+
b.textContent = count > 99 ? "99+" : String(count);
|
|
1858
1973
|
}
|
|
1859
1974
|
buttons.history.setAttribute("aria-label", count ? `Comments (${count})` : "Comments");
|
|
1860
1975
|
if (status && buttons.finish) {
|
|
@@ -1872,6 +1987,33 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1872
1987
|
leftGroup?.classList.add("grabby-toolbar-left-hidden");
|
|
1873
1988
|
}
|
|
1874
1989
|
},
|
|
1990
|
+
collapse() {
|
|
1991
|
+
if (collapsed) return;
|
|
1992
|
+
collapsed = true;
|
|
1993
|
+
if (!container) return;
|
|
1994
|
+
clearMorph();
|
|
1995
|
+
container.style.width = `${container.offsetWidth}px`;
|
|
1996
|
+
void container.offsetWidth;
|
|
1997
|
+
container.classList.add("grabby-toolbar-collapsed");
|
|
1998
|
+
container.style.width = `${COLLAPSED_SIZE}px`;
|
|
1999
|
+
},
|
|
2000
|
+
expand() {
|
|
2001
|
+
if (!collapsed) return;
|
|
2002
|
+
collapsed = false;
|
|
2003
|
+
if (!container) return;
|
|
2004
|
+
clearMorph();
|
|
2005
|
+
container.classList.remove("grabby-toolbar-collapsed");
|
|
2006
|
+
const cs = getComputedStyle(container);
|
|
2007
|
+
const chrome = ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"].reduce((sum, k) => sum + (parseFloat(cs[k]) || 0), 0);
|
|
2008
|
+
container.style.width = `${(content?.offsetWidth ?? 0) + chrome}px`;
|
|
2009
|
+
morphTimer = setTimeout(() => {
|
|
2010
|
+
morphTimer = null;
|
|
2011
|
+
if (!collapsed && container) container.style.width = "";
|
|
2012
|
+
}, MORPH_MS + 40);
|
|
2013
|
+
},
|
|
2014
|
+
isCollapsed() {
|
|
2015
|
+
return collapsed;
|
|
2016
|
+
},
|
|
1875
2017
|
isToolbarElement(el) {
|
|
1876
2018
|
if (allElements.has(el)) return true;
|
|
1877
2019
|
let current = el;
|
|
@@ -1883,12 +2025,15 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1883
2025
|
return false;
|
|
1884
2026
|
},
|
|
1885
2027
|
dispose() {
|
|
2028
|
+
clearMorph();
|
|
1886
2029
|
container?.remove();
|
|
1887
2030
|
removeStyles(STYLE_ID3);
|
|
1888
2031
|
container = null;
|
|
1889
2032
|
leftGroup = null;
|
|
2033
|
+
content = null;
|
|
1890
2034
|
buttons = {};
|
|
1891
2035
|
badge = null;
|
|
2036
|
+
expandBadge = null;
|
|
1892
2037
|
status = null;
|
|
1893
2038
|
allElements.clear();
|
|
1894
2039
|
}
|
|
@@ -2455,6 +2600,18 @@ function createCommentPopover(callbacks) {
|
|
|
2455
2600
|
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
|
|
2456
2601
|
background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
|
|
2457
2602
|
}
|
|
2603
|
+
#${POPOVER_ID} .grabby-cp-edit-actions { display: flex; align-items: center; gap: 6px; }
|
|
2604
|
+
#${POPOVER_ID} .grabby-cp-edit-actions .grabby-cp-spacer { flex: 1; }
|
|
2605
|
+
#${POPOVER_ID} .grabby-cp-delete {
|
|
2606
|
+
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 6px; border: none;
|
|
2607
|
+
border-radius: 8px; background: transparent; color: #b91c1c; cursor: pointer;
|
|
2608
|
+
}
|
|
2609
|
+
#${POPOVER_ID} .grabby-cp-delete:hover { background: rgba(185, 28, 28, 0.08); }
|
|
2610
|
+
#${POPOVER_ID} .grabby-cp-cancel {
|
|
2611
|
+
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 10px; border: none;
|
|
2612
|
+
border-radius: 8px; background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer;
|
|
2613
|
+
}
|
|
2614
|
+
#${POPOVER_ID} .grabby-cp-cancel:hover { background: var(--grabby-surface, #f1f5f9); }
|
|
2458
2615
|
#${POPOVER_ID} .grabby-cp-hint {
|
|
2459
2616
|
font-size: 11px;
|
|
2460
2617
|
color: var(--grabby-text-muted, #94a3b8);
|
|
@@ -2516,6 +2673,37 @@ function createCommentPopover(callbacks) {
|
|
|
2516
2673
|
function isEditable(el) {
|
|
2517
2674
|
return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
|
|
2518
2675
|
}
|
|
2676
|
+
function save() {
|
|
2677
|
+
const v = textarea?.value.trim();
|
|
2678
|
+
if (!v) return;
|
|
2679
|
+
pendingValue = v;
|
|
2680
|
+
if (askIdentity) showIdentityStep();
|
|
2681
|
+
else finish();
|
|
2682
|
+
}
|
|
2683
|
+
function editActions() {
|
|
2684
|
+
const act = (fn) => (e) => {
|
|
2685
|
+
e.stopPropagation();
|
|
2686
|
+
fn();
|
|
2687
|
+
};
|
|
2688
|
+
const cancel = () => {
|
|
2689
|
+
const ctx = currentCtx;
|
|
2690
|
+
doHide();
|
|
2691
|
+
callbacks.onCancel(ctx);
|
|
2692
|
+
};
|
|
2693
|
+
const del = () => {
|
|
2694
|
+
const ctx = currentCtx;
|
|
2695
|
+
doHide();
|
|
2696
|
+
callbacks.onDelete?.(ctx);
|
|
2697
|
+
};
|
|
2698
|
+
return h(
|
|
2699
|
+
"div",
|
|
2700
|
+
{ class: "grabby-cp-edit-actions" },
|
|
2701
|
+
callbacks.onDelete ? h("button", { type: "button", class: "grabby-cp-delete", "data-grabby-delete": "", onclick: act(del) }, "Delete") : null,
|
|
2702
|
+
h("span", { class: "grabby-cp-spacer" }),
|
|
2703
|
+
h("button", { type: "button", class: "grabby-cp-cancel", "data-grabby-cancel": "", onclick: act(cancel) }, "Cancel"),
|
|
2704
|
+
h("button", { type: "button", class: "grabby-cp-post", "data-grabby-save": "", onclick: act(save) }, "Save")
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2519
2707
|
function finish(identity) {
|
|
2520
2708
|
const ctx = currentCtx;
|
|
2521
2709
|
const value = pendingValue;
|
|
@@ -2581,11 +2769,7 @@ function createCommentPopover(callbacks) {
|
|
|
2581
2769
|
e.stopImmediatePropagation();
|
|
2582
2770
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2583
2771
|
e.preventDefault();
|
|
2584
|
-
|
|
2585
|
-
if (!v) return;
|
|
2586
|
-
pendingValue = v;
|
|
2587
|
-
if (askIdentity) showIdentityStep();
|
|
2588
|
-
else finish();
|
|
2772
|
+
save();
|
|
2589
2773
|
} else if (e.key === "Escape") {
|
|
2590
2774
|
e.preventDefault();
|
|
2591
2775
|
const ctx = currentCtx;
|
|
@@ -2619,6 +2803,7 @@ function createCommentPopover(callbacks) {
|
|
|
2619
2803
|
currentCtx = { mode: opts.mode, entryId: opts.entryId };
|
|
2620
2804
|
askIdentity = opts.askIdentity === true && opts.mode === "new";
|
|
2621
2805
|
visible = true;
|
|
2806
|
+
if (opts.mode === "edit") el.appendChild(editActions());
|
|
2622
2807
|
position(el, opts.anchor);
|
|
2623
2808
|
attachKey();
|
|
2624
2809
|
textarea?.focus();
|
|
@@ -3150,9 +3335,10 @@ function createOutbox(deps) {
|
|
|
3150
3335
|
}, delay);
|
|
3151
3336
|
}
|
|
3152
3337
|
function wireShape(c) {
|
|
3153
|
-
const { screenshot: _shot, sync: _sync, ...rest } = c;
|
|
3338
|
+
const { screenshot: _shot, sync: _sync, pin: _pin, ...rest } = c;
|
|
3154
3339
|
void _shot;
|
|
3155
3340
|
void _sync;
|
|
3341
|
+
void _pin;
|
|
3156
3342
|
return rest;
|
|
3157
3343
|
}
|
|
3158
3344
|
function postComment(comment) {
|
|
@@ -3501,11 +3687,314 @@ function createFreezeOverlay() {
|
|
|
3501
3687
|
};
|
|
3502
3688
|
}
|
|
3503
3689
|
|
|
3690
|
+
// src/core/overlay/markers.ts
|
|
3691
|
+
var LAYER_ID = "__grabby-markers__";
|
|
3692
|
+
var TIP_ID = "__grabby-marker-tip__";
|
|
3693
|
+
var STYLE_ID9 = "__grabby-marker-styles__";
|
|
3694
|
+
var SIZE = 22;
|
|
3695
|
+
var ROUTE_CHECK_MS = 250;
|
|
3696
|
+
var LOOKUP_RETRY_MS = 500;
|
|
3697
|
+
var STAGGER_MS = 30;
|
|
3698
|
+
var TIP_MAX = 140;
|
|
3699
|
+
var ICON_EDIT = {
|
|
3700
|
+
size: 12,
|
|
3701
|
+
shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
|
|
3702
|
+
};
|
|
3703
|
+
function createMarkers(deps) {
|
|
3704
|
+
let layer = null;
|
|
3705
|
+
let tip = null;
|
|
3706
|
+
let visible = false;
|
|
3707
|
+
let route = "";
|
|
3708
|
+
let rafId = null;
|
|
3709
|
+
let lastRouteCheck = 0;
|
|
3710
|
+
let hovered = null;
|
|
3711
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3712
|
+
function injectStyles2() {
|
|
3713
|
+
if (hasStyles(STYLE_ID9)) return;
|
|
3714
|
+
addStyles(STYLE_ID9, `
|
|
3715
|
+
#${LAYER_ID} {
|
|
3716
|
+
position: fixed;
|
|
3717
|
+
inset: 0;
|
|
3718
|
+
pointer-events: none;
|
|
3719
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3720
|
+
}
|
|
3721
|
+
#${LAYER_ID} .grabby-marker {
|
|
3722
|
+
position: absolute;
|
|
3723
|
+
left: 0;
|
|
3724
|
+
top: 0;
|
|
3725
|
+
width: ${SIZE}px;
|
|
3726
|
+
height: ${SIZE}px;
|
|
3727
|
+
margin: 0;
|
|
3728
|
+
padding: 0;
|
|
3729
|
+
border: none;
|
|
3730
|
+
border-radius: 50%;
|
|
3731
|
+
background: var(--grabby-accent, #2563eb);
|
|
3732
|
+
color: #fff;
|
|
3733
|
+
box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3734
|
+
font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3735
|
+
display: flex;
|
|
3736
|
+
align-items: center;
|
|
3737
|
+
justify-content: center;
|
|
3738
|
+
cursor: pointer;
|
|
3739
|
+
pointer-events: auto;
|
|
3740
|
+
transition: transform 0.12s ease, box-shadow 0.15s ease;
|
|
3741
|
+
}
|
|
3742
|
+
#${LAYER_ID} .grabby-marker[hidden] { display: none; }
|
|
3743
|
+
#${LAYER_ID} .grabby-marker:hover,
|
|
3744
|
+
#${LAYER_ID} .grabby-marker:focus-visible {
|
|
3745
|
+
z-index: 1;
|
|
3746
|
+
outline: none;
|
|
3747
|
+
box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--grabby-accent, #2563eb) 35%, transparent), 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3748
|
+
}
|
|
3749
|
+
#${LAYER_ID} .grabby-marker-edit { display: none; }
|
|
3750
|
+
#${LAYER_ID} .grabby-marker:hover .grabby-marker-num,
|
|
3751
|
+
#${LAYER_ID} .grabby-marker:focus-visible .grabby-marker-num { display: none; }
|
|
3752
|
+
#${LAYER_ID} .grabby-marker:hover .grabby-marker-edit,
|
|
3753
|
+
#${LAYER_ID} .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
|
|
3754
|
+
#${LAYER_ID} .grabby-marker-in {
|
|
3755
|
+
animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
3756
|
+
}
|
|
3757
|
+
#${LAYER_ID} .grabby-marker-out {
|
|
3758
|
+
animation: grabby-marker-out 0.2s ease-out both;
|
|
3759
|
+
pointer-events: none;
|
|
3760
|
+
}
|
|
3761
|
+
@keyframes grabby-marker-in {
|
|
3762
|
+
from { opacity: 0; scale: 0.3; }
|
|
3763
|
+
to { opacity: 1; scale: 1; }
|
|
3764
|
+
}
|
|
3765
|
+
@keyframes grabby-marker-out {
|
|
3766
|
+
from { opacity: 1; scale: 1; }
|
|
3767
|
+
to { opacity: 0; scale: 0.3; }
|
|
3768
|
+
}
|
|
3769
|
+
#${TIP_ID} {
|
|
3770
|
+
position: fixed;
|
|
3771
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3772
|
+
max-width: 260px;
|
|
3773
|
+
padding: 8px 10px;
|
|
3774
|
+
border-radius: 10px;
|
|
3775
|
+
background: var(--grabby-label-bg, #1e293b);
|
|
3776
|
+
color: #fff;
|
|
3777
|
+
font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3778
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
|
|
3779
|
+
pointer-events: none;
|
|
3780
|
+
white-space: pre-wrap;
|
|
3781
|
+
overflow-wrap: anywhere;
|
|
3782
|
+
animation: grabby-marker-tip-in 0.12s ease both;
|
|
3783
|
+
}
|
|
3784
|
+
#${TIP_ID}[hidden] { display: none; }
|
|
3785
|
+
#${TIP_ID} .grabby-marker-tip-hint { display: block; margin-top: 4px; opacity: 0.6; font-size: 11px; }
|
|
3786
|
+
@keyframes grabby-marker-tip-in {
|
|
3787
|
+
from { opacity: 0; transform: translateY(-2px); }
|
|
3788
|
+
to { opacity: 1; transform: none; }
|
|
3789
|
+
}
|
|
3790
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3791
|
+
#${LAYER_ID} .grabby-marker-in, #${LAYER_ID} .grabby-marker-out, #${TIP_ID} { animation: none; }
|
|
3792
|
+
}
|
|
3793
|
+
`);
|
|
3794
|
+
}
|
|
3795
|
+
function ensureLayer() {
|
|
3796
|
+
if (layer) return layer;
|
|
3797
|
+
injectStyles2();
|
|
3798
|
+
layer = document.createElement("div");
|
|
3799
|
+
layer.id = LAYER_ID;
|
|
3800
|
+
tip = document.createElement("div");
|
|
3801
|
+
tip.id = TIP_ID;
|
|
3802
|
+
tip.hidden = true;
|
|
3803
|
+
tip.setAttribute("role", "tooltip");
|
|
3804
|
+
getUiRoot().append(layer, tip);
|
|
3805
|
+
return layer;
|
|
3806
|
+
}
|
|
3807
|
+
function pageComments() {
|
|
3808
|
+
return deps.getComments().filter((c) => c.page.route === route).reverse();
|
|
3809
|
+
}
|
|
3810
|
+
function preview(text) {
|
|
3811
|
+
const flat = text.trim();
|
|
3812
|
+
return flat.length > TIP_MAX ? `${flat.slice(0, TIP_MAX - 1)}\u2026` : flat;
|
|
3813
|
+
}
|
|
3814
|
+
function createEntry(comment) {
|
|
3815
|
+
const number = document.createElement("span");
|
|
3816
|
+
number.className = "grabby-marker-num";
|
|
3817
|
+
const button = document.createElement("button");
|
|
3818
|
+
button.type = "button";
|
|
3819
|
+
button.className = "grabby-marker";
|
|
3820
|
+
button.dataset.grabbyMarker = comment.id;
|
|
3821
|
+
button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
|
|
3822
|
+
const entry = { comment, button, number, element: null, lastLookup: 0 };
|
|
3823
|
+
button.addEventListener("click", (e) => {
|
|
3824
|
+
e.preventDefault();
|
|
3825
|
+
e.stopPropagation();
|
|
3826
|
+
hideTip();
|
|
3827
|
+
deps.onOpen(entry.comment, entry.element, button);
|
|
3828
|
+
});
|
|
3829
|
+
button.addEventListener("mouseenter", () => startHover(entry));
|
|
3830
|
+
button.addEventListener("focus", () => startHover(entry));
|
|
3831
|
+
button.addEventListener("mouseleave", () => endHover(entry));
|
|
3832
|
+
button.addEventListener("blur", () => endHover(entry));
|
|
3833
|
+
return entry;
|
|
3834
|
+
}
|
|
3835
|
+
function startHover(entry) {
|
|
3836
|
+
hovered = entry;
|
|
3837
|
+
showTip(entry);
|
|
3838
|
+
deps.onHover(entry.comment, entry.element);
|
|
3839
|
+
}
|
|
3840
|
+
function endHover(entry) {
|
|
3841
|
+
if (hovered !== entry) return;
|
|
3842
|
+
hovered = null;
|
|
3843
|
+
hideTip();
|
|
3844
|
+
deps.onHover(null, null);
|
|
3845
|
+
}
|
|
3846
|
+
function showTip(entry) {
|
|
3847
|
+
if (!tip) return;
|
|
3848
|
+
const hint = document.createElement("span");
|
|
3849
|
+
hint.className = "grabby-marker-tip-hint";
|
|
3850
|
+
hint.textContent = "Click to edit";
|
|
3851
|
+
tip.replaceChildren(document.createTextNode(preview(entry.comment.comment)), hint);
|
|
3852
|
+
tip.hidden = false;
|
|
3853
|
+
placeTip(entry);
|
|
3854
|
+
}
|
|
3855
|
+
function placeTip(entry) {
|
|
3856
|
+
if (!tip || tip.hidden) return;
|
|
3857
|
+
const m = entry.button.getBoundingClientRect();
|
|
3858
|
+
const t = tip.getBoundingClientRect();
|
|
3859
|
+
const left = Math.max(8, Math.min(m.left + m.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
|
|
3860
|
+
const below = m.bottom + 8;
|
|
3861
|
+
const top = below + t.height > window.innerHeight - 8 ? m.top - 8 - t.height : below;
|
|
3862
|
+
tip.style.left = `${left}px`;
|
|
3863
|
+
tip.style.top = `${Math.max(8, top)}px`;
|
|
3864
|
+
}
|
|
3865
|
+
function hideTip() {
|
|
3866
|
+
if (tip) tip.hidden = true;
|
|
3867
|
+
}
|
|
3868
|
+
function animateIn(button, delay) {
|
|
3869
|
+
button.classList.remove("grabby-marker-out", "grabby-marker-in");
|
|
3870
|
+
button.style.animationDelay = `${delay}ms`;
|
|
3871
|
+
void button.offsetWidth;
|
|
3872
|
+
button.classList.add("grabby-marker-in");
|
|
3873
|
+
}
|
|
3874
|
+
function removeEntry(id, animate) {
|
|
3875
|
+
const entry = entries.get(id);
|
|
3876
|
+
if (!entry) return;
|
|
3877
|
+
entries.delete(id);
|
|
3878
|
+
if (hovered === entry) endHover(entry);
|
|
3879
|
+
if (!animate) {
|
|
3880
|
+
entry.button.remove();
|
|
3881
|
+
return;
|
|
3882
|
+
}
|
|
3883
|
+
entry.button.style.animationDelay = "0ms";
|
|
3884
|
+
entry.button.classList.remove("grabby-marker-in");
|
|
3885
|
+
entry.button.classList.add("grabby-marker-out");
|
|
3886
|
+
setTimeout(() => entry.button.remove(), 220);
|
|
3887
|
+
}
|
|
3888
|
+
function sync(fresh) {
|
|
3889
|
+
if (!visible) return;
|
|
3890
|
+
const host2 = ensureLayer();
|
|
3891
|
+
const list = pageComments();
|
|
3892
|
+
const ids = new Set(list.map((c) => c.id));
|
|
3893
|
+
for (const id of [...entries.keys()]) if (!ids.has(id)) removeEntry(id, !fresh);
|
|
3894
|
+
list.forEach((comment, i) => {
|
|
3895
|
+
let entry = entries.get(comment.id);
|
|
3896
|
+
const isNew = !entry;
|
|
3897
|
+
if (!entry) {
|
|
3898
|
+
entry = createEntry(comment);
|
|
3899
|
+
entries.set(comment.id, entry);
|
|
3900
|
+
host2.appendChild(entry.button);
|
|
3901
|
+
}
|
|
3902
|
+
entry.comment = comment;
|
|
3903
|
+
const n = String(i + 1);
|
|
3904
|
+
entry.number.textContent = n;
|
|
3905
|
+
entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
|
|
3906
|
+
if (fresh || isNew) animateIn(entry.button, fresh ? i * STAGGER_MS : 0);
|
|
3907
|
+
});
|
|
3908
|
+
if (hovered && entries.get(hovered.comment.id) === hovered) showTip(hovered);
|
|
3909
|
+
position(performance.now());
|
|
3910
|
+
schedule();
|
|
3911
|
+
}
|
|
3912
|
+
function position(now) {
|
|
3913
|
+
for (const entry of entries.values()) {
|
|
3914
|
+
if (!entry.element?.isConnected) {
|
|
3915
|
+
entry.element = null;
|
|
3916
|
+
if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
|
|
3917
|
+
entry.lastLookup = now;
|
|
3918
|
+
entry.element = deps.findElement(entry.comment);
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
const rect = entry.element?.getBoundingClientRect();
|
|
3922
|
+
if (!rect || rect.width === 0 && rect.height === 0) {
|
|
3923
|
+
entry.button.hidden = true;
|
|
3924
|
+
continue;
|
|
3925
|
+
}
|
|
3926
|
+
const pin = entry.comment.pin ?? { x: 1, y: 0 };
|
|
3927
|
+
const x = rect.left + pin.x * rect.width - SIZE / 2;
|
|
3928
|
+
const y = rect.top + pin.y * rect.height - SIZE / 2;
|
|
3929
|
+
entry.button.hidden = false;
|
|
3930
|
+
entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
|
|
3931
|
+
}
|
|
3932
|
+
if (hovered) placeTip(hovered);
|
|
3933
|
+
}
|
|
3934
|
+
function frame() {
|
|
3935
|
+
rafId = null;
|
|
3936
|
+
const now = performance.now();
|
|
3937
|
+
if (!visible) return;
|
|
3938
|
+
if (now - lastRouteCheck >= ROUTE_CHECK_MS) {
|
|
3939
|
+
lastRouteCheck = now;
|
|
3940
|
+
const next = deps.currentRoute();
|
|
3941
|
+
if (next !== route) {
|
|
3942
|
+
route = next;
|
|
3943
|
+
for (const id of [...entries.keys()]) removeEntry(id, false);
|
|
3944
|
+
sync(true);
|
|
3945
|
+
return;
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
position(now);
|
|
3949
|
+
schedule();
|
|
3950
|
+
}
|
|
3951
|
+
function schedule() {
|
|
3952
|
+
if (rafId === null && visible) rafId = requestAnimationFrame(frame);
|
|
3953
|
+
}
|
|
3954
|
+
function stop() {
|
|
3955
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
3956
|
+
rafId = null;
|
|
3957
|
+
}
|
|
3958
|
+
return {
|
|
3959
|
+
setVisible(next) {
|
|
3960
|
+
if (next === visible) return;
|
|
3961
|
+
visible = next;
|
|
3962
|
+
if (next) {
|
|
3963
|
+
route = deps.currentRoute();
|
|
3964
|
+
lastRouteCheck = performance.now();
|
|
3965
|
+
sync(true);
|
|
3966
|
+
} else {
|
|
3967
|
+
stop();
|
|
3968
|
+
hideTip();
|
|
3969
|
+
if (hovered) endHover(hovered);
|
|
3970
|
+
for (const id of [...entries.keys()]) removeEntry(id, true);
|
|
3971
|
+
}
|
|
3972
|
+
},
|
|
3973
|
+
refresh() {
|
|
3974
|
+
sync(false);
|
|
3975
|
+
},
|
|
3976
|
+
isMarkerElement(el) {
|
|
3977
|
+
return !!layer && (layer === el || layer.contains(el));
|
|
3978
|
+
},
|
|
3979
|
+
dispose() {
|
|
3980
|
+
stop();
|
|
3981
|
+
entries.clear();
|
|
3982
|
+
layer?.remove();
|
|
3983
|
+
tip?.remove();
|
|
3984
|
+
layer = null;
|
|
3985
|
+
tip = null;
|
|
3986
|
+
hovered = null;
|
|
3987
|
+
visible = false;
|
|
3988
|
+
removeStyles(STYLE_ID9);
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3504
3993
|
// src/core/overlay/select-feedback.ts
|
|
3505
|
-
var
|
|
3994
|
+
var STYLE_ID10 = "__grabby-feedback-styles__";
|
|
3506
3995
|
function injectStyles() {
|
|
3507
|
-
if (hasStyles(
|
|
3508
|
-
addStyles(
|
|
3996
|
+
if (hasStyles(STYLE_ID10)) return;
|
|
3997
|
+
addStyles(STYLE_ID10, `
|
|
3509
3998
|
@keyframes grabby-flash {
|
|
3510
3999
|
0% { opacity: 1; }
|
|
3511
4000
|
100% { opacity: 0; transform: scale(1.02); }
|
|
@@ -3584,7 +4073,7 @@ function showSelectFeedback(element, label = "Selected") {
|
|
|
3584
4073
|
setTimeout(cleanup, 1200);
|
|
3585
4074
|
}
|
|
3586
4075
|
function disposeFeedbackStyles() {
|
|
3587
|
-
removeStyles(
|
|
4076
|
+
removeStyles(STYLE_ID10);
|
|
3588
4077
|
}
|
|
3589
4078
|
|
|
3590
4079
|
// src/core/storage/history-persistence.ts
|
|
@@ -4583,6 +5072,21 @@ function flushLeftovers(options) {
|
|
|
4583
5072
|
}
|
|
4584
5073
|
});
|
|
4585
5074
|
}
|
|
5075
|
+
var COLLAPSED_KEY = "grabby:v1:collapsed";
|
|
5076
|
+
function loadCollapsed() {
|
|
5077
|
+
try {
|
|
5078
|
+
return sessionStorage.getItem(COLLAPSED_KEY) === "1";
|
|
5079
|
+
} catch {
|
|
5080
|
+
return false;
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
function saveCollapsed(on) {
|
|
5084
|
+
try {
|
|
5085
|
+
if (on) sessionStorage.setItem(COLLAPSED_KEY, "1");
|
|
5086
|
+
else sessionStorage.removeItem(COLLAPSED_KEY);
|
|
5087
|
+
} catch {
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
4586
5090
|
function isDevMode() {
|
|
4587
5091
|
try {
|
|
4588
5092
|
if (typeof ngDevMode !== "undefined" && ngDevMode === false) return false;
|
|
@@ -4663,8 +5167,12 @@ function createGrabInstance(options) {
|
|
|
4663
5167
|
let sourceResolver = adapters.resolveSource;
|
|
4664
5168
|
const cleanClasses = (list) => adapters.cleanClasses(list.filter((c) => !isNoiseClass(c)));
|
|
4665
5169
|
let selectedElement = null;
|
|
5170
|
+
let selectedPin;
|
|
4666
5171
|
let pendingShot = null;
|
|
5172
|
+
const commentedElements = /* @__PURE__ */ new Map();
|
|
5173
|
+
let editingFromMarker = false;
|
|
4667
5174
|
let level = loadLevel(merged.detailLevel);
|
|
5175
|
+
let collapsed = loadCollapsed();
|
|
4668
5176
|
const pendingShotDeletes = /* @__PURE__ */ new Map();
|
|
4669
5177
|
themeManager.apply(store.state.toolbar.themeMode);
|
|
4670
5178
|
updateToastOffset();
|
|
@@ -4721,7 +5229,7 @@ function createGrabInstance(options) {
|
|
|
4721
5229
|
column: c.target.source?.column ?? null
|
|
4722
5230
|
};
|
|
4723
5231
|
}
|
|
4724
|
-
function saveComment(element, text, shot) {
|
|
5232
|
+
function saveComment(element, text, shot, pin) {
|
|
4725
5233
|
const now = Date.now();
|
|
4726
5234
|
const comment = {
|
|
4727
5235
|
id: randomId(),
|
|
@@ -4738,8 +5246,10 @@ function createGrabInstance(options) {
|
|
|
4738
5246
|
target: captureTarget(element, { componentResolver, sourceResolver, cleanClasses }),
|
|
4739
5247
|
screenshot: null,
|
|
4740
5248
|
framework: adapters.frameworkFor(element),
|
|
4741
|
-
...outbox ? { sync: "pending" } : {}
|
|
5249
|
+
...outbox ? { sync: "pending" } : {},
|
|
5250
|
+
...pin ? { pin } : {}
|
|
4742
5251
|
};
|
|
5252
|
+
commentedElements.set(comment.id, element);
|
|
4743
5253
|
setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
|
|
4744
5254
|
pluginRegistry.callHook("onComment", comment, element);
|
|
4745
5255
|
outbox?.send(comment.id);
|
|
@@ -4784,6 +5294,7 @@ function createGrabInstance(options) {
|
|
|
4784
5294
|
const idSet = new Set(ids);
|
|
4785
5295
|
const before = comments();
|
|
4786
5296
|
const removed = before.filter((c) => idSet.has(c.id));
|
|
5297
|
+
for (const id of ids) commentedElements.delete(id);
|
|
4787
5298
|
setComments(before.filter((c) => !idSet.has(c.id)));
|
|
4788
5299
|
const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
|
|
4789
5300
|
const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
|
|
@@ -4838,9 +5349,24 @@ function createGrabInstance(options) {
|
|
|
4838
5349
|
function isAnyToolbarElement(el) {
|
|
4839
5350
|
return isUiNode(el) || freezeOverlay.isFreezeElement(el);
|
|
4840
5351
|
}
|
|
5352
|
+
function hideCommentPopover() {
|
|
5353
|
+
commentPopover.hide();
|
|
5354
|
+
endMarkerEdit();
|
|
5355
|
+
if (picker.isHolding()) {
|
|
5356
|
+
selectedElement = null;
|
|
5357
|
+
selectedPin = void 0;
|
|
5358
|
+
pendingShot = null;
|
|
5359
|
+
picker.release();
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
function endMarkerEdit() {
|
|
5363
|
+
if (!editingFromMarker) return;
|
|
5364
|
+
editingFromMarker = false;
|
|
5365
|
+
overlay.hide();
|
|
5366
|
+
}
|
|
4841
5367
|
function closeAllPopovers() {
|
|
4842
5368
|
commentsPanel.hide();
|
|
4843
|
-
|
|
5369
|
+
hideCommentPopover();
|
|
4844
5370
|
copySheet.close();
|
|
4845
5371
|
finishSheet.close();
|
|
4846
5372
|
}
|
|
@@ -4874,15 +5400,52 @@ function createGrabInstance(options) {
|
|
|
4874
5400
|
pluginRegistry.callHook("onElementHover", element);
|
|
4875
5401
|
}
|
|
4876
5402
|
},
|
|
4877
|
-
onSelect(element) {
|
|
5403
|
+
onSelect(element, point) {
|
|
4878
5404
|
selectedElement = element;
|
|
5405
|
+
const rect = element.getBoundingClientRect();
|
|
5406
|
+
const frac = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
|
|
5407
|
+
selectedPin = {
|
|
5408
|
+
x: Math.round(frac(point.x, rect.left, rect.width) * 1e3) / 1e3,
|
|
5409
|
+
y: Math.round(frac(point.y, rect.top, rect.height) * 1e3) / 1e3
|
|
5410
|
+
};
|
|
4879
5411
|
pendingShot = store.state.options.screenshots ? captureScreenshot(element) : null;
|
|
4880
5412
|
pluginRegistry.callHook("onElementSelect", element);
|
|
4881
5413
|
coachMark.dismiss();
|
|
4882
5414
|
showSelectFeedback(element);
|
|
5415
|
+
picker.hold(element);
|
|
4883
5416
|
commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
|
|
4884
5417
|
}
|
|
4885
5418
|
});
|
|
5419
|
+
const markers = createMarkers({
|
|
5420
|
+
getComments: comments,
|
|
5421
|
+
currentRoute: () => sanitizeRoute(location, store.state.options.captureQueryParams),
|
|
5422
|
+
findElement(comment) {
|
|
5423
|
+
const known = commentedElements.get(comment.id);
|
|
5424
|
+
if (known?.isConnected) return known;
|
|
5425
|
+
return safeQuery(comment.target.selector);
|
|
5426
|
+
},
|
|
5427
|
+
onHover(comment, element) {
|
|
5428
|
+
if (picker.isHolding() || editingFromMarker || commentPopover.isVisible()) return;
|
|
5429
|
+
if (comment && element) overlay.show(element, comment.target.component, null, []);
|
|
5430
|
+
else overlay.hide();
|
|
5431
|
+
},
|
|
5432
|
+
onOpen(comment, element, marker) {
|
|
5433
|
+
if (picker.isHolding()) return;
|
|
5434
|
+
closeAllPopovers();
|
|
5435
|
+
doDeactivate(true);
|
|
5436
|
+
editingFromMarker = true;
|
|
5437
|
+
if (element) overlay.show(element, comment.target.component, null, []);
|
|
5438
|
+
commentPopover.show({
|
|
5439
|
+
anchor: element ?? marker,
|
|
5440
|
+
initialValue: comment.comment,
|
|
5441
|
+
mode: "edit",
|
|
5442
|
+
entryId: comment.id
|
|
5443
|
+
});
|
|
5444
|
+
}
|
|
5445
|
+
});
|
|
5446
|
+
function updateMarkers() {
|
|
5447
|
+
markers.setVisible(store.state.toolbar.visible && !collapsed && store.state.options.enabled);
|
|
5448
|
+
}
|
|
4886
5449
|
function doActivate() {
|
|
4887
5450
|
if (!store.state.options.enabled) return;
|
|
4888
5451
|
if (store.state.active) return;
|
|
@@ -4890,6 +5453,7 @@ function createGrabInstance(options) {
|
|
|
4890
5453
|
store.state.toolbar = { ...store.state.toolbar, visible: true };
|
|
4891
5454
|
toolbar.show();
|
|
4892
5455
|
}
|
|
5456
|
+
if (collapsed) expandToolbar();
|
|
4893
5457
|
closeAllPopovers();
|
|
4894
5458
|
store.state.active = true;
|
|
4895
5459
|
picker.activate();
|
|
@@ -4924,7 +5488,7 @@ function createGrabInstance(options) {
|
|
|
4924
5488
|
}
|
|
4925
5489
|
},
|
|
4926
5490
|
onHistory() {
|
|
4927
|
-
|
|
5491
|
+
hideCommentPopover();
|
|
4928
5492
|
copySheet.close();
|
|
4929
5493
|
if (commentsPanel.isVisible()) {
|
|
4930
5494
|
commentsPanel.hide();
|
|
@@ -4941,16 +5505,30 @@ function createGrabInstance(options) {
|
|
|
4941
5505
|
}
|
|
4942
5506
|
toolbar.update(store.state);
|
|
4943
5507
|
},
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
}
|
|
4950
|
-
exitFeedbackMode();
|
|
4951
|
-
},
|
|
5508
|
+
// Close collapses the toolbar into a round button in the bottom-right
|
|
5509
|
+
// corner instead of removing it, so nothing is lost and it's one click
|
|
5510
|
+
// back. Comments keep sending while it's collapsed.
|
|
5511
|
+
onDismiss: collapseToolbar,
|
|
5512
|
+
onExpand: expandToolbar,
|
|
4952
5513
|
onFinish: openFinishSheet
|
|
4953
|
-
}, live ? { label: "Comment", dismissLabel: "
|
|
5514
|
+
}, live ? { label: "Comment", dismissLabel: "Hide toolbar", expandLabel: "Leave feedback", hideEnable: true, review: !!merged.server } : { dismissLabel: "Hide toolbar", expandLabel: "Open Grabby toolbar" });
|
|
5515
|
+
function collapseToolbar() {
|
|
5516
|
+
closeAllPopovers();
|
|
5517
|
+
coachMark.dismiss();
|
|
5518
|
+
doDeactivate(true);
|
|
5519
|
+
collapsed = true;
|
|
5520
|
+
toolbar.collapse();
|
|
5521
|
+
saveCollapsed(true);
|
|
5522
|
+
updateToastOffset();
|
|
5523
|
+
updateMarkers();
|
|
5524
|
+
}
|
|
5525
|
+
function expandToolbar() {
|
|
5526
|
+
collapsed = false;
|
|
5527
|
+
toolbar.expand();
|
|
5528
|
+
saveCollapsed(false);
|
|
5529
|
+
updateToastOffset();
|
|
5530
|
+
updateMarkers();
|
|
5531
|
+
}
|
|
4954
5532
|
const commentsPanel = createCommentsPanel({
|
|
4955
5533
|
onHover(comment) {
|
|
4956
5534
|
const el = comment ? safeQuery(comment.target.selector) : null;
|
|
@@ -5037,9 +5615,11 @@ function createGrabInstance(options) {
|
|
|
5037
5615
|
if (ctx.mode === "new") {
|
|
5038
5616
|
const element = selectedElement;
|
|
5039
5617
|
const shot = pendingShot;
|
|
5618
|
+
const pin = selectedPin;
|
|
5040
5619
|
selectedElement = null;
|
|
5620
|
+
selectedPin = void 0;
|
|
5041
5621
|
pendingShot = null;
|
|
5042
|
-
if (element) saveComment(element, value, shot);
|
|
5622
|
+
if (element) saveComment(element, value, shot, pin);
|
|
5043
5623
|
doDeactivate(true);
|
|
5044
5624
|
return;
|
|
5045
5625
|
}
|
|
@@ -5050,16 +5630,23 @@ function createGrabInstance(options) {
|
|
|
5050
5630
|
setComments(updated);
|
|
5051
5631
|
outbox?.send(ctx.entryId);
|
|
5052
5632
|
showToast("Comment updated");
|
|
5053
|
-
|
|
5633
|
+
if (editingFromMarker) endMarkerEdit();
|
|
5634
|
+
else commentsPanel.show([...updated]);
|
|
5054
5635
|
},
|
|
5055
5636
|
onCancel(ctx) {
|
|
5056
5637
|
if (ctx.mode === "new") {
|
|
5057
5638
|
selectedElement = null;
|
|
5639
|
+
selectedPin = void 0;
|
|
5058
5640
|
pendingShot = null;
|
|
5059
5641
|
doDeactivate(true);
|
|
5060
5642
|
return;
|
|
5061
5643
|
}
|
|
5062
|
-
|
|
5644
|
+
if (editingFromMarker) endMarkerEdit();
|
|
5645
|
+
else commentsPanel.show([...comments()]);
|
|
5646
|
+
},
|
|
5647
|
+
onDelete(ctx) {
|
|
5648
|
+
endMarkerEdit();
|
|
5649
|
+
if (ctx.entryId) removeComments([ctx.entryId], "Comment deleted", true);
|
|
5063
5650
|
}
|
|
5064
5651
|
});
|
|
5065
5652
|
function handleDocumentClick(e) {
|
|
@@ -5087,7 +5674,7 @@ function createGrabInstance(options) {
|
|
|
5087
5674
|
}
|
|
5088
5675
|
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
5089
5676
|
function updateToastOffset() {
|
|
5090
|
-
if (store.state.toolbar.visible) {
|
|
5677
|
+
if (store.state.toolbar.visible && !collapsed) {
|
|
5091
5678
|
document.documentElement.style.setProperty("--grabby-toast-bottom", TOOLBAR_TOAST_OFFSET);
|
|
5092
5679
|
} else {
|
|
5093
5680
|
document.documentElement.style.removeProperty("--grabby-toast-bottom");
|
|
@@ -5215,6 +5802,7 @@ function createGrabInstance(options) {
|
|
|
5215
5802
|
overlay.dispose();
|
|
5216
5803
|
crosshair.dispose();
|
|
5217
5804
|
freezeOverlay.dispose();
|
|
5805
|
+
markers.dispose();
|
|
5218
5806
|
disposeToast();
|
|
5219
5807
|
disposeFeedbackStyles();
|
|
5220
5808
|
pluginRegistry.dispose();
|
|
@@ -5237,9 +5825,10 @@ function createGrabInstance(options) {
|
|
|
5237
5825
|
keyboard.start();
|
|
5238
5826
|
}
|
|
5239
5827
|
store.state.toolbar = { ...store.state.toolbar, visible: false };
|
|
5828
|
+
if (collapsed) toolbar.collapse();
|
|
5240
5829
|
if (live && merged.showToolbar) {
|
|
5241
5830
|
api.showToolbar();
|
|
5242
|
-
coachMark.maybeShow();
|
|
5831
|
+
if (!collapsed) coachMark.maybeShow();
|
|
5243
5832
|
}
|
|
5244
5833
|
store.subscribe((state, key) => {
|
|
5245
5834
|
if (key === "options") {
|
|
@@ -5250,8 +5839,11 @@ function createGrabInstance(options) {
|
|
|
5250
5839
|
doDeactivate(true);
|
|
5251
5840
|
}
|
|
5252
5841
|
}
|
|
5842
|
+
if (key === "options") updateMarkers();
|
|
5253
5843
|
if (key === "toolbar") {
|
|
5254
5844
|
updateToastOffset();
|
|
5845
|
+
updateMarkers();
|
|
5846
|
+
markers.refresh();
|
|
5255
5847
|
if (state.options.persistHistory) {
|
|
5256
5848
|
if (state.toolbar.comments.length > 0) {
|
|
5257
5849
|
saveHistory(state.toolbar.comments);
|
|
@@ -5273,6 +5865,7 @@ function createGrabInstance(options) {
|
|
|
5273
5865
|
if (merged.webhookUrl) {
|
|
5274
5866
|
api.registerPlugin(createWebhookPlugin(merged.webhookUrl));
|
|
5275
5867
|
}
|
|
5868
|
+
updateMarkers();
|
|
5276
5869
|
return api;
|
|
5277
5870
|
}
|
|
5278
5871
|
|