@commentkit/comment-kit 1.5.1 → 2.0.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 (141) hide show
  1. package/CHANGELOG.md +281 -582
  2. package/README.md +334 -154
  3. package/SECURITY.md +47 -46
  4. package/dist/node/THIRD_PARTY_NOTICES.txt +56 -0
  5. package/dist/node/browser.js +17 -0
  6. package/dist/node/cli/api.js +226 -0
  7. package/dist/node/cli/bin.js +18 -0
  8. package/dist/node/cli/credentials.js +268 -0
  9. package/dist/node/cli/doctor.js +725 -0
  10. package/dist/node/cli/format.js +54 -0
  11. package/dist/node/cli/init.js +372 -0
  12. package/dist/node/cli/main.js +519 -0
  13. package/dist/node/cli/mcp.js +114 -0
  14. package/dist/node/cli/open.js +20 -0
  15. package/dist/node/plugins/astro-B5y1Gtbf.js +31 -0
  16. package/dist/node/plugins/astro.js +26 -0
  17. package/dist/node/plugins/git-BIXLbL3f.js +92 -0
  18. package/dist/node/plugins/jsx-Bg4BdSph.js +7958 -0
  19. package/dist/node/plugins/next.js +48 -0
  20. package/dist/node/plugins/options-THop1K92.js +71 -0
  21. package/dist/node/plugins/transform-CKiAuSbk.js +1155 -0
  22. package/dist/node/plugins/vite-BdAYUW10.js +74 -0
  23. package/dist/node/plugins/vite.js +1 -0
  24. package/dist/node/plugins/webpack-R2U2DLlY.js +35 -0
  25. package/dist/node/plugins/webpack-loader.cjs +21 -0
  26. package/dist/node/plugins/webpack-loader.js +18 -0
  27. package/dist/node/plugins/webpack.js +1 -0
  28. package/dist/node/shared/endpoint.js +26 -0
  29. package/dist/node/shared/format.js +63 -0
  30. package/dist/node/types/astro.d.ts +11 -0
  31. package/dist/node/types/next.d.ts +34 -0
  32. package/dist/node/types/options.d.ts +59 -0
  33. package/dist/node/types/vite.d.ts +11 -0
  34. package/dist/node/types/webpack-loader.d.ts +22 -0
  35. package/dist/node/types/webpack.d.ts +27 -0
  36. package/dist/npm/THIRD_PARTY_NOTICES.txt +6 -6
  37. package/dist/npm/chunks/AgentSend-DxRJIYiz.js +68 -0
  38. package/dist/npm/chunks/Checklist-CnlfeSbc.js +282 -0
  39. package/dist/npm/chunks/Composer-B1bBVszY.js +725 -0
  40. package/dist/npm/chunks/Guest-vvNPz8h-.js +267 -0
  41. package/dist/npm/chunks/MarkupEditor-VCOXh9d2.js +338 -0
  42. package/dist/npm/chunks/Panel-F37vIL1K.js +1206 -0
  43. package/dist/npm/chunks/Settings-BGoZS2iV.js +231 -0
  44. package/dist/npm/chunks/Shortcuts-B2OMvczr.js +62 -0
  45. package/dist/npm/chunks/StyleEditor-CJ_d8Huf.js +46 -0
  46. package/dist/npm/chunks/StylePanel-yQzHHlY7.js +199 -0
  47. package/dist/npm/chunks/TaskFields-fmy6_HtK.js +289 -0
  48. package/dist/npm/chunks/ThreadCard-D51slKST.js +1113 -0
  49. package/dist/npm/chunks/Viewer-BOBadqmC.js +111 -0
  50. package/dist/npm/chunks/{agent-CqDO3JMA.js → agent-C1OQzBAm.js} +20 -21
  51. package/dist/npm/chunks/{anchor-OCQnjp_6.js → anchor-BsQNVkHj.js} +109 -87
  52. package/dist/npm/chunks/{ar-BQ9K9Oqf.js → ar-CAJ3XT8e.js} +73 -20
  53. package/dist/npm/chunks/card-bits-CAnzrqx3.js +53 -0
  54. package/dist/npm/chunks/{client-dZeNdizE.js → client-kNAo2TTG.js} +292 -285
  55. package/dist/npm/chunks/{colors-CAjY4jxf.js → colors-CWAn_swA.js} +1 -2
  56. package/dist/npm/chunks/confetti-CkBdSu19.js +49 -0
  57. package/dist/npm/chunks/context-B8UAzve0.js +20 -0
  58. package/dist/npm/chunks/context-BuMl7A07.js +48 -0
  59. package/dist/npm/chunks/{de-CcPi8xdC.js → de-Dl18G48t.js} +64 -19
  60. package/dist/npm/chunks/dialog-GO04oC3D.js +3 -0
  61. package/dist/npm/chunks/dpop-U48QIQd7.js +96 -0
  62. package/dist/npm/chunks/drafts-B0ctr1g9.js +21 -0
  63. package/dist/npm/chunks/{es-DXgkjDCG.js → es-Dxk79lS9.js} +64 -19
  64. package/dist/npm/chunks/extension-CKFpPWmi.js +62 -0
  65. package/dist/npm/chunks/{extension-BFkXOmX5.js → extension-E81hWyiT.js} +21 -14
  66. package/dist/npm/chunks/files-DyD5BZgp.js +114 -0
  67. package/dist/npm/chunks/{fr-IjJaUbWh.js → fr-8BebGKYD.js} +121 -76
  68. package/dist/npm/chunks/{hi-BhKQK2MU.js → hi-BIN6Yy_p.js} +65 -20
  69. package/dist/npm/chunks/{html2canvas-pro.esm-lgs6tb4C.js → html2canvas-pro.esm-B7b8p5Wr.js} +608 -528
  70. package/dist/npm/chunks/i18n-DOBt8e9U.js +936 -0
  71. package/dist/npm/chunks/identify-CN-3xzqL.js +106 -0
  72. package/dist/npm/chunks/{it-DKiSCkiD.js → it-Cr6EwpPQ.js} +83 -38
  73. package/dist/npm/chunks/{ja-BI1WagDg.js → ja-Iy3s5aur.js} +62 -17
  74. package/dist/npm/chunks/late-words-B2bmZceJ.js +12 -0
  75. package/dist/npm/chunks/live-CelVeZfP.js +85 -0
  76. package/dist/npm/chunks/locale-D8Q4Q2Nt.js +26 -0
  77. package/dist/npm/chunks/{lock-C82sC17d.js → lock-B1JLlOhz.js} +0 -1
  78. package/dist/npm/chunks/{nl-CJw3VUQ5.js → nl-B84WHqqe.js} +65 -20
  79. package/dist/npm/chunks/page-key-DepmJzC1.js +62 -0
  80. package/dist/npm/chunks/{pick-dDDLxCDI.js → pick-yTyqtxN0.js} +46 -46
  81. package/dist/npm/chunks/pkce-ChKGSW_4.js +8 -0
  82. package/dist/npm/chunks/placement-BF_HOUDD.js +74 -0
  83. package/dist/npm/chunks/privacy-BWUGlHw5.js +57 -0
  84. package/dist/npm/chunks/{pt-BR-CjBolC5g.js → pt-BR-DOkdlfoe.js} +64 -19
  85. package/dist/npm/chunks/{realtime-D22tI_AS.js → realtime-C79zF50C.js} +16 -15
  86. package/dist/npm/chunks/report-CrIqQZDI.js +44 -0
  87. package/dist/npm/chunks/{rolldown-runtime-Y_bBpyJl.js → rolldown-runtime-QGRDbDUS.js} +1 -2
  88. package/dist/npm/chunks/show-BgVC8gWY.js +97 -0
  89. package/dist/npm/chunks/signin-Dd1rb2BP.js +75 -0
  90. package/dist/npm/chunks/{source-BQS2_xfB.js → source-pXVve2Cx.js} +2 -3
  91. package/dist/npm/chunks/src-BTMy4Gyc.js +208 -0
  92. package/dist/npm/chunks/start-DtVlpt7p.js +1878 -0
  93. package/dist/npm/chunks/states-sfTbjZz8.js +3 -0
  94. package/dist/npm/chunks/upload-MgPYqPyE.js +42 -0
  95. package/dist/npm/chunks/uploads-D49mywwz.js +1146 -0
  96. package/dist/npm/chunks/wrap-Bl0gbnFa.js +69 -0
  97. package/dist/npm/chunks/{zh-CN-BrZGx2S0.js → zh-CN-Z5fQCb7G.js} +63 -18
  98. package/dist/npm/element.js +59 -23
  99. package/dist/npm/headless.js +7 -3
  100. package/dist/npm/index.js +3 -3
  101. package/dist/npm/react.js +19 -13
  102. package/dist/npm/svelte.js +29 -14
  103. package/dist/npm/types/adapters/react.d.ts +4 -1
  104. package/dist/npm/types/adapters/svelte.d.ts +4 -1
  105. package/dist/npm/types/adapters/vue.d.ts +35 -2
  106. package/dist/npm/types/anchor/index.d.ts +19 -0
  107. package/dist/npm/types/capture/privacy.d.ts +14 -0
  108. package/dist/npm/types/core/api.d.ts +20 -1
  109. package/dist/npm/types/core/auth.d.ts +47 -14
  110. package/dist/npm/types/core/client.d.ts +60 -4
  111. package/dist/npm/types/core/page-key.d.ts +42 -0
  112. package/dist/npm/types/core/types.d.ts +87 -4
  113. package/dist/npm/types/element.d.ts +17 -7
  114. package/dist/npm/types/headless.d.ts +2 -1
  115. package/dist/npm/types/index.d.ts +16 -6
  116. package/dist/npm/vue.js +45 -11
  117. package/package.json +95 -21
  118. package/dist/npm/chunks/AgentSend-DjFZSC0S.js +0 -64
  119. package/dist/npm/chunks/Checklist-BEz4IZdT.js +0 -259
  120. package/dist/npm/chunks/Composer-D1wbmdjF.js +0 -681
  121. package/dist/npm/chunks/Guest-CtyRy8Kz.js +0 -170
  122. package/dist/npm/chunks/MarkupEditor-CPH4yKx4.js +0 -334
  123. package/dist/npm/chunks/Panel-DSoUAlbQ.js +0 -863
  124. package/dist/npm/chunks/Settings-C_qV4n7J.js +0 -206
  125. package/dist/npm/chunks/Shortcuts-ChnaribX.js +0 -60
  126. package/dist/npm/chunks/StyleEditor-DqZd6C5o.js +0 -44
  127. package/dist/npm/chunks/StylePanel-DMC3riYK.js +0 -199
  128. package/dist/npm/chunks/TaskFields-BfjjllMx.js +0 -272
  129. package/dist/npm/chunks/ThreadCard-DmKAelSL.js +0 -1026
  130. package/dist/npm/chunks/Viewer-mw69qSI5.js +0 -110
  131. package/dist/npm/chunks/card-bits-C7bIk5KX.js +0 -126
  132. package/dist/npm/chunks/confetti-DKeKR7-6.js +0 -41
  133. package/dist/npm/chunks/drafts-CpQdHhcK.js +0 -51
  134. package/dist/npm/chunks/extension-Gvei3opb.js +0 -54
  135. package/dist/npm/chunks/i18n-DAJGndZ2.js +0 -904
  136. package/dist/npm/chunks/live-MvvBdoGd.js +0 -34
  137. package/dist/npm/chunks/report-DoDVi1qT.js +0 -28
  138. package/dist/npm/chunks/src-C_oUnL0i.js +0 -150
  139. package/dist/npm/chunks/start-C5-rebEU.js +0 -1783
  140. package/dist/npm/chunks/upload-CzPAjktW.js +0 -42
  141. package/dist/npm/chunks/uploads-tpLjiJdH.js +0 -541
@@ -1,170 +0,0 @@
1
- import { p as e } from "./client-dZeNdizE.js";
2
- import { f as t, l as n, m as r, s as i, u as a } from "./i18n-DAJGndZ2.js";
3
- import { r as o } from "./card-bits-C7bIk5KX.js";
4
- import { c as s, d as c, n as l } from "./start-C5-rebEU.js";
5
- //#endregion
6
- //#region src/ui/Guest.tsx
7
- l(".ck-verify-text{margin:0 0 12px;line-height:1.5}.ck-code{font-family:var(--ck-mono);letter-spacing:.32em;text-align:center;height:46px;font-size:20px}.ck-verify-text{text-wrap:pretty}");
8
- async function u(t, n) {
9
- try {
10
- let e = await t.api.request("/guest/start", {
11
- method: "POST",
12
- anonymous: !0,
13
- body: {
14
- client_id: t.options.project,
15
- share: n.share,
16
- name: n.name.trim(),
17
- email: n.email.trim()
18
- }
19
- }), r = Date.parse(e.pending_session.expires_at);
20
- return t.auth.setPending({
21
- token: e.access_token,
22
- email: e.pending_session.email,
23
- expiresAt: Number.isFinite(r) ? r : Date.now() + e.expires_in * 1e3
24
- }), "started";
25
- } catch (t) {
26
- if (t instanceof e && t.code === "origin_not_allowed") return "popup";
27
- throw t instanceof e && (t.code === "share_expired" || t.status === 410 || t.errors?.share) ? new e(410, "share_expired", i("shareExpired")) : t;
28
- }
29
- }
30
- function d({ client: l, email: u, onDone: d, onDifferentEmail: m, onClose: h }) {
31
- let [g, _] = r(""), [v, y] = r(!1), [b, x] = r(null), [S, C] = r(null), w = t(null);
32
- a(() => w.current?.focus({ preventScroll: !0 }), []);
33
- let [T, E] = r(f);
34
- a(() => {
35
- if (T <= 0) return;
36
- let e = setTimeout(() => E((e) => e - 1), 1e3);
37
- return () => clearTimeout(e);
38
- }, [T]);
39
- let D = async (t = g) => {
40
- if (/^\d{6}$/.test(t) && !v) {
41
- y(!0), x(null);
42
- try {
43
- let e = await l.api.request("/guest/verify", {
44
- method: "POST",
45
- body: { code: t }
46
- });
47
- l.auth.adopt(e), await l.loadSession().catch(() => null), d(e.published_thread_ids ?? []);
48
- } catch (t) {
49
- if ((t instanceof e ? t.status : 0) === 422) return _(""), w.current?.focus({ preventScroll: !0 }), x({
50
- text: i("verifyWrong"),
51
- tone: "warning"
52
- });
53
- let n = p(t);
54
- n && (l.auth.setPending(null), C(n === "expired" ? "again" : "stop")), x({
55
- text: n ? i(n === "link" ? "verifyLinkExpired" : n === "removed" ? "verifyRemoved" : "verifyExpired") : s(t),
56
- tone: "warning"
57
- });
58
- } finally {
59
- y(!1);
60
- }
61
- }
62
- }, O = async () => {
63
- try {
64
- await l.api.request("/guest/resend", { method: "POST" }), x({ text: i("verifyResent") }), E(f);
65
- } catch (t) {
66
- x({
67
- text: t instanceof e && t.status === 429 ? i("verifyWait") : i("errorGeneric"),
68
- tone: "warning"
69
- });
70
- }
71
- };
72
- return /* @__PURE__ */ n("div", {
73
- class: "ck-card",
74
- style: o({
75
- x: innerWidth / 2 - 190,
76
- y: 80
77
- }),
78
- role: "dialog",
79
- "aria-labelledby": "ck-verify-title",
80
- "data-commentkit-ui": !0,
81
- onKeyDown: (e) => e.key === "Escape" && h(),
82
- children: [
83
- /* @__PURE__ */ n("div", {
84
- class: "ck-card-head",
85
- children: [/* @__PURE__ */ n("h2", {
86
- class: "ck-card-title",
87
- id: "ck-verify-title",
88
- children: i("verifyTitle")
89
- }), /* @__PURE__ */ n("button", {
90
- class: "ck-ghost",
91
- "aria-label": i("close"),
92
- onClick: h,
93
- children: /* @__PURE__ */ n(c, { name: "close" })
94
- })]
95
- }),
96
- /* @__PURE__ */ n("div", {
97
- class: "ck-card-body",
98
- children: [
99
- /* @__PURE__ */ n("p", {
100
- class: "ck-verify-text",
101
- children: i("verifyBody", { email: u })
102
- }),
103
- /* @__PURE__ */ n("label", {
104
- class: "ck-field",
105
- children: [/* @__PURE__ */ n("span", { children: i("verifyCode") }), /* @__PURE__ */ n("input", {
106
- ref: w,
107
- class: "ck-input ck-code",
108
- inputMode: "numeric",
109
- autoComplete: "one-time-code",
110
- pattern: "[0-9]*",
111
- maxLength: 6,
112
- value: g,
113
- onInput: (e) => {
114
- let t = e.target.value.replace(/\D/g, "").slice(0, 6);
115
- _(t), b?.tone && x(null), t.length === 6 && t !== g && D(t);
116
- },
117
- onKeyDown: (e) => {
118
- e.stopPropagation(), e.key === "Enter" && D(), e.key === "Escape" && h();
119
- }
120
- })]
121
- }),
122
- b ? /* @__PURE__ */ n("div", {
123
- class: "ck-note",
124
- role: b.tone ? "alert" : "status",
125
- "data-tone": b.tone,
126
- children: b.text
127
- }) : null,
128
- S ? null : /* @__PURE__ */ n("div", {
129
- class: "ck-actions",
130
- children: [/* @__PURE__ */ n("button", {
131
- class: "ck-chip",
132
- disabled: T > 0,
133
- onClick: () => void O(),
134
- children: T > 0 ? i("verifyResendIn", { n: T }) : i("verifyResend")
135
- }), /* @__PURE__ */ n("button", {
136
- class: "ck-chip",
137
- onClick: () => {
138
- l.auth.setPending(null), m();
139
- },
140
- children: i("verifyDifferent")
141
- })]
142
- })
143
- ]
144
- }),
145
- /* @__PURE__ */ n("div", {
146
- class: "ck-card-foot",
147
- children: [/* @__PURE__ */ n("span", { class: "ck-spacer" }), S === "again" ? /* @__PURE__ */ n("button", {
148
- class: "ck-btn ck-primary",
149
- onClick: m,
150
- children: i("writeAgain")
151
- }) : S === "stop" ? /* @__PURE__ */ n("button", {
152
- class: "ck-btn",
153
- onClick: h,
154
- children: i("close")
155
- }) : /* @__PURE__ */ n("button", {
156
- class: "ck-btn ck-primary",
157
- disabled: v || g.length !== 6,
158
- onClick: () => void D(),
159
- children: i(v ? "sending" : "verifyPublish")
160
- })]
161
- })
162
- ]
163
- });
164
- }
165
- var f = 60;
166
- function p(t) {
167
- return t instanceof e ? t.code === "share_expired" || t.status === 410 ? "link" : t.code === "guest_removed" ? "removed" : t.status === 403 ? /\blink\b/i.test(t.message) ? "link" : "removed" : t.status === 409 || t.status === 401 ? "expired" : null : null;
168
- }
169
- //#endregion
170
- export { d as GuestVerify, u as startGuest };
@@ -1,334 +0,0 @@
1
- import { f as e, l as t, m as n, s as r, u as i } from "./i18n-DAJGndZ2.js";
2
- import { m as a, n as o } from "./start-C5-rebEU.js";
3
- //#endregion
4
- //#region src/ui/MarkupEditor.tsx
5
- o(".ck-markup-tools{background:var(--ck-bg);max-width:100%;box-shadow:var(--ck-shadow);border-radius:999px;flex-wrap:wrap;justify-content:center;gap:4px;padding:6px;display:flex}.ck-label-box{z-index:1;background:var(--ck-bg);box-shadow:var(--ck-shadow);border:1px solid #0000;border-radius:12px;align-items:center;gap:6px;padding:6px;display:flex;position:fixed}.ck-markup-tools{align-items:center;gap:2px;padding:4px}.ck-markup-group{align-items:center;gap:2px;padding:0 4px;display:flex}.ck-markup-group+.ck-markup-group{border-inline-start:1px solid var(--ck-hairline);margin-inline-start:4px;padding-inline-start:8px}.ck-tool{width:32px;height:32px;color:var(--ck-text-muted);background:0 0;border:0;border-radius:999px;place-items:center;padding:0;transition:background-color .12s,color .12s,scale .15s ease-out;display:grid}.ck-tool[aria-pressed=true]{background:var(--ck-accent-soft);color:color-mix(in srgb, var(--ck-accent) 70%, var(--ck-text))}.ck-tool:disabled{opacity:.35;cursor:default}.ck-tool:active:not(:disabled),.ck-icon-btn:active:not(:disabled){scale:.96}.ck-tool{width:30px;height:30px}.ck-dot{border-radius:50%;width:14px;height:14px;display:block;box-shadow:0 0 0 1px #00000014}.ck-tool[aria-pressed=true] .ck-dot{box-shadow:0 0 0 2px var(--ck-bg), 0 0 0 3.5px currentColor}.ck-width{gap:8px;width:150px}.ck-width input{min-width:0;accent-color:var(--ck-accent);cursor:pointer;flex:1}.ck-width span{width:30px;color:var(--ck-text-muted);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.ck-btn-group{display:inline-flex}.ck-icon-btn{border:1px solid var(--ck-border);background:var(--ck-bg);width:30px;height:30px;color:var(--ck-text);place-items:center;padding:0;transition:background-color .12s;display:grid}.ck-icon-btn+.ck-icon-btn{margin-inline-start:-1px}.ck-icon-btn:first-child:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:8px;border-bottom-left-radius:8px}.ck-icon-btn:first-child:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-left-radius:8px;border-bottom-left-radius:8px}.ck-icon-btn:first-child:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:8px;border-bottom-right-radius:8px}.ck-icon-btn:first-child:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-right-radius:8px;border-bottom-right-radius:8px}.ck-icon-btn:last-child:not(:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:8px;border-bottom-right-radius:8px}.ck-icon-btn:last-child:not(:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi))){border-top-right-radius:8px;border-bottom-right-radius:8px}.ck-icon-btn:last-child:-webkit-any(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:8px;border-bottom-left-radius:8px}.ck-icon-btn:last-child:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){border-top-left-radius:8px;border-bottom-left-radius:8px}.ck-icon-btn:disabled,.ck-icon-btn[aria-disabled=true]{opacity:.45;cursor:default}.ck-icon-btn.ck-primary{border-color:var(--ck-accent);background:var(--ck-accent);color:var(--ck-accent-ink);position:relative}@media (hover:hover){.ck-icon-btn:hover:not(:disabled):not(.ck-primary){background:var(--ck-bg-hover)}.ck-tool:hover:not(:disabled){background:var(--ck-bg-hover);color:var(--ck-text)}}@media (pointer:coarse){.ck-tool,.ck-icon-btn{width:40px;height:40px}}@media (max-width:520px){.ck-markup-tools{border-radius:16px}}");
6
- var s = /* @__PURE__ */ new WeakSet(), c = [
7
- "pen",
8
- "line",
9
- "rect",
10
- "ellipse",
11
- "arrow",
12
- "blur",
13
- "text"
14
- ], l = [
15
- "#ef4444",
16
- "#f97316",
17
- "#eab308",
18
- "#22c55e",
19
- "#3b82f6",
20
- "#8b5cf6",
21
- "#ec4899"
22
- ], u = [
23
- "color_red",
24
- "color_orange",
25
- "color_yellow",
26
- "color_green",
27
- "color_blue",
28
- "color_purple",
29
- "color_pink"
30
- ], d = {
31
- arrow: "M5 19L19 5M10 5h9v9",
32
- line: "M5 19L19 5",
33
- rect: "M5 6h14v12H5z",
34
- ellipse: "M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16z",
35
- pen: "M4 20l4-1 11-11-3-3L5 16z",
36
- blur: "M4 4h4v4H4zM10 4h4v4h-4zM16 4h4v4h-4zM4 10h4v4H4zM16 10h4v4h-4zM4 16h4v4H4zM10 16h4v4h-4zM16 16h4v4h-4zM10 10h4v4h-4z",
37
- text: "M5 6V5h14v1M12 5v14M9 19h6"
38
- }, f = {
39
- undo: "M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",
40
- redo: "M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",
41
- clear: "M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3",
42
- cancel: "M6 6l12 12M18 6L6 18",
43
- save: "M5 12l5 5L20 7"
44
- };
45
- function p({ d: e }) {
46
- return /* @__PURE__ */ t("svg", {
47
- width: "16",
48
- height: "16",
49
- viewBox: "0 0 24 24",
50
- fill: "none",
51
- stroke: "currentColor",
52
- "stroke-width": "2",
53
- "stroke-linecap": "round",
54
- "stroke-linejoin": "round",
55
- "aria-hidden": "true",
56
- children: /* @__PURE__ */ t("path", { d: e })
57
- });
58
- }
59
- function m({ image: o, onDone: m, onCancel: v }) {
60
- let y = e(null), [b, x] = n(null), [S, C] = n("pen"), [w, T] = n(l[0]), [E, D] = n(3), [O, k] = n({
61
- steps: [[]],
62
- at: 0
63
- }), A = O.steps[O.at], j = (e) => k((t) => ({
64
- steps: [...t.steps.slice(0, t.at + 1), e],
65
- at: t.at + 1
66
- })), M = () => k((e) => ({
67
- ...e,
68
- at: Math.max(0, e.at - 1)
69
- })), N = () => k((e) => ({
70
- ...e,
71
- at: Math.min(e.steps.length - 1, e.at + 1)
72
- })), P = e(null), [F, I] = n(null), L = e(null), R = e(null);
73
- i(() => (L.current ?? R.current)?.focus({ preventScroll: !0 }), [!!F]);
74
- let z = () => {
75
- let e = F?.text.trim().slice(0, 500);
76
- F && e && j([...A, {
77
- tool: "text",
78
- color: w,
79
- points: [F.x, F.y],
80
- text: e,
81
- width: h(y.current, E)
82
- }]), R.current?.focus({ preventScroll: !0 }), I(null);
83
- };
84
- i(() => {
85
- let e = !0, t = null;
86
- return createImageBitmap(o).then((n) => e ? x(t = n) : n.close()), () => {
87
- if (e = !1, t) {
88
- let e = t;
89
- x((t) => t === e ? null : t), s.add(e), e.close();
90
- }
91
- };
92
- }, [o]), i(() => B(), [b, A]);
93
- let B = (e) => {
94
- let t = y.current;
95
- if (!t || !b || s.has(b)) return;
96
- (t.width !== b.width || t.height !== b.height) && (t.width = b.width, t.height = b.height);
97
- let n = t.getContext("2d");
98
- n.clearRect(0, 0, t.width, t.height), n.drawImage(b, 0, 0);
99
- for (let t of e ? [...A, e] : A) _(n, t, b);
100
- }, V = (e) => {
101
- let t = y.current, n = t.getBoundingClientRect();
102
- return [Math.round((e.clientX - n.left) / n.width * t.width), Math.round((e.clientY - n.top) / n.height * t.height)];
103
- }, H = (e) => {
104
- let [t, n] = V(e);
105
- S === "text" ? (e.preventDefault(), z(), I({
106
- x: t,
107
- y: n,
108
- left: Math.min(e.clientX, innerWidth - 240),
109
- top: Math.max(8, e.clientY - 18),
110
- text: ""
111
- })) : (P.current = {
112
- tool: S,
113
- color: w,
114
- points: [
115
- t,
116
- n,
117
- t,
118
- n
119
- ],
120
- width: h(y.current, E)
121
- }, y.current?.setPointerCapture(e.pointerId));
122
- }, U = (e) => {
123
- let t = P.current;
124
- if (!t?.points) return;
125
- let [n, r] = V(e);
126
- t.tool === "pen" ? t.points.length < 4e3 && t.points.push(n, r) : (t.points[2] = n, t.points[3] = r), B(t);
127
- }, W = () => {
128
- P.current && j([...A, P.current]), P.current = null;
129
- }, G = () => {
130
- let e = F?.text.trim().slice(0, 500), t = F && e ? {
131
- tool: "text",
132
- color: w,
133
- points: [F.x, F.y],
134
- text: e,
135
- width: h(y.current, E)
136
- } : null;
137
- t && B(t), y.current?.toBlob((e) => e && m(e, t ? [...A, t] : A), "image/webp", .88);
138
- };
139
- return /* @__PURE__ */ t("div", {
140
- class: "ck-markup",
141
- ref: R,
142
- tabIndex: -1,
143
- role: "dialog",
144
- "aria-label": r("markup"),
145
- "data-commentkit-ui": !0,
146
- onKeyDown: (e) => {
147
- if ((e.metaKey || e.ctrlKey) && !F && (e.key.toLowerCase() === "z" || e.key.toLowerCase() === "y")) return e.preventDefault(), e.stopPropagation(), e.key.toLowerCase() === "y" || e.shiftKey ? N() : M();
148
- e.key === "Escape" && (e.stopPropagation(), F ? (R.current?.focus({ preventScroll: !0 }), I(null)) : v());
149
- },
150
- children: [
151
- /* @__PURE__ */ t("div", {
152
- class: "ck-markup-tools",
153
- role: "toolbar",
154
- "aria-label": r("markup"),
155
- children: [
156
- /* @__PURE__ */ t("div", {
157
- class: "ck-markup-group",
158
- role: "group",
159
- "aria-label": r("markupTools"),
160
- children: c.map((e) => /* @__PURE__ */ t("button", {
161
- class: "ck-tool",
162
- "aria-pressed": S === e,
163
- "aria-label": r(`tool_${e}`),
164
- title: r(`tool_${e}`),
165
- onClick: () => C(e),
166
- children: /* @__PURE__ */ t(p, { d: d[e] })
167
- }))
168
- }),
169
- /* @__PURE__ */ t("div", {
170
- class: "ck-markup-group",
171
- role: "group",
172
- "aria-label": r("markupColors"),
173
- children: l.map((e, n) => /* @__PURE__ */ t("button", {
174
- class: "ck-tool",
175
- "aria-pressed": w === e,
176
- "aria-label": r(u[n]),
177
- title: r(u[n]),
178
- onClick: () => T(e),
179
- children: /* @__PURE__ */ t("span", {
180
- class: "ck-dot",
181
- style: { background: e }
182
- })
183
- }))
184
- }),
185
- /* @__PURE__ */ t("label", {
186
- class: "ck-markup-group ck-width",
187
- children: [/* @__PURE__ */ t("input", {
188
- type: "range",
189
- min: 1,
190
- max: 12,
191
- step: 1,
192
- value: E,
193
- "aria-label": r("markupSize"),
194
- onInput: (e) => D(Number(e.target.value))
195
- }), /* @__PURE__ */ t("span", { children: [E, "px"] })]
196
- }),
197
- /* @__PURE__ */ t("div", {
198
- class: "ck-markup-group",
199
- role: "group",
200
- "aria-label": r("markupHistory"),
201
- children: /* @__PURE__ */ t("span", {
202
- class: "ck-btn-group",
203
- children: [
204
- /* @__PURE__ */ t("button", {
205
- class: "ck-icon-btn",
206
- disabled: O.at === 0,
207
- "aria-label": r("undo"),
208
- title: `${r("undo")} (${g()} Z)`,
209
- "aria-keyshortcuts": "Meta+Z",
210
- onClick: M,
211
- children: /* @__PURE__ */ t(p, { d: f.undo })
212
- }),
213
- /* @__PURE__ */ t("button", {
214
- class: "ck-icon-btn",
215
- disabled: O.at === O.steps.length - 1,
216
- "aria-label": r("redo"),
217
- title: `${r("redo")} (${g()} Shift Z)`,
218
- "aria-keyshortcuts": "Meta+Shift+Z",
219
- onClick: N,
220
- children: /* @__PURE__ */ t(p, { d: f.redo })
221
- }),
222
- /* @__PURE__ */ t("button", {
223
- class: "ck-icon-btn",
224
- disabled: !A.length,
225
- "aria-label": r("clearAll"),
226
- title: r("clearAll"),
227
- onClick: () => j([]),
228
- children: /* @__PURE__ */ t(p, { d: f.clear })
229
- })
230
- ]
231
- })
232
- }),
233
- /* @__PURE__ */ t("div", {
234
- class: "ck-markup-group",
235
- children: /* @__PURE__ */ t("span", {
236
- class: "ck-btn-group",
237
- children: [/* @__PURE__ */ t("button", {
238
- class: "ck-icon-btn",
239
- "aria-label": r("cancel"),
240
- title: `${r("cancel")} (Esc)`,
241
- onClick: v,
242
- children: /* @__PURE__ */ t(p, { d: f.cancel })
243
- }), /* @__PURE__ */ t("button", {
244
- class: "ck-icon-btn ck-primary",
245
- "aria-disabled": !A.length && !F?.text.trim() || void 0,
246
- "aria-label": r("markupDone"),
247
- title: !A.length && !F?.text.trim() ? r("markupEmpty") : r("markupDone"),
248
- onClick: () => (A.length || F?.text.trim()) && G(),
249
- children: /* @__PURE__ */ t(p, { d: f.save })
250
- })]
251
- })
252
- })
253
- ]
254
- }),
255
- /* @__PURE__ */ t("canvas", {
256
- ref: y,
257
- onPointerDown: H,
258
- onPointerMove: U,
259
- onPointerUp: W
260
- }),
261
- F ? /* @__PURE__ */ t("div", {
262
- class: "ck-label-box",
263
- style: a(F.left, F.top),
264
- children: [/* @__PURE__ */ t("input", {
265
- ref: L,
266
- class: "ck-input",
267
- maxLength: 500,
268
- value: F.text,
269
- placeholder: r("markupTextPrompt"),
270
- "aria-label": r("markupTextPrompt"),
271
- style: { color: w },
272
- onInput: (e) => I({
273
- ...F,
274
- text: e.target.value
275
- }),
276
- onKeyDown: (e) => {
277
- e.key === "Enter" && (e.preventDefault(), z());
278
- }
279
- }), /* @__PURE__ */ t("button", {
280
- class: "ck-chip ck-primary",
281
- onMouseDown: (e) => e.preventDefault(),
282
- onClick: z,
283
- children: r("markupTextAdd")
284
- })]
285
- }) : null
286
- ]
287
- });
288
- }
289
- function h(e, t) {
290
- let n = e?.getBoundingClientRect().width || e?.width || 1;
291
- return Math.max(1, Math.min(64, Math.round(t * ((e?.width ?? n) / n))));
292
- }
293
- var g = () => /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl";
294
- function _(e, t, n) {
295
- let r = t.points ?? [], i = t.width ?? Math.max(3, Math.round(n.width / 300));
296
- e.save(), e.strokeStyle = e.fillStyle = t.color ?? "#ff3b30", e.lineWidth = i, e.lineCap = e.lineJoin = "round";
297
- let [a = 0, o = 0, s = 0, c = 0] = r;
298
- switch (t.tool) {
299
- case "rect":
300
- e.strokeRect(Math.min(a, s), Math.min(o, c), Math.abs(s - a), Math.abs(c - o));
301
- break;
302
- case "ellipse":
303
- e.beginPath(), e.ellipse((a + s) / 2, (o + c) / 2, Math.abs(s - a) / 2, Math.abs(c - o) / 2, 0, 0, Math.PI * 2), e.stroke();
304
- break;
305
- case "line":
306
- e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke();
307
- break;
308
- case "arrow": {
309
- let t = Math.atan2(c - o, s - a), n = i * 5;
310
- e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke(), e.beginPath(), e.moveTo(s, c), e.lineTo(s - n * Math.cos(t - .45), c - n * Math.sin(t - .45)), e.lineTo(s - n * Math.cos(t + .45), c - n * Math.sin(t + .45)), e.closePath(), e.fill();
311
- break;
312
- }
313
- case "pen":
314
- e.beginPath();
315
- for (let t = 0; t < r.length; t += 2) (t ? e.lineTo : e.moveTo).call(e, r[t], r[t + 1]);
316
- e.stroke();
317
- break;
318
- case "blur": {
319
- let t = Math.min(a, s), n = Math.min(o, c), r = Math.abs(s - a), i = Math.abs(c - o);
320
- if (r > 2 && i > 2) {
321
- let a = Math.max(8, Math.round(Math.min(r, i) / 6)), o = e.getImageData(t, n, r, i);
322
- for (let s = 0; s < i; s += a) for (let i = 0; i < r; i += a) {
323
- let c = (s * r + i) * 4;
324
- e.fillStyle = `rgb(${o.data[c]},${o.data[c + 1]},${o.data[c + 2]})`, e.fillRect(t + i, n + s, a, a);
325
- }
326
- }
327
- break;
328
- }
329
- case "text": e.font = `bold ${Math.max(14, i * 6)}px system-ui, sans-serif`, e.lineWidth = i * 1.5, e.strokeStyle = "#ffffff", e.strokeText(t.text ?? "", a, o), e.fillText(t.text ?? "", a, o);
330
- }
331
- e.restore();
332
- }
333
- //#endregion
334
- export { m as MarkupEditor };