@kungal/editor-vue 0.31.1 → 0.32.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 +21 -0
- package/dist/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/KunEditor.vue.d.ts +1 -0
- package/dist/components/KunEditor.vue.d.ts.map +1 -1
- package/dist/components/ToolbarHost.vue.d.ts +1 -0
- package/dist/components/ToolbarHost.vue.d.ts.map +1 -1
- package/dist/composables/useActiveMarks.d.ts +10 -0
- package/dist/composables/useActiveMarks.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +296 -258
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @kungal/editor-vue
|
|
2
2
|
|
|
3
|
+
## 0.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7dd7f71: Show an active state on the toolbar's toggle marks (bold / italic /
|
|
8
|
+
strikethrough / inline code).
|
|
9
|
+
|
|
10
|
+
The toolbar buttons ran the toggle commands but never reflected whether the
|
|
11
|
+
mark was on, so a user could not tell if bold (etc.) was engaged. The
|
|
12
|
+
`#toolbar` slot API now exposes a reactive `activeMarks` map (bold / italic /
|
|
13
|
+
strike / code), recomputed from the ProseMirror selection on selection and doc
|
|
14
|
+
changes and immediately after each command. `<KunEditorToolbar>` renders the
|
|
15
|
+
pressed buttons with the primary "active" look (same as hover) and sets
|
|
16
|
+
`aria-pressed`; the headless `EditorToolbar` sets `data-active` for the
|
|
17
|
+
`.kun-editor__tool[data-active='true']` style.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [35bc140]
|
|
22
|
+
- @kungal/editor-core@0.32.0
|
|
23
|
+
|
|
3
24
|
## 0.31.1
|
|
4
25
|
|
|
5
26
|
### Patch 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":"AA4gBA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -54,6 +54,7 @@ declare var __VLS_1: {
|
|
|
54
54
|
toggleScrollSync: () => void;
|
|
55
55
|
}, __VLS_22: {
|
|
56
56
|
run: <T>(key: import("@milkdown/kit/core").CmdKey<T>, payload?: T) => void;
|
|
57
|
+
activeMarks: Readonly<Record<import("../types").KunToggleMark, boolean>>;
|
|
57
58
|
insertText: (text: string) => void;
|
|
58
59
|
uploadImage: (file: File) => void;
|
|
59
60
|
insertImage: (payload: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AAsbA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,UAAU,EACX,MAAM,qBAAqB,CAAA;AAO5B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAUjE,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE9C,KAAK,WAAW,GAAG;IACf,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,qDAAqD;IACrD,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,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|
4
5
|
insertText: (text: string) => void;
|
|
5
6
|
uploadImage: (file: File) => void;
|
|
6
7
|
insertImage: (payload: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarHost.vue.d.ts","sourceRoot":"","sources":["../../src/components/ToolbarHost.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToolbarHost.vue.d.ts","sourceRoot":"","sources":["../../src/components/ToolbarHost.vue"],"names":[],"mappings":"AAgHA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AA8GhD,QAAA,IAAI,OAAO;oCA/GX,CAzEkC;;;;;;WAyElC,CAjCgC;aAiChC,CA/BM;;;;YA+BN,CAjBI;;;;;;;;;;;;;;CAgIkB,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActiveMarks.d.ts","sourceRoot":"","sources":["../../src/composables/useActiveMarks.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,cAAc;;;;;;;mBAUL,IAAI;CA8BzB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { KunEditorExpose } from './types';
|
|
|
5
5
|
export type { KunEditorToolbarApi } from './types';
|
|
6
6
|
export type { KunToolbarItem } from './types';
|
|
7
7
|
export type { KunSelectionItem } from './types';
|
|
8
|
+
export type { KunToggleMark } from './types';
|
|
8
9
|
export type { KunEditorViewSwitchApi } from './types';
|
|
9
10
|
export { EMOJI } from './emoji';
|
|
10
11
|
export type { KunHeading } from '@kungal/editor-core';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,CAAA;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAA;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,MAI7B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,CAAA;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAA;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,MAI7B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
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,
|
|
2
|
-
import { Milkdown as
|
|
3
|
-
import { ProsemirrorAdapterProvider as
|
|
4
|
-
import { parseHeadings as
|
|
5
|
-
import { Editor 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, vShow as S, watch as C, withCtx as w, withDirectives as T, withModifiers as E } from "vue";
|
|
2
|
+
import { Milkdown as D, MilkdownProvider as O, useEditor as k, useInstance as A } from "@milkdown/vue";
|
|
3
|
+
import { ProsemirrorAdapterProvider as j, usePluginViewContext as M, usePluginViewFactory as N } from "@prosemirror-adapter/vue";
|
|
4
|
+
import { parseHeadings as ee, parseHeadings as te } from "@kungal/editor-core";
|
|
5
|
+
import { Editor as P, defaultValueCtx as F, editorViewCtx as I, editorViewOptionsCtx as ne, rootCtx as L } from "@milkdown/kit/core";
|
|
6
6
|
import { listenerCtx as R } from "@milkdown/kit/plugin/listener";
|
|
7
|
-
import { SlashProvider as
|
|
8
|
-
import { TooltipProvider as B, tooltipFactory as
|
|
9
|
-
import { callCommand as
|
|
10
|
-
import { TextSelection as
|
|
11
|
-
import { createCodeBlockCommand as
|
|
12
|
-
import { createKunEditorPlugins as
|
|
13
|
-
import { toggleStrikethroughCommand as
|
|
14
|
-
import { Annotation as
|
|
7
|
+
import { SlashProvider as re, slashFactory as z } from "@milkdown/kit/plugin/slash";
|
|
8
|
+
import { TooltipProvider as B, tooltipFactory as V } from "@milkdown/kit/plugin/tooltip";
|
|
9
|
+
import { callCommand as H, replaceAll as U } from "@milkdown/kit/utils";
|
|
10
|
+
import { TextSelection as W } from "@milkdown/kit/prose/state";
|
|
11
|
+
import { createCodeBlockCommand as ie, emphasisSchema as ae, inlineCodeSchema as G, insertHrCommand as K, insertImageCommand as q, strongSchema as oe, toggleEmphasisCommand as se, toggleInlineCodeCommand as ce, toggleStrongCommand as le, wrapInBlockquoteCommand as ue, wrapInBulletListCommand as de, wrapInOrderedListCommand as fe } from "@milkdown/kit/preset/commonmark";
|
|
12
|
+
import { createKunEditorPlugins as pe, insertKunSpoilerCommand as me, insertLinkCommand as J, insertMentionCommand as he, insertQuoteCommand as ge, kunCM as _e, mentionId as ve, setHeadingCommand as ye, startImageUpload as be } from "@kungal/editor-core/preset";
|
|
13
|
+
import { strikethroughSchema as xe, toggleStrikethroughCommand as Se } from "@milkdown/kit/preset/gfm";
|
|
14
|
+
import { Annotation as Ce, EditorState as we } from "@codemirror/state";
|
|
15
15
|
import { EditorView as Y } from "@codemirror/view";
|
|
16
|
-
import { markdown as
|
|
17
|
-
import { basicSetup as
|
|
16
|
+
import { markdown as Te } from "@codemirror/lang-markdown";
|
|
17
|
+
import { basicSetup as Ee } from "codemirror";
|
|
18
18
|
//#region src/context.ts
|
|
19
|
-
var X = Symbol("kun-editor-context"),
|
|
19
|
+
var X = Symbol("kun-editor-context"), De = [
|
|
20
20
|
"data-active",
|
|
21
21
|
"onMousedown",
|
|
22
22
|
"onMouseenter"
|
|
23
|
-
],
|
|
23
|
+
], Oe = ["src", "alt"], ke = {
|
|
24
24
|
key: 1,
|
|
25
25
|
class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
|
|
26
|
-
},
|
|
26
|
+
}, Ae = { class: "kun-mention-dropdown__name" }, je = {
|
|
27
27
|
key: 1,
|
|
28
28
|
class: "kun-mention-dropdown__hint"
|
|
29
|
-
},
|
|
29
|
+
}, Me = {
|
|
30
30
|
key: 2,
|
|
31
31
|
class: "kun-mention-dropdown__hint"
|
|
32
|
-
},
|
|
32
|
+
}, Ne = {
|
|
33
33
|
key: 3,
|
|
34
34
|
class: "kun-mention-dropdown__hint"
|
|
35
|
-
},
|
|
35
|
+
}, Pe = /* @__PURE__ */ s({
|
|
36
36
|
__name: "MentionDropdown",
|
|
37
37
|
setup(n) {
|
|
38
38
|
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 ? {
|
|
@@ -43,8 +43,8 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
43
43
|
searching: "搜索中…",
|
|
44
44
|
empty: "无匹配用户",
|
|
45
45
|
prompt: "输入用户名以搜索"
|
|
46
|
-
}), { view: d, prevState: h } =
|
|
47
|
-
A &&= (clearTimeout(A), null),
|
|
46
|
+
}), { view: d, prevState: h } = M(), g = _(null), y, x = _(!1), S = _(""), w = _([]), T = _(0), D = _(!1), O = null, k = 0, A = null, j = () => {
|
|
47
|
+
A &&= (clearTimeout(A), null), S.value = "", w.value = [], T.value = 0, D.value = !1, O = null;
|
|
48
48
|
}, N = (e) => {
|
|
49
49
|
if (A &&= (clearTimeout(A), null), !e || !s) {
|
|
50
50
|
w.value = [], D.value = !1;
|
|
@@ -57,7 +57,7 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
57
57
|
} catch {
|
|
58
58
|
n = [];
|
|
59
59
|
}
|
|
60
|
-
t === k && (w.value = n ?? [],
|
|
60
|
+
t === k && (w.value = n ?? [], T.value = 0, D.value = !1);
|
|
61
61
|
}, 180);
|
|
62
62
|
}, ee = (e) => {
|
|
63
63
|
let { selection: t } = e.state;
|
|
@@ -71,74 +71,74 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
71
71
|
return O = {
|
|
72
72
|
from: n - (t.length + 1),
|
|
73
73
|
to: n
|
|
74
|
-
}, t !==
|
|
74
|
+
}, t !== S.value && (S.value = t, N(t)), !0;
|
|
75
75
|
}, P = (e) => {
|
|
76
76
|
let t = d.value;
|
|
77
77
|
if (!t || !O) return;
|
|
78
|
-
let n = t.state.schema.nodes[
|
|
78
|
+
let n = t.state.schema.nodes[ve];
|
|
79
79
|
if (!n) return;
|
|
80
80
|
let r = n.create({
|
|
81
81
|
userId: e.id,
|
|
82
82
|
name: e.name
|
|
83
83
|
}), { from: i, to: a } = O, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
|
|
84
|
-
o.insertText(" ", s), o.setSelection(
|
|
84
|
+
o.insertText(" ", s), o.setSelection(W.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), y.hide();
|
|
85
85
|
}, F = (e) => {
|
|
86
86
|
if (!x.value || !w.value.length) {
|
|
87
|
-
x.value && e.key === "Escape" && (e.preventDefault(),
|
|
87
|
+
x.value && e.key === "Escape" && (e.preventDefault(), y.hide());
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
let t = w.value.length - 1;
|
|
91
91
|
switch (e.key) {
|
|
92
92
|
case "ArrowDown":
|
|
93
|
-
e.preventDefault(), e.stopPropagation(),
|
|
93
|
+
e.preventDefault(), e.stopPropagation(), T.value = T.value >= t ? 0 : T.value + 1;
|
|
94
94
|
break;
|
|
95
95
|
case "ArrowUp":
|
|
96
|
-
e.preventDefault(), e.stopPropagation(),
|
|
96
|
+
e.preventDefault(), e.stopPropagation(), T.value = T.value <= 0 ? t : T.value - 1;
|
|
97
97
|
break;
|
|
98
98
|
case "Enter":
|
|
99
99
|
case "Tab": {
|
|
100
|
-
let t = w.value[
|
|
100
|
+
let t = w.value[T.value];
|
|
101
101
|
t && (e.preventDefault(), e.stopPropagation(), P(t));
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
104
|
case "Escape":
|
|
105
|
-
e.preventDefault(), e.stopPropagation(),
|
|
105
|
+
e.preventDefault(), e.stopPropagation(), y.hide();
|
|
106
106
|
break;
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
return p(() => {
|
|
110
|
-
|
|
111
|
-
content:
|
|
110
|
+
y = new re({
|
|
111
|
+
content: g.value,
|
|
112
112
|
trigger: "@",
|
|
113
113
|
shouldShow: te,
|
|
114
114
|
debounce: 0
|
|
115
|
-
}),
|
|
115
|
+
}), y.onShow = () => {
|
|
116
116
|
x.value = !0;
|
|
117
|
-
},
|
|
118
|
-
x.value = !1,
|
|
119
|
-
},
|
|
120
|
-
}),
|
|
121
|
-
|
|
117
|
+
}, y.onHide = () => {
|
|
118
|
+
x.value = !1, j();
|
|
119
|
+
}, y.update(d.value, h.value), window.addEventListener("keydown", F, !0);
|
|
120
|
+
}), C([d, h], () => {
|
|
121
|
+
y?.update(d.value, h.value);
|
|
122
122
|
}), f(() => {
|
|
123
|
-
A && clearTimeout(A), window.removeEventListener("keydown", F, !0),
|
|
123
|
+
A && clearTimeout(A), window.removeEventListener("keydown", F, !0), y?.destroy();
|
|
124
124
|
}), (t, n) => (m(), i("div", {
|
|
125
125
|
ref_key: "divRef",
|
|
126
|
-
ref:
|
|
126
|
+
ref: g,
|
|
127
127
|
class: "kun-mention-dropdown",
|
|
128
128
|
"data-show": "false"
|
|
129
|
-
}, [w.value.length ? (m(!0), i(e, { key: 0 },
|
|
129
|
+
}, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (e, t) => (m(), i("button", {
|
|
130
130
|
key: e.id,
|
|
131
131
|
type: "button",
|
|
132
132
|
class: "kun-mention-dropdown__item",
|
|
133
|
-
"data-active": t ===
|
|
134
|
-
onMousedown:
|
|
135
|
-
onMouseenter: (e) =>
|
|
133
|
+
"data-active": t === T.value,
|
|
134
|
+
onMousedown: E((t) => P(e), ["prevent"]),
|
|
135
|
+
onMouseenter: (e) => T.value = t
|
|
136
136
|
}, [e.avatar ? (m(), i("img", {
|
|
137
137
|
key: 0,
|
|
138
138
|
src: e.avatar,
|
|
139
139
|
alt: e.name,
|
|
140
140
|
class: "kun-mention-dropdown__avatar"
|
|
141
|
-
}, null, 8,
|
|
141
|
+
}, null, 8, Oe)) : (m(), i("span", ke, b(e.name.charAt(0)), 1)), a("span", Ae, b(e.name), 1)], 40, De))), 128)) : D.value ? (m(), i("div", je, b(u.value.searching), 1)) : S.value ? (m(), i("div", Me, b(u.value.empty), 1)) : (m(), i("div", Ne, b(u.value.prompt), 1))], 512));
|
|
142
142
|
}
|
|
143
143
|
}), 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>`, $ = {
|
|
144
144
|
bold: Z("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
|
|
@@ -158,47 +158,47 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
158
158
|
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\"/>"),
|
|
159
159
|
latex: Q("Σ", 15),
|
|
160
160
|
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\"/>")
|
|
161
|
-
},
|
|
161
|
+
}, Fe = {
|
|
162
162
|
key: 0,
|
|
163
163
|
class: "kun-editor__toolbar-divider",
|
|
164
164
|
"aria-hidden": "true"
|
|
165
|
-
},
|
|
165
|
+
}, Ie = [
|
|
166
166
|
"title",
|
|
167
167
|
"aria-label",
|
|
168
168
|
"onMousedown"
|
|
169
|
-
],
|
|
169
|
+
], Le = ["innerHTML"], Re = /* @__PURE__ */ s({
|
|
170
170
|
__name: "SelectionTooltip",
|
|
171
171
|
setup(n) {
|
|
172
|
-
let { view: r, prevState: o } =
|
|
173
|
-
s()?.action(
|
|
172
|
+
let { view: r, prevState: o } = M(), [, s] = A(), c = l(X), u = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), d = _(null), h, g = (e, t) => {
|
|
173
|
+
s()?.action(H(e, t));
|
|
174
174
|
}, y = async () => {
|
|
175
175
|
let e = r.value, { from: t, to: n } = e?.state.selection ?? {
|
|
176
176
|
from: 0,
|
|
177
177
|
to: 0
|
|
178
178
|
}, i = e ? e.state.doc.textBetween(t, n, " ") : "", a = c?.adapters.linkPrompt, o = (a ? await a({ text: i }) : window.prompt(u.value ? "Link URL" : "链接 URL"))?.trim();
|
|
179
|
-
o &&
|
|
179
|
+
o && g(J.key, { href: o });
|
|
180
180
|
}, b = t(() => {
|
|
181
181
|
let e = u.value;
|
|
182
182
|
return {
|
|
183
183
|
bold: {
|
|
184
184
|
svg: $.bold,
|
|
185
185
|
title: e ? "Bold" : "加粗",
|
|
186
|
-
run: () =>
|
|
186
|
+
run: () => g(le.key)
|
|
187
187
|
},
|
|
188
188
|
italic: {
|
|
189
189
|
svg: $.italic,
|
|
190
190
|
title: e ? "Italic" : "斜体",
|
|
191
|
-
run: () =>
|
|
191
|
+
run: () => g(se.key)
|
|
192
192
|
},
|
|
193
193
|
strike: {
|
|
194
194
|
svg: $.strike,
|
|
195
195
|
title: e ? "Strikethrough" : "删除线",
|
|
196
|
-
run: () =>
|
|
196
|
+
run: () => g(Se.key)
|
|
197
197
|
},
|
|
198
198
|
code: {
|
|
199
199
|
svg: $.code,
|
|
200
200
|
title: e ? "Inline code" : "行内代码",
|
|
201
|
-
run: () =>
|
|
201
|
+
run: () => g(ce.key)
|
|
202
202
|
},
|
|
203
203
|
link: {
|
|
204
204
|
svg: $.link,
|
|
@@ -226,7 +226,7 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
226
226
|
content: d.value,
|
|
227
227
|
offset: 8
|
|
228
228
|
}), h.update(r.value, o.value);
|
|
229
|
-
}),
|
|
229
|
+
}), C([r, o], () => {
|
|
230
230
|
h?.update(r.value, o.value);
|
|
231
231
|
}), f(() => {
|
|
232
232
|
h?.destroy();
|
|
@@ -235,19 +235,19 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
235
235
|
ref: d,
|
|
236
236
|
class: "kun-editor__bubble",
|
|
237
237
|
"data-show": "false"
|
|
238
|
-
}, [(m(!0), i(e, null,
|
|
238
|
+
}, [(m(!0), i(e, null, v(x.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", Fe)) : (m(), i("button", {
|
|
239
239
|
key: 1,
|
|
240
240
|
type: "button",
|
|
241
241
|
class: "kun-editor__bubble-btn",
|
|
242
242
|
title: t.title,
|
|
243
243
|
"aria-label": t.title,
|
|
244
|
-
onMousedown:
|
|
244
|
+
onMousedown: E((e) => t.run(), ["prevent"])
|
|
245
245
|
}, [a("span", {
|
|
246
246
|
class: "kun-editor__icon",
|
|
247
247
|
innerHTML: t.svg
|
|
248
|
-
}, null, 8,
|
|
248
|
+
}, null, 8, Le)], 40, Ie))], 64))), 128))], 512));
|
|
249
249
|
}
|
|
250
|
-
}),
|
|
250
|
+
}), ze = /* @__PURE__ */ s({
|
|
251
251
|
__name: "MilkdownEditor",
|
|
252
252
|
props: {
|
|
253
253
|
modelValue: {},
|
|
@@ -262,44 +262,44 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
262
262
|
},
|
|
263
263
|
emits: ["update:modelValue", "update:loading"],
|
|
264
264
|
setup(e, { expose: t, emit: r }) {
|
|
265
|
-
let i = e, a = r, o = i.modelValue, s = !1, c =
|
|
266
|
-
let t =
|
|
267
|
-
t.set(L, e), t.set(
|
|
265
|
+
let i = e, a = r, o = i.modelValue, s = !1, c = N(), l = z("kunMention"), u = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!c, d = V("kunSelectionTooltip"), f = i.selectionToolbar && !!c, p = k((e) => {
|
|
266
|
+
let t = P.make().config((t) => {
|
|
267
|
+
t.set(L, e), t.set(F, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
|
|
268
268
|
!i.active || s || t === n || (o = t, a("update:modelValue", t));
|
|
269
|
-
}), t.update(
|
|
269
|
+
}), t.update(ne, (e) => ({
|
|
270
270
|
...e,
|
|
271
271
|
editable: () => !i.readonly
|
|
272
|
-
})), u && t.set(l.key, { view: c({ component:
|
|
273
|
-
}).use(
|
|
272
|
+
})), u && t.set(l.key, { view: c({ component: Pe }) }), f && t.set(d.key, { view: c({ component: Re }) });
|
|
273
|
+
}).use(pe(i.adapters, i.features, {
|
|
274
274
|
locale: i.locale,
|
|
275
275
|
placeholder: i.placeholder,
|
|
276
276
|
placeholderMode: i.placeholderMode
|
|
277
277
|
}));
|
|
278
278
|
return u && t.use(l), f && t.use(d), t;
|
|
279
279
|
});
|
|
280
|
-
|
|
280
|
+
C(p.loading, (e) => a("update:loading", e), { immediate: !0 }), C(() => i.modelValue, (e) => {
|
|
281
281
|
if (e === o) return;
|
|
282
282
|
o = e;
|
|
283
283
|
let t = p.get();
|
|
284
|
-
t && (s = !0, t.action(
|
|
285
|
-
}),
|
|
284
|
+
t && (s = !0, t.action(U(e)), s = !1);
|
|
285
|
+
}), C(() => i.readonly, () => {
|
|
286
286
|
p.get()?.action((e) => {
|
|
287
|
-
let t = e.get(
|
|
287
|
+
let t = e.get(I);
|
|
288
288
|
t.dispatch(t.state.tr);
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
let h = () => {
|
|
292
|
-
p.get()?.action((e) => e.get(
|
|
292
|
+
p.get()?.action((e) => e.get(I).focus());
|
|
293
293
|
};
|
|
294
294
|
return t({
|
|
295
295
|
insertQuote: (e) => {
|
|
296
|
-
p.get()?.action(
|
|
296
|
+
p.get()?.action(H(ge.key, e)), h();
|
|
297
297
|
},
|
|
298
298
|
insertMention: (e) => {
|
|
299
|
-
p.get()?.action(
|
|
299
|
+
p.get()?.action(H(he.key, e)), h();
|
|
300
300
|
},
|
|
301
301
|
insertImage: (e) => {
|
|
302
|
-
p.get()?.action(
|
|
302
|
+
p.get()?.action(H(q.key, {
|
|
303
303
|
src: e.src,
|
|
304
304
|
alt: e.alt ?? "",
|
|
305
305
|
title: e.title ?? ""
|
|
@@ -308,7 +308,7 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
308
308
|
uploadImage: (e) => {
|
|
309
309
|
let t = i.adapters.uploadImage, n = p.get();
|
|
310
310
|
!t || !n || n.action((n) => {
|
|
311
|
-
|
|
311
|
+
be(n.get(I), e, {
|
|
312
312
|
uploadImage: t,
|
|
313
313
|
notify: i.adapters.notify,
|
|
314
314
|
locale: i.locale
|
|
@@ -318,38 +318,67 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
318
318
|
focus: h,
|
|
319
319
|
scrollToHeading: (e) => {
|
|
320
320
|
p.get()?.action((t) => {
|
|
321
|
-
let n = t.get(
|
|
321
|
+
let n = t.get(I), r = 0, i = -1;
|
|
322
322
|
if (n.state.doc.forEach((t, n) => {
|
|
323
323
|
t.type.name === "heading" && (r === e && (i = n), r += 1);
|
|
324
324
|
}), !(i < 0) && (n.nodeDOM(i)?.scrollIntoView({
|
|
325
325
|
behavior: "smooth",
|
|
326
326
|
block: "start"
|
|
327
327
|
}), n.editable)) {
|
|
328
|
-
let e =
|
|
328
|
+
let e = W.near(n.state.doc.resolve(i + 1));
|
|
329
329
|
n.dispatch(n.state.tr.setSelection(e)), n.focus();
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
|
-
}), (e, t) => (m(), n(
|
|
333
|
+
}), (e, t) => (m(), n(x(D)));
|
|
334
334
|
}
|
|
335
|
-
}),
|
|
335
|
+
}), Be = {
|
|
336
|
+
bold: oe,
|
|
337
|
+
italic: ae,
|
|
338
|
+
strike: xe,
|
|
339
|
+
code: G
|
|
340
|
+
}, Ve = () => {
|
|
341
|
+
let [e, t] = A(), n = g({
|
|
342
|
+
bold: !1,
|
|
343
|
+
italic: !1,
|
|
344
|
+
strike: !1,
|
|
345
|
+
code: !1
|
|
346
|
+
}), r = () => {
|
|
347
|
+
t()?.action((e) => {
|
|
348
|
+
let t = e.get(I).state, { from: r, $from: i, to: a, empty: o } = t.selection;
|
|
349
|
+
Object.keys(Be).forEach((s) => {
|
|
350
|
+
let c = Be[s].type(e);
|
|
351
|
+
n[s] = o ? !!c.isInSet(t.storedMarks ?? i.marks()) : t.doc.rangeHasMark(r, a, c);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
return C(e, (e) => {
|
|
356
|
+
e || (t()?.action((e) => {
|
|
357
|
+
let t = e.get(R);
|
|
358
|
+
t.selectionUpdated(r), t.updated(r);
|
|
359
|
+
}), r());
|
|
360
|
+
}, { immediate: !0 }), {
|
|
361
|
+
activeMarks: n,
|
|
362
|
+
refresh: r
|
|
363
|
+
};
|
|
364
|
+
}, He = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ue = [
|
|
336
365
|
"title",
|
|
337
366
|
"aria-label",
|
|
338
367
|
"aria-expanded"
|
|
339
|
-
],
|
|
368
|
+
], We = ["innerHTML"], Ge = { class: "kun-editor__picker-panel" }, Ke = {
|
|
340
369
|
key: 0,
|
|
341
370
|
class: "kun-editor__picker-tabs",
|
|
342
371
|
role: "tablist"
|
|
343
|
-
},
|
|
372
|
+
}, qe = ["data-active"], Je = ["data-active"], Ye = { class: "kun-editor__emoji-grid" }, Xe = ["onClick"], Ze = {
|
|
344
373
|
key: 1,
|
|
345
374
|
class: "kun-editor__sticker-body"
|
|
346
|
-
},
|
|
375
|
+
}, Qe = { class: "kun-editor__pack-name" }, $e = { class: "kun-editor__sticker-grid" }, et = ["title", "onClick"], tt = ["src", "alt"], nt = {
|
|
347
376
|
key: 1,
|
|
348
377
|
class: "kun-editor__picker-hint"
|
|
349
|
-
},
|
|
378
|
+
}, rt = /* @__PURE__ */ s({
|
|
350
379
|
__name: "StickerPicker",
|
|
351
380
|
setup(n) {
|
|
352
|
-
let [, o] =
|
|
381
|
+
let [, o] = A(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
|
|
353
382
|
trigger: "Emoji & stickers",
|
|
354
383
|
emoji: "Emoji",
|
|
355
384
|
sticker: "Stickers",
|
|
@@ -361,28 +390,28 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
361
390
|
sticker: "贴纸",
|
|
362
391
|
empty: "暂无贴纸",
|
|
363
392
|
failed: "贴纸加载失败"
|
|
364
|
-
}),
|
|
393
|
+
}), g = _(!1), y = _(null), C = _("emoji"), w = _([]), E = _(!1), D = _(!1), O = async () => {
|
|
365
394
|
if (!(E.value || !c)) {
|
|
366
395
|
E.value = !0;
|
|
367
396
|
try {
|
|
368
|
-
|
|
397
|
+
w.value = await c();
|
|
369
398
|
} catch {
|
|
370
399
|
D.value = !0;
|
|
371
400
|
}
|
|
372
401
|
}
|
|
373
|
-
},
|
|
374
|
-
|
|
402
|
+
}, k = () => {
|
|
403
|
+
g.value = !g.value, g.value && u && O();
|
|
375
404
|
}, j = (e) => {
|
|
376
|
-
|
|
405
|
+
g.value && y.value && !y.value.contains(e.target) && (g.value = !1);
|
|
377
406
|
};
|
|
378
407
|
p(() => document.addEventListener("click", j)), f(() => document.removeEventListener("click", j));
|
|
379
408
|
let M = (e) => {
|
|
380
409
|
o()?.action((t) => {
|
|
381
|
-
let n = t.get(
|
|
410
|
+
let n = t.get(I), { state: r } = n;
|
|
382
411
|
n.dispatch(r.tr.insertText(e, r.selection.from));
|
|
383
412
|
});
|
|
384
413
|
}, N = (e, t) => {
|
|
385
|
-
o()?.action(
|
|
414
|
+
o()?.action(H(q.key, {
|
|
386
415
|
src: e,
|
|
387
416
|
title: t,
|
|
388
417
|
alt: t
|
|
@@ -390,40 +419,40 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
390
419
|
};
|
|
391
420
|
return (t, n) => (m(), i("div", {
|
|
392
421
|
ref_key: "rootRef",
|
|
393
|
-
ref:
|
|
422
|
+
ref: y,
|
|
394
423
|
class: "kun-editor__picker"
|
|
395
424
|
}, [a("button", {
|
|
396
425
|
type: "button",
|
|
397
426
|
class: "kun-editor__tool",
|
|
398
427
|
title: h.value.trigger,
|
|
399
428
|
"aria-label": h.value.trigger,
|
|
400
|
-
"aria-expanded":
|
|
401
|
-
onClick:
|
|
429
|
+
"aria-expanded": g.value,
|
|
430
|
+
onClick: k
|
|
402
431
|
}, [a("span", {
|
|
403
432
|
class: "kun-editor__icon",
|
|
404
|
-
innerHTML:
|
|
405
|
-
}, null, 8,
|
|
406
|
-
u ? (m(), i("div",
|
|
433
|
+
innerHTML: x($).smile
|
|
434
|
+
}, null, 8, We)], 8, Ue), T(a("div", Ge, [
|
|
435
|
+
u ? (m(), i("div", Ke, [a("button", {
|
|
407
436
|
type: "button",
|
|
408
437
|
class: "kun-editor__picker-tab",
|
|
409
438
|
"data-active": C.value === "emoji",
|
|
410
439
|
onClick: n[0] ||= (e) => C.value = "emoji"
|
|
411
|
-
},
|
|
440
|
+
}, b(h.value.emoji), 9, qe), a("button", {
|
|
412
441
|
type: "button",
|
|
413
442
|
class: "kun-editor__picker-tab",
|
|
414
443
|
"data-active": C.value === "sticker",
|
|
415
444
|
onClick: n[1] ||= (e) => C.value = "sticker"
|
|
416
|
-
},
|
|
417
|
-
|
|
445
|
+
}, b(h.value.sticker), 9, Je)])) : r("", !0),
|
|
446
|
+
T(a("div", Ye, [(m(!0), i(e, null, v(x(He), (e, t) => (m(), i("button", {
|
|
418
447
|
key: t,
|
|
419
448
|
type: "button",
|
|
420
449
|
class: "kun-editor__emoji",
|
|
421
450
|
onClick: (t) => M(e)
|
|
422
|
-
},
|
|
423
|
-
u ?
|
|
451
|
+
}, b(e), 9, Xe))), 128))], 512), [[S, !u || C.value === "emoji"]]),
|
|
452
|
+
u ? T((m(), i("div", Ze, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
|
|
424
453
|
key: t.name,
|
|
425
454
|
class: "kun-editor__pack"
|
|
426
|
-
}, [a("div",
|
|
455
|
+
}, [a("div", Qe, b(t.name), 1), a("div", $e, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
|
|
427
456
|
key: t,
|
|
428
457
|
type: "button",
|
|
429
458
|
class: "kun-editor__sticker",
|
|
@@ -433,35 +462,37 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
433
462
|
src: e.src,
|
|
434
463
|
alt: e.name,
|
|
435
464
|
loading: "lazy"
|
|
436
|
-
}, null, 8,
|
|
437
|
-
], 512), [[
|
|
465
|
+
}, null, 8, tt)], 8, et))), 128))])]))), 128)) : (m(), i("div", nt, b(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[S, C.value === "sticker"]]) : r("", !0)
|
|
466
|
+
], 512), [[S, g.value]])], 512));
|
|
438
467
|
}
|
|
439
|
-
}),
|
|
468
|
+
}), it = {
|
|
440
469
|
class: "kun-editor__format-toolbar",
|
|
441
470
|
role: "toolbar"
|
|
442
|
-
},
|
|
471
|
+
}, at = ["aria-label"], ot = {
|
|
443
472
|
value: "",
|
|
444
473
|
disabled: "",
|
|
445
474
|
selected: ""
|
|
446
|
-
},
|
|
475
|
+
}, st = ["value"], ct = [
|
|
447
476
|
"title",
|
|
448
477
|
"aria-label",
|
|
478
|
+
"aria-pressed",
|
|
479
|
+
"data-active",
|
|
449
480
|
"onClick"
|
|
450
|
-
],
|
|
481
|
+
], lt = ["innerHTML"], ut = ["title", "aria-label"], dt = ["innerHTML"], ft = /* @__PURE__ */ s({
|
|
451
482
|
__name: "EditorToolbar",
|
|
452
483
|
setup(n) {
|
|
453
|
-
let [, s] =
|
|
454
|
-
s()?.action(
|
|
455
|
-
},
|
|
484
|
+
let [, s] = A(), c = l(X), { activeMarks: u, refresh: d } = Ve(), f = t(() => c?.adapters.uploadImage), p = t(() => c?.features.sticker !== !1), h = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = (e, t) => {
|
|
485
|
+
s()?.action(H(e, t)), d();
|
|
486
|
+
}, y = async () => {
|
|
456
487
|
let e = "";
|
|
457
488
|
s()?.action((t) => {
|
|
458
|
-
let n = t.get(
|
|
489
|
+
let n = t.get(I), { from: r, to: i } = n.state.selection;
|
|
459
490
|
e = n.state.doc.textBetween(r, i, " ");
|
|
460
491
|
});
|
|
461
|
-
let t = c?.adapters.linkPrompt, n = (t ? await t({ text: e }) : window.prompt(
|
|
462
|
-
n &&
|
|
463
|
-
},
|
|
464
|
-
let e =
|
|
492
|
+
let t = c?.adapters.linkPrompt, n = (t ? await t({ text: e }) : window.prompt(h.value ? "Link URL" : "链接 URL"))?.trim();
|
|
493
|
+
n && g(J.key, { href: n });
|
|
494
|
+
}, S = t(() => {
|
|
495
|
+
let e = h.value;
|
|
465
496
|
return {
|
|
466
497
|
textSize: e ? "Text size" : "文本大小",
|
|
467
498
|
bold: e ? "Bold" : "加粗",
|
|
@@ -477,8 +508,8 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
477
508
|
spoiler: e ? "Spoiler" : "隐藏文本",
|
|
478
509
|
image: e ? "Upload image" : "上传图片"
|
|
479
510
|
};
|
|
480
|
-
}),
|
|
481
|
-
let e =
|
|
511
|
+
}), C = t(() => {
|
|
512
|
+
let e = h.value;
|
|
482
513
|
return [
|
|
483
514
|
"正文",
|
|
484
515
|
"一级标题",
|
|
@@ -491,105 +522,111 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
491
522
|
level: n,
|
|
492
523
|
label: e ? n === 0 ? "Paragraph" : `Heading ${n}` : t
|
|
493
524
|
}));
|
|
494
|
-
}),
|
|
525
|
+
}), w = (e) => {
|
|
495
526
|
let t = e.target;
|
|
496
|
-
|
|
497
|
-
},
|
|
527
|
+
g(ye.key, Number(t.value)), t.selectedIndex = 0;
|
|
528
|
+
}, T = t(() => [
|
|
498
529
|
[
|
|
499
530
|
{
|
|
500
531
|
svg: $.bold,
|
|
501
|
-
title:
|
|
502
|
-
run: () =>
|
|
532
|
+
title: S.value.bold,
|
|
533
|
+
run: () => g(le.key),
|
|
534
|
+
mark: "bold"
|
|
503
535
|
},
|
|
504
536
|
{
|
|
505
537
|
svg: $.italic,
|
|
506
|
-
title:
|
|
507
|
-
run: () =>
|
|
538
|
+
title: S.value.italic,
|
|
539
|
+
run: () => g(se.key),
|
|
540
|
+
mark: "italic"
|
|
508
541
|
},
|
|
509
542
|
{
|
|
510
543
|
svg: $.strike,
|
|
511
|
-
title:
|
|
512
|
-
run: () =>
|
|
544
|
+
title: S.value.strike,
|
|
545
|
+
run: () => g(Se.key),
|
|
546
|
+
mark: "strike"
|
|
513
547
|
},
|
|
514
548
|
{
|
|
515
549
|
svg: $.code,
|
|
516
|
-
title:
|
|
517
|
-
run: () =>
|
|
550
|
+
title: S.value.code,
|
|
551
|
+
run: () => g(ce.key),
|
|
552
|
+
mark: "code"
|
|
518
553
|
},
|
|
519
554
|
{
|
|
520
555
|
svg: $.link,
|
|
521
|
-
title:
|
|
522
|
-
run:
|
|
556
|
+
title: S.value.link,
|
|
557
|
+
run: y
|
|
523
558
|
}
|
|
524
559
|
],
|
|
525
560
|
[
|
|
526
561
|
{
|
|
527
562
|
svg: $.bulletList,
|
|
528
|
-
title:
|
|
529
|
-
run: () =>
|
|
563
|
+
title: S.value.bulletList,
|
|
564
|
+
run: () => g(de.key)
|
|
530
565
|
},
|
|
531
566
|
{
|
|
532
567
|
svg: $.orderedList,
|
|
533
|
-
title:
|
|
534
|
-
run: () =>
|
|
568
|
+
title: S.value.orderedList,
|
|
569
|
+
run: () => g(fe.key)
|
|
535
570
|
},
|
|
536
571
|
{
|
|
537
572
|
svg: $.quote,
|
|
538
|
-
title:
|
|
539
|
-
run: () =>
|
|
573
|
+
title: S.value.quote,
|
|
574
|
+
run: () => g(ue.key)
|
|
540
575
|
},
|
|
541
576
|
{
|
|
542
577
|
svg: $.codeBlock,
|
|
543
|
-
title:
|
|
544
|
-
run: () =>
|
|
578
|
+
title: S.value.codeBlock,
|
|
579
|
+
run: () => g(ie.key, "")
|
|
545
580
|
},
|
|
546
581
|
{
|
|
547
582
|
svg: $.hr,
|
|
548
|
-
title:
|
|
549
|
-
run: () =>
|
|
583
|
+
title: S.value.hr,
|
|
584
|
+
run: () => g(K.key)
|
|
550
585
|
}
|
|
551
586
|
],
|
|
552
587
|
[{
|
|
553
588
|
svg: $.spoiler,
|
|
554
|
-
title:
|
|
555
|
-
run: () =>
|
|
589
|
+
title: S.value.spoiler,
|
|
590
|
+
run: () => g(me.key)
|
|
556
591
|
}]
|
|
557
|
-
]),
|
|
592
|
+
]), E = _(null), D = () => E.value?.click(), O = (e) => {
|
|
558
593
|
let t = e.target, n = t.files?.[0];
|
|
559
594
|
t.value = "";
|
|
560
|
-
let r =
|
|
595
|
+
let r = f.value;
|
|
561
596
|
!n || !r || s()?.action((e) => {
|
|
562
|
-
|
|
597
|
+
be(e.get(I), n, {
|
|
563
598
|
uploadImage: r,
|
|
564
599
|
notify: c?.adapters.notify,
|
|
565
600
|
locale: c?.locale
|
|
566
601
|
});
|
|
567
602
|
});
|
|
568
603
|
};
|
|
569
|
-
return (t, n) => (m(), i("div",
|
|
604
|
+
return (t, n) => (m(), i("div", it, [
|
|
570
605
|
a("select", {
|
|
571
606
|
class: "kun-editor__heading-select",
|
|
572
|
-
"aria-label":
|
|
573
|
-
onChange:
|
|
574
|
-
}, [a("option",
|
|
607
|
+
"aria-label": S.value.textSize,
|
|
608
|
+
onChange: w
|
|
609
|
+
}, [a("option", ot, b(S.value.textSize), 1), (m(!0), i(e, null, v(C.value, (e) => (m(), i("option", {
|
|
575
610
|
key: e.level,
|
|
576
611
|
value: e.level
|
|
577
|
-
},
|
|
578
|
-
(m(!0), i(e, null,
|
|
612
|
+
}, b(e.label), 9, st))), 128))], 40, at),
|
|
613
|
+
(m(!0), i(e, null, v(T.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
|
|
579
614
|
class: "kun-editor__toolbar-divider",
|
|
580
615
|
"aria-hidden": "true"
|
|
581
|
-
}, null, -1), (m(!0), i(e, null,
|
|
616
|
+
}, null, -1), (m(!0), i(e, null, v(t, (e, t) => (m(), i("button", {
|
|
582
617
|
key: t,
|
|
583
618
|
type: "button",
|
|
584
619
|
class: "kun-editor__tool",
|
|
585
620
|
title: e.title,
|
|
586
621
|
"aria-label": e.title,
|
|
622
|
+
"aria-pressed": e.mark ? x(u)[e.mark] : void 0,
|
|
623
|
+
"data-active": e.mark ? x(u)[e.mark] : void 0,
|
|
587
624
|
onClick: (t) => e.run()
|
|
588
625
|
}, [a("span", {
|
|
589
626
|
class: "kun-editor__icon",
|
|
590
627
|
innerHTML: e.svg
|
|
591
|
-
}, null, 8,
|
|
592
|
-
|
|
628
|
+
}, null, 8, lt)], 8, ct))), 128))], 64))), 128)),
|
|
629
|
+
f.value ? (m(), i(e, { key: 0 }, [
|
|
593
630
|
n[1] ||= a("span", {
|
|
594
631
|
class: "kun-editor__toolbar-divider",
|
|
595
632
|
"aria-hidden": "true"
|
|
@@ -597,47 +634,48 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
597
634
|
a("button", {
|
|
598
635
|
type: "button",
|
|
599
636
|
class: "kun-editor__tool",
|
|
600
|
-
title:
|
|
601
|
-
"aria-label":
|
|
602
|
-
onClick:
|
|
637
|
+
title: S.value.image,
|
|
638
|
+
"aria-label": S.value.image,
|
|
639
|
+
onClick: D
|
|
603
640
|
}, [a("span", {
|
|
604
641
|
class: "kun-editor__icon",
|
|
605
|
-
innerHTML:
|
|
606
|
-
}, null, 8,
|
|
642
|
+
innerHTML: x($).image
|
|
643
|
+
}, null, 8, dt)], 8, ut),
|
|
607
644
|
a("input", {
|
|
608
645
|
ref_key: "fileInput",
|
|
609
|
-
ref:
|
|
646
|
+
ref: E,
|
|
610
647
|
type: "file",
|
|
611
648
|
accept: ".jpg,.jpeg,.png,.webp,.gif",
|
|
612
649
|
hidden: "",
|
|
613
|
-
onChange:
|
|
650
|
+
onChange: O
|
|
614
651
|
}, null, 544)
|
|
615
652
|
], 64)) : r("", !0),
|
|
616
|
-
|
|
653
|
+
p.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
|
|
617
654
|
class: "kun-editor__toolbar-divider",
|
|
618
655
|
"aria-hidden": "true"
|
|
619
|
-
}, null, -1), o(
|
|
656
|
+
}, null, -1), o(rt)], 64)) : r("", !0)
|
|
620
657
|
]));
|
|
621
658
|
}
|
|
622
|
-
}),
|
|
659
|
+
}), pt = /* @__PURE__ */ s({
|
|
623
660
|
__name: "ToolbarHost",
|
|
624
661
|
setup(e) {
|
|
625
|
-
let [, t] =
|
|
626
|
-
t()?.action(
|
|
627
|
-
},
|
|
628
|
-
t()?.action((e) => e.get(
|
|
629
|
-
},
|
|
630
|
-
run:
|
|
662
|
+
let [, t] = A(), n = l(X, void 0), { activeMarks: r, refresh: i } = Ve(), a = (e, n) => {
|
|
663
|
+
t()?.action(H(e, n)), i();
|
|
664
|
+
}, o = () => {
|
|
665
|
+
t()?.action((e) => e.get(I).focus());
|
|
666
|
+
}, s = {
|
|
667
|
+
run: a,
|
|
668
|
+
activeMarks: r,
|
|
631
669
|
insertText: (e) => {
|
|
632
670
|
t()?.action((t) => {
|
|
633
|
-
let n = t.get(
|
|
671
|
+
let n = t.get(I);
|
|
634
672
|
n.dispatch(n.state.tr.insertText(e));
|
|
635
|
-
}),
|
|
673
|
+
}), o();
|
|
636
674
|
},
|
|
637
675
|
uploadImage: (e) => {
|
|
638
676
|
let r = n?.adapters.uploadImage, i = t();
|
|
639
677
|
!r || !i || i.action((t) => {
|
|
640
|
-
|
|
678
|
+
be(t.get(I), e, {
|
|
641
679
|
uploadImage: r,
|
|
642
680
|
notify: n?.adapters.notify,
|
|
643
681
|
locale: n?.locale
|
|
@@ -645,22 +683,22 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
645
683
|
});
|
|
646
684
|
},
|
|
647
685
|
insertLink: (e) => {
|
|
648
|
-
|
|
686
|
+
a(J.key, e), o();
|
|
649
687
|
},
|
|
650
688
|
insertImage: (e) => {
|
|
651
|
-
|
|
689
|
+
a(q.key, {
|
|
652
690
|
src: e.src,
|
|
653
691
|
alt: e.alt ?? "",
|
|
654
692
|
title: e.title ?? ""
|
|
655
|
-
}),
|
|
693
|
+
}), o();
|
|
656
694
|
},
|
|
657
695
|
insertQuote: (e) => {
|
|
658
|
-
|
|
696
|
+
a(ge.key, e), o();
|
|
659
697
|
},
|
|
660
698
|
insertMention: (e) => {
|
|
661
|
-
|
|
699
|
+
a(he.key, e), o();
|
|
662
700
|
},
|
|
663
|
-
focus:
|
|
701
|
+
focus: o,
|
|
664
702
|
get adapters() {
|
|
665
703
|
return n?.adapters ?? {};
|
|
666
704
|
},
|
|
@@ -671,9 +709,9 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
671
709
|
return n?.locale ?? "zh-cn";
|
|
672
710
|
}
|
|
673
711
|
};
|
|
674
|
-
return (e, t) =>
|
|
712
|
+
return (e, t) => y(e.$slots, "default", d(c(s)));
|
|
675
713
|
}
|
|
676
|
-
}),
|
|
714
|
+
}), mt = /* @__PURE__ */ s({
|
|
677
715
|
__name: "MarkdownSource",
|
|
678
716
|
props: {
|
|
679
717
|
modelValue: {},
|
|
@@ -681,13 +719,13 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
681
719
|
},
|
|
682
720
|
emits: ["update:modelValue"],
|
|
683
721
|
setup(e, { expose: t, emit: n }) {
|
|
684
|
-
let r = e, a = n, o =
|
|
722
|
+
let r = e, a = n, o = _(null), s = null, c = Ce.define(), l = (e) => we.create({
|
|
685
723
|
doc: e,
|
|
686
724
|
extensions: [
|
|
687
|
-
|
|
725
|
+
_e(),
|
|
688
726
|
Y.lineWrapping,
|
|
689
|
-
|
|
690
|
-
|
|
727
|
+
Ee,
|
|
728
|
+
Te(),
|
|
691
729
|
Y.editable.of(!r.readonly),
|
|
692
730
|
Y.updateListener.of((e) => {
|
|
693
731
|
e.docChanged && !e.transactions.some((e) => e.annotation(c)) && a("update:modelValue", e.state.doc.toString());
|
|
@@ -724,7 +762,7 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
724
762
|
selection: { anchor: i },
|
|
725
763
|
scrollIntoView: !0
|
|
726
764
|
}), s.focus());
|
|
727
|
-
} }),
|
|
765
|
+
} }), C(() => r.modelValue, (e) => {
|
|
728
766
|
if (!s || s.state.doc.toString() === e) return;
|
|
729
767
|
let { anchor: t, head: n } = s.state.selection.main, r = e.length;
|
|
730
768
|
s.dispatch({
|
|
@@ -745,23 +783,23 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
745
783
|
class: "kun-editor__source"
|
|
746
784
|
}, null, 512));
|
|
747
785
|
}
|
|
748
|
-
}),
|
|
786
|
+
}), ht = ["data-mode"], gt = {
|
|
749
787
|
key: 0,
|
|
750
788
|
class: "kun-editor__toolbar",
|
|
751
789
|
role: "tablist"
|
|
752
|
-
},
|
|
790
|
+
}, _t = [
|
|
753
791
|
"aria-selected",
|
|
754
792
|
"data-active",
|
|
755
793
|
"onClick"
|
|
756
|
-
],
|
|
794
|
+
], vt = ["title", "aria-label"], yt = [
|
|
757
795
|
"data-active",
|
|
758
796
|
"title",
|
|
759
797
|
"aria-pressed"
|
|
760
|
-
],
|
|
798
|
+
], bt = ["data-swap"], xt = { class: "kun-editor__wysiwyg kun-editor__pane" }, St = {
|
|
761
799
|
key: 1,
|
|
762
800
|
class: "kun-editor__loading",
|
|
763
801
|
"aria-hidden": "true"
|
|
764
|
-
},
|
|
802
|
+
}, Ct = /* @__PURE__ */ s({
|
|
765
803
|
__name: "KunEditor",
|
|
766
804
|
props: {
|
|
767
805
|
modelValue: {},
|
|
@@ -793,49 +831,49 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
793
831
|
"update:headings",
|
|
794
832
|
"update:loading"
|
|
795
833
|
],
|
|
796
|
-
setup(s, { expose: l, emit:
|
|
834
|
+
setup(s, { expose: l, emit: g }) {
|
|
797
835
|
let E = [
|
|
798
836
|
"bold",
|
|
799
837
|
"italic",
|
|
800
838
|
"strike",
|
|
801
839
|
"code",
|
|
802
840
|
"link"
|
|
803
|
-
],
|
|
841
|
+
], D = s, k = g, A = _(!1);
|
|
804
842
|
p(() => {
|
|
805
|
-
|
|
843
|
+
A.value = !0;
|
|
806
844
|
});
|
|
807
|
-
let M =
|
|
845
|
+
let M = _(!0), N = (e) => {
|
|
808
846
|
M.value = e, k("update:loading", e);
|
|
809
847
|
};
|
|
810
|
-
|
|
848
|
+
C(() => D.modelValue, (e) => k("update:headings", te(e)), { immediate: !0 }), h(X, {
|
|
811
849
|
get adapters() {
|
|
812
|
-
return
|
|
850
|
+
return D.adapters;
|
|
813
851
|
},
|
|
814
852
|
get features() {
|
|
815
|
-
return
|
|
853
|
+
return D.features;
|
|
816
854
|
},
|
|
817
855
|
get locale() {
|
|
818
|
-
return
|
|
856
|
+
return D.locale;
|
|
819
857
|
},
|
|
820
858
|
get selectionToolbarItems() {
|
|
821
|
-
return Array.isArray(
|
|
859
|
+
return Array.isArray(D.selectionToolbar) ? D.selectionToolbar : E;
|
|
822
860
|
}
|
|
823
861
|
});
|
|
824
|
-
let
|
|
862
|
+
let ee = t(() => D.selectionToolbar !== !1), P = _(D.views.includes("wysiwyg") ? "wysiwyg" : D.views[0] ?? "wysiwyg"), F = (e) => {
|
|
825
863
|
P.value = e;
|
|
826
864
|
};
|
|
827
|
-
|
|
865
|
+
C(() => D.views, (e) => {
|
|
828
866
|
e.includes(P.value) || (P.value = e[0] ?? "wysiwyg");
|
|
829
867
|
});
|
|
830
|
-
let I =
|
|
868
|
+
let I = _(!1), ne = () => {
|
|
831
869
|
I.value = !I.value;
|
|
832
|
-
},
|
|
833
|
-
|
|
834
|
-
|
|
870
|
+
}, L = _(D.scrollSync);
|
|
871
|
+
C(() => D.scrollSync, (e) => {
|
|
872
|
+
L.value = e;
|
|
835
873
|
});
|
|
836
|
-
let
|
|
837
|
-
|
|
838
|
-
},
|
|
874
|
+
let R = () => {
|
|
875
|
+
L.value = !L.value;
|
|
876
|
+
}, re = t(() => D.locale.toLowerCase().startsWith("en")), z = t(() => re.value ? {
|
|
839
877
|
wysiwyg: "Preview",
|
|
840
878
|
source: "Markdown",
|
|
841
879
|
split: "Split",
|
|
@@ -847,11 +885,11 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
847
885
|
split: "分栏",
|
|
848
886
|
swap: "左右互换",
|
|
849
887
|
scrollSync: "同步滚动"
|
|
850
|
-
}),
|
|
888
|
+
}), B = _(null), V = null, H = null, U = null, W = () => {
|
|
851
889
|
V?.(), V = null, H = null;
|
|
852
890
|
}, ie = () => {
|
|
853
891
|
W();
|
|
854
|
-
let e =
|
|
892
|
+
let e = B.value;
|
|
855
893
|
if (!e) return;
|
|
856
894
|
let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
|
|
857
895
|
if (!t || !n) return;
|
|
@@ -867,83 +905,83 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
867
905
|
t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
|
|
868
906
|
};
|
|
869
907
|
};
|
|
870
|
-
|
|
908
|
+
C([P, L], ([e, t]) => {
|
|
871
909
|
W(), e === "split" && t && u(ie);
|
|
872
910
|
}), f(W);
|
|
873
|
-
let
|
|
911
|
+
let ae = t(() => D.readonly || P.value === "split"), G = (e) => k("update:modelValue", e), K = _(null), q = _(null);
|
|
874
912
|
return l({
|
|
875
|
-
insertQuote: (e) =>
|
|
876
|
-
insertMention: (e) =>
|
|
877
|
-
insertImage: (e) =>
|
|
878
|
-
uploadImage: (e) =>
|
|
879
|
-
focus: () =>
|
|
913
|
+
insertQuote: (e) => K.value?.insertQuote(e),
|
|
914
|
+
insertMention: (e) => K.value?.insertMention(e),
|
|
915
|
+
insertImage: (e) => K.value?.insertImage(e),
|
|
916
|
+
uploadImage: (e) => K.value?.uploadImage(e),
|
|
917
|
+
focus: () => K.value?.focus(),
|
|
880
918
|
scrollToHeading: (e) => {
|
|
881
|
-
P.value === "source" || P.value === "split" ?
|
|
919
|
+
P.value === "source" || P.value === "split" ? q.value?.scrollToHeading(e) : K.value?.scrollToHeading(e);
|
|
882
920
|
}
|
|
883
921
|
}), (t, l) => (m(), i("div", {
|
|
884
922
|
ref_key: "rootEl",
|
|
885
|
-
ref:
|
|
923
|
+
ref: B,
|
|
886
924
|
class: "kun-editor",
|
|
887
925
|
"data-kun-editor": "",
|
|
888
926
|
"data-mode": P.value
|
|
889
|
-
}, [
|
|
927
|
+
}, [A.value ? (m(), i(e, { key: 0 }, [y(t.$slots, "view-switch", {
|
|
890
928
|
mode: P.value,
|
|
891
929
|
setMode: F,
|
|
892
|
-
labels:
|
|
930
|
+
labels: z.value,
|
|
893
931
|
views: s.views,
|
|
894
932
|
swapped: I.value,
|
|
895
|
-
swap:
|
|
896
|
-
scrollSync:
|
|
897
|
-
toggleScrollSync:
|
|
898
|
-
}, () => [s.views.length > 1 ? (m(), i("div",
|
|
933
|
+
swap: ne,
|
|
934
|
+
scrollSync: L.value,
|
|
935
|
+
toggleScrollSync: R
|
|
936
|
+
}, () => [s.views.length > 1 ? (m(), i("div", gt, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
|
|
899
937
|
key: e,
|
|
900
938
|
type: "button",
|
|
901
939
|
class: "kun-editor__tab",
|
|
902
940
|
"aria-selected": P.value === e,
|
|
903
941
|
"data-active": P.value === e,
|
|
904
942
|
onClick: (t) => F(e)
|
|
905
|
-
},
|
|
943
|
+
}, b(z.value[e]), 9, _t))), 128)), P.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
|
|
906
944
|
type: "button",
|
|
907
945
|
class: "kun-editor__tab kun-editor__swap",
|
|
908
|
-
title:
|
|
909
|
-
"aria-label":
|
|
910
|
-
onClick: l[0] ||= (e) =>
|
|
911
|
-
}, " ⇄ ", 8,
|
|
946
|
+
title: z.value.swap,
|
|
947
|
+
"aria-label": z.value.swap,
|
|
948
|
+
onClick: l[0] ||= (e) => ne()
|
|
949
|
+
}, " ⇄ ", 8, vt), a("button", {
|
|
912
950
|
type: "button",
|
|
913
951
|
class: "kun-editor__tab",
|
|
914
|
-
"data-active":
|
|
915
|
-
title:
|
|
916
|
-
"aria-pressed":
|
|
917
|
-
onClick: l[1] ||= (e) =>
|
|
918
|
-
},
|
|
919
|
-
default:
|
|
920
|
-
default:
|
|
921
|
-
default:
|
|
952
|
+
"data-active": L.value,
|
|
953
|
+
title: z.value.scrollSync,
|
|
954
|
+
"aria-pressed": L.value,
|
|
955
|
+
onClick: l[1] ||= (e) => R()
|
|
956
|
+
}, b(z.value.scrollSync), 9, yt)], 64)) : r("", !0)])) : r("", !0)]), o(x(O), null, {
|
|
957
|
+
default: w(() => [o(x(j), null, {
|
|
958
|
+
default: w(() => [T(a("div", null, [o(pt, null, {
|
|
959
|
+
default: w((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(ft)])]),
|
|
922
960
|
_: 3
|
|
923
|
-
})], 512), [[
|
|
961
|
+
})], 512), [[S, P.value === "wysiwyg" && !s.readonly]]), a("div", {
|
|
924
962
|
class: "kun-editor__panes",
|
|
925
963
|
"data-swap": I.value
|
|
926
|
-
}, [P.value === "source" || P.value === "split" ? (m(), n(
|
|
964
|
+
}, [P.value === "source" || P.value === "split" ? (m(), n(mt, {
|
|
927
965
|
key: 0,
|
|
928
966
|
ref_key: "source",
|
|
929
|
-
ref:
|
|
967
|
+
ref: q,
|
|
930
968
|
class: "kun-editor__pane",
|
|
931
969
|
"model-value": s.modelValue,
|
|
932
970
|
readonly: s.readonly,
|
|
933
|
-
"onUpdate:modelValue":
|
|
934
|
-
}, null, 8, ["model-value", "readonly"])) : r("", !0),
|
|
971
|
+
"onUpdate:modelValue": G
|
|
972
|
+
}, null, 8, ["model-value", "readonly"])) : r("", !0), T(a("div", xt, [o(ze, {
|
|
935
973
|
ref_key: "inner",
|
|
936
|
-
ref:
|
|
974
|
+
ref: K,
|
|
937
975
|
"model-value": s.modelValue,
|
|
938
976
|
adapters: s.adapters,
|
|
939
977
|
features: s.features,
|
|
940
978
|
locale: s.locale,
|
|
941
|
-
readonly:
|
|
979
|
+
readonly: ae.value,
|
|
942
980
|
placeholder: s.placeholder,
|
|
943
981
|
"placeholder-mode": s.placeholderMode,
|
|
944
982
|
active: P.value === "wysiwyg" && !s.readonly,
|
|
945
|
-
"selection-toolbar":
|
|
946
|
-
"onUpdate:modelValue":
|
|
983
|
+
"selection-toolbar": ee.value,
|
|
984
|
+
"onUpdate:modelValue": G,
|
|
947
985
|
"onUpdate:loading": N
|
|
948
986
|
}, null, 8, [
|
|
949
987
|
"model-value",
|
|
@@ -955,18 +993,18 @@ var X = Symbol("kun-editor-context"), Se = [
|
|
|
955
993
|
"placeholder-mode",
|
|
956
994
|
"active",
|
|
957
995
|
"selection-toolbar"
|
|
958
|
-
])], 512), [[
|
|
996
|
+
])], 512), [[S, P.value === "wysiwyg" || P.value === "split"]])], 8, bt)]),
|
|
959
997
|
_: 3
|
|
960
998
|
})]),
|
|
961
999
|
_: 3
|
|
962
|
-
})], 64)) : r("", !0), !
|
|
1000
|
+
})], 64)) : r("", !0), !A.value || M.value ? (m(), i("div", St, [y(t.$slots, "loading", {}, () => [
|
|
963
1001
|
l[2] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
|
|
964
1002
|
l[3] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
|
|
965
1003
|
l[4] ||= a("div", { class: "kun-editor__skeleton" }, null, -1)
|
|
966
|
-
])])) : r("", !0)], 8,
|
|
1004
|
+
])])) : r("", !0)], 8, ht));
|
|
967
1005
|
}
|
|
968
|
-
}),
|
|
969
|
-
e.component("KunEditor",
|
|
1006
|
+
}), wt = { install(e) {
|
|
1007
|
+
e.component("KunEditor", Ct);
|
|
970
1008
|
} };
|
|
971
1009
|
//#endregion
|
|
972
|
-
export {
|
|
1010
|
+
export { He as EMOJI, Ct as KunEditor, wt as KunEditorPlugin, ee as parseHeadings };
|
package/dist/types.d.ts
CHANGED
|
@@ -2,9 +2,17 @@ import type { CmdKey } from '@milkdown/kit/core';
|
|
|
2
2
|
import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
|
|
3
3
|
export type KunToolbarItem = 'heading' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'quote' | 'codeBlock' | 'hr' | 'spoiler' | 'link' | 'image' | 'picker' | '|';
|
|
4
4
|
export type KunSelectionItem = 'bold' | 'italic' | 'strike' | 'code' | 'link' | '|';
|
|
5
|
+
export type KunToggleMark = 'bold' | 'italic' | 'strike' | 'code';
|
|
5
6
|
export interface KunEditorToolbarApi {
|
|
6
7
|
/** Run a Milkdown command (import its key from the preset/commonmark/gfm). */
|
|
7
8
|
run: <T>(key: CmdKey<T>, payload?: T) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Reactive active state of the toggle marks at the current cursor. A key is
|
|
11
|
+
* `true` while that mark is active (e.g. `bold` is true inside a bold run, or
|
|
12
|
+
* when it is the pending stored mark), so a toolbar can highlight its pressed
|
|
13
|
+
* buttons the same way it highlights hover.
|
|
14
|
+
*/
|
|
15
|
+
activeMarks: Readonly<Record<KunToggleMark, boolean>>;
|
|
8
16
|
/** Insert plain text at the cursor (e.g. an emoji). */
|
|
9
17
|
insertText: (text: string) => void;
|
|
10
18
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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": "0.32.0",
|
|
4
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": [
|
|
@@ -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.32.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.32.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "vite build && vue-tsc -p tsconfig.build.json",
|