@commentkit/comment-kit 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -1
- package/README.md +2 -2
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +3 -3
- package/dist/demo.es.js +2 -2
- package/dist/headless.es.js +2 -2
- package/dist/preact.es.js +2 -2
- package/dist/qwik.qwik.mjs +2 -2
- package/dist/react.es.js +2 -2
- package/dist/shared/{annotation-toolbar-DgqxkHy8.js → annotation-toolbar-zeiCmKIr.js} +110 -109
- package/dist/shared/{attachment-refresh-DRX7dKDI.js → attachment-refresh-DAacLaRu.js} +1 -1
- package/dist/shared/{capture-privacy-DUROnio5.js → capture-privacy-CiOrcAlt.js} +38 -14
- package/dist/shared/{comment-drawing-canvas-hSdcLShI.js → comment-drawing-canvas-Btc12IsS.js} +2 -2
- package/dist/shared/{comment-image-lightbox-4zroOCCG.js → comment-image-lightbox--QpbcAtH.js} +2 -2
- package/dist/shared/{comment-images-content-D4hTya6e.js → comment-images-content-C_r4SHM-.js} +13 -13
- package/dist/shared/{comment-kit-core-D068rcdY.js → comment-kit-core-CmLUFujd.js} +382 -348
- package/dist/shared/{comment-kit-ui-BDzNt0jv.js → comment-kit-ui-BHwYuSIi.js} +5255 -5487
- package/dist/shared/{comment-screenshot-annotator-BGnu_NgP.js → comment-screenshot-annotator-zJZyO-XM.js} +2 -2
- package/dist/shared/{comment-screenshot-overlay-BCRmojWB.js → comment-screenshot-overlay-CoKTYB0J.js} +6 -6
- package/dist/shared/{dev-export-panel-CYmUKmIV.js → dev-export-panel-Cnt6oCZU.js} +4 -4
- package/dist/shared/{dev-grab-BYsCpsGI.js → dev-grab-B85jo9AS.js} +3 -3
- package/dist/shared/{element-selector-79Oo5pit.js → element-selector-Cng84xC7.js} +349 -347
- package/dist/shared/input-UPtAj0M6.js +111 -0
- package/dist/shared/{mount-ui-DuHk132g.js → mount-ui-Dz7FB_Ak.js} +4 -4
- package/dist/shared/{pusher-3jyUauYd.js → pusher-CnhQgAvF.js} +1 -1
- package/dist/shared/{realtime-DspH16g5.js → realtime-yGLX4wMK.js} +2 -2
- package/dist/shared/{screenshot-BIuEaRiu.js → screenshot-B5-hwpmt.js} +2 -2
- package/dist/shared/{shadow-root-3-yGIhMs.js → shadow-root-B58ZI2yz.js} +1 -1
- package/dist/shared/{token-session-_Pi4fOEi.js → token-session-D92MYbNu.js} +2 -2
- package/dist/shared/useLabelableId-8n0QmH8N.js +154 -0
- package/dist/shared/{websocket-manager-CvgZSo_L.js → websocket-manager-KhH4hL0Q.js} +2 -2
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +2 -0
- package/dist/types/core/comment-kit-core.d.ts +4 -2
- package/dist/types/core/types.d.ts +12 -5
- package/dist/types/core/write-access.d.ts +2 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +1 -1
- package/package.json +1 -1
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import { u as e } from "./comment-kit-core-
|
|
1
|
+
import { u as e } from "./comment-kit-core-CmLUFujd.js";
|
|
2
2
|
import { a as t, i as n, m as r, n as i, o as a } from "./dom-Bhf4WFtY.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
3
|
+
import { o, r as s, t as c } from "./input-UPtAj0M6.js";
|
|
4
|
+
import { n as l } from "./dist-D9A5k-N4.js";
|
|
5
|
+
import { t as u } from "./button-D4GHW6oZ.js";
|
|
6
|
+
import { t as d } from "./createReactComponent-BZHeRbD0.js";
|
|
7
|
+
import { I as f, n as ee } from "./comment-kit-ui-BHwYuSIi.js";
|
|
8
|
+
import * as p from "react";
|
|
9
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
10
|
+
var te = d("outline", "paperclip", "Paperclip", [["path", {
|
|
10
11
|
d: "M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",
|
|
11
12
|
key: "svg-0"
|
|
12
|
-
}]]),
|
|
13
|
+
}]]), ne = d("outline", "x", "X", [["path", {
|
|
13
14
|
d: "M18 6l-12 12",
|
|
14
15
|
key: "svg-0"
|
|
15
16
|
}], ["path", {
|
|
16
17
|
d: "M6 6l12 12",
|
|
17
18
|
key: "svg-1"
|
|
18
|
-
}]]),
|
|
19
|
-
function b() {
|
|
20
|
-
if (v || typeof document > "u") return;
|
|
21
|
-
let e = document.createElement("style");
|
|
22
|
-
e.setAttribute(ae, ""), e.textContent = g, document.head.appendChild(e), v = e;
|
|
23
|
-
}
|
|
19
|
+
}]]), _ = ".ck-element-selector{z-index:calc(var(--z-ck-fab) - 1);pointer-events:none;position:fixed;inset:0}.ck-element-selector-outline,.ck-element-selector-mark{pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-outline{z-index:calc(var(--z-ck-fab) - 1);border:2px solid var(--primary);background-color:color-mix(in oklch, var(--primary) 8%, transparent);box-shadow:0 0 0 1px color-mix(in oklch, var(--background) 95%, transparent), 0 0 0 4px color-mix(in oklch, var(--primary) 18%, transparent)}.ck-element-selector-outline[data-state=selected]{background-color:color-mix(in oklch, var(--primary) 12%, transparent);border-style:solid}.ck-element-selector-outline[data-state=multi]{border-style:dashed;border-color:color-mix(in oklch, var(--primary) 70%, var(--foreground));background-color:color-mix(in oklch, var(--primary) 6%, transparent)}.ck-element-selector-outline[data-state=multi]:before{content:attr(data-multi-index);top:-10px;background:var(--primary);min-width:20px;height:20px;color:var(--primary-foreground,white);text-align:center;border-radius:999px;padding:0 6px;font:600 11px/20px ui-monospace,SF Mono,Menlo,monospace;position:absolute;inset-inline-start:-10px;box-shadow:0 1px 3px #00000040}.ck-element-selector-multibar{bottom:24px;z-index:calc(var(--z-ck-fab) + 1);border:1px solid var(--border);background-color:var(--popover);color:var(--popover-foreground);box-shadow:0 18px 30px -12px #00000047, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:999px;align-items:center;gap:8px;padding:6px 10px;font:13px/1 system-ui,sans-serif;display:inline-flex;position:fixed;inset-inline-start:50%;transform:translate(-50%)}.ck-element-selector-multibar-count{color:var(--popover-foreground);padding:0 4px}.ck-element-selector-marquee{z-index:calc(var(--z-ck-fab) - 1);border:1px dashed var(--primary);background-color:color-mix(in oklch, var(--primary) 12%, transparent);pointer-events:none;border-radius:4px;position:fixed}.ck-element-selector-context-menu{z-index:calc(var(--z-ck-fab) + 2);border:1px solid var(--border);background-color:var(--popover);min-width:200px;color:var(--popover-foreground);box-shadow:0 18px 30px -12px #0000004d, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;margin:0;padding:4px;font:13px/1 system-ui,sans-serif;list-style:none;position:fixed}.ck-element-selector-context-menu li{list-style:none}.ck-element-selector-context-menu button{width:100%;color:inherit;text-align:left;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:4px;padding:8px 10px}.ck-element-selector-context-menu button:hover,.ck-element-selector-context-menu button:focus-visible{background-color:color-mix(in oklch, var(--primary) 14%, transparent);outline:none}.ck-element-selector-mark{z-index:calc(var(--z-ck-fab) - 2);border:2px solid color-mix(in oklch, var(--primary) 78%, var(--foreground));box-shadow:inset 0 0 0 1px color-mix(in oklch, var(--background) 80%, transparent), 0 0 0 3px color-mix(in oklch, var(--primary) 14%, transparent)}.ck-element-selector-composer{z-index:var(--z-ck-fab);border:1px solid var(--border);background-color:var(--popover);width:min(28rem,100vw - 1rem);color:var(--popover-foreground);box-shadow:0 22px 42px -16px #00000052, 0 0 0 1px color-mix(in oklch, var(--foreground) 8%, transparent);pointer-events:auto;border-radius:8px;align-items:stretch;gap:.625rem;padding:.75rem;display:grid;position:fixed}.ck-element-selector-input-row{min-width:0}.ck-element-selector-composer .ck-input{border-radius:7px;width:100%;min-width:0;min-height:3rem;padding-inline:.875rem;font-size:.875rem;line-height:1.25rem}.ck-element-selector-actions{align-items:center;gap:.5rem;width:100%;display:flex}.ck-element-selector-actions .ck-button{min-height:2.375rem}.ck-element-selector-attach-action{gap:.375rem;margin-inline-end:auto}.ck-element-selector-grab-action{min-width:8.75rem}.ck-element-selector-action-icon{flex:none;width:.95rem;height:.95rem}.ck-element-selector-file-input{clip:rect(0 0 0 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.ck-element-selector-attachment{border:1px solid color-mix(in oklch, var(--border) 80%, transparent);background-color:color-mix(in oklch, var(--muted) 55%, transparent);border-radius:7px;align-items:center;gap:.625rem;width:100%;min-width:0;padding:.5rem;display:flex}.ck-element-selector-attachment-image{object-fit:cover;border-radius:6px;flex:none;width:2.5rem;height:2.5rem}.ck-element-selector-attachment-meta{flex:1;gap:.125rem;min-width:0;display:grid}.ck-element-selector-attachment-name,.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.ck-element-selector-attachment-name{color:var(--foreground);font-size:.75rem;font-weight:600;line-height:1rem}.ck-element-selector-attachment-path,.ck-element-selector-attachment-size{color:var(--muted-foreground);font-size:.6875rem;line-height:.875rem}.ck-element-selector-error{width:100%;color:var(--destructive);font-size:.75rem;line-height:1rem}@media (width<=420px){.ck-element-selector-actions{flex-wrap:wrap}.ck-element-selector-attach-action{margin-inline-end:0}.ck-element-selector-save-action,.ck-element-selector-grab-action{flex:auto}}", re = "data-commentkit-freeze", ie = "\n*, *::before, *::after {\n animation-play-state: paused !important;\n transition: none !important;\n}\n", v = 0, y = null, b = [];
|
|
24
20
|
function x() {
|
|
25
|
-
|
|
21
|
+
if (y || typeof document > "u") return;
|
|
22
|
+
let e = document.createElement("style");
|
|
23
|
+
e.setAttribute(re, ""), e.textContent = ie, document.head.appendChild(e), y = e;
|
|
26
24
|
}
|
|
27
25
|
function S() {
|
|
28
|
-
|
|
26
|
+
y &&= (y.remove(), null);
|
|
27
|
+
}
|
|
28
|
+
function C() {
|
|
29
|
+
typeof document < "u" && typeof document.getAnimations == "function" && (b = document.getAnimations().filter((e) => {
|
|
29
30
|
if (e.playState !== "running") return !1;
|
|
30
31
|
try {
|
|
31
32
|
return e.pause(), !0;
|
|
@@ -34,63 +35,63 @@ function S() {
|
|
|
34
35
|
}
|
|
35
36
|
}));
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
for (let e of
|
|
38
|
+
function w() {
|
|
39
|
+
for (let e of b) try {
|
|
39
40
|
e.play();
|
|
40
41
|
} catch {}
|
|
41
|
-
|
|
42
|
+
b = [];
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
44
|
+
function ae() {
|
|
45
|
+
v++, v === 1 && (x(), C());
|
|
45
46
|
let e = !1;
|
|
46
47
|
return () => {
|
|
47
|
-
e || (e = !0,
|
|
48
|
+
e || (e = !0, v = Math.max(0, v - 1), v === 0 && (S(), w()));
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
|
-
var
|
|
51
|
-
function
|
|
51
|
+
var T = 448, oe = 236, E = 8, D = .9, O = 1e3, k = 2147483600;
|
|
52
|
+
function A(e) {
|
|
52
53
|
return typeof Element < "u" && e instanceof Element;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function j() {
|
|
55
56
|
let e = document.activeElement;
|
|
56
57
|
for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
|
|
57
58
|
return e;
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function se(e) {
|
|
60
61
|
let t = typeof e.composedPath == "function" ? e.composedPath()[0] ?? e.target : e.target;
|
|
61
|
-
if (!
|
|
62
|
+
if (!A(t)) return !1;
|
|
62
63
|
let n = t.tagName.toLowerCase();
|
|
63
64
|
return n === "input" || n === "textarea" || n === "select" || t instanceof HTMLElement && t.isContentEditable;
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function M(e) {
|
|
66
67
|
let t = e.getRootNode();
|
|
67
68
|
return !!(e.closest("[data-commentkit], [data-commentkit-host], [data-commentkit-ui], .ck-root") || typeof ShadowRoot < "u" && t instanceof ShadowRoot && t.host.matches("[data-commentkit], [data-commentkit-host], [data-commentkit-ui]"));
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function N(e, t = H(e)) {
|
|
70
71
|
let n = e.tagName.toLowerCase();
|
|
71
|
-
if (n === "html" || n === "body" ||
|
|
72
|
+
if (n === "html" || n === "body" || M(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !U(t)) return !1;
|
|
72
73
|
let r = window.getComputedStyle(e);
|
|
73
74
|
if (r.display === "none" || r.visibility === "hidden") return !1;
|
|
74
75
|
let i = Number.parseFloat(r.opacity || "1");
|
|
75
76
|
if (Number.isFinite(i) && i <= .01) return !1;
|
|
76
|
-
let a = Number.parseInt(r.zIndex || "", 10), o = r.position === "fixed" || r.position === "absolute", s = t.width / Math.max(window.innerWidth, 1) >=
|
|
77
|
-
return !(r.pointerEvents === "none" && r.position === "fixed" && Number.isFinite(a) && a >=
|
|
77
|
+
let a = Number.parseInt(r.zIndex || "", 10), o = r.position === "fixed" || r.position === "absolute", s = t.width / Math.max(window.innerWidth, 1) >= D && t.height / Math.max(window.innerHeight, 1) >= D;
|
|
78
|
+
return !(r.pointerEvents === "none" && r.position === "fixed" && Number.isFinite(a) && a >= k || s && o && (r.backgroundColor === "transparent" || r.backgroundColor === "rgba(0, 0, 0, 0)" || Number.isFinite(i) && i < .1 || Number.isFinite(a) && a > O));
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function P(e) {
|
|
80
81
|
return typeof e.composedPath == "function" ? e.composedPath() : e.target ? [e.target] : [];
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
return
|
|
83
|
+
function F(e) {
|
|
84
|
+
return P(e).some((e) => A(e) && M(e));
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function I(e, t) {
|
|
86
87
|
if (typeof document.elementsFromPoint == "function") return document.elementsFromPoint(e, t);
|
|
87
88
|
let n = document.elementFromPoint?.(e, t);
|
|
88
89
|
return n ? [n] : [];
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
91
|
+
function L(e, t) {
|
|
92
|
+
return I(e, t).find((e) => N(e)) ?? null;
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function ce(e) {
|
|
94
95
|
let t = Math.min(e.startX, e.x), n = Math.min(e.startY, e.y), r = Math.abs(e.x - e.startX), i = Math.abs(e.y - e.startY);
|
|
95
96
|
return {
|
|
96
97
|
left: t,
|
|
@@ -101,27 +102,27 @@ function le(e) {
|
|
|
101
102
|
bottom: n + i
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
+
function R(e, t) {
|
|
105
106
|
return !(e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
|
|
106
107
|
}
|
|
107
|
-
var
|
|
108
|
-
function
|
|
108
|
+
var z = 200, B = 5e3;
|
|
109
|
+
function V(e) {
|
|
109
110
|
let t = window.getComputedStyle(e), n = (e) => e === "hidden" || e === "clip";
|
|
110
111
|
return n(t.overflowX) || n(t.overflowY) || n(t.overflow);
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function le(e) {
|
|
113
114
|
let t = [];
|
|
114
115
|
if (typeof document > "u") return t;
|
|
115
116
|
let n = 0, r = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, { acceptNode(r) {
|
|
116
|
-
if (n >=
|
|
117
|
+
if (n >= B || t.length >= z) return NodeFilter.FILTER_REJECT;
|
|
117
118
|
n += 1;
|
|
118
|
-
let i = r, a =
|
|
119
|
-
return !o &&
|
|
119
|
+
let i = r, a = H(i), o = U(a) && R(a, e);
|
|
120
|
+
return !o && V(i) ? NodeFilter.FILTER_REJECT : o && N(i, a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
120
121
|
} }), i = r.nextNode();
|
|
121
|
-
for (; i && (t.push(i), !(t.length >=
|
|
122
|
+
for (; i && (t.push(i), !(t.length >= z || n >= B));) i = r.nextNode();
|
|
122
123
|
return t;
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function H(e) {
|
|
125
126
|
let t = e.getBoundingClientRect();
|
|
126
127
|
return {
|
|
127
128
|
top: t.top,
|
|
@@ -132,38 +133,38 @@ function V(e) {
|
|
|
132
133
|
right: t.right
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
+
function U(e) {
|
|
136
137
|
return e.width > 0 && e.height > 0;
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
+
function W(e) {
|
|
139
140
|
return {
|
|
140
141
|
element: e,
|
|
141
142
|
selector: n(e),
|
|
142
143
|
xpath: t(e),
|
|
143
|
-
rect:
|
|
144
|
+
rect: H(e)
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
+
function G(e, t, n) {
|
|
147
148
|
return Math.min(n, Math.max(t, e));
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function K() {
|
|
150
151
|
return {
|
|
151
152
|
width: Math.max(window.innerWidth || 0, 16),
|
|
152
153
|
height: Math.max(window.innerHeight || 0, 16)
|
|
153
154
|
};
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
-
let t =
|
|
156
|
+
function ue(e) {
|
|
157
|
+
let t = K(), n = G(e.rect.left + e.rect.width / 2, 0, t.width), i = G(e.rect.top + e.rect.height / 2, 0, t.height);
|
|
157
158
|
return {
|
|
158
159
|
...r(n, i, t),
|
|
159
160
|
element: e.selector,
|
|
160
161
|
xpath: e.xpath
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function de(e) {
|
|
164
165
|
return typeof e != "number" || !Number.isFinite(e) ? "" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
|
|
165
166
|
}
|
|
166
|
-
function
|
|
167
|
+
function q(e, t) {
|
|
167
168
|
let n = e.path;
|
|
168
169
|
if (typeof n == "string" && n.trim()) return {
|
|
169
170
|
path: n.trim(),
|
|
@@ -182,8 +183,8 @@ function pe(e, t) {
|
|
|
182
183
|
pathSource: "browser-fallback"
|
|
183
184
|
};
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
-
let { path: n, pathSource: r } =
|
|
186
|
+
function fe(e, t) {
|
|
187
|
+
let { path: n, pathSource: r } = q(e, t);
|
|
187
188
|
return {
|
|
188
189
|
file: e,
|
|
189
190
|
name: e.name,
|
|
@@ -195,23 +196,23 @@ function me(e, t) {
|
|
|
195
196
|
previewUrl: e.type.startsWith("image/") && typeof URL.createObjectURL == "function" ? URL.createObjectURL(e) : null
|
|
196
197
|
};
|
|
197
198
|
}
|
|
198
|
-
function
|
|
199
|
+
function J(e) {
|
|
199
200
|
e && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
200
201
|
}
|
|
201
|
-
async function
|
|
202
|
+
async function pe(e, t) {
|
|
202
203
|
try {
|
|
203
204
|
if (!navigator.clipboard?.writeText) throw Error("clipboard unavailable");
|
|
204
205
|
await navigator.clipboard.writeText(e);
|
|
205
206
|
try {
|
|
206
|
-
|
|
207
|
+
l.success(`${t} copied`);
|
|
207
208
|
} catch {}
|
|
208
209
|
} catch {
|
|
209
210
|
try {
|
|
210
|
-
|
|
211
|
+
l.error(`Could not copy ${t.toLowerCase()}`);
|
|
211
212
|
} catch {}
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
function
|
|
215
|
+
function me(e) {
|
|
215
216
|
return {
|
|
216
217
|
top: e.top,
|
|
217
218
|
left: e.left,
|
|
@@ -219,19 +220,19 @@ function q(e) {
|
|
|
219
220
|
height: e.height
|
|
220
221
|
};
|
|
221
222
|
}
|
|
222
|
-
function
|
|
223
|
-
let n =
|
|
223
|
+
function he(e, t = oe) {
|
|
224
|
+
let n = K(), r = Math.max(E, n.width - T - E), i = G(e.left, E, r), a = e.bottom + E, o = e.top - t - E;
|
|
224
225
|
return {
|
|
225
226
|
left: i,
|
|
226
|
-
top: a + t <= n.height -
|
|
227
|
+
top: a + t <= n.height - E ? a : G(o, E, n.height - t - E)
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
|
-
var
|
|
230
|
+
var ge = 220, _e = 200;
|
|
230
231
|
function ve(e) {
|
|
231
|
-
let t =
|
|
232
|
+
let t = K();
|
|
232
233
|
return {
|
|
233
|
-
left:
|
|
234
|
-
top:
|
|
234
|
+
left: G(e.x, E, Math.max(E, t.width - ge - E)),
|
|
235
|
+
top: G(e.y, E, Math.max(E, t.height - _e - E))
|
|
235
236
|
};
|
|
236
237
|
}
|
|
237
238
|
function ye(e) {
|
|
@@ -242,16 +243,16 @@ function be(e) {
|
|
|
242
243
|
if (!ye(e)) return [];
|
|
243
244
|
let t = i(e.position.element ?? "", e.position.xpath);
|
|
244
245
|
if (!t) return [];
|
|
245
|
-
let n =
|
|
246
|
-
return
|
|
246
|
+
let n = H(t);
|
|
247
|
+
return N(t, n) ? [{
|
|
247
248
|
id: e.id,
|
|
248
249
|
rect: n
|
|
249
250
|
}] : [];
|
|
250
251
|
});
|
|
251
252
|
}
|
|
252
253
|
function xe(e) {
|
|
253
|
-
let [t, n] =
|
|
254
|
-
return
|
|
254
|
+
let [t, n] = p.useState(0);
|
|
255
|
+
return p.useEffect(() => {
|
|
255
256
|
if (!e) return;
|
|
256
257
|
let t = 0, r = () => {
|
|
257
258
|
t ||= window.requestAnimationFrame(() => {
|
|
@@ -275,63 +276,63 @@ function xe(e) {
|
|
|
275
276
|
};
|
|
276
277
|
}, [e]), t;
|
|
277
278
|
}
|
|
278
|
-
var Y =
|
|
279
|
-
let
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}, [
|
|
283
|
-
|
|
284
|
-
}, [
|
|
285
|
-
Ee.current = E;
|
|
286
|
-
}, [E]), d.useEffect(() => {
|
|
279
|
+
var Y = p.memo(function({ core: r, state: i, active: l }) {
|
|
280
|
+
let d = s(), _ = i.projectContext?.permissions.canExportAgentContext !== !1, { canWrite: re, message: ie } = o(), [v, y] = p.useState(null), [b, x] = p.useState(null), [S, C] = p.useState([]), [w, T] = p.useState(null), [E, D] = p.useState(null), [O, k] = p.useState(""), [A, M] = p.useState(null), [N, P] = p.useState(!1), I = p.useRef(null), [R, z] = p.useState(!1), [B, V] = p.useState(null), U = p.useRef(null), G = p.useRef(null), K = p.useRef(null), q = p.useRef(null), [ge, _e] = p.useState(oe), Y = a().path, Se = p.useMemo(() => i.comments.filter((e) => e.page?.path === Y), [i.comments, Y]), Ce = Se.some(ye), we = xe(l || Ce || !!b || S.length > 0), Te = p.useRef(null), Ee = p.useRef([]), De = p.useRef(""), Oe = p.useRef(null);
|
|
281
|
+
p.useEffect(() => {
|
|
282
|
+
Te.current = b?.element ?? v?.element ?? null;
|
|
283
|
+
}, [v, b]), p.useEffect(() => {
|
|
284
|
+
Ee.current = S;
|
|
285
|
+
}, [S]), p.useEffect(() => {
|
|
287
286
|
De.current = O;
|
|
288
|
-
}, [O])
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
287
|
+
}, [O]), p.useEffect(() => {
|
|
288
|
+
Oe.current = A;
|
|
289
|
+
}, [A]);
|
|
290
|
+
let ke = p.useMemo(() => be(Se), [Se, we]);
|
|
291
|
+
p.useEffect(() => {
|
|
292
|
+
let e = I.current;
|
|
293
|
+
(e && (i.currentUser?.id !== e.userId || (i.activeBranch ?? null) !== e.branch || Y !== e.page || !e.submitting && i.activeTool === null || i.activeTool !== null && i.activeTool !== "select") || !l && !N) && (I.current = null, y(null), x(null), C([]), D(null), k(""), M((e) => (J(e?.previewUrl), null)), P(!1), V(null), T(null), Q.current = null, $.current = !1);
|
|
293
294
|
}, [
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
l,
|
|
296
|
+
N,
|
|
296
297
|
i.activeTool,
|
|
297
298
|
i.activeBranch,
|
|
298
299
|
i.currentUser?.id,
|
|
299
|
-
|
|
300
|
-
]),
|
|
301
|
-
|
|
302
|
-
}, []),
|
|
303
|
-
if (!
|
|
300
|
+
Y
|
|
301
|
+
]), p.useEffect(() => () => {
|
|
302
|
+
I.current = null, J(Oe.current?.previewUrl);
|
|
303
|
+
}, []), p.useEffect(() => {
|
|
304
|
+
if (!l) return;
|
|
304
305
|
let e = document.body.style.cursor;
|
|
305
306
|
document.body.style.cursor = "crosshair";
|
|
306
|
-
let t =
|
|
307
|
+
let t = ae();
|
|
307
308
|
return () => {
|
|
308
309
|
document.body.style.cursor = e, t();
|
|
309
310
|
};
|
|
310
|
-
}, [
|
|
311
|
-
let X =
|
|
312
|
-
|
|
311
|
+
}, [l]);
|
|
312
|
+
let X = l && !!b;
|
|
313
|
+
p.useEffect(() => {
|
|
313
314
|
if (!X) return;
|
|
314
|
-
let e =
|
|
315
|
-
return e instanceof HTMLElement && !
|
|
316
|
-
let e =
|
|
317
|
-
|
|
315
|
+
let e = j();
|
|
316
|
+
return e instanceof HTMLElement && !U.current?.contains(e) && (q.current = e), U.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
|
|
317
|
+
let e = q.current;
|
|
318
|
+
q.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
|
|
318
319
|
};
|
|
319
320
|
}, [X]);
|
|
320
|
-
let
|
|
321
|
-
|
|
322
|
-
let e = !
|
|
323
|
-
if (
|
|
324
|
-
let t =
|
|
321
|
+
let Ae = p.useRef(i.isAuthenticated);
|
|
322
|
+
p.useEffect(() => {
|
|
323
|
+
let e = !Ae.current && i.isAuthenticated;
|
|
324
|
+
if (Ae.current = i.isAuthenticated, !e || !X || !O.trim()) return;
|
|
325
|
+
let t = U.current?.querySelector("[data-ck-composer-input]");
|
|
325
326
|
t?.focus({ preventScroll: !0 });
|
|
326
327
|
let n = t?.value.length ?? 0;
|
|
327
|
-
t?.setSelectionRange?.(n, n),
|
|
328
|
+
t?.setSelectionRange?.(n, n), V((e) => e && e.startsWith("Sign in to save comments") ? null : e);
|
|
328
329
|
}, [
|
|
329
330
|
i.isAuthenticated,
|
|
330
331
|
X,
|
|
331
|
-
|
|
332
|
-
]),
|
|
332
|
+
O
|
|
333
|
+
]), p.useLayoutEffect(() => {
|
|
333
334
|
if (!X) return;
|
|
334
|
-
let e =
|
|
335
|
+
let e = U.current;
|
|
335
336
|
if (!e) return;
|
|
336
337
|
let t = () => {
|
|
337
338
|
let t = e.getBoundingClientRect().height;
|
|
@@ -347,29 +348,29 @@ var Y = d.memo(function({ core: r, state: i, active: o }) {
|
|
|
347
348
|
return () => n?.disconnect();
|
|
348
349
|
}, [
|
|
349
350
|
X,
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
]),
|
|
353
|
-
if (!
|
|
351
|
+
A,
|
|
352
|
+
B
|
|
353
|
+
]), p.useEffect(() => {
|
|
354
|
+
if (!l) return;
|
|
354
355
|
let e = () => {
|
|
355
|
-
|
|
356
|
+
x((e) => e && {
|
|
356
357
|
...e,
|
|
357
|
-
rect:
|
|
358
|
-
}),
|
|
358
|
+
rect: H(e.element)
|
|
359
|
+
}), y((e) => e && {
|
|
359
360
|
...e,
|
|
360
|
-
rect:
|
|
361
|
-
}),
|
|
361
|
+
rect: H(e.element)
|
|
362
|
+
}), C((e) => e.map((e) => ({
|
|
362
363
|
...e,
|
|
363
|
-
rect:
|
|
364
|
+
rect: H(e.element)
|
|
364
365
|
})));
|
|
365
366
|
};
|
|
366
367
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
367
368
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
368
369
|
};
|
|
369
|
-
}, [
|
|
370
|
-
let Z =
|
|
371
|
-
if (!e ||
|
|
372
|
-
|
|
370
|
+
}, [l]);
|
|
371
|
+
let Z = p.useCallback(async (e, t, n) => {
|
|
372
|
+
if (!e || R) return !1;
|
|
373
|
+
z(!0), V(null);
|
|
373
374
|
try {
|
|
374
375
|
let i = t?.trim(), a = n ? [{
|
|
375
376
|
name: n.name,
|
|
@@ -382,45 +383,45 @@ var Y = d.memo(function({ core: r, state: i, active: o }) {
|
|
|
382
383
|
...i ? { comment: i } : {},
|
|
383
384
|
...a.length > 0 ? { attachments: a } : {}
|
|
384
385
|
} : void 0, s = o ? await r.grabElement(e, o) : await r.grabElement(e);
|
|
385
|
-
return
|
|
386
|
+
return z(!1), s ? (x(null), y(null), k(""), M((e) => (J(e?.previewUrl), null)), r.setTool(null), !0) : (V("Could not grab this element."), !1);
|
|
386
387
|
} catch {
|
|
387
|
-
return
|
|
388
|
+
return z(!1), V("Could not copy this element for the agent."), !1;
|
|
388
389
|
}
|
|
389
|
-
}, [r,
|
|
390
|
-
if (e.length === 0 ||
|
|
391
|
-
|
|
390
|
+
}, [r, R]), je = p.useCallback(async (e) => {
|
|
391
|
+
if (e.length === 0 || R) return !1;
|
|
392
|
+
z(!0), V(null);
|
|
392
393
|
try {
|
|
393
394
|
let t = await r.grabElements(e);
|
|
394
|
-
return
|
|
395
|
+
return z(!1), t ? (C([]), x(null), y(null), k(""), M((e) => (J(e?.previewUrl), null)), r.setTool(null), !0) : (V("Could not grab these elements."), !1);
|
|
395
396
|
} catch {
|
|
396
|
-
return
|
|
397
|
+
return z(!1), V("Could not copy these elements for the agent."), !1;
|
|
397
398
|
}
|
|
398
|
-
}, [r,
|
|
399
|
-
let e =
|
|
400
|
-
|
|
401
|
-
}, [
|
|
402
|
-
|
|
403
|
-
}, []), Q =
|
|
404
|
-
|
|
405
|
-
let
|
|
406
|
-
|
|
407
|
-
if (!
|
|
399
|
+
}, [r, R]), Me = p.useCallback(() => {
|
|
400
|
+
let e = Ee.current.map((e) => e.element);
|
|
401
|
+
je(e);
|
|
402
|
+
}, [je]), Ne = p.useCallback(() => {
|
|
403
|
+
C([]);
|
|
404
|
+
}, []), Q = p.useRef(null), $ = p.useRef(!1), Pe = p.useRef(null);
|
|
405
|
+
Pe.current = w;
|
|
406
|
+
let Fe = p.useRef(null);
|
|
407
|
+
Fe.current = E, p.useEffect(() => {
|
|
408
|
+
if (!E) return;
|
|
408
409
|
let e = r.blockEscape();
|
|
409
410
|
return () => e();
|
|
410
|
-
}, [
|
|
411
|
-
if (!
|
|
412
|
-
let e =
|
|
413
|
-
return e instanceof HTMLElement && !
|
|
414
|
-
let e =
|
|
415
|
-
|
|
411
|
+
}, [E, r]), p.useEffect(() => {
|
|
412
|
+
if (!E) return;
|
|
413
|
+
let e = j();
|
|
414
|
+
return e instanceof HTMLElement && !K.current?.contains(e) && (q.current = e), K.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
|
|
415
|
+
let e = q.current;
|
|
416
|
+
q.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
|
|
416
417
|
};
|
|
417
|
-
}, [
|
|
418
|
-
let
|
|
419
|
-
let t =
|
|
418
|
+
}, [E]);
|
|
419
|
+
let Ie = p.useCallback((e) => {
|
|
420
|
+
let t = K.current;
|
|
420
421
|
if (!t) return;
|
|
421
422
|
let n = Array.from(t.querySelectorAll("[role=\"menuitem\"]"));
|
|
422
423
|
if (n.length === 0) return;
|
|
423
|
-
let r =
|
|
424
|
+
let r = j(), i = n.findIndex((e) => e === r), a = (e) => {
|
|
424
425
|
n[(e + n.length) % n.length]?.focus({ preventScroll: !0 });
|
|
425
426
|
};
|
|
426
427
|
switch (e.key) {
|
|
@@ -437,454 +438,455 @@ var Y = d.memo(function({ core: r, state: i, active: o }) {
|
|
|
437
438
|
e.preventDefault(), e.stopPropagation(), a(n.length - 1);
|
|
438
439
|
break;
|
|
439
440
|
case "Enter":
|
|
440
|
-
case " ": e.preventDefault(), e.stopPropagation(),
|
|
441
|
+
case " ": e.preventDefault(), e.stopPropagation(), j()?.click();
|
|
441
442
|
}
|
|
442
443
|
}, []);
|
|
443
|
-
|
|
444
|
-
if (!
|
|
444
|
+
p.useEffect(() => {
|
|
445
|
+
if (!l && !N) return;
|
|
445
446
|
let i = (t) => {
|
|
446
|
-
e() || t.button !== 0 ||
|
|
447
|
+
_ && (e() || t.button !== 0 || F(t) || b || (D(null), Q.current = {
|
|
447
448
|
x: t.clientX,
|
|
448
449
|
y: t.clientY
|
|
449
|
-
}, $.current = !1);
|
|
450
|
+
}, $.current = !1));
|
|
450
451
|
}, a = (r) => {
|
|
451
|
-
if (e() ||
|
|
452
|
-
let i =
|
|
453
|
-
i && (r.preventDefault(), r.stopPropagation(),
|
|
452
|
+
if (e() || F(r)) return;
|
|
453
|
+
let i = L(r.clientX, r.clientY);
|
|
454
|
+
i && (r.preventDefault(), r.stopPropagation(), D({
|
|
454
455
|
element: i,
|
|
455
456
|
selector: n(i),
|
|
456
457
|
xpath: t(i),
|
|
457
458
|
x: r.clientX,
|
|
458
459
|
y: r.clientY
|
|
459
460
|
}));
|
|
460
|
-
},
|
|
461
|
-
|
|
462
|
-
},
|
|
463
|
-
if (e() ||
|
|
461
|
+
}, o = null, s = null, c = () => {
|
|
462
|
+
o &&= (clearTimeout(o), null), s = null;
|
|
463
|
+
}, u = (r) => {
|
|
464
|
+
if (e() || F(r) || r.touches.length !== 1) return;
|
|
464
465
|
let i = r.touches[0];
|
|
465
466
|
if (!i) return;
|
|
466
|
-
let a =
|
|
467
|
-
a && (
|
|
467
|
+
let a = L(i.clientX, i.clientY);
|
|
468
|
+
a && (s = {
|
|
468
469
|
x: i.clientX,
|
|
469
470
|
y: i.clientY,
|
|
470
471
|
element: a
|
|
471
|
-
},
|
|
472
|
-
|
|
473
|
-
element:
|
|
474
|
-
selector: n(
|
|
475
|
-
xpath: t(
|
|
476
|
-
x:
|
|
477
|
-
y:
|
|
478
|
-
}),
|
|
472
|
+
}, o = setTimeout(() => {
|
|
473
|
+
s && (D({
|
|
474
|
+
element: s.element,
|
|
475
|
+
selector: n(s.element),
|
|
476
|
+
xpath: t(s.element),
|
|
477
|
+
x: s.x,
|
|
478
|
+
y: s.y
|
|
479
|
+
}), s = null, o = null);
|
|
479
480
|
}, 550));
|
|
480
|
-
},
|
|
481
|
-
if (!
|
|
481
|
+
}, d = (e) => {
|
|
482
|
+
if (!s || e.touches.length !== 1) return;
|
|
482
483
|
let t = e.touches[0];
|
|
483
484
|
if (!t) return;
|
|
484
|
-
let n = t.clientX -
|
|
485
|
-
(Math.abs(n) > 10 || Math.abs(r) > 10) &&
|
|
486
|
-
},
|
|
487
|
-
|
|
488
|
-
},
|
|
489
|
-
if (e() ||
|
|
485
|
+
let n = t.clientX - s.x, r = t.clientY - s.y;
|
|
486
|
+
(Math.abs(n) > 10 || Math.abs(r) > 10) && c();
|
|
487
|
+
}, f = () => {
|
|
488
|
+
c();
|
|
489
|
+
}, ee = (t) => {
|
|
490
|
+
if (e() || F(t)) return;
|
|
490
491
|
let n = Q.current;
|
|
491
492
|
if (n) {
|
|
492
|
-
if (t.pointerType === "mouse" && !(t.buttons & 1)) Q.current = null, $.current = !1,
|
|
493
|
+
if (t.pointerType === "mouse" && !(t.buttons & 1)) Q.current = null, $.current = !1, T(null);
|
|
493
494
|
else {
|
|
494
495
|
let e = t.clientX - n.x, r = t.clientY - n.y;
|
|
495
|
-
if (
|
|
496
|
-
$.current = !0,
|
|
496
|
+
if (Pe.current || Math.abs(e) > 6 || Math.abs(r) > 6) {
|
|
497
|
+
$.current = !0, T({
|
|
497
498
|
startX: n.x,
|
|
498
499
|
startY: n.y,
|
|
499
500
|
x: t.clientX,
|
|
500
501
|
y: t.clientY
|
|
501
|
-
}),
|
|
502
|
+
}), y(null);
|
|
502
503
|
return;
|
|
503
504
|
}
|
|
504
505
|
}
|
|
505
506
|
}
|
|
506
|
-
if (
|
|
507
|
-
let r =
|
|
508
|
-
|
|
509
|
-
},
|
|
510
|
-
Q.current = null, $.current = !1,
|
|
511
|
-
},
|
|
507
|
+
if (b) return;
|
|
508
|
+
let r = L(t.clientX, t.clientY);
|
|
509
|
+
y(r ? W(r) : null);
|
|
510
|
+
}, p = () => {
|
|
511
|
+
Q.current = null, $.current = !1, T(null);
|
|
512
|
+
}, m = (t) => {
|
|
512
513
|
if (e()) return;
|
|
513
514
|
let n = Q.current;
|
|
514
515
|
Q.current = null;
|
|
515
|
-
let r =
|
|
516
|
+
let r = Pe.current;
|
|
516
517
|
if (!n || !r) return;
|
|
517
|
-
let i =
|
|
518
|
+
let i = ce({
|
|
518
519
|
...r,
|
|
519
520
|
x: t.clientX,
|
|
520
521
|
y: t.clientY
|
|
521
522
|
});
|
|
522
523
|
if (i.width < 6 || i.height < 6) {
|
|
523
|
-
|
|
524
|
+
T(null);
|
|
524
525
|
return;
|
|
525
526
|
}
|
|
526
|
-
let a =
|
|
527
|
+
let a = le(i);
|
|
527
528
|
if (a.length > 0) {
|
|
528
|
-
let e = a.map(
|
|
529
|
-
|
|
529
|
+
let e = a.map(W);
|
|
530
|
+
C((t) => {
|
|
530
531
|
let n = new Set(t.map((e) => e.element)), r = [...t];
|
|
531
532
|
for (let t of e) n.has(t.element) || r.push(t);
|
|
532
533
|
return r;
|
|
533
534
|
});
|
|
534
535
|
}
|
|
535
|
-
|
|
536
|
-
},
|
|
537
|
-
if (e() ||
|
|
536
|
+
T(null);
|
|
537
|
+
}, h = (t) => {
|
|
538
|
+
if (e() || F(t) || N) return;
|
|
538
539
|
if ($.current) {
|
|
539
540
|
$.current = !1, t.preventDefault(), t.stopPropagation();
|
|
540
541
|
return;
|
|
541
542
|
}
|
|
542
543
|
t.preventDefault(), t.stopPropagation();
|
|
543
|
-
let n =
|
|
544
|
-
|
|
545
|
-
},
|
|
544
|
+
let n = L(t.clientX, t.clientY);
|
|
545
|
+
b && (!t.shiftKey || !_) ? (x(null), y(null), k(""), M((e) => (J(e?.previewUrl), null)), V(null)) : n && (t.shiftKey && _ ? (C((e) => e.some((e) => e.element === n) ? e.filter((e) => e.element !== n) : [...b && !e.some((e) => e.element === b.element) ? [...e, b] : e, W(n)]), y(null), x(null), k(""), M((e) => (J(e?.previewUrl), null)), V(null)) : (x(W(n)), y(null), k(""), M((e) => (J(e?.previewUrl), null)), V(null)));
|
|
546
|
+
}, g = (t) => {
|
|
546
547
|
if (e()) return;
|
|
547
548
|
if (t.key === "Escape") {
|
|
548
549
|
if (t.isComposing) return;
|
|
549
|
-
if (
|
|
550
|
-
t.preventDefault(), t.stopPropagation(),
|
|
550
|
+
if (Fe.current) {
|
|
551
|
+
t.preventDefault(), t.stopPropagation(), D(null);
|
|
551
552
|
return;
|
|
552
553
|
}
|
|
553
|
-
t.preventDefault(), t.stopPropagation(),
|
|
554
|
+
t.preventDefault(), t.stopPropagation(), I.current = null, P(!1), x(null), y(null), k(""), M((e) => (J(e?.previewUrl), null)), V(null), r.setTool(null);
|
|
554
555
|
return;
|
|
555
556
|
}
|
|
556
|
-
if (
|
|
557
|
+
if (N || !t.metaKey && !t.ctrlKey || t.shiftKey || t.altKey || t.key !== "c" && t.key !== "C" && t.code !== "KeyC" || !_ || se(t)) return;
|
|
557
558
|
let n = typeof window < "u" ? window.getSelection() : null;
|
|
558
559
|
if (n && !n.isCollapsed && n.toString().length > 0) return;
|
|
559
|
-
let i =
|
|
560
|
+
let i = Ee.current;
|
|
560
561
|
if (i.length > 0) {
|
|
561
|
-
t.preventDefault(), t.stopPropagation(),
|
|
562
|
+
t.preventDefault(), t.stopPropagation(), je(i.map((e) => e.element));
|
|
562
563
|
return;
|
|
563
564
|
}
|
|
564
|
-
let a =
|
|
565
|
+
let a = Te.current;
|
|
565
566
|
if (!a) return;
|
|
566
567
|
t.preventDefault(), t.stopPropagation();
|
|
567
|
-
let o =
|
|
568
|
-
Z(a, o ?
|
|
568
|
+
let o = b?.element === a;
|
|
569
|
+
Z(a, o ? De.current : void 0, o ? Oe.current : null);
|
|
569
570
|
};
|
|
570
|
-
return document.addEventListener("pointerdown", i, !0), document.addEventListener("pointermove",
|
|
571
|
+
return document.addEventListener("pointerdown", i, !0), document.addEventListener("pointermove", ee, !0), document.addEventListener("pointerup", m, !0), document.addEventListener("pointercancel", p, !0), document.addEventListener("click", h, !0), document.addEventListener("contextmenu", a, !0), document.addEventListener("touchstart", u, {
|
|
571
572
|
capture: !0,
|
|
572
573
|
passive: !0
|
|
573
|
-
}), document.addEventListener("touchmove",
|
|
574
|
+
}), document.addEventListener("touchmove", d, {
|
|
574
575
|
capture: !0,
|
|
575
576
|
passive: !0
|
|
576
|
-
}), document.addEventListener("touchend",
|
|
577
|
+
}), document.addEventListener("touchend", f, {
|
|
577
578
|
capture: !0,
|
|
578
579
|
passive: !0
|
|
579
|
-
}), document.addEventListener("touchcancel",
|
|
580
|
+
}), document.addEventListener("touchcancel", f, {
|
|
580
581
|
capture: !0,
|
|
581
582
|
passive: !0
|
|
582
|
-
}), window.addEventListener("keydown",
|
|
583
|
-
document.removeEventListener("pointerdown", i, !0), document.removeEventListener("pointermove",
|
|
583
|
+
}), window.addEventListener("keydown", g, !0), () => {
|
|
584
|
+
document.removeEventListener("pointerdown", i, !0), document.removeEventListener("pointermove", ee, !0), document.removeEventListener("pointerup", m, !0), document.removeEventListener("pointercancel", p, !0), document.removeEventListener("click", h, !0), document.removeEventListener("contextmenu", a, !0), document.removeEventListener("touchstart", u, !0), document.removeEventListener("touchmove", d, !0), document.removeEventListener("touchend", f, !0), document.removeEventListener("touchcancel", f, !0), window.removeEventListener("keydown", g, !0), c();
|
|
584
585
|
};
|
|
585
586
|
}, [
|
|
586
|
-
|
|
587
|
-
|
|
587
|
+
l,
|
|
588
|
+
N,
|
|
588
589
|
r,
|
|
589
590
|
Z,
|
|
590
|
-
|
|
591
|
-
|
|
591
|
+
je,
|
|
592
|
+
b,
|
|
593
|
+
_
|
|
592
594
|
]);
|
|
593
|
-
let
|
|
595
|
+
let Le = p.useCallback(async (e) => {
|
|
594
596
|
e.preventDefault();
|
|
595
|
-
let t =
|
|
596
|
-
if (!
|
|
597
|
+
let t = O.trim();
|
|
598
|
+
if (!b || !t || N) return;
|
|
597
599
|
if (!i.currentUser) {
|
|
598
|
-
|
|
600
|
+
V("Sign in to save comments. You can still use Grab for agent without signing in."), r.toggleLoginModal();
|
|
599
601
|
return;
|
|
600
602
|
}
|
|
601
603
|
let n = {
|
|
602
604
|
userId: i.currentUser.id,
|
|
603
605
|
branch: i.activeBranch ?? null,
|
|
604
|
-
page:
|
|
606
|
+
page: Y,
|
|
605
607
|
submitting: !1
|
|
606
608
|
};
|
|
607
|
-
|
|
609
|
+
I.current = n;
|
|
608
610
|
let o = () => {
|
|
609
611
|
let e = r.getState();
|
|
610
|
-
return
|
|
612
|
+
return I.current === n && e.isAuthenticated && e.currentUser?.id === n.userId && (e.activeBranch ?? null) === n.branch && (e.activeTool === null || e.activeTool === "select") && a().path === n.page;
|
|
611
613
|
}, s = r.on("auth:logout", () => {
|
|
612
|
-
|
|
614
|
+
I.current === n && (I.current = null, P(!1));
|
|
613
615
|
});
|
|
614
|
-
|
|
616
|
+
P(!0), V(null);
|
|
615
617
|
try {
|
|
616
|
-
let e = await
|
|
618
|
+
let e = await f(r, t, ue(b), { files: A ? [A.file] : [] }, () => !o() || r.getState().activeTool !== "select" ? !1 : (n.submitting = !0, !0));
|
|
617
619
|
if (!o()) return;
|
|
618
620
|
if (e.status === "failed") throw Error(e.message);
|
|
619
|
-
|
|
621
|
+
x(null), k(""), M((e) => (J(e?.previewUrl), null)), r.setTool(null);
|
|
620
622
|
} catch {
|
|
621
623
|
if (!o()) return;
|
|
622
|
-
r.getState().activeTool === null && r.setTool("select"),
|
|
624
|
+
r.getState().activeTool === null && r.setTool("select"), V("Could not save this comment. Try again.");
|
|
623
625
|
} finally {
|
|
624
|
-
s(),
|
|
626
|
+
s(), I.current === n && (I.current = null, P(!1));
|
|
625
627
|
}
|
|
626
628
|
}, [
|
|
629
|
+
A,
|
|
627
630
|
O,
|
|
628
|
-
E,
|
|
629
631
|
r,
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
632
|
+
Y,
|
|
633
|
+
N,
|
|
634
|
+
b,
|
|
633
635
|
i.activeBranch,
|
|
634
636
|
i.currentUser
|
|
635
|
-
]),
|
|
636
|
-
Z(
|
|
637
|
+
]), Re = p.useCallback(() => {
|
|
638
|
+
Z(b?.element ?? null, O, A);
|
|
637
639
|
}, [
|
|
640
|
+
A,
|
|
638
641
|
O,
|
|
639
|
-
E,
|
|
640
642
|
Z,
|
|
641
|
-
|
|
642
|
-
]),
|
|
643
|
-
|
|
644
|
-
}, []),
|
|
643
|
+
b
|
|
644
|
+
]), ze = p.useCallback(() => {
|
|
645
|
+
G.current?.click();
|
|
646
|
+
}, []), Be = p.useCallback((e) => {
|
|
645
647
|
let t = e.currentTarget, n = t.files?.[0] ?? null;
|
|
646
|
-
|
|
647
|
-
}, []),
|
|
648
|
-
|
|
649
|
-
}, []),
|
|
650
|
-
return !
|
|
648
|
+
M((e) => (J(e?.previewUrl), n ? fe(n, t) : null)), t.value = "";
|
|
649
|
+
}, []), Ve = p.useCallback(() => {
|
|
650
|
+
M((e) => (J(e?.previewUrl), null));
|
|
651
|
+
}, []), He = p.useMemo(() => ee(), []);
|
|
652
|
+
return !l && !N && ke.length === 0 ? null : /* @__PURE__ */ g("div", {
|
|
651
653
|
className: "ck-element-selector",
|
|
652
654
|
"data-testid": "ck-element-selector",
|
|
653
655
|
children: [
|
|
654
|
-
|
|
656
|
+
ke.map((e) => /* @__PURE__ */ h("div", {
|
|
655
657
|
"aria-hidden": "true",
|
|
656
658
|
className: "ck-element-selector-mark",
|
|
657
659
|
"data-comment-id": e.id,
|
|
658
|
-
style:
|
|
660
|
+
style: me(e.rect)
|
|
659
661
|
}, e.id)),
|
|
660
|
-
|
|
662
|
+
l && v && !w && /* @__PURE__ */ h("div", {
|
|
661
663
|
"aria-hidden": "true",
|
|
662
664
|
className: "ck-element-selector-outline",
|
|
663
665
|
"data-state": "hover",
|
|
664
|
-
style:
|
|
666
|
+
style: me(v.rect)
|
|
665
667
|
}),
|
|
666
|
-
|
|
668
|
+
l && w && /* @__PURE__ */ h("div", {
|
|
667
669
|
"aria-hidden": "true",
|
|
668
670
|
className: "ck-element-selector-marquee",
|
|
669
671
|
"data-testid": "ck-element-selector-marquee",
|
|
670
672
|
style: {
|
|
671
|
-
left: Math.min(
|
|
672
|
-
top: Math.min(
|
|
673
|
-
width: Math.abs(
|
|
674
|
-
height: Math.abs(
|
|
673
|
+
left: Math.min(w.startX, w.x),
|
|
674
|
+
top: Math.min(w.startY, w.y),
|
|
675
|
+
width: Math.abs(w.x - w.startX),
|
|
676
|
+
height: Math.abs(w.y - w.startY)
|
|
675
677
|
}
|
|
676
678
|
}),
|
|
677
|
-
|
|
679
|
+
l && S.map((e, t) => /* @__PURE__ */ h("div", {
|
|
678
680
|
"aria-hidden": "true",
|
|
679
681
|
className: "ck-element-selector-outline",
|
|
680
682
|
"data-state": "multi",
|
|
681
683
|
"data-multi-index": t + 1,
|
|
682
|
-
style:
|
|
684
|
+
style: me(e.rect)
|
|
683
685
|
}, `multi-${t}-${e.selector}-${e.xpath}`)),
|
|
684
|
-
|
|
685
|
-
ref:
|
|
686
|
+
l && E && /* @__PURE__ */ g("ul", {
|
|
687
|
+
ref: K,
|
|
686
688
|
className: "ck-element-selector-context-menu",
|
|
687
689
|
"data-testid": "ck-element-selector-context-menu",
|
|
688
690
|
role: "menu",
|
|
689
691
|
"aria-label": "Element actions",
|
|
690
|
-
onKeyDown:
|
|
691
|
-
style: ve(
|
|
692
|
+
onKeyDown: Ie,
|
|
693
|
+
style: ve(E),
|
|
692
694
|
children: [
|
|
693
|
-
/* @__PURE__ */
|
|
695
|
+
_ && /* @__PURE__ */ h("li", { children: /* @__PURE__ */ h("button", {
|
|
694
696
|
type: "button",
|
|
695
697
|
role: "menuitem",
|
|
696
698
|
"data-testid": "ck-context-menu-grab",
|
|
697
699
|
onClick: () => {
|
|
698
|
-
let e =
|
|
699
|
-
|
|
700
|
+
let e = E.element;
|
|
701
|
+
D(null), Z(e);
|
|
700
702
|
},
|
|
701
703
|
children: "Grab for agent"
|
|
702
704
|
}) }),
|
|
703
|
-
/* @__PURE__ */
|
|
705
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h("button", {
|
|
704
706
|
type: "button",
|
|
705
707
|
role: "menuitem",
|
|
706
708
|
"data-testid": "ck-context-menu-comment",
|
|
707
|
-
disabled: !
|
|
709
|
+
disabled: !re,
|
|
708
710
|
onClick: () => {
|
|
709
|
-
let e =
|
|
710
|
-
|
|
711
|
+
let e = W(E.element);
|
|
712
|
+
D(null), x(e);
|
|
711
713
|
},
|
|
712
714
|
children: "Add comment"
|
|
713
715
|
}) }),
|
|
714
|
-
/* @__PURE__ */
|
|
716
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h("button", {
|
|
715
717
|
type: "button",
|
|
716
718
|
role: "menuitem",
|
|
717
719
|
"data-testid": "ck-context-menu-copy-selector",
|
|
718
720
|
onClick: () => {
|
|
719
|
-
let e =
|
|
720
|
-
|
|
721
|
+
let e = E.selector;
|
|
722
|
+
D(null), pe(e, "CSS selector");
|
|
721
723
|
},
|
|
722
724
|
children: "Copy CSS selector"
|
|
723
725
|
}) }),
|
|
724
|
-
/* @__PURE__ */
|
|
726
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h("button", {
|
|
725
727
|
type: "button",
|
|
726
728
|
role: "menuitem",
|
|
727
729
|
"data-testid": "ck-context-menu-copy-xpath",
|
|
728
730
|
onClick: () => {
|
|
729
|
-
let e =
|
|
730
|
-
|
|
731
|
+
let e = E.xpath;
|
|
732
|
+
D(null), pe(e, "XPath");
|
|
731
733
|
},
|
|
732
734
|
children: "Copy XPath"
|
|
733
735
|
}) }),
|
|
734
|
-
/* @__PURE__ */
|
|
736
|
+
/* @__PURE__ */ h("li", { children: /* @__PURE__ */ h("button", {
|
|
735
737
|
type: "button",
|
|
736
738
|
role: "menuitem",
|
|
737
739
|
"data-testid": "ck-context-menu-inspect",
|
|
738
740
|
onClick: () => {
|
|
739
|
-
console.log("[CommentKit] inspect",
|
|
741
|
+
console.log("[CommentKit] inspect", E.element), D(null);
|
|
740
742
|
},
|
|
741
743
|
children: "Inspect (log to console)"
|
|
742
744
|
}) })
|
|
743
745
|
]
|
|
744
746
|
}),
|
|
745
|
-
|
|
747
|
+
l && _ && S.length > 0 && /* @__PURE__ */ g("div", {
|
|
746
748
|
className: "ck-element-selector-multibar",
|
|
747
749
|
"data-testid": "ck-element-selector-multibar",
|
|
748
750
|
children: [
|
|
749
|
-
/* @__PURE__ */
|
|
751
|
+
/* @__PURE__ */ g("span", {
|
|
750
752
|
className: "ck-element-selector-multibar-count",
|
|
751
|
-
children: [
|
|
753
|
+
children: [S.length, " selected"]
|
|
752
754
|
}),
|
|
753
|
-
/* @__PURE__ */
|
|
755
|
+
/* @__PURE__ */ h(u, {
|
|
754
756
|
type: "button",
|
|
755
757
|
size: "sm",
|
|
756
|
-
onClick:
|
|
757
|
-
disabled:
|
|
758
|
+
onClick: Me,
|
|
759
|
+
disabled: R,
|
|
758
760
|
"data-testid": "ck-element-grab-many-button",
|
|
759
|
-
children:
|
|
761
|
+
children: R ? "Grabbing…" : `Grab ${S.length} for agent`
|
|
760
762
|
}),
|
|
761
|
-
/* @__PURE__ */
|
|
763
|
+
/* @__PURE__ */ h(u, {
|
|
762
764
|
type: "button",
|
|
763
765
|
size: "sm",
|
|
764
766
|
variant: "ghost",
|
|
765
|
-
onClick:
|
|
766
|
-
disabled:
|
|
767
|
+
onClick: Ne,
|
|
768
|
+
disabled: R,
|
|
767
769
|
"data-testid": "ck-element-grab-clear-button",
|
|
768
770
|
children: "Clear"
|
|
769
771
|
})
|
|
770
772
|
]
|
|
771
773
|
}),
|
|
772
|
-
(
|
|
774
|
+
(l || N) && b && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
|
|
773
775
|
"aria-hidden": "true",
|
|
774
776
|
className: "ck-element-selector-outline",
|
|
775
777
|
"data-state": "selected",
|
|
776
|
-
style:
|
|
777
|
-
}), /* @__PURE__ */
|
|
778
|
-
ref:
|
|
778
|
+
style: me(b.rect)
|
|
779
|
+
}), /* @__PURE__ */ g("form", {
|
|
780
|
+
ref: U,
|
|
779
781
|
className: "ck-element-selector-composer",
|
|
780
|
-
style:
|
|
781
|
-
onSubmit:
|
|
782
|
+
style: he(b.rect, ge),
|
|
783
|
+
onSubmit: Le,
|
|
782
784
|
children: [
|
|
783
|
-
/* @__PURE__ */
|
|
785
|
+
/* @__PURE__ */ h("div", {
|
|
784
786
|
className: "ck-element-selector-input-row",
|
|
785
|
-
children: /* @__PURE__ */
|
|
787
|
+
children: /* @__PURE__ */ h(c, {
|
|
786
788
|
"data-ck-composer-input": "",
|
|
787
789
|
"aria-label": "Element comment",
|
|
788
|
-
value:
|
|
790
|
+
value: O,
|
|
789
791
|
placeholder: "Add comment",
|
|
790
|
-
disabled:
|
|
792
|
+
disabled: N || R,
|
|
791
793
|
onChange: (e) => {
|
|
792
|
-
|
|
794
|
+
k(e.currentTarget.value), B && V(null);
|
|
793
795
|
}
|
|
794
796
|
})
|
|
795
797
|
}),
|
|
796
|
-
!
|
|
797
|
-
ref:
|
|
798
|
+
!d && /* @__PURE__ */ h("input", {
|
|
799
|
+
ref: G,
|
|
798
800
|
"aria-label": "Attach file",
|
|
799
801
|
className: "ck-element-selector-file-input",
|
|
800
802
|
type: "file",
|
|
801
|
-
disabled:
|
|
802
|
-
onChange:
|
|
803
|
+
disabled: N || R,
|
|
804
|
+
onChange: Be
|
|
803
805
|
}),
|
|
804
|
-
|
|
806
|
+
A && /* @__PURE__ */ g("div", {
|
|
805
807
|
className: "ck-element-selector-attachment",
|
|
806
808
|
"data-testid": "ck-element-attachment-preview",
|
|
807
809
|
children: [
|
|
808
|
-
|
|
810
|
+
A.previewUrl && /* @__PURE__ */ h("img", {
|
|
809
811
|
alt: "",
|
|
810
812
|
"aria-hidden": "true",
|
|
811
813
|
className: "ck-element-selector-attachment-image",
|
|
812
|
-
src:
|
|
814
|
+
src: A.previewUrl
|
|
813
815
|
}),
|
|
814
|
-
/* @__PURE__ */
|
|
816
|
+
/* @__PURE__ */ g("div", {
|
|
815
817
|
className: "ck-element-selector-attachment-meta",
|
|
816
818
|
children: [
|
|
817
|
-
/* @__PURE__ */
|
|
819
|
+
/* @__PURE__ */ h("span", {
|
|
818
820
|
className: "ck-element-selector-attachment-name",
|
|
819
|
-
children:
|
|
821
|
+
children: A.name
|
|
820
822
|
}),
|
|
821
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ h("span", {
|
|
822
824
|
className: "ck-element-selector-attachment-path",
|
|
823
|
-
title:
|
|
824
|
-
children:
|
|
825
|
+
title: A.path,
|
|
826
|
+
children: A.path
|
|
825
827
|
}),
|
|
826
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ h("span", {
|
|
827
829
|
className: "ck-element-selector-attachment-size",
|
|
828
|
-
children:
|
|
830
|
+
children: de(A.size)
|
|
829
831
|
})
|
|
830
832
|
]
|
|
831
833
|
}),
|
|
832
|
-
/* @__PURE__ */
|
|
834
|
+
/* @__PURE__ */ h(u, {
|
|
833
835
|
type: "button",
|
|
834
836
|
size: "icon-xs",
|
|
835
837
|
variant: "ghost",
|
|
836
838
|
"aria-label": "Remove attachment",
|
|
837
|
-
disabled:
|
|
838
|
-
onClick:
|
|
839
|
-
children: /* @__PURE__ */
|
|
839
|
+
disabled: N || R,
|
|
840
|
+
onClick: Ve,
|
|
841
|
+
children: /* @__PURE__ */ h(ne, {
|
|
840
842
|
className: "ck-element-selector-action-icon",
|
|
841
843
|
"aria-hidden": "true"
|
|
842
844
|
})
|
|
843
845
|
})
|
|
844
846
|
]
|
|
845
847
|
}),
|
|
846
|
-
/* @__PURE__ */
|
|
848
|
+
/* @__PURE__ */ g("div", {
|
|
847
849
|
className: "ck-element-selector-actions",
|
|
848
850
|
children: [
|
|
849
|
-
!
|
|
851
|
+
!d && /* @__PURE__ */ g(u, {
|
|
850
852
|
type: "button",
|
|
851
853
|
variant: "outline",
|
|
852
854
|
className: "ck-element-selector-attach-action",
|
|
853
|
-
disabled:
|
|
854
|
-
onClick:
|
|
855
|
+
disabled: N || R,
|
|
856
|
+
onClick: ze,
|
|
855
857
|
"data-testid": "ck-element-attach-button",
|
|
856
|
-
children: [/* @__PURE__ */
|
|
858
|
+
children: [/* @__PURE__ */ h(te, {
|
|
857
859
|
className: "ck-element-selector-action-icon",
|
|
858
860
|
"aria-hidden": "true"
|
|
859
|
-
}), /* @__PURE__ */
|
|
861
|
+
}), /* @__PURE__ */ h("span", { children: "Attach" })]
|
|
860
862
|
}),
|
|
861
|
-
/* @__PURE__ */
|
|
863
|
+
/* @__PURE__ */ h(u, {
|
|
862
864
|
type: "submit",
|
|
863
865
|
className: "ck-element-selector-save-action",
|
|
864
|
-
disabled: !
|
|
865
|
-
children:
|
|
866
|
+
disabled: !re || !O.trim() || N || R,
|
|
867
|
+
children: N ? "Saving" : "Save"
|
|
866
868
|
}),
|
|
867
|
-
/* @__PURE__ */
|
|
869
|
+
_ && /* @__PURE__ */ h(u, {
|
|
868
870
|
type: "button",
|
|
869
871
|
className: "ck-element-selector-grab-action",
|
|
870
|
-
variant:
|
|
871
|
-
disabled:
|
|
872
|
-
onClick:
|
|
873
|
-
title:
|
|
872
|
+
variant: He ? "default" : "outline",
|
|
873
|
+
disabled: N || R,
|
|
874
|
+
onClick: Re,
|
|
875
|
+
title: d ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
|
|
874
876
|
"data-testid": "ck-element-grab-button",
|
|
875
|
-
children:
|
|
877
|
+
children: R ? "Grabbing…" : "Grab for agent"
|
|
876
878
|
})
|
|
877
879
|
]
|
|
878
880
|
}),
|
|
879
|
-
!
|
|
881
|
+
!re && /* @__PURE__ */ h("p", {
|
|
880
882
|
role: "status",
|
|
881
883
|
className: "ck-element-selector-error",
|
|
882
|
-
children:
|
|
884
|
+
children: ie
|
|
883
885
|
}),
|
|
884
|
-
|
|
886
|
+
B && /* @__PURE__ */ h("p", {
|
|
885
887
|
className: "ck-element-selector-error",
|
|
886
888
|
role: "alert",
|
|
887
|
-
children:
|
|
889
|
+
children: B
|
|
888
890
|
})
|
|
889
891
|
]
|
|
890
892
|
})] })
|
|
@@ -892,9 +894,9 @@ var Y = d.memo(function({ core: r, state: i, active: o }) {
|
|
|
892
894
|
});
|
|
893
895
|
});
|
|
894
896
|
function Se(e) {
|
|
895
|
-
return /* @__PURE__ */ m
|
|
897
|
+
return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("style", {
|
|
896
898
|
"data-ck-tool-styles": "element-selector",
|
|
897
|
-
children:
|
|
898
|
-
}), /* @__PURE__ */
|
|
899
|
+
children: _
|
|
900
|
+
}), /* @__PURE__ */ h(Y, { ...e })] });
|
|
899
901
|
}
|
|
900
902
|
export { Se as ElementSelector };
|