@kungal/editor-vue 0.25.2 → 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 CHANGED
@@ -1,5 +1,37 @@
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
+
3
35
  ## 0.25.2
4
36
 
5
37
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAycA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
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":"AAuWA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AASjE,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,OAAO,CAAA;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,KAAK,GAAG,OAAO,CAAA;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;IAClB;oEACgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;OA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,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AA2RA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
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":"AAyFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuFhD,QAAA,IAAI,OAAO;oCAxFX,CArDQ;;;;;;;;;;;;;;;CA6Ic,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"}
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 W } from "@milkdown/kit/utils";
9
- import { createKunEditorPlugins as G, insertKunSpoilerCommand as K, insertMentionCommand as q, insertQuoteCommand as J, kunCM as ee, mentionId as te, setHeadingCommand as ne, startImageUpload as re } from "@kungal/editor-core/preset";
10
- import { TextSelection as ie } from "@milkdown/kit/prose/state";
11
- import { createCodeBlockCommand as ae, insertHrCommand as oe, insertImageCommand as se, toggleEmphasisCommand as ce, toggleInlineCodeCommand as le, toggleStrongCommand as ue, wrapInBlockquoteCommand as de, wrapInBulletListCommand as fe, wrapInOrderedListCommand as pe } from "@milkdown/kit/preset/commonmark";
12
- import { toggleStrikethroughCommand as me } from "@milkdown/kit/preset/gfm";
13
- import { Annotation as he, EditorState as ge } from "@codemirror/state";
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 _e } from "@codemirror/lang-markdown";
16
- import { basicSetup as ve } from "codemirror";
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"), ye = [
18
+ var X = Symbol("kun-editor-context"), be = [
19
19
  "data-active",
20
20
  "onMousedown",
21
21
  "onMouseenter"
22
- ], be = ["src", "alt"], xe = {
22
+ ], xe = ["src", "alt"], Se = {
23
23
  key: 1,
24
24
  class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
25
- }, Se = { class: "kun-mention-dropdown__name" }, Ce = {
25
+ }, Ce = { class: "kun-mention-dropdown__name" }, we = {
26
26
  key: 1,
27
27
  class: "kun-mention-dropdown__hint"
28
- }, we = {
28
+ }, Te = {
29
29
  key: 2,
30
30
  class: "kun-mention-dropdown__hint"
31
- }, Te = {
31
+ }, Ee = {
32
32
  key: 3,
33
33
  class: "kun-mention-dropdown__hint"
34
- }, Ee = /* @__PURE__ */ s({
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[te];
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(ie.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
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, be)) : (m(), i("span", xe, y(e.name.charAt(0)), 1)), a("span", Se, y(e.name), 1)], 40, ye))), 128)) : D.value ? (m(), i("div", Ce, y(u.value.searching), 1)) : C.value ? (m(), i("div", we, y(u.value.empty), 1)) : (m(), i("div", Te, y(u.value.prompt), 1))], 512));
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
- }, De = {
160
+ }, Oe = {
160
161
  key: 0,
161
162
  class: "kun-editor__toolbar-divider",
162
163
  "aria-hidden": "true"
163
- }, Oe = [
164
+ }, ke = [
164
165
  "title",
165
166
  "aria-label",
166
167
  "onMousedown"
167
- ], ke = ["innerHTML"], Ae = /* @__PURE__ */ s({
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 = t(() => {
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(ue.key)
182
+ run: () => v(fe.key)
179
183
  },
180
184
  italic: {
181
185
  svg: $.italic,
182
186
  title: e ? "Italic" : "斜体",
183
- run: () => v(ce.key)
187
+ run: () => v(q.key)
184
188
  },
185
189
  strike: {
186
190
  svg: $.strike,
187
191
  title: e ? "Strikethrough" : "删除线",
188
- run: () => v(me.key)
192
+ run: () => v(J.key)
189
193
  },
190
194
  code: {
191
195
  svg: $.code,
192
196
  title: e ? "Inline code" : "行内代码",
193
- run: () => v(le.key)
197
+ run: () => v(de.key)
198
+ },
199
+ link: {
200
+ svg: $.link,
201
+ title: e ? "Link" : "链接",
202
+ run: y
194
203
  }
195
204
  };
196
- }), b = t(() => {
197
- let e = y.value, t = (c?.selectionToolbarItems ?? [
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, _(b.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", De)) : (m(), i("button", {
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, ke)], 40, Oe))], 64))), 128))], 512));
244
+ }, null, 8, Ae)], 40, ke))], 64))), 128))], 512));
235
245
  }
236
- }), je = /* @__PURE__ */ s({
246
+ }), Me = /* @__PURE__ */ s({
237
247
  __name: "MilkdownEditor",
238
248
  props: {
239
249
  modelValue: {},
@@ -255,8 +265,8 @@ var X = Symbol("kun-editor-context"), ye = [
255
265
  }), t.update(I, (e) => ({
256
266
  ...e,
257
267
  editable: () => !i.readonly
258
- })), u && t.set(l.key, { view: c({ component: Ee }) }), f && t.set(d.key, { view: c({ component: Ae }) });
259
- }).use(G(i.adapters, i.features, {
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, {
260
270
  locale: i.locale,
261
271
  placeholder: i.placeholder,
262
272
  placeholderMode: i.placeholderMode
@@ -267,7 +277,7 @@ var X = Symbol("kun-editor-context"), ye = [
267
277
  if (e === o) return;
268
278
  o = e;
269
279
  let t = p.get();
270
- t && (s = !0, t.action(W(e)), s = !1);
280
+ t && (s = !0, t.action(ee(e)), s = !1);
271
281
  }), S(() => i.readonly, () => {
272
282
  p.get()?.action((e) => {
273
283
  let t = e.get(F);
@@ -279,29 +289,29 @@ var X = Symbol("kun-editor-context"), ye = [
279
289
  };
280
290
  return t({
281
291
  insertQuote: (e) => {
282
- p.get()?.action(U(J.key, e)), h();
292
+ p.get()?.action(U(re.key, e)), h();
283
293
  },
284
294
  insertMention: (e) => {
285
- p.get()?.action(U(q.key, e)), h();
295
+ p.get()?.action(U(ne.key, e)), h();
286
296
  },
287
297
  focus: h
288
298
  }), (e, t) => (m(), n(b(E)));
289
299
  }
290
- }), Me = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ne = [
300
+ }), Ne = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Pe = [
291
301
  "title",
292
302
  "aria-label",
293
303
  "aria-expanded"
294
- ], Pe = ["innerHTML"], Fe = { class: "kun-editor__picker-panel" }, Ie = {
304
+ ], Fe = ["innerHTML"], Ie = { class: "kun-editor__picker-panel" }, Le = {
295
305
  key: 0,
296
306
  class: "kun-editor__picker-tabs",
297
307
  role: "tablist"
298
- }, Le = ["data-active"], Re = ["data-active"], ze = { class: "kun-editor__emoji-grid" }, Be = ["onClick"], Ve = {
308
+ }, Re = ["data-active"], ze = ["data-active"], Be = { class: "kun-editor__emoji-grid" }, Ve = ["onClick"], He = {
299
309
  key: 1,
300
310
  class: "kun-editor__sticker-body"
301
- }, He = { class: "kun-editor__pack-name" }, Ue = { class: "kun-editor__sticker-grid" }, We = ["title", "onClick"], Ge = ["src", "alt"], Ke = {
311
+ }, Ue = { class: "kun-editor__pack-name" }, We = { class: "kun-editor__sticker-grid" }, Ge = ["title", "onClick"], Ke = ["src", "alt"], qe = {
302
312
  key: 1,
303
313
  class: "kun-editor__picker-hint"
304
- }, qe = /* @__PURE__ */ s({
314
+ }, Je = /* @__PURE__ */ s({
305
315
  __name: "StickerPicker",
306
316
  setup(n) {
307
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 ? {
@@ -337,7 +347,7 @@ var X = Symbol("kun-editor-context"), ye = [
337
347
  n.dispatch(r.tr.insertText(e, r.selection.from));
338
348
  });
339
349
  }, N = (e, t) => {
340
- o()?.action(U(se.key, {
350
+ o()?.action(U(ue.key, {
341
351
  src: e,
342
352
  title: t,
343
353
  alt: t
@@ -357,28 +367,28 @@ var X = Symbol("kun-editor-context"), ye = [
357
367
  }, [a("span", {
358
368
  class: "kun-editor__icon",
359
369
  innerHTML: b($).smile
360
- }, null, 8, Pe)], 8, Ne), w(a("div", Fe, [
361
- u ? (m(), i("div", Ie, [a("button", {
370
+ }, null, 8, Fe)], 8, Pe), w(a("div", Ie, [
371
+ u ? (m(), i("div", Le, [a("button", {
362
372
  type: "button",
363
373
  class: "kun-editor__picker-tab",
364
374
  "data-active": C.value === "emoji",
365
375
  onClick: n[0] ||= (e) => C.value = "emoji"
366
- }, y(h.value.emoji), 9, Le), a("button", {
376
+ }, y(h.value.emoji), 9, Re), a("button", {
367
377
  type: "button",
368
378
  class: "kun-editor__picker-tab",
369
379
  "data-active": C.value === "sticker",
370
380
  onClick: n[1] ||= (e) => C.value = "sticker"
371
- }, y(h.value.sticker), 9, Re)])) : r("", !0),
372
- w(a("div", ze, [(m(!0), i(e, null, _(b(Me), (e, t) => (m(), i("button", {
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", {
373
383
  key: t,
374
384
  type: "button",
375
385
  class: "kun-editor__emoji",
376
386
  onClick: (t) => M(e)
377
- }, y(e), 9, Be))), 128))], 512), [[x, !u || C.value === "emoji"]]),
378
- u ? w((m(), i("div", Ve, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (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", {
379
389
  key: t.name,
380
390
  class: "kun-editor__pack"
381
- }, [a("div", He, y(t.name), 1), a("div", Ue, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
391
+ }, [a("div", Ue, y(t.name), 1), a("div", We, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
382
392
  key: t,
383
393
  type: "button",
384
394
  class: "kun-editor__sticker",
@@ -388,26 +398,29 @@ var X = Symbol("kun-editor-context"), ye = [
388
398
  src: e.src,
389
399
  alt: e.name,
390
400
  loading: "lazy"
391
- }, null, 8, Ge)], 8, We))), 128))])]))), 128)) : (m(), i("div", Ke, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
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)
392
402
  ], 512), [[x, v.value]])], 512));
393
403
  }
394
- }), Je = {
404
+ }), Ye = {
395
405
  class: "kun-editor__format-toolbar",
396
406
  role: "toolbar"
397
- }, Ye = ["aria-label"], Xe = {
407
+ }, Xe = ["aria-label"], Ze = {
398
408
  value: "",
399
409
  disabled: "",
400
410
  selected: ""
401
- }, Ze = ["value"], Qe = [
411
+ }, Qe = ["value"], $e = [
402
412
  "title",
403
413
  "aria-label",
404
414
  "onClick"
405
- ], $e = ["innerHTML"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = /* @__PURE__ */ s({
415
+ ], et = ["innerHTML"], tt = ["title", "aria-label"], nt = ["innerHTML"], rt = /* @__PURE__ */ s({
406
416
  __name: "EditorToolbar",
407
417
  setup(n) {
408
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) => {
409
419
  s()?.action(U(e, t));
410
- }, h = t(() => {
420
+ }, h = () => {
421
+ let e = window.prompt(f.value ? "Link URL" : "链接 URL")?.trim();
422
+ e && p(G.key, { href: e });
423
+ }, v = t(() => {
411
424
  let e = f.value;
412
425
  return {
413
426
  textSize: e ? "Text size" : "文本大小",
@@ -415,6 +428,7 @@ var X = Symbol("kun-editor-context"), ye = [
415
428
  italic: e ? "Italic" : "斜体",
416
429
  strike: e ? "Strikethrough" : "删除线",
417
430
  code: e ? "Inline code" : "行内代码",
431
+ link: e ? "Link" : "链接",
418
432
  bulletList: e ? "Bullet list" : "无序列表",
419
433
  orderedList: e ? "Ordered list" : "有序列表",
420
434
  quote: e ? "Blockquote" : "引用块",
@@ -423,7 +437,7 @@ var X = Symbol("kun-editor-context"), ye = [
423
437
  spoiler: e ? "Spoiler" : "隐藏文本",
424
438
  image: e ? "Upload image" : "上传图片"
425
439
  };
426
- }), v = t(() => {
440
+ }), x = t(() => {
427
441
  let e = f.value;
428
442
  return [
429
443
  "正文",
@@ -437,86 +451,91 @@ var X = Symbol("kun-editor-context"), ye = [
437
451
  level: n,
438
452
  label: e ? n === 0 ? "Paragraph" : `Heading ${n}` : t
439
453
  }));
440
- }), x = (e) => {
454
+ }), S = (e) => {
441
455
  let t = e.target;
442
- p(ne.key, Number(t.value)), t.selectedIndex = 0;
443
- }, S = t(() => [
456
+ p(oe.key, Number(t.value)), t.selectedIndex = 0;
457
+ }, C = t(() => [
444
458
  [
445
459
  {
446
460
  svg: $.bold,
447
- title: h.value.bold,
448
- run: () => p(ue.key)
461
+ title: v.value.bold,
462
+ run: () => p(fe.key)
449
463
  },
450
464
  {
451
465
  svg: $.italic,
452
- title: h.value.italic,
453
- run: () => p(ce.key)
466
+ title: v.value.italic,
467
+ run: () => p(q.key)
454
468
  },
455
469
  {
456
470
  svg: $.strike,
457
- title: h.value.strike,
458
- run: () => p(me.key)
471
+ title: v.value.strike,
472
+ run: () => p(J.key)
459
473
  },
460
474
  {
461
475
  svg: $.code,
462
- title: h.value.code,
463
- run: () => p(le.key)
476
+ title: v.value.code,
477
+ run: () => p(de.key)
478
+ },
479
+ {
480
+ svg: $.link,
481
+ title: v.value.link,
482
+ run: h
464
483
  }
465
484
  ],
466
485
  [
467
486
  {
468
487
  svg: $.bulletList,
469
- title: h.value.bulletList,
470
- run: () => p(fe.key)
488
+ title: v.value.bulletList,
489
+ run: () => p(me.key)
471
490
  },
472
491
  {
473
492
  svg: $.orderedList,
474
- title: h.value.orderedList,
475
- run: () => p(pe.key)
493
+ title: v.value.orderedList,
494
+ run: () => p(he.key)
476
495
  },
477
496
  {
478
497
  svg: $.quote,
479
- title: h.value.quote,
480
- run: () => p(de.key)
498
+ title: v.value.quote,
499
+ run: () => p(pe.key)
481
500
  },
482
501
  {
483
502
  svg: $.codeBlock,
484
- title: h.value.codeBlock,
485
- run: () => p(ae.key, "")
503
+ title: v.value.codeBlock,
504
+ run: () => p(ce.key, "")
486
505
  },
487
506
  {
488
507
  svg: $.hr,
489
- title: h.value.hr,
490
- run: () => p(oe.key)
508
+ title: v.value.hr,
509
+ run: () => p(le.key)
491
510
  }
492
511
  ],
493
512
  [{
494
513
  svg: $.spoiler,
495
- title: h.value.spoiler,
496
- run: () => p(K.key)
514
+ title: v.value.spoiler,
515
+ run: () => p(W.key)
497
516
  }]
498
- ]), C = g(null), w = () => C.value?.click(), T = (e) => {
517
+ ]), w = g(null), T = () => w.value?.click(), E = (e) => {
499
518
  let t = e.target, n = t.files?.[0];
500
519
  t.value = "";
501
520
  let r = u.value;
502
521
  !n || !r || s()?.action((e) => {
503
- re(e.get(F), n, {
522
+ K(e.get(F), n, {
504
523
  uploadImage: r,
505
524
  notify: c?.adapters.notify,
506
525
  locale: c?.locale
507
526
  });
508
527
  });
509
528
  };
510
- return (t, n) => (m(), i("div", Je, [
529
+ return (t, n) => (m(), i("div", Ye, [
511
530
  a("select", {
512
531
  class: "kun-editor__heading-select",
513
- "aria-label": h.value.textSize,
514
- onChange: x
515
- }, [a("option", Xe, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("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", {
516
535
  key: e.level,
517
536
  value: e.level
518
- }, y(e.label), 9, Ze))), 128))], 40, Ye),
519
- (m(!0), i(e, null, _(S.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
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", {
520
539
  class: "kun-editor__toolbar-divider",
521
540
  "aria-hidden": "true"
522
541
  }, null, -1), (m(!0), i(e, null, _(t, (e, t) => (m(), i("button", {
@@ -529,7 +548,7 @@ var X = Symbol("kun-editor-context"), ye = [
529
548
  }, [a("span", {
530
549
  class: "kun-editor__icon",
531
550
  innerHTML: e.svg
532
- }, null, 8, $e)], 8, Qe))), 128))], 64))), 128)),
551
+ }, null, 8, et)], 8, $e))), 128))], 64))), 128)),
533
552
  u.value ? (m(), i(e, { key: 0 }, [
534
553
  n[1] ||= a("span", {
535
554
  class: "kun-editor__toolbar-divider",
@@ -538,29 +557,29 @@ var X = Symbol("kun-editor-context"), ye = [
538
557
  a("button", {
539
558
  type: "button",
540
559
  class: "kun-editor__tool",
541
- title: h.value.image,
542
- "aria-label": h.value.image,
543
- onClick: w
560
+ title: v.value.image,
561
+ "aria-label": v.value.image,
562
+ onClick: T
544
563
  }, [a("span", {
545
564
  class: "kun-editor__icon",
546
565
  innerHTML: b($).image
547
- }, null, 8, tt)], 8, et),
566
+ }, null, 8, nt)], 8, tt),
548
567
  a("input", {
549
568
  ref_key: "fileInput",
550
- ref: C,
569
+ ref: w,
551
570
  type: "file",
552
571
  accept: ".jpg,.jpeg,.png,.webp,.gif",
553
572
  hidden: "",
554
- onChange: T
573
+ onChange: E
555
574
  }, null, 544)
556
575
  ], 64)) : r("", !0),
557
576
  d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
558
577
  class: "kun-editor__toolbar-divider",
559
578
  "aria-hidden": "true"
560
- }, null, -1), o(qe)], 64)) : r("", !0)
579
+ }, null, -1), o(Je)], 64)) : r("", !0)
561
580
  ]));
562
581
  }
563
- }), rt = /* @__PURE__ */ s({
582
+ }), it = /* @__PURE__ */ s({
564
583
  __name: "ToolbarHost",
565
584
  setup(e) {
566
585
  let [, t] = k(), n = l(X, void 0), r = (e, n) => {
@@ -578,18 +597,21 @@ var X = Symbol("kun-editor-context"), ye = [
578
597
  uploadImage: (e) => {
579
598
  let r = n?.adapters.uploadImage, i = t();
580
599
  !r || !i || i.action((t) => {
581
- re(t.get(F), e, {
600
+ K(t.get(F), e, {
582
601
  uploadImage: r,
583
602
  notify: n?.adapters.notify,
584
603
  locale: n?.locale
585
604
  });
586
605
  });
587
606
  },
607
+ insertLink: (e) => {
608
+ r(G.key, e), i();
609
+ },
588
610
  insertQuote: (e) => {
589
- r(J.key, e), i();
611
+ r(re.key, e), i();
590
612
  },
591
613
  insertMention: (e) => {
592
- r(q.key, e), i();
614
+ r(ne.key, e), i();
593
615
  },
594
616
  focus: i,
595
617
  get adapters() {
@@ -604,7 +626,7 @@ var X = Symbol("kun-editor-context"), ye = [
604
626
  };
605
627
  return (e, t) => v(e.$slots, "default", d(c(a)));
606
628
  }
607
- }), it = /* @__PURE__ */ s({
629
+ }), at = /* @__PURE__ */ s({
608
630
  __name: "MarkdownSource",
609
631
  props: {
610
632
  modelValue: {},
@@ -612,13 +634,13 @@ var X = Symbol("kun-editor-context"), ye = [
612
634
  },
613
635
  emits: ["update:modelValue"],
614
636
  setup(e, { emit: t }) {
615
- let n = e, r = t, a = g(null), o = null, s = he.define(), c = (e) => ge.create({
637
+ let n = e, r = t, a = g(null), o = null, s = ge.define(), c = (e) => _e.create({
616
638
  doc: e,
617
639
  extensions: [
618
- ee(),
640
+ ie(),
619
641
  Y.lineWrapping,
620
- ve,
621
- _e(),
642
+ ye,
643
+ ve(),
622
644
  Y.editable.of(!n.readonly),
623
645
  Y.updateListener.of((e) => {
624
646
  e.docChanged && !e.transactions.some((e) => e.annotation(s)) && r("update:modelValue", e.state.doc.toString());
@@ -653,19 +675,19 @@ var X = Symbol("kun-editor-context"), ye = [
653
675
  class: "kun-editor__source"
654
676
  }, null, 512));
655
677
  }
656
- }), at = ["data-mode"], ot = {
678
+ }), ot = ["data-mode"], st = {
657
679
  key: 0,
658
680
  class: "kun-editor__toolbar",
659
681
  role: "tablist"
660
- }, st = [
682
+ }, ct = [
661
683
  "aria-selected",
662
684
  "data-active",
663
685
  "onClick"
664
- ], ct = ["title", "aria-label"], lt = [
686
+ ], lt = ["title", "aria-label"], ut = [
665
687
  "data-active",
666
688
  "title",
667
689
  "aria-pressed"
668
- ], ut = ["data-swap"], dt = { class: "kun-editor__wysiwyg kun-editor__pane" }, ft = /* @__PURE__ */ s({
690
+ ], dt = ["data-swap"], ft = { class: "kun-editor__wysiwyg kun-editor__pane" }, pt = /* @__PURE__ */ s({
669
691
  __name: "KunEditor",
670
692
  props: {
671
693
  modelValue: {},
@@ -698,7 +720,8 @@ var X = Symbol("kun-editor-context"), ye = [
698
720
  "bold",
699
721
  "italic",
700
722
  "strike",
701
- "code"
723
+ "code",
724
+ "link"
702
725
  ], E = s, O = p;
703
726
  h(X, {
704
727
  get adapters() {
@@ -742,7 +765,7 @@ var X = Symbol("kun-editor-context"), ye = [
742
765
  scrollSync: "同步滚动"
743
766
  }), z = g(null), B = null, V = null, H = null, U = () => {
744
767
  B?.(), B = null, V = null;
745
- }, W = () => {
768
+ }, ee = () => {
746
769
  U();
747
770
  let e = z.value;
748
771
  if (!e) return;
@@ -761,13 +784,13 @@ var X = Symbol("kun-editor-context"), ye = [
761
784
  };
762
785
  };
763
786
  S([j, F], ([e, t]) => {
764
- U(), e === "split" && t && u(W);
787
+ U(), e === "split" && t && u(ee);
765
788
  }), f(U);
766
- let G = t(() => E.readonly || j.value === "split"), K = (e) => O("update:modelValue", e), q = g(null);
789
+ let te = t(() => E.readonly || j.value === "split"), W = (e) => O("update:modelValue", e), G = g(null);
767
790
  return l({
768
- insertQuote: (e) => q.value?.insertQuote(e),
769
- insertMention: (e) => q.value?.insertMention(e),
770
- focus: () => q.value?.focus()
791
+ insertQuote: (e) => G.value?.insertQuote(e),
792
+ insertMention: (e) => G.value?.insertMention(e),
793
+ focus: () => G.value?.focus()
771
794
  }), (t, l) => (m(), i("div", {
772
795
  ref_key: "rootEl",
773
796
  ref: z,
@@ -783,53 +806,53 @@ var X = Symbol("kun-editor-context"), ye = [
783
806
  swap: P,
784
807
  scrollSync: F.value,
785
808
  toggleScrollSync: I
786
- }, () => [s.views.length > 1 ? (m(), i("div", ot, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
809
+ }, () => [s.views.length > 1 ? (m(), i("div", st, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
787
810
  key: e,
788
811
  type: "button",
789
812
  class: "kun-editor__tab",
790
813
  "aria-selected": j.value === e,
791
814
  "data-active": j.value === e,
792
815
  onClick: (t) => M(e)
793
- }, y(R.value[e]), 9, st))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
816
+ }, y(R.value[e]), 9, ct))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
794
817
  type: "button",
795
818
  class: "kun-editor__tab kun-editor__swap",
796
819
  title: R.value.swap,
797
820
  "aria-label": R.value.swap,
798
821
  onClick: l[0] ||= (e) => P()
799
- }, " ⇄ ", 8, ct), a("button", {
822
+ }, " ⇄ ", 8, lt), a("button", {
800
823
  type: "button",
801
824
  class: "kun-editor__tab",
802
825
  "data-active": F.value,
803
826
  title: R.value.scrollSync,
804
827
  "aria-pressed": F.value,
805
828
  onClick: l[1] ||= (e) => I()
806
- }, y(R.value.scrollSync), 9, lt)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
829
+ }, y(R.value.scrollSync), 9, ut)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
807
830
  default: C(() => [o(b(A), null, {
808
- default: C(() => [w(a("div", null, [o(rt, null, {
809
- default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(nt)])]),
831
+ default: C(() => [w(a("div", null, [o(it, null, {
832
+ default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(rt)])]),
810
833
  _: 3
811
834
  })], 512), [[x, j.value === "wysiwyg" && !s.readonly]]), a("div", {
812
835
  class: "kun-editor__panes",
813
836
  "data-swap": N.value
814
- }, [j.value === "source" || j.value === "split" ? (m(), n(it, {
837
+ }, [j.value === "source" || j.value === "split" ? (m(), n(at, {
815
838
  key: 0,
816
839
  class: "kun-editor__pane",
817
840
  "model-value": s.modelValue,
818
841
  readonly: s.readonly,
819
- "onUpdate:modelValue": K
820
- }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", dt, [o(je, {
842
+ "onUpdate:modelValue": W
843
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ft, [o(Me, {
821
844
  ref_key: "inner",
822
- ref: q,
845
+ ref: G,
823
846
  "model-value": s.modelValue,
824
847
  adapters: s.adapters,
825
848
  features: s.features,
826
849
  locale: s.locale,
827
- readonly: G.value,
850
+ readonly: te.value,
828
851
  placeholder: s.placeholder,
829
852
  "placeholder-mode": s.placeholderMode,
830
853
  active: j.value === "wysiwyg" && !s.readonly,
831
854
  "selection-toolbar": k.value,
832
- "onUpdate:modelValue": K
855
+ "onUpdate:modelValue": W
833
856
  }, null, 8, [
834
857
  "model-value",
835
858
  "adapters",
@@ -840,14 +863,14 @@ var X = Symbol("kun-editor-context"), ye = [
840
863
  "placeholder-mode",
841
864
  "active",
842
865
  "selection-toolbar"
843
- ])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, ut)]),
866
+ ])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, dt)]),
844
867
  _: 3
845
868
  })]),
846
869
  _: 3
847
- })], 8, at));
870
+ })], 8, ot));
848
871
  }
849
- }), pt = { install(e) {
850
- e.component("KunEditor", ft);
872
+ }), mt = { install(e) {
873
+ e.component("KunEditor", pt);
851
874
  } };
852
875
  //#endregion
853
- export { Me as EMOJI, ft as KunEditor, pt as KunEditorPlugin };
876
+ export { Ne as EMOJI, pt as KunEditor, mt as KunEditorPlugin };
@@ -13,6 +13,7 @@ export declare const TOOLBAR_ICONS: {
13
13
  readonly hr: string;
14
14
  readonly image: string;
15
15
  readonly spoiler: string;
16
+ readonly link: string;
16
17
  readonly latex: string;
17
18
  readonly smile: string;
18
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar-icons.d.ts","sourceRoot":"","sources":["../src/toolbar-icons.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAiBhB,CAAA"}
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;
@@ -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,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,GAAG,CAAA;AAM1E,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,EA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,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.25.2",
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.25.2"
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.25.2"
83
+ "@kungal/editor-core": "0.26.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",