@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/react/index.js
CHANGED
|
@@ -1211,7 +1211,7 @@ function createElementPicker(deps) {
|
|
|
1211
1211
|
e.stopPropagation();
|
|
1212
1212
|
if (heldElement) return;
|
|
1213
1213
|
if (hoveredElement) {
|
|
1214
|
-
deps.onSelect(hoveredElement);
|
|
1214
|
+
deps.onSelect(hoveredElement, { x: e.clientX, y: e.clientY });
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
1217
|
return {
|
|
@@ -1469,7 +1469,8 @@ function createWebhookPlugin(url) {
|
|
|
1469
1469
|
type: "grabby.comment",
|
|
1470
1470
|
version: 1,
|
|
1471
1471
|
origin: typeof location !== "undefined" ? location.origin : null,
|
|
1472
|
-
|
|
1472
|
+
// The marker position is browser-only.
|
|
1473
|
+
comment: { ...comment, pin: void 0 }
|
|
1473
1474
|
})
|
|
1474
1475
|
}).catch(() => {
|
|
1475
1476
|
});
|
|
@@ -1561,6 +1562,9 @@ ${vars.join("\n")}
|
|
|
1561
1562
|
|
|
1562
1563
|
// src/core/toolbar/toolbar-renderer.ts
|
|
1563
1564
|
var TOOLBAR_ID = "__grabby-toolbar__";
|
|
1565
|
+
var COLLAPSED_SIZE = 42;
|
|
1566
|
+
var EASE_OUT_EXPO = "cubic-bezier(0.19, 1, 0.22, 1)";
|
|
1567
|
+
var MORPH_MS = 360;
|
|
1564
1568
|
var STYLE_ID3 = "__grabby-toolbar-styles__";
|
|
1565
1569
|
function syncSummary(comments) {
|
|
1566
1570
|
if (comments.length === 0) return null;
|
|
@@ -1582,7 +1586,13 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1582
1586
|
let badge = null;
|
|
1583
1587
|
let status = null;
|
|
1584
1588
|
let expandBadge = null;
|
|
1589
|
+
let content = null;
|
|
1585
1590
|
let collapsed = false;
|
|
1591
|
+
let morphTimer = null;
|
|
1592
|
+
function clearMorph() {
|
|
1593
|
+
if (morphTimer) clearTimeout(morphTimer);
|
|
1594
|
+
morphTimer = null;
|
|
1595
|
+
}
|
|
1586
1596
|
function injectStyles2() {
|
|
1587
1597
|
if (hasStyles(STYLE_ID3)) return;
|
|
1588
1598
|
addStyles(STYLE_ID3, `
|
|
@@ -1602,7 +1612,21 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1602
1612
|
box-shadow: 0 4px 16px var(--grabby-toolbar-shadow, rgba(0, 0, 0, 0.12));
|
|
1603
1613
|
pointer-events: auto;
|
|
1604
1614
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
1605
|
-
|
|
1615
|
+
box-sizing: border-box;
|
|
1616
|
+
height: ${COLLAPSED_SIZE}px;
|
|
1617
|
+
overflow: hidden;
|
|
1618
|
+
justify-content: flex-end;
|
|
1619
|
+
transition: opacity 0.2s ease, transform 0.2s ease,
|
|
1620
|
+
left ${MORPH_MS}ms ${EASE_OUT_EXPO}, width ${MORPH_MS}ms ${EASE_OUT_EXPO};
|
|
1621
|
+
}
|
|
1622
|
+
#${TOOLBAR_ID} .grabby-toolbar-content {
|
|
1623
|
+
display: flex;
|
|
1624
|
+
align-items: center;
|
|
1625
|
+
gap: 2px;
|
|
1626
|
+
flex-shrink: 0;
|
|
1627
|
+
transform-origin: right center;
|
|
1628
|
+
transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
|
|
1629
|
+
transform 0.42s ${EASE_OUT_EXPO}, visibility 0s;
|
|
1606
1630
|
}
|
|
1607
1631
|
#${TOOLBAR_ID}.grabby-toolbar-hidden {
|
|
1608
1632
|
opacity: 0;
|
|
@@ -1698,23 +1722,44 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1698
1722
|
background: var(--grabby-accent-hover, #1d4ed8);
|
|
1699
1723
|
color: #fff;
|
|
1700
1724
|
}
|
|
1701
|
-
#${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1725
|
+
#${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1726
|
+
position: absolute;
|
|
1727
|
+
left: 50%;
|
|
1728
|
+
top: 50%;
|
|
1729
|
+
translate: -50% -50%;
|
|
1730
|
+
color: var(--grabby-accent, #2563eb);
|
|
1731
|
+
opacity: 0;
|
|
1732
|
+
scale: 0.6;
|
|
1733
|
+
visibility: hidden;
|
|
1734
|
+
pointer-events: none;
|
|
1735
|
+
transition: opacity 0.2s ease-out, scale 0.3s ${EASE_OUT_EXPO}, visibility 0s 0.2s;
|
|
1736
|
+
}
|
|
1737
|
+
#${TOOLBAR_ID} button.grabby-btn-expand .grabby-badge { top: -3px; right: -5px; }
|
|
1702
1738
|
#${TOOLBAR_ID}.grabby-toolbar-collapsed {
|
|
1703
|
-
left:
|
|
1704
|
-
right: 20px;
|
|
1705
|
-
transform: none;
|
|
1739
|
+
left: calc(100% - 20px - ${COLLAPSED_SIZE / 2}px);
|
|
1706
1740
|
padding: 4px;
|
|
1707
1741
|
}
|
|
1708
|
-
#${TOOLBAR_ID}.grabby-toolbar-collapsed.grabby-toolbar-
|
|
1709
|
-
|
|
1742
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed .grabby-toolbar-content {
|
|
1743
|
+
opacity: 0;
|
|
1744
|
+
filter: blur(6px);
|
|
1745
|
+
transform: scale(0.4);
|
|
1746
|
+
pointer-events: none;
|
|
1747
|
+
visibility: hidden;
|
|
1748
|
+
transition: opacity 0.24s ease-out, filter 0.3s cubic-bezier(0.22, 1, 0.36, 1),
|
|
1749
|
+
transform 0.42s ${EASE_OUT_EXPO}, visibility 0s 0.3s;
|
|
1710
1750
|
}
|
|
1711
|
-
#${TOOLBAR_ID}.grabby-toolbar-collapsed
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1751
|
+
#${TOOLBAR_ID}.grabby-toolbar-collapsed button.grabby-btn-expand {
|
|
1752
|
+
opacity: 1;
|
|
1753
|
+
scale: 1;
|
|
1754
|
+
visibility: visible;
|
|
1755
|
+
pointer-events: auto;
|
|
1756
|
+
transition: opacity 0.24s ease-out 0.08s, scale 0.36s ${EASE_OUT_EXPO} 0.08s, visibility 0s;
|
|
1757
|
+
}
|
|
1758
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1759
|
+
#${TOOLBAR_ID}, #${TOOLBAR_ID} .grabby-toolbar-content, #${TOOLBAR_ID} button.grabby-btn-expand {
|
|
1760
|
+
transition-duration: 0s !important;
|
|
1761
|
+
transition-delay: 0s !important;
|
|
1762
|
+
}
|
|
1718
1763
|
}
|
|
1719
1764
|
#${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
|
|
1720
1765
|
max-width: 0;
|
|
@@ -1769,7 +1814,9 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1769
1814
|
leftGroup.appendChild(buttons.selection);
|
|
1770
1815
|
leftGroup.appendChild(buttons.history);
|
|
1771
1816
|
leftGroup.appendChild(divider);
|
|
1772
|
-
|
|
1817
|
+
content = document.createElement("div");
|
|
1818
|
+
content.className = "grabby-toolbar-content";
|
|
1819
|
+
content.appendChild(leftGroup);
|
|
1773
1820
|
if (options.review) {
|
|
1774
1821
|
status = document.createElement("span");
|
|
1775
1822
|
status.className = "grabby-toolbar-status";
|
|
@@ -1786,18 +1833,22 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1786
1833
|
e.stopPropagation();
|
|
1787
1834
|
callbacks.onFinish?.();
|
|
1788
1835
|
});
|
|
1789
|
-
|
|
1790
|
-
|
|
1836
|
+
content.appendChild(status);
|
|
1837
|
+
content.appendChild(buttons.finish);
|
|
1791
1838
|
allElements.add(status);
|
|
1792
1839
|
}
|
|
1793
|
-
if (!options.hideEnable)
|
|
1794
|
-
|
|
1795
|
-
container.
|
|
1796
|
-
|
|
1840
|
+
if (!options.hideEnable) content.appendChild(buttons.enable);
|
|
1841
|
+
content.appendChild(buttons.dismiss);
|
|
1842
|
+
container.append(content, buttons.expand);
|
|
1843
|
+
if (collapsed) {
|
|
1844
|
+
container.classList.add("grabby-toolbar-collapsed");
|
|
1845
|
+
container.style.width = `${COLLAPSED_SIZE}px`;
|
|
1846
|
+
}
|
|
1797
1847
|
getUiRoot().appendChild(container);
|
|
1798
1848
|
allElements.clear();
|
|
1799
1849
|
allElements.add(container);
|
|
1800
1850
|
allElements.add(leftGroup);
|
|
1851
|
+
allElements.add(content);
|
|
1801
1852
|
allElements.add(divider);
|
|
1802
1853
|
for (const btn of Object.values(buttons)) {
|
|
1803
1854
|
allElements.add(btn);
|
|
@@ -1843,12 +1894,28 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1843
1894
|
}
|
|
1844
1895
|
},
|
|
1845
1896
|
collapse() {
|
|
1897
|
+
if (collapsed) return;
|
|
1846
1898
|
collapsed = true;
|
|
1847
|
-
container
|
|
1899
|
+
if (!container) return;
|
|
1900
|
+
clearMorph();
|
|
1901
|
+
container.style.width = `${container.offsetWidth}px`;
|
|
1902
|
+
void container.offsetWidth;
|
|
1903
|
+
container.classList.add("grabby-toolbar-collapsed");
|
|
1904
|
+
container.style.width = `${COLLAPSED_SIZE}px`;
|
|
1848
1905
|
},
|
|
1849
1906
|
expand() {
|
|
1907
|
+
if (!collapsed) return;
|
|
1850
1908
|
collapsed = false;
|
|
1851
|
-
container
|
|
1909
|
+
if (!container) return;
|
|
1910
|
+
clearMorph();
|
|
1911
|
+
container.classList.remove("grabby-toolbar-collapsed");
|
|
1912
|
+
const cs = getComputedStyle(container);
|
|
1913
|
+
const chrome = ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"].reduce((sum, k) => sum + (parseFloat(cs[k]) || 0), 0);
|
|
1914
|
+
container.style.width = `${(content?.offsetWidth ?? 0) + chrome}px`;
|
|
1915
|
+
morphTimer = setTimeout(() => {
|
|
1916
|
+
morphTimer = null;
|
|
1917
|
+
if (!collapsed && container) container.style.width = "";
|
|
1918
|
+
}, MORPH_MS + 40);
|
|
1852
1919
|
},
|
|
1853
1920
|
isCollapsed() {
|
|
1854
1921
|
return collapsed;
|
|
@@ -1864,10 +1931,12 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1864
1931
|
return false;
|
|
1865
1932
|
},
|
|
1866
1933
|
dispose() {
|
|
1934
|
+
clearMorph();
|
|
1867
1935
|
container?.remove();
|
|
1868
1936
|
removeStyles(STYLE_ID3);
|
|
1869
1937
|
container = null;
|
|
1870
1938
|
leftGroup = null;
|
|
1939
|
+
content = null;
|
|
1871
1940
|
buttons = {};
|
|
1872
1941
|
badge = null;
|
|
1873
1942
|
expandBadge = null;
|
|
@@ -2437,6 +2506,18 @@ function createCommentPopover(callbacks) {
|
|
|
2437
2506
|
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
|
|
2438
2507
|
background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
|
|
2439
2508
|
}
|
|
2509
|
+
#${POPOVER_ID} .grabby-cp-edit-actions { display: flex; align-items: center; gap: 6px; }
|
|
2510
|
+
#${POPOVER_ID} .grabby-cp-edit-actions .grabby-cp-spacer { flex: 1; }
|
|
2511
|
+
#${POPOVER_ID} .grabby-cp-delete {
|
|
2512
|
+
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 6px; border: none;
|
|
2513
|
+
border-radius: 8px; background: transparent; color: #b91c1c; cursor: pointer;
|
|
2514
|
+
}
|
|
2515
|
+
#${POPOVER_ID} .grabby-cp-delete:hover { background: rgba(185, 28, 28, 0.08); }
|
|
2516
|
+
#${POPOVER_ID} .grabby-cp-cancel {
|
|
2517
|
+
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 10px; border: none;
|
|
2518
|
+
border-radius: 8px; background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer;
|
|
2519
|
+
}
|
|
2520
|
+
#${POPOVER_ID} .grabby-cp-cancel:hover { background: var(--grabby-surface, #f1f5f9); }
|
|
2440
2521
|
#${POPOVER_ID} .grabby-cp-hint {
|
|
2441
2522
|
font-size: 11px;
|
|
2442
2523
|
color: var(--grabby-text-muted, #94a3b8);
|
|
@@ -2498,6 +2579,37 @@ function createCommentPopover(callbacks) {
|
|
|
2498
2579
|
function isEditable(el) {
|
|
2499
2580
|
return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
|
|
2500
2581
|
}
|
|
2582
|
+
function save() {
|
|
2583
|
+
const v = textarea?.value.trim();
|
|
2584
|
+
if (!v) return;
|
|
2585
|
+
pendingValue = v;
|
|
2586
|
+
if (askIdentity) showIdentityStep();
|
|
2587
|
+
else finish();
|
|
2588
|
+
}
|
|
2589
|
+
function editActions() {
|
|
2590
|
+
const act = (fn) => (e) => {
|
|
2591
|
+
e.stopPropagation();
|
|
2592
|
+
fn();
|
|
2593
|
+
};
|
|
2594
|
+
const cancel = () => {
|
|
2595
|
+
const ctx = currentCtx;
|
|
2596
|
+
doHide();
|
|
2597
|
+
callbacks.onCancel(ctx);
|
|
2598
|
+
};
|
|
2599
|
+
const del = () => {
|
|
2600
|
+
const ctx = currentCtx;
|
|
2601
|
+
doHide();
|
|
2602
|
+
callbacks.onDelete?.(ctx);
|
|
2603
|
+
};
|
|
2604
|
+
return h(
|
|
2605
|
+
"div",
|
|
2606
|
+
{ class: "grabby-cp-edit-actions" },
|
|
2607
|
+
callbacks.onDelete ? h("button", { type: "button", class: "grabby-cp-delete", "data-grabby-delete": "", onclick: act(del) }, "Delete") : null,
|
|
2608
|
+
h("span", { class: "grabby-cp-spacer" }),
|
|
2609
|
+
h("button", { type: "button", class: "grabby-cp-cancel", "data-grabby-cancel": "", onclick: act(cancel) }, "Cancel"),
|
|
2610
|
+
h("button", { type: "button", class: "grabby-cp-post", "data-grabby-save": "", onclick: act(save) }, "Save")
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2501
2613
|
function finish(identity) {
|
|
2502
2614
|
const ctx = currentCtx;
|
|
2503
2615
|
const value = pendingValue;
|
|
@@ -2563,11 +2675,7 @@ function createCommentPopover(callbacks) {
|
|
|
2563
2675
|
e.stopImmediatePropagation();
|
|
2564
2676
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2565
2677
|
e.preventDefault();
|
|
2566
|
-
|
|
2567
|
-
if (!v) return;
|
|
2568
|
-
pendingValue = v;
|
|
2569
|
-
if (askIdentity) showIdentityStep();
|
|
2570
|
-
else finish();
|
|
2678
|
+
save();
|
|
2571
2679
|
} else if (e.key === "Escape") {
|
|
2572
2680
|
e.preventDefault();
|
|
2573
2681
|
const ctx = currentCtx;
|
|
@@ -2601,6 +2709,7 @@ function createCommentPopover(callbacks) {
|
|
|
2601
2709
|
currentCtx = { mode: opts.mode, entryId: opts.entryId };
|
|
2602
2710
|
askIdentity = opts.askIdentity === true && opts.mode === "new";
|
|
2603
2711
|
visible = true;
|
|
2712
|
+
if (opts.mode === "edit") el.appendChild(editActions());
|
|
2604
2713
|
position(el, opts.anchor);
|
|
2605
2714
|
attachKey();
|
|
2606
2715
|
textarea?.focus();
|
|
@@ -3132,9 +3241,10 @@ function createOutbox(deps) {
|
|
|
3132
3241
|
}, delay);
|
|
3133
3242
|
}
|
|
3134
3243
|
function wireShape(c) {
|
|
3135
|
-
const { screenshot: _shot, sync: _sync, ...rest } = c;
|
|
3244
|
+
const { screenshot: _shot, sync: _sync, pin: _pin, ...rest } = c;
|
|
3136
3245
|
void _shot;
|
|
3137
3246
|
void _sync;
|
|
3247
|
+
void _pin;
|
|
3138
3248
|
return rest;
|
|
3139
3249
|
}
|
|
3140
3250
|
function postComment(comment) {
|
|
@@ -3483,11 +3593,363 @@ function createFreezeOverlay() {
|
|
|
3483
3593
|
};
|
|
3484
3594
|
}
|
|
3485
3595
|
|
|
3596
|
+
// src/core/overlay/markers.ts
|
|
3597
|
+
var LAYER_ID = "__grabby-markers__";
|
|
3598
|
+
var DOC_LAYER_ID = "__grabby-markers-doc__";
|
|
3599
|
+
var CONTEXT_CHECK_MS = 1e3;
|
|
3600
|
+
var TIP_ID = "__grabby-marker-tip__";
|
|
3601
|
+
var STYLE_ID9 = "__grabby-marker-styles__";
|
|
3602
|
+
var SIZE = 22;
|
|
3603
|
+
var ROUTE_CHECK_MS = 250;
|
|
3604
|
+
var LOOKUP_RETRY_MS = 500;
|
|
3605
|
+
var STAGGER_MS = 30;
|
|
3606
|
+
var TIP_MAX = 140;
|
|
3607
|
+
var ICON_EDIT = {
|
|
3608
|
+
size: 12,
|
|
3609
|
+
shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
|
|
3610
|
+
};
|
|
3611
|
+
function scrollContextOf(el) {
|
|
3612
|
+
for (let cur = el.parentElement; cur && cur !== document.body && cur !== document.documentElement; cur = cur.parentElement) {
|
|
3613
|
+
const style = getComputedStyle(cur);
|
|
3614
|
+
if (style.position === "fixed" || style.position === "sticky") return "screen";
|
|
3615
|
+
if (/(auto|scroll|overlay)/.test(style.overflowY + style.overflowX)) return "screen";
|
|
3616
|
+
}
|
|
3617
|
+
const own = getComputedStyle(el).position;
|
|
3618
|
+
return own === "fixed" || own === "sticky" ? "screen" : "page";
|
|
3619
|
+
}
|
|
3620
|
+
function createMarkers(deps) {
|
|
3621
|
+
let layer = null;
|
|
3622
|
+
let docLayer = null;
|
|
3623
|
+
let tip = null;
|
|
3624
|
+
let visible = false;
|
|
3625
|
+
let route = "";
|
|
3626
|
+
let rafId = null;
|
|
3627
|
+
let lastRouteCheck = 0;
|
|
3628
|
+
let hovered = null;
|
|
3629
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3630
|
+
function injectStyles2() {
|
|
3631
|
+
if (hasStyles(STYLE_ID9)) return;
|
|
3632
|
+
addStyles(STYLE_ID9, `
|
|
3633
|
+
/*
|
|
3634
|
+
* Page coordinates: the browser moves these with the page as it
|
|
3635
|
+
* scrolls, so they never trail behind their element. (A fixed layer
|
|
3636
|
+
* repositioned from script lags a frame behind fast scrolling.)
|
|
3637
|
+
*/
|
|
3638
|
+
#${DOC_LAYER_ID} {
|
|
3639
|
+
position: absolute;
|
|
3640
|
+
left: 0;
|
|
3641
|
+
top: 0;
|
|
3642
|
+
width: 0;
|
|
3643
|
+
height: 0;
|
|
3644
|
+
pointer-events: none;
|
|
3645
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3646
|
+
}
|
|
3647
|
+
#${LAYER_ID} {
|
|
3648
|
+
position: fixed;
|
|
3649
|
+
inset: 0;
|
|
3650
|
+
pointer-events: none;
|
|
3651
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3652
|
+
}
|
|
3653
|
+
.grabby-markers-layer .grabby-marker {
|
|
3654
|
+
position: absolute;
|
|
3655
|
+
left: 0;
|
|
3656
|
+
top: 0;
|
|
3657
|
+
width: ${SIZE}px;
|
|
3658
|
+
height: ${SIZE}px;
|
|
3659
|
+
margin: 0;
|
|
3660
|
+
padding: 0;
|
|
3661
|
+
border: none;
|
|
3662
|
+
border-radius: 50%;
|
|
3663
|
+
background: var(--grabby-accent, #2563eb);
|
|
3664
|
+
color: #fff;
|
|
3665
|
+
box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3666
|
+
font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3667
|
+
display: flex;
|
|
3668
|
+
align-items: center;
|
|
3669
|
+
justify-content: center;
|
|
3670
|
+
cursor: pointer;
|
|
3671
|
+
pointer-events: auto;
|
|
3672
|
+
transition: transform 0.12s ease, box-shadow 0.15s ease;
|
|
3673
|
+
}
|
|
3674
|
+
.grabby-markers-layer .grabby-marker[hidden] { display: none; }
|
|
3675
|
+
.grabby-markers-layer .grabby-marker:hover,
|
|
3676
|
+
.grabby-markers-layer .grabby-marker:focus-visible {
|
|
3677
|
+
z-index: 1;
|
|
3678
|
+
outline: none;
|
|
3679
|
+
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);
|
|
3680
|
+
}
|
|
3681
|
+
.grabby-markers-layer .grabby-marker-edit { display: none; }
|
|
3682
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-num,
|
|
3683
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-num { display: none; }
|
|
3684
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-edit,
|
|
3685
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
|
|
3686
|
+
.grabby-markers-layer .grabby-marker-in {
|
|
3687
|
+
animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
3688
|
+
}
|
|
3689
|
+
.grabby-markers-layer .grabby-marker-out {
|
|
3690
|
+
animation: grabby-marker-out 0.2s ease-out both;
|
|
3691
|
+
pointer-events: none;
|
|
3692
|
+
}
|
|
3693
|
+
@keyframes grabby-marker-in {
|
|
3694
|
+
from { opacity: 0; scale: 0.3; }
|
|
3695
|
+
to { opacity: 1; scale: 1; }
|
|
3696
|
+
}
|
|
3697
|
+
@keyframes grabby-marker-out {
|
|
3698
|
+
from { opacity: 1; scale: 1; }
|
|
3699
|
+
to { opacity: 0; scale: 0.3; }
|
|
3700
|
+
}
|
|
3701
|
+
#${TIP_ID} {
|
|
3702
|
+
position: fixed;
|
|
3703
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3704
|
+
max-width: 260px;
|
|
3705
|
+
padding: 8px 10px;
|
|
3706
|
+
border-radius: 10px;
|
|
3707
|
+
background: var(--grabby-label-bg, #1e293b);
|
|
3708
|
+
color: #fff;
|
|
3709
|
+
font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3710
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
|
|
3711
|
+
pointer-events: none;
|
|
3712
|
+
white-space: pre-wrap;
|
|
3713
|
+
overflow-wrap: anywhere;
|
|
3714
|
+
animation: grabby-marker-tip-in 0.12s ease both;
|
|
3715
|
+
}
|
|
3716
|
+
#${TIP_ID}[hidden] { display: none; }
|
|
3717
|
+
#${TIP_ID} .grabby-marker-tip-hint { display: block; margin-top: 4px; opacity: 0.6; font-size: 11px; }
|
|
3718
|
+
@keyframes grabby-marker-tip-in {
|
|
3719
|
+
from { opacity: 0; transform: translateY(-2px); }
|
|
3720
|
+
to { opacity: 1; transform: none; }
|
|
3721
|
+
}
|
|
3722
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3723
|
+
.grabby-markers-layer .grabby-marker-in, .grabby-markers-layer .grabby-marker-out, #${TIP_ID} { animation: none; }
|
|
3724
|
+
}
|
|
3725
|
+
`);
|
|
3726
|
+
}
|
|
3727
|
+
function ensureLayer() {
|
|
3728
|
+
if (layer) return layer;
|
|
3729
|
+
injectStyles2();
|
|
3730
|
+
layer = document.createElement("div");
|
|
3731
|
+
layer.id = LAYER_ID;
|
|
3732
|
+
layer.className = "grabby-markers-layer";
|
|
3733
|
+
docLayer = document.createElement("div");
|
|
3734
|
+
docLayer.id = DOC_LAYER_ID;
|
|
3735
|
+
docLayer.className = "grabby-markers-layer";
|
|
3736
|
+
tip = document.createElement("div");
|
|
3737
|
+
tip.id = TIP_ID;
|
|
3738
|
+
tip.hidden = true;
|
|
3739
|
+
tip.setAttribute("role", "tooltip");
|
|
3740
|
+
getUiRoot().append(docLayer, layer, tip);
|
|
3741
|
+
return layer;
|
|
3742
|
+
}
|
|
3743
|
+
function pageComments() {
|
|
3744
|
+
return deps.getComments().filter((c) => c.page.route === route).reverse();
|
|
3745
|
+
}
|
|
3746
|
+
function preview(text) {
|
|
3747
|
+
const flat = text.trim();
|
|
3748
|
+
return flat.length > TIP_MAX ? `${flat.slice(0, TIP_MAX - 1)}\u2026` : flat;
|
|
3749
|
+
}
|
|
3750
|
+
function createEntry(comment) {
|
|
3751
|
+
const number = document.createElement("span");
|
|
3752
|
+
number.className = "grabby-marker-num";
|
|
3753
|
+
const button = document.createElement("button");
|
|
3754
|
+
button.type = "button";
|
|
3755
|
+
button.className = "grabby-marker";
|
|
3756
|
+
button.dataset.grabbyMarker = comment.id;
|
|
3757
|
+
button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
|
|
3758
|
+
const entry = { comment, button, number, element: null, lastLookup: 0, context: "page", contextCheckedAt: -Infinity };
|
|
3759
|
+
button.addEventListener("click", (e) => {
|
|
3760
|
+
e.preventDefault();
|
|
3761
|
+
e.stopPropagation();
|
|
3762
|
+
hideTip();
|
|
3763
|
+
deps.onOpen(entry.comment, entry.element, button);
|
|
3764
|
+
});
|
|
3765
|
+
button.addEventListener("mouseenter", () => startHover(entry));
|
|
3766
|
+
button.addEventListener("focus", () => startHover(entry));
|
|
3767
|
+
button.addEventListener("mouseleave", () => endHover(entry));
|
|
3768
|
+
button.addEventListener("blur", () => endHover(entry));
|
|
3769
|
+
return entry;
|
|
3770
|
+
}
|
|
3771
|
+
function startHover(entry) {
|
|
3772
|
+
hovered = entry;
|
|
3773
|
+
showTip(entry);
|
|
3774
|
+
deps.onHover(entry.comment, entry.element);
|
|
3775
|
+
}
|
|
3776
|
+
function endHover(entry) {
|
|
3777
|
+
if (hovered !== entry) return;
|
|
3778
|
+
hovered = null;
|
|
3779
|
+
hideTip();
|
|
3780
|
+
deps.onHover(null, null);
|
|
3781
|
+
}
|
|
3782
|
+
function showTip(entry) {
|
|
3783
|
+
if (!tip) return;
|
|
3784
|
+
const hint = document.createElement("span");
|
|
3785
|
+
hint.className = "grabby-marker-tip-hint";
|
|
3786
|
+
hint.textContent = "Click to edit";
|
|
3787
|
+
tip.replaceChildren(document.createTextNode(preview(entry.comment.comment)), hint);
|
|
3788
|
+
tip.hidden = false;
|
|
3789
|
+
placeTip(entry);
|
|
3790
|
+
}
|
|
3791
|
+
function placeTip(entry) {
|
|
3792
|
+
if (!tip || tip.hidden) return;
|
|
3793
|
+
const m = entry.button.getBoundingClientRect();
|
|
3794
|
+
const t = tip.getBoundingClientRect();
|
|
3795
|
+
const left = Math.max(8, Math.min(m.left + m.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
|
|
3796
|
+
const below = m.bottom + 8;
|
|
3797
|
+
const top = below + t.height > window.innerHeight - 8 ? m.top - 8 - t.height : below;
|
|
3798
|
+
tip.style.left = `${left}px`;
|
|
3799
|
+
tip.style.top = `${Math.max(8, top)}px`;
|
|
3800
|
+
}
|
|
3801
|
+
function hideTip() {
|
|
3802
|
+
if (tip) tip.hidden = true;
|
|
3803
|
+
}
|
|
3804
|
+
function animateIn(button, delay) {
|
|
3805
|
+
button.classList.remove("grabby-marker-out", "grabby-marker-in");
|
|
3806
|
+
button.style.animationDelay = `${delay}ms`;
|
|
3807
|
+
void button.offsetWidth;
|
|
3808
|
+
button.classList.add("grabby-marker-in");
|
|
3809
|
+
}
|
|
3810
|
+
function removeEntry(id, animate) {
|
|
3811
|
+
const entry = entries.get(id);
|
|
3812
|
+
if (!entry) return;
|
|
3813
|
+
entries.delete(id);
|
|
3814
|
+
if (hovered === entry) endHover(entry);
|
|
3815
|
+
if (!animate) {
|
|
3816
|
+
entry.button.remove();
|
|
3817
|
+
return;
|
|
3818
|
+
}
|
|
3819
|
+
entry.button.style.animationDelay = "0ms";
|
|
3820
|
+
entry.button.classList.remove("grabby-marker-in");
|
|
3821
|
+
entry.button.classList.add("grabby-marker-out");
|
|
3822
|
+
setTimeout(() => entry.button.remove(), 220);
|
|
3823
|
+
}
|
|
3824
|
+
function sync(fresh) {
|
|
3825
|
+
if (!visible) return;
|
|
3826
|
+
const host2 = ensureLayer();
|
|
3827
|
+
const list = pageComments();
|
|
3828
|
+
const ids = new Set(list.map((c) => c.id));
|
|
3829
|
+
for (const id of [...entries.keys()]) if (!ids.has(id)) removeEntry(id, !fresh);
|
|
3830
|
+
list.forEach((comment, i) => {
|
|
3831
|
+
let entry = entries.get(comment.id);
|
|
3832
|
+
const isNew = !entry;
|
|
3833
|
+
if (!entry) {
|
|
3834
|
+
entry = createEntry(comment);
|
|
3835
|
+
entries.set(comment.id, entry);
|
|
3836
|
+
host2.appendChild(entry.button);
|
|
3837
|
+
}
|
|
3838
|
+
entry.comment = comment;
|
|
3839
|
+
const n = String(i + 1);
|
|
3840
|
+
entry.number.textContent = n;
|
|
3841
|
+
entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
|
|
3842
|
+
if (fresh || isNew) animateIn(entry.button, fresh ? i * STAGGER_MS : 0);
|
|
3843
|
+
});
|
|
3844
|
+
if (hovered && entries.get(hovered.comment.id) === hovered) showTip(hovered);
|
|
3845
|
+
position(performance.now());
|
|
3846
|
+
schedule();
|
|
3847
|
+
}
|
|
3848
|
+
function position(now) {
|
|
3849
|
+
for (const entry of entries.values()) {
|
|
3850
|
+
if (!entry.element?.isConnected) {
|
|
3851
|
+
entry.element = null;
|
|
3852
|
+
if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
|
|
3853
|
+
entry.lastLookup = now;
|
|
3854
|
+
entry.element = deps.findElement(entry.comment);
|
|
3855
|
+
}
|
|
3856
|
+
}
|
|
3857
|
+
const rect = entry.element?.getBoundingClientRect();
|
|
3858
|
+
if (!rect || rect.width === 0 && rect.height === 0) {
|
|
3859
|
+
entry.button.hidden = true;
|
|
3860
|
+
continue;
|
|
3861
|
+
}
|
|
3862
|
+
if (now - entry.contextCheckedAt >= CONTEXT_CHECK_MS) {
|
|
3863
|
+
entry.contextCheckedAt = now;
|
|
3864
|
+
entry.context = scrollContextOf(entry.element);
|
|
3865
|
+
const home = entry.context === "page" ? docLayer : layer;
|
|
3866
|
+
if (home && entry.button.parentElement !== home) home.appendChild(entry.button);
|
|
3867
|
+
}
|
|
3868
|
+
const pin = entry.comment.pin ?? { x: 1, y: 0 };
|
|
3869
|
+
const maxX = (document.documentElement.clientWidth || window.innerWidth) - SIZE;
|
|
3870
|
+
let x = Math.max(0, Math.min(rect.left + pin.x * rect.width - SIZE / 2, maxX));
|
|
3871
|
+
let y = rect.top + pin.y * rect.height - SIZE / 2;
|
|
3872
|
+
if (entry.context === "page") {
|
|
3873
|
+
x += window.scrollX;
|
|
3874
|
+
y = Math.max(0, y + window.scrollY);
|
|
3875
|
+
}
|
|
3876
|
+
entry.button.hidden = false;
|
|
3877
|
+
entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
|
|
3878
|
+
}
|
|
3879
|
+
if (hovered) placeTip(hovered);
|
|
3880
|
+
}
|
|
3881
|
+
function frame() {
|
|
3882
|
+
rafId = null;
|
|
3883
|
+
const now = performance.now();
|
|
3884
|
+
if (!visible) return;
|
|
3885
|
+
if (now - lastRouteCheck >= ROUTE_CHECK_MS) {
|
|
3886
|
+
lastRouteCheck = now;
|
|
3887
|
+
const next = deps.currentRoute();
|
|
3888
|
+
if (next !== route) {
|
|
3889
|
+
route = next;
|
|
3890
|
+
for (const id of [...entries.keys()]) removeEntry(id, false);
|
|
3891
|
+
sync(true);
|
|
3892
|
+
return;
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
position(now);
|
|
3896
|
+
schedule();
|
|
3897
|
+
}
|
|
3898
|
+
function schedule() {
|
|
3899
|
+
if (rafId === null && visible) rafId = requestAnimationFrame(frame);
|
|
3900
|
+
}
|
|
3901
|
+
function stop() {
|
|
3902
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
3903
|
+
rafId = null;
|
|
3904
|
+
}
|
|
3905
|
+
function handleScroll() {
|
|
3906
|
+
if (visible && entries.size) position(performance.now());
|
|
3907
|
+
}
|
|
3908
|
+
return {
|
|
3909
|
+
setVisible(next) {
|
|
3910
|
+
if (next === visible) return;
|
|
3911
|
+
visible = next;
|
|
3912
|
+
if (next) {
|
|
3913
|
+
route = deps.currentRoute();
|
|
3914
|
+
lastRouteCheck = performance.now();
|
|
3915
|
+
document.addEventListener("scroll", handleScroll, { capture: true, passive: true });
|
|
3916
|
+
sync(true);
|
|
3917
|
+
} else {
|
|
3918
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
3919
|
+
stop();
|
|
3920
|
+
hideTip();
|
|
3921
|
+
if (hovered) endHover(hovered);
|
|
3922
|
+
for (const id of [...entries.keys()]) removeEntry(id, true);
|
|
3923
|
+
}
|
|
3924
|
+
},
|
|
3925
|
+
refresh() {
|
|
3926
|
+
sync(false);
|
|
3927
|
+
},
|
|
3928
|
+
isMarkerElement(el) {
|
|
3929
|
+
return [layer, docLayer].some((l) => !!l && (l === el || l.contains(el)));
|
|
3930
|
+
},
|
|
3931
|
+
dispose() {
|
|
3932
|
+
stop();
|
|
3933
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
3934
|
+
entries.clear();
|
|
3935
|
+
layer?.remove();
|
|
3936
|
+
docLayer?.remove();
|
|
3937
|
+
docLayer = null;
|
|
3938
|
+
tip?.remove();
|
|
3939
|
+
layer = null;
|
|
3940
|
+
tip = null;
|
|
3941
|
+
hovered = null;
|
|
3942
|
+
visible = false;
|
|
3943
|
+
removeStyles(STYLE_ID9);
|
|
3944
|
+
}
|
|
3945
|
+
};
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3486
3948
|
// src/core/overlay/select-feedback.ts
|
|
3487
|
-
var
|
|
3949
|
+
var STYLE_ID10 = "__grabby-feedback-styles__";
|
|
3488
3950
|
function injectStyles() {
|
|
3489
|
-
if (hasStyles(
|
|
3490
|
-
addStyles(
|
|
3951
|
+
if (hasStyles(STYLE_ID10)) return;
|
|
3952
|
+
addStyles(STYLE_ID10, `
|
|
3491
3953
|
@keyframes grabby-flash {
|
|
3492
3954
|
0% { opacity: 1; }
|
|
3493
3955
|
100% { opacity: 0; transform: scale(1.02); }
|
|
@@ -3566,7 +4028,7 @@ function showSelectFeedback(element, label = "Selected") {
|
|
|
3566
4028
|
setTimeout(cleanup, 1200);
|
|
3567
4029
|
}
|
|
3568
4030
|
function disposeFeedbackStyles() {
|
|
3569
|
-
removeStyles(
|
|
4031
|
+
removeStyles(STYLE_ID10);
|
|
3570
4032
|
}
|
|
3571
4033
|
|
|
3572
4034
|
// src/core/storage/history-persistence.ts
|
|
@@ -4754,7 +5216,10 @@ function createGrabInstance(options) {
|
|
|
4754
5216
|
let sourceResolver = adapters.resolveSource;
|
|
4755
5217
|
const cleanClasses = (list) => adapters.cleanClasses(list.filter((c) => !isNoiseClass(c)));
|
|
4756
5218
|
let selectedElement = null;
|
|
5219
|
+
let selectedPin;
|
|
4757
5220
|
let pendingShot = null;
|
|
5221
|
+
const commentedElements = /* @__PURE__ */ new Map();
|
|
5222
|
+
let editingFromMarker = false;
|
|
4758
5223
|
let level = loadLevel(merged.detailLevel);
|
|
4759
5224
|
let collapsed = loadCollapsed();
|
|
4760
5225
|
const pendingShotDeletes = /* @__PURE__ */ new Map();
|
|
@@ -4813,7 +5278,7 @@ function createGrabInstance(options) {
|
|
|
4813
5278
|
column: c.target.source?.column ?? null
|
|
4814
5279
|
};
|
|
4815
5280
|
}
|
|
4816
|
-
function saveComment(element, text, shot) {
|
|
5281
|
+
function saveComment(element, text, shot, pin) {
|
|
4817
5282
|
const now = Date.now();
|
|
4818
5283
|
const comment = {
|
|
4819
5284
|
id: randomId(),
|
|
@@ -4830,8 +5295,10 @@ function createGrabInstance(options) {
|
|
|
4830
5295
|
target: captureTarget(element, { componentResolver, sourceResolver, cleanClasses }),
|
|
4831
5296
|
screenshot: null,
|
|
4832
5297
|
framework: adapters.frameworkFor(element),
|
|
4833
|
-
...outbox ? { sync: "pending" } : {}
|
|
5298
|
+
...outbox ? { sync: "pending" } : {},
|
|
5299
|
+
...pin ? { pin } : {}
|
|
4834
5300
|
};
|
|
5301
|
+
commentedElements.set(comment.id, element);
|
|
4835
5302
|
setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
|
|
4836
5303
|
pluginRegistry.callHook("onComment", comment, element);
|
|
4837
5304
|
outbox?.send(comment.id);
|
|
@@ -4876,6 +5343,7 @@ function createGrabInstance(options) {
|
|
|
4876
5343
|
const idSet = new Set(ids);
|
|
4877
5344
|
const before = comments();
|
|
4878
5345
|
const removed = before.filter((c) => idSet.has(c.id));
|
|
5346
|
+
for (const id of ids) commentedElements.delete(id);
|
|
4879
5347
|
setComments(before.filter((c) => !idSet.has(c.id)));
|
|
4880
5348
|
const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
|
|
4881
5349
|
const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
|
|
@@ -4932,12 +5400,19 @@ function createGrabInstance(options) {
|
|
|
4932
5400
|
}
|
|
4933
5401
|
function hideCommentPopover() {
|
|
4934
5402
|
commentPopover.hide();
|
|
5403
|
+
endMarkerEdit();
|
|
4935
5404
|
if (picker.isHolding()) {
|
|
4936
5405
|
selectedElement = null;
|
|
5406
|
+
selectedPin = void 0;
|
|
4937
5407
|
pendingShot = null;
|
|
4938
5408
|
picker.release();
|
|
4939
5409
|
}
|
|
4940
5410
|
}
|
|
5411
|
+
function endMarkerEdit() {
|
|
5412
|
+
if (!editingFromMarker) return;
|
|
5413
|
+
editingFromMarker = false;
|
|
5414
|
+
overlay.hide();
|
|
5415
|
+
}
|
|
4941
5416
|
function closeAllPopovers() {
|
|
4942
5417
|
commentsPanel.hide();
|
|
4943
5418
|
hideCommentPopover();
|
|
@@ -4974,8 +5449,14 @@ function createGrabInstance(options) {
|
|
|
4974
5449
|
pluginRegistry.callHook("onElementHover", element);
|
|
4975
5450
|
}
|
|
4976
5451
|
},
|
|
4977
|
-
onSelect(element) {
|
|
5452
|
+
onSelect(element, point) {
|
|
4978
5453
|
selectedElement = element;
|
|
5454
|
+
const rect = element.getBoundingClientRect();
|
|
5455
|
+
const frac = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
|
|
5456
|
+
selectedPin = {
|
|
5457
|
+
x: Math.round(frac(point.x, rect.left, rect.width) * 1e3) / 1e3,
|
|
5458
|
+
y: Math.round(frac(point.y, rect.top, rect.height) * 1e3) / 1e3
|
|
5459
|
+
};
|
|
4979
5460
|
pendingShot = store.state.options.screenshots ? captureScreenshot(element) : null;
|
|
4980
5461
|
pluginRegistry.callHook("onElementSelect", element);
|
|
4981
5462
|
coachMark.dismiss();
|
|
@@ -4984,6 +5465,36 @@ function createGrabInstance(options) {
|
|
|
4984
5465
|
commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
|
|
4985
5466
|
}
|
|
4986
5467
|
});
|
|
5468
|
+
const markers = createMarkers({
|
|
5469
|
+
getComments: comments,
|
|
5470
|
+
currentRoute: () => sanitizeRoute(location, store.state.options.captureQueryParams),
|
|
5471
|
+
findElement(comment) {
|
|
5472
|
+
const known = commentedElements.get(comment.id);
|
|
5473
|
+
if (known?.isConnected) return known;
|
|
5474
|
+
return safeQuery(comment.target.selector);
|
|
5475
|
+
},
|
|
5476
|
+
onHover(comment, element) {
|
|
5477
|
+
if (picker.isHolding() || editingFromMarker || commentPopover.isVisible()) return;
|
|
5478
|
+
if (comment && element) overlay.show(element, comment.target.component, null, []);
|
|
5479
|
+
else overlay.hide();
|
|
5480
|
+
},
|
|
5481
|
+
onOpen(comment, element, marker) {
|
|
5482
|
+
if (picker.isHolding()) return;
|
|
5483
|
+
closeAllPopovers();
|
|
5484
|
+
doDeactivate(true);
|
|
5485
|
+
editingFromMarker = true;
|
|
5486
|
+
if (element) overlay.show(element, comment.target.component, null, []);
|
|
5487
|
+
commentPopover.show({
|
|
5488
|
+
anchor: element ?? marker,
|
|
5489
|
+
initialValue: comment.comment,
|
|
5490
|
+
mode: "edit",
|
|
5491
|
+
entryId: comment.id
|
|
5492
|
+
});
|
|
5493
|
+
}
|
|
5494
|
+
});
|
|
5495
|
+
function updateMarkers() {
|
|
5496
|
+
markers.setVisible(store.state.toolbar.visible && !collapsed && store.state.options.enabled);
|
|
5497
|
+
}
|
|
4987
5498
|
function doActivate() {
|
|
4988
5499
|
if (!store.state.options.enabled) return;
|
|
4989
5500
|
if (store.state.active) return;
|
|
@@ -5058,12 +5569,14 @@ function createGrabInstance(options) {
|
|
|
5058
5569
|
toolbar.collapse();
|
|
5059
5570
|
saveCollapsed(true);
|
|
5060
5571
|
updateToastOffset();
|
|
5572
|
+
updateMarkers();
|
|
5061
5573
|
}
|
|
5062
5574
|
function expandToolbar() {
|
|
5063
5575
|
collapsed = false;
|
|
5064
5576
|
toolbar.expand();
|
|
5065
5577
|
saveCollapsed(false);
|
|
5066
5578
|
updateToastOffset();
|
|
5579
|
+
updateMarkers();
|
|
5067
5580
|
}
|
|
5068
5581
|
const commentsPanel = createCommentsPanel({
|
|
5069
5582
|
onHover(comment) {
|
|
@@ -5151,9 +5664,11 @@ function createGrabInstance(options) {
|
|
|
5151
5664
|
if (ctx.mode === "new") {
|
|
5152
5665
|
const element = selectedElement;
|
|
5153
5666
|
const shot = pendingShot;
|
|
5667
|
+
const pin = selectedPin;
|
|
5154
5668
|
selectedElement = null;
|
|
5669
|
+
selectedPin = void 0;
|
|
5155
5670
|
pendingShot = null;
|
|
5156
|
-
if (element) saveComment(element, value, shot);
|
|
5671
|
+
if (element) saveComment(element, value, shot, pin);
|
|
5157
5672
|
doDeactivate(true);
|
|
5158
5673
|
return;
|
|
5159
5674
|
}
|
|
@@ -5164,16 +5679,23 @@ function createGrabInstance(options) {
|
|
|
5164
5679
|
setComments(updated);
|
|
5165
5680
|
outbox?.send(ctx.entryId);
|
|
5166
5681
|
showToast("Comment updated");
|
|
5167
|
-
|
|
5682
|
+
if (editingFromMarker) endMarkerEdit();
|
|
5683
|
+
else commentsPanel.show([...updated]);
|
|
5168
5684
|
},
|
|
5169
5685
|
onCancel(ctx) {
|
|
5170
5686
|
if (ctx.mode === "new") {
|
|
5171
5687
|
selectedElement = null;
|
|
5688
|
+
selectedPin = void 0;
|
|
5172
5689
|
pendingShot = null;
|
|
5173
5690
|
doDeactivate(true);
|
|
5174
5691
|
return;
|
|
5175
5692
|
}
|
|
5176
|
-
|
|
5693
|
+
if (editingFromMarker) endMarkerEdit();
|
|
5694
|
+
else commentsPanel.show([...comments()]);
|
|
5695
|
+
},
|
|
5696
|
+
onDelete(ctx) {
|
|
5697
|
+
endMarkerEdit();
|
|
5698
|
+
if (ctx.entryId) removeComments([ctx.entryId], "Comment deleted", true);
|
|
5177
5699
|
}
|
|
5178
5700
|
});
|
|
5179
5701
|
function handleDocumentClick(e) {
|
|
@@ -5329,6 +5851,7 @@ function createGrabInstance(options) {
|
|
|
5329
5851
|
overlay.dispose();
|
|
5330
5852
|
crosshair.dispose();
|
|
5331
5853
|
freezeOverlay.dispose();
|
|
5854
|
+
markers.dispose();
|
|
5332
5855
|
disposeToast();
|
|
5333
5856
|
disposeFeedbackStyles();
|
|
5334
5857
|
pluginRegistry.dispose();
|
|
@@ -5365,8 +5888,11 @@ function createGrabInstance(options) {
|
|
|
5365
5888
|
doDeactivate(true);
|
|
5366
5889
|
}
|
|
5367
5890
|
}
|
|
5891
|
+
if (key === "options") updateMarkers();
|
|
5368
5892
|
if (key === "toolbar") {
|
|
5369
5893
|
updateToastOffset();
|
|
5894
|
+
updateMarkers();
|
|
5895
|
+
markers.refresh();
|
|
5370
5896
|
if (state.options.persistHistory) {
|
|
5371
5897
|
if (state.toolbar.comments.length > 0) {
|
|
5372
5898
|
saveHistory(state.toolbar.comments);
|
|
@@ -5388,6 +5914,7 @@ function createGrabInstance(options) {
|
|
|
5388
5914
|
if (merged.webhookUrl) {
|
|
5389
5915
|
api.registerPlugin(createWebhookPlugin(merged.webhookUrl));
|
|
5390
5916
|
}
|
|
5917
|
+
updateMarkers();
|
|
5391
5918
|
return api;
|
|
5392
5919
|
}
|
|
5393
5920
|
|