@kungal/editor-vue 0.14.0 → 0.16.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 +28 -0
- package/dist/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/index.js +118 -114
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @kungal/editor-vue
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @kungal/editor-core@0.16.0
|
|
8
|
+
|
|
9
|
+
## 0.15.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- a7273bb: Toolbar: headings become one "text size" dropdown; remove the formula button.
|
|
14
|
+
|
|
15
|
+
- **Headings → a single "text size" control** (Paragraph / H1–H6) instead of
|
|
16
|
+
three H1/H2/H3 buttons — the modern standard, and it can set Paragraph (reset),
|
|
17
|
+
which the old toggle buttons couldn't. The headless `EditorToolbar` uses a
|
|
18
|
+
native `<select>` (new `.kun-editor__heading-select` class hook); the KunUI
|
|
19
|
+
`<KunEditorToolbar>` uses a `<KunPopover>` with each level shown at its own size
|
|
20
|
+
(like the forum). Both drive `setHeadingCommand`.
|
|
21
|
+
- **Remove the math/formula button.** With no selection it inserted an empty
|
|
22
|
+
inline-math node (a broken formula box). Math is entered via the existing
|
|
23
|
+
`$…$` / `$$` input rules instead — the ecosystem norm (prosemirror-math). The
|
|
24
|
+
spoiler button stays.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [a7273bb]
|
|
29
|
+
- @kungal/editor-core@0.15.0
|
|
30
|
+
|
|
3
31
|
## 0.14.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAmcA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/index.js
CHANGED
|
@@ -5,32 +5,32 @@ import { Editor as M, defaultValueCtx as N, editorViewCtx as P, editorViewOption
|
|
|
5
5
|
import { listenerCtx as L } from "@milkdown/kit/plugin/listener";
|
|
6
6
|
import { SlashProvider as ee, slashFactory as te } from "@milkdown/kit/plugin/slash";
|
|
7
7
|
import { callCommand as R, replaceAll as z } from "@milkdown/kit/utils";
|
|
8
|
-
import { createKunEditorPlugins as ne, insertKunSpoilerCommand as re, insertMentionCommand as B, insertQuoteCommand as V, kunCM as ie, mentionId as ae,
|
|
8
|
+
import { createKunEditorPlugins as ne, insertKunSpoilerCommand as re, insertMentionCommand as B, insertQuoteCommand as V, kunCM as ie, mentionId as ae, setHeadingCommand as oe } from "@kungal/editor-core/preset";
|
|
9
9
|
import { TextSelection as se } from "@milkdown/kit/prose/state";
|
|
10
|
-
import { createCodeBlockCommand as ce, insertHrCommand as
|
|
11
|
-
import { toggleStrikethroughCommand as
|
|
12
|
-
import { EditorState as
|
|
10
|
+
import { createCodeBlockCommand as ce, insertHrCommand as H, insertImageCommand as U, toggleEmphasisCommand as W, toggleInlineCodeCommand as G, toggleStrongCommand as le, wrapInBlockquoteCommand as ue, wrapInBulletListCommand as de, wrapInOrderedListCommand as fe } from "@milkdown/kit/preset/commonmark";
|
|
11
|
+
import { toggleStrikethroughCommand as pe } from "@milkdown/kit/preset/gfm";
|
|
12
|
+
import { EditorState as me } from "@codemirror/state";
|
|
13
13
|
import { EditorView as K } from "@codemirror/view";
|
|
14
|
-
import { markdown as
|
|
15
|
-
import { basicSetup as
|
|
14
|
+
import { markdown as he } from "@codemirror/lang-markdown";
|
|
15
|
+
import { basicSetup as ge } from "codemirror";
|
|
16
16
|
//#region src/context.ts
|
|
17
|
-
var q = Symbol("kun-editor-context"),
|
|
17
|
+
var q = Symbol("kun-editor-context"), _e = [
|
|
18
18
|
"data-active",
|
|
19
19
|
"onMousedown",
|
|
20
20
|
"onMouseenter"
|
|
21
|
-
],
|
|
21
|
+
], ve = ["src", "alt"], ye = {
|
|
22
22
|
key: 1,
|
|
23
23
|
class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
|
|
24
|
-
},
|
|
24
|
+
}, be = { class: "kun-mention-dropdown__name" }, xe = {
|
|
25
25
|
key: 1,
|
|
26
26
|
class: "kun-mention-dropdown__hint"
|
|
27
|
-
},
|
|
27
|
+
}, Se = {
|
|
28
28
|
key: 2,
|
|
29
29
|
class: "kun-mention-dropdown__hint"
|
|
30
|
-
},
|
|
30
|
+
}, Ce = {
|
|
31
31
|
key: 3,
|
|
32
32
|
class: "kun-mention-dropdown__hint"
|
|
33
|
-
},
|
|
33
|
+
}, we = /* @__PURE__ */ s({
|
|
34
34
|
__name: "MentionDropdown",
|
|
35
35
|
setup(n) {
|
|
36
36
|
let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(q), s = o?.adapters.searchMentionUsers, c = t(() => (o?.locale ?? "zh-cn").toLowerCase().startsWith("en")), u = t(() => c.value ? {
|
|
@@ -136,9 +136,9 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
136
136
|
src: e.avatar,
|
|
137
137
|
alt: e.name,
|
|
138
138
|
class: "kun-mention-dropdown__avatar"
|
|
139
|
-
}, null, 8,
|
|
139
|
+
}, null, 8, ve)) : (p(), i("span", ye, v(e.name.charAt(0)), 1)), a("span", be, v(e.name), 1)], 40, _e))), 128)) : D.value ? (p(), i("div", xe, v(u.value.searching), 1)) : C.value ? (p(), i("div", Se, v(u.value.empty), 1)) : (p(), i("div", Ce, v(u.value.prompt), 1))], 512));
|
|
140
140
|
}
|
|
141
|
-
}),
|
|
141
|
+
}), Te = /* @__PURE__ */ s({
|
|
142
142
|
__name: "MilkdownEditor",
|
|
143
143
|
props: {
|
|
144
144
|
modelValue: {},
|
|
@@ -156,7 +156,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
156
156
|
}), t.update(F, (e) => ({
|
|
157
157
|
...e,
|
|
158
158
|
editable: () => !i.readonly
|
|
159
|
-
})), l && t.set(c.key, { view: s({ component:
|
|
159
|
+
})), l && t.set(c.key, { view: s({ component: we }) });
|
|
160
160
|
}).use(ne(i.adapters, i.features, { locale: i.locale }));
|
|
161
161
|
return l && t.use(c), t;
|
|
162
162
|
});
|
|
@@ -193,21 +193,21 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
193
193
|
spoiler: J("<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\"/>"),
|
|
194
194
|
latex: Y("Σ", 15),
|
|
195
195
|
smile: J("<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\"/>")
|
|
196
|
-
}, Z = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."),
|
|
196
|
+
}, Z = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ee = [
|
|
197
197
|
"title",
|
|
198
198
|
"aria-label",
|
|
199
199
|
"aria-expanded"
|
|
200
|
-
],
|
|
200
|
+
], De = ["innerHTML"], Oe = { class: "kun-editor__picker-panel" }, ke = {
|
|
201
201
|
key: 0,
|
|
202
202
|
class: "kun-editor__picker-tabs",
|
|
203
203
|
role: "tablist"
|
|
204
|
-
},
|
|
204
|
+
}, Ae = ["data-active"], je = ["data-active"], Me = { class: "kun-editor__emoji-grid" }, Ne = ["onClick"], Pe = {
|
|
205
205
|
key: 1,
|
|
206
206
|
class: "kun-editor__sticker-body"
|
|
207
|
-
},
|
|
207
|
+
}, Fe = { class: "kun-editor__pack-name" }, Ie = { class: "kun-editor__sticker-grid" }, Le = ["title", "onClick"], Re = ["src", "alt"], ze = {
|
|
208
208
|
key: 1,
|
|
209
209
|
class: "kun-editor__picker-hint"
|
|
210
|
-
},
|
|
210
|
+
}, Be = /* @__PURE__ */ s({
|
|
211
211
|
__name: "StickerPicker",
|
|
212
212
|
setup(n) {
|
|
213
213
|
let [, o] = O(), s = l(q), c = s?.adapters.stickerSource, u = !!c, m = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), _ = t(() => m.value ? {
|
|
@@ -243,7 +243,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
243
243
|
n.dispatch(r.tr.insertText(e, r.selection.from));
|
|
244
244
|
});
|
|
245
245
|
}, N = (e, t) => {
|
|
246
|
-
o()?.action(R(
|
|
246
|
+
o()?.action(R(U.key, {
|
|
247
247
|
src: e,
|
|
248
248
|
title: t,
|
|
249
249
|
alt: t
|
|
@@ -263,28 +263,28 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
263
263
|
}, [a("span", {
|
|
264
264
|
class: "kun-editor__icon",
|
|
265
265
|
innerHTML: y(X).smile
|
|
266
|
-
}, null, 8,
|
|
267
|
-
u ? (p(), i("div",
|
|
266
|
+
}, null, 8, De)], 8, Ee), C(a("div", Oe, [
|
|
267
|
+
u ? (p(), i("div", ke, [a("button", {
|
|
268
268
|
type: "button",
|
|
269
269
|
class: "kun-editor__picker-tab",
|
|
270
270
|
"data-active": w.value === "emoji",
|
|
271
271
|
onClick: n[0] ||= (e) => w.value = "emoji"
|
|
272
|
-
}, v(_.value.emoji), 9,
|
|
272
|
+
}, v(_.value.emoji), 9, Ae), a("button", {
|
|
273
273
|
type: "button",
|
|
274
274
|
class: "kun-editor__picker-tab",
|
|
275
275
|
"data-active": w.value === "sticker",
|
|
276
276
|
onClick: n[1] ||= (e) => w.value = "sticker"
|
|
277
|
-
}, v(_.value.sticker), 9,
|
|
278
|
-
C(a("div",
|
|
277
|
+
}, v(_.value.sticker), 9, je)])) : r("", !0),
|
|
278
|
+
C(a("div", Me, [(p(!0), i(e, null, g(y(Z), (e, t) => (p(), i("button", {
|
|
279
279
|
key: t,
|
|
280
280
|
type: "button",
|
|
281
281
|
class: "kun-editor__emoji",
|
|
282
282
|
onClick: (t) => M(e)
|
|
283
|
-
}, v(e), 9,
|
|
284
|
-
u ? C((p(), i("div",
|
|
283
|
+
}, v(e), 9, Ne))), 128))], 512), [[b, !u || w.value === "emoji"]]),
|
|
284
|
+
u ? C((p(), i("div", Pe, [T.value.length ? (p(!0), i(e, { key: 0 }, g(T.value, (t) => (p(), i("div", {
|
|
285
285
|
key: t.name,
|
|
286
286
|
class: "kun-editor__pack"
|
|
287
|
-
}, [a("div",
|
|
287
|
+
}, [a("div", Fe, v(t.name), 1), a("div", Ie, [(p(!0), i(e, null, g(t.stickers, (e, t) => (p(), i("button", {
|
|
288
288
|
key: t,
|
|
289
289
|
type: "button",
|
|
290
290
|
class: "kun-editor__sticker",
|
|
@@ -294,127 +294,120 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
294
294
|
src: e.src,
|
|
295
295
|
alt: e.name,
|
|
296
296
|
loading: "lazy"
|
|
297
|
-
}, null, 8,
|
|
297
|
+
}, null, 8, Re)], 8, Le))), 128))])]))), 128)) : (p(), i("div", ze, v(D.value ? _.value.failed : _.value.empty), 1))], 512)), [[b, w.value === "sticker"]]) : r("", !0)
|
|
298
298
|
], 512), [[b, x.value]])], 512));
|
|
299
299
|
}
|
|
300
|
-
}),
|
|
300
|
+
}), Ve = {
|
|
301
301
|
class: "kun-editor__format-toolbar",
|
|
302
302
|
role: "toolbar"
|
|
303
|
-
}, Q = {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}, Ue = [
|
|
303
|
+
}, He = ["aria-label"], Q = {
|
|
304
|
+
value: "",
|
|
305
|
+
disabled: "",
|
|
306
|
+
selected: ""
|
|
307
|
+
}, Ue = ["value"], We = [
|
|
308
308
|
"title",
|
|
309
309
|
"aria-label",
|
|
310
310
|
"onClick"
|
|
311
|
-
],
|
|
311
|
+
], Ge = ["innerHTML"], Ke = ["title", "aria-label"], qe = ["innerHTML"], Je = /* @__PURE__ */ s({
|
|
312
312
|
__name: "EditorToolbar",
|
|
313
313
|
setup(n) {
|
|
314
314
|
let [, s] = O(), c = l(q), u = t(() => c?.adapters.uploadImage), d = () => c?.adapters.notify, f = t(() => c?.features.sticker !== !1), m = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), _ = (e, t) => {
|
|
315
315
|
s()?.action(R(e, t));
|
|
316
|
-
},
|
|
316
|
+
}, b = t(() => {
|
|
317
317
|
let e = m.value;
|
|
318
318
|
return {
|
|
319
|
+
textSize: e ? "Text size" : "文本大小",
|
|
319
320
|
bold: e ? "Bold" : "加粗",
|
|
320
321
|
italic: e ? "Italic" : "斜体",
|
|
321
322
|
strike: e ? "Strikethrough" : "删除线",
|
|
322
323
|
code: e ? "Inline code" : "行内代码",
|
|
323
|
-
h1: e ? "Heading 1" : "一级标题",
|
|
324
|
-
h2: e ? "Heading 2" : "二级标题",
|
|
325
|
-
h3: e ? "Heading 3" : "三级标题",
|
|
326
324
|
bulletList: e ? "Bullet list" : "无序列表",
|
|
327
325
|
orderedList: e ? "Ordered list" : "有序列表",
|
|
328
326
|
quote: e ? "Blockquote" : "引用块",
|
|
329
327
|
codeBlock: e ? "Code block" : "代码块",
|
|
330
328
|
hr: e ? "Divider" : "分隔线",
|
|
331
329
|
spoiler: e ? "Spoiler" : "隐藏文本",
|
|
332
|
-
latex: e ? "Math (LaTeX)" : "公式",
|
|
333
330
|
image: e ? "Upload image" : "上传图片"
|
|
334
331
|
};
|
|
335
|
-
}),
|
|
332
|
+
}), x = t(() => {
|
|
333
|
+
let e = m.value;
|
|
334
|
+
return [
|
|
335
|
+
"正文",
|
|
336
|
+
"一级标题",
|
|
337
|
+
"二级标题",
|
|
338
|
+
"三级标题",
|
|
339
|
+
"四级标题",
|
|
340
|
+
"五级标题",
|
|
341
|
+
"六级标题"
|
|
342
|
+
].map((t, n) => ({
|
|
343
|
+
level: n,
|
|
344
|
+
label: e ? n === 0 ? "Paragraph" : `Heading ${n}` : t
|
|
345
|
+
}));
|
|
346
|
+
}), S = (e) => {
|
|
347
|
+
let t = e.target;
|
|
348
|
+
_(oe.key, Number(t.value)), t.selectedIndex = 0;
|
|
349
|
+
}, C = t(() => [
|
|
336
350
|
[
|
|
337
351
|
{
|
|
338
352
|
svg: X.bold,
|
|
339
|
-
title:
|
|
340
|
-
run: () => _(
|
|
353
|
+
title: b.value.bold,
|
|
354
|
+
run: () => _(le.key)
|
|
341
355
|
},
|
|
342
356
|
{
|
|
343
357
|
svg: X.italic,
|
|
344
|
-
title:
|
|
345
|
-
run: () => _(
|
|
358
|
+
title: b.value.italic,
|
|
359
|
+
run: () => _(W.key)
|
|
346
360
|
},
|
|
347
361
|
{
|
|
348
362
|
svg: X.strike,
|
|
349
|
-
title:
|
|
350
|
-
run: () => _(
|
|
363
|
+
title: b.value.strike,
|
|
364
|
+
run: () => _(pe.key)
|
|
351
365
|
},
|
|
352
366
|
{
|
|
353
367
|
svg: X.code,
|
|
354
|
-
title:
|
|
355
|
-
run: () => _(
|
|
356
|
-
}
|
|
357
|
-
],
|
|
358
|
-
[
|
|
359
|
-
{
|
|
360
|
-
svg: X.h1,
|
|
361
|
-
title: v.value.h1,
|
|
362
|
-
run: () => _(G.key, 1)
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
svg: X.h2,
|
|
366
|
-
title: v.value.h2,
|
|
367
|
-
run: () => _(G.key, 2)
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
svg: X.h3,
|
|
371
|
-
title: v.value.h3,
|
|
372
|
-
run: () => _(G.key, 3)
|
|
368
|
+
title: b.value.code,
|
|
369
|
+
run: () => _(G.key)
|
|
373
370
|
}
|
|
374
371
|
],
|
|
375
372
|
[
|
|
376
373
|
{
|
|
377
374
|
svg: X.bulletList,
|
|
378
|
-
title:
|
|
379
|
-
run: () => _(
|
|
375
|
+
title: b.value.bulletList,
|
|
376
|
+
run: () => _(de.key)
|
|
380
377
|
},
|
|
381
378
|
{
|
|
382
379
|
svg: X.orderedList,
|
|
383
|
-
title:
|
|
384
|
-
run: () => _(
|
|
380
|
+
title: b.value.orderedList,
|
|
381
|
+
run: () => _(fe.key)
|
|
385
382
|
},
|
|
386
383
|
{
|
|
387
384
|
svg: X.quote,
|
|
388
|
-
title:
|
|
389
|
-
run: () => _(
|
|
385
|
+
title: b.value.quote,
|
|
386
|
+
run: () => _(ue.key)
|
|
390
387
|
},
|
|
391
388
|
{
|
|
392
389
|
svg: X.codeBlock,
|
|
393
|
-
title:
|
|
390
|
+
title: b.value.codeBlock,
|
|
394
391
|
run: () => _(ce.key, "")
|
|
395
392
|
},
|
|
396
393
|
{
|
|
397
394
|
svg: X.hr,
|
|
398
|
-
title:
|
|
399
|
-
run: () => _(
|
|
395
|
+
title: b.value.hr,
|
|
396
|
+
run: () => _(H.key)
|
|
400
397
|
}
|
|
401
398
|
],
|
|
402
399
|
[{
|
|
403
400
|
svg: X.spoiler,
|
|
404
|
-
title:
|
|
401
|
+
title: b.value.spoiler,
|
|
405
402
|
run: () => _(re.key)
|
|
406
|
-
}, {
|
|
407
|
-
svg: X.latex,
|
|
408
|
-
title: v.value.latex,
|
|
409
|
-
run: () => _(oe.key)
|
|
410
403
|
}]
|
|
411
|
-
]),
|
|
404
|
+
]), w = h(null), T = () => w.value?.click(), E = async (e) => {
|
|
412
405
|
let t = e.target, n = t.files?.[0];
|
|
413
406
|
t.value = "";
|
|
414
407
|
let r = u.value;
|
|
415
408
|
if (!(!n || !r)) try {
|
|
416
409
|
let e = await r(n);
|
|
417
|
-
_(
|
|
410
|
+
_(U.key, {
|
|
418
411
|
src: e,
|
|
419
412
|
title: n.name,
|
|
420
413
|
alt: n.name
|
|
@@ -423,8 +416,19 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
423
416
|
d()?.(m.value ? "Image upload failed" : "图片上传失败", "error");
|
|
424
417
|
}
|
|
425
418
|
};
|
|
426
|
-
return (t, n) => (p(), i("div",
|
|
427
|
-
(
|
|
419
|
+
return (t, n) => (p(), i("div", Ve, [
|
|
420
|
+
a("select", {
|
|
421
|
+
class: "kun-editor__heading-select",
|
|
422
|
+
"aria-label": b.value.textSize,
|
|
423
|
+
onChange: S
|
|
424
|
+
}, [a("option", Q, v(b.value.textSize), 1), (p(!0), i(e, null, g(x.value, (e) => (p(), i("option", {
|
|
425
|
+
key: e.level,
|
|
426
|
+
value: e.level
|
|
427
|
+
}, v(e.label), 9, Ue))), 128))], 40, He),
|
|
428
|
+
(p(!0), i(e, null, g(C.value, (t, r) => (p(), i(e, { key: r }, [n[0] ||= a("span", {
|
|
429
|
+
class: "kun-editor__toolbar-divider",
|
|
430
|
+
"aria-hidden": "true"
|
|
431
|
+
}, null, -1), (p(!0), i(e, null, g(t, (e, t) => (p(), i("button", {
|
|
428
432
|
key: t,
|
|
429
433
|
type: "button",
|
|
430
434
|
class: "kun-editor__tool",
|
|
@@ -434,38 +438,38 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
434
438
|
}, [a("span", {
|
|
435
439
|
class: "kun-editor__icon",
|
|
436
440
|
innerHTML: e.svg
|
|
437
|
-
}, null, 8,
|
|
441
|
+
}, null, 8, Ge)], 8, We))), 128))], 64))), 128)),
|
|
438
442
|
u.value ? (p(), i(e, { key: 0 }, [
|
|
439
|
-
n[
|
|
443
|
+
n[1] ||= a("span", {
|
|
440
444
|
class: "kun-editor__toolbar-divider",
|
|
441
445
|
"aria-hidden": "true"
|
|
442
446
|
}, null, -1),
|
|
443
447
|
a("button", {
|
|
444
448
|
type: "button",
|
|
445
449
|
class: "kun-editor__tool",
|
|
446
|
-
title:
|
|
447
|
-
"aria-label":
|
|
448
|
-
onClick:
|
|
450
|
+
title: b.value.image,
|
|
451
|
+
"aria-label": b.value.image,
|
|
452
|
+
onClick: T
|
|
449
453
|
}, [a("span", {
|
|
450
454
|
class: "kun-editor__icon",
|
|
451
455
|
innerHTML: y(X).image
|
|
452
|
-
}, null, 8,
|
|
456
|
+
}, null, 8, qe)], 8, Ke),
|
|
453
457
|
a("input", {
|
|
454
458
|
ref_key: "fileInput",
|
|
455
|
-
ref:
|
|
459
|
+
ref: w,
|
|
456
460
|
type: "file",
|
|
457
461
|
accept: ".jpg,.jpeg,.png,.webp,.gif",
|
|
458
462
|
hidden: "",
|
|
459
|
-
onChange:
|
|
463
|
+
onChange: E
|
|
460
464
|
}, null, 544)
|
|
461
465
|
], 64)) : r("", !0),
|
|
462
|
-
f.value ? (p(), i(e, { key: 1 }, [n[
|
|
466
|
+
f.value ? (p(), i(e, { key: 1 }, [n[2] ||= a("span", {
|
|
463
467
|
class: "kun-editor__toolbar-divider",
|
|
464
468
|
"aria-hidden": "true"
|
|
465
|
-
}, null, -1), o(
|
|
469
|
+
}, null, -1), o(Be)], 64)) : r("", !0)
|
|
466
470
|
]));
|
|
467
471
|
}
|
|
468
|
-
}),
|
|
472
|
+
}), Ye = /* @__PURE__ */ s({
|
|
469
473
|
__name: "ToolbarHost",
|
|
470
474
|
setup(e) {
|
|
471
475
|
let [, t] = O(), n = l(q, void 0), r = (e, n) => {
|
|
@@ -499,7 +503,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
499
503
|
};
|
|
500
504
|
return (e, t) => _(e.$slots, "default", u(c(a)));
|
|
501
505
|
}
|
|
502
|
-
}),
|
|
506
|
+
}), Xe = /* @__PURE__ */ s({
|
|
503
507
|
__name: "MarkdownSource",
|
|
504
508
|
props: {
|
|
505
509
|
modelValue: {},
|
|
@@ -507,13 +511,13 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
507
511
|
},
|
|
508
512
|
emits: ["update:modelValue"],
|
|
509
513
|
setup(e, { emit: t }) {
|
|
510
|
-
let n = e, r = t, a = h(null), o = null, s = (e) =>
|
|
514
|
+
let n = e, r = t, a = h(null), o = null, s = (e) => me.create({
|
|
511
515
|
doc: e,
|
|
512
516
|
extensions: [
|
|
513
517
|
ie(),
|
|
514
518
|
K.lineWrapping,
|
|
515
|
-
|
|
516
|
-
|
|
519
|
+
ge,
|
|
520
|
+
he(),
|
|
517
521
|
K.editable.of(!n.readonly),
|
|
518
522
|
K.updateListener.of((e) => {
|
|
519
523
|
e.docChanged && r("update:modelValue", e.state.doc.toString());
|
|
@@ -535,13 +539,13 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
535
539
|
class: "kun-editor__source"
|
|
536
540
|
}, null, 512));
|
|
537
541
|
}
|
|
538
|
-
}),
|
|
542
|
+
}), Ze = {
|
|
539
543
|
class: "kun-editor",
|
|
540
544
|
"data-kun-editor": ""
|
|
541
|
-
},
|
|
545
|
+
}, Qe = {
|
|
542
546
|
class: "kun-editor__toolbar",
|
|
543
547
|
role: "tablist"
|
|
544
|
-
},
|
|
548
|
+
}, $e = ["aria-selected", "data-active"], et = ["aria-selected", "data-active"], tt = { class: "kun-editor__wysiwyg" }, $ = /* @__PURE__ */ s({
|
|
545
549
|
__name: "KunEditor",
|
|
546
550
|
props: {
|
|
547
551
|
modelValue: {},
|
|
@@ -580,30 +584,30 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
580
584
|
insertQuote: (e) => O.value?.insertQuote(e),
|
|
581
585
|
insertMention: (e) => O.value?.insertMention(e),
|
|
582
586
|
focus: () => O.value?.focus()
|
|
583
|
-
}), (t, s) => (p(), i("div",
|
|
587
|
+
}), (t, s) => (p(), i("div", Ze, [
|
|
584
588
|
_(t.$slots, "view-switch", {
|
|
585
589
|
mode: g.value,
|
|
586
590
|
setMode: x,
|
|
587
591
|
labels: T.value
|
|
588
|
-
}, () => [a("div",
|
|
592
|
+
}, () => [a("div", Qe, [a("button", {
|
|
589
593
|
type: "button",
|
|
590
594
|
class: "kun-editor__tab",
|
|
591
595
|
"aria-selected": g.value === "wysiwyg",
|
|
592
596
|
"data-active": g.value === "wysiwyg",
|
|
593
597
|
onClick: s[0] ||= (e) => x("wysiwyg")
|
|
594
|
-
}, v(T.value.wysiwyg), 9,
|
|
598
|
+
}, v(T.value.wysiwyg), 9, $e), a("button", {
|
|
595
599
|
type: "button",
|
|
596
600
|
class: "kun-editor__tab",
|
|
597
601
|
"aria-selected": g.value === "source",
|
|
598
602
|
"data-active": g.value === "source",
|
|
599
603
|
onClick: s[1] ||= (e) => x("source")
|
|
600
|
-
}, v(T.value.source), 9,
|
|
604
|
+
}, v(T.value.source), 9, et)])]),
|
|
601
605
|
o(y(E), null, {
|
|
602
606
|
default: S(() => [o(y(k), null, {
|
|
603
|
-
default: S(() => [C(a("div", null, [o(
|
|
604
|
-
default: S((e) => [_(t.$slots, "toolbar", u(c(e)), () => [o(
|
|
607
|
+
default: S(() => [C(a("div", null, [o(Ye, null, {
|
|
608
|
+
default: S((e) => [_(t.$slots, "toolbar", u(c(e)), () => [o(Je)])]),
|
|
605
609
|
_: 3
|
|
606
|
-
})], 512), [[b, g.value === "wysiwyg" && !e.readonly]]), C(a("div",
|
|
610
|
+
})], 512), [[b, g.value === "wysiwyg" && !e.readonly]]), C(a("div", tt, [o(Te, {
|
|
607
611
|
ref_key: "inner",
|
|
608
612
|
ref: O,
|
|
609
613
|
"model-value": e.modelValue,
|
|
@@ -623,7 +627,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
623
627
|
})]),
|
|
624
628
|
_: 3
|
|
625
629
|
}),
|
|
626
|
-
g.value === "source" ? (p(), n(
|
|
630
|
+
g.value === "source" ? (p(), n(Xe, {
|
|
627
631
|
key: 0,
|
|
628
632
|
"model-value": e.modelValue,
|
|
629
633
|
readonly: e.readonly,
|
|
@@ -631,8 +635,8 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
631
635
|
}, null, 8, ["model-value", "readonly"])) : r("", !0)
|
|
632
636
|
]));
|
|
633
637
|
}
|
|
634
|
-
}),
|
|
638
|
+
}), nt = { install(e) {
|
|
635
639
|
e.component("KunEditor", $);
|
|
636
640
|
} };
|
|
637
641
|
//#endregion
|
|
638
|
-
export { Z as EMOJI, $ as KunEditor,
|
|
642
|
+
export { Z as EMOJI, $ as KunEditor, nt as KunEditorPlugin };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungal/editor-vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "KunEditor Vue 3 layer — the <KunEditor> component (dual WYSIWYG / markdown-source), toolbar and plugin views.
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "KunEditor Vue 3 layer — the headless <KunEditor> component (dual WYSIWYG / markdown-source), toolbar and plugin views. Ships zero CSS and no UI-kit dependency; consumes @kungal/editor-core, and pairs with @kungal/editor-nuxt for optional KunUI chrome.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"kungal",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@prosemirror-adapter/vue": "^0.4.6",
|
|
43
|
-
"@kungal/editor-core": "0.
|
|
43
|
+
"@kungal/editor-core": "0.16.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@codemirror/lang-markdown": "^6.0.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"vite": "^8.0.16",
|
|
81
81
|
"vue": "^3.5.35",
|
|
82
82
|
"vue-tsc": "^3.3.3",
|
|
83
|
-
"@kungal/editor-core": "0.
|
|
83
|
+
"@kungal/editor-core": "0.16.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "vite build && vue-tsc -p tsconfig.build.json",
|