@commentkit/comment-kit 1.6.0 → 2.0.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 +298 -590
- package/README.md +421 -145
- package/SECURITY.md +47 -46
- package/dist/node/THIRD_PARTY_NOTICES.txt +56 -0
- package/dist/node/browser.js +17 -0
- package/dist/node/cli/api.js +226 -0
- package/dist/node/cli/bin.js +18 -0
- package/dist/node/cli/credentials.js +268 -0
- package/dist/node/cli/doctor.js +789 -0
- package/dist/node/cli/format.js +54 -0
- package/dist/node/cli/init.js +686 -0
- package/dist/node/cli/main.js +537 -0
- package/dist/node/cli/mcp.js +295 -0
- package/dist/node/cli/open.js +20 -0
- package/dist/node/plugins/astro-B5y1Gtbf.js +31 -0
- package/dist/node/plugins/astro.js +26 -0
- package/dist/node/plugins/git-BIXLbL3f.js +92 -0
- package/dist/node/plugins/jsx-Bg4BdSph.js +7958 -0
- package/dist/node/plugins/next.js +48 -0
- package/dist/node/plugins/options-THop1K92.js +71 -0
- package/dist/node/plugins/transform-CKiAuSbk.js +1155 -0
- package/dist/node/plugins/vite-BdAYUW10.js +74 -0
- package/dist/node/plugins/vite.js +1 -0
- package/dist/node/plugins/webpack-R2U2DLlY.js +35 -0
- package/dist/node/plugins/webpack-loader.cjs +21 -0
- package/dist/node/plugins/webpack-loader.js +18 -0
- package/dist/node/plugins/webpack.js +1 -0
- package/dist/node/shared/dashboard-places.js +33 -0
- package/dist/node/shared/endpoint.js +26 -0
- package/dist/node/shared/format.js +63 -0
- package/dist/node/types/astro.d.ts +11 -0
- package/dist/node/types/next.d.ts +34 -0
- package/dist/node/types/options.d.ts +59 -0
- package/dist/node/types/vite.d.ts +11 -0
- package/dist/node/types/webpack-loader.d.ts +22 -0
- package/dist/node/types/webpack.d.ts +27 -0
- package/dist/npm/THIRD_PARTY_NOTICES.txt +6 -6
- package/dist/npm/chunks/AgentSend-DOy3jhyF.js +68 -0
- package/dist/npm/chunks/Checklist-CW_SwMpS.js +282 -0
- package/dist/npm/chunks/Composer-Bveq5QrK.js +727 -0
- package/dist/npm/chunks/Guest-7hcN765o.js +270 -0
- package/dist/npm/chunks/MarkupEditor-6bJGpWGO.js +345 -0
- package/dist/npm/chunks/Panel-ChPUB68C.js +1211 -0
- package/dist/npm/chunks/Settings-CB5eEKnf.js +231 -0
- package/dist/npm/chunks/Shortcuts-eAyjJ89P.js +62 -0
- package/dist/npm/chunks/StyleEditor-CZTdAA5c.js +46 -0
- package/dist/npm/chunks/StylePanel-B4pHQUL9.js +199 -0
- package/dist/npm/chunks/TaskFields-C8BX0Sgg.js +289 -0
- package/dist/npm/chunks/ThreadCard-B1EsX3PR.js +1160 -0
- package/dist/npm/chunks/Viewer-DY6zb90M.js +114 -0
- package/dist/npm/chunks/{agent-BDMQtOzH.js → agent-MTQHr9ei.js} +9 -9
- package/dist/npm/chunks/{anchor-BsradQhn.js → anchor-BsQNVkHj.js} +108 -85
- package/dist/npm/chunks/{ar-8tPch6W4.js → ar-L5cQ-NPe.js} +71 -19
- package/dist/npm/chunks/card-bits-CTdrkYn8.js +53 -0
- package/dist/npm/chunks/{client-EFTWxHbJ.js → client-7eVxvg5j.js} +282 -290
- package/dist/npm/chunks/confetti-BIs5s14P.js +49 -0
- package/dist/npm/chunks/context-BuMl7A07.js +48 -0
- package/dist/npm/chunks/context-Cf6khm7A.js +20 -0
- package/dist/npm/chunks/{de-C63897uD.js → de-D0C-v6tP.js} +62 -18
- package/dist/npm/chunks/dialog-DvdIkCW0.js +3 -0
- package/dist/npm/chunks/dpop-0A76OPa9.js +96 -0
- package/dist/npm/chunks/drafts-B0ctr1g9.js +21 -0
- package/dist/npm/chunks/{es-CI2bSpvB.js → es-Bw4Dj9tN.js} +62 -18
- package/dist/npm/chunks/extension-DFVOvciD.js +62 -0
- package/dist/npm/chunks/{extension-BST6LH1q.js → extension-SmoH5AA4.js} +20 -12
- package/dist/npm/chunks/files-4lV9YQIX.js +114 -0
- package/dist/npm/chunks/{fr-rsVe-Lqk.js → fr-TkuQaIAa.js} +120 -76
- package/dist/npm/chunks/{hi-cvwbSaWP.js → hi-DXSH2U8d.js} +63 -19
- package/dist/npm/chunks/{i18n-C4v0M-6z.js → i18n-aVSu9TcJ.js} +136 -92
- package/dist/npm/chunks/identify-BGYh2dVo.js +106 -0
- package/dist/npm/chunks/{it-C8tnV0BF.js → it-CiWA_bch.js} +81 -37
- package/dist/npm/chunks/{ja-BWxDfC2f.js → ja-C-QmR3yz.js} +60 -16
- package/dist/npm/chunks/late-words-80_VWt8S.js +14 -0
- package/dist/npm/chunks/live-BExWHzQ7.js +85 -0
- package/dist/npm/chunks/locale-D8Q4Q2Nt.js +26 -0
- package/dist/npm/chunks/{nl-DNQ6eCht.js → nl-CEmZRqjX.js} +63 -19
- package/dist/npm/chunks/page-key-HSY3Lze5.js +62 -0
- package/dist/npm/chunks/{pick-CLyOdjnD.js → pick-B3sR7jtS.js} +45 -44
- package/dist/npm/chunks/pkce-CfZhiNBi.js +8 -0
- package/dist/npm/chunks/placement-BF_HOUDD.js +74 -0
- package/dist/npm/chunks/privacy-BWUGlHw5.js +57 -0
- package/dist/npm/chunks/{pt-BR-CkG7vpU2.js → pt-BR-b-a8sxO8.js} +62 -18
- package/dist/npm/chunks/{realtime-DIo-Wth4.js → realtime-C79zF50C.js} +14 -12
- package/dist/npm/chunks/report-DaVuoRYS.js +44 -0
- package/dist/npm/chunks/show-BoN8AC-F.js +97 -0
- package/dist/npm/chunks/signin-BOWr_WCo.js +75 -0
- package/dist/npm/chunks/{source-CS7C6wJA.js → source-mk3rGBBQ.js} +1 -1
- package/dist/npm/chunks/src-C8rZFyL_.js +215 -0
- package/dist/npm/chunks/start-CV4j78_q.js +1894 -0
- package/dist/npm/chunks/states-b9Bv3Ci7.js +3 -0
- package/dist/npm/chunks/upload-B2mkgMeJ.js +42 -0
- package/dist/npm/chunks/uploads-8AxyRq7g.js +1147 -0
- package/dist/npm/chunks/wrap-DW6EFbVQ.js +69 -0
- package/dist/npm/chunks/{zh-CN-BKuZOLBE.js → zh-CN-JTscW8u8.js} +61 -17
- package/dist/npm/element.js +58 -21
- package/dist/npm/headless.js +7 -3
- package/dist/npm/index.js +3 -3
- package/dist/npm/react.js +18 -11
- package/dist/npm/svelte.js +28 -12
- package/dist/npm/types/adapters/react.d.ts +4 -1
- package/dist/npm/types/adapters/svelte.d.ts +4 -1
- package/dist/npm/types/adapters/vue.d.ts +35 -2
- package/dist/npm/types/anchor/index.d.ts +19 -0
- package/dist/npm/types/capture/privacy.d.ts +14 -0
- package/dist/npm/types/core/api.d.ts +20 -1
- package/dist/npm/types/core/auth.d.ts +40 -21
- package/dist/npm/types/core/client.d.ts +60 -4
- package/dist/npm/types/core/page-key.d.ts +42 -0
- package/dist/npm/types/core/types.d.ts +87 -4
- package/dist/npm/types/element.d.ts +17 -7
- package/dist/npm/types/headless.d.ts +2 -1
- package/dist/npm/types/index.d.ts +16 -6
- package/dist/npm/vue.js +44 -9
- package/package.json +90 -14
- package/dist/npm/chunks/AgentSend-2JPDseOo.js +0 -63
- package/dist/npm/chunks/Checklist-BpDXQebo.js +0 -257
- package/dist/npm/chunks/Composer-CAyj-c8e.js +0 -677
- package/dist/npm/chunks/Guest-ZdFmTcXI.js +0 -187
- package/dist/npm/chunks/MarkupEditor-BFplZwFy.js +0 -332
- package/dist/npm/chunks/Panel-BhZ4XRDR.js +0 -861
- package/dist/npm/chunks/Settings-SPG9EHUZ.js +0 -204
- package/dist/npm/chunks/Shortcuts-C28HVDw6.js +0 -58
- package/dist/npm/chunks/StyleEditor-ByZMtq10.js +0 -43
- package/dist/npm/chunks/StylePanel-Iwhce2tE.js +0 -197
- package/dist/npm/chunks/TaskFields-BsP_fVJg.js +0 -273
- package/dist/npm/chunks/ThreadCard-BzVZdDCb.js +0 -1030
- package/dist/npm/chunks/Viewer-CqtGrdD8.js +0 -108
- package/dist/npm/chunks/card-bits-Bna-g3Py.js +0 -124
- package/dist/npm/chunks/confetti-DTKpwF3O.js +0 -40
- package/dist/npm/chunks/drafts-akdBsOd0.js +0 -50
- package/dist/npm/chunks/extension-D-V3utTm.js +0 -53
- package/dist/npm/chunks/live-BCpJVBeN.js +0 -33
- package/dist/npm/chunks/report-BBrT3r89.js +0 -27
- package/dist/npm/chunks/src-C4FsVoUp.js +0 -148
- package/dist/npm/chunks/start-i9M-r3aH.js +0 -1800
- package/dist/npm/chunks/upload-DSv7EyBD.js +0 -41
- package/dist/npm/chunks/uploads-I01kdqQF.js +0 -1103
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { p as e } from "./client-EFTWxHbJ.js";
|
|
2
|
-
import { f as t, l as n, m as r, n as i, s as a, u as o } from "./i18n-C4v0M-6z.js";
|
|
3
|
-
import { r as s } from "./card-bits-Bna-g3Py.js";
|
|
4
|
-
import { c, f as l, n as u } from "./start-i9M-r3aH.js";
|
|
5
|
-
// src/ui/Guest.tsx
|
|
6
|
-
u(".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}");
|
|
7
|
-
async function d(t, n) {
|
|
8
|
-
try {
|
|
9
|
-
let e = await t.api.request("/guest/start", {
|
|
10
|
-
method: "POST",
|
|
11
|
-
anonymous: !0,
|
|
12
|
-
body: {
|
|
13
|
-
client_id: t.options.project,
|
|
14
|
-
share: n.share,
|
|
15
|
-
name: n.name.trim(),
|
|
16
|
-
email: n.email.trim()
|
|
17
|
-
}
|
|
18
|
-
}), r = Date.parse(e.pending_session.expires_at);
|
|
19
|
-
return t.auth.setPending({
|
|
20
|
-
token: e.access_token,
|
|
21
|
-
email: e.pending_session.email,
|
|
22
|
-
expiresAt: Number.isFinite(r) ? r : Date.now() + e.expires_in * 1e3
|
|
23
|
-
}), "started";
|
|
24
|
-
} catch (t) {
|
|
25
|
-
if (t instanceof e && t.code === "origin_not_allowed") return "popup";
|
|
26
|
-
throw t instanceof e && (t.code === "share_expired" || t.status === 410 || t.errors?.share) ? new e(410, "share_expired", a("shareExpired")) : t;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function f() {
|
|
30
|
-
let e;
|
|
31
|
-
try {
|
|
32
|
-
e = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
33
|
-
} catch {
|
|
34
|
-
e = void 0;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
...e && e.length <= 64 ? { timezone: e } : {},
|
|
38
|
-
locale: i()
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function p({ client: i, email: u, onDone: d, onDifferentEmail: p, onClose: g }) {
|
|
42
|
-
let [_, v] = r(""), [y, b] = r(!1), [x, S] = r(null), [C, w] = r(null), T = t(null);
|
|
43
|
-
o(() => T.current?.focus({ preventScroll: !0 }), []);
|
|
44
|
-
let [E, D] = r(m);
|
|
45
|
-
o(() => {
|
|
46
|
-
if (E <= 0) return;
|
|
47
|
-
let e = setTimeout(() => D((e) => e - 1), 1e3);
|
|
48
|
-
return () => clearTimeout(e);
|
|
49
|
-
}, [E]);
|
|
50
|
-
let O = async (t = _) => {
|
|
51
|
-
if (/^\d{6}$/.test(t) && !y) {
|
|
52
|
-
b(!0), S(null);
|
|
53
|
-
try {
|
|
54
|
-
let e = {
|
|
55
|
-
code: t,
|
|
56
|
-
...f()
|
|
57
|
-
}, n = await i.api.request("/guest/verify", {
|
|
58
|
-
method: "POST",
|
|
59
|
-
body: e
|
|
60
|
-
});
|
|
61
|
-
i.auth.adopt(n), await i.loadSession().catch(() => null), d(n.published_thread_ids ?? []);
|
|
62
|
-
} catch (t) {
|
|
63
|
-
if ((t instanceof e ? t.status : 0) === 422) return v(""), T.current?.focus({ preventScroll: !0 }), S({
|
|
64
|
-
text: a("verifyWrong"),
|
|
65
|
-
tone: "warning"
|
|
66
|
-
});
|
|
67
|
-
let n = h(t);
|
|
68
|
-
n && (i.auth.setPending(null), w(n === "expired" ? "again" : "stop")), S({
|
|
69
|
-
text: n ? a(n === "link" ? "verifyLinkExpired" : n === "removed" ? "verifyRemoved" : "verifyExpired") : c(t),
|
|
70
|
-
tone: "warning"
|
|
71
|
-
});
|
|
72
|
-
} finally {
|
|
73
|
-
b(!1);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, k = async () => {
|
|
77
|
-
try {
|
|
78
|
-
await i.api.request("/guest/resend", { method: "POST" }), S({ text: a("verifyResent") }), D(m);
|
|
79
|
-
} catch (t) {
|
|
80
|
-
S({
|
|
81
|
-
text: t instanceof e && t.status === 429 ? a("verifyWait") : a("errorGeneric"),
|
|
82
|
-
tone: "warning"
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
return /* @__PURE__ */ n("div", {
|
|
87
|
-
class: "ck-card",
|
|
88
|
-
style: s({
|
|
89
|
-
x: innerWidth / 2 - 190,
|
|
90
|
-
y: 80
|
|
91
|
-
}),
|
|
92
|
-
role: "dialog",
|
|
93
|
-
"aria-labelledby": "ck-verify-title",
|
|
94
|
-
"data-commentkit-ui": !0,
|
|
95
|
-
onKeyDown: (e) => e.key === "Escape" && g(),
|
|
96
|
-
children: [
|
|
97
|
-
/* @__PURE__ */ n("div", {
|
|
98
|
-
class: "ck-card-head",
|
|
99
|
-
children: [/* @__PURE__ */ n("h2", {
|
|
100
|
-
class: "ck-card-title",
|
|
101
|
-
id: "ck-verify-title",
|
|
102
|
-
children: a("verifyTitle")
|
|
103
|
-
}), /* @__PURE__ */ n("button", {
|
|
104
|
-
class: "ck-ghost",
|
|
105
|
-
"aria-label": a("close"),
|
|
106
|
-
onClick: g,
|
|
107
|
-
children: /* @__PURE__ */ n(l, { name: "close" })
|
|
108
|
-
})]
|
|
109
|
-
}),
|
|
110
|
-
/* @__PURE__ */ n("div", {
|
|
111
|
-
class: "ck-card-body",
|
|
112
|
-
children: [
|
|
113
|
-
/* @__PURE__ */ n("p", {
|
|
114
|
-
class: "ck-verify-text",
|
|
115
|
-
children: a("verifyBody", { email: u })
|
|
116
|
-
}),
|
|
117
|
-
/* @__PURE__ */ n("p", {
|
|
118
|
-
class: "ck-verify-text",
|
|
119
|
-
children: a("verifyLookFor", { website: i.state.get().config?.project?.name ?? "" })
|
|
120
|
-
}),
|
|
121
|
-
/* @__PURE__ */ n("label", {
|
|
122
|
-
class: "ck-field",
|
|
123
|
-
children: [/* @__PURE__ */ n("span", { children: a("verifyCode") }), /* @__PURE__ */ n("input", {
|
|
124
|
-
ref: T,
|
|
125
|
-
class: "ck-input ck-code",
|
|
126
|
-
inputMode: "numeric",
|
|
127
|
-
autoComplete: "one-time-code",
|
|
128
|
-
pattern: "[0-9]*",
|
|
129
|
-
maxLength: 6,
|
|
130
|
-
value: _,
|
|
131
|
-
onInput: (e) => {
|
|
132
|
-
let t = e.target.value.replace(/\D/g, "").slice(0, 6);
|
|
133
|
-
v(t), x?.tone && S(null), t.length === 6 && t !== _ && O(t);
|
|
134
|
-
},
|
|
135
|
-
onKeyDown: (e) => {
|
|
136
|
-
e.stopPropagation(), e.key === "Enter" && O(), e.key === "Escape" && g();
|
|
137
|
-
}
|
|
138
|
-
})]
|
|
139
|
-
}),
|
|
140
|
-
x ? /* @__PURE__ */ n("div", {
|
|
141
|
-
class: "ck-note",
|
|
142
|
-
role: x.tone ? "alert" : "status",
|
|
143
|
-
"data-tone": x.tone,
|
|
144
|
-
children: x.text
|
|
145
|
-
}) : null,
|
|
146
|
-
C ? null : /* @__PURE__ */ n("div", {
|
|
147
|
-
class: "ck-actions",
|
|
148
|
-
children: [/* @__PURE__ */ n("button", {
|
|
149
|
-
class: "ck-chip",
|
|
150
|
-
disabled: E > 0,
|
|
151
|
-
onClick: () => void k(),
|
|
152
|
-
children: E > 0 ? a("verifyResendIn", { n: E }) : a("verifyResend")
|
|
153
|
-
}), /* @__PURE__ */ n("button", {
|
|
154
|
-
class: "ck-chip",
|
|
155
|
-
onClick: () => {
|
|
156
|
-
i.auth.setPending(null), p();
|
|
157
|
-
},
|
|
158
|
-
children: a("verifyDifferent")
|
|
159
|
-
})]
|
|
160
|
-
})
|
|
161
|
-
]
|
|
162
|
-
}),
|
|
163
|
-
/* @__PURE__ */ n("div", {
|
|
164
|
-
class: "ck-card-foot",
|
|
165
|
-
children: [/* @__PURE__ */ n("span", { class: "ck-spacer" }), C === "again" ? /* @__PURE__ */ n("button", {
|
|
166
|
-
class: "ck-btn ck-primary",
|
|
167
|
-
onClick: p,
|
|
168
|
-
children: a("writeAgain")
|
|
169
|
-
}) : C === "stop" ? /* @__PURE__ */ n("button", {
|
|
170
|
-
class: "ck-btn",
|
|
171
|
-
onClick: g,
|
|
172
|
-
children: a("close")
|
|
173
|
-
}) : /* @__PURE__ */ n("button", {
|
|
174
|
-
class: "ck-btn ck-primary",
|
|
175
|
-
disabled: y || _.length !== 6,
|
|
176
|
-
onClick: () => void O(),
|
|
177
|
-
children: a(y ? "sending" : "verifyPublish")
|
|
178
|
-
})]
|
|
179
|
-
})
|
|
180
|
-
]
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
var m = 60;
|
|
184
|
-
function h(t) {
|
|
185
|
-
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;
|
|
186
|
-
}
|
|
187
|
-
export { p as GuestVerify, d as startGuest };
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { f as e, l as t, m as n, s as r, u as i } from "./i18n-C4v0M-6z.js";
|
|
2
|
-
import { _ as a, n as o } from "./start-i9M-r3aH.js";
|
|
3
|
-
// src/ui/MarkupEditor.tsx
|
|
4
|
-
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}}");
|
|
5
|
-
var s = /* @__PURE__ */ new WeakSet(), c = [
|
|
6
|
-
"pen",
|
|
7
|
-
"line",
|
|
8
|
-
"rect",
|
|
9
|
-
"ellipse",
|
|
10
|
-
"arrow",
|
|
11
|
-
"blur",
|
|
12
|
-
"text"
|
|
13
|
-
], l = [
|
|
14
|
-
"#ef4444",
|
|
15
|
-
"#f97316",
|
|
16
|
-
"#eab308",
|
|
17
|
-
"#22c55e",
|
|
18
|
-
"#3b82f6",
|
|
19
|
-
"#8b5cf6",
|
|
20
|
-
"#ec4899"
|
|
21
|
-
], u = [
|
|
22
|
-
"color_red",
|
|
23
|
-
"color_orange",
|
|
24
|
-
"color_yellow",
|
|
25
|
-
"color_green",
|
|
26
|
-
"color_blue",
|
|
27
|
-
"color_purple",
|
|
28
|
-
"color_pink"
|
|
29
|
-
], d = {
|
|
30
|
-
arrow: "M5 19L19 5M10 5h9v9",
|
|
31
|
-
line: "M5 19L19 5",
|
|
32
|
-
rect: "M5 6h14v12H5z",
|
|
33
|
-
ellipse: "M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16z",
|
|
34
|
-
pen: "M4 20l4-1 11-11-3-3L5 16z",
|
|
35
|
-
blur: "M4 4h4v4H4zM10 4h4v4h-4zM16 4h4v4h-4zM4 10h4v4H4zM16 10h4v4h-4zM4 16h4v4H4zM10 16h4v4h-4zM16 16h4v4h-4zM10 10h4v4h-4z",
|
|
36
|
-
text: "M5 6V5h14v1M12 5v14M9 19h6"
|
|
37
|
-
}, f = {
|
|
38
|
-
undo: "M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",
|
|
39
|
-
redo: "M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",
|
|
40
|
-
clear: "M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3",
|
|
41
|
-
cancel: "M6 6l12 12M18 6L6 18",
|
|
42
|
-
save: "M5 12l5 5L20 7"
|
|
43
|
-
};
|
|
44
|
-
function p({ d: e }) {
|
|
45
|
-
return /* @__PURE__ */ t("svg", {
|
|
46
|
-
width: "16",
|
|
47
|
-
height: "16",
|
|
48
|
-
viewBox: "0 0 24 24",
|
|
49
|
-
fill: "none",
|
|
50
|
-
stroke: "currentColor",
|
|
51
|
-
"stroke-width": "2",
|
|
52
|
-
"stroke-linecap": "round",
|
|
53
|
-
"stroke-linejoin": "round",
|
|
54
|
-
"aria-hidden": "true",
|
|
55
|
-
children: /* @__PURE__ */ t("path", { d: e })
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function m({ image: o, onDone: m, onCancel: v }) {
|
|
59
|
-
let y = e(null), [b, x] = n(null), [S, C] = n("pen"), [w, T] = n(l[0]), [E, D] = n(3), [O, k] = n({
|
|
60
|
-
steps: [[]],
|
|
61
|
-
at: 0
|
|
62
|
-
}), A = O.steps[O.at], j = (e) => k((t) => ({
|
|
63
|
-
steps: [...t.steps.slice(0, t.at + 1), e],
|
|
64
|
-
at: t.at + 1
|
|
65
|
-
})), M = () => k((e) => ({
|
|
66
|
-
...e,
|
|
67
|
-
at: Math.max(0, e.at - 1)
|
|
68
|
-
})), N = () => k((e) => ({
|
|
69
|
-
...e,
|
|
70
|
-
at: Math.min(e.steps.length - 1, e.at + 1)
|
|
71
|
-
})), P = e(null), [F, I] = n(null), L = e(null), R = e(null);
|
|
72
|
-
i(() => (L.current ?? R.current)?.focus({ preventScroll: !0 }), [!!F]);
|
|
73
|
-
let z = () => {
|
|
74
|
-
let e = F?.text.trim().slice(0, 500);
|
|
75
|
-
F && e && j([...A, {
|
|
76
|
-
tool: "text",
|
|
77
|
-
color: w,
|
|
78
|
-
points: [F.x, F.y],
|
|
79
|
-
text: e,
|
|
80
|
-
width: h(y.current, E)
|
|
81
|
-
}]), R.current?.focus({ preventScroll: !0 }), I(null);
|
|
82
|
-
};
|
|
83
|
-
i(() => {
|
|
84
|
-
let e = !0, t = null;
|
|
85
|
-
return createImageBitmap(o).then((n) => e ? x(t = n) : n.close()), () => {
|
|
86
|
-
if (e = !1, t) {
|
|
87
|
-
let e = t;
|
|
88
|
-
x((t) => t === e ? null : t), s.add(e), e.close();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}, [o]), i(() => B(), [b, A]);
|
|
92
|
-
let B = (e) => {
|
|
93
|
-
let t = y.current;
|
|
94
|
-
if (!t || !b || s.has(b)) return;
|
|
95
|
-
(t.width !== b.width || t.height !== b.height) && (t.width = b.width, t.height = b.height);
|
|
96
|
-
let n = t.getContext("2d");
|
|
97
|
-
n.clearRect(0, 0, t.width, t.height), n.drawImage(b, 0, 0);
|
|
98
|
-
for (let t of e ? [...A, e] : A) _(n, t, b);
|
|
99
|
-
}, V = (e) => {
|
|
100
|
-
let t = y.current, n = t.getBoundingClientRect();
|
|
101
|
-
return [Math.round((e.clientX - n.left) / n.width * t.width), Math.round((e.clientY - n.top) / n.height * t.height)];
|
|
102
|
-
}, H = (e) => {
|
|
103
|
-
let [t, n] = V(e);
|
|
104
|
-
S === "text" ? (e.preventDefault(), z(), I({
|
|
105
|
-
x: t,
|
|
106
|
-
y: n,
|
|
107
|
-
left: Math.min(e.clientX, innerWidth - 240),
|
|
108
|
-
top: Math.max(8, e.clientY - 18),
|
|
109
|
-
text: ""
|
|
110
|
-
})) : (P.current = {
|
|
111
|
-
tool: S,
|
|
112
|
-
color: w,
|
|
113
|
-
points: [
|
|
114
|
-
t,
|
|
115
|
-
n,
|
|
116
|
-
t,
|
|
117
|
-
n
|
|
118
|
-
],
|
|
119
|
-
width: h(y.current, E)
|
|
120
|
-
}, y.current?.setPointerCapture(e.pointerId));
|
|
121
|
-
}, U = (e) => {
|
|
122
|
-
let t = P.current;
|
|
123
|
-
if (!t?.points) return;
|
|
124
|
-
let [n, r] = V(e);
|
|
125
|
-
t.tool === "pen" ? t.points.length < 4e3 && t.points.push(n, r) : (t.points[2] = n, t.points[3] = r), B(t);
|
|
126
|
-
}, W = () => {
|
|
127
|
-
P.current && j([...A, P.current]), P.current = null;
|
|
128
|
-
}, G = () => {
|
|
129
|
-
let e = F?.text.trim().slice(0, 500), t = F && e ? {
|
|
130
|
-
tool: "text",
|
|
131
|
-
color: w,
|
|
132
|
-
points: [F.x, F.y],
|
|
133
|
-
text: e,
|
|
134
|
-
width: h(y.current, E)
|
|
135
|
-
} : null;
|
|
136
|
-
t && B(t), y.current?.toBlob((e) => e && m(e, t ? [...A, t] : A), "image/webp", .88);
|
|
137
|
-
};
|
|
138
|
-
return /* @__PURE__ */ t("div", {
|
|
139
|
-
class: "ck-markup",
|
|
140
|
-
ref: R,
|
|
141
|
-
tabIndex: -1,
|
|
142
|
-
role: "dialog",
|
|
143
|
-
"aria-label": r("markup"),
|
|
144
|
-
"data-commentkit-ui": !0,
|
|
145
|
-
onKeyDown: (e) => {
|
|
146
|
-
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();
|
|
147
|
-
e.key === "Escape" && (e.stopPropagation(), F ? (R.current?.focus({ preventScroll: !0 }), I(null)) : v());
|
|
148
|
-
},
|
|
149
|
-
children: [
|
|
150
|
-
/* @__PURE__ */ t("div", {
|
|
151
|
-
class: "ck-markup-tools",
|
|
152
|
-
role: "toolbar",
|
|
153
|
-
"aria-label": r("markup"),
|
|
154
|
-
children: [
|
|
155
|
-
/* @__PURE__ */ t("div", {
|
|
156
|
-
class: "ck-markup-group",
|
|
157
|
-
role: "group",
|
|
158
|
-
"aria-label": r("markupTools"),
|
|
159
|
-
children: c.map((e) => /* @__PURE__ */ t("button", {
|
|
160
|
-
class: "ck-tool",
|
|
161
|
-
"aria-pressed": S === e,
|
|
162
|
-
"aria-label": r(`tool_${e}`),
|
|
163
|
-
title: r(`tool_${e}`),
|
|
164
|
-
onClick: () => C(e),
|
|
165
|
-
children: /* @__PURE__ */ t(p, { d: d[e] })
|
|
166
|
-
}))
|
|
167
|
-
}),
|
|
168
|
-
/* @__PURE__ */ t("div", {
|
|
169
|
-
class: "ck-markup-group",
|
|
170
|
-
role: "group",
|
|
171
|
-
"aria-label": r("markupColors"),
|
|
172
|
-
children: l.map((e, n) => /* @__PURE__ */ t("button", {
|
|
173
|
-
class: "ck-tool",
|
|
174
|
-
"aria-pressed": w === e,
|
|
175
|
-
"aria-label": r(u[n]),
|
|
176
|
-
title: r(u[n]),
|
|
177
|
-
onClick: () => T(e),
|
|
178
|
-
children: /* @__PURE__ */ t("span", {
|
|
179
|
-
class: "ck-dot",
|
|
180
|
-
style: { background: e }
|
|
181
|
-
})
|
|
182
|
-
}))
|
|
183
|
-
}),
|
|
184
|
-
/* @__PURE__ */ t("label", {
|
|
185
|
-
class: "ck-markup-group ck-width",
|
|
186
|
-
children: [/* @__PURE__ */ t("input", {
|
|
187
|
-
type: "range",
|
|
188
|
-
min: 1,
|
|
189
|
-
max: 12,
|
|
190
|
-
step: 1,
|
|
191
|
-
value: E,
|
|
192
|
-
"aria-label": r("markupSize"),
|
|
193
|
-
onInput: (e) => D(Number(e.target.value))
|
|
194
|
-
}), /* @__PURE__ */ t("span", { children: [E, "px"] })]
|
|
195
|
-
}),
|
|
196
|
-
/* @__PURE__ */ t("div", {
|
|
197
|
-
class: "ck-markup-group",
|
|
198
|
-
role: "group",
|
|
199
|
-
"aria-label": r("markupHistory"),
|
|
200
|
-
children: /* @__PURE__ */ t("span", {
|
|
201
|
-
class: "ck-btn-group",
|
|
202
|
-
children: [
|
|
203
|
-
/* @__PURE__ */ t("button", {
|
|
204
|
-
class: "ck-icon-btn",
|
|
205
|
-
disabled: O.at === 0,
|
|
206
|
-
"aria-label": r("undo"),
|
|
207
|
-
title: `${r("undo")} (${g()} Z)`,
|
|
208
|
-
"aria-keyshortcuts": "Meta+Z",
|
|
209
|
-
onClick: M,
|
|
210
|
-
children: /* @__PURE__ */ t(p, { d: f.undo })
|
|
211
|
-
}),
|
|
212
|
-
/* @__PURE__ */ t("button", {
|
|
213
|
-
class: "ck-icon-btn",
|
|
214
|
-
disabled: O.at === O.steps.length - 1,
|
|
215
|
-
"aria-label": r("redo"),
|
|
216
|
-
title: `${r("redo")} (${g()} Shift Z)`,
|
|
217
|
-
"aria-keyshortcuts": "Meta+Shift+Z",
|
|
218
|
-
onClick: N,
|
|
219
|
-
children: /* @__PURE__ */ t(p, { d: f.redo })
|
|
220
|
-
}),
|
|
221
|
-
/* @__PURE__ */ t("button", {
|
|
222
|
-
class: "ck-icon-btn",
|
|
223
|
-
disabled: !A.length,
|
|
224
|
-
"aria-label": r("clearAll"),
|
|
225
|
-
title: r("clearAll"),
|
|
226
|
-
onClick: () => j([]),
|
|
227
|
-
children: /* @__PURE__ */ t(p, { d: f.clear })
|
|
228
|
-
})
|
|
229
|
-
]
|
|
230
|
-
})
|
|
231
|
-
}),
|
|
232
|
-
/* @__PURE__ */ t("div", {
|
|
233
|
-
class: "ck-markup-group",
|
|
234
|
-
children: /* @__PURE__ */ t("span", {
|
|
235
|
-
class: "ck-btn-group",
|
|
236
|
-
children: [/* @__PURE__ */ t("button", {
|
|
237
|
-
class: "ck-icon-btn",
|
|
238
|
-
"aria-label": r("cancel"),
|
|
239
|
-
title: `${r("cancel")} (Esc)`,
|
|
240
|
-
onClick: v,
|
|
241
|
-
children: /* @__PURE__ */ t(p, { d: f.cancel })
|
|
242
|
-
}), /* @__PURE__ */ t("button", {
|
|
243
|
-
class: "ck-icon-btn ck-primary",
|
|
244
|
-
"aria-disabled": !A.length && !F?.text.trim() || void 0,
|
|
245
|
-
"aria-label": r("markupDone"),
|
|
246
|
-
title: !A.length && !F?.text.trim() ? r("markupEmpty") : r("markupDone"),
|
|
247
|
-
onClick: () => (A.length || F?.text.trim()) && G(),
|
|
248
|
-
children: /* @__PURE__ */ t(p, { d: f.save })
|
|
249
|
-
})]
|
|
250
|
-
})
|
|
251
|
-
})
|
|
252
|
-
]
|
|
253
|
-
}),
|
|
254
|
-
/* @__PURE__ */ t("canvas", {
|
|
255
|
-
ref: y,
|
|
256
|
-
onPointerDown: H,
|
|
257
|
-
onPointerMove: U,
|
|
258
|
-
onPointerUp: W
|
|
259
|
-
}),
|
|
260
|
-
F ? /* @__PURE__ */ t("div", {
|
|
261
|
-
class: "ck-label-box",
|
|
262
|
-
style: a(F.left, F.top),
|
|
263
|
-
children: [/* @__PURE__ */ t("input", {
|
|
264
|
-
ref: L,
|
|
265
|
-
class: "ck-input",
|
|
266
|
-
maxLength: 500,
|
|
267
|
-
value: F.text,
|
|
268
|
-
placeholder: r("markupTextPrompt"),
|
|
269
|
-
"aria-label": r("markupTextPrompt"),
|
|
270
|
-
style: { color: w },
|
|
271
|
-
onInput: (e) => I({
|
|
272
|
-
...F,
|
|
273
|
-
text: e.target.value
|
|
274
|
-
}),
|
|
275
|
-
onKeyDown: (e) => {
|
|
276
|
-
e.key === "Enter" && (e.preventDefault(), z());
|
|
277
|
-
}
|
|
278
|
-
}), /* @__PURE__ */ t("button", {
|
|
279
|
-
class: "ck-chip ck-primary",
|
|
280
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
281
|
-
onClick: z,
|
|
282
|
-
children: r("markupTextAdd")
|
|
283
|
-
})]
|
|
284
|
-
}) : null
|
|
285
|
-
]
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
function h(e, t) {
|
|
289
|
-
let n = e?.getBoundingClientRect().width || e?.width || 1;
|
|
290
|
-
return Math.max(1, Math.min(64, Math.round(t * ((e?.width ?? n) / n))));
|
|
291
|
-
}
|
|
292
|
-
var g = () => /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl";
|
|
293
|
-
function _(e, t, n) {
|
|
294
|
-
let r = t.points ?? [], i = t.width ?? Math.max(3, Math.round(n.width / 300));
|
|
295
|
-
e.save(), e.strokeStyle = e.fillStyle = t.color ?? "#ff3b30", e.lineWidth = i, e.lineCap = e.lineJoin = "round";
|
|
296
|
-
let [a = 0, o = 0, s = 0, c = 0] = r;
|
|
297
|
-
switch (t.tool) {
|
|
298
|
-
case "rect":
|
|
299
|
-
e.strokeRect(Math.min(a, s), Math.min(o, c), Math.abs(s - a), Math.abs(c - o));
|
|
300
|
-
break;
|
|
301
|
-
case "ellipse":
|
|
302
|
-
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();
|
|
303
|
-
break;
|
|
304
|
-
case "line":
|
|
305
|
-
e.beginPath(), e.moveTo(a, o), e.lineTo(s, c), e.stroke();
|
|
306
|
-
break;
|
|
307
|
-
case "arrow": {
|
|
308
|
-
let t = Math.atan2(c - o, s - a), n = i * 5;
|
|
309
|
-
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();
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
case "pen":
|
|
313
|
-
e.beginPath();
|
|
314
|
-
for (let t = 0; t < r.length; t += 2) (t ? e.lineTo : e.moveTo).call(e, r[t], r[t + 1]);
|
|
315
|
-
e.stroke();
|
|
316
|
-
break;
|
|
317
|
-
case "blur": {
|
|
318
|
-
let t = Math.min(a, s), n = Math.min(o, c), r = Math.abs(s - a), i = Math.abs(c - o);
|
|
319
|
-
if (r > 2 && i > 2) {
|
|
320
|
-
let a = Math.max(8, Math.round(Math.min(r, i) / 6)), o = e.getImageData(t, n, r, i);
|
|
321
|
-
for (let s = 0; s < i; s += a) for (let i = 0; i < r; i += a) {
|
|
322
|
-
let c = (s * r + i) * 4;
|
|
323
|
-
e.fillStyle = `rgb(${o.data[c]},${o.data[c + 1]},${o.data[c + 2]})`, e.fillRect(t + i, n + s, a, a);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
break;
|
|
327
|
-
}
|
|
328
|
-
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);
|
|
329
|
-
}
|
|
330
|
-
e.restore();
|
|
331
|
-
}
|
|
332
|
-
export { m as MarkupEditor };
|