@commentkit/comment-kit 0.6.9 → 0.7.0

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +36 -4
  2. package/LICENSE +18 -2
  3. package/README.md +133 -88
  4. package/SECURITY.md +48 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +284 -0
  6. package/dist/angular.es.js +25 -12
  7. package/dist/comment-kit.es.js +23 -11
  8. package/dist/demo.es.js +146 -69
  9. package/dist/headless.es.js +2 -2
  10. package/dist/preact.es.js +3 -3
  11. package/dist/qwik.es.js +1 -110
  12. package/dist/qwik.qwik.mjs +114 -0
  13. package/dist/react.es.js +3 -3
  14. package/dist/shared/annotation-icons-Dh-bmNYK.js +172 -0
  15. package/dist/shared/annotation-toolbar-B9SxYqoF.js +1093 -0
  16. package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
  17. package/dist/shared/{button-group-CHfMRXyA.js → button-group-Cl9CrvvU.js} +1 -1
  18. package/dist/shared/comment-drawing-canvas-Dzb5YoFw.js +124 -0
  19. package/dist/shared/{comment-image-lightbox-0VdAs2iT.js → comment-image-lightbox-BPYJT1sB.js} +62 -57
  20. package/dist/shared/{comment-kit-core-D0kY00St.js → comment-kit-core-BaSuMzp9.js} +1027 -729
  21. package/dist/shared/comment-kit-ui-CzfdAZs2.js +20181 -0
  22. package/dist/shared/comment-screenshot-annotator-C7X-_bm6.js +151 -0
  23. package/dist/shared/comment-screenshot-overlay-wIrZrcRy.js +206 -0
  24. package/dist/shared/comment-utils-BycYTSxA.js +602 -0
  25. package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-FwFVdady.js} +8 -8
  26. package/dist/shared/{dev-grab-pDAfH2lr.js → dev-grab-DDqg0LQf.js} +1 -1
  27. package/dist/shared/dist-De294MVF.js +623 -0
  28. package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-BhJm-NSs.js} +294 -288
  29. package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
  30. package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui--ijs8pWT.js} +4 -4
  31. package/dist/shared/{pusher-BEl7Qn-8.js → pusher-ipHMJnO_.js} +1 -1
  32. package/dist/shared/{realtime-BG_t_ze7.js → realtime-Dk41VwKg.js} +71 -50
  33. package/dist/shared/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
  34. package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-C5v-T8lQ.js} +1 -1
  35. package/dist/shared/styles-D3yMtaec.js +2 -0
  36. package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
  37. package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-DhLWh3Jr.js} +2 -2
  38. package/dist/solid.es.js +3 -3
  39. package/dist/svelte.es.js +3 -3
  40. package/dist/types/adapters/bridge.d.ts +9 -12
  41. package/dist/types/angular/index.d.ts +15 -5
  42. package/dist/types/core/api-client.d.ts +16 -17
  43. package/dist/types/core/comment-kit-core.d.ts +19 -11
  44. package/dist/types/core/local-demo.d.ts +1 -0
  45. package/dist/types/core/types.d.ts +68 -0
  46. package/dist/types/headless.d.ts +1 -1
  47. package/dist/types/index.d.ts +8 -4
  48. package/dist/types/qwik/index.d.ts +4 -1
  49. package/dist/vue.es.js +3 -3
  50. package/docs/api-reference.md +372 -0
  51. package/docs/local-demo.md +60 -0
  52. package/package.json +16 -6
  53. package/dist/shared/annotation-toolbar-pX17NLmJ.js +0 -1104
  54. package/dist/shared/clamp-CcFVX0vC.js +0 -55
  55. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +0 -126
  56. package/dist/shared/comment-kit-ui-D2j2gvnm.js +0 -16685
  57. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +0 -137
  58. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +0 -144
  59. package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
  60. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +0 -669
  61. package/dist/shared/styles-D_FEJZ9G.js +0 -2
  62. 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,6 +0,0 @@
1
- import { createContext as e, useContext as t } from "react";
2
- var n = e(!1);
3
- function r() {
4
- return t(n);
5
- }
6
- export { r as n, n as t };