@kungal/editor-vue 0.19.0 → 0.20.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 +34 -0
- package/dist/components/KunEditor.vue.d.ts +7 -0
- package/dist/components/KunEditor.vue.d.ts.map +1 -1
- package/dist/index.js +307 -258
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @kungal/editor-vue
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 62e14f5: Split view: sync scrolling between the panes, with an off switch.
|
|
8
|
+
|
|
9
|
+
Scrolling the markdown source pane now scrolls the WYSIWYG preview to the same
|
|
10
|
+
position (and vice-versa) — proportional/percentage sync (source↔preview line
|
|
11
|
+
mapping is impractical across two separate renderers), with an active-pane +
|
|
12
|
+
idle-timeout guard so the echoed scroll doesn't feed back into a loop.
|
|
13
|
+
|
|
14
|
+
Turn it off two ways (for downstream customization):
|
|
15
|
+
|
|
16
|
+
- **`scrollSync` prop** on `<KunEditor>` (default `true`) — pass
|
|
17
|
+
`:scroll-sync="false"` to disable entirely.
|
|
18
|
+
- **A runtime toggle** in the view switch: `KunEditorViewSwitchApi` gains
|
|
19
|
+
`scrollSync` / `toggleScrollSync()` (+ `labels.scrollSync`). The default view
|
|
20
|
+
switch shows a 同步滚动 toggle in split mode; `<KunEditorViewSwitch>` (editor-nuxt)
|
|
21
|
+
shows a KunUI link/unlink toggle button. Or replace the whole control via the
|
|
22
|
+
`#view-switch` slot.
|
|
23
|
+
|
|
24
|
+
Sync needs each pane to scroll internally, so the reference `kun-editor.css` now
|
|
25
|
+
gives split panes a bounded height (`--kun-editor-split-height`, default `60vh`,
|
|
26
|
+
overridable) with `overflow: auto`. editor-vue still ships zero CSS.
|
|
27
|
+
|
|
28
|
+
Verified in the docs production build (headless + KunUI view switches): with the
|
|
29
|
+
panes overflowing, scrolling the source drives the preview to the same ratio;
|
|
30
|
+
toggling off makes them scroll independently; toggling on resumes; 0 console
|
|
31
|
+
errors.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- @kungal/editor-core@0.20.0
|
|
36
|
+
|
|
3
37
|
## 0.19.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
|
@@ -13,6 +13,9 @@ type __VLS_Props = {
|
|
|
13
13
|
readonly?: boolean;
|
|
14
14
|
/** Placeholder text shown while the editor is empty. */
|
|
15
15
|
placeholder?: string;
|
|
16
|
+
/** Sync scrolling between the split panes. Default `true`; set `false` to
|
|
17
|
+
* disable (or toggle it at runtime via the view-switch API). */
|
|
18
|
+
scrollSync?: boolean;
|
|
16
19
|
};
|
|
17
20
|
type ViewMode = 'wysiwyg' | 'source' | 'split';
|
|
18
21
|
declare var __VLS_1: {
|
|
@@ -23,9 +26,12 @@ declare var __VLS_1: {
|
|
|
23
26
|
source: string;
|
|
24
27
|
split: string;
|
|
25
28
|
swap: string;
|
|
29
|
+
scrollSync: string;
|
|
26
30
|
};
|
|
27
31
|
swapped: boolean;
|
|
28
32
|
swap: () => void;
|
|
33
|
+
scrollSync: boolean;
|
|
34
|
+
toggleScrollSync: () => void;
|
|
29
35
|
}, __VLS_22: {
|
|
30
36
|
run: <T>(key: import("@milkdown/kit/core").CmdKey<T>, payload?: T) => void;
|
|
31
37
|
insertText: (text: string) => void;
|
|
@@ -58,6 +64,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, KunEditorEx
|
|
|
58
64
|
locale: KunEditorLocale;
|
|
59
65
|
readonly: boolean;
|
|
60
66
|
placeholder: string;
|
|
67
|
+
scrollSync: boolean;
|
|
61
68
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
62
69
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
63
70
|
declare const _default: typeof __VLS_export;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AA6TA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,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,OAAO,CAAA;IAClB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;oEACgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC;AAsCJ,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAsW9C,QAAA,IAAI,OAAO;;iBApWS,QAAQ;;;;;;;;;;;;CAoWP,EAAE,QAAQ;iEA3a/B,CAjTuE;;;;;;;;;;;;;;;CA4tBP,CAAE;AAClE,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAClD;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAQhD,QAAA,MAAM,UAAU;;;;;cAnaD,iBAAiB;cAEjB,iBAAiB;YAEnB,eAAe;cAEb,OAAO;iBAEJ,MAAM;gBAGP,OAAO;6EA6ZtB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
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,
|
|
2
|
-
import { Milkdown as
|
|
3
|
-
import { ProsemirrorAdapterProvider as
|
|
4
|
-
import { Editor as
|
|
5
|
-
import { listenerCtx as
|
|
6
|
-
import { SlashProvider as
|
|
7
|
-
import { callCommand as
|
|
8
|
-
import { createKunEditorPlugins as
|
|
9
|
-
import { TextSelection as
|
|
10
|
-
import { createCodeBlockCommand as
|
|
11
|
-
import { toggleStrikethroughCommand as
|
|
12
|
-
import { EditorState as
|
|
13
|
-
import { EditorView as
|
|
14
|
-
import { markdown as
|
|
15
|
-
import { basicSetup 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, ref as g, renderList as _, renderSlot as v, toDisplayString as y, unref as b, vShow as x, watch as S, withCtx as C, withDirectives as w, withModifiers as T } from "vue";
|
|
2
|
+
import { Milkdown as E, MilkdownProvider as D, useEditor as O, useInstance as k } from "@milkdown/vue";
|
|
3
|
+
import { ProsemirrorAdapterProvider as A, usePluginViewContext as j, usePluginViewFactory as M } from "@prosemirror-adapter/vue";
|
|
4
|
+
import { Editor as N, defaultValueCtx as P, editorViewCtx as F, editorViewOptionsCtx as I, rootCtx as L } from "@milkdown/kit/core";
|
|
5
|
+
import { listenerCtx as R } from "@milkdown/kit/plugin/listener";
|
|
6
|
+
import { SlashProvider as z, slashFactory as B } from "@milkdown/kit/plugin/slash";
|
|
7
|
+
import { callCommand as V, replaceAll as H } from "@milkdown/kit/utils";
|
|
8
|
+
import { createKunEditorPlugins as U, insertKunSpoilerCommand as W, insertMentionCommand as G, insertQuoteCommand as K, kunCM as ee, mentionId as te, setHeadingCommand as ne, startImageUpload as q } from "@kungal/editor-core/preset";
|
|
9
|
+
import { TextSelection as re } from "@milkdown/kit/prose/state";
|
|
10
|
+
import { createCodeBlockCommand as ie, insertHrCommand as ae, insertImageCommand 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";
|
|
11
|
+
import { toggleStrikethroughCommand as pe } from "@milkdown/kit/preset/gfm";
|
|
12
|
+
import { EditorState as me } from "@codemirror/state";
|
|
13
|
+
import { EditorView as J } from "@codemirror/view";
|
|
14
|
+
import { markdown as he } from "@codemirror/lang-markdown";
|
|
15
|
+
import { basicSetup as ge } from "codemirror";
|
|
16
16
|
//#region src/context.ts
|
|
17
|
-
var
|
|
17
|
+
var Y = 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
|
-
let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(
|
|
36
|
+
let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(Y), s = o?.adapters.searchMentionUsers, c = t(() => (o?.locale ?? "zh-cn").toLowerCase().startsWith("en")), u = t(() => c.value ? {
|
|
37
37
|
searching: "Searching…",
|
|
38
38
|
empty: "No matching users",
|
|
39
39
|
prompt: "Type a username to search"
|
|
@@ -41,21 +41,21 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
41
41
|
searching: "搜索中…",
|
|
42
42
|
empty: "无匹配用户",
|
|
43
43
|
prompt: "输入用户名以搜索"
|
|
44
|
-
}), { view:
|
|
45
|
-
|
|
44
|
+
}), { view: d, prevState: h } = j(), v = g(null), b, x = g(!1), C = g(""), w = g([]), E = g(0), D = g(!1), O = null, k = 0, A = null, M = () => {
|
|
45
|
+
A &&= (clearTimeout(A), null), C.value = "", w.value = [], E.value = 0, D.value = !1, O = null;
|
|
46
46
|
}, N = (e) => {
|
|
47
|
-
if (
|
|
48
|
-
|
|
47
|
+
if (A &&= (clearTimeout(A), null), !e || !s) {
|
|
48
|
+
w.value = [], D.value = !1;
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
D.value = !0,
|
|
51
|
+
D.value = !0, A = setTimeout(async () => {
|
|
52
52
|
let t = ++k, n = [];
|
|
53
53
|
try {
|
|
54
54
|
n = await s(e);
|
|
55
55
|
} catch {
|
|
56
56
|
n = [];
|
|
57
57
|
}
|
|
58
|
-
t === k && (
|
|
58
|
+
t === k && (w.value = n ?? [], E.value = 0, D.value = !1);
|
|
59
59
|
}, 180);
|
|
60
60
|
}, P = (e) => {
|
|
61
61
|
let { selection: t } = e.state;
|
|
@@ -71,21 +71,21 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
71
71
|
to: n
|
|
72
72
|
}, t !== C.value && (C.value = t, N(t)), !0;
|
|
73
73
|
}, I = (e) => {
|
|
74
|
-
let t =
|
|
74
|
+
let t = d.value;
|
|
75
75
|
if (!t || !O) return;
|
|
76
|
-
let n = t.state.schema.nodes[
|
|
76
|
+
let n = t.state.schema.nodes[te];
|
|
77
77
|
if (!n) return;
|
|
78
78
|
let r = n.create({
|
|
79
79
|
userId: e.id,
|
|
80
80
|
name: e.name
|
|
81
81
|
}), { from: i, to: a } = O, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
|
|
82
|
-
o.insertText(" ", s), o.setSelection(
|
|
82
|
+
o.insertText(" ", s), o.setSelection(re.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
|
|
83
83
|
}, L = (e) => {
|
|
84
|
-
if (!
|
|
85
|
-
|
|
84
|
+
if (!x.value || !w.value.length) {
|
|
85
|
+
x.value && e.key === "Escape" && (e.preventDefault(), b.hide());
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
let t =
|
|
88
|
+
let t = w.value.length - 1;
|
|
89
89
|
switch (e.key) {
|
|
90
90
|
case "ArrowDown":
|
|
91
91
|
e.preventDefault(), e.stopPropagation(), E.value = E.value >= t ? 0 : E.value + 1;
|
|
@@ -95,7 +95,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
95
95
|
break;
|
|
96
96
|
case "Enter":
|
|
97
97
|
case "Tab": {
|
|
98
|
-
let t =
|
|
98
|
+
let t = w.value[E.value];
|
|
99
99
|
t && (e.preventDefault(), e.stopPropagation(), I(t));
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
@@ -104,41 +104,41 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
104
104
|
break;
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
return
|
|
108
|
-
b = new
|
|
109
|
-
content:
|
|
107
|
+
return p(() => {
|
|
108
|
+
b = new z({
|
|
109
|
+
content: v.value,
|
|
110
110
|
trigger: "@",
|
|
111
111
|
shouldShow: F,
|
|
112
112
|
debounce: 0
|
|
113
113
|
}), b.onShow = () => {
|
|
114
|
-
|
|
114
|
+
x.value = !0;
|
|
115
115
|
}, b.onHide = () => {
|
|
116
|
-
|
|
117
|
-
}, b.update(
|
|
118
|
-
}),
|
|
119
|
-
b?.update(
|
|
120
|
-
}),
|
|
121
|
-
|
|
122
|
-
}), (t, n) => (
|
|
116
|
+
x.value = !1, M();
|
|
117
|
+
}, b.update(d.value, h.value), window.addEventListener("keydown", L, !0);
|
|
118
|
+
}), S([d, h], () => {
|
|
119
|
+
b?.update(d.value, h.value);
|
|
120
|
+
}), f(() => {
|
|
121
|
+
A && clearTimeout(A), window.removeEventListener("keydown", L, !0), b?.destroy();
|
|
122
|
+
}), (t, n) => (m(), i("div", {
|
|
123
123
|
ref_key: "divRef",
|
|
124
|
-
ref:
|
|
124
|
+
ref: v,
|
|
125
125
|
class: "kun-mention-dropdown",
|
|
126
126
|
"data-show": "false"
|
|
127
|
-
}, [
|
|
127
|
+
}, [w.value.length ? (m(!0), i(e, { key: 0 }, _(w.value, (e, t) => (m(), i("button", {
|
|
128
128
|
key: e.id,
|
|
129
129
|
type: "button",
|
|
130
130
|
class: "kun-mention-dropdown__item",
|
|
131
131
|
"data-active": t === E.value,
|
|
132
|
-
onMousedown:
|
|
132
|
+
onMousedown: T((t) => I(e), ["prevent"]),
|
|
133
133
|
onMouseenter: (e) => E.value = t
|
|
134
|
-
}, [e.avatar ? (
|
|
134
|
+
}, [e.avatar ? (m(), i("img", {
|
|
135
135
|
key: 0,
|
|
136
136
|
src: e.avatar,
|
|
137
137
|
alt: e.name,
|
|
138
138
|
class: "kun-mention-dropdown__avatar"
|
|
139
|
-
}, null, 8,
|
|
139
|
+
}, null, 8, ve)) : (m(), i("span", ye, y(e.name.charAt(0)), 1)), a("span", be, y(e.name), 1)], 40, _e))), 128)) : D.value ? (m(), i("div", xe, y(u.value.searching), 1)) : C.value ? (m(), i("div", Se, y(u.value.empty), 1)) : (m(), i("div", Ce, y(u.value.prompt), 1))], 512));
|
|
140
140
|
}
|
|
141
|
-
}),
|
|
141
|
+
}), Te = /* @__PURE__ */ s({
|
|
142
142
|
__name: "MilkdownEditor",
|
|
143
143
|
props: {
|
|
144
144
|
modelValue: {},
|
|
@@ -150,76 +150,76 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
150
150
|
},
|
|
151
151
|
emits: ["update:modelValue"],
|
|
152
152
|
setup(e, { expose: t, emit: r }) {
|
|
153
|
-
let i = e, a = r, o = i.modelValue, s =
|
|
154
|
-
let t =
|
|
155
|
-
t.set(
|
|
153
|
+
let i = e, a = r, o = i.modelValue, s = M(), c = B("kunMention"), l = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!s, u = O((e) => {
|
|
154
|
+
let t = N.make().config((t) => {
|
|
155
|
+
t.set(L, e), t.set(P, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
|
|
156
156
|
t !== n && (o = t, a("update:modelValue", t));
|
|
157
|
-
}), t.update(
|
|
157
|
+
}), t.update(I, (e) => ({
|
|
158
158
|
...e,
|
|
159
159
|
editable: () => !i.readonly
|
|
160
|
-
})), l && t.set(c.key, { view: s({ component:
|
|
161
|
-
}).use(
|
|
160
|
+
})), l && t.set(c.key, { view: s({ component: we }) });
|
|
161
|
+
}).use(U(i.adapters, i.features, {
|
|
162
162
|
locale: i.locale,
|
|
163
163
|
placeholder: i.placeholder
|
|
164
164
|
}));
|
|
165
165
|
return l && t.use(c), t;
|
|
166
166
|
});
|
|
167
|
-
|
|
168
|
-
e !== o && (o = e, u.get()?.action(
|
|
169
|
-
}),
|
|
167
|
+
S(() => i.modelValue, (e) => {
|
|
168
|
+
e !== o && (o = e, u.get()?.action(H(e)));
|
|
169
|
+
}), S(() => i.readonly, () => {
|
|
170
170
|
u.get()?.action((e) => {
|
|
171
|
-
let t = e.get(
|
|
171
|
+
let t = e.get(F);
|
|
172
172
|
t.dispatch(t.state.tr);
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
175
|
let d = () => {
|
|
176
|
-
u.get()?.action((e) => e.get(
|
|
176
|
+
u.get()?.action((e) => e.get(F).focus());
|
|
177
177
|
};
|
|
178
178
|
return t({
|
|
179
179
|
insertQuote: (e) => {
|
|
180
|
-
u.get()?.action(
|
|
180
|
+
u.get()?.action(V(K.key, e)), d();
|
|
181
181
|
},
|
|
182
182
|
insertMention: (e) => {
|
|
183
|
-
u.get()?.action(
|
|
183
|
+
u.get()?.action(V(G.key, e)), d();
|
|
184
184
|
},
|
|
185
185
|
focus: d
|
|
186
|
-
}), (e, t) => (
|
|
186
|
+
}), (e, t) => (m(), n(b(E)));
|
|
187
187
|
}
|
|
188
|
-
}),
|
|
189
|
-
bold:
|
|
190
|
-
italic:
|
|
191
|
-
strike:
|
|
192
|
-
code:
|
|
193
|
-
h1:
|
|
194
|
-
h2:
|
|
195
|
-
h3:
|
|
196
|
-
bulletList:
|
|
197
|
-
orderedList:
|
|
198
|
-
quote:
|
|
199
|
-
codeBlock:
|
|
200
|
-
hr:
|
|
201
|
-
image:
|
|
202
|
-
spoiler:
|
|
203
|
-
latex:
|
|
204
|
-
smile:
|
|
205
|
-
},
|
|
188
|
+
}), X = (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>`, Z = (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>`, Q = {
|
|
189
|
+
bold: X("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
|
|
190
|
+
italic: X("<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\"/>"),
|
|
191
|
+
strike: X("<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\"/>"),
|
|
192
|
+
code: X("<path d=\"m18 16 4-4-4-4\"/><path d=\"m6 8-4 4 4 4\"/><path d=\"m14.5 4-5 16\"/>"),
|
|
193
|
+
h1: Z("H1", 11),
|
|
194
|
+
h2: Z("H2", 11),
|
|
195
|
+
h3: Z("H3", 11),
|
|
196
|
+
bulletList: X("<line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><circle cx=\"3.5\" cy=\"6\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3.5\" cy=\"12\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3.5\" cy=\"18\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/>"),
|
|
197
|
+
orderedList: X("<line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-1.5 2-2.5S5 14 4 14.5\"/>"),
|
|
198
|
+
quote: X("<path d=\"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z\" fill=\"currentColor\" stroke=\"none\"/>"),
|
|
199
|
+
codeBlock: X("<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\"/><path d=\"m9 10-2 2 2 2\"/><path d=\"m15 10 2 2-2 2\"/>"),
|
|
200
|
+
hr: X("<line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/>"),
|
|
201
|
+
image: X("<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"1.8\" fill=\"currentColor\" stroke=\"none\"/><path d=\"m21 15-4.5-4.5a2 2 0 0 0-2.8 0L5 19\"/>"),
|
|
202
|
+
spoiler: X("<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\"/>"),
|
|
203
|
+
latex: Z("Σ", 15),
|
|
204
|
+
smile: X("<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\"/>")
|
|
205
|
+
}, $ = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ee = [
|
|
206
206
|
"title",
|
|
207
207
|
"aria-label",
|
|
208
208
|
"aria-expanded"
|
|
209
|
-
],
|
|
209
|
+
], De = ["innerHTML"], Oe = { class: "kun-editor__picker-panel" }, ke = {
|
|
210
210
|
key: 0,
|
|
211
211
|
class: "kun-editor__picker-tabs",
|
|
212
212
|
role: "tablist"
|
|
213
|
-
},
|
|
213
|
+
}, Ae = ["data-active"], je = ["data-active"], Me = { class: "kun-editor__emoji-grid" }, Ne = ["onClick"], Pe = {
|
|
214
214
|
key: 1,
|
|
215
215
|
class: "kun-editor__sticker-body"
|
|
216
|
-
},
|
|
216
|
+
}, Fe = { class: "kun-editor__pack-name" }, Ie = { class: "kun-editor__sticker-grid" }, Le = ["title", "onClick"], Re = ["src", "alt"], ze = {
|
|
217
217
|
key: 1,
|
|
218
218
|
class: "kun-editor__picker-hint"
|
|
219
|
-
},
|
|
219
|
+
}, Be = /* @__PURE__ */ s({
|
|
220
220
|
__name: "StickerPicker",
|
|
221
221
|
setup(n) {
|
|
222
|
-
let [, o] =
|
|
222
|
+
let [, o] = k(), s = l(Y), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
|
|
223
223
|
trigger: "Emoji & stickers",
|
|
224
224
|
emoji: "Emoji",
|
|
225
225
|
sticker: "Stickers",
|
|
@@ -231,7 +231,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
231
231
|
sticker: "贴纸",
|
|
232
232
|
empty: "暂无贴纸",
|
|
233
233
|
failed: "贴纸加载失败"
|
|
234
|
-
}),
|
|
234
|
+
}), v = g(!1), S = g(null), C = g("emoji"), T = g([]), E = g(!1), D = g(!1), O = async () => {
|
|
235
235
|
if (!(E.value || !c)) {
|
|
236
236
|
E.value = !0;
|
|
237
237
|
try {
|
|
@@ -241,59 +241,59 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
}, A = () => {
|
|
244
|
-
|
|
244
|
+
v.value = !v.value, v.value && u && O();
|
|
245
245
|
}, j = (e) => {
|
|
246
|
-
|
|
246
|
+
v.value && S.value && !S.value.contains(e.target) && (v.value = !1);
|
|
247
247
|
};
|
|
248
|
-
|
|
248
|
+
p(() => document.addEventListener("click", j)), f(() => document.removeEventListener("click", j));
|
|
249
249
|
let M = (e) => {
|
|
250
250
|
o()?.action((t) => {
|
|
251
|
-
let n = t.get(
|
|
251
|
+
let n = t.get(F), { state: r } = n;
|
|
252
252
|
n.dispatch(r.tr.insertText(e, r.selection.from));
|
|
253
253
|
});
|
|
254
254
|
}, N = (e, t) => {
|
|
255
|
-
o()?.action(
|
|
255
|
+
o()?.action(V(oe.key, {
|
|
256
256
|
src: e,
|
|
257
257
|
title: t,
|
|
258
258
|
alt: t
|
|
259
259
|
}));
|
|
260
260
|
};
|
|
261
|
-
return (t, n) => (
|
|
261
|
+
return (t, n) => (m(), i("div", {
|
|
262
262
|
ref_key: "rootRef",
|
|
263
263
|
ref: S,
|
|
264
264
|
class: "kun-editor__picker"
|
|
265
265
|
}, [a("button", {
|
|
266
266
|
type: "button",
|
|
267
267
|
class: "kun-editor__tool",
|
|
268
|
-
title:
|
|
269
|
-
"aria-label":
|
|
270
|
-
"aria-expanded":
|
|
268
|
+
title: h.value.trigger,
|
|
269
|
+
"aria-label": h.value.trigger,
|
|
270
|
+
"aria-expanded": v.value,
|
|
271
271
|
onClick: A
|
|
272
272
|
}, [a("span", {
|
|
273
273
|
class: "kun-editor__icon",
|
|
274
|
-
innerHTML:
|
|
275
|
-
}, null, 8,
|
|
276
|
-
u ? (
|
|
274
|
+
innerHTML: b(Q).smile
|
|
275
|
+
}, null, 8, De)], 8, Ee), w(a("div", Oe, [
|
|
276
|
+
u ? (m(), i("div", ke, [a("button", {
|
|
277
277
|
type: "button",
|
|
278
278
|
class: "kun-editor__picker-tab",
|
|
279
|
-
"data-active":
|
|
280
|
-
onClick: n[0] ||= (e) =>
|
|
281
|
-
},
|
|
279
|
+
"data-active": C.value === "emoji",
|
|
280
|
+
onClick: n[0] ||= (e) => C.value = "emoji"
|
|
281
|
+
}, y(h.value.emoji), 9, Ae), a("button", {
|
|
282
282
|
type: "button",
|
|
283
283
|
class: "kun-editor__picker-tab",
|
|
284
|
-
"data-active":
|
|
285
|
-
onClick: n[1] ||= (e) =>
|
|
286
|
-
},
|
|
287
|
-
|
|
284
|
+
"data-active": C.value === "sticker",
|
|
285
|
+
onClick: n[1] ||= (e) => C.value = "sticker"
|
|
286
|
+
}, y(h.value.sticker), 9, je)])) : r("", !0),
|
|
287
|
+
w(a("div", Me, [(m(!0), i(e, null, _(b($), (e, t) => (m(), i("button", {
|
|
288
288
|
key: t,
|
|
289
289
|
type: "button",
|
|
290
290
|
class: "kun-editor__emoji",
|
|
291
291
|
onClick: (t) => M(e)
|
|
292
|
-
},
|
|
293
|
-
u ?
|
|
292
|
+
}, y(e), 9, Ne))), 128))], 512), [[x, !u || C.value === "emoji"]]),
|
|
293
|
+
u ? w((m(), i("div", Pe, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
|
|
294
294
|
key: t.name,
|
|
295
295
|
class: "kun-editor__pack"
|
|
296
|
-
}, [a("div",
|
|
296
|
+
}, [a("div", Fe, y(t.name), 1), a("div", Ie, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
|
|
297
297
|
key: t,
|
|
298
298
|
type: "button",
|
|
299
299
|
class: "kun-editor__sticker",
|
|
@@ -303,26 +303,26 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
303
303
|
src: e.src,
|
|
304
304
|
alt: e.name,
|
|
305
305
|
loading: "lazy"
|
|
306
|
-
}, null, 8,
|
|
307
|
-
], 512), [[
|
|
306
|
+
}, null, 8, Re)], 8, Le))), 128))])]))), 128)) : (m(), i("div", ze, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
|
|
307
|
+
], 512), [[x, v.value]])], 512));
|
|
308
308
|
}
|
|
309
|
-
}),
|
|
309
|
+
}), Ve = {
|
|
310
310
|
class: "kun-editor__format-toolbar",
|
|
311
311
|
role: "toolbar"
|
|
312
|
-
},
|
|
312
|
+
}, He = ["aria-label"], Ue = {
|
|
313
313
|
value: "",
|
|
314
314
|
disabled: "",
|
|
315
315
|
selected: ""
|
|
316
|
-
},
|
|
316
|
+
}, We = ["value"], Ge = [
|
|
317
317
|
"title",
|
|
318
318
|
"aria-label",
|
|
319
319
|
"onClick"
|
|
320
|
-
],
|
|
320
|
+
], Ke = ["innerHTML"], qe = ["title", "aria-label"], Je = ["innerHTML"], Ye = /* @__PURE__ */ s({
|
|
321
321
|
__name: "EditorToolbar",
|
|
322
322
|
setup(n) {
|
|
323
|
-
let [, s] =
|
|
324
|
-
s()?.action(
|
|
325
|
-
},
|
|
323
|
+
let [, s] = k(), c = l(Y), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), p = (e, t) => {
|
|
324
|
+
s()?.action(V(e, t));
|
|
325
|
+
}, h = t(() => {
|
|
326
326
|
let e = f.value;
|
|
327
327
|
return {
|
|
328
328
|
textSize: e ? "Text size" : "文本大小",
|
|
@@ -338,7 +338,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
338
338
|
spoiler: e ? "Spoiler" : "隐藏文本",
|
|
339
339
|
image: e ? "Upload image" : "上传图片"
|
|
340
340
|
};
|
|
341
|
-
}),
|
|
341
|
+
}), v = t(() => {
|
|
342
342
|
let e = f.value;
|
|
343
343
|
return [
|
|
344
344
|
"正文",
|
|
@@ -354,87 +354,87 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
354
354
|
}));
|
|
355
355
|
}), x = (e) => {
|
|
356
356
|
let t = e.target;
|
|
357
|
-
|
|
357
|
+
p(ne.key, Number(t.value)), t.selectedIndex = 0;
|
|
358
358
|
}, S = t(() => [
|
|
359
359
|
[
|
|
360
360
|
{
|
|
361
|
-
svg:
|
|
362
|
-
title:
|
|
363
|
-
run: () =>
|
|
361
|
+
svg: Q.bold,
|
|
362
|
+
title: h.value.bold,
|
|
363
|
+
run: () => p(le.key)
|
|
364
364
|
},
|
|
365
365
|
{
|
|
366
|
-
svg:
|
|
367
|
-
title:
|
|
368
|
-
run: () =>
|
|
366
|
+
svg: Q.italic,
|
|
367
|
+
title: h.value.italic,
|
|
368
|
+
run: () => p(se.key)
|
|
369
369
|
},
|
|
370
370
|
{
|
|
371
|
-
svg:
|
|
372
|
-
title:
|
|
373
|
-
run: () =>
|
|
371
|
+
svg: Q.strike,
|
|
372
|
+
title: h.value.strike,
|
|
373
|
+
run: () => p(pe.key)
|
|
374
374
|
},
|
|
375
375
|
{
|
|
376
|
-
svg:
|
|
377
|
-
title:
|
|
378
|
-
run: () =>
|
|
376
|
+
svg: Q.code,
|
|
377
|
+
title: h.value.code,
|
|
378
|
+
run: () => p(ce.key)
|
|
379
379
|
}
|
|
380
380
|
],
|
|
381
381
|
[
|
|
382
382
|
{
|
|
383
|
-
svg:
|
|
384
|
-
title:
|
|
385
|
-
run: () =>
|
|
383
|
+
svg: Q.bulletList,
|
|
384
|
+
title: h.value.bulletList,
|
|
385
|
+
run: () => p(de.key)
|
|
386
386
|
},
|
|
387
387
|
{
|
|
388
|
-
svg:
|
|
389
|
-
title:
|
|
390
|
-
run: () =>
|
|
388
|
+
svg: Q.orderedList,
|
|
389
|
+
title: h.value.orderedList,
|
|
390
|
+
run: () => p(fe.key)
|
|
391
391
|
},
|
|
392
392
|
{
|
|
393
|
-
svg:
|
|
394
|
-
title:
|
|
395
|
-
run: () =>
|
|
393
|
+
svg: Q.quote,
|
|
394
|
+
title: h.value.quote,
|
|
395
|
+
run: () => p(ue.key)
|
|
396
396
|
},
|
|
397
397
|
{
|
|
398
|
-
svg:
|
|
399
|
-
title:
|
|
400
|
-
run: () =>
|
|
398
|
+
svg: Q.codeBlock,
|
|
399
|
+
title: h.value.codeBlock,
|
|
400
|
+
run: () => p(ie.key, "")
|
|
401
401
|
},
|
|
402
402
|
{
|
|
403
|
-
svg:
|
|
404
|
-
title:
|
|
405
|
-
run: () =>
|
|
403
|
+
svg: Q.hr,
|
|
404
|
+
title: h.value.hr,
|
|
405
|
+
run: () => p(ae.key)
|
|
406
406
|
}
|
|
407
407
|
],
|
|
408
408
|
[{
|
|
409
|
-
svg:
|
|
410
|
-
title:
|
|
411
|
-
run: () =>
|
|
409
|
+
svg: Q.spoiler,
|
|
410
|
+
title: h.value.spoiler,
|
|
411
|
+
run: () => p(W.key)
|
|
412
412
|
}]
|
|
413
|
-
]), C =
|
|
413
|
+
]), C = g(null), w = () => C.value?.click(), T = (e) => {
|
|
414
414
|
let t = e.target, n = t.files?.[0];
|
|
415
415
|
t.value = "";
|
|
416
416
|
let r = u.value;
|
|
417
417
|
!n || !r || s()?.action((e) => {
|
|
418
|
-
|
|
418
|
+
q(e.get(F), n, {
|
|
419
419
|
uploadImage: r,
|
|
420
420
|
notify: c?.adapters.notify,
|
|
421
421
|
locale: c?.locale
|
|
422
422
|
});
|
|
423
423
|
});
|
|
424
424
|
};
|
|
425
|
-
return (t, n) => (
|
|
425
|
+
return (t, n) => (m(), i("div", Ve, [
|
|
426
426
|
a("select", {
|
|
427
427
|
class: "kun-editor__heading-select",
|
|
428
|
-
"aria-label":
|
|
428
|
+
"aria-label": h.value.textSize,
|
|
429
429
|
onChange: x
|
|
430
|
-
}, [a("option",
|
|
430
|
+
}, [a("option", Ue, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("option", {
|
|
431
431
|
key: e.level,
|
|
432
432
|
value: e.level
|
|
433
|
-
},
|
|
434
|
-
(
|
|
433
|
+
}, y(e.label), 9, We))), 128))], 40, He),
|
|
434
|
+
(m(!0), i(e, null, _(S.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
|
|
435
435
|
class: "kun-editor__toolbar-divider",
|
|
436
436
|
"aria-hidden": "true"
|
|
437
|
-
}, null, -1), (
|
|
437
|
+
}, null, -1), (m(!0), i(e, null, _(t, (e, t) => (m(), i("button", {
|
|
438
438
|
key: t,
|
|
439
439
|
type: "button",
|
|
440
440
|
class: "kun-editor__tool",
|
|
@@ -444,8 +444,8 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
444
444
|
}, [a("span", {
|
|
445
445
|
class: "kun-editor__icon",
|
|
446
446
|
innerHTML: e.svg
|
|
447
|
-
}, null, 8,
|
|
448
|
-
u.value ? (
|
|
447
|
+
}, null, 8, Ke)], 8, Ge))), 128))], 64))), 128)),
|
|
448
|
+
u.value ? (m(), i(e, { key: 0 }, [
|
|
449
449
|
n[1] ||= a("span", {
|
|
450
450
|
class: "kun-editor__toolbar-divider",
|
|
451
451
|
"aria-hidden": "true"
|
|
@@ -453,13 +453,13 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
453
453
|
a("button", {
|
|
454
454
|
type: "button",
|
|
455
455
|
class: "kun-editor__tool",
|
|
456
|
-
title:
|
|
457
|
-
"aria-label":
|
|
456
|
+
title: h.value.image,
|
|
457
|
+
"aria-label": h.value.image,
|
|
458
458
|
onClick: w
|
|
459
459
|
}, [a("span", {
|
|
460
460
|
class: "kun-editor__icon",
|
|
461
|
-
innerHTML:
|
|
462
|
-
}, null, 8,
|
|
461
|
+
innerHTML: b(Q).image
|
|
462
|
+
}, null, 8, Je)], 8, qe),
|
|
463
463
|
a("input", {
|
|
464
464
|
ref_key: "fileInput",
|
|
465
465
|
ref: C,
|
|
@@ -469,31 +469,31 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
469
469
|
onChange: T
|
|
470
470
|
}, null, 544)
|
|
471
471
|
], 64)) : r("", !0),
|
|
472
|
-
d.value ? (
|
|
472
|
+
d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
|
|
473
473
|
class: "kun-editor__toolbar-divider",
|
|
474
474
|
"aria-hidden": "true"
|
|
475
|
-
}, null, -1), o(
|
|
475
|
+
}, null, -1), o(Be)], 64)) : r("", !0)
|
|
476
476
|
]));
|
|
477
477
|
}
|
|
478
478
|
}), Xe = /* @__PURE__ */ s({
|
|
479
479
|
__name: "ToolbarHost",
|
|
480
480
|
setup(e) {
|
|
481
|
-
let [, t] =
|
|
482
|
-
t()?.action(
|
|
481
|
+
let [, t] = k(), n = l(Y, void 0), r = (e, n) => {
|
|
482
|
+
t()?.action(V(e, n));
|
|
483
483
|
}, i = () => {
|
|
484
|
-
t()?.action((e) => e.get(
|
|
484
|
+
t()?.action((e) => e.get(F).focus());
|
|
485
485
|
}, a = {
|
|
486
486
|
run: r,
|
|
487
487
|
insertText: (e) => {
|
|
488
488
|
t()?.action((t) => {
|
|
489
|
-
let n = t.get(
|
|
489
|
+
let n = t.get(F);
|
|
490
490
|
n.dispatch(n.state.tr.insertText(e));
|
|
491
491
|
}), i();
|
|
492
492
|
},
|
|
493
493
|
uploadImage: (e) => {
|
|
494
494
|
let r = n?.adapters.uploadImage, i = t();
|
|
495
495
|
!r || !i || i.action((t) => {
|
|
496
|
-
|
|
496
|
+
q(t.get(F), e, {
|
|
497
497
|
uploadImage: r,
|
|
498
498
|
notify: n?.adapters.notify,
|
|
499
499
|
locale: n?.locale
|
|
@@ -501,10 +501,10 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
501
501
|
});
|
|
502
502
|
},
|
|
503
503
|
insertQuote: (e) => {
|
|
504
|
-
r(
|
|
504
|
+
r(K.key, e), i();
|
|
505
505
|
},
|
|
506
506
|
insertMention: (e) => {
|
|
507
|
-
r(
|
|
507
|
+
r(G.key, e), i();
|
|
508
508
|
},
|
|
509
509
|
focus: i,
|
|
510
510
|
get adapters() {
|
|
@@ -517,7 +517,7 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
517
517
|
return n?.locale ?? "zh-cn";
|
|
518
518
|
}
|
|
519
519
|
};
|
|
520
|
-
return (e, t) =>
|
|
520
|
+
return (e, t) => v(e.$slots, "default", d(c(a)));
|
|
521
521
|
}
|
|
522
522
|
}), Ze = /* @__PURE__ */ s({
|
|
523
523
|
__name: "MarkdownSource",
|
|
@@ -527,29 +527,29 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
527
527
|
},
|
|
528
528
|
emits: ["update:modelValue"],
|
|
529
529
|
setup(e, { emit: t }) {
|
|
530
|
-
let n = e, r = t, a =
|
|
530
|
+
let n = e, r = t, a = g(null), o = null, s = (e) => me.create({
|
|
531
531
|
doc: e,
|
|
532
532
|
extensions: [
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
533
|
+
ee(),
|
|
534
|
+
J.lineWrapping,
|
|
535
|
+
ge,
|
|
536
|
+
he(),
|
|
537
|
+
J.editable.of(!n.readonly),
|
|
538
|
+
J.updateListener.of((e) => {
|
|
539
539
|
e.docChanged && r("update:modelValue", e.state.doc.toString());
|
|
540
540
|
})
|
|
541
541
|
]
|
|
542
542
|
});
|
|
543
|
-
return
|
|
544
|
-
a.value && (o = new
|
|
543
|
+
return p(() => {
|
|
544
|
+
a.value && (o = new J({
|
|
545
545
|
state: s(n.modelValue),
|
|
546
546
|
parent: a.value
|
|
547
547
|
}));
|
|
548
|
-
}),
|
|
548
|
+
}), f(() => {
|
|
549
549
|
o?.destroy(), o = null;
|
|
550
|
-
}),
|
|
550
|
+
}), S(() => n.modelValue, (e) => {
|
|
551
551
|
o && o.state.doc.toString() !== e && o.setState(s(e));
|
|
552
|
-
}), (e, t) => (
|
|
552
|
+
}), (e, t) => (m(), i("div", {
|
|
553
553
|
ref_key: "host",
|
|
554
554
|
ref: a,
|
|
555
555
|
class: "kun-editor__source"
|
|
@@ -558,7 +558,11 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
558
558
|
}), Qe = ["data-mode"], $e = {
|
|
559
559
|
class: "kun-editor__toolbar",
|
|
560
560
|
role: "tablist"
|
|
561
|
-
}, et = ["aria-selected", "data-active"], tt = ["aria-selected", "data-active"], nt = ["aria-selected", "data-active"], rt = ["title", "aria-label"], it = [
|
|
561
|
+
}, et = ["aria-selected", "data-active"], tt = ["aria-selected", "data-active"], nt = ["aria-selected", "data-active"], rt = ["title", "aria-label"], it = [
|
|
562
|
+
"data-active",
|
|
563
|
+
"title",
|
|
564
|
+
"aria-pressed"
|
|
565
|
+
], at = ["data-swap"], ot = { class: "kun-editor__wysiwyg kun-editor__pane" }, st = /* @__PURE__ */ s({
|
|
562
566
|
__name: "KunEditor",
|
|
563
567
|
props: {
|
|
564
568
|
modelValue: {},
|
|
@@ -569,105 +573,150 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
569
573
|
type: Boolean,
|
|
570
574
|
default: !1
|
|
571
575
|
},
|
|
572
|
-
placeholder: { default: "" }
|
|
576
|
+
placeholder: { default: "" },
|
|
577
|
+
scrollSync: {
|
|
578
|
+
type: Boolean,
|
|
579
|
+
default: !0
|
|
580
|
+
}
|
|
573
581
|
},
|
|
574
582
|
emits: ["update:modelValue"],
|
|
575
|
-
setup(
|
|
576
|
-
let
|
|
577
|
-
|
|
583
|
+
setup(s, { expose: l, emit: p }) {
|
|
584
|
+
let _ = s, T = p;
|
|
585
|
+
h(Y, {
|
|
578
586
|
get adapters() {
|
|
579
|
-
return
|
|
587
|
+
return _.adapters;
|
|
580
588
|
},
|
|
581
589
|
get features() {
|
|
582
|
-
return
|
|
590
|
+
return _.features;
|
|
583
591
|
},
|
|
584
592
|
get locale() {
|
|
585
|
-
return
|
|
593
|
+
return _.locale;
|
|
586
594
|
}
|
|
587
595
|
});
|
|
588
|
-
let
|
|
589
|
-
|
|
590
|
-
},
|
|
591
|
-
|
|
592
|
-
},
|
|
596
|
+
let E = g("wysiwyg"), O = (e) => {
|
|
597
|
+
E.value = e;
|
|
598
|
+
}, k = g(!1), j = () => {
|
|
599
|
+
k.value = !k.value;
|
|
600
|
+
}, M = g(_.scrollSync);
|
|
601
|
+
S(() => _.scrollSync, (e) => {
|
|
602
|
+
M.value = e;
|
|
603
|
+
});
|
|
604
|
+
let N = () => {
|
|
605
|
+
M.value = !M.value;
|
|
606
|
+
}, P = t(() => _.locale.toLowerCase().startsWith("en")), F = t(() => P.value ? {
|
|
593
607
|
wysiwyg: "Preview",
|
|
594
608
|
source: "Markdown",
|
|
595
609
|
split: "Split",
|
|
596
|
-
swap: "Swap sides"
|
|
610
|
+
swap: "Swap sides",
|
|
611
|
+
scrollSync: "Sync scroll"
|
|
597
612
|
} : {
|
|
598
613
|
wysiwyg: "预览",
|
|
599
614
|
source: "Markdown",
|
|
600
615
|
split: "分栏",
|
|
601
|
-
swap: "左右互换"
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
616
|
+
swap: "左右互换",
|
|
617
|
+
scrollSync: "同步滚动"
|
|
618
|
+
}), I = g(null), L = null, R = null, z = null, B = () => {
|
|
619
|
+
L?.(), L = null, R = null;
|
|
620
|
+
}, V = () => {
|
|
621
|
+
B();
|
|
622
|
+
let e = I.value;
|
|
623
|
+
if (!e) return;
|
|
624
|
+
let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
|
|
625
|
+
if (!t || !n) return;
|
|
626
|
+
let r = (e, t) => () => {
|
|
627
|
+
if (R && R !== e) return;
|
|
628
|
+
R = e;
|
|
629
|
+
let n = e.scrollHeight - e.clientHeight, r = n > 0 ? e.scrollTop / n : 0, i = t.scrollHeight - t.clientHeight;
|
|
630
|
+
t.scrollTop = r * (i > 0 ? i : 0), z && clearTimeout(z), z = setTimeout(() => {
|
|
631
|
+
R = null;
|
|
632
|
+
}, 120);
|
|
633
|
+
}, i = r(t, n), a = r(n, t);
|
|
634
|
+
t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), L = () => {
|
|
635
|
+
t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
S([E, M], ([e, t]) => {
|
|
639
|
+
B(), e === "split" && t && u(V);
|
|
640
|
+
}), f(B);
|
|
641
|
+
let H = t(() => _.readonly || E.value === "split"), U = (e) => T("update:modelValue", e), W = g(null);
|
|
642
|
+
return l({
|
|
643
|
+
insertQuote: (e) => W.value?.insertQuote(e),
|
|
644
|
+
insertMention: (e) => W.value?.insertMention(e),
|
|
645
|
+
focus: () => W.value?.focus()
|
|
646
|
+
}), (t, l) => (m(), i("div", {
|
|
647
|
+
ref_key: "rootEl",
|
|
648
|
+
ref: I,
|
|
608
649
|
class: "kun-editor",
|
|
609
650
|
"data-kun-editor": "",
|
|
610
|
-
"data-mode":
|
|
611
|
-
}, [
|
|
612
|
-
mode:
|
|
613
|
-
setMode:
|
|
614
|
-
labels:
|
|
615
|
-
swapped:
|
|
616
|
-
swap:
|
|
651
|
+
"data-mode": E.value
|
|
652
|
+
}, [v(t.$slots, "view-switch", {
|
|
653
|
+
mode: E.value,
|
|
654
|
+
setMode: O,
|
|
655
|
+
labels: F.value,
|
|
656
|
+
swapped: k.value,
|
|
657
|
+
swap: j,
|
|
658
|
+
scrollSync: M.value,
|
|
659
|
+
toggleScrollSync: N
|
|
617
660
|
}, () => [a("div", $e, [
|
|
618
661
|
a("button", {
|
|
619
662
|
type: "button",
|
|
620
663
|
class: "kun-editor__tab",
|
|
621
|
-
"aria-selected":
|
|
622
|
-
"data-active":
|
|
623
|
-
onClick:
|
|
624
|
-
},
|
|
664
|
+
"aria-selected": E.value === "wysiwyg",
|
|
665
|
+
"data-active": E.value === "wysiwyg",
|
|
666
|
+
onClick: l[0] ||= (e) => O("wysiwyg")
|
|
667
|
+
}, y(F.value.wysiwyg), 9, et),
|
|
625
668
|
a("button", {
|
|
626
669
|
type: "button",
|
|
627
670
|
class: "kun-editor__tab",
|
|
628
|
-
"aria-selected":
|
|
629
|
-
"data-active":
|
|
630
|
-
onClick:
|
|
631
|
-
},
|
|
671
|
+
"aria-selected": E.value === "source",
|
|
672
|
+
"data-active": E.value === "source",
|
|
673
|
+
onClick: l[1] ||= (e) => O("source")
|
|
674
|
+
}, y(F.value.source), 9, tt),
|
|
632
675
|
a("button", {
|
|
633
676
|
type: "button",
|
|
634
677
|
class: "kun-editor__tab",
|
|
635
|
-
"aria-selected":
|
|
636
|
-
"data-active":
|
|
637
|
-
onClick:
|
|
638
|
-
},
|
|
639
|
-
|
|
640
|
-
key: 0,
|
|
678
|
+
"aria-selected": E.value === "split",
|
|
679
|
+
"data-active": E.value === "split",
|
|
680
|
+
onClick: l[2] ||= (e) => O("split")
|
|
681
|
+
}, y(F.value.split), 9, nt),
|
|
682
|
+
E.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
|
|
641
683
|
type: "button",
|
|
642
684
|
class: "kun-editor__tab kun-editor__swap",
|
|
643
|
-
title:
|
|
644
|
-
"aria-label":
|
|
645
|
-
onClick:
|
|
646
|
-
}, " ⇄ ", 8, rt)
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
685
|
+
title: F.value.swap,
|
|
686
|
+
"aria-label": F.value.swap,
|
|
687
|
+
onClick: l[3] ||= (e) => j()
|
|
688
|
+
}, " ⇄ ", 8, rt), a("button", {
|
|
689
|
+
type: "button",
|
|
690
|
+
class: "kun-editor__tab",
|
|
691
|
+
"data-active": M.value,
|
|
692
|
+
title: F.value.scrollSync,
|
|
693
|
+
"aria-pressed": M.value,
|
|
694
|
+
onClick: l[4] ||= (e) => N()
|
|
695
|
+
}, y(F.value.scrollSync), 9, it)], 64)) : r("", !0)
|
|
696
|
+
])]), o(b(D), null, {
|
|
697
|
+
default: C(() => [o(b(A), null, {
|
|
698
|
+
default: C(() => [w(a("div", null, [o(Xe, null, {
|
|
699
|
+
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(Ye)])]),
|
|
651
700
|
_: 3
|
|
652
|
-
})], 512), [[
|
|
701
|
+
})], 512), [[x, E.value === "wysiwyg" && !s.readonly]]), a("div", {
|
|
653
702
|
class: "kun-editor__panes",
|
|
654
|
-
"data-swap":
|
|
655
|
-
}, [
|
|
703
|
+
"data-swap": k.value
|
|
704
|
+
}, [E.value === "source" || E.value === "split" ? (m(), n(Ze, {
|
|
656
705
|
key: 0,
|
|
657
706
|
class: "kun-editor__pane",
|
|
658
|
-
"model-value":
|
|
659
|
-
readonly:
|
|
660
|
-
"onUpdate:modelValue":
|
|
661
|
-
}, null, 8, ["model-value", "readonly"])) : r("", !0),
|
|
707
|
+
"model-value": s.modelValue,
|
|
708
|
+
readonly: s.readonly,
|
|
709
|
+
"onUpdate:modelValue": U
|
|
710
|
+
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ot, [o(Te, {
|
|
662
711
|
ref_key: "inner",
|
|
663
|
-
ref:
|
|
664
|
-
"model-value":
|
|
665
|
-
adapters:
|
|
666
|
-
features:
|
|
667
|
-
locale:
|
|
668
|
-
readonly:
|
|
669
|
-
placeholder:
|
|
670
|
-
"onUpdate:modelValue":
|
|
712
|
+
ref: W,
|
|
713
|
+
"model-value": s.modelValue,
|
|
714
|
+
adapters: s.adapters,
|
|
715
|
+
features: s.features,
|
|
716
|
+
locale: s.locale,
|
|
717
|
+
readonly: H.value,
|
|
718
|
+
placeholder: s.placeholder,
|
|
719
|
+
"onUpdate:modelValue": U
|
|
671
720
|
}, null, 8, [
|
|
672
721
|
"model-value",
|
|
673
722
|
"adapters",
|
|
@@ -675,14 +724,14 @@ var q = Symbol("kun-editor-context"), ve = [
|
|
|
675
724
|
"locale",
|
|
676
725
|
"readonly",
|
|
677
726
|
"placeholder"
|
|
678
|
-
])], 512), [[
|
|
727
|
+
])], 512), [[x, E.value === "wysiwyg" || E.value === "split"]])], 8, at)]),
|
|
679
728
|
_: 3
|
|
680
729
|
})]),
|
|
681
730
|
_: 3
|
|
682
731
|
})], 8, Qe));
|
|
683
732
|
}
|
|
684
|
-
}),
|
|
685
|
-
e.component("KunEditor",
|
|
733
|
+
}), ct = { install(e) {
|
|
734
|
+
e.component("KunEditor", st);
|
|
686
735
|
} };
|
|
687
736
|
//#endregion
|
|
688
|
-
export {
|
|
737
|
+
export { $ as EMOJI, st as KunEditor, ct as KunEditorPlugin };
|
package/dist/types.d.ts
CHANGED
|
@@ -41,11 +41,16 @@ export interface KunEditorViewSwitchApi {
|
|
|
41
41
|
source: string;
|
|
42
42
|
split: string;
|
|
43
43
|
swap: string;
|
|
44
|
+
scrollSync: string;
|
|
44
45
|
};
|
|
45
46
|
/** Whether the split panes are swapped (source on the right). */
|
|
46
47
|
swapped: boolean;
|
|
47
48
|
/** Toggle the split panes' left/right order. */
|
|
48
49
|
swap: () => void;
|
|
50
|
+
/** Whether split-pane scroll sync is on. */
|
|
51
|
+
scrollSync: boolean;
|
|
52
|
+
/** Toggle split-pane scroll sync. */
|
|
53
|
+
toggleScrollSync: () => void;
|
|
49
54
|
}
|
|
50
55
|
export interface KunEditorExpose {
|
|
51
56
|
/**
|
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,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC7C,uDAAuD;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC;;;;OAIG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChE,6CAA6C;IAC7C,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAClE,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CACjC;AAMD,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACpC,8BAA8B;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAA;IACvD,qDAAqD;IACrD,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC7C,uDAAuD;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC;;;;OAIG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChE,6CAA6C;IAC7C,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAClE,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CACjC;AAMD,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACpC,8BAA8B;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAA;IACvD,qDAAqD;IACrD,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAA;IAChB,gDAAgD;IAChD,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAA;IACnB,qCAAqC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B;AASD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC5D;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9D,gCAAgC;IAChC,KAAK,IAAI,IAAI,CAAA;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungal/editor-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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.20.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.20.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "vite build && vue-tsc -p tsconfig.build.json",
|