@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/angular/index.js
CHANGED
|
@@ -1305,7 +1305,7 @@ function createElementPicker(deps) {
|
|
|
1305
1305
|
e.stopPropagation();
|
|
1306
1306
|
if (heldElement) return;
|
|
1307
1307
|
if (hoveredElement) {
|
|
1308
|
-
deps.onSelect(hoveredElement);
|
|
1308
|
+
deps.onSelect(hoveredElement, { x: e.clientX, y: e.clientY });
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
1311
|
return {
|
|
@@ -1563,7 +1563,8 @@ function createWebhookPlugin(url) {
|
|
|
1563
1563
|
type: "grabby.comment",
|
|
1564
1564
|
version: 1,
|
|
1565
1565
|
origin: typeof location !== "undefined" ? location.origin : null,
|
|
1566
|
-
|
|
1566
|
+
// The marker position is browser-only.
|
|
1567
|
+
comment: { ...comment, pin: void 0 }
|
|
1567
1568
|
})
|
|
1568
1569
|
}).catch(() => {
|
|
1569
1570
|
});
|
|
@@ -1655,6 +1656,9 @@ ${vars.join("\n")}
|
|
|
1655
1656
|
|
|
1656
1657
|
// src/core/toolbar/toolbar-renderer.ts
|
|
1657
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;
|
|
1658
1662
|
var STYLE_ID3 = "__grabby-toolbar-styles__";
|
|
1659
1663
|
function syncSummary(comments) {
|
|
1660
1664
|
if (comments.length === 0) return null;
|
|
@@ -1676,7 +1680,13 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1676
1680
|
let badge = null;
|
|
1677
1681
|
let status = null;
|
|
1678
1682
|
let expandBadge = null;
|
|
1683
|
+
let content = null;
|
|
1679
1684
|
let collapsed = false;
|
|
1685
|
+
let morphTimer = null;
|
|
1686
|
+
function clearMorph() {
|
|
1687
|
+
if (morphTimer) clearTimeout(morphTimer);
|
|
1688
|
+
morphTimer = null;
|
|
1689
|
+
}
|
|
1680
1690
|
function injectStyles2() {
|
|
1681
1691
|
if (hasStyles(STYLE_ID3)) return;
|
|
1682
1692
|
addStyles(STYLE_ID3, `
|
|
@@ -1696,7 +1706,21 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1696
1706
|
box-shadow: 0 4px 16px var(--grabby-toolbar-shadow, rgba(0, 0, 0, 0.12));
|
|
1697
1707
|
pointer-events: auto;
|
|
1698
1708
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
1699
|
-
|
|
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;
|
|
1700
1724
|
}
|
|
1701
1725
|
#${TOOLBAR_ID}.grabby-toolbar-hidden {
|
|
1702
1726
|
opacity: 0;
|
|
@@ -1792,23 +1816,44 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1792
1816
|
background: var(--grabby-accent-hover, #1d4ed8);
|
|
1793
1817
|
color: #fff;
|
|
1794
1818
|
}
|
|
1795
|
-
#${TOOLBAR_ID} button.grabby-btn-expand {
|
|
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; }
|
|
1796
1832
|
#${TOOLBAR_ID}.grabby-toolbar-collapsed {
|
|
1797
|
-
left:
|
|
1798
|
-
right: 20px;
|
|
1799
|
-
transform: none;
|
|
1833
|
+
left: calc(100% - 20px - ${COLLAPSED_SIZE / 2}px);
|
|
1800
1834
|
padding: 4px;
|
|
1801
1835
|
}
|
|
1802
|
-
#${TOOLBAR_ID}.grabby-toolbar-collapsed.grabby-toolbar-
|
|
1803
|
-
|
|
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;
|
|
1804
1844
|
}
|
|
1805
|
-
#${TOOLBAR_ID}.grabby-toolbar-collapsed
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
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
|
+
}
|
|
1812
1857
|
}
|
|
1813
1858
|
#${TOOLBAR_ID} .grabby-toolbar-left.grabby-toolbar-left-hidden {
|
|
1814
1859
|
max-width: 0;
|
|
@@ -1863,7 +1908,9 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1863
1908
|
leftGroup.appendChild(buttons.selection);
|
|
1864
1909
|
leftGroup.appendChild(buttons.history);
|
|
1865
1910
|
leftGroup.appendChild(divider);
|
|
1866
|
-
|
|
1911
|
+
content = document.createElement("div");
|
|
1912
|
+
content.className = "grabby-toolbar-content";
|
|
1913
|
+
content.appendChild(leftGroup);
|
|
1867
1914
|
if (options.review) {
|
|
1868
1915
|
status = document.createElement("span");
|
|
1869
1916
|
status.className = "grabby-toolbar-status";
|
|
@@ -1880,18 +1927,22 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1880
1927
|
e.stopPropagation();
|
|
1881
1928
|
callbacks.onFinish?.();
|
|
1882
1929
|
});
|
|
1883
|
-
|
|
1884
|
-
|
|
1930
|
+
content.appendChild(status);
|
|
1931
|
+
content.appendChild(buttons.finish);
|
|
1885
1932
|
allElements.add(status);
|
|
1886
1933
|
}
|
|
1887
|
-
if (!options.hideEnable)
|
|
1888
|
-
|
|
1889
|
-
container.
|
|
1890
|
-
|
|
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
|
+
}
|
|
1891
1941
|
getUiRoot().appendChild(container);
|
|
1892
1942
|
allElements.clear();
|
|
1893
1943
|
allElements.add(container);
|
|
1894
1944
|
allElements.add(leftGroup);
|
|
1945
|
+
allElements.add(content);
|
|
1895
1946
|
allElements.add(divider);
|
|
1896
1947
|
for (const btn of Object.values(buttons)) {
|
|
1897
1948
|
allElements.add(btn);
|
|
@@ -1937,12 +1988,28 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1937
1988
|
}
|
|
1938
1989
|
},
|
|
1939
1990
|
collapse() {
|
|
1991
|
+
if (collapsed) return;
|
|
1940
1992
|
collapsed = true;
|
|
1941
|
-
container
|
|
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`;
|
|
1942
1999
|
},
|
|
1943
2000
|
expand() {
|
|
2001
|
+
if (!collapsed) return;
|
|
1944
2002
|
collapsed = false;
|
|
1945
|
-
container
|
|
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);
|
|
1946
2013
|
},
|
|
1947
2014
|
isCollapsed() {
|
|
1948
2015
|
return collapsed;
|
|
@@ -1958,10 +2025,12 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1958
2025
|
return false;
|
|
1959
2026
|
},
|
|
1960
2027
|
dispose() {
|
|
2028
|
+
clearMorph();
|
|
1961
2029
|
container?.remove();
|
|
1962
2030
|
removeStyles(STYLE_ID3);
|
|
1963
2031
|
container = null;
|
|
1964
2032
|
leftGroup = null;
|
|
2033
|
+
content = null;
|
|
1965
2034
|
buttons = {};
|
|
1966
2035
|
badge = null;
|
|
1967
2036
|
expandBadge = null;
|
|
@@ -2531,6 +2600,18 @@ function createCommentPopover(callbacks) {
|
|
|
2531
2600
|
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
|
|
2532
2601
|
background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
|
|
2533
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); }
|
|
2534
2615
|
#${POPOVER_ID} .grabby-cp-hint {
|
|
2535
2616
|
font-size: 11px;
|
|
2536
2617
|
color: var(--grabby-text-muted, #94a3b8);
|
|
@@ -2592,6 +2673,37 @@ function createCommentPopover(callbacks) {
|
|
|
2592
2673
|
function isEditable(el) {
|
|
2593
2674
|
return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
|
|
2594
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
|
+
}
|
|
2595
2707
|
function finish(identity) {
|
|
2596
2708
|
const ctx = currentCtx;
|
|
2597
2709
|
const value = pendingValue;
|
|
@@ -2657,11 +2769,7 @@ function createCommentPopover(callbacks) {
|
|
|
2657
2769
|
e.stopImmediatePropagation();
|
|
2658
2770
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2659
2771
|
e.preventDefault();
|
|
2660
|
-
|
|
2661
|
-
if (!v) return;
|
|
2662
|
-
pendingValue = v;
|
|
2663
|
-
if (askIdentity) showIdentityStep();
|
|
2664
|
-
else finish();
|
|
2772
|
+
save();
|
|
2665
2773
|
} else if (e.key === "Escape") {
|
|
2666
2774
|
e.preventDefault();
|
|
2667
2775
|
const ctx = currentCtx;
|
|
@@ -2695,6 +2803,7 @@ function createCommentPopover(callbacks) {
|
|
|
2695
2803
|
currentCtx = { mode: opts.mode, entryId: opts.entryId };
|
|
2696
2804
|
askIdentity = opts.askIdentity === true && opts.mode === "new";
|
|
2697
2805
|
visible = true;
|
|
2806
|
+
if (opts.mode === "edit") el.appendChild(editActions());
|
|
2698
2807
|
position(el, opts.anchor);
|
|
2699
2808
|
attachKey();
|
|
2700
2809
|
textarea?.focus();
|
|
@@ -3226,9 +3335,10 @@ function createOutbox(deps) {
|
|
|
3226
3335
|
}, delay);
|
|
3227
3336
|
}
|
|
3228
3337
|
function wireShape(c) {
|
|
3229
|
-
const { screenshot: _shot, sync: _sync, ...rest } = c;
|
|
3338
|
+
const { screenshot: _shot, sync: _sync, pin: _pin, ...rest } = c;
|
|
3230
3339
|
void _shot;
|
|
3231
3340
|
void _sync;
|
|
3341
|
+
void _pin;
|
|
3232
3342
|
return rest;
|
|
3233
3343
|
}
|
|
3234
3344
|
function postComment(comment) {
|
|
@@ -3577,11 +3687,363 @@ function createFreezeOverlay() {
|
|
|
3577
3687
|
};
|
|
3578
3688
|
}
|
|
3579
3689
|
|
|
3690
|
+
// src/core/overlay/markers.ts
|
|
3691
|
+
var LAYER_ID = "__grabby-markers__";
|
|
3692
|
+
var DOC_LAYER_ID = "__grabby-markers-doc__";
|
|
3693
|
+
var CONTEXT_CHECK_MS = 1e3;
|
|
3694
|
+
var TIP_ID = "__grabby-marker-tip__";
|
|
3695
|
+
var STYLE_ID9 = "__grabby-marker-styles__";
|
|
3696
|
+
var SIZE = 22;
|
|
3697
|
+
var ROUTE_CHECK_MS = 250;
|
|
3698
|
+
var LOOKUP_RETRY_MS = 500;
|
|
3699
|
+
var STAGGER_MS = 30;
|
|
3700
|
+
var TIP_MAX = 140;
|
|
3701
|
+
var ICON_EDIT = {
|
|
3702
|
+
size: 12,
|
|
3703
|
+
shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
|
|
3704
|
+
};
|
|
3705
|
+
function scrollContextOf(el) {
|
|
3706
|
+
for (let cur = el.parentElement; cur && cur !== document.body && cur !== document.documentElement; cur = cur.parentElement) {
|
|
3707
|
+
const style = getComputedStyle(cur);
|
|
3708
|
+
if (style.position === "fixed" || style.position === "sticky") return "screen";
|
|
3709
|
+
if (/(auto|scroll|overlay)/.test(style.overflowY + style.overflowX)) return "screen";
|
|
3710
|
+
}
|
|
3711
|
+
const own = getComputedStyle(el).position;
|
|
3712
|
+
return own === "fixed" || own === "sticky" ? "screen" : "page";
|
|
3713
|
+
}
|
|
3714
|
+
function createMarkers(deps) {
|
|
3715
|
+
let layer = null;
|
|
3716
|
+
let docLayer = null;
|
|
3717
|
+
let tip = null;
|
|
3718
|
+
let visible = false;
|
|
3719
|
+
let route = "";
|
|
3720
|
+
let rafId = null;
|
|
3721
|
+
let lastRouteCheck = 0;
|
|
3722
|
+
let hovered = null;
|
|
3723
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3724
|
+
function injectStyles2() {
|
|
3725
|
+
if (hasStyles(STYLE_ID9)) return;
|
|
3726
|
+
addStyles(STYLE_ID9, `
|
|
3727
|
+
/*
|
|
3728
|
+
* Page coordinates: the browser moves these with the page as it
|
|
3729
|
+
* scrolls, so they never trail behind their element. (A fixed layer
|
|
3730
|
+
* repositioned from script lags a frame behind fast scrolling.)
|
|
3731
|
+
*/
|
|
3732
|
+
#${DOC_LAYER_ID} {
|
|
3733
|
+
position: absolute;
|
|
3734
|
+
left: 0;
|
|
3735
|
+
top: 0;
|
|
3736
|
+
width: 0;
|
|
3737
|
+
height: 0;
|
|
3738
|
+
pointer-events: none;
|
|
3739
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3740
|
+
}
|
|
3741
|
+
#${LAYER_ID} {
|
|
3742
|
+
position: fixed;
|
|
3743
|
+
inset: 0;
|
|
3744
|
+
pointer-events: none;
|
|
3745
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3746
|
+
}
|
|
3747
|
+
.grabby-markers-layer .grabby-marker {
|
|
3748
|
+
position: absolute;
|
|
3749
|
+
left: 0;
|
|
3750
|
+
top: 0;
|
|
3751
|
+
width: ${SIZE}px;
|
|
3752
|
+
height: ${SIZE}px;
|
|
3753
|
+
margin: 0;
|
|
3754
|
+
padding: 0;
|
|
3755
|
+
border: none;
|
|
3756
|
+
border-radius: 50%;
|
|
3757
|
+
background: var(--grabby-accent, #2563eb);
|
|
3758
|
+
color: #fff;
|
|
3759
|
+
box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3760
|
+
font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3761
|
+
display: flex;
|
|
3762
|
+
align-items: center;
|
|
3763
|
+
justify-content: center;
|
|
3764
|
+
cursor: pointer;
|
|
3765
|
+
pointer-events: auto;
|
|
3766
|
+
transition: transform 0.12s ease, box-shadow 0.15s ease;
|
|
3767
|
+
}
|
|
3768
|
+
.grabby-markers-layer .grabby-marker[hidden] { display: none; }
|
|
3769
|
+
.grabby-markers-layer .grabby-marker:hover,
|
|
3770
|
+
.grabby-markers-layer .grabby-marker:focus-visible {
|
|
3771
|
+
z-index: 1;
|
|
3772
|
+
outline: none;
|
|
3773
|
+
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);
|
|
3774
|
+
}
|
|
3775
|
+
.grabby-markers-layer .grabby-marker-edit { display: none; }
|
|
3776
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-num,
|
|
3777
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-num { display: none; }
|
|
3778
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-edit,
|
|
3779
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
|
|
3780
|
+
.grabby-markers-layer .grabby-marker-in {
|
|
3781
|
+
animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
3782
|
+
}
|
|
3783
|
+
.grabby-markers-layer .grabby-marker-out {
|
|
3784
|
+
animation: grabby-marker-out 0.2s ease-out both;
|
|
3785
|
+
pointer-events: none;
|
|
3786
|
+
}
|
|
3787
|
+
@keyframes grabby-marker-in {
|
|
3788
|
+
from { opacity: 0; scale: 0.3; }
|
|
3789
|
+
to { opacity: 1; scale: 1; }
|
|
3790
|
+
}
|
|
3791
|
+
@keyframes grabby-marker-out {
|
|
3792
|
+
from { opacity: 1; scale: 1; }
|
|
3793
|
+
to { opacity: 0; scale: 0.3; }
|
|
3794
|
+
}
|
|
3795
|
+
#${TIP_ID} {
|
|
3796
|
+
position: fixed;
|
|
3797
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3798
|
+
max-width: 260px;
|
|
3799
|
+
padding: 8px 10px;
|
|
3800
|
+
border-radius: 10px;
|
|
3801
|
+
background: var(--grabby-label-bg, #1e293b);
|
|
3802
|
+
color: #fff;
|
|
3803
|
+
font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
3804
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
|
|
3805
|
+
pointer-events: none;
|
|
3806
|
+
white-space: pre-wrap;
|
|
3807
|
+
overflow-wrap: anywhere;
|
|
3808
|
+
animation: grabby-marker-tip-in 0.12s ease both;
|
|
3809
|
+
}
|
|
3810
|
+
#${TIP_ID}[hidden] { display: none; }
|
|
3811
|
+
#${TIP_ID} .grabby-marker-tip-hint { display: block; margin-top: 4px; opacity: 0.6; font-size: 11px; }
|
|
3812
|
+
@keyframes grabby-marker-tip-in {
|
|
3813
|
+
from { opacity: 0; transform: translateY(-2px); }
|
|
3814
|
+
to { opacity: 1; transform: none; }
|
|
3815
|
+
}
|
|
3816
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3817
|
+
.grabby-markers-layer .grabby-marker-in, .grabby-markers-layer .grabby-marker-out, #${TIP_ID} { animation: none; }
|
|
3818
|
+
}
|
|
3819
|
+
`);
|
|
3820
|
+
}
|
|
3821
|
+
function ensureLayer() {
|
|
3822
|
+
if (layer) return layer;
|
|
3823
|
+
injectStyles2();
|
|
3824
|
+
layer = document.createElement("div");
|
|
3825
|
+
layer.id = LAYER_ID;
|
|
3826
|
+
layer.className = "grabby-markers-layer";
|
|
3827
|
+
docLayer = document.createElement("div");
|
|
3828
|
+
docLayer.id = DOC_LAYER_ID;
|
|
3829
|
+
docLayer.className = "grabby-markers-layer";
|
|
3830
|
+
tip = document.createElement("div");
|
|
3831
|
+
tip.id = TIP_ID;
|
|
3832
|
+
tip.hidden = true;
|
|
3833
|
+
tip.setAttribute("role", "tooltip");
|
|
3834
|
+
getUiRoot().append(docLayer, layer, tip);
|
|
3835
|
+
return layer;
|
|
3836
|
+
}
|
|
3837
|
+
function pageComments() {
|
|
3838
|
+
return deps.getComments().filter((c) => c.page.route === route).reverse();
|
|
3839
|
+
}
|
|
3840
|
+
function preview(text) {
|
|
3841
|
+
const flat = text.trim();
|
|
3842
|
+
return flat.length > TIP_MAX ? `${flat.slice(0, TIP_MAX - 1)}\u2026` : flat;
|
|
3843
|
+
}
|
|
3844
|
+
function createEntry(comment) {
|
|
3845
|
+
const number = document.createElement("span");
|
|
3846
|
+
number.className = "grabby-marker-num";
|
|
3847
|
+
const button = document.createElement("button");
|
|
3848
|
+
button.type = "button";
|
|
3849
|
+
button.className = "grabby-marker";
|
|
3850
|
+
button.dataset.grabbyMarker = comment.id;
|
|
3851
|
+
button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
|
|
3852
|
+
const entry = { comment, button, number, element: null, lastLookup: 0, context: "page", contextCheckedAt: -Infinity };
|
|
3853
|
+
button.addEventListener("click", (e) => {
|
|
3854
|
+
e.preventDefault();
|
|
3855
|
+
e.stopPropagation();
|
|
3856
|
+
hideTip();
|
|
3857
|
+
deps.onOpen(entry.comment, entry.element, button);
|
|
3858
|
+
});
|
|
3859
|
+
button.addEventListener("mouseenter", () => startHover(entry));
|
|
3860
|
+
button.addEventListener("focus", () => startHover(entry));
|
|
3861
|
+
button.addEventListener("mouseleave", () => endHover(entry));
|
|
3862
|
+
button.addEventListener("blur", () => endHover(entry));
|
|
3863
|
+
return entry;
|
|
3864
|
+
}
|
|
3865
|
+
function startHover(entry) {
|
|
3866
|
+
hovered = entry;
|
|
3867
|
+
showTip(entry);
|
|
3868
|
+
deps.onHover(entry.comment, entry.element);
|
|
3869
|
+
}
|
|
3870
|
+
function endHover(entry) {
|
|
3871
|
+
if (hovered !== entry) return;
|
|
3872
|
+
hovered = null;
|
|
3873
|
+
hideTip();
|
|
3874
|
+
deps.onHover(null, null);
|
|
3875
|
+
}
|
|
3876
|
+
function showTip(entry) {
|
|
3877
|
+
if (!tip) return;
|
|
3878
|
+
const hint = document.createElement("span");
|
|
3879
|
+
hint.className = "grabby-marker-tip-hint";
|
|
3880
|
+
hint.textContent = "Click to edit";
|
|
3881
|
+
tip.replaceChildren(document.createTextNode(preview(entry.comment.comment)), hint);
|
|
3882
|
+
tip.hidden = false;
|
|
3883
|
+
placeTip(entry);
|
|
3884
|
+
}
|
|
3885
|
+
function placeTip(entry) {
|
|
3886
|
+
if (!tip || tip.hidden) return;
|
|
3887
|
+
const m = entry.button.getBoundingClientRect();
|
|
3888
|
+
const t = tip.getBoundingClientRect();
|
|
3889
|
+
const left = Math.max(8, Math.min(m.left + m.width / 2 - t.width / 2, window.innerWidth - t.width - 8));
|
|
3890
|
+
const below = m.bottom + 8;
|
|
3891
|
+
const top = below + t.height > window.innerHeight - 8 ? m.top - 8 - t.height : below;
|
|
3892
|
+
tip.style.left = `${left}px`;
|
|
3893
|
+
tip.style.top = `${Math.max(8, top)}px`;
|
|
3894
|
+
}
|
|
3895
|
+
function hideTip() {
|
|
3896
|
+
if (tip) tip.hidden = true;
|
|
3897
|
+
}
|
|
3898
|
+
function animateIn(button, delay) {
|
|
3899
|
+
button.classList.remove("grabby-marker-out", "grabby-marker-in");
|
|
3900
|
+
button.style.animationDelay = `${delay}ms`;
|
|
3901
|
+
void button.offsetWidth;
|
|
3902
|
+
button.classList.add("grabby-marker-in");
|
|
3903
|
+
}
|
|
3904
|
+
function removeEntry(id, animate) {
|
|
3905
|
+
const entry = entries.get(id);
|
|
3906
|
+
if (!entry) return;
|
|
3907
|
+
entries.delete(id);
|
|
3908
|
+
if (hovered === entry) endHover(entry);
|
|
3909
|
+
if (!animate) {
|
|
3910
|
+
entry.button.remove();
|
|
3911
|
+
return;
|
|
3912
|
+
}
|
|
3913
|
+
entry.button.style.animationDelay = "0ms";
|
|
3914
|
+
entry.button.classList.remove("grabby-marker-in");
|
|
3915
|
+
entry.button.classList.add("grabby-marker-out");
|
|
3916
|
+
setTimeout(() => entry.button.remove(), 220);
|
|
3917
|
+
}
|
|
3918
|
+
function sync(fresh) {
|
|
3919
|
+
if (!visible) return;
|
|
3920
|
+
const host2 = ensureLayer();
|
|
3921
|
+
const list = pageComments();
|
|
3922
|
+
const ids = new Set(list.map((c) => c.id));
|
|
3923
|
+
for (const id of [...entries.keys()]) if (!ids.has(id)) removeEntry(id, !fresh);
|
|
3924
|
+
list.forEach((comment, i) => {
|
|
3925
|
+
let entry = entries.get(comment.id);
|
|
3926
|
+
const isNew = !entry;
|
|
3927
|
+
if (!entry) {
|
|
3928
|
+
entry = createEntry(comment);
|
|
3929
|
+
entries.set(comment.id, entry);
|
|
3930
|
+
host2.appendChild(entry.button);
|
|
3931
|
+
}
|
|
3932
|
+
entry.comment = comment;
|
|
3933
|
+
const n = String(i + 1);
|
|
3934
|
+
entry.number.textContent = n;
|
|
3935
|
+
entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
|
|
3936
|
+
if (fresh || isNew) animateIn(entry.button, fresh ? i * STAGGER_MS : 0);
|
|
3937
|
+
});
|
|
3938
|
+
if (hovered && entries.get(hovered.comment.id) === hovered) showTip(hovered);
|
|
3939
|
+
position(performance.now());
|
|
3940
|
+
schedule();
|
|
3941
|
+
}
|
|
3942
|
+
function position(now) {
|
|
3943
|
+
for (const entry of entries.values()) {
|
|
3944
|
+
if (!entry.element?.isConnected) {
|
|
3945
|
+
entry.element = null;
|
|
3946
|
+
if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
|
|
3947
|
+
entry.lastLookup = now;
|
|
3948
|
+
entry.element = deps.findElement(entry.comment);
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
const rect = entry.element?.getBoundingClientRect();
|
|
3952
|
+
if (!rect || rect.width === 0 && rect.height === 0) {
|
|
3953
|
+
entry.button.hidden = true;
|
|
3954
|
+
continue;
|
|
3955
|
+
}
|
|
3956
|
+
if (now - entry.contextCheckedAt >= CONTEXT_CHECK_MS) {
|
|
3957
|
+
entry.contextCheckedAt = now;
|
|
3958
|
+
entry.context = scrollContextOf(entry.element);
|
|
3959
|
+
const home = entry.context === "page" ? docLayer : layer;
|
|
3960
|
+
if (home && entry.button.parentElement !== home) home.appendChild(entry.button);
|
|
3961
|
+
}
|
|
3962
|
+
const pin = entry.comment.pin ?? { x: 1, y: 0 };
|
|
3963
|
+
const maxX = (document.documentElement.clientWidth || window.innerWidth) - SIZE;
|
|
3964
|
+
let x = Math.max(0, Math.min(rect.left + pin.x * rect.width - SIZE / 2, maxX));
|
|
3965
|
+
let y = rect.top + pin.y * rect.height - SIZE / 2;
|
|
3966
|
+
if (entry.context === "page") {
|
|
3967
|
+
x += window.scrollX;
|
|
3968
|
+
y = Math.max(0, y + window.scrollY);
|
|
3969
|
+
}
|
|
3970
|
+
entry.button.hidden = false;
|
|
3971
|
+
entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
|
|
3972
|
+
}
|
|
3973
|
+
if (hovered) placeTip(hovered);
|
|
3974
|
+
}
|
|
3975
|
+
function frame() {
|
|
3976
|
+
rafId = null;
|
|
3977
|
+
const now = performance.now();
|
|
3978
|
+
if (!visible) return;
|
|
3979
|
+
if (now - lastRouteCheck >= ROUTE_CHECK_MS) {
|
|
3980
|
+
lastRouteCheck = now;
|
|
3981
|
+
const next = deps.currentRoute();
|
|
3982
|
+
if (next !== route) {
|
|
3983
|
+
route = next;
|
|
3984
|
+
for (const id of [...entries.keys()]) removeEntry(id, false);
|
|
3985
|
+
sync(true);
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
position(now);
|
|
3990
|
+
schedule();
|
|
3991
|
+
}
|
|
3992
|
+
function schedule() {
|
|
3993
|
+
if (rafId === null && visible) rafId = requestAnimationFrame(frame);
|
|
3994
|
+
}
|
|
3995
|
+
function stop() {
|
|
3996
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
3997
|
+
rafId = null;
|
|
3998
|
+
}
|
|
3999
|
+
function handleScroll() {
|
|
4000
|
+
if (visible && entries.size) position(performance.now());
|
|
4001
|
+
}
|
|
4002
|
+
return {
|
|
4003
|
+
setVisible(next) {
|
|
4004
|
+
if (next === visible) return;
|
|
4005
|
+
visible = next;
|
|
4006
|
+
if (next) {
|
|
4007
|
+
route = deps.currentRoute();
|
|
4008
|
+
lastRouteCheck = performance.now();
|
|
4009
|
+
document.addEventListener("scroll", handleScroll, { capture: true, passive: true });
|
|
4010
|
+
sync(true);
|
|
4011
|
+
} else {
|
|
4012
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
4013
|
+
stop();
|
|
4014
|
+
hideTip();
|
|
4015
|
+
if (hovered) endHover(hovered);
|
|
4016
|
+
for (const id of [...entries.keys()]) removeEntry(id, true);
|
|
4017
|
+
}
|
|
4018
|
+
},
|
|
4019
|
+
refresh() {
|
|
4020
|
+
sync(false);
|
|
4021
|
+
},
|
|
4022
|
+
isMarkerElement(el) {
|
|
4023
|
+
return [layer, docLayer].some((l) => !!l && (l === el || l.contains(el)));
|
|
4024
|
+
},
|
|
4025
|
+
dispose() {
|
|
4026
|
+
stop();
|
|
4027
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
4028
|
+
entries.clear();
|
|
4029
|
+
layer?.remove();
|
|
4030
|
+
docLayer?.remove();
|
|
4031
|
+
docLayer = null;
|
|
4032
|
+
tip?.remove();
|
|
4033
|
+
layer = null;
|
|
4034
|
+
tip = null;
|
|
4035
|
+
hovered = null;
|
|
4036
|
+
visible = false;
|
|
4037
|
+
removeStyles(STYLE_ID9);
|
|
4038
|
+
}
|
|
4039
|
+
};
|
|
4040
|
+
}
|
|
4041
|
+
|
|
3580
4042
|
// src/core/overlay/select-feedback.ts
|
|
3581
|
-
var
|
|
4043
|
+
var STYLE_ID10 = "__grabby-feedback-styles__";
|
|
3582
4044
|
function injectStyles() {
|
|
3583
|
-
if (hasStyles(
|
|
3584
|
-
addStyles(
|
|
4045
|
+
if (hasStyles(STYLE_ID10)) return;
|
|
4046
|
+
addStyles(STYLE_ID10, `
|
|
3585
4047
|
@keyframes grabby-flash {
|
|
3586
4048
|
0% { opacity: 1; }
|
|
3587
4049
|
100% { opacity: 0; transform: scale(1.02); }
|
|
@@ -3660,7 +4122,7 @@ function showSelectFeedback(element, label = "Selected") {
|
|
|
3660
4122
|
setTimeout(cleanup, 1200);
|
|
3661
4123
|
}
|
|
3662
4124
|
function disposeFeedbackStyles() {
|
|
3663
|
-
removeStyles(
|
|
4125
|
+
removeStyles(STYLE_ID10);
|
|
3664
4126
|
}
|
|
3665
4127
|
|
|
3666
4128
|
// 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
|
|