vdc-editor 0.1.194 → 0.1.196

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.
@@ -0,0 +1,687 @@
1
+ import { c as Z, a as Y, C as be, P as Ce, b as ve, D as ye, d as Ee, _ as Se, e as we, f as Te, S as oe, o as Ie, g as Re, h as Oe, i as Ne, j as We, k as Me, l as He, m as Ae, n as $e } from "./index-DNILyPgY.mjs";
2
+ import { defineComponent as P, createElementBlock as v, openBlock as m, createVNode as E, createElementVNode as h, unref as s, ref as L, onMounted as ee, nextTick as le, createCommentVNode as ie, normalizeClass as z, withModifiers as te, toDisplayString as G, normalizeStyle as ae, Fragment as K, renderList as q, createTextVNode as V, createBlock as B, createStaticVNode as Le, withCtx as $, reactive as ce, computed as se, watch as ue, normalizeProps as De, guardReactiveProps as Pe, renderSlot as Be, onUnmounted as re, resolveDynamicComponent as ze } from "vue";
3
+ import { useWindowSize as je, useEventListener as Ge } from "@vueuse/core";
4
+ const U = {
5
+ SPACING: 1,
6
+ SPELLING: 2
7
+ }, Ve = {
8
+ NOTHING_TO_CHANGE: "NOTHING_TO_CHANGE"
9
+ }, H = {
10
+ LOADING: "loading",
11
+ HAS_ERROR: "hasError",
12
+ NO_ERROR: "noError",
13
+ FAIL: "fail"
14
+ }, D = {
15
+ EDITOR_COMMENT: "editorComment",
16
+ EDITOR_CONTENT: "editorContent"
17
+ };
18
+ /**
19
+ * @license lucide-vue-next v0.439.0 - ISC
20
+ *
21
+ * This source code is licensed under the ISC license.
22
+ * See the LICENSE file in the root directory of this source tree.
23
+ */
24
+ const Fe = Z("ArrowLeftRightIcon", [
25
+ ["path", { d: "M8 3 4 7l4 4", key: "9rb6wj" }],
26
+ ["path", { d: "M4 7h16", key: "6tx8e3" }],
27
+ ["path", { d: "m16 21 4-4-4-4", key: "siv7j2" }],
28
+ ["path", { d: "M20 17H4", key: "h6l3hr" }]
29
+ ]);
30
+ /**
31
+ * @license lucide-vue-next v0.439.0 - ISC
32
+ *
33
+ * This source code is licensed under the ISC license.
34
+ * See the LICENSE file in the root directory of this source tree.
35
+ */
36
+ const Ke = Z("CircleAlertIcon", [
37
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
38
+ ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
39
+ ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
40
+ ]);
41
+ /**
42
+ * @license lucide-vue-next v0.439.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */
47
+ const Ye = Z("CircleCheckIcon", [
48
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
49
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
50
+ ]), Ue = { class: "min-h-[188px] flex flex-col items-center justify-center gap-y-2 text-sm" }, Xe = /* @__PURE__ */ P({
51
+ __name: "BulkSpellCheckerFail",
52
+ setup(o) {
53
+ return (t, r) => (m(), v("div", Ue, [
54
+ E(s(Ke), { class: "h-12 w-12 text-red-500" }),
55
+ r[0] || (r[0] = h("div", null, "맞춤법 검사에 실패했습니다", -1)),
56
+ r[1] || (r[1] = h("p", { class: "text-xs font-normal text-gray-600 dark:text-gray-400" }, "다시 검사하기 버튼을 눌러 재시도 해주세요", -1))
57
+ ]));
58
+ }
59
+ }), qe = { class: "min-h-[188px] flex flex-col items-center justify-center gap-y-2 text-sm" }, Je = /* @__PURE__ */ P({
60
+ __name: "BulkSpellCheckerNotWrongWord",
61
+ setup(o) {
62
+ return (t, r) => (m(), v("div", qe, [
63
+ E(s(Ye), { class: "h-12 w-12 text-blue-500" }),
64
+ r[0] || (r[0] = h("div", null, "맞춤법 오류가 없습니다", -1))
65
+ ]));
66
+ }
67
+ }), Qe = { class: "relative" }, Ze = ["innerHTML"], et = { class: "border-b border-gray-500" }, tt = /* @__PURE__ */ P({
68
+ __name: "BulkSpellCheckerHelpText",
69
+ props: {
70
+ text: {}
71
+ },
72
+ setup(o) {
73
+ const t = L(!1), r = L(!1), i = L(null);
74
+ function p() {
75
+ t.value = !t.value;
76
+ }
77
+ return ee(async () => {
78
+ await le(), i.value && i.value.scrollHeight > 32 && (r.value = !0);
79
+ }), (d, k) => (m(), v("div", Qe, [
80
+ h("div", {
81
+ ref_key: "helpRef",
82
+ ref: i,
83
+ class: z(["text-gray-700 dark:text-gray-400 transition-all", s(t) ? "max-h-none" : "max-h-[32px] overflow-hidden"]),
84
+ innerHTML: d.text
85
+ }, null, 10, Ze),
86
+ s(r) ? (m(), v("div", {
87
+ key: 0,
88
+ class: z([
89
+ "",
90
+ s(Y)(
91
+ "w-32 flex items-end justify-end bg-gradient-to-l from-white via-white to-transparent dark:from-ed-background dark:via-ed-background",
92
+ s(t) ? "ml-auto opacity-60" : "absolute bottom-0 right-0"
93
+ )
94
+ ])
95
+ }, [
96
+ h("button", {
97
+ class: "flex items-center gap-1",
98
+ onClick: te(p, ["stop"])
99
+ }, [
100
+ h("span", et, G(s(t) ? "접기" : "자세히"), 1),
101
+ E(s(be), {
102
+ class: z(["w-4 h-4 transition-transform", s(t) ? "rotate-180" : ""])
103
+ }, null, 8, ["class"])
104
+ ])
105
+ ], 2)) : ie("", !0)
106
+ ]));
107
+ }
108
+ }), ne = new Ce("bulk-spellcheck-highlight");
109
+ function nt(o, t, r = `
110
+ `) {
111
+ return new ve({
112
+ key: ne,
113
+ props: {
114
+ decorations(i) {
115
+ const p = [], d = {
116
+ [U.SPACING]: "bulk-highlight text-blue-500 border-b-2 border-blue-500",
117
+ [U.SPELLING]: "bulk-highlight text-red-500 border-b-2 border-red-500"
118
+ };
119
+ return t.forEach((k) => {
120
+ var g, _;
121
+ const I = j(o, k.startIndex, r), M = j(o, k.endIndex - 1, r) + 1, b = (_ = (g = k.errorHelpDtos) == null ? void 0 : g[0]) == null ? void 0 : _.errorType, A = d[b ?? -1] || "bulk-highlight text-green-500 border-b-2 border-green-500", a = Math.max(0, Math.min(I, i.doc.content.size)), l = Math.max(0, Math.min(M, i.doc.content.size));
122
+ a < l && p.push(Ee.inline(a, l, { class: A }));
123
+ }), ye.create(i.doc, p);
124
+ }
125
+ }
126
+ });
127
+ }
128
+ function Q(o, t) {
129
+ if (o.unregisterPlugin(ne), !t.length) return;
130
+ const r = nt(o, t);
131
+ o.registerPlugin(r);
132
+ }
133
+ function ot(o) {
134
+ o && o.unregisterPlugin(ne);
135
+ }
136
+ function de(o, t = `
137
+ `) {
138
+ const r = [];
139
+ let i = 0, p = !0;
140
+ return o.state.doc.descendants((d, k) => {
141
+ if (d.isText && d.text)
142
+ for (let b = 0; b < d.text.length; b++)
143
+ r[i++] = k + b;
144
+ const I = d.type && d.type.name;
145
+ if ((I === "hardBreak" || I === "hard_break" || I === "br") && t.length > 0)
146
+ for (let b = 0; b < t.length; b++)
147
+ r[i++] = k;
148
+ if (d.isBlock) {
149
+ if (!p && t.length > 0)
150
+ for (let b = 0; b < t.length; b++)
151
+ r[i++] = k;
152
+ p = !1;
153
+ }
154
+ return !0;
155
+ }), r;
156
+ }
157
+ function j(o, t, r = `
158
+ `) {
159
+ const i = de(o, r);
160
+ if (t < 0 && (t = 0), t >= i.length)
161
+ return o.state.doc.content.size;
162
+ const p = i[t];
163
+ if (p == null) {
164
+ for (let d = t; d < i.length; d++) if (i[d] != null) return i[d];
165
+ for (let d = t - 1; d >= 0; d--) if (i[d] != null) return i[d];
166
+ return o.state.doc.content.size;
167
+ }
168
+ return p;
169
+ }
170
+ const st = ["onClick"], rt = { class: "flex items-center mb-2" }, lt = { class: "flex items-center gap-2" }, it = { class: "break-all whitespace-normal" }, at = { class: "flex items-center mb-2" }, ct = {
171
+ key: 0,
172
+ class: "flex-1 space-y-1"
173
+ }, ut = { class: "text-sm" }, dt = ["onClick"], pt = { key: 1 }, ft = { class: "flex" }, gt = { class: "flex-1" }, J = 450, mt = /* @__PURE__ */ P({
174
+ __name: "BulkSpellCheckerWrongWordList",
175
+ props: {
176
+ editorsState: {}
177
+ },
178
+ setup(o) {
179
+ const t = o;
180
+ function r(a) {
181
+ return {
182
+ [U.SPACING]: "bg-blue-500",
183
+ [U.SPELLING]: "bg-red-500"
184
+ }[a ?? -1] || "bg-green-500";
185
+ }
186
+ function i(a) {
187
+ var l, g, _, x;
188
+ return ((x = (_ = (g = (l = a == null ? void 0 : a.extensionStorage) == null ? void 0 : l.spellchecker) == null ? void 0 : g.spellchecker) == null ? void 0 : _.uiStrings) == null ? void 0 : x.uiStrings) || "No suggestions found";
189
+ }
190
+ function p(a) {
191
+ var l, g;
192
+ if (a === D.EDITOR_COMMENT) {
193
+ (l = t.editorsState[D.EDITOR_CONTENT].editor) == null || l.commands.setTextSelection(0);
194
+ return;
195
+ }
196
+ if (a === D.EDITOR_CONTENT) {
197
+ (g = t.editorsState[D.EDITOR_COMMENT].editor) == null || g.commands.setTextSelection(0);
198
+ return;
199
+ }
200
+ }
201
+ function d(a, l, g) {
202
+ if (!l) return;
203
+ p(a);
204
+ const _ = j(l, g.startIndex), x = j(l, g.endIndex - 1) + 1;
205
+ l.chain().setTextSelection({ from: _, to: x }).focus().run();
206
+ const e = Math.max(0, Math.floor((_ + x) / 2)), c = l.view.domAtPos(e).node;
207
+ let f = null;
208
+ c instanceof Element ? f = c : c instanceof Text ? f = c.parentElement : f = (c == null ? void 0 : c.parentElement) ?? l.view.dom, f != null && f.scrollIntoView && f.scrollIntoView({ behavior: "smooth", block: "center" });
209
+ }
210
+ function k(a, l, g, _) {
211
+ var R;
212
+ if (!a) return;
213
+ const x = j(a, g.startIndex), e = j(a, g.endIndex - 1) + 1, n = a.state.tr.insertText(_, x, e);
214
+ a.view.dispatch(n), a.view.focus();
215
+ const c = _.length - (((R = g.wrongWord) == null ? void 0 : R.length) ?? 0), f = g.startIndex, S = g.endIndex;
216
+ for (let O = l.length - 1; O >= 0; O--) {
217
+ const C = l[O];
218
+ if (C.startIndex >= f && C.startIndex < S) {
219
+ l.splice(O, 1);
220
+ continue;
221
+ }
222
+ C.startIndex > f && (C.startIndex += c, C.endIndex += c);
223
+ }
224
+ const T = l.indexOf(g);
225
+ T !== -1 && l.splice(T, 1), Q(a, l);
226
+ }
227
+ const I = L(null), M = L(J), { height: b } = je();
228
+ function A() {
229
+ const a = I.value;
230
+ if (!a) return;
231
+ const l = 80, g = a.getBoundingClientRect(), _ = b.value - g.top - l;
232
+ M.value = J > _ ? _ : J;
233
+ }
234
+ return ee(() => {
235
+ A(), Ge(window, "resize", A);
236
+ }), (a, l) => {
237
+ const g = tt;
238
+ return m(), v("div", {
239
+ ref_key: "contentEl",
240
+ ref: I,
241
+ style: ae({ maxHeight: `${s(M)}px` }),
242
+ class: "pr-1 overflow-y-auto"
243
+ }, [
244
+ (m(!0), v(K, null, q(a.editorsState, (_, x) => (m(), v(K, { key: x }, [
245
+ (m(!0), v(K, null, q(_.wrongWords, (e, n) => {
246
+ var c, f;
247
+ return m(), v("div", {
248
+ key: n,
249
+ class: "border-b border-gray-100 dark:border-ed-muted pb-5 mb-5 cursor-pointer",
250
+ onClick: (S) => d(x, a.editorsState[x].editor, e)
251
+ }, [
252
+ h("div", rt, [
253
+ l[0] || (l[0] = h("span", { class: "w-16 font-medium" }, "입력 내용", -1)),
254
+ h("div", lt, [
255
+ h("span", {
256
+ class: z(["w-1.5 h-1.5 rounded-full", r((c = e.errorHelpDtos[0]) == null ? void 0 : c.errorType)])
257
+ }, null, 2),
258
+ h("span", it, G(e.wrongWord), 1)
259
+ ])
260
+ ]),
261
+ h("div", at, [
262
+ l[3] || (l[3] = h("span", { class: "w-16 font-medium" }, "대치어", -1)),
263
+ e.correctWord.length ? (m(), v("div", ct, [
264
+ (m(!0), v(K, null, q(e.correctWord, (S, T) => (m(), v("div", {
265
+ key: T,
266
+ class: "font-semibold px-3 py-1.5 rounded bg-gray-100 dark:bg-ed-muted flex items-center justify-between"
267
+ }, [
268
+ h("div", ut, G(S), 1),
269
+ h("button", {
270
+ class: "flex items-center gap-1 text-blue-500",
271
+ onClick: te((R) => k(_.editor, _.wrongWords, e, S), ["stop"])
272
+ }, [
273
+ E(s(Fe), { class: "w-4 h-4" }),
274
+ l[1] || (l[1] = V()),
275
+ l[2] || (l[2] = h("span", null, "바꾸기", -1))
276
+ ], 8, dt)
277
+ ]))), 128))
278
+ ])) : (m(), v("div", pt, G(i(_.editor)), 1))
279
+ ]),
280
+ h("div", ft, [
281
+ l[4] || (l[4] = h("span", { class: "w-16 font-medium" }, "도움말", -1)),
282
+ h("div", gt, [
283
+ E(g, {
284
+ text: (f = e.errorHelpDtos[0]) == null ? void 0 : f.errorMessage
285
+ }, null, 8, ["text"])
286
+ ])
287
+ ])
288
+ ], 8, st);
289
+ }), 128))
290
+ ], 64))), 128))
291
+ ], 4);
292
+ };
293
+ }
294
+ }), ht = {
295
+ key: 0,
296
+ class: "opacity-25",
297
+ cx: "12",
298
+ cy: "12",
299
+ r: "10",
300
+ fill: "#ffffff",
301
+ stroke: "currentColor",
302
+ "stroke-width": "4"
303
+ }, _t = {
304
+ key: 1,
305
+ class: "opacity-25",
306
+ cx: "12",
307
+ cy: "12",
308
+ r: "10",
309
+ stroke: "currentColor",
310
+ "stroke-width": "4"
311
+ }, xt = /* @__PURE__ */ P({
312
+ __name: "SpinnerIcon",
313
+ props: {
314
+ fillWhite: { type: Boolean, default: !1 },
315
+ class: { default: "" }
316
+ },
317
+ setup(o) {
318
+ const t = o;
319
+ return (r, i) => (m(), v("svg", {
320
+ class: z(s(Y)("animate-spin h-5 w-5 mr-0.5", t.class)),
321
+ viewBox: "0 0 24 24",
322
+ "aria-hidden": "true"
323
+ }, [
324
+ r.fillWhite ? (m(), v("circle", ht)) : (m(), v("circle", _t)),
325
+ i[0] || (i[0] = h("path", {
326
+ class: "opacity-100",
327
+ fill: "currentColor",
328
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
329
+ }, null, -1))
330
+ ], 2));
331
+ }
332
+ }), kt = {}, bt = { class: "min-h-[188px] flex flex-col items-center justify-center gap-y-2 text-sm" };
333
+ function Ct(o, t) {
334
+ const r = xt;
335
+ return m(), v("div", bt, [
336
+ E(r, {
337
+ "fill-white": "",
338
+ class: "h-10 w-10 text-blue-500"
339
+ }),
340
+ t[0] || (t[0] = h("div", null, "맞춤법 검사 중입니다", -1))
341
+ ]);
342
+ }
343
+ const vt = /* @__PURE__ */ Se(kt, [["render", Ct]]), yt = { class: "text-xs py-4 px-6" }, Et = { class: "flex items-center justify-between mt-3" }, St = { class: "flex gap-x-1" }, wt = /* @__PURE__ */ P({
344
+ __name: "BulkSpellCheckerContent",
345
+ props: {
346
+ editorsState: {},
347
+ spellCheckStatus: {},
348
+ allWrongWordsMissSuggestions: { type: Boolean }
349
+ },
350
+ emits: ["close-modal", "run-spellcheck", "replace-all-editor-errors"],
351
+ setup(o, { emit: t }) {
352
+ const r = t;
353
+ return (i, p) => {
354
+ const d = vt, k = mt, I = Je, M = Xe, b = we;
355
+ return m(), v("div", yt, [
356
+ i.spellCheckStatus === s(H).LOADING ? (m(), B(d, { key: 0 })) : i.spellCheckStatus === s(H).HAS_ERROR ? (m(), B(k, {
357
+ key: 1,
358
+ editorsState: i.editorsState
359
+ }, null, 8, ["editorsState"])) : i.spellCheckStatus === s(H).NO_ERROR ? (m(), B(I, { key: 2 })) : i.spellCheckStatus === s(H).FAIL ? (m(), B(M, { key: 3 })) : ie("", !0),
360
+ h("div", Et, [
361
+ p[4] || (p[4] = Le('<ul class="flex items-cente gap-x-4"><li class="flex items-center gap-x-1"><span class="w-1.5 h-1.5 rounded-full bg-red-500"></span>맞춤법</li><li class="flex items-center gap-x-1"><span class="w-1.5 h-1.5 rounded-full bg-blue-500"></span>띄어쓰기</li><li class="flex items-center gap-x-1"><span class="w-1.5 h-1.5 rounded-full bg-green-500"></span>통합교정</li></ul>', 1)),
362
+ h("div", St, [
363
+ E(b, {
364
+ variant: "outline",
365
+ class: z(
366
+ s(Y)(
367
+ "border-blue-500 text-blue-500 text-xs px-3 py-2 h-auto hover:bg-white/80 hover:opacity-80 hover:text-blue-500 dark:text-dark-blue-100 dark:hover:bg-dark-blue-400 dark:hover:text-dark-blue-50 dark:hover:border-dark-blue-100",
368
+ i.spellCheckStatus === s(H).LOADING && "text-gray-300 bg-gray-100 border-gray-100 pointer-events-none dark:bg-ed-muted/70 dark:border-ed-muted/70 dark:text-gray-500"
369
+ )
370
+ ),
371
+ onClick: p[0] || (p[0] = (A) => r("run-spellcheck"))
372
+ }, {
373
+ default: $(() => p[2] || (p[2] = [
374
+ V("다시 검사하기")
375
+ ])),
376
+ _: 1
377
+ }, 8, ["class"]),
378
+ E(b, {
379
+ class: z(
380
+ s(Y)(
381
+ "border-blue-500 text-white text-xs px-3 py-2 h-auto bg-blue-500 hover:bg-blue-500/80",
382
+ (i.spellCheckStatus !== s(H).HAS_ERROR || i.allWrongWordsMissSuggestions) && "text-gray-300 bg-gray-100 hover:bg-gray-100 pointer-events-none dark:bg-ed-muted/70 dark:text-gray-500"
383
+ )
384
+ ),
385
+ onClick: p[1] || (p[1] = (A) => r("replace-all-editor-errors"))
386
+ }, {
387
+ default: $(() => p[3] || (p[3] = [
388
+ V("모두 바꾸기")
389
+ ])),
390
+ _: 1
391
+ }, 8, ["class"])
392
+ ])
393
+ ])
394
+ ]);
395
+ };
396
+ }
397
+ }), Tt = () => {
398
+ const o = ce({
399
+ [D.EDITOR_COMMENT]: {
400
+ editor: null,
401
+ wrongWords: []
402
+ },
403
+ [D.EDITOR_CONTENT]: {
404
+ editor: null,
405
+ wrongWords: []
406
+ }
407
+ });
408
+ function t(e, n) {
409
+ o[e].editor = n;
410
+ }
411
+ const r = L(H.NO_ERROR);
412
+ function i() {
413
+ Object.values(o).forEach((e) => {
414
+ e.wrongWords = [];
415
+ });
416
+ }
417
+ function p(e, n) {
418
+ return e ? H.FAIL : n ? H.HAS_ERROR : H.NO_ERROR;
419
+ }
420
+ async function d() {
421
+ var c, f;
422
+ r.value = H.LOADING;
423
+ let e = !1, n = !1;
424
+ for (const [S, { editor: T }] of Object.entries(o)) {
425
+ if (!T) continue;
426
+ const R = (c = T == null ? void 0 : T.extensionManager.extensions.find((C) => C.name === "spellchecker")) == null ? void 0 : c.options.proofreader.api, O = T.getText({ blockSeparator: `
427
+ ` });
428
+ if (!(!R || !O))
429
+ try {
430
+ const { data: C } = await Te.post(R, {
431
+ value: O
432
+ });
433
+ if (!C.success && C.code !== Ve.NOTHING_TO_CHANGE) {
434
+ n = !0, o[S].wrongWords = [];
435
+ continue;
436
+ }
437
+ if ((f = C.data) != null && f.wrongWordResponseDto) {
438
+ e = !0, o[S].wrongWords = C.data.wrongWordResponseDto;
439
+ continue;
440
+ }
441
+ o[S].wrongWords = [];
442
+ } catch (C) {
443
+ console.error("handleRunSpellCheck error: ", C), n = !0;
444
+ }
445
+ }
446
+ r.value = p(n, e);
447
+ }
448
+ const k = se(() => Object.values(o).reduce((e, { wrongWords: n }) => e + n.length, 0));
449
+ ue(k, (e) => {
450
+ e === 0 && (r.value = p(!1, !1));
451
+ });
452
+ const I = se(() => {
453
+ const e = Object.values(o).flatMap((n) => n.wrongWords);
454
+ return e.length === 0 ? !1 : e.every((n) => !Array.isArray(n.correctWord) || n.correctWord.length === 0);
455
+ });
456
+ function M() {
457
+ for (const [e, { editor: n, wrongWords: c }] of Object.entries(o))
458
+ n && Q(n, c);
459
+ }
460
+ function b() {
461
+ for (const [e, { editor: n }] of Object.entries(o))
462
+ n && ot(n);
463
+ }
464
+ async function A() {
465
+ await d(), M();
466
+ }
467
+ let a = !0;
468
+ function l(e) {
469
+ if (a = e, !!e)
470
+ for (const [n, { editor: c }] of Object.entries(o))
471
+ c && (c.extensionStorage.spellchecker.spellchecker.setEnabledProofreadText(!1), c.view.dispatch(c.state.tr.setMeta(oe.IS_ACTIVE_SPELLCHECK, !1)));
472
+ }
473
+ function g() {
474
+ if (a)
475
+ for (const [e, { editor: n }] of Object.entries(o))
476
+ n && (n.extensionStorage.spellchecker.spellchecker.setEnabledProofreadText(!0), n.view.dispatch(n.state.tr.setMeta(oe.IS_ACTIVE_SPELLCHECK, !0)));
477
+ }
478
+ function _(e, n, c = `
479
+ `) {
480
+ if (!e || !n.length) return;
481
+ const f = de(e, c);
482
+ function S(u) {
483
+ if (u < 0 && (u = 0), u >= f.length) return e.state.doc.content.size;
484
+ if (f[u] != null) return f[u];
485
+ for (let y = u; y < f.length; y++) if (f[y] != null) return f[y];
486
+ for (let y = u - 1; y >= 0; y--) if (f[y] != null) return f[y];
487
+ return e.state.doc.content.size;
488
+ }
489
+ const R = n.map((u) => {
490
+ var F;
491
+ const y = S(u.startIndex), w = S(Math.max(0, u.endIndex - 1)) + 1, W = ((F = u.correctWord) == null ? void 0 : F[0]) ?? u.wrongWord;
492
+ return { item: u, from: y, to: w, replacement: W };
493
+ }).filter((u) => typeof u.from == "number" && typeof u.to == "number" && u.from < u.to);
494
+ if (!R.length) return;
495
+ R.sort((u, y) => y.from - u.from);
496
+ const O = e.state.tr;
497
+ let C = Number.POSITIVE_INFINITY;
498
+ const N = /* @__PURE__ */ new Set();
499
+ for (const u of R)
500
+ u.to > C || (O.insertText(u.replacement, u.from, u.to), N.add(u.item), C = u.from);
501
+ N.size > 0 && (e.view.dispatch(O), e.view.focus()), N.size > 0 && (n = n.filter((u) => ![...N].some((y) => y === u))), Q(e, n);
502
+ }
503
+ function x() {
504
+ for (const [e, { editor: n, wrongWords: c }] of Object.entries(o))
505
+ n && _(n, c);
506
+ }
507
+ return {
508
+ editorsState: o,
509
+ spellCheckStatus: r,
510
+ countTotalWrongWords: k,
511
+ allWrongWordsMissSuggestions: I,
512
+ setEditor: t,
513
+ resetAllEditorWrongWords: i,
514
+ disableSpellCheckRealTime: l,
515
+ resetEnableSpellCheckRealTime: g,
516
+ applyAllEditorHighlightErrors: M,
517
+ clearAllEditorHighlightErrors: b,
518
+ reRunSpellCheckAndHighlight: A,
519
+ handleRunSpellCheck: d,
520
+ replaceAllEditorErrors: x
521
+ };
522
+ }, It = /* @__PURE__ */ P({
523
+ __name: "DialogTrigger",
524
+ props: {
525
+ asChild: { type: Boolean },
526
+ as: {}
527
+ },
528
+ setup(o) {
529
+ const t = o;
530
+ return (r, i) => (m(), B(s(Ie), De(Pe(t)), {
531
+ default: $(() => [
532
+ Be(r.$slots, "default")
533
+ ]),
534
+ _: 3
535
+ }, 16));
536
+ }
537
+ }), Rt = {
538
+ key: 0,
539
+ class: "border-blue-500 text-white text-xs text-nowrap px-3 py-2 h-auto bg-blue-500 hover:bg-blue-500/80 flex items-center rounded"
540
+ }, Mt = /* @__PURE__ */ P({
541
+ __name: "BulkSpellChecker",
542
+ props: {
543
+ editor: {},
544
+ editorComment: {},
545
+ isEnableSpellCheckRealTime: { type: Boolean }
546
+ },
547
+ setup(o) {
548
+ var u, y;
549
+ const t = o, {
550
+ editorsState: r,
551
+ countTotalWrongWords: i,
552
+ spellCheckStatus: p,
553
+ allWrongWordsMissSuggestions: d,
554
+ setEditor: k,
555
+ disableSpellCheckRealTime: I,
556
+ resetEnableSpellCheckRealTime: M,
557
+ handleRunSpellCheck: b,
558
+ resetAllEditorWrongWords: A,
559
+ applyAllEditorHighlightErrors: a,
560
+ clearAllEditorHighlightErrors: l,
561
+ reRunSpellCheckAndHighlight: g,
562
+ replaceAllEditorErrors: _
563
+ } = Tt(), x = L(!1), e = ce({ x: 0, y: 0 }), n = L(!1), c = { x: 0, y: 0 }, f = (w) => {
564
+ n.value = !0, c.x = w.clientX - e.x, c.y = w.clientY - e.y, document.addEventListener("mousemove", S), document.addEventListener("mouseup", T);
565
+ }, S = (w) => {
566
+ n.value && (e.x = w.clientX - c.x, e.y = w.clientY - c.y);
567
+ }, T = () => {
568
+ n.value = !1, document.removeEventListener("mousemove", S), document.removeEventListener("mouseup", T);
569
+ };
570
+ re(() => {
571
+ document.removeEventListener("mousemove", S), document.removeEventListener("mouseup", T);
572
+ });
573
+ const R = L(null), O = L({ top: 0, right: 0 }), C = () => {
574
+ if (R.value) {
575
+ const w = R.value.$el.getBoundingClientRect();
576
+ O.value = {
577
+ top: w.bottom + window.scrollY + 5,
578
+ right: window.innerWidth - w.right - window.scrollX
579
+ }, e.x = 0, e.y = 0;
580
+ }
581
+ };
582
+ ee(async () => {
583
+ t.editorComment && k(D.EDITOR_COMMENT, t.editorComment), k(D.EDITOR_CONTENT, t.editor);
584
+ }), re(() => {
585
+ k(D.EDITOR_COMMENT, null), k(D.EDITOR_CONTENT, null);
586
+ }), ue(x, async (w) => {
587
+ w ? (await le(), C(), I(t.isEnableSpellCheckRealTime), await b(), a()) : (A(), M(), l());
588
+ });
589
+ const N = (y = (u = t.editor) == null ? void 0 : u.extensionManager.extensions.find((w) => w.name === "spellchecker")) == null ? void 0 : y.options.bulkSpellCheckerButton;
590
+ return (w, W) => {
591
+ const F = Oe, pe = He, fe = Me, ge = Ae, me = We, he = $e, _e = wt, xe = Ne, ke = Re;
592
+ return m(), B(ke, { open: s(x) }, {
593
+ default: $(() => [
594
+ E(s(It), {
595
+ "as-child": "",
596
+ ref_key: "triggerRef",
597
+ ref: R,
598
+ onClick: W[0] || (W[0] = (X) => x.value = !s(x))
599
+ }, {
600
+ default: $(() => [
601
+ s(N) ? (m(), B(ze(s(N).component), {
602
+ key: 1,
603
+ buttonName: s(N).props.buttonName,
604
+ icon: s(N).props.icon,
605
+ type: s(N).props.type,
606
+ disabled: s(N).props.disabled,
607
+ iconPosition: s(N).props.iconPosition,
608
+ buttonSize: s(N).props.buttonSize,
609
+ iconClass: s(N).props.iconClass
610
+ }, null, 8, ["buttonName", "icon", "type", "disabled", "iconPosition", "buttonSize", "iconClass"])) : (m(), v("button", Rt, [
611
+ E(F, { name: "checkUnderline" }),
612
+ W[4] || (W[4] = V("맞춤법 일괄 교정 "))
613
+ ]))
614
+ ]),
615
+ _: 1
616
+ }, 512),
617
+ E(xe, {
618
+ "is-overlay-transparent": "",
619
+ class: "p-0 gap-0 !animate-none !transition-none dark:border-ed-muted",
620
+ "as-child": ""
621
+ }, {
622
+ default: $(() => [
623
+ h("div", {
624
+ class: "z-[70]",
625
+ style: ae({
626
+ transform: `translate(${s(e).x}px, ${s(e).y}px)`,
627
+ top: `${s(O).top}px`,
628
+ right: `${s(O).right}px`,
629
+ left: "auto"
630
+ })
631
+ }, [
632
+ E(me, {
633
+ class: "bg-ed-blue-light py-3.5 px-6 rounded-t-[5px] cursor-move text-blue-500 dark:text-dark-blue-100 flex-row items-center justify-between",
634
+ onMousedown: te(f, ["prevent"])
635
+ }, {
636
+ default: $(() => [
637
+ E(fe, { class: "text-base space-x-2" }, {
638
+ default: $(() => [
639
+ W[5] || (W[5] = h("span", null, "맞춤법/문법 오류", -1)),
640
+ E(pe, { class: "text-sm bg-blue-500 hover:bg-blue-500 dark:bg-dark-blue-100 px-2" }, {
641
+ default: $(() => [
642
+ V(G(s(i)) + "개", 1)
643
+ ]),
644
+ _: 1
645
+ })
646
+ ]),
647
+ _: 1
648
+ }),
649
+ E(ge, {
650
+ onClick: W[1] || (W[1] = (X) => x.value = !1),
651
+ class: "text-xs flex items-center gap-x-1"
652
+ }, {
653
+ default: $(() => [
654
+ E(F, {
655
+ name: "Close",
656
+ class: "w-4 h-4"
657
+ }),
658
+ V(G(w.$t("editor.close")), 1)
659
+ ]),
660
+ _: 1
661
+ })
662
+ ]),
663
+ _: 1
664
+ }),
665
+ E(he),
666
+ E(_e, {
667
+ editorsState: s(r),
668
+ spellCheckStatus: s(p),
669
+ allWrongWordsMissSuggestions: s(d),
670
+ onCloseModal: W[2] || (W[2] = (X) => x.value = !1),
671
+ onRunSpellcheck: s(g),
672
+ onReplaceAllEditorErrors: W[3] || (W[3] = (X) => (s(_)(), x.value = !1))
673
+ }, null, 8, ["editorsState", "spellCheckStatus", "allWrongWordsMissSuggestions", "onRunSpellcheck"])
674
+ ], 4)
675
+ ]),
676
+ _: 1
677
+ })
678
+ ]),
679
+ _: 1
680
+ }, 8, ["open"]);
681
+ };
682
+ }
683
+ });
684
+ export {
685
+ Mt as default
686
+ };
687
+ //# sourceMappingURL=BulkSpellChecker-DPIlFN2j.mjs.map