@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,137 +0,0 @@
|
|
|
1
|
-
import { n as e, t } from "./annotation-toolbar-pX17NLmJ.js";
|
|
2
|
-
import { o as n, s as r } from "./resolveAriaLabelledBy-CIKpnjNJ.js";
|
|
3
|
-
import { g as i, l as a, u as o } from "./comment-kit-ui-D2j2gvnm.js";
|
|
4
|
-
import * as s from "react";
|
|
5
|
-
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
-
function u(e) {
|
|
7
|
-
let t = e.composedPath?.()[0];
|
|
8
|
-
return t instanceof Element ? t : e.target instanceof Element ? e.target : null;
|
|
9
|
-
}
|
|
10
|
-
function d(e) {
|
|
11
|
-
let t = u(e);
|
|
12
|
-
if (!t) return !1;
|
|
13
|
-
let n = t.tagName;
|
|
14
|
-
return n === "INPUT" || n === "TEXTAREA" || n === "SELECT" || t instanceof HTMLElement && t.isContentEditable;
|
|
15
|
-
}
|
|
16
|
-
function f({ imageUrl: u, availableUsers: f = [], onSave: p, onCancel: m }) {
|
|
17
|
-
let h = e(), g = s.useRef(null), _ = s.useRef(null), [v, y] = s.useState(null), b = h.paths, x = s.useMemo(() => {
|
|
18
|
-
if (!v) return {
|
|
19
|
-
w: 800,
|
|
20
|
-
h: 500
|
|
21
|
-
};
|
|
22
|
-
let e = Math.min(window.innerWidth * .7, 900), t = window.innerHeight * .6, n = Math.min(e / v.w, t / v.h, 1);
|
|
23
|
-
return {
|
|
24
|
-
w: Math.round(v.w * n),
|
|
25
|
-
h: Math.round(v.h * n)
|
|
26
|
-
};
|
|
27
|
-
}, [v]), S = b.flatMap((e) => {
|
|
28
|
-
let t = r(e);
|
|
29
|
-
return t ? [t] : [];
|
|
30
|
-
}), C = s.useCallback((e) => {
|
|
31
|
-
let t = g.current?.getBoundingClientRect();
|
|
32
|
-
return t ? {
|
|
33
|
-
x: e.clientX - t.left,
|
|
34
|
-
y: e.clientY - t.top
|
|
35
|
-
} : null;
|
|
36
|
-
}, []);
|
|
37
|
-
return s.useEffect(() => {
|
|
38
|
-
let e = (e) => {
|
|
39
|
-
if (d(e)) return;
|
|
40
|
-
let t = e.metaKey || e.ctrlKey;
|
|
41
|
-
t && e.key.toLowerCase() === "z" && !e.shiftKey ? (e.preventDefault(), h.undo()) : t && (e.key.toLowerCase() === "z" || e.key.toLowerCase() === "y") ? (e.preventDefault(), h.redo()) : e.key === "Escape" && m();
|
|
42
|
-
};
|
|
43
|
-
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
44
|
-
}, [h, m]), /* @__PURE__ */ l("div", {
|
|
45
|
-
"data-commentkit-ui": "",
|
|
46
|
-
className: "ck-screenshot-annotator",
|
|
47
|
-
children: [/* @__PURE__ */ c("div", {
|
|
48
|
-
className: "ck-screenshot-annotator-toolbar",
|
|
49
|
-
children: /* @__PURE__ */ c(t, {
|
|
50
|
-
colors: i,
|
|
51
|
-
drawing: h,
|
|
52
|
-
onCancel: m
|
|
53
|
-
})
|
|
54
|
-
}), /* @__PURE__ */ l("div", {
|
|
55
|
-
className: "ck-screenshot-annotator-stage",
|
|
56
|
-
children: [/* @__PURE__ */ l("div", {
|
|
57
|
-
ref: g,
|
|
58
|
-
className: "ck-screenshot-annotator-canvas",
|
|
59
|
-
style: {
|
|
60
|
-
"--ck-w": `${x.w}px`,
|
|
61
|
-
"--ck-h": `${x.h}px`
|
|
62
|
-
},
|
|
63
|
-
onPointerDown: (e) => {
|
|
64
|
-
if (e.button !== 0) return;
|
|
65
|
-
let t = C(e);
|
|
66
|
-
if (t) {
|
|
67
|
-
h.startPath(t.x, t.y);
|
|
68
|
-
try {
|
|
69
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
70
|
-
} catch {}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
onPointerMove: (e) => {
|
|
74
|
-
if (!h.activePath) return;
|
|
75
|
-
let t = C(e);
|
|
76
|
-
t && h.addPoint(t.x, t.y);
|
|
77
|
-
},
|
|
78
|
-
onPointerUp: () => {
|
|
79
|
-
h.activePath && h.endPath();
|
|
80
|
-
},
|
|
81
|
-
children: [
|
|
82
|
-
/* @__PURE__ */ c("img", {
|
|
83
|
-
src: u,
|
|
84
|
-
alt: "Screenshot",
|
|
85
|
-
className: "ck-screenshot-annotator-image",
|
|
86
|
-
draggable: !1,
|
|
87
|
-
onLoad: (e) => {
|
|
88
|
-
let t = e.currentTarget;
|
|
89
|
-
y({
|
|
90
|
-
w: t.naturalWidth,
|
|
91
|
-
h: t.naturalHeight
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}),
|
|
95
|
-
/* @__PURE__ */ c("svg", {
|
|
96
|
-
ref: _,
|
|
97
|
-
className: "ck-screenshot-annotator-strokes",
|
|
98
|
-
viewBox: `0 0 ${x.w} ${x.h}`,
|
|
99
|
-
children: S.map((e, t) => /* @__PURE__ */ c(n, { path: e }, `${e.type}-${t}`))
|
|
100
|
-
}),
|
|
101
|
-
/* @__PURE__ */ c(a, { mode: "draw" })
|
|
102
|
-
]
|
|
103
|
-
}), /* @__PURE__ */ c("div", {
|
|
104
|
-
className: "ck-screenshot-annotator-composer",
|
|
105
|
-
children: /* @__PURE__ */ c(o, {
|
|
106
|
-
mode: "new-thread",
|
|
107
|
-
placeholder: "Describe what you see...",
|
|
108
|
-
availableUsers: f,
|
|
109
|
-
onSubmit: async (e) => {
|
|
110
|
-
let t = _.current;
|
|
111
|
-
if (!t || b.length === 0) {
|
|
112
|
-
await p(u, e);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
let n = new Image();
|
|
116
|
-
n.src = u, await new Promise((e) => {
|
|
117
|
-
n.onload = () => e(), n.onerror = () => e();
|
|
118
|
-
});
|
|
119
|
-
let r = document.createElement("canvas");
|
|
120
|
-
r.width = n.naturalWidth || x.w, r.height = n.naturalHeight || x.h;
|
|
121
|
-
let i = r.getContext("2d");
|
|
122
|
-
if (!i) {
|
|
123
|
-
await p(u, e);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
i.drawImage(n, 0, 0, r.width, r.height);
|
|
127
|
-
let a = new XMLSerializer().serializeToString(t), o = new Blob([a], { type: "image/svg+xml;charset=utf-8" }), s = URL.createObjectURL(o), c = new Image();
|
|
128
|
-
c.src = s, await new Promise((e) => {
|
|
129
|
-
c.onload = () => e(), c.onerror = () => e();
|
|
130
|
-
}), i.drawImage(c, 0, 0, r.width, r.height), URL.revokeObjectURL(s), await p(r.toDataURL("image/png"), e);
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
})]
|
|
134
|
-
})]
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
export { f as CommentScreenshotAnnotator };
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./button-By0hGrJK.js";
|
|
2
|
-
import { _ as t, f as n, l as r, r as i } from "./comment-kit-ui-D2j2gvnm.js";
|
|
3
|
-
import * as a from "react";
|
|
4
|
-
import { useCallback as o, useState as s } from "react";
|
|
5
|
-
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
-
var d = ".ck-annotation-toolbar{background-color:var(--background);width:100%;max-width:100%;box-shadow:0 10px 15px -3px #0000001a, 0 4px 6px -4px #0000001a, 0 0 0 1px color-mix(in oklch, var(--foreground) 5%, transparent);border-radius:2rem;flex-wrap:wrap;justify-content:center;align-items:center;gap:.375rem .5rem;margin-inline:auto;padding:.375rem;display:flex}@media (width>=1024px){.ck-annotation-toolbar{width:fit-content}}.ck-annotation-separator.ck-separator[data-orientation=vertical]{align-self:center;height:1rem;display:none}@media (width>=1024px){.ck-annotation-separator.ck-separator[data-orientation=vertical]{display:block}}.ck-annotation-stroke{align-items:center;gap:.5rem;width:7rem;padding-inline:.25rem;display:flex}@media (width>=1024px){.ck-annotation-stroke{width:12rem}}.ck-annotation-slider{flex:auto;min-width:0}.ck-annotation-stroke-label{color:var(--muted-foreground);font-variant-numeric:tabular-nums;flex-shrink:0;font-size:.75rem;line-height:1rem}.ck-annotation-swatch{background-color:var(--ck-bg);width:.875rem;height:.875rem;box-shadow:0 0 0 1px color-mix(in oklch, var(--foreground) 5%, transparent);border-radius:999px}.ck-annotation-tooltip{align-items:center;gap:.375rem;display:inline-flex}.ck-annotation-save--disabled{opacity:.5}.ck-screenshot-overlay{z-index:var(--z-ck-overlay);cursor:none;background:color-mix(in srgb, var(--foreground) 20%, transparent);pointer-events:auto;outline:none;position:fixed;inset:0}.ck-screenshot-selection{pointer-events:none;inset-inline-start:var(--ck-x);top:var(--ck-y);width:var(--ck-w);height:var(--ck-h);border:2px solid var(--primary);background:color-mix(in srgb, var(--primary) 10%, transparent);position:fixed}.ck-screenshot-overlay-bar{inset-inline-start:50%;z-index:10;background:var(--card);color:var(--foreground);box-shadow:var(--shadow-lg);border-radius:.5rem;align-items:center;gap:.75rem;padding:.5rem 1rem;font-size:.875rem;display:flex;position:fixed;bottom:1.5rem;transform:translate(-50%)}.ck-screenshot-overlay-status{align-items:center;gap:.5rem;display:inline-flex}.ck-screenshot-annotator{z-index:var(--z-ck-overlay);background:color-mix(in srgb, var(--foreground) 60%, transparent);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);pointer-events:auto;flex-direction:column;display:flex;position:fixed;inset:0}.ck-screenshot-annotator-toolbar{justify-content:center;padding:.75rem;display:flex}.ck-screenshot-annotator-stage{flex-direction:column;flex:1;justify-content:center;align-items:center;gap:1rem;min-height:0;padding:1rem;display:flex}@media (width>=1024px){.ck-screenshot-annotator-stage{flex-direction:row}}.ck-screenshot-annotator-canvas{width:var(--ck-w);height:var(--ck-h);cursor:none;background:var(--card);box-shadow:var(--shadow-xl);border-radius:.5rem;position:relative;overflow:hidden}.ck-screenshot-annotator-image,.ck-screenshot-annotator-strokes{width:100%;height:100%;position:absolute;inset:0}.ck-screenshot-annotator-image{object-fit:contain;-webkit-user-select:none;user-select:none}.ck-screenshot-annotator-strokes{pointer-events:none}.ck-screenshot-annotator-composer{flex-shrink:0;width:min(100%,380px)}", f = 15e3;
|
|
7
|
-
function p(e) {
|
|
8
|
-
try {
|
|
9
|
-
return e.matches?.("[data-commentkit],[data-commentkit-host],[data-commentkit-ui],[data-commentkit-panel],input[type=\"password\"],[data-commentkit-redact],[data-html2canvas-ignore]") ?? !1;
|
|
10
|
-
} catch {
|
|
11
|
-
return !1;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function m() {
|
|
15
|
-
let [e, t] = s(null), [n, r] = s(!1);
|
|
16
|
-
return {
|
|
17
|
-
imageUrl: e,
|
|
18
|
-
capturing: n,
|
|
19
|
-
capture: o(async (e) => {
|
|
20
|
-
r(!0);
|
|
21
|
-
try {
|
|
22
|
-
let n = (await import("html2canvas")).default, r = Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0, window.innerWidth), i = Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0, window.innerHeight), a = await Promise.race([n(document.body, {
|
|
23
|
-
useCORS: !0,
|
|
24
|
-
allowTaint: !1,
|
|
25
|
-
scale: 1,
|
|
26
|
-
logging: !1,
|
|
27
|
-
ignoreElements: p,
|
|
28
|
-
x: e ? e.x + window.scrollX : 0,
|
|
29
|
-
y: e ? e.y + window.scrollY : 0,
|
|
30
|
-
width: e?.width ?? r,
|
|
31
|
-
height: e?.height ?? i,
|
|
32
|
-
windowWidth: r,
|
|
33
|
-
windowHeight: i,
|
|
34
|
-
scrollX: 0,
|
|
35
|
-
scrollY: 0
|
|
36
|
-
}), new Promise((e, t) => {
|
|
37
|
-
window.setTimeout(() => t(/* @__PURE__ */ Error("Screenshot timed out")), f);
|
|
38
|
-
})]);
|
|
39
|
-
t(a.toDataURL("image/png"));
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error("[CommentKit] Screenshot failed:", e), t(null);
|
|
42
|
-
} finally {
|
|
43
|
-
r(!1);
|
|
44
|
-
}
|
|
45
|
-
}, []),
|
|
46
|
-
reset: o(() => {
|
|
47
|
-
t(null);
|
|
48
|
-
}, [])
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
var h = () => import("./comment-screenshot-annotator-BuojwviY.js");
|
|
52
|
-
function g({ availableUsers: o = [], onSave: s, onCancel: c }) {
|
|
53
|
-
let { imageUrl: d, capturing: f, capture: p, reset: g } = m(), [_, v] = a.useState(null), [y, b] = a.useState(null), x = _ !== null, S = a.useMemo(() => !_ || !y ? null : {
|
|
54
|
-
x: Math.min(_.x, y.x),
|
|
55
|
-
y: Math.min(_.y, y.y),
|
|
56
|
-
width: Math.abs(y.x - _.x),
|
|
57
|
-
height: Math.abs(y.y - _.y)
|
|
58
|
-
}, [y, _]), C = a.useCallback(() => {
|
|
59
|
-
p();
|
|
60
|
-
}, [p]);
|
|
61
|
-
return d ? /* @__PURE__ */ l(n, {
|
|
62
|
-
load: h,
|
|
63
|
-
label: "screenshot editor",
|
|
64
|
-
onCancel: () => {
|
|
65
|
-
g(), c();
|
|
66
|
-
},
|
|
67
|
-
children: ({ CommentScreenshotAnnotator: e }) => /* @__PURE__ */ l(e, {
|
|
68
|
-
imageUrl: d,
|
|
69
|
-
availableUsers: o,
|
|
70
|
-
onSave: s,
|
|
71
|
-
onCancel: () => {
|
|
72
|
-
g(), c();
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
}) : /* @__PURE__ */ u("div", {
|
|
76
|
-
role: "button",
|
|
77
|
-
tabIndex: 0,
|
|
78
|
-
"data-commentkit-ui": "",
|
|
79
|
-
className: "ck-screenshot-overlay",
|
|
80
|
-
"aria-label": "Drag to select a region, or press Enter for the full page",
|
|
81
|
-
onMouseDown: (e) => {
|
|
82
|
-
e.button !== 0 || d || f || (v({
|
|
83
|
-
x: e.clientX,
|
|
84
|
-
y: e.clientY
|
|
85
|
-
}), b({
|
|
86
|
-
x: e.clientX,
|
|
87
|
-
y: e.clientY
|
|
88
|
-
}));
|
|
89
|
-
},
|
|
90
|
-
onMouseMove: (e) => {
|
|
91
|
-
x && !d && b({
|
|
92
|
-
x: e.clientX,
|
|
93
|
-
y: e.clientY
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
onMouseUp: () => {
|
|
97
|
-
if (!x || !S || d) {
|
|
98
|
-
v(null), b(null);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
let e = S.width >= 20 && S.height >= 20 ? S : void 0;
|
|
102
|
-
v(null), b(null), p(e);
|
|
103
|
-
},
|
|
104
|
-
onKeyDown: (e) => {
|
|
105
|
-
d || f || e.target !== e.currentTarget || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), C());
|
|
106
|
-
},
|
|
107
|
-
children: [
|
|
108
|
-
S ? /* @__PURE__ */ l("div", {
|
|
109
|
-
className: "ck-screenshot-selection",
|
|
110
|
-
style: {
|
|
111
|
-
"--ck-x": `${S.x}px`,
|
|
112
|
-
"--ck-y": `${S.y}px`,
|
|
113
|
-
"--ck-w": `${S.width}px`,
|
|
114
|
-
"--ck-h": `${S.height}px`
|
|
115
|
-
}
|
|
116
|
-
}) : null,
|
|
117
|
-
/* @__PURE__ */ u("div", {
|
|
118
|
-
className: "ck-screenshot-overlay-bar",
|
|
119
|
-
onMouseDown: (e) => e.stopPropagation(),
|
|
120
|
-
children: [f ? /* @__PURE__ */ u("span", {
|
|
121
|
-
className: "ck-screenshot-overlay-status",
|
|
122
|
-
children: [/* @__PURE__ */ l(i, {}), "Capturing…"]
|
|
123
|
-
}) : /* @__PURE__ */ l("span", { children: "Drag to select region, or click for full page" }), /* @__PURE__ */ u(e, {
|
|
124
|
-
type: "button",
|
|
125
|
-
variant: "secondary",
|
|
126
|
-
size: "sm",
|
|
127
|
-
"aria-label": "Cancel screenshot",
|
|
128
|
-
onClick: (e) => {
|
|
129
|
-
e.stopPropagation(), c();
|
|
130
|
-
},
|
|
131
|
-
children: [/* @__PURE__ */ l(t, {}), "Cancel"]
|
|
132
|
-
})]
|
|
133
|
-
}),
|
|
134
|
-
/* @__PURE__ */ l(r, { mode: "screenshot" })
|
|
135
|
-
]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
function _(e) {
|
|
139
|
-
return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("style", {
|
|
140
|
-
"data-ck-tool-styles": "screenshot",
|
|
141
|
-
children: d
|
|
142
|
-
}), /* @__PURE__ */ l(g, { ...e })] });
|
|
143
|
-
}
|
|
144
|
-
export { _ as CommentScreenshotOverlay };
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { d as e, o as t, r as n, s as r, u as i } from "./comment-kit-core-D0kY00St.js";
|
|
2
|
-
import { a, i as o, o as s } from "./dom-Bhf4WFtY.js";
|
|
3
|
-
var c = 4e3, l = 500, u = 2e3, d = 1e3, f = 5, p = 25, m = 3145728;
|
|
4
|
-
function h(t) {
|
|
5
|
-
let n = e(t?.comment, u);
|
|
6
|
-
return n.length > 0 ? n : null;
|
|
7
|
-
}
|
|
8
|
-
function g(t) {
|
|
9
|
-
return (t?.attachments ?? []).slice(0, f).flatMap((t) => {
|
|
10
|
-
let n = e(t.name, d), r = e(t.path, d);
|
|
11
|
-
return !n || !r ? [] : [{
|
|
12
|
-
name: n,
|
|
13
|
-
path: r,
|
|
14
|
-
...t.pathSource ? { pathSource: t.pathSource } : {},
|
|
15
|
-
...t.type ? { type: e(t.type, d) } : {},
|
|
16
|
-
...typeof t.size == "number" ? { size: t.size } : {},
|
|
17
|
-
...typeof t.lastModified == "number" ? { lastModified: t.lastModified } : {}
|
|
18
|
-
}];
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function _(e) {
|
|
22
|
-
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
23
|
-
}
|
|
24
|
-
function v(t, n, r, i) {
|
|
25
|
-
let s = t.getBoundingClientRect(), u = o(t), d = a(t), f = t.getAttribute("class"), p = t.getAttribute("role"), m = t.getAttribute("aria-label"), h = e(t.textContent, l), g = e(t.outerHTML, c);
|
|
26
|
-
return {
|
|
27
|
-
found: !0,
|
|
28
|
-
tagName: t.tagName.toLowerCase(),
|
|
29
|
-
...t.id ? { id: t.id } : {},
|
|
30
|
-
...f ? { className: f } : {},
|
|
31
|
-
...p ? { role: p } : {},
|
|
32
|
-
...m ? { ariaLabel: m } : {},
|
|
33
|
-
...h ? { text: h } : {},
|
|
34
|
-
rect: {
|
|
35
|
-
top: s.top,
|
|
36
|
-
left: s.left,
|
|
37
|
-
width: s.width,
|
|
38
|
-
height: s.height
|
|
39
|
-
},
|
|
40
|
-
...g ? { htmlPreview: g } : {},
|
|
41
|
-
...u ? { selector: u } : {},
|
|
42
|
-
...d ? { xpath: d } : {},
|
|
43
|
-
...n ? {
|
|
44
|
-
source: y(n),
|
|
45
|
-
stack: r.map(y)
|
|
46
|
-
} : {},
|
|
47
|
-
...i ? { componentName: i } : {}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function y(e) {
|
|
51
|
-
return {
|
|
52
|
-
filePath: e.filePath,
|
|
53
|
-
lineNumber: e.lineNumber,
|
|
54
|
-
columnNumber: e.columnNumber,
|
|
55
|
-
componentName: e.componentName
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function b(e) {
|
|
59
|
-
let t = `${e.filePath}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
|
|
60
|
-
return e.componentName ? `${e.componentName} (${t})` : t;
|
|
61
|
-
}
|
|
62
|
-
function x(e, t, n, r, i, a) {
|
|
63
|
-
let o = ["# CommentKit Element Grab", ""], s = t.tagName ?? "element", c = t.id ? `#${t.id}` : "";
|
|
64
|
-
if (o.push(`**Tag:** \`${s}${c}\``), i && o.push(`**Comment:** ${i}`), a.length > 0) {
|
|
65
|
-
o.push("", "**Attachments:**");
|
|
66
|
-
for (let e of a) {
|
|
67
|
-
let t = [
|
|
68
|
-
e.type ? `type: \`${e.type}\`` : null,
|
|
69
|
-
typeof e.size == "number" ? `size: ${e.size} bytes` : null,
|
|
70
|
-
e.pathSource ? `path source: ${e.pathSource}` : null
|
|
71
|
-
].filter(Boolean).join(", ");
|
|
72
|
-
o.push(`- \`${e.name}\` - path: \`${e.path}\`${t ? ` (${t})` : ""}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (t.componentName && o.push(`**Component:** \`${t.componentName}\``), t.source && o.push(`**Source:** ${b(t.source)}`), t.stack && t.stack.length > 1) {
|
|
76
|
-
o.push("", "**Stack:**");
|
|
77
|
-
for (let e of t.stack) o.push(`- ${b(e)}`);
|
|
78
|
-
}
|
|
79
|
-
return t.source || (t.selector && o.push(`**Selector:** \`${t.selector}\``), t.xpath && o.push(`**XPath:** \`${t.xpath}\``)), o.push(`**Page:** ${e.title || "Untitled"} — ${e.url || e.path}`), o.push(""), o.push("**HTML:**", "```html", n, "```", ""), r && o.push("**Screenshot:** attached to clipboard as an image (paste below this text).", ""), o.join("\n");
|
|
80
|
-
}
|
|
81
|
-
function S(e) {
|
|
82
|
-
let t = e.element;
|
|
83
|
-
return {
|
|
84
|
-
tagName: t.tagName,
|
|
85
|
-
id: t.id,
|
|
86
|
-
className: t.className,
|
|
87
|
-
textContent: t.text,
|
|
88
|
-
componentName: t.componentName,
|
|
89
|
-
filePath: t.source?.filePath,
|
|
90
|
-
lineNumber: t.source?.lineNumber ?? void 0,
|
|
91
|
-
columnNumber: t.source?.columnNumber ?? void 0,
|
|
92
|
-
comment: e.comment ?? void 0,
|
|
93
|
-
attachments: e.attachments,
|
|
94
|
-
selector: t.selector,
|
|
95
|
-
xpath: t.xpath
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function C(e) {
|
|
99
|
-
if (typeof window > "u" || typeof window.dispatchEvent != "function") return;
|
|
100
|
-
let t = e[0];
|
|
101
|
-
t && window.dispatchEvent(new CustomEvent("commentkit:element-selected", { detail: {
|
|
102
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
103
|
-
page: t.page,
|
|
104
|
-
elements: e.map(S)
|
|
105
|
-
} }));
|
|
106
|
-
}
|
|
107
|
-
async function w(a, o, l, u) {
|
|
108
|
-
if (!a || typeof Element > "u" || !(a instanceof Element) || typeof a.getBoundingClientRect != "function") return null;
|
|
109
|
-
let d = (_(a), a), f = await i(a), p = f?.source ?? null, m = f?.stack ?? [], y = f?.componentName ?? null, b = await n(o, l, d, { reportErrors: !1 }), S = b?.dataUrl ?? null, w = b?.blob ?? null, T = v(a, p, m, y), E = T.htmlPreview ?? e(a.outerHTML, c), D = s(), O = h(u), k = g(u), A = x({
|
|
110
|
-
url: D.url,
|
|
111
|
-
path: D.path,
|
|
112
|
-
title: D.title
|
|
113
|
-
}, T, E, S, O, k);
|
|
114
|
-
try {
|
|
115
|
-
w ? await t(A, w) : await r(A);
|
|
116
|
-
} catch {}
|
|
117
|
-
let j = {
|
|
118
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
119
|
-
page: {
|
|
120
|
-
url: D.url,
|
|
121
|
-
path: D.path,
|
|
122
|
-
title: D.title
|
|
123
|
-
},
|
|
124
|
-
element: T,
|
|
125
|
-
comment: O,
|
|
126
|
-
attachments: k,
|
|
127
|
-
html: E,
|
|
128
|
-
screenshotDataUrl: S,
|
|
129
|
-
markdown: A
|
|
130
|
-
};
|
|
131
|
-
return C([j]), j;
|
|
132
|
-
}
|
|
133
|
-
function T(e, t, n, r) {
|
|
134
|
-
let i = [
|
|
135
|
-
"# CommentKit Element Grab",
|
|
136
|
-
"",
|
|
137
|
-
`**Elements:** ${t.length}`,
|
|
138
|
-
`**Page:** ${e.title || "Untitled"} — ${e.url || e.path}`
|
|
139
|
-
];
|
|
140
|
-
if (n && i.push(`**Comment:** ${n}`), r.length > 0) {
|
|
141
|
-
i.push("", "**Attachments:**");
|
|
142
|
-
for (let e of r) i.push(`- \`${e.name}\` - path: \`${e.path}\`${e.pathSource ? ` (path source: ${e.pathSource})` : ""}`);
|
|
143
|
-
}
|
|
144
|
-
return i.push(""), t.forEach((e, t) => {
|
|
145
|
-
let { element: n } = e, r = n.tagName ?? "element", a = n.id ? `#${n.id}` : "";
|
|
146
|
-
i.push(`## [${t + 1}] \`${r}${a}\``), n.componentName && i.push(`- Component: \`${n.componentName}\``), n.source && i.push(`- Source: ${b(n.source)}`), n.stack && n.stack.length > 1 && i.push(`- Stack: ${n.stack.map((e) => e.componentName ?? e.filePath).join(" → ")}`), n.source || (n.selector && i.push(`- Selector: \`${n.selector}\``), n.xpath && i.push(`- XPath: \`${n.xpath}\``)), i.push("", "```html", e.html, "```", ""), e.screenshotDataUrl && i.push(``, "");
|
|
147
|
-
}), i.join("\n");
|
|
148
|
-
}
|
|
149
|
-
async function E(t, a, o, l) {
|
|
150
|
-
let u = t.filter((e) => !!e && typeof Element < "u" && e instanceof Element && typeof e.getBoundingClientRect == "function");
|
|
151
|
-
if (u.length === 0) return null;
|
|
152
|
-
let d = u.slice(0, p);
|
|
153
|
-
u.length > p && typeof console < "u" && console.warn(`[CommentKit] grabElements was called with ${u.length} elements — capped to ${p} for clipboard size. Pass fewer elements to avoid truncation.`);
|
|
154
|
-
let f = [], y = 0, b = 0, S = h(l), w = g(l);
|
|
155
|
-
for (let t of d) {
|
|
156
|
-
let r = (_(t), t), l = await i(t), u = l?.source ?? null, d = l?.stack ?? [], p = l?.componentName ?? null, h = null;
|
|
157
|
-
if (y < m) {
|
|
158
|
-
let e = (await n(a, o, r, { reportErrors: !1 }))?.dataUrl ?? null;
|
|
159
|
-
e && y + e.length <= m ? (h = e, y += e.length) : e && b++;
|
|
160
|
-
} else b++;
|
|
161
|
-
let g = v(t, u, d, p), C = g.htmlPreview ?? e(t.outerHTML, c), T = s(), E = x({
|
|
162
|
-
url: T.url,
|
|
163
|
-
path: T.path,
|
|
164
|
-
title: T.title
|
|
165
|
-
}, g, C, h, S, w);
|
|
166
|
-
f.push({
|
|
167
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
168
|
-
page: {
|
|
169
|
-
url: T.url,
|
|
170
|
-
path: T.path,
|
|
171
|
-
title: T.title
|
|
172
|
-
},
|
|
173
|
-
element: g,
|
|
174
|
-
comment: S,
|
|
175
|
-
attachments: w,
|
|
176
|
-
html: C,
|
|
177
|
-
screenshotDataUrl: h,
|
|
178
|
-
markdown: E
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
b > 0 && typeof console < "u" && console.warn(`[CommentKit] grabElements dropped ${b} screenshot${b === 1 ? "" : "s"} to stay under the ${Math.round(m / 1024 / 1024)}MB clipboard budget.`);
|
|
182
|
-
let E = s(), D = T({
|
|
183
|
-
url: E.url,
|
|
184
|
-
path: E.path,
|
|
185
|
-
title: E.title
|
|
186
|
-
}, f, S, w);
|
|
187
|
-
try {
|
|
188
|
-
await r(D);
|
|
189
|
-
} catch {}
|
|
190
|
-
let O = {
|
|
191
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
192
|
-
page: {
|
|
193
|
-
url: E.url,
|
|
194
|
-
path: E.path,
|
|
195
|
-
title: E.title
|
|
196
|
-
},
|
|
197
|
-
results: f,
|
|
198
|
-
attachments: w,
|
|
199
|
-
markdown: D
|
|
200
|
-
};
|
|
201
|
-
return C(f), O;
|
|
202
|
-
}
|
|
203
|
-
export { w as grabElement, E as grabElements };
|