vdc-editor 0.1.141 → 0.1.142

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