@githumbi/grabby 0.4.0 → 0.5.1
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 +16 -0
- package/dist/angular/index.d.ts +8 -0
- package/dist/angular/index.js +568 -41
- package/dist/angular/index.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/core/index.cjs +635 -108
- 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 +568 -41
- 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 +253 -113
- 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 +568 -41
- 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/core/index.js
CHANGED
|
@@ -1217,7 +1217,7 @@ function createElementPicker(deps) {
|
|
|
1217
1217
|
e.stopPropagation();
|
|
1218
1218
|
if (heldElement) return;
|
|
1219
1219
|
if (hoveredElement) {
|
|
1220
|
-
deps.onSelect(hoveredElement);
|
|
1220
|
+
deps.onSelect(hoveredElement, { x: e.clientX, y: e.clientY });
|
|
1221
1221
|
}
|
|
1222
1222
|
}
|
|
1223
1223
|
return {
|
|
@@ -1475,7 +1475,8 @@ function createWebhookPlugin(url) {
|
|
|
1475
1475
|
type: "grabby.comment",
|
|
1476
1476
|
version: 1,
|
|
1477
1477
|
origin: typeof location !== "undefined" ? location.origin : null,
|
|
1478
|
-
|
|
1478
|
+
// The marker position is browser-only.
|
|
1479
|
+
comment: { ...comment, pin: void 0 }
|
|
1479
1480
|
})
|
|
1480
1481
|
}).catch(() => {
|
|
1481
1482
|
});
|
|
@@ -1567,6 +1568,9 @@ ${vars.join("\n")}
|
|
|
1567
1568
|
|
|
1568
1569
|
// src/core/toolbar/toolbar-renderer.ts
|
|
1569
1570
|
var TOOLBAR_ID = "__grabby-toolbar__";
|
|
1571
|
+
var COLLAPSED_SIZE = 42;
|
|
1572
|
+
var EASE_OUT_EXPO = "cubic-bezier(0.19, 1, 0.22, 1)";
|
|
1573
|
+
var MORPH_MS = 360;
|
|
1570
1574
|
var STYLE_ID3 = "__grabby-toolbar-styles__";
|
|
1571
1575
|
function syncSummary(comments) {
|
|
1572
1576
|
if (comments.length === 0) return null;
|
|
@@ -1588,7 +1592,13 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1588
1592
|
let badge = null;
|
|
1589
1593
|
let status = null;
|
|
1590
1594
|
let expandBadge = null;
|
|
1595
|
+
let content = null;
|
|
1591
1596
|
let collapsed = false;
|
|
1597
|
+
let morphTimer = null;
|
|
1598
|
+
function clearMorph() {
|
|
1599
|
+
if (morphTimer) clearTimeout(morphTimer);
|
|
1600
|
+
morphTimer = null;
|
|
1601
|
+
}
|
|
1592
1602
|
function injectStyles2() {
|
|
1593
1603
|
if (hasStyles(STYLE_ID3)) return;
|
|
1594
1604
|
addStyles(STYLE_ID3, `
|
|
@@ -1608,7 +1618,21 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1608
1618
|
box-shadow: 0 4px 16px var(--grabby-toolbar-shadow, rgba(0, 0, 0, 0.12));
|
|
1609
1619
|
pointer-events: auto;
|
|
1610
1620
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
1611
|
-
|
|
1621
|
+
box-sizing: border-box;
|
|
1622
|
+
height: ${COLLAPSED_SIZE}px;
|
|
1623
|
+
overflow: hidden;
|
|
1624
|
+
justify-content: flex-end;
|
|
1625
|
+
transition: opacity 0.2s ease, transform 0.2s ease,
|
|
1626
|
+
left ${MORPH_MS}ms ${EASE_OUT_EXPO}, width ${MORPH_MS}ms ${EASE_OUT_EXPO};
|
|
1627
|
+
}
|
|
1628
|
+
#${TOOLBAR_ID} .grabby-toolbar-content {
|
|
1629
|
+
display: flex;
|
|
1630
|
+
align-items: center;
|
|
1631
|
+
gap: 2px;
|
|
1632
|
+
flex-shrink: 0;
|
|
1633
|
+
transform-origin: right center;
|
|
1634
|
+
transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
|
|
1635
|
+
transform 0.42s ${EASE_OUT_EXPO}, visibility 0s;
|
|
1612
1636
|
}
|
|
1613
1637
|
#${TOOLBAR_ID}.grabby-toolbar-hidden {
|
|
1614
1638
|
opacity: 0;
|
|
@@ -1704,23 +1728,44 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1704
1728
|
background: var(--grabby-accent-hover, #1d4ed8);
|
|
1705
1729
|
color: #fff;
|
|
1706
1730
|
}
|
|
1707
|
-
#${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1731
|
+
#${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1732
|
+
position: absolute;
|
|
1733
|
+
left: 50%;
|
|
1734
|
+
top: 50%;
|
|
1735
|
+
translate: -50% -50%;
|
|
1736
|
+
color: var(--grabby-accent, #2563eb);
|
|
1737
|
+
opacity: 0;
|
|
1738
|
+
scale: 0.6;
|
|
1739
|
+
visibility: hidden;
|
|
1740
|
+
pointer-events: none;
|
|
1741
|
+
transition: opacity 0.2s ease-out, scale 0.3s ${EASE_OUT_EXPO}, visibility 0s 0.2s;
|
|
1742
|
+
}
|
|
1743
|
+
#${TOOLBAR_ID} button.grabby-btn-expand .grabby-badge { top: -3px; right: -5px; }
|
|
1708
1744
|
#${TOOLBAR_ID}.grabby-toolbar-collapsed {
|
|
1709
|
-
left:
|
|
1710
|
-
right: 20px;
|
|
1711
|
-
transform: none;
|
|
1745
|
+
left: calc(100% - 20px - ${COLLAPSED_SIZE / 2}px);
|
|
1712
1746
|
padding: 4px;
|
|
1713
1747
|
}
|
|
1714
|
-
#${TOOLBAR_ID}.grabby-toolbar-collapsed.grabby-toolbar-
|
|
1715
|
-
|
|
1748
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed .grabby-toolbar-content {
|
|
1749
|
+
opacity: 0;
|
|
1750
|
+
filter: blur(6px);
|
|
1751
|
+
transform: scale(0.4);
|
|
1752
|
+
pointer-events: none;
|
|
1753
|
+
visibility: hidden;
|
|
1754
|
+
transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
|
|
1755
|
+
transform 0.42s ${EASE_OUT_EXPO}, visibility 0s 0.3s;
|
|
1716
1756
|
}
|
|
1717
|
-
#${TOOLBAR_ID}.grabby-toolbar-collapsed
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1757
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed button.grabby-btn-expand {
|
|
1758
|
+
opacity: 1;
|
|
1759
|
+
scale: 1;
|
|
1760
|
+
visibility: visible;
|
|
1761
|
+
pointer-events: auto;
|
|
1762
|
+
transition: opacity 0.24s ease-out 0.08s, scale 0.36s ${EASE_OUT_EXPO} 0.08s, visibility 0s;
|
|
1763
|
+
}
|
|
1764
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1765
|
+
#${TOOLBAR_ID}, #${TOOLBAR_ID} .grabby-toolbar-content, #${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1766
|
+
transition-duration: 0s !important;
|
|
1767
|
+
transition-delay: 0s !important;
|
|
1768
|
+
}
|
|
1724
1769
|
}
|
|
1725
1770
|
#${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
|
|
1726
1771
|
max-width: 0;
|
|
@@ -1775,7 +1820,9 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1775
1820
|
leftGroup.appendChild(buttons.selection);
|
|
1776
1821
|
leftGroup.appendChild(buttons.history);
|
|
1777
1822
|
leftGroup.appendChild(divider);
|
|
1778
|
-
|
|
1823
|
+
content = document.createElement("div");
|
|
1824
|
+
content.className = "grabby-toolbar-content";
|
|
1825
|
+
content.appendChild(leftGroup);
|
|
1779
1826
|
if (options.review) {
|
|
1780
1827
|
status = document.createElement("span");
|
|
1781
1828
|
status.className = "grabby-toolbar-status";
|
|
@@ -1792,18 +1839,22 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1792
1839
|
e.stopPropagation();
|
|
1793
1840
|
callbacks.onFinish?.();
|
|
1794
1841
|
});
|
|
1795
|
-
|
|
1796
|
-
|
|
1842
|
+
content.appendChild(status);
|
|
1843
|
+
content.appendChild(buttons.finish);
|
|
1797
1844
|
allElements.add(status);
|
|
1798
1845
|
}
|
|
1799
|
-
if (!options.hideEnable)
|
|
1800
|
-
|
|
1801
|
-
container.
|
|
1802
|
-
|
|
1846
|
+
if (!options.hideEnable) content.appendChild(buttons.enable);
|
|
1847
|
+
content.appendChild(buttons.dismiss);
|
|
1848
|
+
container.append(content, buttons.expand);
|
|
1849
|
+
if (collapsed) {
|
|
1850
|
+
container.classList.add("grabby-toolbar-collapsed");
|
|
1851
|
+
container.style.width = `${COLLAPSED_SIZE}px`;
|
|
1852
|
+
}
|
|
1803
1853
|
getUiRoot().appendChild(container);
|
|
1804
1854
|
allElements.clear();
|
|
1805
1855
|
allElements.add(container);
|
|
1806
1856
|
allElements.add(leftGroup);
|
|
1857
|
+
allElements.add(content);
|
|
1807
1858
|
allElements.add(divider);
|
|
1808
1859
|
for (const btn of Object.values(buttons)) {
|
|
1809
1860
|
allElements.add(btn);
|
|
@@ -1849,12 +1900,28 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1849
1900
|
}
|
|
1850
1901
|
},
|
|
1851
1902
|
collapse() {
|
|
1903
|
+
if (collapsed) return;
|
|
1852
1904
|
collapsed = true;
|
|
1853
|
-
container
|
|
1905
|
+
if (!container) return;
|
|
1906
|
+
clearMorph();
|
|
1907
|
+
container.style.width = `${container.offsetWidth}px`;
|
|
1908
|
+
void container.offsetWidth;
|
|
1909
|
+
container.classList.add("grabby-toolbar-collapsed");
|
|
1910
|
+
container.style.width = `${COLLAPSED_SIZE}px`;
|
|
1854
1911
|
},
|
|
1855
1912
|
expand() {
|
|
1913
|
+
if (!collapsed) return;
|
|
1856
1914
|
collapsed = false;
|
|
1857
|
-
container
|
|
1915
|
+
if (!container) return;
|
|
1916
|
+
clearMorph();
|
|
1917
|
+
container.classList.remove("grabby-toolbar-collapsed");
|
|
1918
|
+
const cs = getComputedStyle(container);
|
|
1919
|
+
const chrome = ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"].reduce((sum, k) => sum + (parseFloat(cs[k]) || 0), 0);
|
|
1920
|
+
container.style.width = `${(content?.offsetWidth ?? 0) + chrome}px`;
|
|
1921
|
+
morphTimer = setTimeout(() => {
|
|
1922
|
+
morphTimer = null;
|
|
1923
|
+
if (!collapsed && container) container.style.width = "";
|
|
1924
|
+
}, MORPH_MS + 40);
|
|
1858
1925
|
},
|
|
1859
1926
|
isCollapsed() {
|
|
1860
1927
|
return collapsed;
|
|
@@ -1870,10 +1937,12 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1870
1937
|
return false;
|
|
1871
1938
|
},
|
|
1872
1939
|
dispose() {
|
|
1940
|
+
clearMorph();
|
|
1873
1941
|
container?.remove();
|
|
1874
1942
|
removeStyles(STYLE_ID3);
|
|
1875
1943
|
container = null;
|
|
1876
1944
|
leftGroup = null;
|
|
1945
|
+
content = null;
|
|
1877
1946
|
buttons = {};
|
|
1878
1947
|
badge = null;
|
|
1879
1948
|
expandBadge = null;
|
|
@@ -2443,6 +2512,18 @@ function createCommentPopover(callbacks) {
|
|
|
2443
2512
|
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
|
|
2444
2513
|
background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
|
|
2445
2514
|
}
|
|
2515
|
+
#${POPOVER_ID} .grabby-cp-edit-actions { display: flex; align-items: center; gap: 6px; }
|
|
2516
|
+
#${POPOVER_ID} .grabby-cp-edit-actions .grabby-cp-spacer { flex: 1; }
|
|
2517
|
+
#${POPOVER_ID} .grabby-cp-delete {
|
|
2518
|
+
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 6px; border: none;
|
|
2519
|
+
border-radius: 8px; background: transparent; color: #b91c1c; cursor: pointer;
|
|
2520
|
+
}
|
|
2521
|
+
#${POPOVER_ID} .grabby-cp-delete:hover { background: rgba(185, 28, 28, 0.08); }
|
|
2522
|
+
#${POPOVER_ID} .grabby-cp-cancel {
|
|
2523
|
+
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 10px; border: none;
|
|
2524
|
+
border-radius: 8px; background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer;
|
|
2525
|
+
}
|
|
2526
|
+
#${POPOVER_ID} .grabby-cp-cancel:hover { background: var(--grabby-surface, #f1f5f9); }
|
|
2446
2527
|
#${POPOVER_ID} .grabby-cp-hint {
|
|
2447
2528
|
font-size: 11px;
|
|
2448
2529
|
color: var(--grabby-text-muted, #94a3b8);
|
|
@@ -2504,6 +2585,37 @@ function createCommentPopover(callbacks) {
|
|
|
2504
2585
|
function isEditable(el) {
|
|
2505
2586
|
return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
|
|
2506
2587
|
}
|
|
2588
|
+
function save() {
|
|
2589
|
+
const v = textarea?.value.trim();
|
|
2590
|
+
if (!v) return;
|
|
2591
|
+
pendingValue = v;
|
|
2592
|
+
if (askIdentity) showIdentityStep();
|
|
2593
|
+
else finish();
|
|
2594
|
+
}
|
|
2595
|
+
function editActions() {
|
|
2596
|
+
const act = (fn) => (e) => {
|
|
2597
|
+
e.stopPropagation();
|
|
2598
|
+
fn();
|
|
2599
|
+
};
|
|
2600
|
+
const cancel = () => {
|
|
2601
|
+
const ctx = currentCtx;
|
|
2602
|
+
doHide();
|
|
2603
|
+
callbacks.onCancel(ctx);
|
|
2604
|
+
};
|
|
2605
|
+
const del = () => {
|
|
2606
|
+
const ctx = currentCtx;
|
|
2607
|
+
doHide();
|
|
2608
|
+
callbacks.onDelete?.(ctx);
|
|
2609
|
+
};
|
|
2610
|
+
return h(
|
|
2611
|
+
"div",
|
|
2612
|
+
{ class: "grabby-cp-edit-actions" },
|
|
2613
|
+
callbacks.onDelete ? h("button", { type: "button", class: "grabby-cp-delete", "data-grabby-delete": "", onclick: act(del) }, "Delete") : null,
|
|
2614
|
+
h("span", { class: "grabby-cp-spacer" }),
|
|
2615
|
+
h("button", { type: "button", class: "grabby-cp-cancel", "data-grabby-cancel": "", onclick: act(cancel) }, "Cancel"),
|
|
2616
|
+
h("button", { type: "button", class: "grabby-cp-post", "data-grabby-save": "", onclick: act(save) }, "Save")
|
|
2617
|
+
);
|
|
2618
|
+
}
|
|
2507
2619
|
function finish(identity) {
|
|
2508
2620
|
const ctx = currentCtx;
|
|
2509
2621
|
const value = pendingValue;
|
|
@@ -2569,11 +2681,7 @@ function createCommentPopover(callbacks) {
|
|
|
2569
2681
|
e.stopImmediatePropagation();
|
|
2570
2682
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2571
2683
|
e.preventDefault();
|
|
2572
|
-
|
|
2573
|
-
if (!v) return;
|
|
2574
|
-
pendingValue = v;
|
|
2575
|
-
if (askIdentity) showIdentityStep();
|
|
2576
|
-
else finish();
|
|
2684
|
+
save();
|
|
2577
2685
|
} else if (e.key === "Escape") {
|
|
2578
2686
|
e.preventDefault();
|
|
2579
2687
|
const ctx = currentCtx;
|
|
@@ -2607,6 +2715,7 @@ function createCommentPopover(callbacks) {
|
|
|
2607
2715
|
currentCtx = { mode: opts.mode, entryId: opts.entryId };
|
|
2608
2716
|
askIdentity = opts.askIdentity === true && opts.mode === "new";
|
|
2609
2717
|
visible = true;
|
|
2718
|
+
if (opts.mode === "edit") el.appendChild(editActions());
|
|
2610
2719
|
position(el, opts.anchor);
|
|
2611
2720
|
attachKey();
|
|
2612
2721
|
textarea?.focus();
|
|
@@ -3138,9 +3247,10 @@ function createOutbox(deps) {
|
|
|
3138
3247
|
}, delay);
|
|
3139
3248
|
}
|
|
3140
3249
|
function wireShape(c) {
|
|
3141
|
-
const { screenshot: _shot, sync: _sync, ...rest } = c;
|
|
3250
|
+
const { screenshot: _shot, sync: _sync, pin: _pin, ...rest } = c;
|
|
3142
3251
|
void _shot;
|
|
3143
3252
|
void _sync;
|
|
3253
|
+
void _pin;
|
|
3144
3254
|
return rest;
|
|
3145
3255
|
}
|
|
3146
3256
|
function postComment(comment) {
|
|
@@ -3450,11 +3560,363 @@ function createFreezeOverlay() {
|
|
|
3450
3560
|
};
|
|
3451
3561
|
}
|
|
3452
3562
|
|
|
3563
|
+
// src/core/overlay/markers.ts
|
|
3564
|
+
var LAYER_ID = "__grabby-markers__";
|
|
3565
|
+
var DOC_LAYER_ID = "__grabby-markers-doc__";
|
|
3566
|
+
var CONTEXT_CHECK_MS = 1e3;
|
|
3567
|
+
var TIP_ID = "__grabby-marker-tip__";
|
|
3568
|
+
var STYLE_ID9 = "__grabby-marker-styles__";
|
|
3569
|
+
var SIZE = 22;
|
|
3570
|
+
var ROUTE_CHECK_MS = 250;
|
|
3571
|
+
var LOOKUP_RETRY_MS = 500;
|
|
3572
|
+
var STAGGER_MS = 30;
|
|
3573
|
+
var TIP_MAX = 140;
|
|
3574
|
+
var ICON_EDIT = {
|
|
3575
|
+
size: 12,
|
|
3576
|
+
shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
|
|
3577
|
+
};
|
|
3578
|
+
function scrollContextOf(el) {
|
|
3579
|
+
for (let cur = el.parentElement; cur && cur !== document.body && cur !== document.documentElement; cur = cur.parentElement) {
|
|
3580
|
+
const style = getComputedStyle(cur);
|
|
3581
|
+
if (style.position === "fixed" || style.position === "sticky") return "screen";
|
|
3582
|
+
if (/(auto|scroll|overlay)/.test(style.overflowY + style.overflowX)) return "screen";
|
|
3583
|
+
}
|
|
3584
|
+
const own = getComputedStyle(el).position;
|
|
3585
|
+
return own === "fixed" || own === "sticky" ? "screen" : "page";
|
|
3586
|
+
}
|
|
3587
|
+
function createMarkers(deps) {
|
|
3588
|
+
let layer = null;
|
|
3589
|
+
let docLayer = null;
|
|
3590
|
+
let tip = null;
|
|
3591
|
+
let visible = false;
|
|
3592
|
+
let route = "";
|
|
3593
|
+
let rafId = null;
|
|
3594
|
+
let lastRouteCheck = 0;
|
|
3595
|
+
let hovered = null;
|
|
3596
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3597
|
+
function injectStyles2() {
|
|
3598
|
+
if (hasStyles(STYLE_ID9)) return;
|
|
3599
|
+
addStyles(STYLE_ID9, `
|
|
3600
|
+
/*
|
|
3601
|
+
* Page coordinates: the browser moves these with the page as it
|
|
3602
|
+
* scrolls, so they never trail behind their element. (A fixed layer
|
|
3603
|
+
* repositioned from script lags a frame behind fast scrolling.)
|
|
3604
|
+
*/
|
|
3605
|
+
#${DOC_LAYER_ID} {
|
|
3606
|
+
position: absolute;
|
|
3607
|
+
left: 0;
|
|
3608
|
+
top: 0;
|
|
3609
|
+
width: 0;
|
|
3610
|
+
height: 0;
|
|
3611
|
+
pointer-events: none;
|
|
3612
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3613
|
+
}
|
|
3614
|
+
#${LAYER_ID} {
|
|
3615
|
+
position: fixed;
|
|
3616
|
+
inset: 0;
|
|
3617
|
+
pointer-events: none;
|
|
3618
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3619
|
+
}
|
|
3620
|
+
.grabby-markers-layer .grabby-marker {
|
|
3621
|
+
position: absolute;
|
|
3622
|
+
left: 0;
|
|
3623
|
+
top: 0;
|
|
3624
|
+
width: ${SIZE}px;
|
|
3625
|
+
height: ${SIZE}px;
|
|
3626
|
+
margin: 0;
|
|
3627
|
+
padding: 0;
|
|
3628
|
+
border: none;
|
|
3629
|
+
border-radius: 50%;
|
|
3630
|
+
background: var(--grabby-accent, #2563eb);
|
|
3631
|
+
color: #fff;
|
|
3632
|
+
box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3633
|
+
font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3634
|
+
display: flex;
|
|
3635
|
+
align-items: center;
|
|
3636
|
+
justify-content: center;
|
|
3637
|
+
cursor: pointer;
|
|
3638
|
+
pointer-events: auto;
|
|
3639
|
+
transition: transform 0.12s ease, box-shadow 0.15s ease;
|
|
3640
|
+
}
|
|
3641
|
+
.grabby-markers-layer .grabby-marker[hidden] { display: none; }
|
|
3642
|
+
.grabby-markers-layer .grabby-marker:hover,
|
|
3643
|
+
.grabby-markers-layer .grabby-marker:focus-visible {
|
|
3644
|
+
z-index: 1;
|
|
3645
|
+
outline: none;
|
|
3646
|
+
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);
|
|
3647
|
+
}
|
|
3648
|
+
.grabby-markers-layer .grabby-marker-edit { display: none; }
|
|
3649
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-num,
|
|
3650
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-num { display: none; }
|
|
3651
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-edit,
|
|
3652
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
|
|
3653
|
+
.grabby-markers-layer .grabby-marker-in {
|
|
3654
|
+
animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
3655
|
+
}
|
|
3656
|
+
.grabby-markers-layer .grabby-marker-out {
|
|
3657
|
+
animation: grabby-marker-out 0.2s ease-out both;
|
|
3658
|
+
pointer-events: none;
|
|
3659
|
+
}
|
|
3660
|
+
@keyframes grabby-marker-in {
|
|
3661
|
+
from { opacity: 0; scale: 0.3; }
|
|
3662
|
+
to { opacity: 1; scale: 1; }
|
|
3663
|
+
}
|
|
3664
|
+
@keyframes grabby-marker-out {
|
|
3665
|
+
from { opacity: 1; scale: 1; }
|
|
3666
|
+
to { opacity: 0; scale: 0.3; }
|
|
3667
|
+
}
|
|
3668
|
+
#${TIP_ID} {
|
|
3669
|
+
position: fixed;
|
|
3670
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3671
|
+
max-width: 260px;
|
|
3672
|
+
padding: 8px 10px;
|
|
3673
|
+
border-radius: 10px;
|
|
3674
|
+
background: var(--grabby-label-bg, #1e293b);
|
|
3675
|
+
color: #fff;
|
|
3676
|
+
font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3677
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
|
|
3678
|
+
pointer-events: none;
|
|
3679
|
+
white-space: pre-wrap;
|
|
3680
|
+
overflow-wrap: anywhere;
|
|
3681
|
+
animation: grabby-marker-tip-in 0.12s ease both;
|
|
3682
|
+
}
|
|
3683
|
+
#${TIP_ID}[hidden] { display: none; }
|
|
3684
|
+
#${TIP_ID} .grabby-marker-tip-hint { display: block; margin-top: 4px; opacity: 0.6; font-size: 11px; }
|
|
3685
|
+
@keyframes grabby-marker-tip-in {
|
|
3686
|
+
from { opacity: 0; transform: translateY(-2px); }
|
|
3687
|
+
to { opacity: 1; transform: none; }
|
|
3688
|
+
}
|
|
3689
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3690
|
+
.grabby-markers-layer .grabby-marker-in, .grabby-markers-layer .grabby-marker-out, #${TIP_ID} { animation: none; }
|
|
3691
|
+
}
|
|
3692
|
+
`);
|
|
3693
|
+
}
|
|
3694
|
+
function ensureLayer() {
|
|
3695
|
+
if (layer) return layer;
|
|
3696
|
+
injectStyles2();
|
|
3697
|
+
layer = document.createElement("div");
|
|
3698
|
+
layer.id = LAYER_ID;
|
|
3699
|
+
layer.className = "grabby-markers-layer";
|
|
3700
|
+
docLayer = document.createElement("div");
|
|
3701
|
+
docLayer.id = DOC_LAYER_ID;
|
|
3702
|
+
docLayer.className = "grabby-markers-layer";
|
|
3703
|
+
tip = document.createElement("div");
|
|
3704
|
+
tip.id = TIP_ID;
|
|
3705
|
+
tip.hidden = true;
|
|
3706
|
+
tip.setAttribute("role", "tooltip");
|
|
3707
|
+
getUiRoot().append(docLayer, layer, tip);
|
|
3708
|
+
return layer;
|
|
3709
|
+
}
|
|
3710
|
+
function pageComments() {
|
|
3711
|
+
return deps.getComments().filter((c) => c.page.route === route).reverse();
|
|
3712
|
+
}
|
|
3713
|
+
function preview(text) {
|
|
3714
|
+
const flat = text.trim();
|
|
3715
|
+
return flat.length > TIP_MAX ? `${flat.slice(0, TIP_MAX - 1)}\u2026` : flat;
|
|
3716
|
+
}
|
|
3717
|
+
function createEntry(comment) {
|
|
3718
|
+
const number = document.createElement("span");
|
|
3719
|
+
number.className = "grabby-marker-num";
|
|
3720
|
+
const button = document.createElement("button");
|
|
3721
|
+
button.type = "button";
|
|
3722
|
+
button.className = "grabby-marker";
|
|
3723
|
+
button.dataset.grabbyMarker = comment.id;
|
|
3724
|
+
button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
|
|
3725
|
+
const entry = { comment, button, number, element: null, lastLookup: 0, context: "page", contextCheckedAt: -Infinity };
|
|
3726
|
+
button.addEventListener("click", (e) => {
|
|
3727
|
+
e.preventDefault();
|
|
3728
|
+
e.stopPropagation();
|
|
3729
|
+
hideTip();
|
|
3730
|
+
deps.onOpen(entry.comment, entry.element, button);
|
|
3731
|
+
});
|
|
3732
|
+
button.addEventListener("mouseenter", () => startHover(entry));
|
|
3733
|
+
button.addEventListener("focus", () => startHover(entry));
|
|
3734
|
+
button.addEventListener("mouseleave", () => endHover(entry));
|
|
3735
|
+
button.addEventListener("blur", () => endHover(entry));
|
|
3736
|
+
return entry;
|
|
3737
|
+
}
|
|
3738
|
+
function startHover(entry) {
|
|
3739
|
+
hovered = entry;
|
|
3740
|
+
showTip(entry);
|
|
3741
|
+
deps.onHover(entry.comment, entry.element);
|
|
3742
|
+
}
|
|
3743
|
+
function endHover(entry) {
|
|
3744
|
+
if (hovered !== entry) return;
|
|
3745
|
+
hovered = null;
|
|
3746
|
+
hideTip();
|
|
3747
|
+
deps.onHover(null, null);
|
|
3748
|
+
}
|
|
3749
|
+
function showTip(entry) {
|
|
3750
|
+
if (!tip) return;
|
|
3751
|
+
const hint = document.createElement("span");
|
|
3752
|
+
hint.className = "grabby-marker-tip-hint";
|
|
3753
|
+
hint.textContent = "Click to edit";
|
|
3754
|
+
tip.replaceChildren(document.createTextNode(preview(entry.comment.comment)), hint);
|
|
3755
|
+
tip.hidden = false;
|
|
3756
|
+
placeTip(entry);
|
|
3757
|
+
}
|
|
3758
|
+
function placeTip(entry) {
|
|
3759
|
+
if (!tip || tip.hidden) return;
|
|
3760
|
+
const m = entry.button.getBoundingClientRect();
|
|
3761
|
+
const t = tip.getBoundingClientRect();
|
|
3762
|
+
const left = Math.max(8, Math.min(m.left + m.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
|
|
3763
|
+
const below = m.bottom + 8;
|
|
3764
|
+
const top = below + t.height > window.innerHeight - 8 ? m.top - 8 - t.height : below;
|
|
3765
|
+
tip.style.left = `${left}px`;
|
|
3766
|
+
tip.style.top = `${Math.max(8, top)}px`;
|
|
3767
|
+
}
|
|
3768
|
+
function hideTip() {
|
|
3769
|
+
if (tip) tip.hidden = true;
|
|
3770
|
+
}
|
|
3771
|
+
function animateIn(button, delay) {
|
|
3772
|
+
button.classList.remove("grabby-marker-out", "grabby-marker-in");
|
|
3773
|
+
button.style.animationDelay = `${delay}ms`;
|
|
3774
|
+
void button.offsetWidth;
|
|
3775
|
+
button.classList.add("grabby-marker-in");
|
|
3776
|
+
}
|
|
3777
|
+
function removeEntry(id, animate) {
|
|
3778
|
+
const entry = entries.get(id);
|
|
3779
|
+
if (!entry) return;
|
|
3780
|
+
entries.delete(id);
|
|
3781
|
+
if (hovered === entry) endHover(entry);
|
|
3782
|
+
if (!animate) {
|
|
3783
|
+
entry.button.remove();
|
|
3784
|
+
return;
|
|
3785
|
+
}
|
|
3786
|
+
entry.button.style.animationDelay = "0ms";
|
|
3787
|
+
entry.button.classList.remove("grabby-marker-in");
|
|
3788
|
+
entry.button.classList.add("grabby-marker-out");
|
|
3789
|
+
setTimeout(() => entry.button.remove(), 220);
|
|
3790
|
+
}
|
|
3791
|
+
function sync(fresh) {
|
|
3792
|
+
if (!visible) return;
|
|
3793
|
+
const host2 = ensureLayer();
|
|
3794
|
+
const list = pageComments();
|
|
3795
|
+
const ids = new Set(list.map((c) => c.id));
|
|
3796
|
+
for (const id of [...entries.keys()]) if (!ids.has(id)) removeEntry(id, !fresh);
|
|
3797
|
+
list.forEach((comment, i) => {
|
|
3798
|
+
let entry = entries.get(comment.id);
|
|
3799
|
+
const isNew = !entry;
|
|
3800
|
+
if (!entry) {
|
|
3801
|
+
entry = createEntry(comment);
|
|
3802
|
+
entries.set(comment.id, entry);
|
|
3803
|
+
host2.appendChild(entry.button);
|
|
3804
|
+
}
|
|
3805
|
+
entry.comment = comment;
|
|
3806
|
+
const n = String(i + 1);
|
|
3807
|
+
entry.number.textContent = n;
|
|
3808
|
+
entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
|
|
3809
|
+
if (fresh || isNew) animateIn(entry.button, fresh ? i * STAGGER_MS : 0);
|
|
3810
|
+
});
|
|
3811
|
+
if (hovered && entries.get(hovered.comment.id) === hovered) showTip(hovered);
|
|
3812
|
+
position(performance.now());
|
|
3813
|
+
schedule();
|
|
3814
|
+
}
|
|
3815
|
+
function position(now) {
|
|
3816
|
+
for (const entry of entries.values()) {
|
|
3817
|
+
if (!entry.element?.isConnected) {
|
|
3818
|
+
entry.element = null;
|
|
3819
|
+
if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
|
|
3820
|
+
entry.lastLookup = now;
|
|
3821
|
+
entry.element = deps.findElement(entry.comment);
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
const rect = entry.element?.getBoundingClientRect();
|
|
3825
|
+
if (!rect || rect.width === 0 && rect.height === 0) {
|
|
3826
|
+
entry.button.hidden = true;
|
|
3827
|
+
continue;
|
|
3828
|
+
}
|
|
3829
|
+
if (now - entry.contextCheckedAt >= CONTEXT_CHECK_MS) {
|
|
3830
|
+
entry.contextCheckedAt = now;
|
|
3831
|
+
entry.context = scrollContextOf(entry.element);
|
|
3832
|
+
const home = entry.context === "page" ? docLayer : layer;
|
|
3833
|
+
if (home && entry.button.parentElement !== home) home.appendChild(entry.button);
|
|
3834
|
+
}
|
|
3835
|
+
const pin = entry.comment.pin ?? { x: 1, y: 0 };
|
|
3836
|
+
const maxX = (document.documentElement.clientWidth || window.innerWidth) - SIZE;
|
|
3837
|
+
let x = Math.max(0, Math.min(rect.left + pin.x * rect.width - SIZE / 2, maxX));
|
|
3838
|
+
let y = rect.top + pin.y * rect.height - SIZE / 2;
|
|
3839
|
+
if (entry.context === "page") {
|
|
3840
|
+
x += window.scrollX;
|
|
3841
|
+
y = Math.max(0, y + window.scrollY);
|
|
3842
|
+
}
|
|
3843
|
+
entry.button.hidden = false;
|
|
3844
|
+
entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
|
|
3845
|
+
}
|
|
3846
|
+
if (hovered) placeTip(hovered);
|
|
3847
|
+
}
|
|
3848
|
+
function frame() {
|
|
3849
|
+
rafId = null;
|
|
3850
|
+
const now = performance.now();
|
|
3851
|
+
if (!visible) return;
|
|
3852
|
+
if (now - lastRouteCheck >= ROUTE_CHECK_MS) {
|
|
3853
|
+
lastRouteCheck = now;
|
|
3854
|
+
const next = deps.currentRoute();
|
|
3855
|
+
if (next !== route) {
|
|
3856
|
+
route = next;
|
|
3857
|
+
for (const id of [...entries.keys()]) removeEntry(id, false);
|
|
3858
|
+
sync(true);
|
|
3859
|
+
return;
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
position(now);
|
|
3863
|
+
schedule();
|
|
3864
|
+
}
|
|
3865
|
+
function schedule() {
|
|
3866
|
+
if (rafId === null && visible) rafId = requestAnimationFrame(frame);
|
|
3867
|
+
}
|
|
3868
|
+
function stop() {
|
|
3869
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
3870
|
+
rafId = null;
|
|
3871
|
+
}
|
|
3872
|
+
function handleScroll() {
|
|
3873
|
+
if (visible && entries.size) position(performance.now());
|
|
3874
|
+
}
|
|
3875
|
+
return {
|
|
3876
|
+
setVisible(next) {
|
|
3877
|
+
if (next === visible) return;
|
|
3878
|
+
visible = next;
|
|
3879
|
+
if (next) {
|
|
3880
|
+
route = deps.currentRoute();
|
|
3881
|
+
lastRouteCheck = performance.now();
|
|
3882
|
+
document.addEventListener("scroll", handleScroll, { capture: true, passive: true });
|
|
3883
|
+
sync(true);
|
|
3884
|
+
} else {
|
|
3885
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
3886
|
+
stop();
|
|
3887
|
+
hideTip();
|
|
3888
|
+
if (hovered) endHover(hovered);
|
|
3889
|
+
for (const id of [...entries.keys()]) removeEntry(id, true);
|
|
3890
|
+
}
|
|
3891
|
+
},
|
|
3892
|
+
refresh() {
|
|
3893
|
+
sync(false);
|
|
3894
|
+
},
|
|
3895
|
+
isMarkerElement(el) {
|
|
3896
|
+
return [layer, docLayer].some((l) => !!l && (l === el || l.contains(el)));
|
|
3897
|
+
},
|
|
3898
|
+
dispose() {
|
|
3899
|
+
stop();
|
|
3900
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
3901
|
+
entries.clear();
|
|
3902
|
+
layer?.remove();
|
|
3903
|
+
docLayer?.remove();
|
|
3904
|
+
docLayer = null;
|
|
3905
|
+
tip?.remove();
|
|
3906
|
+
layer = null;
|
|
3907
|
+
tip = null;
|
|
3908
|
+
hovered = null;
|
|
3909
|
+
visible = false;
|
|
3910
|
+
removeStyles(STYLE_ID9);
|
|
3911
|
+
}
|
|
3912
|
+
};
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3453
3915
|
// src/core/overlay/select-feedback.ts
|
|
3454
|
-
var
|
|
3916
|
+
var STYLE_ID10 = "__grabby-feedback-styles__";
|
|
3455
3917
|
function injectStyles() {
|
|
3456
|
-
if (hasStyles(
|
|
3457
|
-
addStyles(
|
|
3918
|
+
if (hasStyles(STYLE_ID10)) return;
|
|
3919
|
+
addStyles(STYLE_ID10, `
|
|
3458
3920
|
@keyframes grabby-flash {
|
|
3459
3921
|
0% { opacity: 1; }
|
|
3460
3922
|
100% { opacity: 0; transform: scale(1.02); }
|
|
@@ -3533,7 +3995,7 @@ function showSelectFeedback(element, label = "Selected") {
|
|
|
3533
3995
|
setTimeout(cleanup, 1200);
|
|
3534
3996
|
}
|
|
3535
3997
|
function disposeFeedbackStyles() {
|
|
3536
|
-
removeStyles(
|
|
3998
|
+
removeStyles(STYLE_ID10);
|
|
3537
3999
|
}
|
|
3538
4000
|
|
|
3539
4001
|
// src/core/storage/history-persistence.ts
|
|
@@ -4721,7 +5183,10 @@ function createGrabInstance(options) {
|
|
|
4721
5183
|
let sourceResolver = adapters.resolveSource;
|
|
4722
5184
|
const cleanClasses = (list) => adapters.cleanClasses(list.filter((c) => !isNoiseClass(c)));
|
|
4723
5185
|
let selectedElement = null;
|
|
5186
|
+
let selectedPin;
|
|
4724
5187
|
let pendingShot = null;
|
|
5188
|
+
const commentedElements = /* @__PURE__ */ new Map();
|
|
5189
|
+
let editingFromMarker = false;
|
|
4725
5190
|
let level = loadLevel(merged.detailLevel);
|
|
4726
5191
|
let collapsed = loadCollapsed();
|
|
4727
5192
|
const pendingShotDeletes = /* @__PURE__ */ new Map();
|
|
@@ -4780,7 +5245,7 @@ function createGrabInstance(options) {
|
|
|
4780
5245
|
column: c.target.source?.column ?? null
|
|
4781
5246
|
};
|
|
4782
5247
|
}
|
|
4783
|
-
function saveComment(element, text, shot) {
|
|
5248
|
+
function saveComment(element, text, shot, pin) {
|
|
4784
5249
|
const now = Date.now();
|
|
4785
5250
|
const comment = {
|
|
4786
5251
|
id: randomId(),
|
|
@@ -4797,8 +5262,10 @@ function createGrabInstance(options) {
|
|
|
4797
5262
|
target: captureTarget(element, { componentResolver, sourceResolver, cleanClasses }),
|
|
4798
5263
|
screenshot: null,
|
|
4799
5264
|
framework: adapters.frameworkFor(element),
|
|
4800
|
-
...outbox ? { sync: "pending" } : {}
|
|
5265
|
+
...outbox ? { sync: "pending" } : {},
|
|
5266
|
+
...pin ? { pin } : {}
|
|
4801
5267
|
};
|
|
5268
|
+
commentedElements.set(comment.id, element);
|
|
4802
5269
|
setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
|
|
4803
5270
|
pluginRegistry.callHook("onComment", comment, element);
|
|
4804
5271
|
outbox?.send(comment.id);
|
|
@@ -4843,6 +5310,7 @@ function createGrabInstance(options) {
|
|
|
4843
5310
|
const idSet = new Set(ids);
|
|
4844
5311
|
const before = comments();
|
|
4845
5312
|
const removed = before.filter((c) => idSet.has(c.id));
|
|
5313
|
+
for (const id of ids) commentedElements.delete(id);
|
|
4846
5314
|
setComments(before.filter((c) => !idSet.has(c.id)));
|
|
4847
5315
|
const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
|
|
4848
5316
|
const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
|
|
@@ -4899,12 +5367,19 @@ function createGrabInstance(options) {
|
|
|
4899
5367
|
}
|
|
4900
5368
|
function hideCommentPopover() {
|
|
4901
5369
|
commentPopover.hide();
|
|
5370
|
+
endMarkerEdit();
|
|
4902
5371
|
if (picker.isHolding()) {
|
|
4903
5372
|
selectedElement = null;
|
|
5373
|
+
selectedPin = void 0;
|
|
4904
5374
|
pendingShot = null;
|
|
4905
5375
|
picker.release();
|
|
4906
5376
|
}
|
|
4907
5377
|
}
|
|
5378
|
+
function endMarkerEdit() {
|
|
5379
|
+
if (!editingFromMarker) return;
|
|
5380
|
+
editingFromMarker = false;
|
|
5381
|
+
overlay.hide();
|
|
5382
|
+
}
|
|
4908
5383
|
function closeAllPopovers() {
|
|
4909
5384
|
commentsPanel.hide();
|
|
4910
5385
|
hideCommentPopover();
|
|
@@ -4941,8 +5416,14 @@ function createGrabInstance(options) {
|
|
|
4941
5416
|
pluginRegistry.callHook("onElementHover", element);
|
|
4942
5417
|
}
|
|
4943
5418
|
},
|
|
4944
|
-
onSelect(element) {
|
|
5419
|
+
onSelect(element, point) {
|
|
4945
5420
|
selectedElement = element;
|
|
5421
|
+
const rect = element.getBoundingClientRect();
|
|
5422
|
+
const frac = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
|
|
5423
|
+
selectedPin = {
|
|
5424
|
+
x: Math.round(frac(point.x, rect.left, rect.width) * 1e3) / 1e3,
|
|
5425
|
+
y: Math.round(frac(point.y, rect.top, rect.height) * 1e3) / 1e3
|
|
5426
|
+
};
|
|
4946
5427
|
pendingShot = store.state.options.screenshots ? captureScreenshot(element) : null;
|
|
4947
5428
|
pluginRegistry.callHook("onElementSelect", element);
|
|
4948
5429
|
coachMark.dismiss();
|
|
@@ -4951,6 +5432,36 @@ function createGrabInstance(options) {
|
|
|
4951
5432
|
commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
|
|
4952
5433
|
}
|
|
4953
5434
|
});
|
|
5435
|
+
const markers = createMarkers({
|
|
5436
|
+
getComments: comments,
|
|
5437
|
+
currentRoute: () => sanitizeRoute(location, store.state.options.captureQueryParams),
|
|
5438
|
+
findElement(comment) {
|
|
5439
|
+
const known = commentedElements.get(comment.id);
|
|
5440
|
+
if (known?.isConnected) return known;
|
|
5441
|
+
return safeQuery(comment.target.selector);
|
|
5442
|
+
},
|
|
5443
|
+
onHover(comment, element) {
|
|
5444
|
+
if (picker.isHolding() || editingFromMarker || commentPopover.isVisible()) return;
|
|
5445
|
+
if (comment && element) overlay.show(element, comment.target.component, null, []);
|
|
5446
|
+
else overlay.hide();
|
|
5447
|
+
},
|
|
5448
|
+
onOpen(comment, element, marker) {
|
|
5449
|
+
if (picker.isHolding()) return;
|
|
5450
|
+
closeAllPopovers();
|
|
5451
|
+
doDeactivate(true);
|
|
5452
|
+
editingFromMarker = true;
|
|
5453
|
+
if (element) overlay.show(element, comment.target.component, null, []);
|
|
5454
|
+
commentPopover.show({
|
|
5455
|
+
anchor: element ?? marker,
|
|
5456
|
+
initialValue: comment.comment,
|
|
5457
|
+
mode: "edit",
|
|
5458
|
+
entryId: comment.id
|
|
5459
|
+
});
|
|
5460
|
+
}
|
|
5461
|
+
});
|
|
5462
|
+
function updateMarkers() {
|
|
5463
|
+
markers.setVisible(store.state.toolbar.visible && !collapsed && store.state.options.enabled);
|
|
5464
|
+
}
|
|
4954
5465
|
function doActivate() {
|
|
4955
5466
|
if (!store.state.options.enabled) return;
|
|
4956
5467
|
if (store.state.active) return;
|
|
@@ -5025,12 +5536,14 @@ function createGrabInstance(options) {
|
|
|
5025
5536
|
toolbar.collapse();
|
|
5026
5537
|
saveCollapsed(true);
|
|
5027
5538
|
updateToastOffset();
|
|
5539
|
+
updateMarkers();
|
|
5028
5540
|
}
|
|
5029
5541
|
function expandToolbar() {
|
|
5030
5542
|
collapsed = false;
|
|
5031
5543
|
toolbar.expand();
|
|
5032
5544
|
saveCollapsed(false);
|
|
5033
5545
|
updateToastOffset();
|
|
5546
|
+
updateMarkers();
|
|
5034
5547
|
}
|
|
5035
5548
|
const commentsPanel = createCommentsPanel({
|
|
5036
5549
|
onHover(comment) {
|
|
@@ -5118,9 +5631,11 @@ function createGrabInstance(options) {
|
|
|
5118
5631
|
if (ctx.mode === "new") {
|
|
5119
5632
|
const element = selectedElement;
|
|
5120
5633
|
const shot = pendingShot;
|
|
5634
|
+
const pin = selectedPin;
|
|
5121
5635
|
selectedElement = null;
|
|
5636
|
+
selectedPin = void 0;
|
|
5122
5637
|
pendingShot = null;
|
|
5123
|
-
if (element) saveComment(element, value, shot);
|
|
5638
|
+
if (element) saveComment(element, value, shot, pin);
|
|
5124
5639
|
doDeactivate(true);
|
|
5125
5640
|
return;
|
|
5126
5641
|
}
|
|
@@ -5131,16 +5646,23 @@ function createGrabInstance(options) {
|
|
|
5131
5646
|
setComments(updated);
|
|
5132
5647
|
outbox?.send(ctx.entryId);
|
|
5133
5648
|
showToast("Comment updated");
|
|
5134
|
-
|
|
5649
|
+
if (editingFromMarker) endMarkerEdit();
|
|
5650
|
+
else commentsPanel.show([...updated]);
|
|
5135
5651
|
},
|
|
5136
5652
|
onCancel(ctx) {
|
|
5137
5653
|
if (ctx.mode === "new") {
|
|
5138
5654
|
selectedElement = null;
|
|
5655
|
+
selectedPin = void 0;
|
|
5139
5656
|
pendingShot = null;
|
|
5140
5657
|
doDeactivate(true);
|
|
5141
5658
|
return;
|
|
5142
5659
|
}
|
|
5143
|
-
|
|
5660
|
+
if (editingFromMarker) endMarkerEdit();
|
|
5661
|
+
else commentsPanel.show([...comments()]);
|
|
5662
|
+
},
|
|
5663
|
+
onDelete(ctx) {
|
|
5664
|
+
endMarkerEdit();
|
|
5665
|
+
if (ctx.entryId) removeComments([ctx.entryId], "Comment deleted", true);
|
|
5144
5666
|
}
|
|
5145
5667
|
});
|
|
5146
5668
|
function handleDocumentClick(e) {
|
|
@@ -5296,6 +5818,7 @@ function createGrabInstance(options) {
|
|
|
5296
5818
|
overlay.dispose();
|
|
5297
5819
|
crosshair.dispose();
|
|
5298
5820
|
freezeOverlay.dispose();
|
|
5821
|
+
markers.dispose();
|
|
5299
5822
|
disposeToast();
|
|
5300
5823
|
disposeFeedbackStyles();
|
|
5301
5824
|
pluginRegistry.dispose();
|
|
@@ -5332,8 +5855,11 @@ function createGrabInstance(options) {
|
|
|
5332
5855
|
doDeactivate(true);
|
|
5333
5856
|
}
|
|
5334
5857
|
}
|
|
5858
|
+
if (key === "options") updateMarkers();
|
|
5335
5859
|
if (key === "toolbar") {
|
|
5336
5860
|
updateToastOffset();
|
|
5861
|
+
updateMarkers();
|
|
5862
|
+
markers.refresh();
|
|
5337
5863
|
if (state.options.persistHistory) {
|
|
5338
5864
|
if (state.toolbar.comments.length > 0) {
|
|
5339
5865
|
saveHistory(state.toolbar.comments);
|
|
@@ -5355,6 +5881,7 @@ function createGrabInstance(options) {
|
|
|
5355
5881
|
if (merged.webhookUrl) {
|
|
5356
5882
|
api.registerPlugin(createWebhookPlugin(merged.webhookUrl));
|
|
5357
5883
|
}
|
|
5884
|
+
updateMarkers();
|
|
5358
5885
|
return api;
|
|
5359
5886
|
}
|
|
5360
5887
|
export {
|