@commentkit/comment-kit 0.6.9 → 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 +63 -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 +25 -13
- package/dist/demo.es.js +148 -70
- package/dist/headless.es.js +3 -3
- 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-cGC1p-SP.js +1093 -0
- package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
- package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
- package/dist/shared/{button-group-CHfMRXyA.js → button-group-CWdKaOlC.js} +14 -16
- package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
- package/dist/shared/comment-drawing-canvas-DdXlMgbF.js +124 -0
- package/dist/shared/comment-icon-Dg9ZWpz-.js +608 -0
- 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-D0kY00St.js → comment-kit-core-C862uNAm.js} +1371 -853
- package/dist/shared/comment-kit-ui-0vd-DY4S.js +19977 -0
- package/dist/shared/comment-screenshot-annotator-DcaSSuWB.js +151 -0
- package/dist/shared/comment-screenshot-overlay-D_nFoJmM.js +207 -0
- package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-pWBlhlse.js} +8 -8
- package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
- package/dist/shared/dist-De294MVF.js +623 -0
- package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-DC-_XJ0k.js} +350 -305
- package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
- package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui-B68j8r6I.js} +4 -4
- package/dist/shared/{pusher-BEl7Qn-8.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/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
- package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-CrO75sED.js} +1 -1
- package/dist/shared/styles-C9Jwvm0Q.js +2 -0
- package/dist/shared/useRender-D1z_X_BY.js +5 -0
- package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
- package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
- package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-CFak_YHy.js} +148 -89
- 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 +24 -18
- package/dist/types/core/comment-kit-core.d.ts +28 -11
- package/dist/types/core/local-demo.d.ts +1 -0
- package/dist/types/core/types.d.ts +103 -0
- package/dist/types/core/websocket-manager.d.ts +12 -0
- package/dist/types/core/write-access.d.ts +9 -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 +378 -0
- package/docs/local-demo.md +60 -0
- package/package.json +17 -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-image-lightbox-0VdAs2iT.js +0 -178
- 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/dev-grab-pDAfH2lr.js +0 -203
- package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
- package/dist/shared/realtime-BG_t_ze7.js +0 -281
- 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 {
|
|
6
|
-
import * as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
var
|
|
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 { 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
|
-
}]]),
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
}]]), ie = 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
|
+
}]]), 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
|
+
function y() {
|
|
19
|
+
if (_ || typeof document > "u") return;
|
|
14
20
|
let e = document.createElement("style");
|
|
15
|
-
e.setAttribute(
|
|
21
|
+
e.setAttribute(ae, ""), 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 oe() {
|
|
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, se = 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 ce(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]") || !V(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 le(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 ue(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 = V(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,7 +131,7 @@ function V(e) {
|
|
|
125
131
|
right: t.right
|
|
126
132
|
};
|
|
127
133
|
}
|
|
128
|
-
function
|
|
134
|
+
function V(e) {
|
|
129
135
|
return e.width > 0 && e.height > 0;
|
|
130
136
|
}
|
|
131
137
|
function H(n) {
|
|
@@ -133,7 +139,7 @@ function H(n) {
|
|
|
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
145
|
function U(e, t, n) {
|
|
@@ -145,7 +151,7 @@ function W() {
|
|
|
145
151
|
height: Math.max(window.innerHeight || 0, 16)
|
|
146
152
|
};
|
|
147
153
|
}
|
|
148
|
-
function
|
|
154
|
+
function de(e) {
|
|
149
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);
|
|
150
156
|
return {
|
|
151
157
|
...n(r, i, t),
|
|
@@ -153,10 +159,10 @@ function ce(e) {
|
|
|
153
159
|
xpath: e.xpath
|
|
154
160
|
};
|
|
155
161
|
}
|
|
156
|
-
function
|
|
162
|
+
function fe(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 pe(e, t) {
|
|
160
166
|
let n = e.path;
|
|
161
167
|
if (typeof n == "string" && n.trim()) return {
|
|
162
168
|
path: n.trim(),
|
|
@@ -175,9 +181,10 @@ function ue(e, t) {
|
|
|
175
181
|
pathSource: "browser-fallback"
|
|
176
182
|
};
|
|
177
183
|
}
|
|
178
|
-
function
|
|
179
|
-
let { path: n, pathSource: r } =
|
|
184
|
+
function me(e, t) {
|
|
185
|
+
let { path: n, pathSource: r } = pe(e, t);
|
|
180
186
|
return {
|
|
187
|
+
file: e,
|
|
181
188
|
name: e.name,
|
|
182
189
|
path: n,
|
|
183
190
|
pathSource: r,
|
|
@@ -190,16 +197,16 @@ function de(e, t) {
|
|
|
190
197
|
function G(e) {
|
|
191
198
|
e && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
192
199
|
}
|
|
193
|
-
async function
|
|
200
|
+
async function he(e, t) {
|
|
194
201
|
try {
|
|
195
202
|
if (!navigator.clipboard?.writeText) throw Error("clipboard unavailable");
|
|
196
203
|
await navigator.clipboard.writeText(e);
|
|
197
204
|
try {
|
|
198
|
-
|
|
205
|
+
a.success(`${t} copied`);
|
|
199
206
|
} catch {}
|
|
200
207
|
} catch {
|
|
201
208
|
try {
|
|
202
|
-
|
|
209
|
+
a.error(`Could not copy ${t.toLowerCase()}`);
|
|
203
210
|
} catch {}
|
|
204
211
|
}
|
|
205
212
|
}
|
|
@@ -211,39 +218,39 @@ function K(e) {
|
|
|
211
218
|
height: e.height
|
|
212
219
|
};
|
|
213
220
|
}
|
|
214
|
-
function
|
|
215
|
-
let n = W(), r = Math.max(
|
|
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;
|
|
216
223
|
return {
|
|
217
224
|
left: i,
|
|
218
|
-
top: a + t <= n.height -
|
|
225
|
+
top: a + t <= n.height - w ? a : U(o, w, n.height - t - w)
|
|
219
226
|
};
|
|
220
227
|
}
|
|
221
|
-
var
|
|
222
|
-
function
|
|
228
|
+
var _e = 220, q = 200;
|
|
229
|
+
function ve(e) {
|
|
223
230
|
let t = W();
|
|
224
231
|
return {
|
|
225
|
-
left: U(e.x,
|
|
226
|
-
top: U(e.y,
|
|
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))
|
|
227
234
|
};
|
|
228
235
|
}
|
|
229
|
-
function
|
|
236
|
+
function ye(e) {
|
|
230
237
|
return e.status === "open" && !!(e.position.element || e.position.xpath);
|
|
231
238
|
}
|
|
232
|
-
function
|
|
239
|
+
function be(e) {
|
|
233
240
|
return e.flatMap((e) => {
|
|
234
|
-
if (!
|
|
241
|
+
if (!ye(e)) return [];
|
|
235
242
|
let t = r(e.position.element ?? "", e.position.xpath);
|
|
236
243
|
if (!t) return [];
|
|
237
|
-
let n =
|
|
238
|
-
return
|
|
244
|
+
let n = B(t);
|
|
245
|
+
return j(t, n) ? [{
|
|
239
246
|
id: e.id,
|
|
240
247
|
rect: n
|
|
241
248
|
}] : [];
|
|
242
249
|
});
|
|
243
250
|
}
|
|
244
|
-
function
|
|
245
|
-
let [t, n] =
|
|
246
|
-
return
|
|
251
|
+
function xe(e) {
|
|
252
|
+
let [t, n] = u.useState(0);
|
|
253
|
+
return u.useEffect(() => {
|
|
247
254
|
if (!e) return;
|
|
248
255
|
let t = 0, r = () => {
|
|
249
256
|
t ||= window.requestAnimationFrame(() => {
|
|
@@ -267,59 +274,67 @@ function ve(e) {
|
|
|
267
274
|
};
|
|
268
275
|
}, [e]), t;
|
|
269
276
|
}
|
|
270
|
-
var
|
|
271
|
-
let
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}, [
|
|
275
|
-
|
|
276
|
-
}, [
|
|
277
|
-
|
|
278
|
-
}, [
|
|
279
|
-
|
|
280
|
-
}, [
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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(() => {
|
|
287
302
|
if (!a) return;
|
|
288
303
|
let e = document.body.style.cursor;
|
|
289
304
|
document.body.style.cursor = "crosshair";
|
|
290
|
-
let t =
|
|
305
|
+
let t = oe();
|
|
291
306
|
return () => {
|
|
292
307
|
document.body.style.cursor = e, t();
|
|
293
308
|
};
|
|
294
309
|
}, [a]);
|
|
295
|
-
let Y = a && !!
|
|
296
|
-
|
|
310
|
+
let Y = a && !!_;
|
|
311
|
+
u.useEffect(() => {
|
|
297
312
|
if (!Y) return;
|
|
298
|
-
let e =
|
|
299
|
-
return e instanceof HTMLElement && !
|
|
300
|
-
let e =
|
|
301
|
-
|
|
313
|
+
let e = k();
|
|
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 });
|
|
302
317
|
};
|
|
303
318
|
}, [Y]);
|
|
304
|
-
let
|
|
305
|
-
|
|
306
|
-
let e = !
|
|
307
|
-
if (
|
|
308
|
-
let t =
|
|
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]");
|
|
309
324
|
t?.focus({ preventScroll: !0 });
|
|
310
325
|
let n = t?.value.length ?? 0;
|
|
311
|
-
t?.setSelectionRange?.(n, n),
|
|
326
|
+
t?.setSelectionRange?.(n, n), R((e) => e && e.startsWith("Sign in to save comments") ? null : e);
|
|
312
327
|
}, [
|
|
313
328
|
r.isAuthenticated,
|
|
314
329
|
Y,
|
|
315
|
-
|
|
316
|
-
]),
|
|
330
|
+
T
|
|
331
|
+
]), u.useLayoutEffect(() => {
|
|
317
332
|
if (!Y) return;
|
|
318
|
-
let e =
|
|
333
|
+
let e = z.current;
|
|
319
334
|
if (!e) return;
|
|
320
335
|
let t = () => {
|
|
321
336
|
let t = e.getBoundingClientRect().height;
|
|
322
|
-
t > 0 &&
|
|
337
|
+
t > 0 && _e((e) => Math.abs(e - t) > 1 ? t : e);
|
|
323
338
|
};
|
|
324
339
|
t();
|
|
325
340
|
let n = null;
|
|
@@ -331,29 +346,29 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
331
346
|
return () => n?.disconnect();
|
|
332
347
|
}, [
|
|
333
348
|
Y,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
]),
|
|
349
|
+
D,
|
|
350
|
+
L
|
|
351
|
+
]), u.useEffect(() => {
|
|
337
352
|
if (!a) return;
|
|
338
353
|
let e = () => {
|
|
339
|
-
|
|
354
|
+
v((e) => e && {
|
|
340
355
|
...e,
|
|
341
|
-
rect:
|
|
342
|
-
}),
|
|
356
|
+
rect: B(e.element)
|
|
357
|
+
}), g((e) => e && {
|
|
343
358
|
...e,
|
|
344
|
-
rect:
|
|
345
|
-
}),
|
|
359
|
+
rect: B(e.element)
|
|
360
|
+
}), b((e) => e.map((e) => ({
|
|
346
361
|
...e,
|
|
347
|
-
rect:
|
|
362
|
+
rect: B(e.element)
|
|
348
363
|
})));
|
|
349
364
|
};
|
|
350
365
|
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
351
366
|
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
352
367
|
};
|
|
353
368
|
}, [a]);
|
|
354
|
-
let X =
|
|
355
|
-
if (!e ||
|
|
356
|
-
|
|
369
|
+
let X = u.useCallback(async (e, t, r) => {
|
|
370
|
+
if (!e || P) return !1;
|
|
371
|
+
I(!0), R(null);
|
|
357
372
|
try {
|
|
358
373
|
let i = t?.trim(), a = r ? [{
|
|
359
374
|
name: r.name,
|
|
@@ -366,45 +381,45 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
366
381
|
...i ? { comment: i } : {},
|
|
367
382
|
...a.length > 0 ? { attachments: a } : {}
|
|
368
383
|
} : void 0, s = o ? await n.grabElement(e, o) : await n.grabElement(e);
|
|
369
|
-
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);
|
|
370
385
|
} catch {
|
|
371
|
-
return
|
|
386
|
+
return I(!1), R("Could not copy this element for the agent."), !1;
|
|
372
387
|
}
|
|
373
|
-
}, [n,
|
|
374
|
-
if (e.length === 0 ||
|
|
375
|
-
|
|
388
|
+
}, [n, P]), Z = u.useCallback(async (e) => {
|
|
389
|
+
if (e.length === 0 || P) return !1;
|
|
390
|
+
I(!0), R(null);
|
|
376
391
|
try {
|
|
377
392
|
let t = await n.grabElements(e);
|
|
378
|
-
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);
|
|
379
394
|
} catch {
|
|
380
|
-
return
|
|
395
|
+
return I(!1), R("Could not copy these elements for the agent."), !1;
|
|
381
396
|
}
|
|
382
|
-
}, [n,
|
|
383
|
-
let e =
|
|
397
|
+
}, [n, P]), Ae = u.useCallback(() => {
|
|
398
|
+
let e = Te.current.map((e) => e.element);
|
|
384
399
|
Z(e);
|
|
385
|
-
}, [Z]),
|
|
386
|
-
|
|
387
|
-
}, []), Q =
|
|
388
|
-
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
if (!
|
|
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;
|
|
392
407
|
let e = n.blockEscape();
|
|
393
408
|
return () => e();
|
|
394
|
-
}, [
|
|
395
|
-
if (!
|
|
396
|
-
let e =
|
|
397
|
-
return e instanceof HTMLElement && !
|
|
398
|
-
let e =
|
|
399
|
-
|
|
409
|
+
}, [C, n]), u.useEffect(() => {
|
|
410
|
+
if (!C) return;
|
|
411
|
+
let e = k();
|
|
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 });
|
|
400
415
|
};
|
|
401
|
-
}, [
|
|
402
|
-
let
|
|
403
|
-
let t =
|
|
416
|
+
}, [C]);
|
|
417
|
+
let Pe = u.useCallback((e) => {
|
|
418
|
+
let t = U.current;
|
|
404
419
|
if (!t) return;
|
|
405
420
|
let n = Array.from(t.querySelectorAll("[role=\"menuitem\"]"));
|
|
406
421
|
if (n.length === 0) return;
|
|
407
|
-
let r =
|
|
422
|
+
let r = k(), i = n.findIndex((e) => e === r), a = (e) => {
|
|
408
423
|
n[(e + n.length) % n.length]?.focus({ preventScroll: !0 });
|
|
409
424
|
};
|
|
410
425
|
switch (e.key) {
|
|
@@ -421,20 +436,20 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
421
436
|
e.preventDefault(), e.stopPropagation(), a(n.length - 1);
|
|
422
437
|
break;
|
|
423
438
|
case "Enter":
|
|
424
|
-
case " ": e.preventDefault(), e.stopPropagation(),
|
|
439
|
+
case " ": e.preventDefault(), e.stopPropagation(), k()?.click();
|
|
425
440
|
}
|
|
426
441
|
}, []);
|
|
427
|
-
|
|
428
|
-
if (!a) return;
|
|
442
|
+
u.useEffect(() => {
|
|
443
|
+
if (!a && !A) return;
|
|
429
444
|
let r = (e) => {
|
|
430
|
-
e.button !== 0 ||
|
|
445
|
+
e.button !== 0 || N(e) || _ || (w(null), Q.current = {
|
|
431
446
|
x: e.clientX,
|
|
432
447
|
y: e.clientY
|
|
433
448
|
}, $.current = !1);
|
|
434
449
|
}, i = (n) => {
|
|
435
|
-
if (
|
|
436
|
-
let r =
|
|
437
|
-
r && (n.preventDefault(), n.stopPropagation(),
|
|
450
|
+
if (N(n)) return;
|
|
451
|
+
let r = F(n.clientX, n.clientY);
|
|
452
|
+
r && (n.preventDefault(), n.stopPropagation(), w({
|
|
438
453
|
element: r,
|
|
439
454
|
selector: t(r),
|
|
440
455
|
xpath: e(r),
|
|
@@ -444,16 +459,16 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
444
459
|
}, o = null, s = null, c = () => {
|
|
445
460
|
o &&= (clearTimeout(o), null), s = null;
|
|
446
461
|
}, ee = (n) => {
|
|
447
|
-
if (
|
|
462
|
+
if (N(n) || n.touches.length !== 1) return;
|
|
448
463
|
let r = n.touches[0];
|
|
449
464
|
if (!r) return;
|
|
450
|
-
let i =
|
|
465
|
+
let i = F(r.clientX, r.clientY);
|
|
451
466
|
i && (s = {
|
|
452
467
|
x: r.clientX,
|
|
453
468
|
y: r.clientY,
|
|
454
469
|
element: i
|
|
455
470
|
}, o = setTimeout(() => {
|
|
456
|
-
s && (
|
|
471
|
+
s && (w({
|
|
457
472
|
element: s.element,
|
|
458
473
|
selector: t(s.element),
|
|
459
474
|
xpath: e(s.element),
|
|
@@ -469,87 +484,87 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
469
484
|
(Math.abs(n) > 10 || Math.abs(r) > 10) && c();
|
|
470
485
|
}, l = () => {
|
|
471
486
|
c();
|
|
472
|
-
},
|
|
473
|
-
if (
|
|
487
|
+
}, ne = (e) => {
|
|
488
|
+
if (N(e)) return;
|
|
474
489
|
let t = Q.current;
|
|
475
490
|
if (t) {
|
|
476
|
-
if (e.pointerType === "mouse" && !(e.buttons & 1)) Q.current = null, $.current = !1,
|
|
491
|
+
if (e.pointerType === "mouse" && !(e.buttons & 1)) Q.current = null, $.current = !1, S(null);
|
|
477
492
|
else {
|
|
478
493
|
let n = e.clientX - t.x, r = e.clientY - t.y;
|
|
479
|
-
if (
|
|
480
|
-
$.current = !0,
|
|
494
|
+
if (Me.current || Math.abs(n) > 6 || Math.abs(r) > 6) {
|
|
495
|
+
$.current = !0, S({
|
|
481
496
|
startX: t.x,
|
|
482
497
|
startY: t.y,
|
|
483
498
|
x: e.clientX,
|
|
484
499
|
y: e.clientY
|
|
485
|
-
}),
|
|
500
|
+
}), g(null);
|
|
486
501
|
return;
|
|
487
502
|
}
|
|
488
503
|
}
|
|
489
504
|
}
|
|
490
|
-
if (
|
|
491
|
-
let n =
|
|
492
|
-
|
|
493
|
-
},
|
|
494
|
-
Q.current = null, $.current = !1,
|
|
495
|
-
},
|
|
505
|
+
if (_) return;
|
|
506
|
+
let n = F(e.clientX, e.clientY);
|
|
507
|
+
g(n ? H(n) : null);
|
|
508
|
+
}, u = () => {
|
|
509
|
+
Q.current = null, $.current = !1, S(null);
|
|
510
|
+
}, d = (e) => {
|
|
496
511
|
let t = Q.current;
|
|
497
512
|
Q.current = null;
|
|
498
|
-
let n =
|
|
513
|
+
let n = Me.current;
|
|
499
514
|
if (!t || !n) return;
|
|
500
|
-
let r =
|
|
515
|
+
let r = le({
|
|
501
516
|
...n,
|
|
502
517
|
x: e.clientX,
|
|
503
518
|
y: e.clientY
|
|
504
519
|
});
|
|
505
520
|
if (r.width < 6 || r.height < 6) {
|
|
506
|
-
|
|
521
|
+
S(null);
|
|
507
522
|
return;
|
|
508
523
|
}
|
|
509
|
-
let i =
|
|
524
|
+
let i = ue(r);
|
|
510
525
|
if (i.length > 0) {
|
|
511
526
|
let e = i.map(H);
|
|
512
|
-
|
|
527
|
+
b((t) => {
|
|
513
528
|
let n = new Set(t.map((e) => e.element)), r = [...t];
|
|
514
529
|
for (let t of e) n.has(t.element) || r.push(t);
|
|
515
530
|
return r;
|
|
516
531
|
});
|
|
517
532
|
}
|
|
518
|
-
|
|
519
|
-
},
|
|
520
|
-
if (
|
|
533
|
+
S(null);
|
|
534
|
+
}, f = (e) => {
|
|
535
|
+
if (N(e) || A) return;
|
|
521
536
|
if ($.current) {
|
|
522
537
|
$.current = !1, e.preventDefault(), e.stopPropagation();
|
|
523
538
|
return;
|
|
524
539
|
}
|
|
525
540
|
e.preventDefault(), e.stopPropagation();
|
|
526
|
-
let t =
|
|
527
|
-
|
|
528
|
-
},
|
|
541
|
+
let t = F(e.clientX, e.clientY);
|
|
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) => {
|
|
529
544
|
if (e.key === "Escape") {
|
|
530
545
|
if (e.isComposing) return;
|
|
531
|
-
if (
|
|
532
|
-
e.preventDefault(), e.stopPropagation(),
|
|
546
|
+
if (Ne.current) {
|
|
547
|
+
e.preventDefault(), e.stopPropagation(), w(null);
|
|
533
548
|
return;
|
|
534
549
|
}
|
|
535
|
-
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);
|
|
536
551
|
return;
|
|
537
552
|
}
|
|
538
|
-
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;
|
|
539
554
|
let t = typeof window < "u" ? window.getSelection() : null;
|
|
540
555
|
if (t && !t.isCollapsed && t.toString().length > 0) return;
|
|
541
|
-
let r =
|
|
556
|
+
let r = Te.current;
|
|
542
557
|
if (r.length > 0) {
|
|
543
558
|
e.preventDefault(), e.stopPropagation(), Z(r.map((e) => e.element));
|
|
544
559
|
return;
|
|
545
560
|
}
|
|
546
|
-
let i =
|
|
561
|
+
let i = we.current;
|
|
547
562
|
if (!i) return;
|
|
548
563
|
e.preventDefault(), e.stopPropagation();
|
|
549
|
-
let a =
|
|
550
|
-
X(i, a ?
|
|
564
|
+
let a = _?.element === i;
|
|
565
|
+
X(i, a ? Ee.current : void 0, a ? De.current : null);
|
|
551
566
|
};
|
|
552
|
-
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, {
|
|
553
568
|
capture: !0,
|
|
554
569
|
passive: !0
|
|
555
570
|
}), document.addEventListener("touchmove", te, {
|
|
@@ -561,292 +576,322 @@ var ye = l.memo(function({ core: n, state: r, active: a }) {
|
|
|
561
576
|
}), document.addEventListener("touchcancel", l, {
|
|
562
577
|
capture: !0,
|
|
563
578
|
passive: !0
|
|
564
|
-
}), window.addEventListener("keydown",
|
|
565
|
-
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();
|
|
566
581
|
};
|
|
567
582
|
}, [
|
|
568
583
|
a,
|
|
584
|
+
A,
|
|
569
585
|
n,
|
|
570
586
|
X,
|
|
571
587
|
Z,
|
|
572
|
-
|
|
588
|
+
_
|
|
573
589
|
]);
|
|
574
|
-
let
|
|
590
|
+
let Fe = u.useCallback(async (e) => {
|
|
575
591
|
e.preventDefault();
|
|
576
|
-
let t =
|
|
577
|
-
if (
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
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));
|
|
587
622
|
}
|
|
588
623
|
}, [
|
|
589
|
-
|
|
624
|
+
D,
|
|
625
|
+
T,
|
|
590
626
|
n,
|
|
591
|
-
|
|
592
|
-
|
|
627
|
+
q,
|
|
628
|
+
A,
|
|
629
|
+
_,
|
|
630
|
+
r.activeBranch,
|
|
593
631
|
r.currentUser
|
|
594
|
-
]),
|
|
595
|
-
X(
|
|
632
|
+
]), Ie = u.useCallback(() => {
|
|
633
|
+
X(_?.element ?? null, T, D);
|
|
596
634
|
}, [
|
|
597
|
-
|
|
598
|
-
|
|
635
|
+
D,
|
|
636
|
+
T,
|
|
599
637
|
X,
|
|
600
|
-
|
|
601
|
-
]),
|
|
602
|
-
|
|
603
|
-
}, []),
|
|
638
|
+
_
|
|
639
|
+
]), Le = u.useCallback(() => {
|
|
640
|
+
V.current?.click();
|
|
641
|
+
}, []), Re = u.useCallback((e) => {
|
|
604
642
|
let t = e.currentTarget, n = t.files?.[0] ?? null;
|
|
605
|
-
|
|
606
|
-
}, []),
|
|
607
|
-
|
|
608
|
-
}, []),
|
|
609
|
-
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", {
|
|
610
648
|
className: "ck-element-selector",
|
|
611
649
|
"data-testid": "ck-element-selector",
|
|
612
650
|
children: [
|
|
613
|
-
|
|
651
|
+
Oe.map((e) => /* @__PURE__ */ f("div", {
|
|
614
652
|
"aria-hidden": "true",
|
|
615
653
|
className: "ck-element-selector-mark",
|
|
616
654
|
"data-comment-id": e.id,
|
|
617
655
|
style: K(e.rect)
|
|
618
656
|
}, e.id)),
|
|
619
|
-
a &&
|
|
657
|
+
a && h && !x && /* @__PURE__ */ f("div", {
|
|
620
658
|
"aria-hidden": "true",
|
|
621
659
|
className: "ck-element-selector-outline",
|
|
622
660
|
"data-state": "hover",
|
|
623
|
-
style: K(
|
|
661
|
+
style: K(h.rect)
|
|
624
662
|
}),
|
|
625
|
-
a &&
|
|
663
|
+
a && x && /* @__PURE__ */ f("div", {
|
|
626
664
|
"aria-hidden": "true",
|
|
627
665
|
className: "ck-element-selector-marquee",
|
|
628
666
|
"data-testid": "ck-element-selector-marquee",
|
|
629
667
|
style: {
|
|
630
|
-
left: Math.min(
|
|
631
|
-
top: Math.min(
|
|
632
|
-
width: Math.abs(
|
|
633
|
-
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)
|
|
634
672
|
}
|
|
635
673
|
}),
|
|
636
|
-
a &&
|
|
674
|
+
a && y.map((e, t) => /* @__PURE__ */ f("div", {
|
|
637
675
|
"aria-hidden": "true",
|
|
638
676
|
className: "ck-element-selector-outline",
|
|
639
677
|
"data-state": "multi",
|
|
640
678
|
"data-multi-index": t + 1,
|
|
641
679
|
style: K(e.rect)
|
|
642
680
|
}, `multi-${t}-${e.selector}-${e.xpath}`)),
|
|
643
|
-
a &&
|
|
644
|
-
ref:
|
|
681
|
+
a && C && /* @__PURE__ */ p("ul", {
|
|
682
|
+
ref: U,
|
|
645
683
|
className: "ck-element-selector-context-menu",
|
|
646
684
|
"data-testid": "ck-element-selector-context-menu",
|
|
647
685
|
role: "menu",
|
|
648
686
|
"aria-label": "Element actions",
|
|
649
|
-
onKeyDown:
|
|
650
|
-
style:
|
|
687
|
+
onKeyDown: Pe,
|
|
688
|
+
style: ve(C),
|
|
651
689
|
children: [
|
|
652
|
-
/* @__PURE__ */
|
|
690
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
653
691
|
type: "button",
|
|
654
692
|
role: "menuitem",
|
|
655
693
|
"data-testid": "ck-context-menu-grab",
|
|
656
694
|
onClick: () => {
|
|
657
|
-
let e =
|
|
658
|
-
|
|
695
|
+
let e = C.element;
|
|
696
|
+
w(null), X(e);
|
|
659
697
|
},
|
|
660
698
|
children: "Grab for agent"
|
|
661
699
|
}) }),
|
|
662
|
-
/* @__PURE__ */
|
|
700
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
663
701
|
type: "button",
|
|
664
702
|
role: "menuitem",
|
|
665
703
|
"data-testid": "ck-context-menu-comment",
|
|
704
|
+
disabled: !m,
|
|
666
705
|
onClick: () => {
|
|
667
|
-
let e = H(
|
|
668
|
-
|
|
706
|
+
let e = H(C.element);
|
|
707
|
+
w(null), v(e);
|
|
669
708
|
},
|
|
670
709
|
children: "Add comment"
|
|
671
710
|
}) }),
|
|
672
|
-
/* @__PURE__ */
|
|
711
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
673
712
|
type: "button",
|
|
674
713
|
role: "menuitem",
|
|
675
714
|
"data-testid": "ck-context-menu-copy-selector",
|
|
676
715
|
onClick: () => {
|
|
677
|
-
let e =
|
|
678
|
-
|
|
716
|
+
let e = C.selector;
|
|
717
|
+
w(null), he(e, "CSS selector");
|
|
679
718
|
},
|
|
680
719
|
children: "Copy CSS selector"
|
|
681
720
|
}) }),
|
|
682
|
-
/* @__PURE__ */
|
|
721
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
683
722
|
type: "button",
|
|
684
723
|
role: "menuitem",
|
|
685
724
|
"data-testid": "ck-context-menu-copy-xpath",
|
|
686
725
|
onClick: () => {
|
|
687
|
-
let e =
|
|
688
|
-
|
|
726
|
+
let e = C.xpath;
|
|
727
|
+
w(null), he(e, "XPath");
|
|
689
728
|
},
|
|
690
729
|
children: "Copy XPath"
|
|
691
730
|
}) }),
|
|
692
|
-
/* @__PURE__ */
|
|
731
|
+
/* @__PURE__ */ f("li", { children: /* @__PURE__ */ f("button", {
|
|
693
732
|
type: "button",
|
|
694
733
|
role: "menuitem",
|
|
695
734
|
"data-testid": "ck-context-menu-inspect",
|
|
696
735
|
onClick: () => {
|
|
697
|
-
console.log("[CommentKit] inspect",
|
|
736
|
+
console.log("[CommentKit] inspect", C.element), w(null);
|
|
698
737
|
},
|
|
699
738
|
children: "Inspect (log to console)"
|
|
700
739
|
}) })
|
|
701
740
|
]
|
|
702
741
|
}),
|
|
703
|
-
a &&
|
|
742
|
+
a && y.length > 0 && /* @__PURE__ */ p("div", {
|
|
704
743
|
className: "ck-element-selector-multibar",
|
|
705
744
|
"data-testid": "ck-element-selector-multibar",
|
|
706
745
|
children: [
|
|
707
|
-
/* @__PURE__ */
|
|
746
|
+
/* @__PURE__ */ p("span", {
|
|
708
747
|
className: "ck-element-selector-multibar-count",
|
|
709
|
-
children: [
|
|
748
|
+
children: [y.length, " selected"]
|
|
710
749
|
}),
|
|
711
|
-
/* @__PURE__ */
|
|
750
|
+
/* @__PURE__ */ f(o, {
|
|
712
751
|
type: "button",
|
|
713
752
|
size: "sm",
|
|
714
|
-
onClick:
|
|
715
|
-
disabled:
|
|
753
|
+
onClick: Ae,
|
|
754
|
+
disabled: P,
|
|
716
755
|
"data-testid": "ck-element-grab-many-button",
|
|
717
|
-
children:
|
|
756
|
+
children: P ? "Grabbing…" : `Grab ${y.length} for agent`
|
|
718
757
|
}),
|
|
719
|
-
/* @__PURE__ */
|
|
758
|
+
/* @__PURE__ */ f(o, {
|
|
720
759
|
type: "button",
|
|
721
760
|
size: "sm",
|
|
722
761
|
variant: "ghost",
|
|
723
|
-
onClick:
|
|
724
|
-
disabled:
|
|
762
|
+
onClick: je,
|
|
763
|
+
disabled: P,
|
|
725
764
|
"data-testid": "ck-element-grab-clear-button",
|
|
726
765
|
children: "Clear"
|
|
727
766
|
})
|
|
728
767
|
]
|
|
729
768
|
}),
|
|
730
|
-
a &&
|
|
769
|
+
(a || A) && _ && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
|
|
731
770
|
"aria-hidden": "true",
|
|
732
771
|
className: "ck-element-selector-outline",
|
|
733
772
|
"data-state": "selected",
|
|
734
|
-
style: K(
|
|
735
|
-
}), /* @__PURE__ */
|
|
736
|
-
ref:
|
|
773
|
+
style: K(_.rect)
|
|
774
|
+
}), /* @__PURE__ */ p("form", {
|
|
775
|
+
ref: z,
|
|
737
776
|
className: "ck-element-selector-composer",
|
|
738
|
-
style:
|
|
739
|
-
onSubmit:
|
|
777
|
+
style: ge(_.rect, pe),
|
|
778
|
+
onSubmit: Fe,
|
|
740
779
|
children: [
|
|
741
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ f("div", {
|
|
742
781
|
className: "ck-element-selector-input-row",
|
|
743
|
-
children: /* @__PURE__ */
|
|
782
|
+
children: /* @__PURE__ */ f(te, {
|
|
744
783
|
"data-ck-composer-input": "",
|
|
745
784
|
"aria-label": "Element comment",
|
|
746
|
-
value:
|
|
785
|
+
value: T,
|
|
747
786
|
placeholder: "Add comment",
|
|
748
|
-
disabled:
|
|
787
|
+
disabled: A || P,
|
|
749
788
|
onChange: (e) => {
|
|
750
|
-
|
|
789
|
+
E(e.currentTarget.value), L && R(null);
|
|
751
790
|
}
|
|
752
791
|
})
|
|
753
792
|
}),
|
|
754
|
-
!
|
|
755
|
-
ref:
|
|
793
|
+
!s && /* @__PURE__ */ f("input", {
|
|
794
|
+
ref: V,
|
|
756
795
|
"aria-label": "Attach file",
|
|
757
796
|
className: "ck-element-selector-file-input",
|
|
758
797
|
type: "file",
|
|
759
|
-
|
|
798
|
+
disabled: A || P,
|
|
799
|
+
onChange: Re
|
|
760
800
|
}),
|
|
761
|
-
|
|
801
|
+
D && /* @__PURE__ */ p("div", {
|
|
762
802
|
className: "ck-element-selector-attachment",
|
|
763
803
|
"data-testid": "ck-element-attachment-preview",
|
|
764
804
|
children: [
|
|
765
|
-
|
|
805
|
+
D.previewUrl && /* @__PURE__ */ f("img", {
|
|
766
806
|
alt: "",
|
|
767
807
|
"aria-hidden": "true",
|
|
768
808
|
className: "ck-element-selector-attachment-image",
|
|
769
|
-
src:
|
|
809
|
+
src: D.previewUrl
|
|
770
810
|
}),
|
|
771
|
-
/* @__PURE__ */
|
|
811
|
+
/* @__PURE__ */ p("div", {
|
|
772
812
|
className: "ck-element-selector-attachment-meta",
|
|
773
813
|
children: [
|
|
774
|
-
/* @__PURE__ */
|
|
814
|
+
/* @__PURE__ */ f("span", {
|
|
775
815
|
className: "ck-element-selector-attachment-name",
|
|
776
|
-
children:
|
|
816
|
+
children: D.name
|
|
777
817
|
}),
|
|
778
|
-
/* @__PURE__ */
|
|
818
|
+
/* @__PURE__ */ f("span", {
|
|
779
819
|
className: "ck-element-selector-attachment-path",
|
|
780
|
-
title:
|
|
781
|
-
children:
|
|
820
|
+
title: D.path,
|
|
821
|
+
children: D.path
|
|
782
822
|
}),
|
|
783
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ f("span", {
|
|
784
824
|
className: "ck-element-selector-attachment-size",
|
|
785
|
-
children:
|
|
825
|
+
children: fe(D.size)
|
|
786
826
|
})
|
|
787
827
|
]
|
|
788
828
|
}),
|
|
789
|
-
/* @__PURE__ */
|
|
829
|
+
/* @__PURE__ */ f(o, {
|
|
790
830
|
type: "button",
|
|
791
831
|
size: "icon-xs",
|
|
792
832
|
variant: "ghost",
|
|
793
833
|
"aria-label": "Remove attachment",
|
|
794
|
-
disabled:
|
|
795
|
-
onClick:
|
|
796
|
-
children: /* @__PURE__ */
|
|
834
|
+
disabled: A || P,
|
|
835
|
+
onClick: ze,
|
|
836
|
+
children: /* @__PURE__ */ f(ie, {
|
|
797
837
|
className: "ck-element-selector-action-icon",
|
|
798
838
|
"aria-hidden": "true"
|
|
799
839
|
})
|
|
800
840
|
})
|
|
801
841
|
]
|
|
802
842
|
}),
|
|
803
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ p("div", {
|
|
804
844
|
className: "ck-element-selector-actions",
|
|
805
845
|
children: [
|
|
806
|
-
!
|
|
846
|
+
!s && /* @__PURE__ */ p(o, {
|
|
807
847
|
type: "button",
|
|
808
848
|
variant: "outline",
|
|
809
849
|
className: "ck-element-selector-attach-action",
|
|
810
|
-
disabled:
|
|
811
|
-
onClick:
|
|
850
|
+
disabled: A || P,
|
|
851
|
+
onClick: Le,
|
|
812
852
|
"data-testid": "ck-element-attach-button",
|
|
813
|
-
children: [/* @__PURE__ */
|
|
853
|
+
children: [/* @__PURE__ */ f(re, {
|
|
814
854
|
className: "ck-element-selector-action-icon",
|
|
815
855
|
"aria-hidden": "true"
|
|
816
|
-
}), /* @__PURE__ */
|
|
856
|
+
}), /* @__PURE__ */ f("span", { children: "Attach" })]
|
|
817
857
|
}),
|
|
818
|
-
/* @__PURE__ */
|
|
858
|
+
/* @__PURE__ */ f(o, {
|
|
819
859
|
type: "submit",
|
|
820
860
|
className: "ck-element-selector-save-action",
|
|
821
|
-
disabled: !
|
|
822
|
-
children:
|
|
861
|
+
disabled: !m || !T.trim() || A || P,
|
|
862
|
+
children: A ? "Saving" : "Save"
|
|
823
863
|
}),
|
|
824
|
-
/* @__PURE__ */
|
|
864
|
+
/* @__PURE__ */ f(o, {
|
|
825
865
|
type: "button",
|
|
826
866
|
className: "ck-element-selector-grab-action",
|
|
827
|
-
variant:
|
|
828
|
-
disabled:
|
|
829
|
-
onClick:
|
|
830
|
-
title:
|
|
867
|
+
variant: Be ? "default" : "outline",
|
|
868
|
+
disabled: A || P,
|
|
869
|
+
onClick: Ie,
|
|
870
|
+
title: s ? "Copy element context to clipboard for your agent" : "Copy element source + screenshot to clipboard for your agent",
|
|
831
871
|
"data-testid": "ck-element-grab-button",
|
|
832
|
-
children:
|
|
872
|
+
children: P ? "Grabbing…" : "Grab for agent"
|
|
833
873
|
})
|
|
834
874
|
]
|
|
835
875
|
}),
|
|
836
|
-
|
|
876
|
+
!m && /* @__PURE__ */ f("p", {
|
|
877
|
+
role: "status",
|
|
878
|
+
className: "ck-element-selector-error",
|
|
879
|
+
children: ae
|
|
880
|
+
}),
|
|
881
|
+
L && /* @__PURE__ */ f("p", {
|
|
837
882
|
className: "ck-element-selector-error",
|
|
838
883
|
role: "alert",
|
|
839
|
-
children:
|
|
884
|
+
children: L
|
|
840
885
|
})
|
|
841
886
|
]
|
|
842
887
|
})] })
|
|
843
888
|
]
|
|
844
889
|
});
|
|
845
890
|
});
|
|
846
|
-
function
|
|
847
|
-
return /* @__PURE__ */
|
|
891
|
+
function Se(e) {
|
|
892
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("style", {
|
|
848
893
|
"data-ck-tool-styles": "element-selector",
|
|
849
894
|
children: m
|
|
850
|
-
}), /* @__PURE__ */
|
|
895
|
+
}), /* @__PURE__ */ f(J, { ...e })] });
|
|
851
896
|
}
|
|
852
|
-
export {
|
|
897
|
+
export { Se as ElementSelector };
|