@kungal/editor-vue 0.25.1 → 0.26.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 +55 -0
- package/dist/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/KunEditor.vue.d.ts +4 -0
- package/dist/components/KunEditor.vue.d.ts.map +1 -1
- package/dist/components/MilkdownEditor.vue.d.ts +6 -0
- package/dist/components/MilkdownEditor.vue.d.ts.map +1 -1
- package/dist/components/SelectionTooltip.vue.d.ts.map +1 -1
- package/dist/components/ToolbarHost.vue.d.ts +4 -0
- package/dist/components/ToolbarHost.vue.d.ts.map +1 -1
- package/dist/index.js +161 -135
- package/dist/toolbar-icons.d.ts +1 -0
- package/dist/toolbar-icons.d.ts.map +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @kungal/editor-vue
|
|
2
2
|
|
|
3
|
+
## 0.26.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 945708d: Add an insert-link feature (click to add a URL).
|
|
8
|
+
|
|
9
|
+
The `link` mark already existed (so `[text](url)` round-trips and pasted URLs
|
|
10
|
+
autolink), but there was no click-to-insert UI. Now there is:
|
|
11
|
+
|
|
12
|
+
- **editor-core**: `insertLinkCommand` (`{ href, text? }`) — applies the link mark
|
|
13
|
+
to the selection, or inserts linked text on an empty selection; clears the
|
|
14
|
+
stored mark afterwards. Re-exported from `@kungal/editor-core/preset`.
|
|
15
|
+
- **editor-vue**: `KunEditorToolbarApi.insertLink(payload)`; a `link` button in the
|
|
16
|
+
default toolbar and the selection bubble (both default-on); `'link'` added to
|
|
17
|
+
`KunToolbarItem` and `KunSelectionItem`. Headless UI prompts for the URL.
|
|
18
|
+
- **editor-nuxt**: `<KunEditorToolbar>` gains a `link` button — a KunPopover with a
|
|
19
|
+
KunInput for the URL.
|
|
20
|
+
|
|
21
|
+
A link is a **mark** (`[text](url)`), deliberately distinct from the custom-NODE
|
|
22
|
+
embeds (mention / quote). A future "article card" or custom component would be a
|
|
23
|
+
node like those (schema + toUrl/fromUrl), not this — a separate mechanism.
|
|
24
|
+
|
|
25
|
+
Verified in the docs production build: the KunUI toolbar popover wraps a selection
|
|
26
|
+
(`[…](https://example.com)`); the selection bubble does too
|
|
27
|
+
(`[linktext](https://kun.com)`); 4 new core tests (wrap / insert / autolink
|
|
28
|
+
fallback / blank-href no-op) pass; 0 console errors.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [945708d]
|
|
33
|
+
- @kungal/editor-core@0.26.0
|
|
34
|
+
|
|
35
|
+
## 0.25.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 8e1b8ac: Fix the source pane rewriting raw markdown in split/source mode.
|
|
40
|
+
|
|
41
|
+
Typing `>` turned into `> <br />`, and `~~` / `**` / `[` became `\~\~` / `\*\*` /
|
|
42
|
+
`\[` in the markdown source. Cause: those are Milkdown's WYSIWYG→markdown
|
|
43
|
+
serialization (empty-blockquote → `<br />`, and remark-stringify escaping special
|
|
44
|
+
characters) — correct when Milkdown is the editor, but in split/source mode the
|
|
45
|
+
CodeMirror source owns the raw markdown, and the read-only preview was echoing its
|
|
46
|
+
re-serialized markdown back into the shared `v-model`, clobbering what you typed.
|
|
47
|
+
|
|
48
|
+
Fix: the WYSIWYG editor now emits only when it is the ACTIVE editor (WYSIWYG
|
|
49
|
+
mode). In source/split mode it's a derived preview and never writes back, so the
|
|
50
|
+
source keeps your exact raw markdown. The preview still renders it correctly.
|
|
51
|
+
|
|
52
|
+
Verified in the docs production build (split mode): `> `, `~~strike~~`,
|
|
53
|
+
`**bold**`, and a lone `>` all stay verbatim in the source (no `<br />`, no
|
|
54
|
+
backslash escapes); WYSIWYG-mode editing still updates the value; 0 console errors.
|
|
55
|
+
|
|
56
|
+
- @kungal/editor-core@0.25.2
|
|
57
|
+
|
|
3
58
|
## 0.25.1
|
|
4
59
|
|
|
5
60
|
### 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":"AAieA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -56,6 +56,10 @@ declare var __VLS_1: {
|
|
|
56
56
|
run: <T>(key: import("@milkdown/kit/core").CmdKey<T>, payload?: T) => void;
|
|
57
57
|
insertText: (text: string) => void;
|
|
58
58
|
uploadImage: (file: File) => void;
|
|
59
|
+
insertLink: (payload: {
|
|
60
|
+
href: string;
|
|
61
|
+
text?: string;
|
|
62
|
+
}) => void;
|
|
59
63
|
insertQuote: (payload: {
|
|
60
64
|
refId: string;
|
|
61
65
|
label: string;
|
|
@@ -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":"AAwWA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,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,CAA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QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -9,6 +9,12 @@ type __VLS_Props = {
|
|
|
9
9
|
placeholder: string;
|
|
10
10
|
placeholderMode: 'doc' | 'block';
|
|
11
11
|
selectionToolbar: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether this WYSIWYG is the ACTIVE editor (source of truth). False in
|
|
14
|
+
* source/split mode, where the CodeMirror source owns the raw markdown and this
|
|
15
|
+
* is only a derived preview — so it must NOT emit its re-serialized markdown.
|
|
16
|
+
*/
|
|
17
|
+
active: boolean;
|
|
12
18
|
};
|
|
13
19
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, KunEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
20
|
"update:modelValue": (markdown: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"AAsOA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,KAAK,GAAG,OAAO,CAAA;IAChC,gBAAgB,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB,CAAC;AA+KF,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AAiTA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -3,6 +3,10 @@ declare var __VLS_1: {
|
|
|
3
3
|
run: <T>(key: CmdKey<T>, payload?: T) => void;
|
|
4
4
|
insertText: (text: string) => void;
|
|
5
5
|
uploadImage: (file: File) => void;
|
|
6
|
+
insertLink: (payload: {
|
|
7
|
+
href: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
}) => void;
|
|
6
10
|
insertQuote: (payload: {
|
|
7
11
|
refId: string;
|
|
8
12
|
label: string;
|
|
@@ -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":"AA+FA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AA6FhD,QAAA,IAAI,OAAO;oCA9FX,CA1DqB;;;;;YA0DrB,CAvC2C;;;;;;;;;;;;;;CAqIrB,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"}
|
package/dist/index.js
CHANGED
|
@@ -5,33 +5,33 @@ import { Editor as N, defaultValueCtx as P, editorViewCtx as F, editorViewOption
|
|
|
5
5
|
import { listenerCtx as R } from "@milkdown/kit/plugin/listener";
|
|
6
6
|
import { SlashProvider as z, slashFactory as B } from "@milkdown/kit/plugin/slash";
|
|
7
7
|
import { TooltipProvider as V, tooltipFactory as H } from "@milkdown/kit/plugin/tooltip";
|
|
8
|
-
import { callCommand as U, replaceAll as
|
|
9
|
-
import { createKunEditorPlugins as
|
|
10
|
-
import { TextSelection as
|
|
11
|
-
import { createCodeBlockCommand as
|
|
12
|
-
import { toggleStrikethroughCommand as
|
|
13
|
-
import { Annotation as
|
|
8
|
+
import { callCommand as U, replaceAll as ee } from "@milkdown/kit/utils";
|
|
9
|
+
import { createKunEditorPlugins as te, insertKunSpoilerCommand as W, insertLinkCommand as G, insertMentionCommand as ne, insertQuoteCommand as re, kunCM as ie, mentionId as ae, setHeadingCommand as oe, startImageUpload as K } from "@kungal/editor-core/preset";
|
|
10
|
+
import { TextSelection as se } from "@milkdown/kit/prose/state";
|
|
11
|
+
import { createCodeBlockCommand as ce, insertHrCommand as le, insertImageCommand as ue, toggleEmphasisCommand as q, toggleInlineCodeCommand as de, toggleStrongCommand as fe, wrapInBlockquoteCommand as pe, wrapInBulletListCommand as me, wrapInOrderedListCommand as he } from "@milkdown/kit/preset/commonmark";
|
|
12
|
+
import { toggleStrikethroughCommand as J } from "@milkdown/kit/preset/gfm";
|
|
13
|
+
import { Annotation as ge, EditorState as _e } from "@codemirror/state";
|
|
14
14
|
import { EditorView as Y } from "@codemirror/view";
|
|
15
|
-
import { markdown as
|
|
16
|
-
import { basicSetup as
|
|
15
|
+
import { markdown as ve } from "@codemirror/lang-markdown";
|
|
16
|
+
import { basicSetup as ye } from "codemirror";
|
|
17
17
|
//#region src/context.ts
|
|
18
|
-
var X = Symbol("kun-editor-context"),
|
|
18
|
+
var X = Symbol("kun-editor-context"), be = [
|
|
19
19
|
"data-active",
|
|
20
20
|
"onMousedown",
|
|
21
21
|
"onMouseenter"
|
|
22
|
-
],
|
|
22
|
+
], xe = ["src", "alt"], Se = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
|
|
25
|
-
},
|
|
25
|
+
}, Ce = { class: "kun-mention-dropdown__name" }, we = {
|
|
26
26
|
key: 1,
|
|
27
27
|
class: "kun-mention-dropdown__hint"
|
|
28
|
-
},
|
|
28
|
+
}, Te = {
|
|
29
29
|
key: 2,
|
|
30
30
|
class: "kun-mention-dropdown__hint"
|
|
31
|
-
},
|
|
31
|
+
}, Ee = {
|
|
32
32
|
key: 3,
|
|
33
33
|
class: "kun-mention-dropdown__hint"
|
|
34
|
-
},
|
|
34
|
+
}, De = /* @__PURE__ */ s({
|
|
35
35
|
__name: "MentionDropdown",
|
|
36
36
|
setup(n) {
|
|
37
37
|
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 ? {
|
|
@@ -74,13 +74,13 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
74
74
|
}, I = (e) => {
|
|
75
75
|
let t = d.value;
|
|
76
76
|
if (!t || !O) return;
|
|
77
|
-
let n = t.state.schema.nodes[
|
|
77
|
+
let n = t.state.schema.nodes[ae];
|
|
78
78
|
if (!n) return;
|
|
79
79
|
let r = n.create({
|
|
80
80
|
userId: e.id,
|
|
81
81
|
name: e.name
|
|
82
82
|
}), { from: i, to: a } = O, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
|
|
83
|
-
o.insertText(" ", s), o.setSelection(
|
|
83
|
+
o.insertText(" ", s), o.setSelection(se.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
|
|
84
84
|
}, L = (e) => {
|
|
85
85
|
if (!x.value || !w.value.length) {
|
|
86
86
|
x.value && e.key === "Escape" && (e.preventDefault(), b.hide());
|
|
@@ -137,7 +137,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
137
137
|
src: e.avatar,
|
|
138
138
|
alt: e.name,
|
|
139
139
|
class: "kun-mention-dropdown__avatar"
|
|
140
|
-
}, null, 8,
|
|
140
|
+
}, null, 8, xe)) : (m(), i("span", Se, y(e.name.charAt(0)), 1)), a("span", Ce, y(e.name), 1)], 40, be))), 128)) : D.value ? (m(), i("div", we, y(u.value.searching), 1)) : C.value ? (m(), i("div", Te, y(u.value.empty), 1)) : (m(), i("div", Ee, y(u.value.prompt), 1))], 512));
|
|
141
141
|
}
|
|
142
142
|
}), 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>`, $ = {
|
|
143
143
|
bold: Z("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
|
|
@@ -154,51 +154,61 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
154
154
|
hr: Z("<line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/>"),
|
|
155
155
|
image: Z("<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\"/>"),
|
|
156
156
|
spoiler: Z("<path d=\"M9.9 4.24A9.1 9.1 0 0 1 12 4c7 0 10 8 10 8a13.2 13.2 0 0 1-1.67 2.68\"/><path d=\"M6.6 6.6A13.5 13.5 0 0 0 2 12s3 8 10 8a9.7 9.7 0 0 0 5.4-1.6\"/><line x1=\"2\" y1=\"2\" x2=\"22\" y2=\"22\"/>"),
|
|
157
|
+
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\"/>"),
|
|
157
158
|
latex: Q("Σ", 15),
|
|
158
159
|
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\"/>")
|
|
159
|
-
},
|
|
160
|
+
}, Oe = {
|
|
160
161
|
key: 0,
|
|
161
162
|
class: "kun-editor__toolbar-divider",
|
|
162
163
|
"aria-hidden": "true"
|
|
163
|
-
},
|
|
164
|
+
}, ke = [
|
|
164
165
|
"title",
|
|
165
166
|
"aria-label",
|
|
166
167
|
"onMousedown"
|
|
167
|
-
],
|
|
168
|
+
], Ae = ["innerHTML"], je = /* @__PURE__ */ s({
|
|
168
169
|
__name: "SelectionTooltip",
|
|
169
170
|
setup(n) {
|
|
170
171
|
let { view: r, prevState: o } = j(), [, s] = k(), c = l(X), u = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), d = g(null), h, v = (e, t) => {
|
|
171
172
|
s()?.action(U(e, t));
|
|
172
|
-
}, y =
|
|
173
|
+
}, y = () => {
|
|
174
|
+
let e = window.prompt(u.value ? "Link URL" : "链接 URL")?.trim();
|
|
175
|
+
e && v(G.key, { href: e });
|
|
176
|
+
}, b = t(() => {
|
|
173
177
|
let e = u.value;
|
|
174
178
|
return {
|
|
175
179
|
bold: {
|
|
176
180
|
svg: $.bold,
|
|
177
181
|
title: e ? "Bold" : "加粗",
|
|
178
|
-
run: () => v(
|
|
182
|
+
run: () => v(fe.key)
|
|
179
183
|
},
|
|
180
184
|
italic: {
|
|
181
185
|
svg: $.italic,
|
|
182
186
|
title: e ? "Italic" : "斜体",
|
|
183
|
-
run: () => v(
|
|
187
|
+
run: () => v(q.key)
|
|
184
188
|
},
|
|
185
189
|
strike: {
|
|
186
190
|
svg: $.strike,
|
|
187
191
|
title: e ? "Strikethrough" : "删除线",
|
|
188
|
-
run: () => v(
|
|
192
|
+
run: () => v(J.key)
|
|
189
193
|
},
|
|
190
194
|
code: {
|
|
191
195
|
svg: $.code,
|
|
192
196
|
title: e ? "Inline code" : "行内代码",
|
|
193
|
-
run: () => v(
|
|
197
|
+
run: () => v(de.key)
|
|
198
|
+
},
|
|
199
|
+
link: {
|
|
200
|
+
svg: $.link,
|
|
201
|
+
title: e ? "Link" : "链接",
|
|
202
|
+
run: y
|
|
194
203
|
}
|
|
195
204
|
};
|
|
196
|
-
}),
|
|
197
|
-
let e =
|
|
205
|
+
}), x = t(() => {
|
|
206
|
+
let e = b.value, t = (c?.selectionToolbarItems ?? [
|
|
198
207
|
"bold",
|
|
199
208
|
"italic",
|
|
200
209
|
"strike",
|
|
201
|
-
"code"
|
|
210
|
+
"code",
|
|
211
|
+
"link"
|
|
202
212
|
]).map((t) => t === "|" ? { divider: !0 } : e[t] ? {
|
|
203
213
|
divider: !1,
|
|
204
214
|
...e[t]
|
|
@@ -221,7 +231,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
221
231
|
ref: d,
|
|
222
232
|
class: "kun-editor__bubble",
|
|
223
233
|
"data-show": "false"
|
|
224
|
-
}, [(m(!0), i(e, null, _(
|
|
234
|
+
}, [(m(!0), i(e, null, _(x.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", Oe)) : (m(), i("button", {
|
|
225
235
|
key: 1,
|
|
226
236
|
type: "button",
|
|
227
237
|
class: "kun-editor__bubble-btn",
|
|
@@ -231,9 +241,9 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
231
241
|
}, [a("span", {
|
|
232
242
|
class: "kun-editor__icon",
|
|
233
243
|
innerHTML: t.svg
|
|
234
|
-
}, null, 8,
|
|
244
|
+
}, null, 8, Ae)], 40, ke))], 64))), 128))], 512));
|
|
235
245
|
}
|
|
236
|
-
}),
|
|
246
|
+
}), Me = /* @__PURE__ */ s({
|
|
237
247
|
__name: "MilkdownEditor",
|
|
238
248
|
props: {
|
|
239
249
|
modelValue: {},
|
|
@@ -243,19 +253,20 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
243
253
|
readonly: { type: Boolean },
|
|
244
254
|
placeholder: {},
|
|
245
255
|
placeholderMode: {},
|
|
246
|
-
selectionToolbar: { type: Boolean }
|
|
256
|
+
selectionToolbar: { type: Boolean },
|
|
257
|
+
active: { type: Boolean }
|
|
247
258
|
},
|
|
248
259
|
emits: ["update:modelValue"],
|
|
249
260
|
setup(e, { expose: t, emit: r }) {
|
|
250
261
|
let i = e, a = r, o = i.modelValue, s = !1, c = M(), l = B("kunMention"), u = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!c, d = H("kunSelectionTooltip"), f = i.selectionToolbar && !!c, p = O((e) => {
|
|
251
262
|
let t = N.make().config((t) => {
|
|
252
263
|
t.set(L, e), t.set(P, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
|
|
253
|
-
s || t === n || (o = t, a("update:modelValue", t));
|
|
264
|
+
!i.active || s || t === n || (o = t, a("update:modelValue", t));
|
|
254
265
|
}), t.update(I, (e) => ({
|
|
255
266
|
...e,
|
|
256
267
|
editable: () => !i.readonly
|
|
257
|
-
})), u && t.set(l.key, { view: c({ component:
|
|
258
|
-
}).use(
|
|
268
|
+
})), u && t.set(l.key, { view: c({ component: De }) }), f && t.set(d.key, { view: c({ component: je }) });
|
|
269
|
+
}).use(te(i.adapters, i.features, {
|
|
259
270
|
locale: i.locale,
|
|
260
271
|
placeholder: i.placeholder,
|
|
261
272
|
placeholderMode: i.placeholderMode
|
|
@@ -266,7 +277,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
266
277
|
if (e === o) return;
|
|
267
278
|
o = e;
|
|
268
279
|
let t = p.get();
|
|
269
|
-
t && (s = !0, t.action(
|
|
280
|
+
t && (s = !0, t.action(ee(e)), s = !1);
|
|
270
281
|
}), S(() => i.readonly, () => {
|
|
271
282
|
p.get()?.action((e) => {
|
|
272
283
|
let t = e.get(F);
|
|
@@ -278,29 +289,29 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
278
289
|
};
|
|
279
290
|
return t({
|
|
280
291
|
insertQuote: (e) => {
|
|
281
|
-
p.get()?.action(U(
|
|
292
|
+
p.get()?.action(U(re.key, e)), h();
|
|
282
293
|
},
|
|
283
294
|
insertMention: (e) => {
|
|
284
|
-
p.get()?.action(U(
|
|
295
|
+
p.get()?.action(U(ne.key, e)), h();
|
|
285
296
|
},
|
|
286
297
|
focus: h
|
|
287
298
|
}), (e, t) => (m(), n(b(E)));
|
|
288
299
|
}
|
|
289
|
-
}),
|
|
300
|
+
}), Ne = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Pe = [
|
|
290
301
|
"title",
|
|
291
302
|
"aria-label",
|
|
292
303
|
"aria-expanded"
|
|
293
|
-
],
|
|
304
|
+
], Fe = ["innerHTML"], Ie = { class: "kun-editor__picker-panel" }, Le = {
|
|
294
305
|
key: 0,
|
|
295
306
|
class: "kun-editor__picker-tabs",
|
|
296
307
|
role: "tablist"
|
|
297
|
-
},
|
|
308
|
+
}, Re = ["data-active"], ze = ["data-active"], Be = { class: "kun-editor__emoji-grid" }, Ve = ["onClick"], He = {
|
|
298
309
|
key: 1,
|
|
299
310
|
class: "kun-editor__sticker-body"
|
|
300
|
-
},
|
|
311
|
+
}, Ue = { class: "kun-editor__pack-name" }, We = { class: "kun-editor__sticker-grid" }, Ge = ["title", "onClick"], Ke = ["src", "alt"], qe = {
|
|
301
312
|
key: 1,
|
|
302
313
|
class: "kun-editor__picker-hint"
|
|
303
|
-
},
|
|
314
|
+
}, Je = /* @__PURE__ */ s({
|
|
304
315
|
__name: "StickerPicker",
|
|
305
316
|
setup(n) {
|
|
306
317
|
let [, o] = k(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
|
|
@@ -336,7 +347,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
336
347
|
n.dispatch(r.tr.insertText(e, r.selection.from));
|
|
337
348
|
});
|
|
338
349
|
}, N = (e, t) => {
|
|
339
|
-
o()?.action(U(
|
|
350
|
+
o()?.action(U(ue.key, {
|
|
340
351
|
src: e,
|
|
341
352
|
title: t,
|
|
342
353
|
alt: t
|
|
@@ -356,28 +367,28 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
356
367
|
}, [a("span", {
|
|
357
368
|
class: "kun-editor__icon",
|
|
358
369
|
innerHTML: b($).smile
|
|
359
|
-
}, null, 8,
|
|
360
|
-
u ? (m(), i("div",
|
|
370
|
+
}, null, 8, Fe)], 8, Pe), w(a("div", Ie, [
|
|
371
|
+
u ? (m(), i("div", Le, [a("button", {
|
|
361
372
|
type: "button",
|
|
362
373
|
class: "kun-editor__picker-tab",
|
|
363
374
|
"data-active": C.value === "emoji",
|
|
364
375
|
onClick: n[0] ||= (e) => C.value = "emoji"
|
|
365
|
-
}, y(h.value.emoji), 9,
|
|
376
|
+
}, y(h.value.emoji), 9, Re), a("button", {
|
|
366
377
|
type: "button",
|
|
367
378
|
class: "kun-editor__picker-tab",
|
|
368
379
|
"data-active": C.value === "sticker",
|
|
369
380
|
onClick: n[1] ||= (e) => C.value = "sticker"
|
|
370
|
-
}, y(h.value.sticker), 9,
|
|
371
|
-
w(a("div",
|
|
381
|
+
}, y(h.value.sticker), 9, ze)])) : r("", !0),
|
|
382
|
+
w(a("div", Be, [(m(!0), i(e, null, _(b(Ne), (e, t) => (m(), i("button", {
|
|
372
383
|
key: t,
|
|
373
384
|
type: "button",
|
|
374
385
|
class: "kun-editor__emoji",
|
|
375
386
|
onClick: (t) => M(e)
|
|
376
|
-
}, y(e), 9,
|
|
377
|
-
u ? w((m(), i("div",
|
|
387
|
+
}, y(e), 9, Ve))), 128))], 512), [[x, !u || C.value === "emoji"]]),
|
|
388
|
+
u ? w((m(), i("div", He, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
|
|
378
389
|
key: t.name,
|
|
379
390
|
class: "kun-editor__pack"
|
|
380
|
-
}, [a("div",
|
|
391
|
+
}, [a("div", Ue, y(t.name), 1), a("div", We, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
|
|
381
392
|
key: t,
|
|
382
393
|
type: "button",
|
|
383
394
|
class: "kun-editor__sticker",
|
|
@@ -387,26 +398,29 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
387
398
|
src: e.src,
|
|
388
399
|
alt: e.name,
|
|
389
400
|
loading: "lazy"
|
|
390
|
-
}, null, 8,
|
|
401
|
+
}, null, 8, Ke)], 8, Ge))), 128))])]))), 128)) : (m(), i("div", qe, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
|
|
391
402
|
], 512), [[x, v.value]])], 512));
|
|
392
403
|
}
|
|
393
|
-
}),
|
|
404
|
+
}), Ye = {
|
|
394
405
|
class: "kun-editor__format-toolbar",
|
|
395
406
|
role: "toolbar"
|
|
396
|
-
},
|
|
407
|
+
}, Xe = ["aria-label"], Ze = {
|
|
397
408
|
value: "",
|
|
398
409
|
disabled: "",
|
|
399
410
|
selected: ""
|
|
400
|
-
},
|
|
411
|
+
}, Qe = ["value"], $e = [
|
|
401
412
|
"title",
|
|
402
413
|
"aria-label",
|
|
403
414
|
"onClick"
|
|
404
|
-
],
|
|
415
|
+
], et = ["innerHTML"], tt = ["title", "aria-label"], nt = ["innerHTML"], rt = /* @__PURE__ */ s({
|
|
405
416
|
__name: "EditorToolbar",
|
|
406
417
|
setup(n) {
|
|
407
418
|
let [, s] = k(), c = l(X), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), p = (e, t) => {
|
|
408
419
|
s()?.action(U(e, t));
|
|
409
|
-
}, h =
|
|
420
|
+
}, h = () => {
|
|
421
|
+
let e = window.prompt(f.value ? "Link URL" : "链接 URL")?.trim();
|
|
422
|
+
e && p(G.key, { href: e });
|
|
423
|
+
}, v = t(() => {
|
|
410
424
|
let e = f.value;
|
|
411
425
|
return {
|
|
412
426
|
textSize: e ? "Text size" : "文本大小",
|
|
@@ -414,6 +428,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
414
428
|
italic: e ? "Italic" : "斜体",
|
|
415
429
|
strike: e ? "Strikethrough" : "删除线",
|
|
416
430
|
code: e ? "Inline code" : "行内代码",
|
|
431
|
+
link: e ? "Link" : "链接",
|
|
417
432
|
bulletList: e ? "Bullet list" : "无序列表",
|
|
418
433
|
orderedList: e ? "Ordered list" : "有序列表",
|
|
419
434
|
quote: e ? "Blockquote" : "引用块",
|
|
@@ -422,7 +437,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
422
437
|
spoiler: e ? "Spoiler" : "隐藏文本",
|
|
423
438
|
image: e ? "Upload image" : "上传图片"
|
|
424
439
|
};
|
|
425
|
-
}),
|
|
440
|
+
}), x = t(() => {
|
|
426
441
|
let e = f.value;
|
|
427
442
|
return [
|
|
428
443
|
"正文",
|
|
@@ -436,86 +451,91 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
436
451
|
level: n,
|
|
437
452
|
label: e ? n === 0 ? "Paragraph" : `Heading ${n}` : t
|
|
438
453
|
}));
|
|
439
|
-
}),
|
|
454
|
+
}), S = (e) => {
|
|
440
455
|
let t = e.target;
|
|
441
|
-
p(
|
|
442
|
-
},
|
|
456
|
+
p(oe.key, Number(t.value)), t.selectedIndex = 0;
|
|
457
|
+
}, C = t(() => [
|
|
443
458
|
[
|
|
444
459
|
{
|
|
445
460
|
svg: $.bold,
|
|
446
|
-
title:
|
|
447
|
-
run: () => p(
|
|
461
|
+
title: v.value.bold,
|
|
462
|
+
run: () => p(fe.key)
|
|
448
463
|
},
|
|
449
464
|
{
|
|
450
465
|
svg: $.italic,
|
|
451
|
-
title:
|
|
452
|
-
run: () => p(
|
|
466
|
+
title: v.value.italic,
|
|
467
|
+
run: () => p(q.key)
|
|
453
468
|
},
|
|
454
469
|
{
|
|
455
470
|
svg: $.strike,
|
|
456
|
-
title:
|
|
457
|
-
run: () => p(
|
|
471
|
+
title: v.value.strike,
|
|
472
|
+
run: () => p(J.key)
|
|
458
473
|
},
|
|
459
474
|
{
|
|
460
475
|
svg: $.code,
|
|
461
|
-
title:
|
|
462
|
-
run: () => p(
|
|
476
|
+
title: v.value.code,
|
|
477
|
+
run: () => p(de.key)
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
svg: $.link,
|
|
481
|
+
title: v.value.link,
|
|
482
|
+
run: h
|
|
463
483
|
}
|
|
464
484
|
],
|
|
465
485
|
[
|
|
466
486
|
{
|
|
467
487
|
svg: $.bulletList,
|
|
468
|
-
title:
|
|
469
|
-
run: () => p(
|
|
488
|
+
title: v.value.bulletList,
|
|
489
|
+
run: () => p(me.key)
|
|
470
490
|
},
|
|
471
491
|
{
|
|
472
492
|
svg: $.orderedList,
|
|
473
|
-
title:
|
|
474
|
-
run: () => p(
|
|
493
|
+
title: v.value.orderedList,
|
|
494
|
+
run: () => p(he.key)
|
|
475
495
|
},
|
|
476
496
|
{
|
|
477
497
|
svg: $.quote,
|
|
478
|
-
title:
|
|
479
|
-
run: () => p(
|
|
498
|
+
title: v.value.quote,
|
|
499
|
+
run: () => p(pe.key)
|
|
480
500
|
},
|
|
481
501
|
{
|
|
482
502
|
svg: $.codeBlock,
|
|
483
|
-
title:
|
|
484
|
-
run: () => p(
|
|
503
|
+
title: v.value.codeBlock,
|
|
504
|
+
run: () => p(ce.key, "")
|
|
485
505
|
},
|
|
486
506
|
{
|
|
487
507
|
svg: $.hr,
|
|
488
|
-
title:
|
|
489
|
-
run: () => p(
|
|
508
|
+
title: v.value.hr,
|
|
509
|
+
run: () => p(le.key)
|
|
490
510
|
}
|
|
491
511
|
],
|
|
492
512
|
[{
|
|
493
513
|
svg: $.spoiler,
|
|
494
|
-
title:
|
|
495
|
-
run: () => p(
|
|
514
|
+
title: v.value.spoiler,
|
|
515
|
+
run: () => p(W.key)
|
|
496
516
|
}]
|
|
497
|
-
]),
|
|
517
|
+
]), w = g(null), T = () => w.value?.click(), E = (e) => {
|
|
498
518
|
let t = e.target, n = t.files?.[0];
|
|
499
519
|
t.value = "";
|
|
500
520
|
let r = u.value;
|
|
501
521
|
!n || !r || s()?.action((e) => {
|
|
502
|
-
|
|
522
|
+
K(e.get(F), n, {
|
|
503
523
|
uploadImage: r,
|
|
504
524
|
notify: c?.adapters.notify,
|
|
505
525
|
locale: c?.locale
|
|
506
526
|
});
|
|
507
527
|
});
|
|
508
528
|
};
|
|
509
|
-
return (t, n) => (m(), i("div",
|
|
529
|
+
return (t, n) => (m(), i("div", Ye, [
|
|
510
530
|
a("select", {
|
|
511
531
|
class: "kun-editor__heading-select",
|
|
512
|
-
"aria-label":
|
|
513
|
-
onChange:
|
|
514
|
-
}, [a("option",
|
|
532
|
+
"aria-label": v.value.textSize,
|
|
533
|
+
onChange: S
|
|
534
|
+
}, [a("option", Ze, y(v.value.textSize), 1), (m(!0), i(e, null, _(x.value, (e) => (m(), i("option", {
|
|
515
535
|
key: e.level,
|
|
516
536
|
value: e.level
|
|
517
|
-
}, y(e.label), 9,
|
|
518
|
-
(m(!0), i(e, null, _(
|
|
537
|
+
}, y(e.label), 9, Qe))), 128))], 40, Xe),
|
|
538
|
+
(m(!0), i(e, null, _(C.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
|
|
519
539
|
class: "kun-editor__toolbar-divider",
|
|
520
540
|
"aria-hidden": "true"
|
|
521
541
|
}, null, -1), (m(!0), i(e, null, _(t, (e, t) => (m(), i("button", {
|
|
@@ -528,7 +548,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
528
548
|
}, [a("span", {
|
|
529
549
|
class: "kun-editor__icon",
|
|
530
550
|
innerHTML: e.svg
|
|
531
|
-
}, null, 8,
|
|
551
|
+
}, null, 8, et)], 8, $e))), 128))], 64))), 128)),
|
|
532
552
|
u.value ? (m(), i(e, { key: 0 }, [
|
|
533
553
|
n[1] ||= a("span", {
|
|
534
554
|
class: "kun-editor__toolbar-divider",
|
|
@@ -537,29 +557,29 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
537
557
|
a("button", {
|
|
538
558
|
type: "button",
|
|
539
559
|
class: "kun-editor__tool",
|
|
540
|
-
title:
|
|
541
|
-
"aria-label":
|
|
542
|
-
onClick:
|
|
560
|
+
title: v.value.image,
|
|
561
|
+
"aria-label": v.value.image,
|
|
562
|
+
onClick: T
|
|
543
563
|
}, [a("span", {
|
|
544
564
|
class: "kun-editor__icon",
|
|
545
565
|
innerHTML: b($).image
|
|
546
|
-
}, null, 8,
|
|
566
|
+
}, null, 8, nt)], 8, tt),
|
|
547
567
|
a("input", {
|
|
548
568
|
ref_key: "fileInput",
|
|
549
|
-
ref:
|
|
569
|
+
ref: w,
|
|
550
570
|
type: "file",
|
|
551
571
|
accept: ".jpg,.jpeg,.png,.webp,.gif",
|
|
552
572
|
hidden: "",
|
|
553
|
-
onChange:
|
|
573
|
+
onChange: E
|
|
554
574
|
}, null, 544)
|
|
555
575
|
], 64)) : r("", !0),
|
|
556
576
|
d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
|
|
557
577
|
class: "kun-editor__toolbar-divider",
|
|
558
578
|
"aria-hidden": "true"
|
|
559
|
-
}, null, -1), o(
|
|
579
|
+
}, null, -1), o(Je)], 64)) : r("", !0)
|
|
560
580
|
]));
|
|
561
581
|
}
|
|
562
|
-
}),
|
|
582
|
+
}), it = /* @__PURE__ */ s({
|
|
563
583
|
__name: "ToolbarHost",
|
|
564
584
|
setup(e) {
|
|
565
585
|
let [, t] = k(), n = l(X, void 0), r = (e, n) => {
|
|
@@ -577,18 +597,21 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
577
597
|
uploadImage: (e) => {
|
|
578
598
|
let r = n?.adapters.uploadImage, i = t();
|
|
579
599
|
!r || !i || i.action((t) => {
|
|
580
|
-
|
|
600
|
+
K(t.get(F), e, {
|
|
581
601
|
uploadImage: r,
|
|
582
602
|
notify: n?.adapters.notify,
|
|
583
603
|
locale: n?.locale
|
|
584
604
|
});
|
|
585
605
|
});
|
|
586
606
|
},
|
|
607
|
+
insertLink: (e) => {
|
|
608
|
+
r(G.key, e), i();
|
|
609
|
+
},
|
|
587
610
|
insertQuote: (e) => {
|
|
588
|
-
r(
|
|
611
|
+
r(re.key, e), i();
|
|
589
612
|
},
|
|
590
613
|
insertMention: (e) => {
|
|
591
|
-
r(
|
|
614
|
+
r(ne.key, e), i();
|
|
592
615
|
},
|
|
593
616
|
focus: i,
|
|
594
617
|
get adapters() {
|
|
@@ -603,7 +626,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
603
626
|
};
|
|
604
627
|
return (e, t) => v(e.$slots, "default", d(c(a)));
|
|
605
628
|
}
|
|
606
|
-
}),
|
|
629
|
+
}), at = /* @__PURE__ */ s({
|
|
607
630
|
__name: "MarkdownSource",
|
|
608
631
|
props: {
|
|
609
632
|
modelValue: {},
|
|
@@ -611,13 +634,13 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
611
634
|
},
|
|
612
635
|
emits: ["update:modelValue"],
|
|
613
636
|
setup(e, { emit: t }) {
|
|
614
|
-
let n = e, r = t, a = g(null), o = null, s =
|
|
637
|
+
let n = e, r = t, a = g(null), o = null, s = ge.define(), c = (e) => _e.create({
|
|
615
638
|
doc: e,
|
|
616
639
|
extensions: [
|
|
617
|
-
|
|
640
|
+
ie(),
|
|
618
641
|
Y.lineWrapping,
|
|
619
|
-
|
|
620
|
-
|
|
642
|
+
ye,
|
|
643
|
+
ve(),
|
|
621
644
|
Y.editable.of(!n.readonly),
|
|
622
645
|
Y.updateListener.of((e) => {
|
|
623
646
|
e.docChanged && !e.transactions.some((e) => e.annotation(s)) && r("update:modelValue", e.state.doc.toString());
|
|
@@ -652,19 +675,19 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
652
675
|
class: "kun-editor__source"
|
|
653
676
|
}, null, 512));
|
|
654
677
|
}
|
|
655
|
-
}),
|
|
678
|
+
}), ot = ["data-mode"], st = {
|
|
656
679
|
key: 0,
|
|
657
680
|
class: "kun-editor__toolbar",
|
|
658
681
|
role: "tablist"
|
|
659
|
-
},
|
|
682
|
+
}, ct = [
|
|
660
683
|
"aria-selected",
|
|
661
684
|
"data-active",
|
|
662
685
|
"onClick"
|
|
663
|
-
],
|
|
686
|
+
], lt = ["title", "aria-label"], ut = [
|
|
664
687
|
"data-active",
|
|
665
688
|
"title",
|
|
666
689
|
"aria-pressed"
|
|
667
|
-
],
|
|
690
|
+
], dt = ["data-swap"], ft = { class: "kun-editor__wysiwyg kun-editor__pane" }, pt = /* @__PURE__ */ s({
|
|
668
691
|
__name: "KunEditor",
|
|
669
692
|
props: {
|
|
670
693
|
modelValue: {},
|
|
@@ -697,7 +720,8 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
697
720
|
"bold",
|
|
698
721
|
"italic",
|
|
699
722
|
"strike",
|
|
700
|
-
"code"
|
|
723
|
+
"code",
|
|
724
|
+
"link"
|
|
701
725
|
], E = s, O = p;
|
|
702
726
|
h(X, {
|
|
703
727
|
get adapters() {
|
|
@@ -741,7 +765,7 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
741
765
|
scrollSync: "同步滚动"
|
|
742
766
|
}), z = g(null), B = null, V = null, H = null, U = () => {
|
|
743
767
|
B?.(), B = null, V = null;
|
|
744
|
-
},
|
|
768
|
+
}, ee = () => {
|
|
745
769
|
U();
|
|
746
770
|
let e = z.value;
|
|
747
771
|
if (!e) return;
|
|
@@ -760,13 +784,13 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
760
784
|
};
|
|
761
785
|
};
|
|
762
786
|
S([j, F], ([e, t]) => {
|
|
763
|
-
U(), e === "split" && t && u(
|
|
787
|
+
U(), e === "split" && t && u(ee);
|
|
764
788
|
}), f(U);
|
|
765
|
-
let
|
|
789
|
+
let te = t(() => E.readonly || j.value === "split"), W = (e) => O("update:modelValue", e), G = g(null);
|
|
766
790
|
return l({
|
|
767
|
-
insertQuote: (e) =>
|
|
768
|
-
insertMention: (e) =>
|
|
769
|
-
focus: () =>
|
|
791
|
+
insertQuote: (e) => G.value?.insertQuote(e),
|
|
792
|
+
insertMention: (e) => G.value?.insertMention(e),
|
|
793
|
+
focus: () => G.value?.focus()
|
|
770
794
|
}), (t, l) => (m(), i("div", {
|
|
771
795
|
ref_key: "rootEl",
|
|
772
796
|
ref: z,
|
|
@@ -782,52 +806,53 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
782
806
|
swap: P,
|
|
783
807
|
scrollSync: F.value,
|
|
784
808
|
toggleScrollSync: I
|
|
785
|
-
}, () => [s.views.length > 1 ? (m(), i("div",
|
|
809
|
+
}, () => [s.views.length > 1 ? (m(), i("div", st, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
|
|
786
810
|
key: e,
|
|
787
811
|
type: "button",
|
|
788
812
|
class: "kun-editor__tab",
|
|
789
813
|
"aria-selected": j.value === e,
|
|
790
814
|
"data-active": j.value === e,
|
|
791
815
|
onClick: (t) => M(e)
|
|
792
|
-
}, y(R.value[e]), 9,
|
|
816
|
+
}, y(R.value[e]), 9, ct))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
|
|
793
817
|
type: "button",
|
|
794
818
|
class: "kun-editor__tab kun-editor__swap",
|
|
795
819
|
title: R.value.swap,
|
|
796
820
|
"aria-label": R.value.swap,
|
|
797
821
|
onClick: l[0] ||= (e) => P()
|
|
798
|
-
}, " ⇄ ", 8,
|
|
822
|
+
}, " ⇄ ", 8, lt), a("button", {
|
|
799
823
|
type: "button",
|
|
800
824
|
class: "kun-editor__tab",
|
|
801
825
|
"data-active": F.value,
|
|
802
826
|
title: R.value.scrollSync,
|
|
803
827
|
"aria-pressed": F.value,
|
|
804
828
|
onClick: l[1] ||= (e) => I()
|
|
805
|
-
}, y(R.value.scrollSync), 9,
|
|
829
|
+
}, y(R.value.scrollSync), 9, ut)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
|
|
806
830
|
default: C(() => [o(b(A), null, {
|
|
807
|
-
default: C(() => [w(a("div", null, [o(
|
|
808
|
-
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(
|
|
831
|
+
default: C(() => [w(a("div", null, [o(it, null, {
|
|
832
|
+
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(rt)])]),
|
|
809
833
|
_: 3
|
|
810
834
|
})], 512), [[x, j.value === "wysiwyg" && !s.readonly]]), a("div", {
|
|
811
835
|
class: "kun-editor__panes",
|
|
812
836
|
"data-swap": N.value
|
|
813
|
-
}, [j.value === "source" || j.value === "split" ? (m(), n(
|
|
837
|
+
}, [j.value === "source" || j.value === "split" ? (m(), n(at, {
|
|
814
838
|
key: 0,
|
|
815
839
|
class: "kun-editor__pane",
|
|
816
840
|
"model-value": s.modelValue,
|
|
817
841
|
readonly: s.readonly,
|
|
818
|
-
"onUpdate:modelValue":
|
|
819
|
-
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div",
|
|
842
|
+
"onUpdate:modelValue": W
|
|
843
|
+
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ft, [o(Me, {
|
|
820
844
|
ref_key: "inner",
|
|
821
|
-
ref:
|
|
845
|
+
ref: G,
|
|
822
846
|
"model-value": s.modelValue,
|
|
823
847
|
adapters: s.adapters,
|
|
824
848
|
features: s.features,
|
|
825
849
|
locale: s.locale,
|
|
826
|
-
readonly:
|
|
850
|
+
readonly: te.value,
|
|
827
851
|
placeholder: s.placeholder,
|
|
828
852
|
"placeholder-mode": s.placeholderMode,
|
|
853
|
+
active: j.value === "wysiwyg" && !s.readonly,
|
|
829
854
|
"selection-toolbar": k.value,
|
|
830
|
-
"onUpdate:modelValue":
|
|
855
|
+
"onUpdate:modelValue": W
|
|
831
856
|
}, null, 8, [
|
|
832
857
|
"model-value",
|
|
833
858
|
"adapters",
|
|
@@ -836,15 +861,16 @@ var X = Symbol("kun-editor-context"), ye = [
|
|
|
836
861
|
"readonly",
|
|
837
862
|
"placeholder",
|
|
838
863
|
"placeholder-mode",
|
|
864
|
+
"active",
|
|
839
865
|
"selection-toolbar"
|
|
840
|
-
])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8,
|
|
866
|
+
])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, dt)]),
|
|
841
867
|
_: 3
|
|
842
868
|
})]),
|
|
843
869
|
_: 3
|
|
844
|
-
})], 8,
|
|
870
|
+
})], 8, ot));
|
|
845
871
|
}
|
|
846
|
-
}),
|
|
847
|
-
e.component("KunEditor",
|
|
872
|
+
}), mt = { install(e) {
|
|
873
|
+
e.component("KunEditor", pt);
|
|
848
874
|
} };
|
|
849
875
|
//#endregion
|
|
850
|
-
export {
|
|
876
|
+
export { Ne as EMOJI, pt as KunEditor, mt as KunEditorPlugin };
|
package/dist/toolbar-icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar-icons.d.ts","sourceRoot":"","sources":["../src/toolbar-icons.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"toolbar-icons.d.ts","sourceRoot":"","sources":["../src/toolbar-icons.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;CAkBhB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CmdKey } from '@milkdown/kit/core';
|
|
2
2
|
import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
|
|
3
|
-
export type KunToolbarItem = 'heading' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'quote' | 'codeBlock' | 'hr' | 'spoiler' | 'image' | 'picker' | '|';
|
|
4
|
-
export type KunSelectionItem = 'bold' | 'italic' | 'strike' | 'code' | '|';
|
|
3
|
+
export type KunToolbarItem = 'heading' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'quote' | 'codeBlock' | 'hr' | 'spoiler' | 'link' | 'image' | 'picker' | '|';
|
|
4
|
+
export type KunSelectionItem = 'bold' | 'italic' | 'strike' | 'code' | 'link' | '|';
|
|
5
5
|
export interface KunEditorToolbarApi {
|
|
6
6
|
/** Run a Milkdown command (import its key from the preset/commonmark/gfm). */
|
|
7
7
|
run: <T>(key: CmdKey<T>, payload?: T) => void;
|
|
@@ -13,6 +13,14 @@ export interface KunEditorToolbarApi {
|
|
|
13
13
|
* removing it + notifying on failure. No-op without an `uploadImage` adapter.
|
|
14
14
|
*/
|
|
15
15
|
uploadImage: (file: File) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Apply a link to the selection, or (empty selection) insert linked text.
|
|
18
|
+
* `text` defaults to the href. Standard markdown `[text](href)`.
|
|
19
|
+
*/
|
|
20
|
+
insertLink: (payload: {
|
|
21
|
+
href: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
}) => void;
|
|
16
24
|
/** Insert a reference atom at the cursor (requires the quote feature). */
|
|
17
25
|
insertQuote: (payload: {
|
|
18
26
|
refId: string;
|
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;AAK5B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,GACP,WAAW,GACX,IAAI,GACJ,SAAS,GACT,OAAO,GACP,QAAQ,GACR,GAAG,CAAA;AAIP,MAAM,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,C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version": "0.
|
|
3
|
+
"version": "0.26.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.26.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.26.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "vite build && vue-tsc -p tsconfig.build.json",
|