@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,94 @@
|
|
|
1
|
+
import { s as e } from "./validation-D-8u4M7I.js";
|
|
2
|
+
import { n as t } from "./dist-De294MVF.js";
|
|
3
|
+
import { t as n } from "./button-By0hGrJK.js";
|
|
4
|
+
import { q as r } from "./comment-kit-ui-0vd-DY4S.js";
|
|
5
|
+
import * as i from "react";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
function s(e) {
|
|
8
|
+
try {
|
|
9
|
+
let t = new URL(e, "https://commentkit.dev"), n = t.searchParams.get("expires");
|
|
10
|
+
return t.searchParams.has("signature") && /^\d{1,12}$/.test(n ?? "") && Number(n) * 1e3 <= Date.now() + 3e4;
|
|
11
|
+
} catch {
|
|
12
|
+
return !1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function c(t) {
|
|
16
|
+
return e(t, !0) ? new URL(t, window.location.href).href : null;
|
|
17
|
+
}
|
|
18
|
+
function l(e) {
|
|
19
|
+
let n = i.useContext(r), a = i.useRef(e);
|
|
20
|
+
a.current = e;
|
|
21
|
+
let o = i.useRef(!0), l = i.useRef(null), u = i.useRef(null), d = i.useRef(null), [f, p] = i.useState(null), [m, h] = i.useState(!1), [g, _] = i.useState(!1), [v, y] = i.useState(0);
|
|
22
|
+
i.useEffect(() => (o.current = !0, () => {
|
|
23
|
+
o.current = !1;
|
|
24
|
+
}), []);
|
|
25
|
+
let b = !!(e && f === e.url), x = async () => {
|
|
26
|
+
if (!e || !n) return null;
|
|
27
|
+
if (l.current && u.current === e.id) return l.current;
|
|
28
|
+
let t = e.id, r = {};
|
|
29
|
+
d.current = r, u.current = t, _(!0), h(!1);
|
|
30
|
+
let i = (async () => {
|
|
31
|
+
try {
|
|
32
|
+
let e = await Promise.resolve().then(() => n(t)), r = e ? c(e) : null;
|
|
33
|
+
return !o.current || a.current?.id !== t ? null : r ? (p(null), y((e) => e + 1), r) : (p(a.current.url), h(!0), null);
|
|
34
|
+
} catch {
|
|
35
|
+
return o.current && a.current?.id === t && (p(a.current.url), h(!0)), null;
|
|
36
|
+
} finally {
|
|
37
|
+
d.current === r && (l.current = null, o.current && _(!1));
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
return l.current = i, i;
|
|
41
|
+
}, S = async () => e ? b || s(e.url) ? x() : c(e.url) : null;
|
|
42
|
+
return {
|
|
43
|
+
failed: b,
|
|
44
|
+
refreshFailed: m,
|
|
45
|
+
loading: g,
|
|
46
|
+
attempt: v,
|
|
47
|
+
refresh: x,
|
|
48
|
+
resolve: S,
|
|
49
|
+
download: async (n) => {
|
|
50
|
+
if (!e) return;
|
|
51
|
+
let r = b || s(e.url), i = r ? window.open("about:blank", "_blank") : null;
|
|
52
|
+
i && (i.opener = null);
|
|
53
|
+
let a = await S();
|
|
54
|
+
if (!a) {
|
|
55
|
+
i?.close(), t.error("Could not refresh the attachment. Try again.");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (i) {
|
|
59
|
+
try {
|
|
60
|
+
!i.closed && i.location.href === "about:blank" && i.location.replace(a);
|
|
61
|
+
} catch {}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (r) {
|
|
65
|
+
t.info("Link refreshed. Select Download again to open it.");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let o = document.createElement("a");
|
|
69
|
+
o.href = a, o.download = n, o.target = "_blank", o.rel = "noopener noreferrer", o.click();
|
|
70
|
+
},
|
|
71
|
+
canRefresh: !!n,
|
|
72
|
+
onError: () => {
|
|
73
|
+
e && p(e.url);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function u({ link: e, compact: t = !1 }) {
|
|
78
|
+
return /* @__PURE__ */ o("div", {
|
|
79
|
+
className: `ck-attachment-error${t ? " ck-attachment-error-compact" : ""}`,
|
|
80
|
+
role: "status",
|
|
81
|
+
onClick: (e) => e.stopPropagation(),
|
|
82
|
+
children: [/* @__PURE__ */ a("p", { children: e.refreshFailed ? t ? "Could not refresh." : "Could not refresh this preview. Try again." : t ? "Preview unavailable." : "Preview unavailable. The link may have expired." }), e.canRefresh ? /* @__PURE__ */ a(n, {
|
|
83
|
+
variant: "outline",
|
|
84
|
+
size: "sm",
|
|
85
|
+
disabled: e.loading,
|
|
86
|
+
"aria-label": "Refresh preview",
|
|
87
|
+
onClick: () => {
|
|
88
|
+
e.refresh();
|
|
89
|
+
},
|
|
90
|
+
children: e.loading ? t ? "…" : "Refreshing…" : t ? "Refresh" : "Refresh preview"
|
|
91
|
+
}) : null]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export { s as n, l as r, u as t };
|
|
@@ -81,6 +81,9 @@ function n(t, n) {
|
|
|
81
81
|
toggleShortcutsOverlay: () => u((e) => e.toggleShortcutsOverlay()),
|
|
82
82
|
setPanelView: (e) => u((t) => t.setPanelView(e)),
|
|
83
83
|
loadMoreComments: () => c((e) => e.loadMoreComments()),
|
|
84
|
+
reloadComments: () => c((e) => e.reloadComments()),
|
|
85
|
+
setBranch: (e) => c((t) => t.setBranch(e)),
|
|
86
|
+
reloadProjectContext: () => c((e) => e.reloadProjectContext()),
|
|
84
87
|
getProjectMembers: () => l((e) => e.getProjectMembers(), []),
|
|
85
88
|
createComment: (e, t, n, r, i, a, o) => c((s) => s.createComment(e, t, n, r, i, a, o)),
|
|
86
89
|
updateComment: (e, t) => c((n) => n.updateComment(e, t)),
|
|
@@ -89,10 +92,10 @@ function n(t, n) {
|
|
|
89
92
|
unresolveComment: (e) => c((t) => t.unresolveComment(e)),
|
|
90
93
|
completeComment: (e) => c((t) => t.completeComment(e)),
|
|
91
94
|
selectComment: (e) => u((t) => t.selectComment(e)),
|
|
92
|
-
addReply: (e, t) => c((
|
|
93
|
-
updateReply: (e, t, n) => c((
|
|
95
|
+
addReply: (e, t, n) => c((r) => r.addReply(e, t, ...n ? [n] : [])),
|
|
96
|
+
updateReply: (e, t, n, r) => c((i) => i.updateReply(e, t, n, ...r ? [r] : [])),
|
|
94
97
|
deleteReply: (e, t) => c((n) => n.deleteReply(e, t)),
|
|
95
|
-
reactToComment: (e, t) => c((
|
|
98
|
+
reactToComment: (e, t, n) => c((r) => r.reactToComment(e, t, ...n ? [n] : [])),
|
|
96
99
|
updateCommentPosition: (e, t, n) => c((r) => r.updateCommentPosition(e, t, n)),
|
|
97
100
|
createHighlight: (e, t) => c((n) => n.createHighlight(e, t)),
|
|
98
101
|
createDrawing: (e, t, n) => c((r) => r.createDrawing(e, t, n)),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { O as e, c as t, d as n, s as r
|
|
2
|
-
import { t as
|
|
1
|
+
import { O as e, c as t, d as n, s as r } from "./button-By0hGrJK.js";
|
|
2
|
+
import { t as i } from "./separator-XDBsaWyw.js";
|
|
3
|
+
import { t as a } from "./useRender-D1z_X_BY.js";
|
|
3
4
|
import * as o from "react";
|
|
4
5
|
import { jsx as s } from "react/jsx-runtime";
|
|
5
6
|
var c = "ArrowUp", l = "ArrowDown", u = "ArrowLeft", d = "ArrowRight", f = "Home", p = "PageUp", m = "PageDown", h = /* @__PURE__ */ new Set([
|
|
@@ -56,10 +57,7 @@ function x(e) {
|
|
|
56
57
|
scrollPaddingLeft: parseFloat(t.scrollPaddingLeft) || 0
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
return i(e.defaultTagName ?? "div", e, e);
|
|
61
|
-
}
|
|
62
|
-
var C = o.forwardRef(function({ className: e, orientation: t = "horizontal", ...n }, i) {
|
|
60
|
+
var S = o.forwardRef(function({ className: e, orientation: t = "horizontal", ...n }, i) {
|
|
63
61
|
return /* @__PURE__ */ s("div", {
|
|
64
62
|
ref: i,
|
|
65
63
|
role: "group",
|
|
@@ -69,25 +67,25 @@ var C = o.forwardRef(function({ className: e, orientation: t = "horizontal", ...
|
|
|
69
67
|
...n
|
|
70
68
|
});
|
|
71
69
|
});
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
return
|
|
70
|
+
S.displayName = "ButtonGroup";
|
|
71
|
+
var C = o.forwardRef(function({ className: e, render: t, ...i }, o) {
|
|
72
|
+
return a({
|
|
75
73
|
defaultTagName: "div",
|
|
76
|
-
ref:
|
|
74
|
+
ref: o,
|
|
77
75
|
props: n({ className: r("ck-button-group-text", e) }, i),
|
|
78
76
|
render: t,
|
|
79
77
|
state: { slot: "button-group-text" }
|
|
80
78
|
});
|
|
81
79
|
});
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
return /* @__PURE__ */ s(
|
|
85
|
-
ref:
|
|
80
|
+
C.displayName = "ButtonGroupText";
|
|
81
|
+
var w = o.forwardRef(function({ className: e, orientation: n = "vertical", ...r }, a) {
|
|
82
|
+
return /* @__PURE__ */ s(i, {
|
|
83
|
+
ref: a,
|
|
86
84
|
"data-slot": "button-group-separator",
|
|
87
85
|
orientation: n,
|
|
88
86
|
className: t("ck-button-group-separator", e),
|
|
89
87
|
...r
|
|
90
88
|
});
|
|
91
89
|
});
|
|
92
|
-
|
|
93
|
-
export {
|
|
90
|
+
w.displayName = "ButtonGroupSeparator";
|
|
91
|
+
export { c as a, g as c, v as d, y as f, d as i, m as l, l as n, h as o, u as r, f as s, S as t, p as u };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var e = [
|
|
2
|
+
"background-color",
|
|
3
|
+
"background-image",
|
|
4
|
+
"color",
|
|
5
|
+
"border-top-color",
|
|
6
|
+
"border-right-color",
|
|
7
|
+
"border-bottom-color",
|
|
8
|
+
"border-left-color",
|
|
9
|
+
"box-shadow",
|
|
10
|
+
"text-shadow",
|
|
11
|
+
"text-decoration-color",
|
|
12
|
+
"-webkit-text-stroke-color",
|
|
13
|
+
"list-style-image",
|
|
14
|
+
"fill",
|
|
15
|
+
"stroke"
|
|
16
|
+
];
|
|
17
|
+
function t(e, t) {
|
|
18
|
+
let n = 1, r = "";
|
|
19
|
+
for (let i = t; i < e.length; i++) {
|
|
20
|
+
let t = e[i];
|
|
21
|
+
if (t === "\\") i++;
|
|
22
|
+
else if (r) t === r && (r = "");
|
|
23
|
+
else if (t === "\"" || t === "'") r = t;
|
|
24
|
+
else if (t === "(") n++;
|
|
25
|
+
else if (t === ")" && --n === 0) return i;
|
|
26
|
+
}
|
|
27
|
+
return -1;
|
|
28
|
+
}
|
|
29
|
+
function n(n) {
|
|
30
|
+
let r = n.defaultView;
|
|
31
|
+
if (!r) return;
|
|
32
|
+
let i = null, a = /* @__PURE__ */ new Map(), o = (e) => {
|
|
33
|
+
let t = a.get(e);
|
|
34
|
+
if (t) return t;
|
|
35
|
+
if (!i) {
|
|
36
|
+
let e = n.createElement("canvas");
|
|
37
|
+
if (e.width = e.height = 1, i = e.getContext("2d", {
|
|
38
|
+
colorSpace: "srgb",
|
|
39
|
+
willReadFrequently: !0
|
|
40
|
+
}), !i) throw Error("Screenshot color conversion is unavailable");
|
|
41
|
+
}
|
|
42
|
+
if (i.fillStyle = "#010203", i.fillStyle = e, i.fillStyle === "#010203" && (i.fillStyle = "#040506", i.fillStyle = e, i.fillStyle === "#040506")) throw Error("Unsupported screenshot color");
|
|
43
|
+
i.clearRect(0, 0, 1, 1), i.fillRect(0, 0, 1, 1);
|
|
44
|
+
let [r, o, s, c] = i.getImageData(0, 0, 1, 1).data, l = `rgba(${r}, ${o}, ${s}, ${c / 255})`;
|
|
45
|
+
return a.set(e, l), l;
|
|
46
|
+
}, s = (e) => {
|
|
47
|
+
let n = /\b(url|oklch|oklab|lch|lab|hwb|color|color-mix|light-dark|(?:repeating-)?(?:linear|radial)-gradient)\(/gi, r = "", i = 0;
|
|
48
|
+
for (let a = n.exec(e); a; a = n.exec(e)) {
|
|
49
|
+
let c = t(e, n.lastIndex);
|
|
50
|
+
if (c < 0) return e;
|
|
51
|
+
let l = e.slice(a.index, c + 1), u = a[1].toLowerCase(), d = l;
|
|
52
|
+
if (u.endsWith("gradient")) {
|
|
53
|
+
let t = s(e.slice(n.lastIndex, c)), r = t.indexOf(","), i = t.slice(0, r), a = i.replace(/\s*\bin\s+[\w-]+(?:\s+(?:shorter|longer|increasing|decreasing)\s+hue)?\s*/i, "").trim();
|
|
54
|
+
a !== i.trim() && (t = (a ? a + "," : "") + t.slice(r + 1)), d = `${u}(${t})`;
|
|
55
|
+
} else u !== "url" && (d = o(l));
|
|
56
|
+
r += e.slice(i, a.index) + d, i = n.lastIndex = c + 1;
|
|
57
|
+
}
|
|
58
|
+
return r + e.slice(i);
|
|
59
|
+
}, c = [];
|
|
60
|
+
for (let t of n.querySelectorAll("*")) {
|
|
61
|
+
if (!t.style) continue;
|
|
62
|
+
let n = r.getComputedStyle(t);
|
|
63
|
+
for (let r of e) {
|
|
64
|
+
let e = n.getPropertyValue(r), i = s(e);
|
|
65
|
+
i !== e && c.push([
|
|
66
|
+
t.style,
|
|
67
|
+
r,
|
|
68
|
+
i
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (let [e, t, n] of c) e.setProperty(t, n, "important");
|
|
73
|
+
}
|
|
74
|
+
export { n as normalizeCaptureColors };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./annotation-toolbar-cGC1p-SP.js";
|
|
2
|
+
import { N as r, a as i, g as a, i as o } from "./comment-kit-ui-0vd-DY4S.js";
|
|
3
|
+
import * as s from "react";
|
|
4
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
+
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]{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}.ck-drawing-canvas-error{border-radius:var(--radius-md);background:var(--background);width:max-content;max-width:calc(100vw - 1.5rem);color:var(--destructive);margin:.75rem auto;padding:.75rem;font-size:.875rem}";
|
|
6
|
+
function f(e) {
|
|
7
|
+
let t = e.currentTarget;
|
|
8
|
+
typeof t.hasPointerCapture == "function" && t.hasPointerCapture(e.pointerId) && t.releasePointerCapture(e.pointerId);
|
|
9
|
+
}
|
|
10
|
+
var p = s.memo(function({ onSave: c, onCancel: d, remoteStrokes: p }) {
|
|
11
|
+
let m = t(), h = s.useRef(null), g = s.useRef(null), [_, v] = s.useState(!1), [y, b] = s.useState(null), x = s.useRef(!1), S = s.useCallback((e) => {
|
|
12
|
+
let t = h.current;
|
|
13
|
+
if (!t) return {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0
|
|
16
|
+
};
|
|
17
|
+
let n = t.getBoundingClientRect();
|
|
18
|
+
if ("touches" in e && e.touches) {
|
|
19
|
+
let t = e.touches[0];
|
|
20
|
+
return t ? {
|
|
21
|
+
x: t.clientX - n.left,
|
|
22
|
+
y: t.clientY - n.top
|
|
23
|
+
} : {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
let r = e;
|
|
29
|
+
return {
|
|
30
|
+
x: r.clientX - n.left,
|
|
31
|
+
y: r.clientY - n.top
|
|
32
|
+
};
|
|
33
|
+
}, []), C = s.useCallback((e) => {
|
|
34
|
+
if (e.button !== 0 || g.current !== null || x.current) return;
|
|
35
|
+
g.current = e.pointerId;
|
|
36
|
+
try {
|
|
37
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
38
|
+
} catch {}
|
|
39
|
+
let t = S(e);
|
|
40
|
+
m.startPath(t.x, t.y);
|
|
41
|
+
}, [S, m]), w = s.useCallback((e) => {
|
|
42
|
+
if (!m.activePath || g.current !== e.pointerId) return;
|
|
43
|
+
let t = S(e);
|
|
44
|
+
m.addPoint(t.x, t.y);
|
|
45
|
+
}, [S, m]), T = s.useCallback((e) => {
|
|
46
|
+
g.current === e.pointerId && (g.current = null, f(e), m.endPath());
|
|
47
|
+
}, [m]), E = s.useCallback(() => {
|
|
48
|
+
if (m.paths.length === 0 || x.current) return;
|
|
49
|
+
let e = h.current, t = m.paths.flatMap((e) => {
|
|
50
|
+
let t = i(e);
|
|
51
|
+
return t ? [t] : [];
|
|
52
|
+
});
|
|
53
|
+
t.length !== 0 && (x.current = !0, v(!0), b(null), Promise.resolve().then(() => c({
|
|
54
|
+
type: "svg",
|
|
55
|
+
paths: t,
|
|
56
|
+
viewport: {
|
|
57
|
+
width: e?.clientWidth || window.innerWidth,
|
|
58
|
+
height: e?.clientHeight || window.innerHeight
|
|
59
|
+
}
|
|
60
|
+
})).catch(() => {
|
|
61
|
+
b("Could not save drawing. Your strokes are still here. Try again.");
|
|
62
|
+
}).finally(() => {
|
|
63
|
+
x.current = !1, v(!1);
|
|
64
|
+
}));
|
|
65
|
+
}, [m.paths, c]);
|
|
66
|
+
e(m.undo, m.redo, d);
|
|
67
|
+
let D = m.paths.flatMap((e) => {
|
|
68
|
+
let t = i(e);
|
|
69
|
+
return t ? [t] : [];
|
|
70
|
+
}), O = m.activePath ? i(m.activePath) : null, k = !!(p && p.length > 0);
|
|
71
|
+
return /* @__PURE__ */ u("div", {
|
|
72
|
+
"data-commentkit-ui": !0,
|
|
73
|
+
"data-slot": "comment-drawing-canvas",
|
|
74
|
+
className: "ck-drawing-canvas",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ l("div", {
|
|
77
|
+
"aria-hidden": "true",
|
|
78
|
+
className: "ck-drawing-canvas-scrim"
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ u("div", {
|
|
81
|
+
className: "ck-drawing-canvas-toolbar",
|
|
82
|
+
children: [/* @__PURE__ */ l(n, {
|
|
83
|
+
colors: r,
|
|
84
|
+
drawing: m,
|
|
85
|
+
onSave: E,
|
|
86
|
+
saveDisabled: m.paths.length === 0 || _,
|
|
87
|
+
onCancel: d
|
|
88
|
+
}), y ? /* @__PURE__ */ l("p", {
|
|
89
|
+
role: "alert",
|
|
90
|
+
className: "ck-drawing-canvas-error",
|
|
91
|
+
children: y
|
|
92
|
+
}) : null]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ u("svg", {
|
|
95
|
+
ref: h,
|
|
96
|
+
role: "application",
|
|
97
|
+
"aria-label": "Drawing canvas",
|
|
98
|
+
className: "ck-drawing-canvas-surface",
|
|
99
|
+
onPointerDown: C,
|
|
100
|
+
onPointerMove: w,
|
|
101
|
+
onPointerUp: T,
|
|
102
|
+
onPointerCancel: (e) => {
|
|
103
|
+
g.current === e.pointerId && (g.current = null, f(e), m.cancelPath());
|
|
104
|
+
},
|
|
105
|
+
children: [
|
|
106
|
+
k && p ? p.map((e, t) => /* @__PURE__ */ l("g", {
|
|
107
|
+
opacity: .5,
|
|
108
|
+
children: /* @__PURE__ */ l(o, { path: e })
|
|
109
|
+
}, `remote-${String(t)}`)) : null,
|
|
110
|
+
D.map((e, t) => /* @__PURE__ */ l(o, { path: e }, `local-${String(t)}`)),
|
|
111
|
+
O ? /* @__PURE__ */ l(o, { path: O }) : null
|
|
112
|
+
]
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ l(a, { mode: "draw" })
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
function m(e) {
|
|
119
|
+
return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("style", {
|
|
120
|
+
"data-ck-tool-styles": "drawing",
|
|
121
|
+
children: d
|
|
122
|
+
}), /* @__PURE__ */ l(p, { ...e })] });
|
|
123
|
+
}
|
|
124
|
+
export { m as CommentDrawingCanvas };
|