@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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { n as e } from "./dist-De294MVF.js";
|
|
2
|
+
import { s as t, t as n } from "./button-By0hGrJK.js";
|
|
3
|
+
import { i as r, o as i, r as a } from "./separator-XDBsaWyw.js";
|
|
4
|
+
import { t as o } from "./comment-icon-Dg9ZWpz-.js";
|
|
5
|
+
import { t as s } from "./button-group-CWdKaOlC.js";
|
|
6
|
+
import { c, h as l, m as u, p as d } from "./comment-kit-ui-0vd-DY4S.js";
|
|
7
|
+
import { r as f, t as p } from "./attachment-refresh-CzQFXHkL.js";
|
|
8
|
+
import * as m from "react";
|
|
9
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
10
|
+
var v = ".ck-dialog-content.ck-image-lightbox{width:100vw;max-width:none;height:100dvh;max-height:none;box-shadow:none;background-color:#0000;border:0;border-radius:0;justify-content:center;align-items:center;gap:0;padding:0;display:flex;inset:0;translate:none}@media (width>=640px){.ck-dialog-content.ck-image-lightbox{max-width:none}}.ck-root[data-theme=dark] .ck-dialog-content.ck-image-lightbox{box-shadow:none}.ck-image-lightbox-prev,.ck-image-lightbox-next{position:absolute}.ck-image-lightbox-prev{inset-inline-start:1rem}.ck-image-lightbox-next{inset-inline-end:1rem}.ck-image-lightbox-photo{object-fit:contain;width:auto;max-width:90vw;height:auto;max-height:90vh}.ck-image-lightbox-meta{border-radius:var(--radius-xl);background-color:var(--muted);text-align:center;max-width:90vw;color:var(--muted-foreground);padding:.25rem .625rem;font-size:.75rem;line-height:1rem;position:absolute;bottom:3.5rem;left:50%;transform:translate(-50%)}.ck-image-lightbox-actions{top:1rem;position:absolute;inset-inline-end:1rem}.ck-image-lightbox-dots{gap:.5rem;display:flex;position:absolute;bottom:1.5rem}.ck-image-lightbox-dot{cursor:pointer;background-color:color-mix(in oklch, var(--foreground) 40%, transparent);border:0;border-radius:999px;width:.625rem;height:.625rem;padding:0;transition:background-color .15s cubic-bezier(.4,0,.2,1)}.ck-image-lightbox-dot:hover{background-color:color-mix(in oklch, var(--foreground) 60%, transparent)}.ck-image-lightbox-dot--active,.ck-image-lightbox-dot--active:hover{background-color:var(--foreground)}";
|
|
11
|
+
function y() {
|
|
12
|
+
return /* @__PURE__ */ g(o, {
|
|
13
|
+
strokeWidth: 1.5,
|
|
14
|
+
children: /* @__PURE__ */ g("path", { d: "M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18" })
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function b() {
|
|
18
|
+
return /* @__PURE__ */ g(o, {
|
|
19
|
+
strokeWidth: 1.5,
|
|
20
|
+
children: /* @__PURE__ */ g("path", { d: "M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18" })
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function x() {
|
|
24
|
+
return /* @__PURE__ */ _(o, {
|
|
25
|
+
strokeWidth: 1.5,
|
|
26
|
+
children: [/* @__PURE__ */ g("path", { d: "M7.5 14.5C7.5 11.2002 7.5 9.55025 8.52513 8.52513C9.55025 7.5 11.2002 7.5 14.5 7.5C17.7998 7.5 19.4497 7.5 20.4749 8.52513C21.5 9.55025 21.5 11.2002 21.5 14.5C21.5 17.7998 21.5 19.4497 20.4749 20.4749C19.4497 21.5 17.7998 21.5 14.5 21.5C11.2002 21.5 9.55025 21.5 8.52513 20.4749C7.5 19.4497 7.5 17.7998 7.5 14.5Z" }), /* @__PURE__ */ g("path", { d: "M7.5 16.5C6.10355 16.5 5.40533 16.5 4.84402 16.3036C3.83866 15.9518 3.0482 15.1613 2.69641 14.156C2.5 13.5947 2.5 12.8964 2.5 11.5V9.5C2.5 6.20017 2.5 4.55025 3.52513 3.52513C4.55025 2.5 6.20017 2.5 9.5 2.5H11.5C12.8964 2.5 13.5947 2.5 14.156 2.69641C15.1613 3.0482 15.9518 3.83866 16.3036 4.84402C16.5 5.40533 16.5 6.10355 16.5 7.5" })]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function S() {
|
|
30
|
+
return /* @__PURE__ */ _(o, {
|
|
31
|
+
strokeWidth: 1.5,
|
|
32
|
+
children: [/* @__PURE__ */ g("path", { d: "M2.99969 17.0002C2.99969 17.9302 2.99969 18.3952 3.10192 18.7767C3.37932 19.8119 4.18796 20.6206 5.22324 20.898C5.60474 21.0002 6.06972 21.0002 6.99969 21.0002L16.9997 21.0002C17.9297 21.0002 18.3947 21.0002 18.7762 20.898C19.8114 20.6206 20.6201 19.8119 20.8975 18.7767C20.9997 18.3952 20.9997 17.9302 20.9997 17.0002" }), /* @__PURE__ */ g("path", { d: "M16.4998 11.5002C16.4998 11.5002 13.1856 16.0002 11.9997 16.0002C10.8139 16.0002 7.49976 11.5002 7.49976 11.5002M11.9997 15.0002V3.00016" })]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function C() {
|
|
36
|
+
return /* @__PURE__ */ g(o, {
|
|
37
|
+
strokeWidth: 1.5,
|
|
38
|
+
children: /* @__PURE__ */ g("path", { d: "M18 6L6.00081 17.9992M17.9992 18L6 6.00085" })
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
var w = m.memo(function({ images: o, initialIndex: v, open: w, onClose: T, returnFocusRef: E }) {
|
|
42
|
+
let [D, O] = m.useState(v);
|
|
43
|
+
m.useEffect(() => {
|
|
44
|
+
w && O(Math.max(0, Math.min(v, o.length - 1)));
|
|
45
|
+
}, [
|
|
46
|
+
v,
|
|
47
|
+
w,
|
|
48
|
+
o.length
|
|
49
|
+
]);
|
|
50
|
+
let k = o[D], A = f(k), j = !!(k && (k.type ?? k.filename ?? k.size != null)), M = async (t) => {
|
|
51
|
+
if (t.stopPropagation(), k) try {
|
|
52
|
+
let t = await A.resolve();
|
|
53
|
+
if (!t) throw Error("Attachment unavailable");
|
|
54
|
+
let n = new URL(t, window.location.href);
|
|
55
|
+
if (n.protocol !== "http:" && n.protocol !== "https:" && n.protocol !== "data:" && n.protocol !== "blob:") throw Error("Invalid image URL protocol");
|
|
56
|
+
let r = await fetch(n.href).catch((e) => {
|
|
57
|
+
throw A.onError(), e;
|
|
58
|
+
});
|
|
59
|
+
if (!r.ok) throw A.onError(), Error(`Failed to fetch image (${String(r.status)})`);
|
|
60
|
+
let i = await r.blob();
|
|
61
|
+
await navigator.clipboard.write([new ClipboardItem({ [i.type]: i })]), e.success("Image copied");
|
|
62
|
+
} catch {
|
|
63
|
+
e.error("Failed to copy image");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ g(d, {
|
|
67
|
+
open: w && o.length > 0,
|
|
68
|
+
onOpenChange: (e) => {
|
|
69
|
+
e || T();
|
|
70
|
+
},
|
|
71
|
+
children: /* @__PURE__ */ _(u, {
|
|
72
|
+
showCloseButton: !1,
|
|
73
|
+
finalFocus: E,
|
|
74
|
+
"aria-describedby": void 0,
|
|
75
|
+
className: "ck-image-lightbox",
|
|
76
|
+
onClick: T,
|
|
77
|
+
onKeyDownCapture: (e) => {
|
|
78
|
+
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
|
|
79
|
+
e.preventDefault(), e.stopPropagation();
|
|
80
|
+
let t = e.key === "ArrowLeft" ? -1 : 1;
|
|
81
|
+
O((e) => Math.max(0, Math.min(o.length - 1, e + t)));
|
|
82
|
+
},
|
|
83
|
+
children: [/* @__PURE__ */ g(l, {
|
|
84
|
+
className: "ck-sr-only",
|
|
85
|
+
children: "Image lightbox"
|
|
86
|
+
}), k ? /* @__PURE__ */ _(h, { children: [
|
|
87
|
+
o.length > 1 && D > 0 ? /* @__PURE__ */ g(n, {
|
|
88
|
+
variant: "outline",
|
|
89
|
+
size: "icon",
|
|
90
|
+
"aria-label": "Previous image",
|
|
91
|
+
className: "ck-image-lightbox-prev",
|
|
92
|
+
onClick: (e) => {
|
|
93
|
+
e.stopPropagation(), O((e) => e - 1);
|
|
94
|
+
},
|
|
95
|
+
children: /* @__PURE__ */ g(y, {})
|
|
96
|
+
}) : null,
|
|
97
|
+
o.length > 1 && D < o.length - 1 ? /* @__PURE__ */ g(n, {
|
|
98
|
+
variant: "outline",
|
|
99
|
+
size: "icon",
|
|
100
|
+
"aria-label": "Next image",
|
|
101
|
+
className: "ck-image-lightbox-next",
|
|
102
|
+
onClick: (e) => {
|
|
103
|
+
e.stopPropagation(), O((e) => e + 1);
|
|
104
|
+
},
|
|
105
|
+
children: /* @__PURE__ */ g(b, {})
|
|
106
|
+
}) : null,
|
|
107
|
+
A.failed ? /* @__PURE__ */ g(p, { link: A }) : /* @__PURE__ */ g("img", {
|
|
108
|
+
src: k.url,
|
|
109
|
+
onError: A.onError,
|
|
110
|
+
alt: k.alt ?? k.filename ?? `Image ${String(D + 1)}`,
|
|
111
|
+
className: "ck-image-lightbox-photo",
|
|
112
|
+
onClick: (e) => {
|
|
113
|
+
e.stopPropagation();
|
|
114
|
+
}
|
|
115
|
+
}, `${k.url}:${A.attempt}`),
|
|
116
|
+
j ? /* @__PURE__ */ g("div", {
|
|
117
|
+
className: "ck-image-lightbox-meta",
|
|
118
|
+
onClick: (e) => {
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
k.type,
|
|
123
|
+
k.filename,
|
|
124
|
+
c(k.size)
|
|
125
|
+
].filter(Boolean).join(" • ")
|
|
126
|
+
}) : null,
|
|
127
|
+
/* @__PURE__ */ _(s, {
|
|
128
|
+
className: "ck-image-lightbox-actions",
|
|
129
|
+
onClick: (e) => {
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
},
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(i, {
|
|
134
|
+
render: /* @__PURE__ */ g(n, {
|
|
135
|
+
variant: "outline",
|
|
136
|
+
size: "icon",
|
|
137
|
+
"aria-label": "Copy image",
|
|
138
|
+
disabled: A.loading,
|
|
139
|
+
onClick: (e) => {
|
|
140
|
+
M(e);
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
children: /* @__PURE__ */ g(x, {})
|
|
144
|
+
}), /* @__PURE__ */ g(r, { children: "Copy image" })] }),
|
|
145
|
+
/* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(i, {
|
|
146
|
+
render: /* @__PURE__ */ g(n, {
|
|
147
|
+
variant: "outline",
|
|
148
|
+
size: "icon",
|
|
149
|
+
"aria-label": "Download",
|
|
150
|
+
disabled: A.loading,
|
|
151
|
+
onClick: (e) => {
|
|
152
|
+
e.stopPropagation(), k && A.download(k.filename ?? k.alt ?? `image-${String(D + 1)}`);
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
children: /* @__PURE__ */ g(S, {})
|
|
156
|
+
}), /* @__PURE__ */ g(r, { children: "Download" })] }),
|
|
157
|
+
/* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(i, {
|
|
158
|
+
render: /* @__PURE__ */ g(n, {
|
|
159
|
+
variant: "outline",
|
|
160
|
+
size: "icon",
|
|
161
|
+
"aria-label": "Close",
|
|
162
|
+
onClick: T
|
|
163
|
+
}),
|
|
164
|
+
children: /* @__PURE__ */ g(C, {})
|
|
165
|
+
}), /* @__PURE__ */ g(r, { children: "Close" })] })
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
o.length > 1 ? /* @__PURE__ */ g("div", {
|
|
169
|
+
className: "ck-image-lightbox-dots",
|
|
170
|
+
children: o.map((e, n) => /* @__PURE__ */ g("button", {
|
|
171
|
+
type: "button",
|
|
172
|
+
"aria-label": `Go to image ${String(n + 1)}`,
|
|
173
|
+
"aria-current": n === D ? "true" : void 0,
|
|
174
|
+
className: t("ck-image-lightbox-dot", n === D && "ck-image-lightbox-dot--active"),
|
|
175
|
+
onClick: (e) => {
|
|
176
|
+
e.stopPropagation(), O(n);
|
|
177
|
+
}
|
|
178
|
+
}, e.id))
|
|
179
|
+
}) : null
|
|
180
|
+
] }) : null]
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
function T(e) {
|
|
185
|
+
return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", {
|
|
186
|
+
"data-ck-tool-styles": "lightbox",
|
|
187
|
+
children: v
|
|
188
|
+
}), /* @__PURE__ */ g(w, { ...e })] });
|
|
189
|
+
}
|
|
190
|
+
export { T as CommentImageLightbox };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { d as e, s as t, t as n } from "./button-By0hGrJK.js";
|
|
2
|
+
import { t as r } from "./useRender-D1z_X_BY.js";
|
|
3
|
+
import { c as i, j as a, l as o, r as s } from "./comment-kit-ui-0vd-DY4S.js";
|
|
4
|
+
import { n as c, r as l, t as u } from "./attachment-refresh-CzQFXHkL.js";
|
|
5
|
+
import * as d from "react";
|
|
6
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
7
|
+
var h = d.forwardRef(function({ ratio: e, className: n, style: r, ...i }, a) {
|
|
8
|
+
return /* @__PURE__ */ p("div", {
|
|
9
|
+
ref: a,
|
|
10
|
+
"data-slot": "aspect-ratio",
|
|
11
|
+
className: t("ck-aspect-ratio", n),
|
|
12
|
+
style: {
|
|
13
|
+
"--ratio": e,
|
|
14
|
+
...r
|
|
15
|
+
},
|
|
16
|
+
...i
|
|
17
|
+
});
|
|
18
|
+
}), g = d.forwardRef(function({ className: e, state: n = "done", size: r = "default", orientation: i = "horizontal", ...a }, o) {
|
|
19
|
+
return /* @__PURE__ */ p("div", {
|
|
20
|
+
ref: o,
|
|
21
|
+
"data-slot": "attachment",
|
|
22
|
+
"data-state": n,
|
|
23
|
+
"data-size": r,
|
|
24
|
+
"data-orientation": i,
|
|
25
|
+
className: t("ck-attachment", e),
|
|
26
|
+
...a
|
|
27
|
+
});
|
|
28
|
+
}), _ = d.forwardRef(function({ className: e, variant: n = "icon", ...r }, i) {
|
|
29
|
+
return /* @__PURE__ */ p("div", {
|
|
30
|
+
ref: i,
|
|
31
|
+
"data-slot": "attachment-media",
|
|
32
|
+
"data-variant": n,
|
|
33
|
+
className: t("ck-attachment-media", e),
|
|
34
|
+
...r
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
d.forwardRef(function({ className: e, ...n }, r) {
|
|
38
|
+
return s("attachment"), /* @__PURE__ */ p("div", {
|
|
39
|
+
ref: r,
|
|
40
|
+
"data-slot": "attachment-group",
|
|
41
|
+
className: t("ck-attachment-group", e),
|
|
42
|
+
...n
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
var v = d.forwardRef(function({ className: e, ...n }, r) {
|
|
46
|
+
return /* @__PURE__ */ p("div", {
|
|
47
|
+
ref: r,
|
|
48
|
+
"data-slot": "attachment-content",
|
|
49
|
+
className: t("ck-attachment-content", e),
|
|
50
|
+
...n
|
|
51
|
+
});
|
|
52
|
+
}), y = d.forwardRef(function({ className: e, ...n }, r) {
|
|
53
|
+
return /* @__PURE__ */ p("span", {
|
|
54
|
+
ref: r,
|
|
55
|
+
"data-slot": "attachment-title",
|
|
56
|
+
className: t("ck-attachment-title", e),
|
|
57
|
+
...n
|
|
58
|
+
});
|
|
59
|
+
}), b = d.forwardRef(function({ className: e, ...n }, r) {
|
|
60
|
+
return /* @__PURE__ */ p("span", {
|
|
61
|
+
ref: r,
|
|
62
|
+
"data-slot": "attachment-description",
|
|
63
|
+
className: t("ck-attachment-description", e),
|
|
64
|
+
...n
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
d.forwardRef(function({ className: e, ...n }, r) {
|
|
68
|
+
return /* @__PURE__ */ p("div", {
|
|
69
|
+
ref: r,
|
|
70
|
+
"data-slot": "attachment-actions",
|
|
71
|
+
className: t("ck-attachment-actions", e),
|
|
72
|
+
...n
|
|
73
|
+
});
|
|
74
|
+
}), d.forwardRef(function({ className: e, variant: t = "ghost", size: r = "icon-xs", ...i }, a) {
|
|
75
|
+
return /* @__PURE__ */ p(n, {
|
|
76
|
+
ref: a,
|
|
77
|
+
"data-slot": "attachment-action",
|
|
78
|
+
variant: t,
|
|
79
|
+
size: r,
|
|
80
|
+
className: e,
|
|
81
|
+
...i
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
var x = d.forwardRef(function({ className: n, render: i, type: a, ...o }, s) {
|
|
85
|
+
return r({
|
|
86
|
+
defaultTagName: "button",
|
|
87
|
+
props: e({
|
|
88
|
+
ref: s,
|
|
89
|
+
type: i ? a : a ?? "button",
|
|
90
|
+
className: t("ck-attachment-trigger", n)
|
|
91
|
+
}, o),
|
|
92
|
+
render: i,
|
|
93
|
+
state: { slot: "attachment-trigger" }
|
|
94
|
+
});
|
|
95
|
+
}), S = () => import("./comment-image-lightbox-B7iHjnAz.js"), C = 3;
|
|
96
|
+
function w(e) {
|
|
97
|
+
return e.mimeType ? e.mimeType.startsWith("image/") : e.type === "screenshot" || e.type === "drawing" || e.thumbnail ? !0 : /^data:image\//i.test(e.url) || /\.(png|jpe?g|webp|gif|avif|svg)(?:[?#]|$)/i.test(e.filename ?? e.url);
|
|
98
|
+
}
|
|
99
|
+
function T(e) {
|
|
100
|
+
try {
|
|
101
|
+
let t = new URL(e, typeof window > "u" ? "https://commentkit.dev" : window.location.href);
|
|
102
|
+
return [
|
|
103
|
+
"http:",
|
|
104
|
+
"https:",
|
|
105
|
+
"blob:"
|
|
106
|
+
].includes(t.protocol) ? t.href : void 0;
|
|
107
|
+
} catch {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var E = d.memo(function({ images: e }) {
|
|
112
|
+
let [t, n] = d.useState(!1), [r, i] = d.useState(0), o = d.useRef(null), s = e.filter(w), c = e.filter((e) => !w(e)), l = s.length > C ? s.length - C : 0, u = s.slice(0, C), h = d.useCallback((e) => {
|
|
113
|
+
i(e), n(!0);
|
|
114
|
+
}, []);
|
|
115
|
+
return e.length === 0 ? null : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("div", {
|
|
116
|
+
className: "ck-comment-images",
|
|
117
|
+
onClick: (e) => {
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
},
|
|
120
|
+
children: [u.map((e, t) => /* @__PURE__ */ p(D, {
|
|
121
|
+
image: e,
|
|
122
|
+
index: t,
|
|
123
|
+
more: t === u.length - 1 ? l : 0,
|
|
124
|
+
onOpen: (e) => {
|
|
125
|
+
o.current = e, h(t);
|
|
126
|
+
}
|
|
127
|
+
}, e.id)), c.map((e) => /* @__PURE__ */ p(O, { file: e }, e.id))]
|
|
128
|
+
}), /* @__PURE__ */ p(a, {
|
|
129
|
+
load: S,
|
|
130
|
+
label: "image viewer",
|
|
131
|
+
needed: t,
|
|
132
|
+
onCancel: () => n(!1),
|
|
133
|
+
children: ({ CommentImageLightbox: e }) => /* @__PURE__ */ p(e, {
|
|
134
|
+
images: s,
|
|
135
|
+
initialIndex: r,
|
|
136
|
+
open: t,
|
|
137
|
+
returnFocusRef: o,
|
|
138
|
+
onClose: () => {
|
|
139
|
+
n(!1);
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
})] });
|
|
143
|
+
});
|
|
144
|
+
function D({ image: e, index: t, more: n, onOpen: r }) {
|
|
145
|
+
let a = l(e), s = e.filename ?? e.alt ?? `Image ${String(t + 1)}`;
|
|
146
|
+
return /* @__PURE__ */ m(g, {
|
|
147
|
+
orientation: "vertical",
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ p(_, {
|
|
150
|
+
variant: "image",
|
|
151
|
+
children: /* @__PURE__ */ p(h, {
|
|
152
|
+
ratio: 1,
|
|
153
|
+
className: "ck-comment-image-ratio",
|
|
154
|
+
children: a.failed ? /* @__PURE__ */ p(u, {
|
|
155
|
+
link: a,
|
|
156
|
+
compact: !0
|
|
157
|
+
}) : /* @__PURE__ */ p("img", {
|
|
158
|
+
src: e.url,
|
|
159
|
+
alt: s,
|
|
160
|
+
className: "ck-comment-image",
|
|
161
|
+
onError: a.onError
|
|
162
|
+
}, `${e.url}:${a.attempt}`)
|
|
163
|
+
})
|
|
164
|
+
}),
|
|
165
|
+
n > 0 ? /* @__PURE__ */ m(o, {
|
|
166
|
+
variant: "secondary",
|
|
167
|
+
className: "ck-comment-image-more",
|
|
168
|
+
children: ["+", n]
|
|
169
|
+
}) : null,
|
|
170
|
+
/* @__PURE__ */ p(x, {
|
|
171
|
+
"aria-label": `Open ${s}`,
|
|
172
|
+
title: [
|
|
173
|
+
e.type,
|
|
174
|
+
e.filename,
|
|
175
|
+
i(e.size)
|
|
176
|
+
].filter(Boolean).join(" • ") || void 0,
|
|
177
|
+
onClick: (e) => {
|
|
178
|
+
e.stopPropagation(), r(e.currentTarget);
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function O({ file: e }) {
|
|
185
|
+
let t = l(e), n = e.filename ?? e.alt ?? "Attachment", r = T(e.url);
|
|
186
|
+
return /* @__PURE__ */ m(g, {
|
|
187
|
+
className: "ck-comment-file",
|
|
188
|
+
children: [
|
|
189
|
+
/* @__PURE__ */ p(_, { children: /* @__PURE__ */ m("svg", {
|
|
190
|
+
viewBox: "0 0 24 24",
|
|
191
|
+
fill: "none",
|
|
192
|
+
stroke: "currentColor",
|
|
193
|
+
strokeWidth: "1.5",
|
|
194
|
+
"aria-hidden": "true",
|
|
195
|
+
children: [/* @__PURE__ */ p("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6Z" }), /* @__PURE__ */ p("path", { d: "M14 2v6h6M8 13h8M8 17h5" })]
|
|
196
|
+
}) }),
|
|
197
|
+
/* @__PURE__ */ m(v, { children: [/* @__PURE__ */ p(y, { children: n }), /* @__PURE__ */ p(b, { children: t.refreshFailed ? "Could not refresh. Try again." : t.loading ? "Refreshing link…" : i(e.size) ?? "File" })] }),
|
|
198
|
+
r ? /* @__PURE__ */ p(x, {
|
|
199
|
+
render: /* @__PURE__ */ p("a", {
|
|
200
|
+
href: r,
|
|
201
|
+
download: n,
|
|
202
|
+
target: "_blank",
|
|
203
|
+
rel: "noopener noreferrer"
|
|
204
|
+
}),
|
|
205
|
+
"aria-label": `Download ${n}`,
|
|
206
|
+
"aria-disabled": t.loading || void 0,
|
|
207
|
+
onClick: (r) => {
|
|
208
|
+
t.loading ? r.preventDefault() : c(e.url) && (r.preventDefault(), t.download(n));
|
|
209
|
+
}
|
|
210
|
+
}) : null
|
|
211
|
+
]
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
export { E as CommentImagesContent };
|