@kungal/editor-vue 0.32.1 → 0.34.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.
- package/CHANGELOG.md +91 -0
- package/dist/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/KunEditor.vue.d.ts +1 -1
- package/dist/components/KunEditor.vue.d.ts.map +1 -1
- package/dist/components/LinkInput.vue.d.ts +4 -0
- package/dist/components/LinkInput.vue.d.ts.map +1 -0
- package/dist/components/SelectionTooltip.vue.d.ts.map +1 -1
- package/dist/index.js +465 -330
- package/dist/selected-href.d.ts +5 -0
- package/dist/selected-href.d.ts.map +1 -0
- package/dist/toolbar-icons.d.ts +2 -0
- package/dist/toolbar-icons.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, guardReactiveProps as c, inject as l, nextTick as u, normalizeProps as d, onBeforeUnmount as f, onMounted as p, openBlock as m, provide as h, reactive as g, ref as _, renderList as v, renderSlot as y, toDisplayString as b, unref as x,
|
|
2
|
-
import { Milkdown as
|
|
3
|
-
import { ProsemirrorAdapterProvider as
|
|
4
|
-
import { parseHeadings as
|
|
5
|
-
import { Editor as
|
|
6
|
-
import { listenerCtx as
|
|
7
|
-
import { SlashProvider as
|
|
8
|
-
import { TooltipProvider as
|
|
9
|
-
import { $prose as
|
|
10
|
-
import { Plugin as
|
|
11
|
-
import { createCodeBlockCommand as
|
|
12
|
-
import { createKunEditorPlugins as
|
|
13
|
-
import { strikethroughSchema as
|
|
14
|
-
import { Annotation as
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, guardReactiveProps as c, inject as l, nextTick as u, normalizeProps as d, onBeforeUnmount as f, onMounted as p, openBlock as m, provide as h, reactive as g, ref as _, renderList as v, renderSlot as y, toDisplayString as b, unref as x, vModelText as S, vShow as C, watch as w, withCtx as T, withDirectives as E, withKeys as D, withModifiers as O } from "vue";
|
|
2
|
+
import { Milkdown as k, MilkdownProvider as A, useEditor as j, useInstance as M } from "@milkdown/vue";
|
|
3
|
+
import { ProsemirrorAdapterProvider as N, usePluginViewContext as ee, usePluginViewFactory as P } from "@prosemirror-adapter/vue";
|
|
4
|
+
import { parseHeadings as F, parseHeadings as I } from "@kungal/editor-core";
|
|
5
|
+
import { Editor as L, defaultValueCtx as te, editorViewCtx as R, editorViewOptionsCtx as z, rootCtx as B } from "@milkdown/kit/core";
|
|
6
|
+
import { listenerCtx as ne } from "@milkdown/kit/plugin/listener";
|
|
7
|
+
import { SlashProvider as re, slashFactory as V } from "@milkdown/kit/plugin/slash";
|
|
8
|
+
import { TooltipProvider as ie, tooltipFactory as H } from "@milkdown/kit/plugin/tooltip";
|
|
9
|
+
import { $prose as U, callCommand as W, replaceAll as G } from "@milkdown/kit/utils";
|
|
10
|
+
import { Plugin as ae, PluginKey as oe, TextSelection as K } from "@milkdown/kit/prose/state";
|
|
11
|
+
import { createCodeBlockCommand as q, emphasisSchema as se, inlineCodeSchema as ce, insertHrCommand as le, insertImageCommand as ue, linkSchema as de, strongSchema as fe, toggleEmphasisCommand as pe, toggleInlineCodeCommand as me, toggleStrongCommand as he, wrapInBlockquoteCommand as ge, wrapInBulletListCommand as _e, wrapInOrderedListCommand as ve } from "@milkdown/kit/preset/commonmark";
|
|
12
|
+
import { createKunEditorPlugins as ye, insertKunSpoilerCommand as be, insertLinkCommand as J, insertMentionCommand as xe, insertQuoteCommand as Se, kunCM as Ce, mentionId as we, setHeadingCommand as Te, startImageUpload as Ee } from "@kungal/editor-core/preset";
|
|
13
|
+
import { strikethroughSchema as De, toggleStrikethroughCommand as Oe } from "@milkdown/kit/preset/gfm";
|
|
14
|
+
import { Annotation as ke, EditorState as Ae } from "@codemirror/state";
|
|
15
15
|
import { EditorView as Y } from "@codemirror/view";
|
|
16
|
-
import { markdown as
|
|
17
|
-
import { basicSetup as
|
|
16
|
+
import { markdown as je } from "@codemirror/lang-markdown";
|
|
17
|
+
import { basicSetup as Me } from "codemirror";
|
|
18
18
|
//#region src/active-marks.ts
|
|
19
|
-
var
|
|
19
|
+
var Ne = [
|
|
20
20
|
"bold",
|
|
21
21
|
"italic",
|
|
22
22
|
"strike",
|
|
23
23
|
"code"
|
|
24
|
-
],
|
|
25
|
-
bold:
|
|
26
|
-
italic:
|
|
27
|
-
strike:
|
|
28
|
-
code:
|
|
29
|
-
},
|
|
24
|
+
], Pe = {
|
|
25
|
+
bold: fe,
|
|
26
|
+
italic: se,
|
|
27
|
+
strike: De,
|
|
28
|
+
code: ce
|
|
29
|
+
}, Fe = () => ({
|
|
30
30
|
bold: !1,
|
|
31
31
|
italic: !1,
|
|
32
32
|
strike: !1,
|
|
33
33
|
code: !1
|
|
34
|
-
}),
|
|
35
|
-
let { from: n, $from: r, to: i, empty: a } = e.selection, o =
|
|
36
|
-
for (let s of
|
|
37
|
-
let c =
|
|
34
|
+
}), Ie = Object.freeze(Fe()), Le = (e, t) => {
|
|
35
|
+
let { from: n, $from: r, to: i, empty: a } = e.selection, o = Fe();
|
|
36
|
+
for (let s of Ne) {
|
|
37
|
+
let c = Pe[s].type(t);
|
|
38
38
|
o[s] = a ? !!c.isInSet(e.storedMarks ?? r.marks()) : e.doc.rangeHasMark(n, i, c);
|
|
39
39
|
}
|
|
40
40
|
return o;
|
|
41
|
-
},
|
|
42
|
-
let r =
|
|
43
|
-
for (let e of
|
|
44
|
-
},
|
|
45
|
-
key:
|
|
46
|
-
view: (n) => (
|
|
47
|
-
|
|
41
|
+
}, Re = (e, t, n) => {
|
|
42
|
+
let r = Le(e, t);
|
|
43
|
+
for (let e of Ne) n[e] !== r[e] && (n[e] = r[e]);
|
|
44
|
+
}, ze = new oe("KUN_ACTIVE_MARKS"), Be = (e) => U((t) => new ae({
|
|
45
|
+
key: ze,
|
|
46
|
+
view: (n) => (Re(n.state, t, e), { update(n) {
|
|
47
|
+
Re(n.state, t, e);
|
|
48
48
|
} })
|
|
49
|
-
})), X = Symbol("kun-editor-context"),
|
|
49
|
+
})), X = Symbol("kun-editor-context"), Ve = [
|
|
50
50
|
"data-active",
|
|
51
51
|
"onMousedown",
|
|
52
52
|
"onMouseenter"
|
|
53
|
-
],
|
|
53
|
+
], He = ["src", "alt"], Ue = {
|
|
54
54
|
key: 1,
|
|
55
55
|
class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
|
|
56
|
-
},
|
|
56
|
+
}, We = { class: "kun-mention-dropdown__name" }, Ge = {
|
|
57
57
|
key: 1,
|
|
58
58
|
class: "kun-mention-dropdown__hint"
|
|
59
|
-
},
|
|
59
|
+
}, Ke = {
|
|
60
60
|
key: 2,
|
|
61
61
|
class: "kun-mention-dropdown__hint"
|
|
62
|
-
},
|
|
62
|
+
}, qe = {
|
|
63
63
|
key: 3,
|
|
64
64
|
class: "kun-mention-dropdown__hint"
|
|
65
|
-
},
|
|
65
|
+
}, Je = /* @__PURE__ */ s({
|
|
66
66
|
__name: "MentionDropdown",
|
|
67
67
|
setup(n) {
|
|
68
68
|
let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(X), s = o?.adapters.searchMentionUsers, c = t(() => (o?.locale ?? "zh-cn").toLowerCase().startsWith("en")), u = t(() => c.value ? {
|
|
@@ -73,51 +73,51 @@ var Ae = [
|
|
|
73
73
|
searching: "搜索中…",
|
|
74
74
|
empty: "无匹配用户",
|
|
75
75
|
prompt: "输入用户名以搜索"
|
|
76
|
-
}), { view: d, prevState: h } =
|
|
77
|
-
A &&= (clearTimeout(A), null), S.value = "",
|
|
78
|
-
},
|
|
76
|
+
}), { view: d, prevState: h } = ee(), g = _(null), y, x = _(!1), S = _(""), C = _([]), T = _(0), E = _(!1), D = null, k = 0, A = null, j = () => {
|
|
77
|
+
A &&= (clearTimeout(A), null), S.value = "", C.value = [], T.value = 0, E.value = !1, D = null;
|
|
78
|
+
}, M = (e) => {
|
|
79
79
|
if (A &&= (clearTimeout(A), null), !e || !s) {
|
|
80
|
-
|
|
80
|
+
C.value = [], E.value = !1;
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
E.value = !0, A = setTimeout(async () => {
|
|
84
84
|
let t = ++k, n = [];
|
|
85
85
|
try {
|
|
86
86
|
n = await s(e);
|
|
87
87
|
} catch {
|
|
88
88
|
n = [];
|
|
89
89
|
}
|
|
90
|
-
t === k && (
|
|
90
|
+
t === k && (C.value = n ?? [], T.value = 0, E.value = !1);
|
|
91
91
|
}, 180);
|
|
92
|
-
},
|
|
92
|
+
}, N = (e) => {
|
|
93
93
|
let { selection: t } = e.state;
|
|
94
94
|
if (!t.empty) return null;
|
|
95
95
|
let { $from: n } = t, i = n.parent.textBetween(Math.max(0, n.parentOffset - 100), n.parentOffset, void 0, "").match(r);
|
|
96
96
|
return i ? i[1] ?? "" : null;
|
|
97
|
-
},
|
|
98
|
-
let t =
|
|
97
|
+
}, P = (e) => {
|
|
98
|
+
let t = N(e);
|
|
99
99
|
if (t === null) return !1;
|
|
100
100
|
let n = e.state.selection.$from.pos;
|
|
101
|
-
return
|
|
101
|
+
return D = {
|
|
102
102
|
from: n - (t.length + 1),
|
|
103
103
|
to: n
|
|
104
|
-
}, t !== S.value && (S.value = t,
|
|
104
|
+
}, t !== S.value && (S.value = t, M(t)), !0;
|
|
105
105
|
}, F = (e) => {
|
|
106
106
|
let t = d.value;
|
|
107
|
-
if (!t || !
|
|
108
|
-
let n = t.state.schema.nodes[
|
|
107
|
+
if (!t || !D) return;
|
|
108
|
+
let n = t.state.schema.nodes[we];
|
|
109
109
|
if (!n) return;
|
|
110
110
|
let r = n.create({
|
|
111
111
|
userId: e.id,
|
|
112
112
|
name: e.name
|
|
113
|
-
}), { from: i, to: a } =
|
|
114
|
-
o.insertText(" ", s), o.setSelection(
|
|
113
|
+
}), { from: i, to: a } = D, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
|
|
114
|
+
o.insertText(" ", s), o.setSelection(K.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), y.hide();
|
|
115
115
|
}, I = (e) => {
|
|
116
|
-
if (!x.value || !
|
|
116
|
+
if (!x.value || !C.value.length) {
|
|
117
117
|
x.value && e.key === "Escape" && (e.preventDefault(), y.hide());
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
let t =
|
|
120
|
+
let t = C.value.length - 1;
|
|
121
121
|
switch (e.key) {
|
|
122
122
|
case "ArrowDown":
|
|
123
123
|
e.preventDefault(), e.stopPropagation(), T.value = T.value >= t ? 0 : T.value + 1;
|
|
@@ -127,7 +127,7 @@ var Ae = [
|
|
|
127
127
|
break;
|
|
128
128
|
case "Enter":
|
|
129
129
|
case "Tab": {
|
|
130
|
-
let t =
|
|
130
|
+
let t = C.value[T.value];
|
|
131
131
|
t && (e.preventDefault(), e.stopPropagation(), F(t));
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
@@ -137,17 +137,17 @@ var Ae = [
|
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
return p(() => {
|
|
140
|
-
y = new
|
|
140
|
+
y = new re({
|
|
141
141
|
content: g.value,
|
|
142
142
|
trigger: "@",
|
|
143
|
-
shouldShow:
|
|
143
|
+
shouldShow: P,
|
|
144
144
|
debounce: 0
|
|
145
145
|
}), y.onShow = () => {
|
|
146
146
|
x.value = !0;
|
|
147
147
|
}, y.onHide = () => {
|
|
148
148
|
x.value = !1, j();
|
|
149
149
|
}, y.update(d.value, h.value), window.addEventListener("keydown", I, !0);
|
|
150
|
-
}),
|
|
150
|
+
}), w([d, h], () => {
|
|
151
151
|
y?.update(d.value, h.value);
|
|
152
152
|
}), f(() => {
|
|
153
153
|
A && clearTimeout(A), window.removeEventListener("keydown", I, !0), y?.destroy();
|
|
@@ -156,21 +156,28 @@ var Ae = [
|
|
|
156
156
|
ref: g,
|
|
157
157
|
class: "kun-mention-dropdown",
|
|
158
158
|
"data-show": "false"
|
|
159
|
-
}, [
|
|
159
|
+
}, [C.value.length ? (m(!0), i(e, { key: 0 }, v(C.value, (e, t) => (m(), i("button", {
|
|
160
160
|
key: e.id,
|
|
161
161
|
type: "button",
|
|
162
162
|
class: "kun-mention-dropdown__item",
|
|
163
163
|
"data-active": t === T.value,
|
|
164
|
-
onMousedown:
|
|
164
|
+
onMousedown: O((t) => F(e), ["prevent"]),
|
|
165
165
|
onMouseenter: (e) => T.value = t
|
|
166
166
|
}, [e.avatar ? (m(), i("img", {
|
|
167
167
|
key: 0,
|
|
168
168
|
src: e.avatar,
|
|
169
169
|
alt: e.name,
|
|
170
170
|
class: "kun-mention-dropdown__avatar"
|
|
171
|
-
}, null, 8,
|
|
171
|
+
}, null, 8, He)) : (m(), i("span", Ue, b(e.name.charAt(0)), 1)), a("span", We, b(e.name), 1)], 40, Ve))), 128)) : E.value ? (m(), i("div", Ge, b(u.value.searching), 1)) : S.value ? (m(), i("div", Ke, b(u.value.empty), 1)) : (m(), i("div", qe, b(u.value.prompt), 1))], 512));
|
|
172
172
|
}
|
|
173
|
-
}),
|
|
173
|
+
}), Ye = (e, t) => {
|
|
174
|
+
let n = de.type(t), { from: r, to: i } = e.selection, a = "";
|
|
175
|
+
return e.doc.nodesBetween(r, i, (e) => {
|
|
176
|
+
if (a) return !1;
|
|
177
|
+
let t = n.isInSet(e.marks);
|
|
178
|
+
return t && (a = String(t.attrs.href ?? "")), !0;
|
|
179
|
+
}), a;
|
|
180
|
+
}, Z = (e) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`, Q = (e, t = 13) => `<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><text x="12" y="12" dominant-baseline="central" text-anchor="middle" font-size="${t}" font-weight="700" font-family="ui-sans-serif, system-ui, sans-serif" fill="currentColor">${e}</text></svg>`, $ = {
|
|
174
181
|
bold: Z("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
|
|
175
182
|
italic: Z("<line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/>"),
|
|
176
183
|
strike: Z("<path d=\"M16 4H9a3 3 0 0 0-2.83 4\"/><path d=\"M14 12a4 4 0 0 1 0 8H6\"/><line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/>"),
|
|
@@ -187,63 +194,90 @@ var Ae = [
|
|
|
187
194
|
spoiler: Z("<path d=\"M9.9 4.24A9.1 9.1 0 0 1 12 4c7 0 10 8 10 8a13.2 13.2 0 0 1-1.67 2.68\"/><path d=\"M6.6 6.6A13.5 13.5 0 0 0 2 12s3 8 10 8a9.7 9.7 0 0 0 5.4-1.6\"/><line x1=\"2\" y1=\"2\" x2=\"22\" y2=\"22\"/>"),
|
|
188
195
|
link: Z("<path d=\"M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/>"),
|
|
189
196
|
latex: Q("Σ", 15),
|
|
197
|
+
check: Z("<path d=\"m5 13 4 4L19 7\"/>"),
|
|
198
|
+
close: Z("<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/>"),
|
|
190
199
|
smile: Z("<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M8 14s1.5 2 4 2 4-2 4-2\"/><line x1=\"9\" y1=\"9\" x2=\"9.01\" y2=\"9\"/><line x1=\"15\" y1=\"9\" x2=\"15.01\" y2=\"9\"/>")
|
|
191
|
-
},
|
|
200
|
+
}, Xe = ["data-mode"], Ze = ["placeholder", "aria-label"], Qe = ["title", "aria-label"], $e = ["innerHTML"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = {
|
|
192
201
|
key: 0,
|
|
193
202
|
class: "kun-editor__toolbar-divider",
|
|
194
203
|
"aria-hidden": "true"
|
|
195
|
-
},
|
|
204
|
+
}, rt = [
|
|
196
205
|
"title",
|
|
197
206
|
"aria-label",
|
|
198
207
|
"aria-pressed",
|
|
199
208
|
"data-active",
|
|
200
209
|
"onMousedown"
|
|
201
|
-
],
|
|
210
|
+
], it = ["innerHTML"], at = /* @__PURE__ */ s({
|
|
202
211
|
__name: "SelectionTooltip",
|
|
203
212
|
setup(n) {
|
|
204
|
-
let { view: r, prevState: o } =
|
|
205
|
-
|
|
206
|
-
}, b = async () => {
|
|
207
|
-
let e = r.value, { from: t, to: n } = e?.state.selection ?? {
|
|
208
|
-
from: 0,
|
|
209
|
-
to: 0
|
|
210
|
-
}, i = e ? e.state.doc.textBetween(t, n, " ") : "", a = c?.adapters.linkPrompt, o = (a ? await a({ text: i }) : window.prompt(d.value ? "Link URL" : "链接 URL"))?.trim();
|
|
211
|
-
o && y(_e.key, { href: o });
|
|
212
|
-
}, S = t(() => {
|
|
213
|
-
let e = d.value;
|
|
213
|
+
let { view: r, prevState: o } = ee(), [, s] = M(), c = l(X), d = c?.activeMarks ?? Ie, h = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = t(() => {
|
|
214
|
+
let e = h.value;
|
|
214
215
|
return {
|
|
215
|
-
bold:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
title: e ? "Italic" : "斜体",
|
|
224
|
-
run: () => y(le.key),
|
|
225
|
-
mark: "italic"
|
|
226
|
-
},
|
|
227
|
-
strike: {
|
|
228
|
-
svg: $.strike,
|
|
229
|
-
title: e ? "Strikethrough" : "删除线",
|
|
230
|
-
run: () => y(Te.key),
|
|
231
|
-
mark: "strike"
|
|
232
|
-
},
|
|
233
|
-
code: {
|
|
234
|
-
svg: $.code,
|
|
235
|
-
title: e ? "Inline code" : "行内代码",
|
|
236
|
-
run: () => y(ue.key),
|
|
237
|
-
mark: "code"
|
|
238
|
-
},
|
|
239
|
-
link: {
|
|
240
|
-
svg: $.link,
|
|
241
|
-
title: e ? "Link" : "链接",
|
|
242
|
-
run: b
|
|
243
|
-
}
|
|
216
|
+
bold: e ? "Bold" : "加粗",
|
|
217
|
+
italic: e ? "Italic" : "斜体",
|
|
218
|
+
strike: e ? "Strikethrough" : "删除线",
|
|
219
|
+
code: e ? "Inline code" : "行内代码",
|
|
220
|
+
link: e ? "Link" : "链接",
|
|
221
|
+
linkUrl: e ? "Link URL" : "链接 URL",
|
|
222
|
+
apply: e ? "Apply" : "确定",
|
|
223
|
+
cancel: e ? "Cancel" : "取消"
|
|
244
224
|
};
|
|
245
|
-
}),
|
|
246
|
-
|
|
225
|
+
}), y = _(null), b, C = (e, t) => {
|
|
226
|
+
s()?.action(W(e, t));
|
|
227
|
+
}, T = _(!1), k = _(""), A = _(null), j = () => {
|
|
228
|
+
let e = "";
|
|
229
|
+
return s()?.action((t) => {
|
|
230
|
+
let n = r.value?.state;
|
|
231
|
+
n && (e = Ye(n, t));
|
|
232
|
+
}), e;
|
|
233
|
+
}, N = () => {
|
|
234
|
+
T.value = !1, k.value = "", r.value?.focus();
|
|
235
|
+
}, P = () => {
|
|
236
|
+
let e = k.value.trim();
|
|
237
|
+
e && C(J.key, { href: e }), N();
|
|
238
|
+
}, F = async () => {
|
|
239
|
+
let e = c?.adapters.linkPrompt;
|
|
240
|
+
if (e) {
|
|
241
|
+
let t = r.value, { from: n, to: i } = t?.state.selection ?? {
|
|
242
|
+
from: 0,
|
|
243
|
+
to: 0
|
|
244
|
+
}, a = (await e({ text: t ? t.state.doc.textBetween(n, i, " ") : "" }))?.trim();
|
|
245
|
+
a && C(J.key, { href: a });
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
k.value = j(), T.value = !0, await u(), A.value?.focus(), A.value?.select();
|
|
249
|
+
}, I = t(() => ({
|
|
250
|
+
bold: {
|
|
251
|
+
svg: $.bold,
|
|
252
|
+
title: g.value.bold,
|
|
253
|
+
run: () => C(he.key),
|
|
254
|
+
mark: "bold"
|
|
255
|
+
},
|
|
256
|
+
italic: {
|
|
257
|
+
svg: $.italic,
|
|
258
|
+
title: g.value.italic,
|
|
259
|
+
run: () => C(pe.key),
|
|
260
|
+
mark: "italic"
|
|
261
|
+
},
|
|
262
|
+
strike: {
|
|
263
|
+
svg: $.strike,
|
|
264
|
+
title: g.value.strike,
|
|
265
|
+
run: () => C(Oe.key),
|
|
266
|
+
mark: "strike"
|
|
267
|
+
},
|
|
268
|
+
code: {
|
|
269
|
+
svg: $.code,
|
|
270
|
+
title: g.value.code,
|
|
271
|
+
run: () => C(me.key),
|
|
272
|
+
mark: "code"
|
|
273
|
+
},
|
|
274
|
+
link: {
|
|
275
|
+
svg: $.link,
|
|
276
|
+
title: g.value.link,
|
|
277
|
+
run: F
|
|
278
|
+
}
|
|
279
|
+
})), L = t(() => {
|
|
280
|
+
let e = I.value, t = (c?.selectionToolbarItems ?? [
|
|
247
281
|
"bold",
|
|
248
282
|
"italic",
|
|
249
283
|
"strike",
|
|
@@ -258,34 +292,70 @@ var Ae = [
|
|
|
258
292
|
return n;
|
|
259
293
|
});
|
|
260
294
|
return p(() => {
|
|
261
|
-
|
|
262
|
-
content:
|
|
295
|
+
b = new ie({
|
|
296
|
+
content: y.value,
|
|
263
297
|
offset: 8
|
|
264
|
-
}),
|
|
265
|
-
|
|
266
|
-
|
|
298
|
+
}), b.onHide = () => {
|
|
299
|
+
T.value = !1, k.value = "";
|
|
300
|
+
}, b.update(r.value, o.value);
|
|
301
|
+
}), w([r, o], () => {
|
|
302
|
+
b?.update(r.value, o.value);
|
|
267
303
|
}), f(() => {
|
|
268
|
-
|
|
304
|
+
b?.destroy();
|
|
269
305
|
}), (t, n) => (m(), i("div", {
|
|
270
306
|
ref_key: "divRef",
|
|
271
|
-
ref:
|
|
307
|
+
ref: y,
|
|
272
308
|
class: "kun-editor__bubble",
|
|
273
|
-
"data-show": "false"
|
|
274
|
-
|
|
309
|
+
"data-show": "false",
|
|
310
|
+
"data-mode": T.value ? "link" : "marks"
|
|
311
|
+
}, [T.value ? (m(), i(e, { key: 0 }, [
|
|
312
|
+
E(a("input", {
|
|
313
|
+
ref_key: "inputRef",
|
|
314
|
+
ref: A,
|
|
315
|
+
"onUpdate:modelValue": n[0] ||= (e) => k.value = e,
|
|
316
|
+
type: "url",
|
|
317
|
+
class: "kun-editor__link-input",
|
|
318
|
+
placeholder: g.value.linkUrl,
|
|
319
|
+
"aria-label": g.value.linkUrl,
|
|
320
|
+
spellcheck: "false",
|
|
321
|
+
autocomplete: "off",
|
|
322
|
+
onKeydown: [n[1] ||= D(O((e) => P(), ["prevent"]), ["enter"]), n[2] ||= D(O((e) => N(), ["stop", "prevent"]), ["esc"])]
|
|
323
|
+
}, null, 40, Ze), [[S, k.value]]),
|
|
324
|
+
a("button", {
|
|
325
|
+
type: "button",
|
|
326
|
+
class: "kun-editor__bubble-btn",
|
|
327
|
+
title: g.value.apply,
|
|
328
|
+
"aria-label": g.value.apply,
|
|
329
|
+
onMousedown: n[3] ||= O((e) => P(), ["prevent"])
|
|
330
|
+
}, [a("span", {
|
|
331
|
+
class: "kun-editor__icon",
|
|
332
|
+
innerHTML: x($).check
|
|
333
|
+
}, null, 8, $e)], 40, Qe),
|
|
334
|
+
a("button", {
|
|
335
|
+
type: "button",
|
|
336
|
+
class: "kun-editor__bubble-btn",
|
|
337
|
+
title: g.value.cancel,
|
|
338
|
+
"aria-label": g.value.cancel,
|
|
339
|
+
onMousedown: n[4] ||= O((e) => N(), ["prevent"])
|
|
340
|
+
}, [a("span", {
|
|
341
|
+
class: "kun-editor__icon",
|
|
342
|
+
innerHTML: x($).close
|
|
343
|
+
}, null, 8, tt)], 40, et)
|
|
344
|
+
], 64)) : (m(!0), i(e, { key: 1 }, v(L.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", nt)) : (m(), i("button", {
|
|
275
345
|
key: 1,
|
|
276
346
|
type: "button",
|
|
277
347
|
class: "kun-editor__bubble-btn",
|
|
278
348
|
title: t.title,
|
|
279
349
|
"aria-label": t.title,
|
|
280
|
-
"aria-pressed": t.mark ? x(
|
|
281
|
-
"data-active": t.mark ? x(
|
|
282
|
-
onMousedown:
|
|
350
|
+
"aria-pressed": t.mark ? x(d)[t.mark] : void 0,
|
|
351
|
+
"data-active": t.mark ? x(d)[t.mark] : void 0,
|
|
352
|
+
onMousedown: O((e) => t.run(), ["prevent"])
|
|
283
353
|
}, [a("span", {
|
|
284
354
|
class: "kun-editor__icon",
|
|
285
355
|
innerHTML: t.svg
|
|
286
|
-
}, null, 8,
|
|
356
|
+
}, null, 8, it)], 40, rt))], 64))), 128))], 8, Xe));
|
|
287
357
|
}
|
|
288
|
-
}),
|
|
358
|
+
}), ot = /* @__PURE__ */ s({
|
|
289
359
|
__name: "MilkdownEditor",
|
|
290
360
|
props: {
|
|
291
361
|
modelValue: {},
|
|
@@ -300,44 +370,44 @@ var Ae = [
|
|
|
300
370
|
},
|
|
301
371
|
emits: ["update:modelValue", "update:loading"],
|
|
302
372
|
setup(e, { expose: t, emit: r }) {
|
|
303
|
-
let i = e, a = r, o = i.modelValue, s = !1, c = l(X), u =
|
|
304
|
-
let t =
|
|
305
|
-
t.set(
|
|
373
|
+
let i = e, a = r, o = i.modelValue, s = !1, c = l(X), u = P(), d = V("kunMention"), f = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!u, p = H("kunSelectionTooltip"), h = i.selectionToolbar && !!u, g = j((e) => {
|
|
374
|
+
let t = L.make().config((t) => {
|
|
375
|
+
t.set(B, e), t.set(te, i.modelValue), t.get(ne).markdownUpdated((e, t, n) => {
|
|
306
376
|
!i.active || s || t === n || (o = t, a("update:modelValue", t));
|
|
307
|
-
}), t.update(
|
|
377
|
+
}), t.update(z, (e) => ({
|
|
308
378
|
...e,
|
|
309
379
|
editable: () => !i.readonly
|
|
310
|
-
})), f && t.set(d.key, { view: u({ component:
|
|
311
|
-
}).use(
|
|
380
|
+
})), f && t.set(d.key, { view: u({ component: Je }) }), h && t.set(p.key, { view: u({ component: at }) });
|
|
381
|
+
}).use(ye(i.adapters, i.features, {
|
|
312
382
|
locale: i.locale,
|
|
313
383
|
placeholder: i.placeholder,
|
|
314
384
|
placeholderMode: i.placeholderMode
|
|
315
385
|
}));
|
|
316
|
-
return f && t.use(d), h && t.use(p), c && t.use(
|
|
386
|
+
return f && t.use(d), h && t.use(p), c && t.use(Be(c.activeMarks)), t;
|
|
317
387
|
});
|
|
318
|
-
|
|
388
|
+
w(g.loading, (e) => a("update:loading", e), { immediate: !0 }), w(() => i.modelValue, (e) => {
|
|
319
389
|
if (e === o) return;
|
|
320
390
|
o = e;
|
|
321
391
|
let t = g.get();
|
|
322
392
|
t && (s = !0, t.action(G(e)), s = !1);
|
|
323
|
-
}),
|
|
393
|
+
}), w(() => i.readonly, () => {
|
|
324
394
|
g.get()?.action((e) => {
|
|
325
|
-
let t = e.get(
|
|
395
|
+
let t = e.get(R);
|
|
326
396
|
t.dispatch(t.state.tr);
|
|
327
397
|
});
|
|
328
398
|
});
|
|
329
399
|
let _ = () => {
|
|
330
|
-
g.get()?.action((e) => e.get(
|
|
400
|
+
g.get()?.action((e) => e.get(R).focus());
|
|
331
401
|
};
|
|
332
402
|
return t({
|
|
333
403
|
insertQuote: (e) => {
|
|
334
|
-
g.get()?.action(W(
|
|
404
|
+
g.get()?.action(W(Se.key, e)), _();
|
|
335
405
|
},
|
|
336
406
|
insertMention: (e) => {
|
|
337
|
-
g.get()?.action(W(
|
|
407
|
+
g.get()?.action(W(xe.key, e)), _();
|
|
338
408
|
},
|
|
339
409
|
insertImage: (e) => {
|
|
340
|
-
g.get()?.action(W(
|
|
410
|
+
g.get()?.action(W(ue.key, {
|
|
341
411
|
src: e.src,
|
|
342
412
|
alt: e.alt ?? "",
|
|
343
413
|
title: e.title ?? ""
|
|
@@ -346,7 +416,7 @@ var Ae = [
|
|
|
346
416
|
uploadImage: (e) => {
|
|
347
417
|
let t = i.adapters.uploadImage, n = g.get();
|
|
348
418
|
!t || !n || n.action((n) => {
|
|
349
|
-
|
|
419
|
+
Ee(n.get(R), e, {
|
|
350
420
|
uploadImage: t,
|
|
351
421
|
notify: i.adapters.notify,
|
|
352
422
|
locale: i.locale
|
|
@@ -356,38 +426,116 @@ var Ae = [
|
|
|
356
426
|
focus: _,
|
|
357
427
|
scrollToHeading: (e) => {
|
|
358
428
|
g.get()?.action((t) => {
|
|
359
|
-
let n = t.get(
|
|
429
|
+
let n = t.get(R), r = 0, i = -1;
|
|
360
430
|
if (n.state.doc.forEach((t, n) => {
|
|
361
431
|
t.type.name === "heading" && (r === e && (i = n), r += 1);
|
|
362
432
|
}), !(i < 0) && (n.nodeDOM(i)?.scrollIntoView({
|
|
363
433
|
behavior: "smooth",
|
|
364
434
|
block: "start"
|
|
365
435
|
}), n.editable)) {
|
|
366
|
-
let e =
|
|
436
|
+
let e = K.near(n.state.doc.resolve(i + 1));
|
|
367
437
|
n.dispatch(n.state.tr.setSelection(e)), n.focus();
|
|
368
438
|
}
|
|
369
439
|
});
|
|
370
440
|
}
|
|
371
|
-
}), (e, t) => (m(), n(x(
|
|
441
|
+
}), (e, t) => (m(), n(x(k)));
|
|
442
|
+
}
|
|
443
|
+
}), st = [
|
|
444
|
+
"title",
|
|
445
|
+
"aria-label",
|
|
446
|
+
"aria-expanded"
|
|
447
|
+
], ct = ["innerHTML"], lt = { class: "kun-editor__link-panel" }, ut = ["placeholder", "aria-label"], dt = ["title", "aria-label"], ft = ["innerHTML"], pt = /* @__PURE__ */ s({
|
|
448
|
+
__name: "LinkInput",
|
|
449
|
+
setup(e) {
|
|
450
|
+
let [, n] = M(), r = l(X), o = t(() => (r?.locale ?? "zh-cn").toLowerCase().startsWith("en")), s = t(() => {
|
|
451
|
+
let e = o.value;
|
|
452
|
+
return {
|
|
453
|
+
link: e ? "Link" : "链接",
|
|
454
|
+
linkUrl: e ? "Link URL" : "链接 URL",
|
|
455
|
+
apply: e ? "Apply" : "确定"
|
|
456
|
+
};
|
|
457
|
+
}), c = _(!1), d = _(""), h = _(null), g = _(null), v = (e) => {
|
|
458
|
+
e && n()?.action(W(J.key, { href: e }));
|
|
459
|
+
}, y = () => {
|
|
460
|
+
c.value = !1, d.value = "";
|
|
461
|
+
}, b = () => {
|
|
462
|
+
y(), n()?.action((e) => e.get(R).focus());
|
|
463
|
+
}, w = () => {
|
|
464
|
+
v(d.value.trim()), b();
|
|
465
|
+
}, T = async () => {
|
|
466
|
+
let e = r?.adapters.linkPrompt;
|
|
467
|
+
if (e) {
|
|
468
|
+
let t = "";
|
|
469
|
+
n()?.action((e) => {
|
|
470
|
+
let { state: n } = e.get(R), { from: r, to: i } = n.selection;
|
|
471
|
+
t = n.doc.textBetween(r, i, " ");
|
|
472
|
+
}), v((await e({ text: t }))?.trim() ?? "");
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (c.value) {
|
|
476
|
+
y();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
n()?.action((e) => {
|
|
480
|
+
d.value = Ye(e.get(R).state, e);
|
|
481
|
+
}), c.value = !0, await u(), g.value?.focus(), g.value?.select();
|
|
482
|
+
}, k = (e) => {
|
|
483
|
+
c.value && h.value && !h.value.contains(e.target) && y();
|
|
484
|
+
};
|
|
485
|
+
return p(() => document.addEventListener("click", k)), f(() => document.removeEventListener("click", k)), (e, t) => (m(), i("div", {
|
|
486
|
+
ref_key: "rootRef",
|
|
487
|
+
ref: h,
|
|
488
|
+
class: "kun-editor__link"
|
|
489
|
+
}, [a("button", {
|
|
490
|
+
type: "button",
|
|
491
|
+
class: "kun-editor__tool",
|
|
492
|
+
title: s.value.link,
|
|
493
|
+
"aria-label": s.value.link,
|
|
494
|
+
"aria-expanded": c.value,
|
|
495
|
+
onClick: T
|
|
496
|
+
}, [a("span", {
|
|
497
|
+
class: "kun-editor__icon",
|
|
498
|
+
innerHTML: x($).link
|
|
499
|
+
}, null, 8, ct)], 8, st), E(a("div", lt, [E(a("input", {
|
|
500
|
+
ref_key: "inputRef",
|
|
501
|
+
ref: g,
|
|
502
|
+
"onUpdate:modelValue": t[0] ||= (e) => d.value = e,
|
|
503
|
+
type: "url",
|
|
504
|
+
class: "kun-editor__link-input",
|
|
505
|
+
placeholder: s.value.linkUrl,
|
|
506
|
+
"aria-label": s.value.linkUrl,
|
|
507
|
+
spellcheck: "false",
|
|
508
|
+
autocomplete: "off",
|
|
509
|
+
onKeydown: [t[1] ||= D(O((e) => w(), ["prevent"]), ["enter"]), t[2] ||= D(O((e) => b(), ["stop", "prevent"]), ["esc"])]
|
|
510
|
+
}, null, 40, ut), [[S, d.value]]), a("button", {
|
|
511
|
+
type: "button",
|
|
512
|
+
class: "kun-editor__tool",
|
|
513
|
+
title: s.value.apply,
|
|
514
|
+
"aria-label": s.value.apply,
|
|
515
|
+
onClick: t[3] ||= (e) => w()
|
|
516
|
+
}, [a("span", {
|
|
517
|
+
class: "kun-editor__icon",
|
|
518
|
+
innerHTML: x($).check
|
|
519
|
+
}, null, 8, ft)], 8, dt)], 512), [[C, c.value]])], 512));
|
|
372
520
|
}
|
|
373
|
-
}),
|
|
521
|
+
}), mt = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), ht = [
|
|
374
522
|
"title",
|
|
375
523
|
"aria-label",
|
|
376
524
|
"aria-expanded"
|
|
377
|
-
],
|
|
525
|
+
], gt = ["innerHTML"], _t = { class: "kun-editor__picker-panel" }, vt = {
|
|
378
526
|
key: 0,
|
|
379
527
|
class: "kun-editor__picker-tabs",
|
|
380
528
|
role: "tablist"
|
|
381
|
-
},
|
|
529
|
+
}, yt = ["data-active"], bt = ["data-active"], xt = { class: "kun-editor__emoji-grid" }, St = ["onClick"], Ct = {
|
|
382
530
|
key: 1,
|
|
383
531
|
class: "kun-editor__sticker-body"
|
|
384
|
-
},
|
|
532
|
+
}, wt = { class: "kun-editor__pack-name" }, Tt = { class: "kun-editor__sticker-grid" }, Et = ["title", "onClick"], Dt = ["src", "alt"], Ot = {
|
|
385
533
|
key: 1,
|
|
386
534
|
class: "kun-editor__picker-hint"
|
|
387
|
-
},
|
|
535
|
+
}, kt = /* @__PURE__ */ s({
|
|
388
536
|
__name: "StickerPicker",
|
|
389
537
|
setup(n) {
|
|
390
|
-
let [, o] =
|
|
538
|
+
let [, o] = M(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
|
|
391
539
|
trigger: "Emoji & stickers",
|
|
392
540
|
emoji: "Emoji",
|
|
393
541
|
sticker: "Stickers",
|
|
@@ -399,9 +547,9 @@ var Ae = [
|
|
|
399
547
|
sticker: "贴纸",
|
|
400
548
|
empty: "暂无贴纸",
|
|
401
549
|
failed: "贴纸加载失败"
|
|
402
|
-
}), g = _(!1), y = _(null),
|
|
403
|
-
if (!(
|
|
404
|
-
|
|
550
|
+
}), g = _(!1), y = _(null), S = _("emoji"), w = _([]), T = _(!1), D = _(!1), O = async () => {
|
|
551
|
+
if (!(T.value || !c)) {
|
|
552
|
+
T.value = !0;
|
|
405
553
|
try {
|
|
406
554
|
w.value = await c();
|
|
407
555
|
} catch {
|
|
@@ -410,17 +558,17 @@ var Ae = [
|
|
|
410
558
|
}
|
|
411
559
|
}, k = () => {
|
|
412
560
|
g.value = !g.value, g.value && u && O();
|
|
413
|
-
},
|
|
561
|
+
}, A = (e) => {
|
|
414
562
|
g.value && y.value && !y.value.contains(e.target) && (g.value = !1);
|
|
415
563
|
};
|
|
416
|
-
p(() => document.addEventListener("click",
|
|
417
|
-
let
|
|
564
|
+
p(() => document.addEventListener("click", A)), f(() => document.removeEventListener("click", A));
|
|
565
|
+
let j = (e) => {
|
|
418
566
|
o()?.action((t) => {
|
|
419
|
-
let n = t.get(
|
|
567
|
+
let n = t.get(R), { state: r } = n;
|
|
420
568
|
n.dispatch(r.tr.insertText(e, r.selection.from));
|
|
421
569
|
});
|
|
422
570
|
}, N = (e, t) => {
|
|
423
|
-
o()?.action(W(
|
|
571
|
+
o()?.action(W(ue.key, {
|
|
424
572
|
src: e,
|
|
425
573
|
title: t,
|
|
426
574
|
alt: t
|
|
@@ -440,28 +588,28 @@ var Ae = [
|
|
|
440
588
|
}, [a("span", {
|
|
441
589
|
class: "kun-editor__icon",
|
|
442
590
|
innerHTML: x($).smile
|
|
443
|
-
}, null, 8,
|
|
444
|
-
u ? (m(), i("div",
|
|
591
|
+
}, null, 8, gt)], 8, ht), E(a("div", _t, [
|
|
592
|
+
u ? (m(), i("div", vt, [a("button", {
|
|
445
593
|
type: "button",
|
|
446
594
|
class: "kun-editor__picker-tab",
|
|
447
|
-
"data-active":
|
|
448
|
-
onClick: n[0] ||= (e) =>
|
|
449
|
-
}, b(h.value.emoji), 9,
|
|
595
|
+
"data-active": S.value === "emoji",
|
|
596
|
+
onClick: n[0] ||= (e) => S.value = "emoji"
|
|
597
|
+
}, b(h.value.emoji), 9, yt), a("button", {
|
|
450
598
|
type: "button",
|
|
451
599
|
class: "kun-editor__picker-tab",
|
|
452
|
-
"data-active":
|
|
453
|
-
onClick: n[1] ||= (e) =>
|
|
454
|
-
}, b(h.value.sticker), 9,
|
|
455
|
-
|
|
600
|
+
"data-active": S.value === "sticker",
|
|
601
|
+
onClick: n[1] ||= (e) => S.value = "sticker"
|
|
602
|
+
}, b(h.value.sticker), 9, bt)])) : r("", !0),
|
|
603
|
+
E(a("div", xt, [(m(!0), i(e, null, v(x(mt), (e, t) => (m(), i("button", {
|
|
456
604
|
key: t,
|
|
457
605
|
type: "button",
|
|
458
606
|
class: "kun-editor__emoji",
|
|
459
|
-
onClick: (t) =>
|
|
460
|
-
}, b(e), 9,
|
|
461
|
-
u ?
|
|
607
|
+
onClick: (t) => j(e)
|
|
608
|
+
}, b(e), 9, St))), 128))], 512), [[C, !u || S.value === "emoji"]]),
|
|
609
|
+
u ? E((m(), i("div", Ct, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
|
|
462
610
|
key: t.name,
|
|
463
611
|
class: "kun-editor__pack"
|
|
464
|
-
}, [a("div",
|
|
612
|
+
}, [a("div", wt, b(t.name), 1), a("div", Tt, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
|
|
465
613
|
key: t,
|
|
466
614
|
type: "button",
|
|
467
615
|
class: "kun-editor__sticker",
|
|
@@ -471,44 +619,35 @@ var Ae = [
|
|
|
471
619
|
src: e.src,
|
|
472
620
|
alt: e.name,
|
|
473
621
|
loading: "lazy"
|
|
474
|
-
}, null, 8,
|
|
475
|
-
], 512), [[
|
|
622
|
+
}, null, 8, Dt)], 8, Et))), 128))])]))), 128)) : (m(), i("div", Ot, b(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[C, S.value === "sticker"]]) : r("", !0)
|
|
623
|
+
], 512), [[C, g.value]])], 512));
|
|
476
624
|
}
|
|
477
|
-
}),
|
|
625
|
+
}), At = {
|
|
478
626
|
class: "kun-editor__format-toolbar",
|
|
479
627
|
role: "toolbar"
|
|
480
|
-
},
|
|
628
|
+
}, jt = ["aria-label"], Mt = {
|
|
481
629
|
value: "",
|
|
482
630
|
disabled: "",
|
|
483
631
|
selected: ""
|
|
484
|
-
},
|
|
632
|
+
}, Nt = ["value"], Pt = [
|
|
485
633
|
"title",
|
|
486
634
|
"aria-label",
|
|
487
635
|
"aria-pressed",
|
|
488
636
|
"data-active",
|
|
489
637
|
"onClick"
|
|
490
|
-
],
|
|
638
|
+
], Ft = ["innerHTML"], It = ["title", "aria-label"], Lt = ["innerHTML"], Rt = /* @__PURE__ */ s({
|
|
491
639
|
__name: "EditorToolbar",
|
|
492
|
-
setup(
|
|
493
|
-
let [,
|
|
494
|
-
|
|
495
|
-
}, g = async () => {
|
|
496
|
-
let e = "";
|
|
497
|
-
s()?.action((t) => {
|
|
498
|
-
let n = t.get(L), { from: r, to: i } = n.state.selection;
|
|
499
|
-
e = n.state.doc.textBetween(r, i, " ");
|
|
500
|
-
});
|
|
501
|
-
let t = c?.adapters.linkPrompt, n = (t ? await t({ text: e }) : window.prompt(p.value ? "Link URL" : "链接 URL"))?.trim();
|
|
502
|
-
n && h(_e.key, { href: n });
|
|
640
|
+
setup(s) {
|
|
641
|
+
let [, c] = M(), u = l(X), d = u?.activeMarks ?? Ie, f = t(() => u?.adapters.uploadImage), p = t(() => u?.features.sticker !== !1), h = t(() => (u?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = (e, t) => {
|
|
642
|
+
c()?.action(W(e, t));
|
|
503
643
|
}, y = t(() => {
|
|
504
|
-
let e =
|
|
644
|
+
let e = h.value;
|
|
505
645
|
return {
|
|
506
646
|
textSize: e ? "Text size" : "文本大小",
|
|
507
647
|
bold: e ? "Bold" : "加粗",
|
|
508
648
|
italic: e ? "Italic" : "斜体",
|
|
509
649
|
strike: e ? "Strikethrough" : "删除线",
|
|
510
650
|
code: e ? "Inline code" : "行内代码",
|
|
511
|
-
link: e ? "Link" : "链接",
|
|
512
651
|
bulletList: e ? "Bullet list" : "无序列表",
|
|
513
652
|
orderedList: e ? "Ordered list" : "有序列表",
|
|
514
653
|
quote: e ? "Blockquote" : "引用块",
|
|
@@ -518,7 +657,7 @@ var Ae = [
|
|
|
518
657
|
image: e ? "Upload image" : "上传图片"
|
|
519
658
|
};
|
|
520
659
|
}), S = t(() => {
|
|
521
|
-
let e =
|
|
660
|
+
let e = h.value;
|
|
522
661
|
return [
|
|
523
662
|
"正文",
|
|
524
663
|
"一级标题",
|
|
@@ -533,110 +672,106 @@ var Ae = [
|
|
|
533
672
|
}));
|
|
534
673
|
}), C = (e) => {
|
|
535
674
|
let t = e.target;
|
|
536
|
-
|
|
675
|
+
g(Te.key, Number(t.value)), t.selectedIndex = 0;
|
|
537
676
|
}, w = t(() => [
|
|
538
677
|
[
|
|
539
678
|
{
|
|
540
679
|
svg: $.bold,
|
|
541
680
|
title: y.value.bold,
|
|
542
|
-
run: () =>
|
|
681
|
+
run: () => g(he.key),
|
|
543
682
|
mark: "bold"
|
|
544
683
|
},
|
|
545
684
|
{
|
|
546
685
|
svg: $.italic,
|
|
547
686
|
title: y.value.italic,
|
|
548
|
-
run: () =>
|
|
687
|
+
run: () => g(pe.key),
|
|
549
688
|
mark: "italic"
|
|
550
689
|
},
|
|
551
690
|
{
|
|
552
691
|
svg: $.strike,
|
|
553
692
|
title: y.value.strike,
|
|
554
|
-
run: () =>
|
|
693
|
+
run: () => g(Oe.key),
|
|
555
694
|
mark: "strike"
|
|
556
695
|
},
|
|
557
696
|
{
|
|
558
697
|
svg: $.code,
|
|
559
698
|
title: y.value.code,
|
|
560
|
-
run: () =>
|
|
699
|
+
run: () => g(me.key),
|
|
561
700
|
mark: "code"
|
|
562
701
|
},
|
|
563
|
-
{
|
|
564
|
-
svg: $.link,
|
|
565
|
-
title: y.value.link,
|
|
566
|
-
run: g
|
|
567
|
-
}
|
|
702
|
+
{ link: !0 }
|
|
568
703
|
],
|
|
569
704
|
[
|
|
570
705
|
{
|
|
571
706
|
svg: $.bulletList,
|
|
572
707
|
title: y.value.bulletList,
|
|
573
|
-
run: () =>
|
|
708
|
+
run: () => g(_e.key)
|
|
574
709
|
},
|
|
575
710
|
{
|
|
576
711
|
svg: $.orderedList,
|
|
577
712
|
title: y.value.orderedList,
|
|
578
|
-
run: () =>
|
|
713
|
+
run: () => g(ve.key)
|
|
579
714
|
},
|
|
580
715
|
{
|
|
581
716
|
svg: $.quote,
|
|
582
717
|
title: y.value.quote,
|
|
583
|
-
run: () =>
|
|
718
|
+
run: () => g(ge.key)
|
|
584
719
|
},
|
|
585
720
|
{
|
|
586
721
|
svg: $.codeBlock,
|
|
587
722
|
title: y.value.codeBlock,
|
|
588
|
-
run: () =>
|
|
723
|
+
run: () => g(q.key, "")
|
|
589
724
|
},
|
|
590
725
|
{
|
|
591
726
|
svg: $.hr,
|
|
592
727
|
title: y.value.hr,
|
|
593
|
-
run: () =>
|
|
728
|
+
run: () => g(le.key)
|
|
594
729
|
}
|
|
595
730
|
],
|
|
596
731
|
[{
|
|
597
732
|
svg: $.spoiler,
|
|
598
733
|
title: y.value.spoiler,
|
|
599
|
-
run: () =>
|
|
734
|
+
run: () => g(be.key)
|
|
600
735
|
}]
|
|
601
736
|
]), T = _(null), E = () => T.value?.click(), D = (e) => {
|
|
602
737
|
let t = e.target, n = t.files?.[0];
|
|
603
738
|
t.value = "";
|
|
604
|
-
let r =
|
|
605
|
-
!n || !r ||
|
|
606
|
-
|
|
739
|
+
let r = f.value;
|
|
740
|
+
!n || !r || c()?.action((e) => {
|
|
741
|
+
Ee(e.get(R), n, {
|
|
607
742
|
uploadImage: r,
|
|
608
|
-
notify:
|
|
609
|
-
locale:
|
|
743
|
+
notify: u?.adapters.notify,
|
|
744
|
+
locale: u?.locale
|
|
610
745
|
});
|
|
611
746
|
});
|
|
612
747
|
};
|
|
613
|
-
return (t,
|
|
748
|
+
return (t, s) => (m(), i("div", At, [
|
|
614
749
|
a("select", {
|
|
615
750
|
class: "kun-editor__heading-select",
|
|
616
751
|
"aria-label": y.value.textSize,
|
|
617
752
|
onChange: C
|
|
618
|
-
}, [a("option",
|
|
753
|
+
}, [a("option", Mt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
|
|
619
754
|
key: e.level,
|
|
620
755
|
value: e.level
|
|
621
|
-
}, b(e.label), 9,
|
|
622
|
-
(m(!0), i(e, null, v(w.value, (t, r) => (m(), i(e, { key: r }, [
|
|
756
|
+
}, b(e.label), 9, Nt))), 128))], 40, jt),
|
|
757
|
+
(m(!0), i(e, null, v(w.value, (t, r) => (m(), i(e, { key: r }, [s[0] ||= a("span", {
|
|
623
758
|
class: "kun-editor__toolbar-divider",
|
|
624
759
|
"aria-hidden": "true"
|
|
625
|
-
}, null, -1), (m(!0), i(e, null, v(t, (e, t)
|
|
626
|
-
key:
|
|
760
|
+
}, null, -1), (m(!0), i(e, null, v(t, (t, r) => (m(), i(e, { key: r }, ["link" in t ? (m(), n(pt, { key: 0 })) : (m(), i("button", {
|
|
761
|
+
key: 1,
|
|
627
762
|
type: "button",
|
|
628
763
|
class: "kun-editor__tool",
|
|
629
|
-
title:
|
|
630
|
-
"aria-label":
|
|
631
|
-
"aria-pressed":
|
|
632
|
-
"data-active":
|
|
633
|
-
onClick: (
|
|
764
|
+
title: t.title,
|
|
765
|
+
"aria-label": t.title,
|
|
766
|
+
"aria-pressed": t.mark ? x(d)[t.mark] : void 0,
|
|
767
|
+
"data-active": t.mark ? x(d)[t.mark] : void 0,
|
|
768
|
+
onClick: (e) => t.run()
|
|
634
769
|
}, [a("span", {
|
|
635
770
|
class: "kun-editor__icon",
|
|
636
|
-
innerHTML:
|
|
637
|
-
}, null, 8,
|
|
638
|
-
|
|
639
|
-
|
|
771
|
+
innerHTML: t.svg
|
|
772
|
+
}, null, 8, Ft)], 8, Pt))], 64))), 128))], 64))), 128)),
|
|
773
|
+
f.value ? (m(), i(e, { key: 0 }, [
|
|
774
|
+
s[1] ||= a("span", {
|
|
640
775
|
class: "kun-editor__toolbar-divider",
|
|
641
776
|
"aria-hidden": "true"
|
|
642
777
|
}, null, -1),
|
|
@@ -649,7 +784,7 @@ var Ae = [
|
|
|
649
784
|
}, [a("span", {
|
|
650
785
|
class: "kun-editor__icon",
|
|
651
786
|
innerHTML: x($).image
|
|
652
|
-
}, null, 8,
|
|
787
|
+
}, null, 8, Lt)], 8, It),
|
|
653
788
|
a("input", {
|
|
654
789
|
ref_key: "fileInput",
|
|
655
790
|
ref: T,
|
|
@@ -659,34 +794,34 @@ var Ae = [
|
|
|
659
794
|
onChange: D
|
|
660
795
|
}, null, 544)
|
|
661
796
|
], 64)) : r("", !0),
|
|
662
|
-
|
|
797
|
+
p.value ? (m(), i(e, { key: 1 }, [s[2] ||= a("span", {
|
|
663
798
|
class: "kun-editor__toolbar-divider",
|
|
664
799
|
"aria-hidden": "true"
|
|
665
|
-
}, null, -1), o(
|
|
800
|
+
}, null, -1), o(kt)], 64)) : r("", !0)
|
|
666
801
|
]));
|
|
667
802
|
}
|
|
668
|
-
}),
|
|
803
|
+
}), zt = /* @__PURE__ */ s({
|
|
669
804
|
__name: "ToolbarHost",
|
|
670
805
|
setup(e) {
|
|
671
|
-
let [, t] =
|
|
806
|
+
let [, t] = M(), n = l(X, void 0), r = (e, n) => {
|
|
672
807
|
t()?.action(W(e, n));
|
|
673
808
|
}, i = () => {
|
|
674
|
-
t()?.action((e) => e.get(
|
|
809
|
+
t()?.action((e) => e.get(R).focus());
|
|
675
810
|
}, a = {
|
|
676
811
|
run: r,
|
|
677
812
|
get activeMarks() {
|
|
678
|
-
return n?.activeMarks ??
|
|
813
|
+
return n?.activeMarks ?? Ie;
|
|
679
814
|
},
|
|
680
815
|
insertText: (e) => {
|
|
681
816
|
t()?.action((t) => {
|
|
682
|
-
let n = t.get(
|
|
817
|
+
let n = t.get(R);
|
|
683
818
|
n.dispatch(n.state.tr.insertText(e));
|
|
684
819
|
}), i();
|
|
685
820
|
},
|
|
686
821
|
uploadImage: (e) => {
|
|
687
822
|
let r = n?.adapters.uploadImage, i = t();
|
|
688
823
|
!r || !i || i.action((t) => {
|
|
689
|
-
|
|
824
|
+
Ee(t.get(R), e, {
|
|
690
825
|
uploadImage: r,
|
|
691
826
|
notify: n?.adapters.notify,
|
|
692
827
|
locale: n?.locale
|
|
@@ -694,20 +829,20 @@ var Ae = [
|
|
|
694
829
|
});
|
|
695
830
|
},
|
|
696
831
|
insertLink: (e) => {
|
|
697
|
-
r(
|
|
832
|
+
r(J.key, e), i();
|
|
698
833
|
},
|
|
699
834
|
insertImage: (e) => {
|
|
700
|
-
r(
|
|
835
|
+
r(ue.key, {
|
|
701
836
|
src: e.src,
|
|
702
837
|
alt: e.alt ?? "",
|
|
703
838
|
title: e.title ?? ""
|
|
704
839
|
}), i();
|
|
705
840
|
},
|
|
706
841
|
insertQuote: (e) => {
|
|
707
|
-
r(
|
|
842
|
+
r(Se.key, e), i();
|
|
708
843
|
},
|
|
709
844
|
insertMention: (e) => {
|
|
710
|
-
r(
|
|
845
|
+
r(xe.key, e), i();
|
|
711
846
|
},
|
|
712
847
|
focus: i,
|
|
713
848
|
get adapters() {
|
|
@@ -722,7 +857,7 @@ var Ae = [
|
|
|
722
857
|
};
|
|
723
858
|
return (e, t) => y(e.$slots, "default", d(c(a)));
|
|
724
859
|
}
|
|
725
|
-
}),
|
|
860
|
+
}), Bt = /* @__PURE__ */ s({
|
|
726
861
|
__name: "MarkdownSource",
|
|
727
862
|
props: {
|
|
728
863
|
modelValue: {},
|
|
@@ -730,13 +865,13 @@ var Ae = [
|
|
|
730
865
|
},
|
|
731
866
|
emits: ["update:modelValue"],
|
|
732
867
|
setup(e, { expose: t, emit: n }) {
|
|
733
|
-
let r = e, a = n, o = _(null), s = null, c =
|
|
868
|
+
let r = e, a = n, o = _(null), s = null, c = ke.define(), l = (e) => Ae.create({
|
|
734
869
|
doc: e,
|
|
735
870
|
extensions: [
|
|
736
|
-
|
|
871
|
+
Ce(),
|
|
737
872
|
Y.lineWrapping,
|
|
738
|
-
|
|
739
|
-
|
|
873
|
+
Me,
|
|
874
|
+
je(),
|
|
740
875
|
Y.editable.of(!r.readonly),
|
|
741
876
|
Y.updateListener.of((e) => {
|
|
742
877
|
e.docChanged && !e.transactions.some((e) => e.annotation(c)) && a("update:modelValue", e.state.doc.toString());
|
|
@@ -773,7 +908,7 @@ var Ae = [
|
|
|
773
908
|
selection: { anchor: i },
|
|
774
909
|
scrollIntoView: !0
|
|
775
910
|
}), s.focus());
|
|
776
|
-
} }),
|
|
911
|
+
} }), w(() => r.modelValue, (e) => {
|
|
777
912
|
if (!s || s.state.doc.toString() === e) return;
|
|
778
913
|
let { anchor: t, head: n } = s.state.selection.main, r = e.length;
|
|
779
914
|
s.dispatch({
|
|
@@ -794,23 +929,23 @@ var Ae = [
|
|
|
794
929
|
class: "kun-editor__source"
|
|
795
930
|
}, null, 512));
|
|
796
931
|
}
|
|
797
|
-
}),
|
|
932
|
+
}), Vt = ["data-mode"], Ht = {
|
|
798
933
|
key: 0,
|
|
799
934
|
class: "kun-editor__toolbar",
|
|
800
935
|
role: "tablist"
|
|
801
|
-
},
|
|
936
|
+
}, Ut = [
|
|
802
937
|
"aria-selected",
|
|
803
938
|
"data-active",
|
|
804
939
|
"onClick"
|
|
805
|
-
],
|
|
940
|
+
], Wt = ["title", "aria-label"], Gt = [
|
|
806
941
|
"data-active",
|
|
807
942
|
"title",
|
|
808
943
|
"aria-pressed"
|
|
809
|
-
],
|
|
944
|
+
], Kt = ["data-swap"], qt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Jt = {
|
|
810
945
|
key: 1,
|
|
811
946
|
class: "kun-editor__loading",
|
|
812
947
|
"aria-hidden": "true"
|
|
813
|
-
},
|
|
948
|
+
}, Yt = /* @__PURE__ */ s({
|
|
814
949
|
__name: "KunEditor",
|
|
815
950
|
props: {
|
|
816
951
|
modelValue: {},
|
|
@@ -842,54 +977,54 @@ var Ae = [
|
|
|
842
977
|
"update:headings",
|
|
843
978
|
"update:loading"
|
|
844
979
|
],
|
|
845
|
-
setup(s, { expose: l, emit:
|
|
980
|
+
setup(s, { expose: l, emit: S }) {
|
|
846
981
|
let D = [
|
|
847
982
|
"bold",
|
|
848
983
|
"italic",
|
|
849
984
|
"strike",
|
|
850
985
|
"code",
|
|
851
986
|
"link"
|
|
852
|
-
],
|
|
987
|
+
], O = s, k = S, j = _(!1);
|
|
853
988
|
p(() => {
|
|
854
|
-
|
|
989
|
+
j.value = !0;
|
|
855
990
|
});
|
|
856
|
-
let
|
|
857
|
-
|
|
991
|
+
let M = _(!0), ee = (e) => {
|
|
992
|
+
M.value = e, k("update:loading", e);
|
|
858
993
|
};
|
|
859
|
-
|
|
860
|
-
let
|
|
994
|
+
w(() => O.modelValue, (e) => k("update:headings", I(e)), { immediate: !0 });
|
|
995
|
+
let P = g(Fe());
|
|
861
996
|
h(X, {
|
|
862
997
|
get adapters() {
|
|
863
|
-
return
|
|
998
|
+
return O.adapters;
|
|
864
999
|
},
|
|
865
1000
|
get features() {
|
|
866
|
-
return
|
|
1001
|
+
return O.features;
|
|
867
1002
|
},
|
|
868
1003
|
get locale() {
|
|
869
|
-
return
|
|
1004
|
+
return O.locale;
|
|
870
1005
|
},
|
|
871
1006
|
get selectionToolbarItems() {
|
|
872
|
-
return Array.isArray(
|
|
1007
|
+
return Array.isArray(O.selectionToolbar) ? O.selectionToolbar : D;
|
|
873
1008
|
},
|
|
874
1009
|
get activeMarks() {
|
|
875
|
-
return
|
|
1010
|
+
return P;
|
|
876
1011
|
}
|
|
877
1012
|
});
|
|
878
|
-
let
|
|
1013
|
+
let F = t(() => O.selectionToolbar !== !1), L = _(O.views.includes("wysiwyg") ? "wysiwyg" : O.views[0] ?? "wysiwyg"), te = (e) => {
|
|
879
1014
|
L.value = e;
|
|
880
1015
|
};
|
|
881
|
-
|
|
1016
|
+
w(() => O.views, (e) => {
|
|
882
1017
|
e.includes(L.value) || (L.value = e[0] ?? "wysiwyg");
|
|
883
1018
|
});
|
|
884
|
-
let
|
|
885
|
-
|
|
886
|
-
},
|
|
887
|
-
|
|
888
|
-
|
|
1019
|
+
let R = _(!1), z = () => {
|
|
1020
|
+
R.value = !R.value;
|
|
1021
|
+
}, B = _(O.scrollSync);
|
|
1022
|
+
w(() => O.scrollSync, (e) => {
|
|
1023
|
+
B.value = e;
|
|
889
1024
|
});
|
|
890
|
-
let
|
|
891
|
-
|
|
892
|
-
},
|
|
1025
|
+
let ne = () => {
|
|
1026
|
+
B.value = !B.value;
|
|
1027
|
+
}, re = t(() => O.locale.toLowerCase().startsWith("en")), V = t(() => re.value ? {
|
|
893
1028
|
wysiwyg: "Preview",
|
|
894
1029
|
source: "Markdown",
|
|
895
1030
|
split: "Split",
|
|
@@ -901,104 +1036,104 @@ var Ae = [
|
|
|
901
1036
|
split: "分栏",
|
|
902
1037
|
swap: "左右互换",
|
|
903
1038
|
scrollSync: "同步滚动"
|
|
904
|
-
}),
|
|
905
|
-
|
|
906
|
-
},
|
|
907
|
-
|
|
908
|
-
let e =
|
|
1039
|
+
}), ie = _(null), H = null, U = null, W = null, G = () => {
|
|
1040
|
+
H?.(), H = null, U = null;
|
|
1041
|
+
}, ae = () => {
|
|
1042
|
+
G();
|
|
1043
|
+
let e = ie.value;
|
|
909
1044
|
if (!e) return;
|
|
910
1045
|
let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
|
|
911
1046
|
if (!t || !n) return;
|
|
912
1047
|
let r = (e, t) => () => {
|
|
913
|
-
if (
|
|
914
|
-
|
|
1048
|
+
if (U && U !== e) return;
|
|
1049
|
+
U = e;
|
|
915
1050
|
let n = e.scrollHeight - e.clientHeight, r = n > 0 ? e.scrollTop / n : 0, i = t.scrollHeight - t.clientHeight;
|
|
916
|
-
t.scrollTop = r * (i > 0 ? i : 0),
|
|
917
|
-
|
|
1051
|
+
t.scrollTop = r * (i > 0 ? i : 0), W && clearTimeout(W), W = setTimeout(() => {
|
|
1052
|
+
U = null;
|
|
918
1053
|
}, 120);
|
|
919
1054
|
}, i = r(t, n), a = r(n, t);
|
|
920
|
-
t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }),
|
|
1055
|
+
t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), H = () => {
|
|
921
1056
|
t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
|
|
922
1057
|
};
|
|
923
1058
|
};
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}), f(
|
|
927
|
-
let
|
|
1059
|
+
w([L, B], ([e, t]) => {
|
|
1060
|
+
G(), e === "split" && t && u(ae);
|
|
1061
|
+
}), f(G);
|
|
1062
|
+
let oe = t(() => O.readonly || L.value === "split"), K = (e) => k("update:modelValue", e), q = _(null), se = _(null);
|
|
928
1063
|
return l({
|
|
929
|
-
insertQuote: (e) =>
|
|
930
|
-
insertMention: (e) =>
|
|
931
|
-
insertImage: (e) =>
|
|
932
|
-
uploadImage: (e) =>
|
|
933
|
-
focus: () =>
|
|
1064
|
+
insertQuote: (e) => q.value?.insertQuote(e),
|
|
1065
|
+
insertMention: (e) => q.value?.insertMention(e),
|
|
1066
|
+
insertImage: (e) => q.value?.insertImage(e),
|
|
1067
|
+
uploadImage: (e) => q.value?.uploadImage(e),
|
|
1068
|
+
focus: () => q.value?.focus(),
|
|
934
1069
|
scrollToHeading: (e) => {
|
|
935
|
-
L.value === "source" || L.value === "split" ?
|
|
1070
|
+
L.value === "source" || L.value === "split" ? se.value?.scrollToHeading(e) : q.value?.scrollToHeading(e);
|
|
936
1071
|
}
|
|
937
1072
|
}), (t, l) => (m(), i("div", {
|
|
938
1073
|
ref_key: "rootEl",
|
|
939
|
-
ref:
|
|
1074
|
+
ref: ie,
|
|
940
1075
|
class: "kun-editor",
|
|
941
1076
|
"data-kun-editor": "",
|
|
942
1077
|
"data-mode": L.value
|
|
943
|
-
}, [
|
|
1078
|
+
}, [j.value ? (m(), i(e, { key: 0 }, [y(t.$slots, "view-switch", {
|
|
944
1079
|
mode: L.value,
|
|
945
|
-
setMode:
|
|
946
|
-
labels:
|
|
1080
|
+
setMode: te,
|
|
1081
|
+
labels: V.value,
|
|
947
1082
|
views: s.views,
|
|
948
|
-
swapped:
|
|
949
|
-
swap:
|
|
950
|
-
scrollSync:
|
|
951
|
-
toggleScrollSync:
|
|
952
|
-
}, () => [s.views.length > 1 ? (m(), i("div",
|
|
1083
|
+
swapped: R.value,
|
|
1084
|
+
swap: z,
|
|
1085
|
+
scrollSync: B.value,
|
|
1086
|
+
toggleScrollSync: ne
|
|
1087
|
+
}, () => [s.views.length > 1 ? (m(), i("div", Ht, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
|
|
953
1088
|
key: e,
|
|
954
1089
|
type: "button",
|
|
955
1090
|
class: "kun-editor__tab",
|
|
956
1091
|
"aria-selected": L.value === e,
|
|
957
1092
|
"data-active": L.value === e,
|
|
958
|
-
onClick: (t) =>
|
|
959
|
-
}, b(
|
|
1093
|
+
onClick: (t) => te(e)
|
|
1094
|
+
}, b(V.value[e]), 9, Ut))), 128)), L.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
|
|
960
1095
|
type: "button",
|
|
961
1096
|
class: "kun-editor__tab kun-editor__swap",
|
|
962
|
-
title:
|
|
963
|
-
"aria-label":
|
|
964
|
-
onClick: l[0] ||= (e) =>
|
|
965
|
-
}, " ⇄ ", 8,
|
|
1097
|
+
title: V.value.swap,
|
|
1098
|
+
"aria-label": V.value.swap,
|
|
1099
|
+
onClick: l[0] ||= (e) => z()
|
|
1100
|
+
}, " ⇄ ", 8, Wt), a("button", {
|
|
966
1101
|
type: "button",
|
|
967
1102
|
class: "kun-editor__tab",
|
|
968
|
-
"data-active":
|
|
969
|
-
title:
|
|
970
|
-
"aria-pressed":
|
|
971
|
-
onClick: l[1] ||= (e) =>
|
|
972
|
-
}, b(
|
|
973
|
-
default:
|
|
974
|
-
default:
|
|
975
|
-
default:
|
|
1103
|
+
"data-active": B.value,
|
|
1104
|
+
title: V.value.scrollSync,
|
|
1105
|
+
"aria-pressed": B.value,
|
|
1106
|
+
onClick: l[1] ||= (e) => ne()
|
|
1107
|
+
}, b(V.value.scrollSync), 9, Gt)], 64)) : r("", !0)])) : r("", !0)]), o(x(A), null, {
|
|
1108
|
+
default: T(() => [o(x(N), null, {
|
|
1109
|
+
default: T(() => [E(a("div", null, [o(zt, null, {
|
|
1110
|
+
default: T((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(Rt)])]),
|
|
976
1111
|
_: 3
|
|
977
|
-
})], 512), [[
|
|
1112
|
+
})], 512), [[C, L.value === "wysiwyg" && !s.readonly]]), a("div", {
|
|
978
1113
|
class: "kun-editor__panes",
|
|
979
|
-
"data-swap":
|
|
980
|
-
}, [L.value === "source" || L.value === "split" ? (m(), n(
|
|
1114
|
+
"data-swap": R.value
|
|
1115
|
+
}, [L.value === "source" || L.value === "split" ? (m(), n(Bt, {
|
|
981
1116
|
key: 0,
|
|
982
1117
|
ref_key: "source",
|
|
983
|
-
ref:
|
|
1118
|
+
ref: se,
|
|
984
1119
|
class: "kun-editor__pane",
|
|
985
1120
|
"model-value": s.modelValue,
|
|
986
1121
|
readonly: s.readonly,
|
|
987
|
-
"onUpdate:modelValue":
|
|
988
|
-
}, null, 8, ["model-value", "readonly"])) : r("", !0),
|
|
1122
|
+
"onUpdate:modelValue": K
|
|
1123
|
+
}, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", qt, [o(ot, {
|
|
989
1124
|
ref_key: "inner",
|
|
990
|
-
ref:
|
|
1125
|
+
ref: q,
|
|
991
1126
|
"model-value": s.modelValue,
|
|
992
1127
|
adapters: s.adapters,
|
|
993
1128
|
features: s.features,
|
|
994
1129
|
locale: s.locale,
|
|
995
|
-
readonly:
|
|
1130
|
+
readonly: oe.value,
|
|
996
1131
|
placeholder: s.placeholder,
|
|
997
1132
|
"placeholder-mode": s.placeholderMode,
|
|
998
1133
|
active: L.value === "wysiwyg" && !s.readonly,
|
|
999
|
-
"selection-toolbar":
|
|
1000
|
-
"onUpdate:modelValue":
|
|
1001
|
-
"onUpdate:loading":
|
|
1134
|
+
"selection-toolbar": F.value,
|
|
1135
|
+
"onUpdate:modelValue": K,
|
|
1136
|
+
"onUpdate:loading": ee
|
|
1002
1137
|
}, null, 8, [
|
|
1003
1138
|
"model-value",
|
|
1004
1139
|
"adapters",
|
|
@@ -1009,18 +1144,18 @@ var Ae = [
|
|
|
1009
1144
|
"placeholder-mode",
|
|
1010
1145
|
"active",
|
|
1011
1146
|
"selection-toolbar"
|
|
1012
|
-
])], 512), [[
|
|
1147
|
+
])], 512), [[C, L.value === "wysiwyg" || L.value === "split"]])], 8, Kt)]),
|
|
1013
1148
|
_: 3
|
|
1014
1149
|
})]),
|
|
1015
1150
|
_: 3
|
|
1016
|
-
})], 64)) : r("", !0), !
|
|
1151
|
+
})], 64)) : r("", !0), !j.value || M.value ? (m(), i("div", Jt, [y(t.$slots, "loading", {}, () => [
|
|
1017
1152
|
l[2] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
|
|
1018
1153
|
l[3] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
|
|
1019
1154
|
l[4] ||= a("div", { class: "kun-editor__skeleton" }, null, -1)
|
|
1020
|
-
])])) : r("", !0)], 8,
|
|
1155
|
+
])])) : r("", !0)], 8, Vt));
|
|
1021
1156
|
}
|
|
1022
|
-
}),
|
|
1023
|
-
e.component("KunEditor",
|
|
1157
|
+
}), Xt = { install(e) {
|
|
1158
|
+
e.component("KunEditor", Yt);
|
|
1024
1159
|
} };
|
|
1025
1160
|
//#endregion
|
|
1026
|
-
export {
|
|
1161
|
+
export { mt as EMOJI, Yt as KunEditor, Xt as KunEditorPlugin, F as parseHeadings };
|