@commentkit/comment-kit 0.7.0 → 0.7.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 +27 -0
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +5 -5
- package/dist/demo.es.js +4 -3
- package/dist/headless.es.js +3 -3
- 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-B9SxYqoF.js → annotation-toolbar-cGC1p-SP.js} +379 -379
- package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
- package/dist/shared/{button-group-Cl9CrvvU.js → button-group-CWdKaOlC.js} +14 -16
- package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
- package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-DdXlMgbF.js} +2 -2
- package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-Dg9ZWpz-.js} +29 -23
- package/dist/shared/comment-image-lightbox-B7iHjnAz.js +190 -0
- package/dist/shared/comment-images-content-D7YNUgo5.js +214 -0
- package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-C862uNAm.js} +998 -778
- package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-0vd-DY4S.js} +5206 -5410
- package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-DcaSSuWB.js} +5 -5
- package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-D_nFoJmM.js} +6 -5
- package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-pWBlhlse.js} +7 -7
- package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
- package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-DC-_XJ0k.js} +311 -272
- package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-B68j8r6I.js} +4 -4
- package/dist/shared/{pusher-ipHMJnO_.js → pusher-C1FHQGXV.js} +1 -1
- package/dist/shared/realtime-Diqz7G_y.js +317 -0
- package/dist/shared/realtime-recovery-DJ_adc-H.js +135 -0
- package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-CrO75sED.js} +1 -1
- package/dist/shared/{styles-D3yMtaec.js → styles-C9Jwvm0Q.js} +1 -1
- package/dist/shared/useRender-D1z_X_BY.js +5 -0
- package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
- package/dist/shared/{websocket-manager-DhLWh3Jr.js → websocket-manager-CFak_YHy.js} +148 -89
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +8 -1
- package/dist/types/core/comment-kit-core.d.ts +9 -0
- package/dist/types/core/types.d.ts +35 -0
- package/dist/types/core/websocket-manager.d.ts +12 -0
- package/dist/types/core/write-access.d.ts +9 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +6 -0
- package/package.json +3 -2
- package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
- package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
- package/dist/shared/realtime-Dk41VwKg.js +0 -302
|
@@ -2,23 +2,23 @@ import { a as e, i as t, m as n, n as r, o as i } from "./dom-Bhf4WFtY.js";
|
|
|
2
2
|
import { n as a } from "./dist-De294MVF.js";
|
|
3
3
|
import { t as o } from "./button-By0hGrJK.js";
|
|
4
4
|
import { t as s } from "./createReactComponent-BZHeRbD0.js";
|
|
5
|
-
import {
|
|
6
|
-
import * as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
var
|
|
5
|
+
import { G as c, K as ee, S as te, V as l, n as ne } from "./comment-kit-ui-0vd-DY4S.js";
|
|
6
|
+
import * as u from "react";
|
|
7
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
8
|
+
var re = s("outline", "paperclip", "Paperclip", [["path", {
|
|
9
9
|
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",
|
|
10
10
|
key: "svg-0"
|
|
11
|
-
}]]),
|
|
11
|
+
}]]), ie = s("outline", "x", "X", [["path", {
|
|
12
12
|
d: "M18 6l-12 12",
|
|
13
13
|
key: "svg-0"
|
|
14
14
|
}], ["path", {
|
|
15
15
|
d: "M6 6l12 12",
|
|
16
16
|
key: "svg-1"
|
|
17
|
-
}]]),
|
|
17
|
+
}]]), m = ".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}}", ae = "data-commentkit-freeze", h = "\n*, *::before, *::after {\n animation-play-state: paused !important;\n transition: none !important;\n}\n", g = 0, _ = null, v = [];
|
|
18
18
|
function y() {
|
|
19
19
|
if (_ || typeof document > "u") return;
|
|
20
20
|
let e = document.createElement("style");
|
|
21
|
-
e.setAttribute(
|
|
21
|
+
e.setAttribute(ae, ""), e.textContent = h, document.head.appendChild(e), _ = e;
|
|
22
22
|
}
|
|
23
23
|
function b() {
|
|
24
24
|
_ &&= (_.remove(), null);
|
|
@@ -39,14 +39,14 @@ function S() {
|
|
|
39
39
|
} catch {}
|
|
40
40
|
v = [];
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function oe() {
|
|
43
43
|
g++, g === 1 && (y(), x());
|
|
44
44
|
let e = !1;
|
|
45
45
|
return () => {
|
|
46
46
|
e || (e = !0, g = Math.max(0, g - 1), g === 0 && (b(), S()));
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
var C = 448,
|
|
49
|
+
var C = 448, se = 236, w = 8, T = .9, E = 1e3, D = 2147483600;
|
|
50
50
|
function O(e) {
|
|
51
51
|
return typeof Element < "u" && e instanceof Element;
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ function k() {
|
|
|
55
55
|
for (; e?.shadowRoot?.activeElement;) e = e.shadowRoot.activeElement;
|
|
56
56
|
return e;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function ce(e) {
|
|
59
59
|
let t = typeof e.composedPath == "function" ? e.composedPath()[0] ?? e.target : e.target;
|
|
60
60
|
if (!O(t)) return !1;
|
|
61
61
|
let n = t.tagName.toLowerCase();
|
|
@@ -67,7 +67,7 @@ function A(e) {
|
|
|
67
67
|
}
|
|
68
68
|
function j(e, t = B(e)) {
|
|
69
69
|
let n = e.tagName.toLowerCase();
|
|
70
|
-
if (n === "html" || n === "body" || A(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !
|
|
70
|
+
if (n === "html" || n === "body" || A(e) || e.closest("[data-commentkit-ignore], [data-react-grab-ignore]") || !V(t)) return !1;
|
|
71
71
|
let r = window.getComputedStyle(e);
|
|
72
72
|
if (r.display === "none" || r.visibility === "hidden") return !1;
|
|
73
73
|
let i = Number.parseFloat(r.opacity || "1");
|
|
@@ -89,7 +89,7 @@ function P(e, t) {
|
|
|
89
89
|
function F(e, t) {
|
|
90
90
|
return P(e, t).find((e) => j(e)) ?? null;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function le(e) {
|
|
93
93
|
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);
|
|
94
94
|
return {
|
|
95
95
|
left: t,
|
|
@@ -108,13 +108,13 @@ function z(e) {
|
|
|
108
108
|
let t = window.getComputedStyle(e), n = (e) => e === "hidden" || e === "clip";
|
|
109
109
|
return n(t.overflowX) || n(t.overflowY) || n(t.overflow);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function ue(e) {
|
|
112
112
|
let t = [];
|
|
113
113
|
if (typeof document > "u") return t;
|
|
114
114
|
let n = 0, r = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, { acceptNode(r) {
|
|
115
115
|
if (n >= R || t.length >= L) return NodeFilter.FILTER_REJECT;
|
|
116
116
|
n += 1;
|
|
117
|
-
let i = r, a = B(i), o =
|
|
117
|
+
let i = r, a = B(i), o = V(a) && I(a, e);
|
|
118
118
|
return !o && z(i) ? NodeFilter.FILTER_REJECT : o && j(i, a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
119
119
|
} }), i = r.nextNode();
|
|
120
120
|
for (; i && (t.push(i), !(t.length >= L || n >= R));) i = r.nextNode();
|
|
@@ -131,10 +131,10 @@ function B(e) {
|
|
|
131
131
|
right: t.right
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function V(e) {
|
|
135
135
|
return e.width > 0 && e.height > 0;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function H(n) {
|
|
138
138
|
return {
|
|
139
139
|
element: n,
|
|
140
140
|
selector: t(n),
|
|
@@ -142,27 +142,27 @@ function V(n) {
|
|
|
142
142
|
rect: B(n)
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function U(e, t, n) {
|
|
146
146
|
return Math.min(n, Math.max(t, e));
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function W() {
|
|
149
149
|
return {
|
|
150
150
|
width: Math.max(window.innerWidth || 0, 16),
|
|
151
151
|
height: Math.max(window.innerHeight || 0, 16)
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
let t =
|
|
154
|
+
function de(e) {
|
|
155
|
+
let t = W(), r = U(e.rect.left + e.rect.width / 2, 0, t.width), i = U(e.rect.top + e.rect.height / 2, 0, t.height);
|
|
156
156
|
return {
|
|
157
157
|
...n(r, i, t),
|
|
158
158
|
element: e.selector,
|
|
159
159
|
xpath: e.xpath
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function fe(e) {
|
|
163
163
|
return typeof e != "number" || !Number.isFinite(e) ? "" : e < 1024 ? `${e} B` : e < 1048576 ? `${(e / 1024).toFixed(1)} KB` : `${(e / 1024 / 1024).toFixed(1)} MB`;
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function pe(e, t) {
|
|
166
166
|
let n = e.path;
|
|
167
167
|
if (typeof n == "string" && n.trim()) return {
|
|
168
168
|
path: n.trim(),
|
|
@@ -181,9 +181,10 @@ function W(e, t) {
|
|
|
181
181
|
pathSource: "browser-fallback"
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
let { path: n, pathSource: r } =
|
|
184
|
+
function me(e, t) {
|
|
185
|
+
let { path: n, pathSource: r } = pe(e, t);
|
|
186
186
|
return {
|
|
187
|
+
file: e,
|
|
187
188
|
name: e.name,
|
|
188
189
|
path: n,
|
|
189
190
|
pathSource: r,
|
|
@@ -196,7 +197,7 @@ function fe(e, t) {
|
|
|
196
197
|
function G(e) {
|
|
197
198
|
e && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
198
199
|
}
|
|
199
|
-
async function
|
|
200
|
+
async function he(e, t) {
|
|
200
201
|
try {
|
|
201
202
|
if (!navigator.clipboard?.writeText) throw Error("clipboard unavailable");
|
|
202
203
|
await navigator.clipboard.writeText(e);
|
|
@@ -217,27 +218,27 @@ function K(e) {
|
|
|
217
218
|
height: e.height
|
|
218
219
|
};
|
|
219
220
|
}
|
|
220
|
-
function
|
|
221
|
-
let n =
|
|
221
|
+
function ge(e, t = se) {
|
|
222
|
+
let n = W(), r = Math.max(w, n.width - C - w), i = U(e.left, w, r), a = e.bottom + w, o = e.top - t - w;
|
|
222
223
|
return {
|
|
223
224
|
left: i,
|
|
224
|
-
top: a + t <= n.height - w ? a :
|
|
225
|
+
top: a + t <= n.height - w ? a : U(o, w, n.height - t - w)
|
|
225
226
|
};
|
|
226
227
|
}
|
|
227
|
-
var
|
|
228
|
-
function
|
|
229
|
-
let t =
|
|
228
|
+
var _e = 220, q = 200;
|
|
229
|
+
function ve(e) {
|
|
230
|
+
let t = W();
|
|
230
231
|
return {
|
|
231
|
-
left:
|
|
232
|
-
top:
|
|
232
|
+
left: U(e.x, w, Math.max(w, t.width - _e - w)),
|
|
233
|
+
top: U(e.y, w, Math.max(w, t.height - q - w))
|
|
233
234
|
};
|
|
234
235
|
}
|
|
235
|
-
function
|
|
236
|
+
function ye(e) {
|
|
236
237
|
return e.status === "open" && !!(e.position.element || e.position.xpath);
|
|
237
238
|
}
|
|
238
|
-
function
|
|
239
|
+
function be(e) {
|
|
239
240
|
return e.flatMap((e) => {
|
|
240
|
-
if (!
|
|
241
|
+
if (!ye(e)) return [];
|
|
241
242
|
let t = r(e.position.element ?? "", e.position.xpath);
|
|
242
243
|
if (!t) return [];
|
|
243
244
|
let n = B(t);
|
|
@@ -247,9 +248,9 @@ function ye(e) {
|
|
|
247
248
|
}] : [];
|
|
248
249
|
});
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
-
let [t, n] =
|
|
252
|
-
return
|
|
251
|
+
function xe(e) {
|
|
252
|
+
let [t, n] = u.useState(0);
|
|
253
|
+
return u.useEffect(() => {
|
|
253
254
|
if (!e) return;
|
|
254
255
|
let t = 0, r = () => {
|
|
255
256
|
t ||= window.requestAnimationFrame(() => {
|
|
@@ -273,59 +274,67 @@ function be(e) {
|
|
|
273
274
|
};
|
|
274
275
|
}, [e]), t;
|
|
275
276
|
}
|
|
276
|
-
var
|
|
277
|
-
let s =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}, [
|
|
281
|
-
|
|
282
|
-
}, [
|
|
283
|
-
|
|
284
|
-
}, [
|
|
285
|
-
|
|
286
|
-
}, [
|
|
287
|
-
let
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
277
|
+
var J = u.memo(function({ core: n, state: r, active: a }) {
|
|
278
|
+
let s = l(), { canWrite: m, message: ae } = ee(), [h, g] = u.useState(null), [_, v] = u.useState(null), [y, b] = u.useState([]), [x, S] = u.useState(null), [C, w] = u.useState(null), [T, E] = u.useState(""), [D, O] = u.useState(null), [A, j] = u.useState(!1), M = u.useRef(null), [P, I] = u.useState(!1), [L, R] = u.useState(null), z = u.useRef(null), V = u.useRef(null), U = u.useRef(null), W = u.useRef(null), [pe, _e] = u.useState(se), q = i().path, J = u.useMemo(() => r.comments.filter((e) => e.page?.path === q), [r.comments, q]), Se = J.some(ye), Ce = xe(a || Se || !!_ || y.length > 0), we = u.useRef(null), Te = u.useRef([]), Ee = u.useRef(""), De = u.useRef(null);
|
|
279
|
+
u.useEffect(() => {
|
|
280
|
+
we.current = _?.element ?? h?.element ?? null;
|
|
281
|
+
}, [h, _]), u.useEffect(() => {
|
|
282
|
+
Te.current = y;
|
|
283
|
+
}, [y]), u.useEffect(() => {
|
|
284
|
+
Ee.current = T;
|
|
285
|
+
}, [T]), u.useEffect(() => {
|
|
286
|
+
De.current = D;
|
|
287
|
+
}, [D]);
|
|
288
|
+
let Oe = u.useMemo(() => be(J), [J, Ce]);
|
|
289
|
+
u.useEffect(() => {
|
|
290
|
+
let e = M.current;
|
|
291
|
+
(e && (r.currentUser?.id !== e.userId || (r.activeBranch ?? null) !== e.branch || q !== e.page || !e.submitting && r.activeTool === null || r.activeTool !== null && r.activeTool !== "select") || !a && !A) && (M.current = null, g(null), v(null), b([]), w(null), E(""), O((e) => (G(e?.previewUrl), null)), j(!1), R(null), S(null), Q.current = null, $.current = !1);
|
|
292
|
+
}, [
|
|
293
|
+
a,
|
|
294
|
+
A,
|
|
295
|
+
r.activeTool,
|
|
296
|
+
r.activeBranch,
|
|
297
|
+
r.currentUser?.id,
|
|
298
|
+
q
|
|
299
|
+
]), u.useEffect(() => () => {
|
|
300
|
+
M.current = null, G(De.current?.previewUrl);
|
|
301
|
+
}, []), u.useEffect(() => {
|
|
293
302
|
if (!a) return;
|
|
294
303
|
let e = document.body.style.cursor;
|
|
295
304
|
document.body.style.cursor = "crosshair";
|
|
296
|
-
let t =
|
|
305
|
+
let t = oe();
|
|
297
306
|
return () => {
|
|
298
307
|
document.body.style.cursor = e, t();
|
|
299
308
|
};
|
|
300
309
|
}, [a]);
|
|
301
|
-
let
|
|
302
|
-
|
|
303
|
-
if (!
|
|
310
|
+
let Y = a && !!_;
|
|
311
|
+
u.useEffect(() => {
|
|
312
|
+
if (!Y) return;
|
|
304
313
|
let e = k();
|
|
305
|
-
return e instanceof HTMLElement && !
|
|
306
|
-
let e =
|
|
307
|
-
|
|
314
|
+
return e instanceof HTMLElement && !z.current?.contains(e) && (W.current = e), z.current?.querySelector("[data-ck-composer-input]")?.focus({ preventScroll: !0 }), () => {
|
|
315
|
+
let e = W.current;
|
|
316
|
+
W.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
|
|
308
317
|
};
|
|
309
|
-
}, [
|
|
310
|
-
let
|
|
311
|
-
|
|
312
|
-
let e = !
|
|
313
|
-
if (
|
|
314
|
-
let t =
|
|
318
|
+
}, [Y]);
|
|
319
|
+
let ke = u.useRef(r.isAuthenticated);
|
|
320
|
+
u.useEffect(() => {
|
|
321
|
+
let e = !ke.current && r.isAuthenticated;
|
|
322
|
+
if (ke.current = r.isAuthenticated, !e || !Y || !T.trim()) return;
|
|
323
|
+
let t = z.current?.querySelector("[data-ck-composer-input]");
|
|
315
324
|
t?.focus({ preventScroll: !0 });
|
|
316
325
|
let n = t?.value.length ?? 0;
|
|
317
|
-
t?.setSelectionRange?.(n, n),
|
|
326
|
+
t?.setSelectionRange?.(n, n), R((e) => e && e.startsWith("Sign in to save comments") ? null : e);
|
|
318
327
|
}, [
|
|
319
328
|
r.isAuthenticated,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
]),
|
|
323
|
-
if (!
|
|
324
|
-
let e =
|
|
329
|
+
Y,
|
|
330
|
+
T
|
|
331
|
+
]), u.useLayoutEffect(() => {
|
|
332
|
+
if (!Y) return;
|
|
333
|
+
let e = z.current;
|
|
325
334
|
if (!e) return;
|
|
326
335
|
let t = () => {
|
|
327
336
|
let t = e.getBoundingClientRect().height;
|
|
328
|
-
t > 0 &&
|
|
337
|
+
t > 0 && _e((e) => Math.abs(e - t) > 1 ? t : e);
|
|
329
338
|
};
|
|
330
339
|
t();
|
|
331
340
|
let n = null;
|
|
@@ -336,19 +345,19 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
336
345
|
}
|
|
337
346
|
return () => n?.disconnect();
|
|
338
347
|
}, [
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
]),
|
|
348
|
+
Y,
|
|
349
|
+
D,
|
|
350
|
+
L
|
|
351
|
+
]), u.useEffect(() => {
|
|
343
352
|
if (!a) return;
|
|
344
353
|
let e = () => {
|
|
345
|
-
|
|
354
|
+
v((e) => e && {
|
|
346
355
|
...e,
|
|
347
356
|
rect: B(e.element)
|
|
348
|
-
}),
|
|
357
|
+
}), g((e) => e && {
|
|
349
358
|
...e,
|
|
350
359
|
rect: B(e.element)
|
|
351
|
-
}),
|
|
360
|
+
}), b((e) => e.map((e) => ({
|
|
352
361
|
...e,
|
|
353
362
|
rect: B(e.element)
|
|
354
363
|
})));
|
|
@@ -357,9 +366,9 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
357
366
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
358
367
|
};
|
|
359
368
|
}, [a]);
|
|
360
|
-
let
|
|
361
|
-
if (!e ||
|
|
362
|
-
|
|
369
|
+
let X = u.useCallback(async (e, t, r) => {
|
|
370
|
+
if (!e || P) return !1;
|
|
371
|
+
I(!0), R(null);
|
|
363
372
|
try {
|
|
364
373
|
let i = t?.trim(), a = r ? [{
|
|
365
374
|
name: r.name,
|
|
@@ -372,41 +381,41 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
372
381
|
...i ? { comment: i } : {},
|
|
373
382
|
...a.length > 0 ? { attachments: a } : {}
|
|
374
383
|
} : void 0, s = o ? await n.grabElement(e, o) : await n.grabElement(e);
|
|
375
|
-
return
|
|
384
|
+
return I(!1), s ? (v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (R("Could not grab this element."), !1);
|
|
376
385
|
} catch {
|
|
377
|
-
return
|
|
386
|
+
return I(!1), R("Could not copy this element for the agent."), !1;
|
|
378
387
|
}
|
|
379
|
-
}, [n,
|
|
380
|
-
if (e.length === 0 ||
|
|
381
|
-
|
|
388
|
+
}, [n, P]), Z = u.useCallback(async (e) => {
|
|
389
|
+
if (e.length === 0 || P) return !1;
|
|
390
|
+
I(!0), R(null);
|
|
382
391
|
try {
|
|
383
392
|
let t = await n.grabElements(e);
|
|
384
|
-
return
|
|
393
|
+
return I(!1), t ? (b([]), v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), n.setTool(null), !0) : (R("Could not grab these elements."), !1);
|
|
385
394
|
} catch {
|
|
386
|
-
return
|
|
395
|
+
return I(!1), R("Could not copy these elements for the agent."), !1;
|
|
387
396
|
}
|
|
388
|
-
}, [n,
|
|
389
|
-
let e =
|
|
390
|
-
|
|
391
|
-
}, [
|
|
392
|
-
|
|
393
|
-
}, []),
|
|
394
|
-
|
|
395
|
-
let
|
|
396
|
-
|
|
397
|
-
if (!
|
|
397
|
+
}, [n, P]), Ae = u.useCallback(() => {
|
|
398
|
+
let e = Te.current.map((e) => e.element);
|
|
399
|
+
Z(e);
|
|
400
|
+
}, [Z]), je = u.useCallback(() => {
|
|
401
|
+
b([]);
|
|
402
|
+
}, []), Q = u.useRef(null), $ = u.useRef(!1), Me = u.useRef(null);
|
|
403
|
+
Me.current = x;
|
|
404
|
+
let Ne = u.useRef(null);
|
|
405
|
+
Ne.current = C, u.useEffect(() => {
|
|
406
|
+
if (!C) return;
|
|
398
407
|
let e = n.blockEscape();
|
|
399
408
|
return () => e();
|
|
400
|
-
}, [
|
|
401
|
-
if (!
|
|
409
|
+
}, [C, n]), u.useEffect(() => {
|
|
410
|
+
if (!C) return;
|
|
402
411
|
let e = k();
|
|
403
|
-
return e instanceof HTMLElement && !
|
|
404
|
-
let e =
|
|
405
|
-
|
|
412
|
+
return e instanceof HTMLElement && !U.current?.contains(e) && (W.current = e), U.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: !0 }), () => {
|
|
413
|
+
let e = W.current;
|
|
414
|
+
W.current = null, e && e.isConnected && e.focus({ preventScroll: !0 });
|
|
406
415
|
};
|
|
407
|
-
}, [
|
|
408
|
-
let
|
|
409
|
-
let t =
|
|
416
|
+
}, [C]);
|
|
417
|
+
let Pe = u.useCallback((e) => {
|
|
418
|
+
let t = U.current;
|
|
410
419
|
if (!t) return;
|
|
411
420
|
let n = Array.from(t.querySelectorAll("[role=\"menuitem\"]"));
|
|
412
421
|
if (n.length === 0) return;
|
|
@@ -430,17 +439,17 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
430
439
|
case " ": e.preventDefault(), e.stopPropagation(), k()?.click();
|
|
431
440
|
}
|
|
432
441
|
}, []);
|
|
433
|
-
|
|
434
|
-
if (!a) return;
|
|
442
|
+
u.useEffect(() => {
|
|
443
|
+
if (!a && !A) return;
|
|
435
444
|
let r = (e) => {
|
|
436
|
-
e.button !== 0 || N(e) ||
|
|
445
|
+
e.button !== 0 || N(e) || _ || (w(null), Q.current = {
|
|
437
446
|
x: e.clientX,
|
|
438
447
|
y: e.clientY
|
|
439
|
-
},
|
|
448
|
+
}, $.current = !1);
|
|
440
449
|
}, i = (n) => {
|
|
441
450
|
if (N(n)) return;
|
|
442
451
|
let r = F(n.clientX, n.clientY);
|
|
443
|
-
r && (n.preventDefault(), n.stopPropagation(),
|
|
452
|
+
r && (n.preventDefault(), n.stopPropagation(), w({
|
|
444
453
|
element: r,
|
|
445
454
|
selector: t(r),
|
|
446
455
|
xpath: e(r),
|
|
@@ -459,7 +468,7 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
459
468
|
y: r.clientY,
|
|
460
469
|
element: i
|
|
461
470
|
}, o = setTimeout(() => {
|
|
462
|
-
s && (
|
|
471
|
+
s && (w({
|
|
463
472
|
element: s.element,
|
|
464
473
|
selector: t(s.element),
|
|
465
474
|
xpath: e(s.element),
|
|
@@ -475,87 +484,87 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
475
484
|
(Math.abs(n) > 10 || Math.abs(r) > 10) && c();
|
|
476
485
|
}, l = () => {
|
|
477
486
|
c();
|
|
478
|
-
},
|
|
487
|
+
}, ne = (e) => {
|
|
479
488
|
if (N(e)) return;
|
|
480
|
-
let t =
|
|
489
|
+
let t = Q.current;
|
|
481
490
|
if (t) {
|
|
482
|
-
if (e.pointerType === "mouse" && !(e.buttons & 1))
|
|
491
|
+
if (e.pointerType === "mouse" && !(e.buttons & 1)) Q.current = null, $.current = !1, S(null);
|
|
483
492
|
else {
|
|
484
493
|
let n = e.clientX - t.x, r = e.clientY - t.y;
|
|
485
|
-
if (
|
|
486
|
-
|
|
494
|
+
if (Me.current || Math.abs(n) > 6 || Math.abs(r) > 6) {
|
|
495
|
+
$.current = !0, S({
|
|
487
496
|
startX: t.x,
|
|
488
497
|
startY: t.y,
|
|
489
498
|
x: e.clientX,
|
|
490
499
|
y: e.clientY
|
|
491
|
-
}),
|
|
500
|
+
}), g(null);
|
|
492
501
|
return;
|
|
493
502
|
}
|
|
494
503
|
}
|
|
495
504
|
}
|
|
496
|
-
if (
|
|
505
|
+
if (_) return;
|
|
497
506
|
let n = F(e.clientX, e.clientY);
|
|
498
|
-
|
|
499
|
-
},
|
|
500
|
-
|
|
501
|
-
},
|
|
502
|
-
let t =
|
|
503
|
-
|
|
504
|
-
let n =
|
|
507
|
+
g(n ? H(n) : null);
|
|
508
|
+
}, u = () => {
|
|
509
|
+
Q.current = null, $.current = !1, S(null);
|
|
510
|
+
}, d = (e) => {
|
|
511
|
+
let t = Q.current;
|
|
512
|
+
Q.current = null;
|
|
513
|
+
let n = Me.current;
|
|
505
514
|
if (!t || !n) return;
|
|
506
|
-
let r =
|
|
515
|
+
let r = le({
|
|
507
516
|
...n,
|
|
508
517
|
x: e.clientX,
|
|
509
518
|
y: e.clientY
|
|
510
519
|
});
|
|
511
520
|
if (r.width < 6 || r.height < 6) {
|
|
512
|
-
|
|
521
|
+
S(null);
|
|
513
522
|
return;
|
|
514
523
|
}
|
|
515
|
-
let i =
|
|
524
|
+
let i = ue(r);
|
|
516
525
|
if (i.length > 0) {
|
|
517
|
-
let e = i.map(
|
|
518
|
-
|
|
526
|
+
let e = i.map(H);
|
|
527
|
+
b((t) => {
|
|
519
528
|
let n = new Set(t.map((e) => e.element)), r = [...t];
|
|
520
529
|
for (let t of e) n.has(t.element) || r.push(t);
|
|
521
530
|
return r;
|
|
522
531
|
});
|
|
523
532
|
}
|
|
524
|
-
|
|
525
|
-
},
|
|
526
|
-
if (N(e)) return;
|
|
527
|
-
if (
|
|
528
|
-
|
|
533
|
+
S(null);
|
|
534
|
+
}, f = (e) => {
|
|
535
|
+
if (N(e) || A) return;
|
|
536
|
+
if ($.current) {
|
|
537
|
+
$.current = !1, e.preventDefault(), e.stopPropagation();
|
|
529
538
|
return;
|
|
530
539
|
}
|
|
531
540
|
e.preventDefault(), e.stopPropagation();
|
|
532
541
|
let t = F(e.clientX, e.clientY);
|
|
533
|
-
|
|
534
|
-
},
|
|
542
|
+
_ && !e.shiftKey ? (v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null)) : t && (e.shiftKey ? (b((e) => e.some((e) => e.element === t) ? e.filter((e) => e.element !== t) : [..._ && !e.some((e) => e.element === _.element) ? [...e, _] : e, H(t)]), g(null), v(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null)) : (v(H(t)), g(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null)));
|
|
543
|
+
}, p = (e) => {
|
|
535
544
|
if (e.key === "Escape") {
|
|
536
545
|
if (e.isComposing) return;
|
|
537
|
-
if (
|
|
538
|
-
e.preventDefault(), e.stopPropagation(),
|
|
546
|
+
if (Ne.current) {
|
|
547
|
+
e.preventDefault(), e.stopPropagation(), w(null);
|
|
539
548
|
return;
|
|
540
549
|
}
|
|
541
|
-
e.preventDefault(), e.stopPropagation(),
|
|
550
|
+
e.preventDefault(), e.stopPropagation(), M.current = null, j(!1), v(null), g(null), E(""), O((e) => (G(e?.previewUrl), null)), R(null), n.setTool(null);
|
|
542
551
|
return;
|
|
543
552
|
}
|
|
544
|
-
if (!e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" ||
|
|
553
|
+
if (A || !e.metaKey && !e.ctrlKey || e.shiftKey || e.altKey || e.key !== "c" && e.key !== "C" && e.code !== "KeyC" || ce(e)) return;
|
|
545
554
|
let t = typeof window < "u" ? window.getSelection() : null;
|
|
546
555
|
if (t && !t.isCollapsed && t.toString().length > 0) return;
|
|
547
|
-
let r =
|
|
556
|
+
let r = Te.current;
|
|
548
557
|
if (r.length > 0) {
|
|
549
|
-
e.preventDefault(), e.stopPropagation(),
|
|
558
|
+
e.preventDefault(), e.stopPropagation(), Z(r.map((e) => e.element));
|
|
550
559
|
return;
|
|
551
560
|
}
|
|
552
|
-
let i =
|
|
561
|
+
let i = we.current;
|
|
553
562
|
if (!i) return;
|
|
554
563
|
e.preventDefault(), e.stopPropagation();
|
|
555
|
-
let a =
|
|
556
|
-
|
|
564
|
+
let a = _?.element === i;
|
|
565
|
+
X(i, a ? Ee.current : void 0, a ? De.current : null);
|
|
557
566
|
};
|
|
558
|
-
return document.addEventListener("pointerdown", r, !0), document.addEventListener("pointermove",
|
|
567
|
+
return document.addEventListener("pointerdown", r, !0), document.addEventListener("pointermove", ne, !0), document.addEventListener("pointerup", d, !0), document.addEventListener("pointercancel", u, !0), document.addEventListener("click", f, !0), document.addEventListener("contextmenu", i, !0), document.addEventListener("touchstart", ee, {
|
|
559
568
|
capture: !0,
|
|
560
569
|
passive: !0
|
|
561
570
|
}), document.addEventListener("touchmove", te, {
|
|
@@ -567,292 +576,322 @@ var xe = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
567
576
|
}), document.addEventListener("touchcancel", l, {
|
|
568
577
|
capture: !0,
|
|
569
578
|
passive: !0
|
|
570
|
-
}), window.addEventListener("keydown",
|
|
571
|
-
document.removeEventListener("pointerdown", r, !0), document.removeEventListener("pointermove",
|
|
579
|
+
}), window.addEventListener("keydown", p, !0), () => {
|
|
580
|
+
document.removeEventListener("pointerdown", r, !0), document.removeEventListener("pointermove", ne, !0), document.removeEventListener("pointerup", d, !0), document.removeEventListener("pointercancel", u, !0), document.removeEventListener("click", f, !0), document.removeEventListener("contextmenu", i, !0), document.removeEventListener("touchstart", ee, !0), document.removeEventListener("touchmove", te, !0), document.removeEventListener("touchend", l, !0), document.removeEventListener("touchcancel", l, !0), window.removeEventListener("keydown", p, !0), c();
|
|
572
581
|
};
|
|
573
582
|
}, [
|
|
574
583
|
a,
|
|
584
|
+
A,
|
|
575
585
|
n,
|
|
576
|
-
Y,
|
|
577
586
|
X,
|
|
578
|
-
|
|
587
|
+
Z,
|
|
588
|
+
_
|
|
579
589
|
]);
|
|
580
|
-
let
|
|
590
|
+
let Fe = u.useCallback(async (e) => {
|
|
581
591
|
e.preventDefault();
|
|
582
|
-
let t =
|
|
583
|
-
if (
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
592
|
+
let t = T.trim();
|
|
593
|
+
if (!_ || !t || A) return;
|
|
594
|
+
if (!r.currentUser) {
|
|
595
|
+
R("Sign in to save comments. You can still use Grab for agent without signing in."), n.toggleLoginModal();
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
let a = {
|
|
599
|
+
userId: r.currentUser.id,
|
|
600
|
+
branch: r.activeBranch ?? null,
|
|
601
|
+
page: q,
|
|
602
|
+
submitting: !1
|
|
603
|
+
};
|
|
604
|
+
M.current = a;
|
|
605
|
+
let o = () => {
|
|
606
|
+
let e = n.getState();
|
|
607
|
+
return M.current === a && e.isAuthenticated && e.currentUser?.id === a.userId && (e.activeBranch ?? null) === a.branch && (e.activeTool === null || e.activeTool === "select") && i().path === a.page;
|
|
608
|
+
}, s = n.on("auth:logout", () => {
|
|
609
|
+
M.current === a && (M.current = null, j(!1));
|
|
610
|
+
});
|
|
611
|
+
j(!0), R(null);
|
|
612
|
+
try {
|
|
613
|
+
let e = await c(n, t, de(_), { files: D ? [D.file] : [] }, () => !o() || n.getState().activeTool !== "select" ? !1 : (a.submitting = !0, !0));
|
|
614
|
+
if (!o()) return;
|
|
615
|
+
if (e.status === "failed") throw Error(e.message);
|
|
616
|
+
v(null), E(""), O((e) => (G(e?.previewUrl), null)), n.setTool(null);
|
|
617
|
+
} catch {
|
|
618
|
+
if (!o()) return;
|
|
619
|
+
n.getState().activeTool === null && n.setTool("select"), R("Could not save this comment. Try again.");
|
|
620
|
+
} finally {
|
|
621
|
+
s(), M.current === a && (M.current = null, j(!1));
|
|
593
622
|
}
|
|
594
623
|
}, [
|
|
595
|
-
C,
|
|
596
|
-
n,
|
|
597
624
|
D,
|
|
598
|
-
|
|
625
|
+
T,
|
|
626
|
+
n,
|
|
627
|
+
q,
|
|
628
|
+
A,
|
|
629
|
+
_,
|
|
630
|
+
r.activeBranch,
|
|
599
631
|
r.currentUser
|
|
600
|
-
]),
|
|
601
|
-
|
|
632
|
+
]), Ie = u.useCallback(() => {
|
|
633
|
+
X(_?.element ?? null, T, D);
|
|
602
634
|
}, [
|
|
635
|
+
D,
|
|
603
636
|
T,
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}, []), Ne = l.useCallback((e) => {
|
|
637
|
+
X,
|
|
638
|
+
_
|
|
639
|
+
]), Le = u.useCallback(() => {
|
|
640
|
+
V.current?.click();
|
|
641
|
+
}, []), Re = u.useCallback((e) => {
|
|
610
642
|
let t = e.currentTarget, n = t.files?.[0] ?? null;
|
|
611
|
-
|
|
612
|
-
}, []),
|
|
613
|
-
|
|
614
|
-
}, []),
|
|
615
|
-
return !a &&
|
|
643
|
+
O((e) => (G(e?.previewUrl), n ? me(n, t) : null)), t.value = "";
|
|
644
|
+
}, []), ze = u.useCallback(() => {
|
|
645
|
+
O((e) => (G(e?.previewUrl), null));
|
|
646
|
+
}, []), Be = u.useMemo(() => ne(), []);
|
|
647
|
+
return !a && !A && Oe.length === 0 ? null : /* @__PURE__ */ p("div", {
|
|
616
648
|
className: "ck-element-selector",
|
|
617
649
|
"data-testid": "ck-element-selector",
|
|
618
650
|
children: [
|
|
619
|
-
|
|
651
|
+
Oe.map((e) => /* @__PURE__ */ f("div", {
|
|
620
652
|
"aria-hidden": "true",
|
|
621
653
|
className: "ck-element-selector-mark",
|
|
622
654
|
"data-comment-id": e.id,
|
|
623
655
|
style: K(e.rect)
|
|
624
656
|
}, e.id)),
|
|
625
|
-
a &&
|
|
657
|
+
a && h && !x && /* @__PURE__ */ f("div", {
|
|
626
658
|
"aria-hidden": "true",
|
|
627
659
|
className: "ck-element-selector-outline",
|
|
628
660
|
"data-state": "hover",
|
|
629
|
-
style: K(
|
|
661
|
+
style: K(h.rect)
|
|
630
662
|
}),
|
|
631
|
-
a &&
|
|
663
|
+
a && x && /* @__PURE__ */ f("div", {
|
|
632
664
|
"aria-hidden": "true",
|
|
633
665
|
className: "ck-element-selector-marquee",
|
|
634
666
|
"data-testid": "ck-element-selector-marquee",
|
|
635
667
|
style: {
|
|
636
|
-
left: Math.min(
|
|
637
|
-
top: Math.min(
|
|
638
|
-
width: Math.abs(
|
|
639
|
-
height: Math.abs(
|
|
668
|
+
left: Math.min(x.startX, x.x),
|
|
669
|
+
top: Math.min(x.startY, x.y),
|
|
670
|
+
width: Math.abs(x.x - x.startX),
|
|
671
|
+
height: Math.abs(x.y - x.startY)
|
|
640
672
|
}
|
|
641
673
|
}),
|
|
642
|
-
a &&
|
|
674
|
+
a && y.map((e, t) => /* @__PURE__ */ f("div", {
|
|
643
675
|
"aria-hidden": "true",
|
|
644
676
|
className: "ck-element-selector-outline",
|
|
645
677
|
"data-state": "multi",
|
|
646
678
|
"data-multi-index": t + 1,
|
|
647
679
|
style: K(e.rect)
|
|
648
680
|
}, `multi-${t}-${e.selector}-${e.xpath}`)),
|
|
649
|
-
a &&
|
|
650
|
-
ref:
|
|
681
|
+
a && C && /* @__PURE__ */ p("ul", {
|
|
682
|
+
ref: U,
|
|
651
683
|
className: "ck-element-selector-context-menu",
|
|
652
684
|
"data-testid": "ck-element-selector-context-menu",
|
|
653
685
|
role: "menu",
|
|
654
686
|
"aria-label": "Element actions",
|
|
655
|
-
onKeyDown:
|
|
656
|
-
style:
|
|
687
|
+
onKeyDown: Pe,
|
|
688
|
+
style: ve(C),
|
|
657
689
|
children: [
|
|
658
|
-
/* @__PURE__ */
|
|
690
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
659
691
|
type: "button",
|
|
660
692
|
role: "menuitem",
|
|
661
693
|
"data-testid": "ck-context-menu-grab",
|
|
662
694
|
onClick: () => {
|
|
663
|
-
let e =
|
|
664
|
-
|
|
695
|
+
let e = C.element;
|
|
696
|
+
w(null), X(e);
|
|
665
697
|
},
|
|
666
698
|
children: "Grab for agent"
|
|
667
699
|
}) }),
|
|
668
|
-
/* @__PURE__ */
|
|
700
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
669
701
|
type: "button",
|
|
670
702
|
role: "menuitem",
|
|
671
703
|
"data-testid": "ck-context-menu-comment",
|
|
704
|
+
disabled: !m,
|
|
672
705
|
onClick: () => {
|
|
673
|
-
let e =
|
|
674
|
-
|
|
706
|
+
let e = H(C.element);
|
|
707
|
+
w(null), v(e);
|
|
675
708
|
},
|
|
676
709
|
children: "Add comment"
|
|
677
710
|
}) }),
|
|
678
|
-
/* @__PURE__ */
|
|
711
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
679
712
|
type: "button",
|
|
680
713
|
role: "menuitem",
|
|
681
714
|
"data-testid": "ck-context-menu-copy-selector",
|
|
682
715
|
onClick: () => {
|
|
683
|
-
let e =
|
|
684
|
-
|
|
716
|
+
let e = C.selector;
|
|
717
|
+
w(null), he(e, "CSS selector");
|
|
685
718
|
},
|
|
686
719
|
children: "Copy CSS selector"
|
|
687
720
|
}) }),
|
|
688
|
-
/* @__PURE__ */
|
|
721
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
689
722
|
type: "button",
|
|
690
723
|
role: "menuitem",
|
|
691
724
|
"data-testid": "ck-context-menu-copy-xpath",
|
|
692
725
|
onClick: () => {
|
|
693
|
-
let e =
|
|
694
|
-
|
|
726
|
+
let e = C.xpath;
|
|
727
|
+
w(null), he(e, "XPath");
|
|
695
728
|
},
|
|
696
729
|
children: "Copy XPath"
|
|
697
730
|
}) }),
|
|
698
|
-
/* @__PURE__ */
|
|
731
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
699
732
|
type: "button",
|
|
700
733
|
role: "menuitem",
|
|
701
734
|
"data-testid": "ck-context-menu-inspect",
|
|
702
735
|
onClick: () => {
|
|
703
|
-
console.log("[CommentKit] inspect",
|
|
736
|
+
console.log("[CommentKit] inspect", C.element), w(null);
|
|
704
737
|
},
|
|
705
738
|
children: "Inspect (log to console)"
|
|
706
739
|
}) })
|
|
707
740
|
]
|
|
708
741
|
}),
|
|
709
|
-
a &&
|
|
742
|
+
a && y.length > 0 && /* @__PURE__ */ p("div", {
|
|
710
743
|
className: "ck-element-selector-multibar",
|
|
711
744
|
"data-testid": "ck-element-selector-multibar",
|
|
712
745
|
children: [
|
|
713
|
-
/* @__PURE__ */
|
|
746
|
+
/* @__PURE__ */ p("span", {
|
|
714
747
|
className: "ck-element-selector-multibar-count",
|
|
715
|
-
children: [
|
|
748
|
+
children: [y.length, " selected"]
|
|
716
749
|
}),
|
|
717
|
-
/* @__PURE__ */
|
|
750
|
+
/* @__PURE__ */ f(o, {
|
|
718
751
|
type: "button",
|
|
719
752
|
size: "sm",
|
|
720
|
-
onClick:
|
|
721
|
-
disabled:
|
|
753
|
+
onClick: Ae,
|
|
754
|
+
disabled: P,
|
|
722
755
|
"data-testid": "ck-element-grab-many-button",
|
|
723
|
-
children:
|
|
756
|
+
children: P ? "Grabbing…" : `Grab ${y.length} for agent`
|
|
724
757
|
}),
|
|
725
|
-
/* @__PURE__ */
|
|
758
|
+
/* @__PURE__ */ f(o, {
|
|
726
759
|
type: "button",
|
|
727
760
|
size: "sm",
|
|
728
761
|
variant: "ghost",
|
|
729
|
-
onClick:
|
|
730
|
-
disabled:
|
|
762
|
+
onClick: je,
|
|
763
|
+
disabled: P,
|
|
731
764
|
"data-testid": "ck-element-grab-clear-button",
|
|
732
765
|
children: "Clear"
|
|
733
766
|
})
|
|
734
767
|
]
|
|
735
768
|
}),
|
|
736
|
-
a &&
|
|
769
|
+
(a || A) && _ && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
|
|
737
770
|
"aria-hidden": "true",
|
|
738
771
|
className: "ck-element-selector-outline",
|
|
739
772
|
"data-state": "selected",
|
|
740
|
-
style: K(
|
|
741
|
-
}), /* @__PURE__ */
|
|
742
|
-
ref:
|
|
773
|
+
style: K(_.rect)
|
|
774
|
+
}), /* @__PURE__ */ p("form", {
|
|
775
|
+
ref: z,
|
|
743
776
|
className: "ck-element-selector-composer",
|
|
744
|
-
style:
|
|
745
|
-
onSubmit:
|
|
777
|
+
style: ge(_.rect, pe),
|
|
778
|
+
onSubmit: Fe,
|
|
746
779
|
children: [
|
|
747
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ f("div", {
|
|
748
781
|
className: "ck-element-selector-input-row",
|
|
749
|
-
children: /* @__PURE__ */
|
|
782
|
+
children: /* @__PURE__ */ f(te, {
|
|
750
783
|
"data-ck-composer-input": "",
|
|
751
784
|
"aria-label": "Element comment",
|
|
752
|
-
value:
|
|
785
|
+
value: T,
|
|
753
786
|
placeholder: "Add comment",
|
|
754
|
-
disabled:
|
|
787
|
+
disabled: A || P,
|
|
755
788
|
onChange: (e) => {
|
|
756
|
-
|
|
789
|
+
E(e.currentTarget.value), L && R(null);
|
|
757
790
|
}
|
|
758
791
|
})
|
|
759
792
|
}),
|
|
760
|
-
!s && /* @__PURE__ */
|
|
761
|
-
ref:
|
|
793
|
+
!s && /* @__PURE__ */ f("input", {
|
|
794
|
+
ref: V,
|
|
762
795
|
"aria-label": "Attach file",
|
|
763
796
|
className: "ck-element-selector-file-input",
|
|
764
797
|
type: "file",
|
|
765
|
-
|
|
798
|
+
disabled: A || P,
|
|
799
|
+
onChange: Re
|
|
766
800
|
}),
|
|
767
|
-
|
|
801
|
+
D && /* @__PURE__ */ p("div", {
|
|
768
802
|
className: "ck-element-selector-attachment",
|
|
769
803
|
"data-testid": "ck-element-attachment-preview",
|
|
770
804
|
children: [
|
|
771
|
-
|
|
805
|
+
D.previewUrl && /* @__PURE__ */ f("img", {
|
|
772
806
|
alt: "",
|
|
773
807
|
"aria-hidden": "true",
|
|
774
808
|
className: "ck-element-selector-attachment-image",
|
|
775
|
-
src:
|
|
809
|
+
src: D.previewUrl
|
|
776
810
|
}),
|
|
777
|
-
/* @__PURE__ */
|
|
811
|
+
/* @__PURE__ */ p("div", {
|
|
778
812
|
className: "ck-element-selector-attachment-meta",
|
|
779
813
|
children: [
|
|
780
|
-
/* @__PURE__ */
|
|
814
|
+
/* @__PURE__ */ f("span", {
|
|
781
815
|
className: "ck-element-selector-attachment-name",
|
|
782
|
-
children:
|
|
816
|
+
children: D.name
|
|
783
817
|
}),
|
|
784
|
-
/* @__PURE__ */
|
|
818
|
+
/* @__PURE__ */ f("span", {
|
|
785
819
|
className: "ck-element-selector-attachment-path",
|
|
786
|
-
title:
|
|
787
|
-
children:
|
|
820
|
+
title: D.path,
|
|
821
|
+
children: D.path
|
|
788
822
|
}),
|
|
789
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ f("span", {
|
|
790
824
|
className: "ck-element-selector-attachment-size",
|
|
791
|
-
children:
|
|
825
|
+
children: fe(D.size)
|
|
792
826
|
})
|
|
793
827
|
]
|
|
794
828
|
}),
|
|
795
|
-
/* @__PURE__ */
|
|
829
|
+
/* @__PURE__ */ f(o, {
|
|
796
830
|
type: "button",
|
|
797
831
|
size: "icon-xs",
|
|
798
832
|
variant: "ghost",
|
|
799
833
|
"aria-label": "Remove attachment",
|
|
800
|
-
disabled:
|
|
801
|
-
onClick:
|
|
802
|
-
children: /* @__PURE__ */
|
|
834
|
+
disabled: A || P,
|
|
835
|
+
onClick: ze,
|
|
836
|
+
children: /* @__PURE__ */ f(ie, {
|
|
803
837
|
className: "ck-element-selector-action-icon",
|
|
804
838
|
"aria-hidden": "true"
|
|
805
839
|
})
|
|
806
840
|
})
|
|
807
841
|
]
|
|
808
842
|
}),
|
|
809
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ p("div", {
|
|
810
844
|
className: "ck-element-selector-actions",
|
|
811
845
|
children: [
|
|
812
|
-
!s && /* @__PURE__ */
|
|
846
|
+
!s && /* @__PURE__ */ p(o, {
|
|
813
847
|
type: "button",
|
|
814
848
|
variant: "outline",
|
|
815
849
|
className: "ck-element-selector-attach-action",
|
|
816
|
-
disabled:
|
|
817
|
-
onClick:
|
|
850
|
+
disabled: A || P,
|
|
851
|
+
onClick: Le,
|
|
818
852
|
"data-testid": "ck-element-attach-button",
|
|
819
|
-
children: [/* @__PURE__ */
|
|
853
|
+
children: [/* @__PURE__ */ f(re, {
|
|
820
854
|
className: "ck-element-selector-action-icon",
|
|
821
855
|
"aria-hidden": "true"
|
|
822
|
-
}), /* @__PURE__ */
|
|
856
|
+
}), /* @__PURE__ */ f("span", { children: "Attach" })]
|
|
823
857
|
}),
|
|
824
|
-
/* @__PURE__ */
|
|
858
|
+
/* @__PURE__ */ f(o, {
|
|
825
859
|
type: "submit",
|
|
826
860
|
className: "ck-element-selector-save-action",
|
|
827
|
-
disabled: !
|
|
828
|
-
children:
|
|
861
|
+
disabled: !m || !T.trim() || A || P,
|
|
862
|
+
children: A ? "Saving" : "Save"
|
|
829
863
|
}),
|
|
830
|
-
/* @__PURE__ */
|
|
864
|
+
/* @__PURE__ */ f(o, {
|
|
831
865
|
type: "button",
|
|
832
866
|
className: "ck-element-selector-grab-action",
|
|
833
|
-
variant:
|
|
834
|
-
disabled:
|
|
835
|
-
onClick:
|
|
867
|
+
variant: Be ? "default" : "outline",
|
|
868
|
+
disabled: A || P,
|
|
869
|
+
onClick: Ie,
|
|
836
870
|
title: s ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
|
|
837
871
|
"data-testid": "ck-element-grab-button",
|
|
838
|
-
children:
|
|
872
|
+
children: P ? "Grabbing…" : "Grab for agent"
|
|
839
873
|
})
|
|
840
874
|
]
|
|
841
875
|
}),
|
|
842
|
-
|
|
876
|
+
!m && /* @__PURE__ */ f("p", {
|
|
877
|
+
role: "status",
|
|
878
|
+
className: "ck-element-selector-error",
|
|
879
|
+
children: ae
|
|
880
|
+
}),
|
|
881
|
+
L && /* @__PURE__ */ f("p", {
|
|
843
882
|
className: "ck-element-selector-error",
|
|
844
883
|
role: "alert",
|
|
845
|
-
children:
|
|
884
|
+
children: L
|
|
846
885
|
})
|
|
847
886
|
]
|
|
848
887
|
})] })
|
|
849
888
|
]
|
|
850
889
|
});
|
|
851
890
|
});
|
|
852
|
-
function
|
|
853
|
-
return /* @__PURE__ */
|
|
891
|
+
function Se(e) {
|
|
892
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("style", {
|
|
854
893
|
"data-ck-tool-styles": "element-selector",
|
|
855
|
-
children:
|
|
856
|
-
}), /* @__PURE__ */
|
|
894
|
+
children: m
|
|
895
|
+
}), /* @__PURE__ */ f(J, { ...e })] });
|
|
857
896
|
}
|
|
858
|
-
export {
|
|
897
|
+
export { Se as ElementSelector };
|