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