@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,55 +0,0 @@
|
|
|
1
|
-
import { o as e } from "./button-By0hGrJK.js";
|
|
2
|
-
import * as t from "react";
|
|
3
|
-
function n({ controlled: n, default: i, name: a, state: o = "value" }) {
|
|
4
|
-
let { current: s } = t.useRef(n !== void 0), [c, l] = t.useState(() => i), u = s && n !== void 0 ? n : c;
|
|
5
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6
|
-
t.useEffect(() => {
|
|
7
|
-
s !== (n !== void 0) && e([
|
|
8
|
-
`A component is changing the ${s ? "" : "un"}controlled ${o} state of ${a} to be ${s ? "un" : ""}controlled.`,
|
|
9
|
-
"Elements should not switch from uncontrolled to controlled (or vice versa).",
|
|
10
|
-
`Decide between using a controlled or uncontrolled ${a} element for the lifetime of the component.`,
|
|
11
|
-
"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.",
|
|
12
|
-
"More info: https://fb.me/react-controlled-components"
|
|
13
|
-
].join("\n"));
|
|
14
|
-
}, [
|
|
15
|
-
o,
|
|
16
|
-
a,
|
|
17
|
-
n
|
|
18
|
-
]);
|
|
19
|
-
let { current: c } = t.useRef(i);
|
|
20
|
-
t.useEffect(() => {
|
|
21
|
-
!s && r(c) !== r(i) && e([`A component is changing the default ${o} state of an uncontrolled ${a} after being initialized. To suppress this warning opt to use a controlled ${a}.`].join("\n"));
|
|
22
|
-
}, [i]);
|
|
23
|
-
}
|
|
24
|
-
return [u, t.useCallback((e) => {
|
|
25
|
-
s || l(e);
|
|
26
|
-
}, [])];
|
|
27
|
-
}
|
|
28
|
-
function r(e) {
|
|
29
|
-
let t = 0, n = /* @__PURE__ */ new WeakMap();
|
|
30
|
-
try {
|
|
31
|
-
return JSON.stringify(e, function(e, r) {
|
|
32
|
-
if (!(e === "_owner" && this != null && typeof this == "object" && "$$typeof" in this)) {
|
|
33
|
-
if (typeof r == "bigint") return `__bigint__:${r}`;
|
|
34
|
-
if (typeof r == "object" && r) {
|
|
35
|
-
let e = n.get(r);
|
|
36
|
-
if (e !== void 0) return `__object__:${e}`;
|
|
37
|
-
n.set(r, t), t += 1;
|
|
38
|
-
}
|
|
39
|
-
return r;
|
|
40
|
-
}
|
|
41
|
-
}) ?? `__top__:${typeof e}`;
|
|
42
|
-
} catch {
|
|
43
|
-
return "__unserializable__";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
var i = /*#__PURE__*/ t.createContext(void 0);
|
|
47
|
-
process.env.NODE_ENV !== "production" && (i.displayName = "CSPContext");
|
|
48
|
-
var a = { disableStyleElements: !1 };
|
|
49
|
-
function o() {
|
|
50
|
-
return t.useContext(i) ?? a;
|
|
51
|
-
}
|
|
52
|
-
function s(e, t = -(2 ** 53 - 1), n = 2 ** 53 - 1) {
|
|
53
|
-
return Math.max(t, Math.min(e, n));
|
|
54
|
-
}
|
|
55
|
-
export { o as n, n as r, s as t };
|
|
@@ -1,126 +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 } from "./comment-kit-ui-D2j2gvnm.js";
|
|
4
|
-
import * as o from "react";
|
|
5
|
-
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
-
var u = ".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-drawing-canvas{z-index:var(--z-ck-marker-layer);cursor:none;pointer-events:auto;flex-direction:column;padding-top:1rem;display:flex;position:fixed;inset:0}.ck-drawing-canvas-scrim{pointer-events:none;background-color:#0000004d;position:absolute;inset:0}@supports ((-webkit-backdrop-filter:blur(4px)) or (backdrop-filter:blur(4px))){.ck-drawing-canvas-scrim{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}}.ck-drawing-canvas-toolbar{z-index:1;cursor:auto;width:100%;min-width:0;margin-inline:auto;padding-inline:.75rem;position:relative}.ck-drawing-canvas-surface{z-index:0;touch-action:none;flex:auto;min-height:0;position:relative}";
|
|
7
|
-
function d(e) {
|
|
8
|
-
let t = e.currentTarget;
|
|
9
|
-
typeof t.hasPointerCapture == "function" && t.hasPointerCapture(e.pointerId) && t.releasePointerCapture(e.pointerId);
|
|
10
|
-
}
|
|
11
|
-
var f = o.memo(function({ onSave: s, onCancel: u, remoteStrokes: f }) {
|
|
12
|
-
let p = e(), m = o.useRef(null), h = o.useCallback((e) => {
|
|
13
|
-
let t = m.current;
|
|
14
|
-
if (!t) return {
|
|
15
|
-
x: 0,
|
|
16
|
-
y: 0
|
|
17
|
-
};
|
|
18
|
-
let n = t.getBoundingClientRect();
|
|
19
|
-
if ("touches" in e && e.touches) {
|
|
20
|
-
let t = e.touches[0];
|
|
21
|
-
return t ? {
|
|
22
|
-
x: t.clientX - n.left,
|
|
23
|
-
y: t.clientY - n.top
|
|
24
|
-
} : {
|
|
25
|
-
x: 0,
|
|
26
|
-
y: 0
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
let r = e;
|
|
30
|
-
return {
|
|
31
|
-
x: r.clientX - n.left,
|
|
32
|
-
y: r.clientY - n.top
|
|
33
|
-
};
|
|
34
|
-
}, []), g = o.useCallback((e) => {
|
|
35
|
-
if (e.button !== 0) return;
|
|
36
|
-
try {
|
|
37
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
38
|
-
} catch {}
|
|
39
|
-
let t = h(e);
|
|
40
|
-
p.startPath(t.x, t.y);
|
|
41
|
-
}, [h, p]), _ = o.useCallback((e) => {
|
|
42
|
-
if (!p.activePath) return;
|
|
43
|
-
let t = h(e);
|
|
44
|
-
p.addPoint(t.x, t.y);
|
|
45
|
-
}, [h, p]), v = o.useCallback((e) => {
|
|
46
|
-
d(e), p.endPath();
|
|
47
|
-
}, [p]), y = o.useCallback(() => {
|
|
48
|
-
if (p.paths.length === 0) return;
|
|
49
|
-
let e = m.current, t = p.paths.flatMap((e) => {
|
|
50
|
-
let t = r(e);
|
|
51
|
-
return t ? [t] : [];
|
|
52
|
-
});
|
|
53
|
-
t.length !== 0 && Promise.resolve(s({
|
|
54
|
-
type: "svg",
|
|
55
|
-
paths: t,
|
|
56
|
-
viewport: {
|
|
57
|
-
width: e?.clientWidth || window.innerWidth,
|
|
58
|
-
height: e?.clientHeight || window.innerHeight
|
|
59
|
-
}
|
|
60
|
-
}));
|
|
61
|
-
}, [p.paths, s]), { undo: b, redo: x } = p;
|
|
62
|
-
o.useEffect(() => {
|
|
63
|
-
let e = (e) => {
|
|
64
|
-
(e.metaKey || e.ctrlKey) && e.key === "z" && !e.shiftKey && (e.preventDefault(), b()), (e.metaKey || e.ctrlKey) && (e.key === "y" || e.shiftKey && e.key === "z") && (e.preventDefault(), x()), e.key === "Escape" && u();
|
|
65
|
-
};
|
|
66
|
-
return window.addEventListener("keydown", e), () => {
|
|
67
|
-
window.removeEventListener("keydown", e);
|
|
68
|
-
};
|
|
69
|
-
}, [
|
|
70
|
-
b,
|
|
71
|
-
x,
|
|
72
|
-
u
|
|
73
|
-
]);
|
|
74
|
-
let S = p.paths.flatMap((e) => {
|
|
75
|
-
let t = r(e);
|
|
76
|
-
return t ? [t] : [];
|
|
77
|
-
}), C = p.activePath ? r(p.activePath) : null, w = !!(f && f.length > 0);
|
|
78
|
-
return /* @__PURE__ */ l("div", {
|
|
79
|
-
"data-commentkit-ui": !0,
|
|
80
|
-
"data-slot": "comment-drawing-canvas",
|
|
81
|
-
className: "ck-drawing-canvas",
|
|
82
|
-
children: [
|
|
83
|
-
/* @__PURE__ */ c("div", {
|
|
84
|
-
"aria-hidden": "true",
|
|
85
|
-
className: "ck-drawing-canvas-scrim"
|
|
86
|
-
}),
|
|
87
|
-
/* @__PURE__ */ c("div", {
|
|
88
|
-
className: "ck-drawing-canvas-toolbar",
|
|
89
|
-
children: /* @__PURE__ */ c(t, {
|
|
90
|
-
colors: i,
|
|
91
|
-
drawing: p,
|
|
92
|
-
onSave: y,
|
|
93
|
-
saveDisabled: p.paths.length === 0,
|
|
94
|
-
onCancel: u
|
|
95
|
-
})
|
|
96
|
-
}),
|
|
97
|
-
/* @__PURE__ */ l("svg", {
|
|
98
|
-
ref: m,
|
|
99
|
-
role: "application",
|
|
100
|
-
"aria-label": "Drawing canvas",
|
|
101
|
-
className: "ck-drawing-canvas-surface",
|
|
102
|
-
onPointerDown: g,
|
|
103
|
-
onPointerMove: _,
|
|
104
|
-
onPointerUp: v,
|
|
105
|
-
onPointerLeave: v,
|
|
106
|
-
onPointerCancel: v,
|
|
107
|
-
children: [
|
|
108
|
-
w && f ? f.map((e, t) => /* @__PURE__ */ c("g", {
|
|
109
|
-
opacity: .5,
|
|
110
|
-
children: /* @__PURE__ */ c(n, { path: e })
|
|
111
|
-
}, `remote-${String(t)}`)) : null,
|
|
112
|
-
S.map((e, t) => /* @__PURE__ */ c(n, { path: e }, `local-${String(t)}`)),
|
|
113
|
-
C ? /* @__PURE__ */ c(n, { path: C }) : null
|
|
114
|
-
]
|
|
115
|
-
}),
|
|
116
|
-
/* @__PURE__ */ c(a, { mode: "draw" })
|
|
117
|
-
]
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
function p(e) {
|
|
121
|
-
return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("style", {
|
|
122
|
-
"data-ck-tool-styles": "drawing",
|
|
123
|
-
children: u
|
|
124
|
-
}), /* @__PURE__ */ c(f, { ...e })] });
|
|
125
|
-
}
|
|
126
|
-
export { p as CommentDrawingCanvas };
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { s as e, t } from "./button-By0hGrJK.js";
|
|
2
|
-
import { i as n, o as r, r as i } from "./separator-DusFNTs-.js";
|
|
3
|
-
import { t as a } from "./button-group-CHfMRXyA.js";
|
|
4
|
-
import { b as o, c as s, o as c, p as l, s as u } from "./comment-kit-ui-D2j2gvnm.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 = ".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)}";
|
|
8
|
-
function g({ className: e, children: t, ...n }) {
|
|
9
|
-
return /* @__PURE__ */ p("svg", {
|
|
10
|
-
viewBox: "0 0 24 24",
|
|
11
|
-
fill: "none",
|
|
12
|
-
stroke: "currentColor",
|
|
13
|
-
strokeWidth: 1.5,
|
|
14
|
-
strokeLinecap: "round",
|
|
15
|
-
strokeLinejoin: "round",
|
|
16
|
-
"aria-hidden": "true",
|
|
17
|
-
...n,
|
|
18
|
-
className: e,
|
|
19
|
-
children: t
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function _() {
|
|
23
|
-
return /* @__PURE__ */ p(g, { children: /* @__PURE__ */ p("path", { d: "M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18" }) });
|
|
24
|
-
}
|
|
25
|
-
function v() {
|
|
26
|
-
return /* @__PURE__ */ p(g, { children: /* @__PURE__ */ p("path", { d: "M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18" }) });
|
|
27
|
-
}
|
|
28
|
-
function y() {
|
|
29
|
-
return /* @__PURE__ */ m(g, { children: [/* @__PURE__ */ p("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__ */ p("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" })] });
|
|
30
|
-
}
|
|
31
|
-
function b() {
|
|
32
|
-
return /* @__PURE__ */ m(g, { children: [/* @__PURE__ */ p("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__ */ p("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
|
-
function x() {
|
|
35
|
-
return /* @__PURE__ */ p(g, { children: /* @__PURE__ */ p("path", { d: "M18 6L6.00081 17.9992M17.9992 18L6 6.00085" }) });
|
|
36
|
-
}
|
|
37
|
-
var S = d.memo(function({ images: h, initialIndex: g, open: S, onClose: C }) {
|
|
38
|
-
let [w, T] = d.useState(g);
|
|
39
|
-
d.useEffect(() => {
|
|
40
|
-
T(g);
|
|
41
|
-
}, [g]), d.useEffect(() => {
|
|
42
|
-
if (!S) return;
|
|
43
|
-
let e = (e) => {
|
|
44
|
-
e.key === "ArrowLeft" && (e.preventDefault(), T((e) => Math.max(0, e - 1))), e.key === "ArrowRight" && (e.preventDefault(), T((e) => Math.min(h.length - 1, e + 1)));
|
|
45
|
-
};
|
|
46
|
-
return document.addEventListener("keydown", e), () => {
|
|
47
|
-
document.removeEventListener("keydown", e);
|
|
48
|
-
};
|
|
49
|
-
}, [S, h.length]);
|
|
50
|
-
let E = h[w], D = !!(E && (E.type ?? E.filename ?? E.size != null)), O = async (e) => {
|
|
51
|
-
if (e.stopPropagation(), E) try {
|
|
52
|
-
let e = new URL(E.url, window.location.href);
|
|
53
|
-
if (e.protocol !== "http:" && e.protocol !== "https:" && e.protocol !== "data:" && e.protocol !== "blob:") throw Error("Invalid image URL protocol");
|
|
54
|
-
let t = await fetch(e.href);
|
|
55
|
-
if (!t.ok) throw Error(`Failed to fetch image (${String(t.status)})`);
|
|
56
|
-
let n = await t.blob();
|
|
57
|
-
await navigator.clipboard.write([new ClipboardItem({ [n.type]: n })]), o.success("Image copied");
|
|
58
|
-
} catch {
|
|
59
|
-
o.error("Failed to copy image");
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
return /* @__PURE__ */ p(c, {
|
|
63
|
-
open: S && h.length > 0,
|
|
64
|
-
onOpenChange: (e) => {
|
|
65
|
-
e || C();
|
|
66
|
-
},
|
|
67
|
-
children: /* @__PURE__ */ m(u, {
|
|
68
|
-
showCloseButton: !1,
|
|
69
|
-
"aria-describedby": void 0,
|
|
70
|
-
className: "ck-image-lightbox",
|
|
71
|
-
onClick: C,
|
|
72
|
-
children: [/* @__PURE__ */ p(s, {
|
|
73
|
-
className: "ck-sr-only",
|
|
74
|
-
children: "Image lightbox"
|
|
75
|
-
}), E ? /* @__PURE__ */ m(f, { children: [
|
|
76
|
-
h.length > 1 && w > 0 ? /* @__PURE__ */ p(t, {
|
|
77
|
-
variant: "outline",
|
|
78
|
-
size: "icon",
|
|
79
|
-
"aria-label": "Previous image",
|
|
80
|
-
className: "ck-image-lightbox-prev",
|
|
81
|
-
onClick: (e) => {
|
|
82
|
-
e.stopPropagation(), T((e) => e - 1);
|
|
83
|
-
},
|
|
84
|
-
children: /* @__PURE__ */ p(_, {})
|
|
85
|
-
}) : null,
|
|
86
|
-
h.length > 1 && w < h.length - 1 ? /* @__PURE__ */ p(t, {
|
|
87
|
-
variant: "outline",
|
|
88
|
-
size: "icon",
|
|
89
|
-
"aria-label": "Next image",
|
|
90
|
-
className: "ck-image-lightbox-next",
|
|
91
|
-
onClick: (e) => {
|
|
92
|
-
e.stopPropagation(), T((e) => e + 1);
|
|
93
|
-
},
|
|
94
|
-
children: /* @__PURE__ */ p(v, {})
|
|
95
|
-
}) : null,
|
|
96
|
-
/* @__PURE__ */ p("img", {
|
|
97
|
-
src: E.url,
|
|
98
|
-
alt: E.alt ?? E.filename ?? `Image ${String(w + 1)}`,
|
|
99
|
-
className: "ck-image-lightbox-photo",
|
|
100
|
-
onClick: (e) => {
|
|
101
|
-
e.stopPropagation();
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
D ? /* @__PURE__ */ p("div", {
|
|
105
|
-
className: "ck-image-lightbox-meta",
|
|
106
|
-
onClick: (e) => {
|
|
107
|
-
e.stopPropagation();
|
|
108
|
-
},
|
|
109
|
-
children: [
|
|
110
|
-
E.type,
|
|
111
|
-
E.filename,
|
|
112
|
-
l(E.size)
|
|
113
|
-
].filter(Boolean).join(" • ")
|
|
114
|
-
}) : null,
|
|
115
|
-
/* @__PURE__ */ m(a, {
|
|
116
|
-
className: "ck-image-lightbox-actions",
|
|
117
|
-
onClick: (e) => {
|
|
118
|
-
e.stopPropagation();
|
|
119
|
-
},
|
|
120
|
-
children: [
|
|
121
|
-
/* @__PURE__ */ m(i, { children: [/* @__PURE__ */ p(r, {
|
|
122
|
-
render: /* @__PURE__ */ p(t, {
|
|
123
|
-
variant: "outline",
|
|
124
|
-
size: "icon",
|
|
125
|
-
"aria-label": "Copy image",
|
|
126
|
-
onClick: (e) => {
|
|
127
|
-
O(e);
|
|
128
|
-
}
|
|
129
|
-
}),
|
|
130
|
-
children: /* @__PURE__ */ p(y, {})
|
|
131
|
-
}), /* @__PURE__ */ p(n, { children: "Copy image" })] }),
|
|
132
|
-
/* @__PURE__ */ m(i, { children: [/* @__PURE__ */ p(r, {
|
|
133
|
-
render: /* @__PURE__ */ p(t, {
|
|
134
|
-
variant: "outline",
|
|
135
|
-
size: "icon",
|
|
136
|
-
"aria-label": "Download",
|
|
137
|
-
onClick: (e) => {
|
|
138
|
-
if (e.stopPropagation(), !E) return;
|
|
139
|
-
let t = document.createElement("a");
|
|
140
|
-
t.href = E.url, t.download = E.alt ?? `image-${String(w + 1)}`, t.target = "_blank", t.click();
|
|
141
|
-
}
|
|
142
|
-
}),
|
|
143
|
-
children: /* @__PURE__ */ p(b, {})
|
|
144
|
-
}), /* @__PURE__ */ p(n, { children: "Download" })] }),
|
|
145
|
-
/* @__PURE__ */ m(i, { children: [/* @__PURE__ */ p(r, {
|
|
146
|
-
render: /* @__PURE__ */ p(t, {
|
|
147
|
-
variant: "outline",
|
|
148
|
-
size: "icon",
|
|
149
|
-
"aria-label": "Close",
|
|
150
|
-
onClick: C
|
|
151
|
-
}),
|
|
152
|
-
children: /* @__PURE__ */ p(x, {})
|
|
153
|
-
}), /* @__PURE__ */ p(n, { children: "Close" })] })
|
|
154
|
-
]
|
|
155
|
-
}),
|
|
156
|
-
h.length > 1 ? /* @__PURE__ */ p("div", {
|
|
157
|
-
className: "ck-image-lightbox-dots",
|
|
158
|
-
children: h.map((t, n) => /* @__PURE__ */ p("button", {
|
|
159
|
-
type: "button",
|
|
160
|
-
"aria-label": `Go to image ${String(n + 1)}`,
|
|
161
|
-
"aria-current": n === w ? "true" : void 0,
|
|
162
|
-
className: e("ck-image-lightbox-dot", n === w && "ck-image-lightbox-dot--active"),
|
|
163
|
-
onClick: (e) => {
|
|
164
|
-
e.stopPropagation(), T(n);
|
|
165
|
-
}
|
|
166
|
-
}, t.id))
|
|
167
|
-
}) : null
|
|
168
|
-
] }) : null]
|
|
169
|
-
})
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
function C(e) {
|
|
173
|
-
return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("style", {
|
|
174
|
-
"data-ck-tool-styles": "lightbox",
|
|
175
|
-
children: h
|
|
176
|
-
}), /* @__PURE__ */ p(S, { ...e })] });
|
|
177
|
-
}
|
|
178
|
-
export { C as CommentImageLightbox };
|