@kungal/editor-vue 0.33.0 → 0.35.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,88 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.35.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c90e1b9: fix(link): give a typed URL the scheme it needs, in ONE place
8
+
9
+ Typing `www.kungal.com/topic/1` into any link input produced a **relative**
10
+ href: with no scheme the browser resolves it against the current page, so the
11
+ link went to `<origin>/<current/path>/www.kungal.com/topic/1` — dead, and dead
12
+ in a way the author can't see while writing.
13
+
14
+ `insertLinkCommand` now normalizes its `href`, and since every link entry point
15
+ (the selection bubble's input, the headless toolbar's URL panel, the KunUI
16
+ toolbar's popover, and a host's own `linkPrompt` adapter) dispatches that one
17
+ command, all of them are fixed at once — a host must not re-implement this.
18
+
19
+ - `www.kungal.com/topic/1` → `https://www.kungal.com/topic/1` (https, not http:
20
+ an http-only site redirects, an https-only site doesn't). Ports, queries,
21
+ fragments and bare IPv4 hosts included.
22
+ - `me@kungal.com` → `mailto:me@kungal.com` (`https://` would read the address as
23
+ userinfo and go nowhere).
24
+ - Untouched: anything with a scheme — `kungal-user:` / `kungal-reply:` included
25
+ — and anything explicitly relative (`/x`, `./x`, `../x`, `#x`, `?x`, `//host`).
26
+ - The one ambiguous input is a lone dotted word: `readme.md` looks exactly like
27
+ a hostname (`.md` is a TLD), so it gets `https://`. Write `./readme.md` when a
28
+ relative file is what you mean.
29
+
30
+ The rule is also exported as `normalizeLinkHref(input)` from the light,
31
+ zero-dependency `@kungal/editor-core` entry, so a server can normalize legacy
32
+ content with the exact same logic.
33
+
34
+ Along with it, the three URL inputs move from `type="url"` to `type="text"` +
35
+ `inputmode="url"`. Native URL validation rejects exactly the schemeless input
36
+ this change exists to accept — in the KunUI toolbar's popover, which submits a
37
+ real `<form>`, pressing Enter on `www.kungal.com/topic/1` did nothing at all.
38
+ The mobile keyboard hint is kept.
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [c90e1b9]
43
+ - @kungal/editor-core@0.35.0
44
+
45
+ ## 0.34.0
46
+
47
+ ### Minor Changes
48
+
49
+ - ab7fbc2: No native `prompt` left: the headless toolbar gets a link URL panel too
50
+
51
+ 0.33.0 gave the selection bubble an inline URL input; the fixed (headless)
52
+ toolbar still popped `window.prompt`. It now opens a small panel under the link
53
+ button — Enter applies, Esc cancels, clicking outside closes, and the editor
54
+ gets focus back. Same behaviour as the bubble otherwise: an existing href is
55
+ prefilled (and selected), and with nothing selected the URL is inserted as
56
+ linked text. A panel rather than an in-place swap because a fixed toolbar row
57
+ that rearranges itself is jarring; the bubble is already a floating layer, so
58
+ there the swap is the right shape.
59
+
60
+ **Breaking (CSS hook, one version old):** `.kun-editor__bubble-input` →
61
+ `.kun-editor__link-input`. Both entry points render the same input, so the hook
62
+ is named after the thing, not the place. Hosts importing
63
+ `@kungal/editor-nuxt/editor.css` need no change; a copied stylesheet wants the
64
+ rename plus the two new hooks:
65
+
66
+ ```css
67
+ .kun-editor__link {
68
+ position: relative;
69
+ } /* structural */
70
+ .kun-editor__link-panel {
71
+ position: absolute;
72
+ } /* structural */
73
+ .kun-editor__link-input {
74
+ /* shared by the toolbar panel and the bubble */
75
+ }
76
+ ```
77
+
78
+ `linkPrompt` keeps taking precedence over all three built-in entries (bubble
79
+ input, toolbar panel, KunUI popover), so a host modal is still one override.
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [ab7fbc2]
84
+ - @kungal/editor-core@0.34.0
85
+
3
86
  ## 0.33.0
4
87
 
5
88
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAsgBA,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":"AAifA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,4 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ //# sourceMappingURL=LinkInput.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkInput.vue.d.ts","sourceRoot":"","sources":["../../src/components/LinkInput.vue"],"names":[],"mappings":"AA8UA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AA0lBA,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":"AAukBA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
package/dist/index.js CHANGED
@@ -2,46 +2,46 @@ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r
2
2
  import { Milkdown as k, MilkdownProvider as A, useEditor as j, useInstance as M } from "@milkdown/vue";
3
3
  import { ProsemirrorAdapterProvider as N, usePluginViewContext as ee, usePluginViewFactory as P } from "@prosemirror-adapter/vue";
4
4
  import { parseHeadings as F, parseHeadings as I } from "@kungal/editor-core";
5
- import { Editor as L, defaultValueCtx as te, editorViewCtx as R, editorViewOptionsCtx as ne, rootCtx as z } from "@milkdown/kit/core";
6
- import { listenerCtx as re } from "@milkdown/kit/plugin/listener";
7
- import { SlashProvider as ie, slashFactory as B } from "@milkdown/kit/plugin/slash";
8
- import { TooltipProvider as ae, tooltipFactory as V } from "@milkdown/kit/plugin/tooltip";
9
- import { $prose as H, callCommand as U, replaceAll as W } from "@milkdown/kit/utils";
10
- import { Plugin as oe, PluginKey as se, TextSelection as G } from "@milkdown/kit/prose/state";
11
- import { createCodeBlockCommand as K, emphasisSchema as ce, inlineCodeSchema as le, insertHrCommand as ue, insertImageCommand as de, linkSchema as fe, strongSchema as pe, toggleEmphasisCommand as me, toggleInlineCodeCommand as he, toggleStrongCommand as ge, wrapInBlockquoteCommand as _e, wrapInBulletListCommand as ve, wrapInOrderedListCommand as ye } from "@milkdown/kit/preset/commonmark";
12
- import { createKunEditorPlugins as be, insertKunSpoilerCommand as xe, insertLinkCommand as q, insertMentionCommand as Se, insertQuoteCommand as Ce, kunCM as we, mentionId as Te, setHeadingCommand as Ee, startImageUpload as De } from "@kungal/editor-core/preset";
13
- import { strikethroughSchema as Oe, toggleStrikethroughCommand as ke } from "@milkdown/kit/preset/gfm";
14
- import { Annotation as Ae, EditorState as je } from "@codemirror/state";
15
- import { EditorView as J } from "@codemirror/view";
16
- import { markdown as Me } from "@codemirror/lang-markdown";
17
- import { basicSetup as Ne } from "codemirror";
5
+ import { Editor as L, defaultValueCtx as te, editorViewCtx as R, editorViewOptionsCtx as z, rootCtx as B } from "@milkdown/kit/core";
6
+ import { listenerCtx as ne } from "@milkdown/kit/plugin/listener";
7
+ import { SlashProvider as re, slashFactory as V } from "@milkdown/kit/plugin/slash";
8
+ import { TooltipProvider as ie, tooltipFactory as H } from "@milkdown/kit/plugin/tooltip";
9
+ import { $prose as U, callCommand as W, replaceAll as G } from "@milkdown/kit/utils";
10
+ import { Plugin as ae, PluginKey as oe, TextSelection as K } from "@milkdown/kit/prose/state";
11
+ import { createCodeBlockCommand as q, emphasisSchema as se, inlineCodeSchema as ce, insertHrCommand as le, insertImageCommand as ue, linkSchema as de, strongSchema as fe, toggleEmphasisCommand as pe, toggleInlineCodeCommand as me, toggleStrongCommand as he, wrapInBlockquoteCommand as ge, wrapInBulletListCommand as _e, wrapInOrderedListCommand as ve } from "@milkdown/kit/preset/commonmark";
12
+ import { createKunEditorPlugins as ye, insertKunSpoilerCommand as be, insertLinkCommand as J, insertMentionCommand as xe, insertQuoteCommand as Se, kunCM as Ce, mentionId as we, setHeadingCommand as Te, startImageUpload as Ee } from "@kungal/editor-core/preset";
13
+ import { strikethroughSchema as De, toggleStrikethroughCommand as Oe } from "@milkdown/kit/preset/gfm";
14
+ import { Annotation as ke, EditorState as Ae } from "@codemirror/state";
15
+ import { EditorView as Y } from "@codemirror/view";
16
+ import { markdown as je } from "@codemirror/lang-markdown";
17
+ import { basicSetup as Me } from "codemirror";
18
18
  //#region src/active-marks.ts
19
- var Pe = [
19
+ var Ne = [
20
20
  "bold",
21
21
  "italic",
22
22
  "strike",
23
23
  "code"
24
- ], Fe = {
25
- bold: pe,
26
- italic: ce,
27
- strike: Oe,
28
- code: le
29
- }, Ie = () => ({
24
+ ], Pe = {
25
+ bold: fe,
26
+ italic: se,
27
+ strike: De,
28
+ code: ce
29
+ }, Fe = () => ({
30
30
  bold: !1,
31
31
  italic: !1,
32
32
  strike: !1,
33
33
  code: !1
34
- }), Y = Object.freeze(Ie()), Le = (e, t) => {
35
- let { from: n, $from: r, to: i, empty: a } = e.selection, o = Ie();
36
- for (let s of Pe) {
37
- let c = Fe[s].type(t);
34
+ }), Ie = Object.freeze(Fe()), Le = (e, t) => {
35
+ let { from: n, $from: r, to: i, empty: a } = e.selection, o = Fe();
36
+ for (let s of Ne) {
37
+ let c = Pe[s].type(t);
38
38
  o[s] = a ? !!c.isInSet(e.storedMarks ?? r.marks()) : e.doc.rangeHasMark(n, i, c);
39
39
  }
40
40
  return o;
41
41
  }, Re = (e, t, n) => {
42
42
  let r = Le(e, t);
43
- for (let e of Pe) n[e] !== r[e] && (n[e] = r[e]);
44
- }, ze = new se("KUN_ACTIVE_MARKS"), Be = (e) => H((t) => new oe({
43
+ for (let e of Ne) n[e] !== r[e] && (n[e] = r[e]);
44
+ }, ze = new oe("KUN_ACTIVE_MARKS"), Be = (e) => U((t) => new ae({
45
45
  key: ze,
46
46
  view: (n) => (Re(n.state, t, e), { update(n) {
47
47
  Re(n.state, t, e);
@@ -105,13 +105,13 @@ var Pe = [
105
105
  }, F = (e) => {
106
106
  let t = d.value;
107
107
  if (!t || !D) return;
108
- let n = t.state.schema.nodes[Te];
108
+ let n = t.state.schema.nodes[we];
109
109
  if (!n) return;
110
110
  let r = n.create({
111
111
  userId: e.id,
112
112
  name: e.name
113
113
  }), { from: i, to: a } = D, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
114
- o.insertText(" ", s), o.setSelection(G.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), y.hide();
114
+ o.insertText(" ", s), o.setSelection(K.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), y.hide();
115
115
  }, I = (e) => {
116
116
  if (!x.value || !C.value.length) {
117
117
  x.value && e.key === "Escape" && (e.preventDefault(), y.hide());
@@ -137,7 +137,7 @@ var Pe = [
137
137
  }
138
138
  };
139
139
  return p(() => {
140
- y = new ie({
140
+ y = new re({
141
141
  content: g.value,
142
142
  trigger: "@",
143
143
  shouldShow: P,
@@ -170,7 +170,14 @@ var Pe = [
170
170
  class: "kun-mention-dropdown__avatar"
171
171
  }, null, 8, He)) : (m(), i("span", Ue, b(e.name.charAt(0)), 1)), a("span", We, b(e.name), 1)], 40, Ve))), 128)) : E.value ? (m(), i("div", Ge, b(u.value.searching), 1)) : S.value ? (m(), i("div", Ke, b(u.value.empty), 1)) : (m(), i("div", qe, b(u.value.prompt), 1))], 512));
172
172
  }
173
- }), 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>`, $ = {
173
+ }), Ye = (e, t) => {
174
+ let n = de.type(t), { from: r, to: i } = e.selection, a = "";
175
+ return e.doc.nodesBetween(r, i, (e) => {
176
+ if (a) return !1;
177
+ let t = n.isInSet(e.marks);
178
+ return t && (a = String(t.attrs.href ?? "")), !0;
179
+ }), a;
180
+ }, 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>`, $ = {
174
181
  bold: Z("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
175
182
  italic: Z("<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\"/>"),
176
183
  strike: Z("<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\"/>"),
@@ -190,20 +197,20 @@ var Pe = [
190
197
  check: Z("<path d=\"m5 13 4 4L19 7\"/>"),
191
198
  close: Z("<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/>"),
192
199
  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\"/>")
193
- }, Ye = ["data-mode"], Xe = ["placeholder", "aria-label"], Ze = ["title", "aria-label"], Qe = ["innerHTML"], $e = ["title", "aria-label"], et = ["innerHTML"], tt = {
200
+ }, Xe = ["data-mode"], Ze = ["placeholder", "aria-label"], Qe = ["title", "aria-label"], $e = ["innerHTML"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = {
194
201
  key: 0,
195
202
  class: "kun-editor__toolbar-divider",
196
203
  "aria-hidden": "true"
197
- }, nt = [
204
+ }, rt = [
198
205
  "title",
199
206
  "aria-label",
200
207
  "aria-pressed",
201
208
  "data-active",
202
209
  "onMousedown"
203
- ], rt = ["innerHTML"], it = /* @__PURE__ */ s({
210
+ ], it = ["innerHTML"], at = /* @__PURE__ */ s({
204
211
  __name: "SelectionTooltip",
205
212
  setup(n) {
206
- let { view: r, prevState: o } = ee(), [, s] = M(), c = l(X), d = c?.activeMarks ?? Y, h = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = t(() => {
213
+ let { view: r, prevState: o } = ee(), [, s] = M(), c = l(X), d = c?.activeMarks ?? Ie, h = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = t(() => {
207
214
  let e = h.value;
208
215
  return {
209
216
  bold: e ? "Bold" : "加粗",
@@ -216,24 +223,18 @@ var Pe = [
216
223
  cancel: e ? "Cancel" : "取消"
217
224
  };
218
225
  }), y = _(null), b, C = (e, t) => {
219
- s()?.action(U(e, t));
226
+ s()?.action(W(e, t));
220
227
  }, T = _(!1), k = _(""), A = _(null), j = () => {
221
228
  let e = "";
222
229
  return s()?.action((t) => {
223
230
  let n = r.value?.state;
224
- if (!n) return;
225
- let i = fe.type(t), { from: a, to: o } = n.selection;
226
- n.doc.nodesBetween(a, o, (t) => {
227
- if (e) return !1;
228
- let n = i.isInSet(t.marks);
229
- return n && (e = String(n.attrs.href ?? "")), !0;
230
- });
231
+ n && (e = Ye(n, t));
231
232
  }), e;
232
233
  }, N = () => {
233
234
  T.value = !1, k.value = "", r.value?.focus();
234
235
  }, P = () => {
235
236
  let e = k.value.trim();
236
- e && C(q.key, { href: e }), N();
237
+ e && C(J.key, { href: e }), N();
237
238
  }, F = async () => {
238
239
  let e = c?.adapters.linkPrompt;
239
240
  if (e) {
@@ -241,7 +242,7 @@ var Pe = [
241
242
  from: 0,
242
243
  to: 0
243
244
  }, a = (await e({ text: t ? t.state.doc.textBetween(n, i, " ") : "" }))?.trim();
244
- a && C(q.key, { href: a });
245
+ a && C(J.key, { href: a });
245
246
  return;
246
247
  }
247
248
  k.value = j(), T.value = !0, await u(), A.value?.focus(), A.value?.select();
@@ -249,25 +250,25 @@ var Pe = [
249
250
  bold: {
250
251
  svg: $.bold,
251
252
  title: g.value.bold,
252
- run: () => C(ge.key),
253
+ run: () => C(he.key),
253
254
  mark: "bold"
254
255
  },
255
256
  italic: {
256
257
  svg: $.italic,
257
258
  title: g.value.italic,
258
- run: () => C(me.key),
259
+ run: () => C(pe.key),
259
260
  mark: "italic"
260
261
  },
261
262
  strike: {
262
263
  svg: $.strike,
263
264
  title: g.value.strike,
264
- run: () => C(ke.key),
265
+ run: () => C(Oe.key),
265
266
  mark: "strike"
266
267
  },
267
268
  code: {
268
269
  svg: $.code,
269
270
  title: g.value.code,
270
- run: () => C(he.key),
271
+ run: () => C(me.key),
271
272
  mark: "code"
272
273
  },
273
274
  link: {
@@ -291,7 +292,7 @@ var Pe = [
291
292
  return n;
292
293
  });
293
294
  return p(() => {
294
- b = new ae({
295
+ b = new ie({
295
296
  content: y.value,
296
297
  offset: 8
297
298
  }), b.onHide = () => {
@@ -312,14 +313,15 @@ var Pe = [
312
313
  ref_key: "inputRef",
313
314
  ref: A,
314
315
  "onUpdate:modelValue": n[0] ||= (e) => k.value = e,
315
- type: "url",
316
- class: "kun-editor__bubble-input",
316
+ type: "text",
317
+ inputmode: "url",
318
+ class: "kun-editor__link-input",
317
319
  placeholder: g.value.linkUrl,
318
320
  "aria-label": g.value.linkUrl,
319
321
  spellcheck: "false",
320
322
  autocomplete: "off",
321
323
  onKeydown: [n[1] ||= D(O((e) => P(), ["prevent"]), ["enter"]), n[2] ||= D(O((e) => N(), ["stop", "prevent"]), ["esc"])]
322
- }, null, 40, Xe), [[S, k.value]]),
324
+ }, null, 40, Ze), [[S, k.value]]),
323
325
  a("button", {
324
326
  type: "button",
325
327
  class: "kun-editor__bubble-btn",
@@ -329,7 +331,7 @@ var Pe = [
329
331
  }, [a("span", {
330
332
  class: "kun-editor__icon",
331
333
  innerHTML: x($).check
332
- }, null, 8, Qe)], 40, Ze),
334
+ }, null, 8, $e)], 40, Qe),
333
335
  a("button", {
334
336
  type: "button",
335
337
  class: "kun-editor__bubble-btn",
@@ -339,8 +341,8 @@ var Pe = [
339
341
  }, [a("span", {
340
342
  class: "kun-editor__icon",
341
343
  innerHTML: x($).close
342
- }, null, 8, et)], 40, $e)
343
- ], 64)) : (m(!0), i(e, { key: 1 }, v(L.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", tt)) : (m(), i("button", {
344
+ }, null, 8, tt)], 40, et)
345
+ ], 64)) : (m(!0), i(e, { key: 1 }, v(L.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", nt)) : (m(), i("button", {
344
346
  key: 1,
345
347
  type: "button",
346
348
  class: "kun-editor__bubble-btn",
@@ -352,9 +354,9 @@ var Pe = [
352
354
  }, [a("span", {
353
355
  class: "kun-editor__icon",
354
356
  innerHTML: t.svg
355
- }, null, 8, rt)], 40, nt))], 64))), 128))], 8, Ye));
357
+ }, null, 8, it)], 40, rt))], 64))), 128))], 8, Xe));
356
358
  }
357
- }), at = /* @__PURE__ */ s({
359
+ }), ot = /* @__PURE__ */ s({
358
360
  __name: "MilkdownEditor",
359
361
  props: {
360
362
  modelValue: {},
@@ -369,15 +371,15 @@ var Pe = [
369
371
  },
370
372
  emits: ["update:modelValue", "update:loading"],
371
373
  setup(e, { expose: t, emit: r }) {
372
- let i = e, a = r, o = i.modelValue, s = !1, c = l(X), u = P(), d = B("kunMention"), f = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!u, p = V("kunSelectionTooltip"), h = i.selectionToolbar && !!u, g = j((e) => {
374
+ let i = e, a = r, o = i.modelValue, s = !1, c = l(X), u = P(), d = V("kunMention"), f = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!u, p = H("kunSelectionTooltip"), h = i.selectionToolbar && !!u, g = j((e) => {
373
375
  let t = L.make().config((t) => {
374
- t.set(z, e), t.set(te, i.modelValue), t.get(re).markdownUpdated((e, t, n) => {
376
+ t.set(B, e), t.set(te, i.modelValue), t.get(ne).markdownUpdated((e, t, n) => {
375
377
  !i.active || s || t === n || (o = t, a("update:modelValue", t));
376
- }), t.update(ne, (e) => ({
378
+ }), t.update(z, (e) => ({
377
379
  ...e,
378
380
  editable: () => !i.readonly
379
- })), f && t.set(d.key, { view: u({ component: Je }) }), h && t.set(p.key, { view: u({ component: it }) });
380
- }).use(be(i.adapters, i.features, {
381
+ })), f && t.set(d.key, { view: u({ component: Je }) }), h && t.set(p.key, { view: u({ component: at }) });
382
+ }).use(ye(i.adapters, i.features, {
381
383
  locale: i.locale,
382
384
  placeholder: i.placeholder,
383
385
  placeholderMode: i.placeholderMode
@@ -388,7 +390,7 @@ var Pe = [
388
390
  if (e === o) return;
389
391
  o = e;
390
392
  let t = g.get();
391
- t && (s = !0, t.action(W(e)), s = !1);
393
+ t && (s = !0, t.action(G(e)), s = !1);
392
394
  }), w(() => i.readonly, () => {
393
395
  g.get()?.action((e) => {
394
396
  let t = e.get(R);
@@ -400,13 +402,13 @@ var Pe = [
400
402
  };
401
403
  return t({
402
404
  insertQuote: (e) => {
403
- g.get()?.action(U(Ce.key, e)), _();
405
+ g.get()?.action(W(Se.key, e)), _();
404
406
  },
405
407
  insertMention: (e) => {
406
- g.get()?.action(U(Se.key, e)), _();
408
+ g.get()?.action(W(xe.key, e)), _();
407
409
  },
408
410
  insertImage: (e) => {
409
- g.get()?.action(U(de.key, {
411
+ g.get()?.action(W(ue.key, {
410
412
  src: e.src,
411
413
  alt: e.alt ?? "",
412
414
  title: e.title ?? ""
@@ -415,7 +417,7 @@ var Pe = [
415
417
  uploadImage: (e) => {
416
418
  let t = i.adapters.uploadImage, n = g.get();
417
419
  !t || !n || n.action((n) => {
418
- De(n.get(R), e, {
420
+ Ee(n.get(R), e, {
419
421
  uploadImage: t,
420
422
  notify: i.adapters.notify,
421
423
  locale: i.locale
@@ -432,28 +434,107 @@ var Pe = [
432
434
  behavior: "smooth",
433
435
  block: "start"
434
436
  }), n.editable)) {
435
- let e = G.near(n.state.doc.resolve(i + 1));
437
+ let e = K.near(n.state.doc.resolve(i + 1));
436
438
  n.dispatch(n.state.tr.setSelection(e)), n.focus();
437
439
  }
438
440
  });
439
441
  }
440
442
  }), (e, t) => (m(), n(x(k)));
441
443
  }
442
- }), ot = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), st = [
444
+ }), st = [
445
+ "title",
446
+ "aria-label",
447
+ "aria-expanded"
448
+ ], ct = ["innerHTML"], lt = { class: "kun-editor__link-panel" }, ut = ["placeholder", "aria-label"], dt = ["title", "aria-label"], ft = ["innerHTML"], pt = /* @__PURE__ */ s({
449
+ __name: "LinkInput",
450
+ setup(e) {
451
+ let [, n] = M(), r = l(X), o = t(() => (r?.locale ?? "zh-cn").toLowerCase().startsWith("en")), s = t(() => {
452
+ let e = o.value;
453
+ return {
454
+ link: e ? "Link" : "链接",
455
+ linkUrl: e ? "Link URL" : "链接 URL",
456
+ apply: e ? "Apply" : "确定"
457
+ };
458
+ }), c = _(!1), d = _(""), h = _(null), g = _(null), v = (e) => {
459
+ e && n()?.action(W(J.key, { href: e }));
460
+ }, y = () => {
461
+ c.value = !1, d.value = "";
462
+ }, b = () => {
463
+ y(), n()?.action((e) => e.get(R).focus());
464
+ }, w = () => {
465
+ v(d.value.trim()), b();
466
+ }, T = async () => {
467
+ let e = r?.adapters.linkPrompt;
468
+ if (e) {
469
+ let t = "";
470
+ n()?.action((e) => {
471
+ let { state: n } = e.get(R), { from: r, to: i } = n.selection;
472
+ t = n.doc.textBetween(r, i, " ");
473
+ }), v((await e({ text: t }))?.trim() ?? "");
474
+ return;
475
+ }
476
+ if (c.value) {
477
+ y();
478
+ return;
479
+ }
480
+ n()?.action((e) => {
481
+ d.value = Ye(e.get(R).state, e);
482
+ }), c.value = !0, await u(), g.value?.focus(), g.value?.select();
483
+ }, k = (e) => {
484
+ c.value && h.value && !h.value.contains(e.target) && y();
485
+ };
486
+ return p(() => document.addEventListener("click", k)), f(() => document.removeEventListener("click", k)), (e, t) => (m(), i("div", {
487
+ ref_key: "rootRef",
488
+ ref: h,
489
+ class: "kun-editor__link"
490
+ }, [a("button", {
491
+ type: "button",
492
+ class: "kun-editor__tool",
493
+ title: s.value.link,
494
+ "aria-label": s.value.link,
495
+ "aria-expanded": c.value,
496
+ onClick: T
497
+ }, [a("span", {
498
+ class: "kun-editor__icon",
499
+ innerHTML: x($).link
500
+ }, null, 8, ct)], 8, st), E(a("div", lt, [E(a("input", {
501
+ ref_key: "inputRef",
502
+ ref: g,
503
+ "onUpdate:modelValue": t[0] ||= (e) => d.value = e,
504
+ type: "text",
505
+ inputmode: "url",
506
+ class: "kun-editor__link-input",
507
+ placeholder: s.value.linkUrl,
508
+ "aria-label": s.value.linkUrl,
509
+ spellcheck: "false",
510
+ autocomplete: "off",
511
+ onKeydown: [t[1] ||= D(O((e) => w(), ["prevent"]), ["enter"]), t[2] ||= D(O((e) => b(), ["stop", "prevent"]), ["esc"])]
512
+ }, null, 40, ut), [[S, d.value]]), a("button", {
513
+ type: "button",
514
+ class: "kun-editor__tool",
515
+ title: s.value.apply,
516
+ "aria-label": s.value.apply,
517
+ onClick: t[3] ||= (e) => w()
518
+ }, [a("span", {
519
+ class: "kun-editor__icon",
520
+ innerHTML: x($).check
521
+ }, null, 8, ft)], 8, dt)], 512), [[C, c.value]])], 512));
522
+ }
523
+ }), mt = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), ht = [
443
524
  "title",
444
525
  "aria-label",
445
526
  "aria-expanded"
446
- ], ct = ["innerHTML"], lt = { class: "kun-editor__picker-panel" }, ut = {
527
+ ], gt = ["innerHTML"], _t = { class: "kun-editor__picker-panel" }, vt = {
447
528
  key: 0,
448
529
  class: "kun-editor__picker-tabs",
449
530
  role: "tablist"
450
- }, dt = ["data-active"], ft = ["data-active"], pt = { class: "kun-editor__emoji-grid" }, mt = ["onClick"], ht = {
531
+ }, yt = ["data-active"], bt = ["data-active"], xt = { class: "kun-editor__emoji-grid" }, St = ["onClick"], Ct = {
451
532
  key: 1,
452
533
  class: "kun-editor__sticker-body"
453
- }, gt = { class: "kun-editor__pack-name" }, _t = { class: "kun-editor__sticker-grid" }, vt = ["title", "onClick"], yt = ["src", "alt"], bt = {
534
+ }, wt = { class: "kun-editor__pack-name" }, Tt = { class: "kun-editor__sticker-grid" }, Et = ["title", "onClick"], Dt = ["src", "alt"], Ot = {
454
535
  key: 1,
455
536
  class: "kun-editor__picker-hint"
456
- }, xt = /* @__PURE__ */ s({
537
+ }, kt = /* @__PURE__ */ s({
457
538
  __name: "StickerPicker",
458
539
  setup(n) {
459
540
  let [, o] = M(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
@@ -489,7 +570,7 @@ var Pe = [
489
570
  n.dispatch(r.tr.insertText(e, r.selection.from));
490
571
  });
491
572
  }, N = (e, t) => {
492
- o()?.action(U(de.key, {
573
+ o()?.action(W(ue.key, {
493
574
  src: e,
494
575
  title: t,
495
576
  alt: t
@@ -509,28 +590,28 @@ var Pe = [
509
590
  }, [a("span", {
510
591
  class: "kun-editor__icon",
511
592
  innerHTML: x($).smile
512
- }, null, 8, ct)], 8, st), E(a("div", lt, [
513
- u ? (m(), i("div", ut, [a("button", {
593
+ }, null, 8, gt)], 8, ht), E(a("div", _t, [
594
+ u ? (m(), i("div", vt, [a("button", {
514
595
  type: "button",
515
596
  class: "kun-editor__picker-tab",
516
597
  "data-active": S.value === "emoji",
517
598
  onClick: n[0] ||= (e) => S.value = "emoji"
518
- }, b(h.value.emoji), 9, dt), a("button", {
599
+ }, b(h.value.emoji), 9, yt), a("button", {
519
600
  type: "button",
520
601
  class: "kun-editor__picker-tab",
521
602
  "data-active": S.value === "sticker",
522
603
  onClick: n[1] ||= (e) => S.value = "sticker"
523
- }, b(h.value.sticker), 9, ft)])) : r("", !0),
524
- E(a("div", pt, [(m(!0), i(e, null, v(x(ot), (e, t) => (m(), i("button", {
604
+ }, b(h.value.sticker), 9, bt)])) : r("", !0),
605
+ E(a("div", xt, [(m(!0), i(e, null, v(x(mt), (e, t) => (m(), i("button", {
525
606
  key: t,
526
607
  type: "button",
527
608
  class: "kun-editor__emoji",
528
609
  onClick: (t) => j(e)
529
- }, b(e), 9, mt))), 128))], 512), [[C, !u || S.value === "emoji"]]),
530
- u ? E((m(), i("div", ht, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
610
+ }, b(e), 9, St))), 128))], 512), [[C, !u || S.value === "emoji"]]),
611
+ u ? E((m(), i("div", Ct, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
531
612
  key: t.name,
532
613
  class: "kun-editor__pack"
533
- }, [a("div", gt, b(t.name), 1), a("div", _t, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
614
+ }, [a("div", wt, b(t.name), 1), a("div", Tt, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
534
615
  key: t,
535
616
  type: "button",
536
617
  class: "kun-editor__sticker",
@@ -540,44 +621,35 @@ var Pe = [
540
621
  src: e.src,
541
622
  alt: e.name,
542
623
  loading: "lazy"
543
- }, null, 8, yt)], 8, vt))), 128))])]))), 128)) : (m(), i("div", bt, b(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[C, S.value === "sticker"]]) : r("", !0)
624
+ }, null, 8, Dt)], 8, Et))), 128))])]))), 128)) : (m(), i("div", Ot, b(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[C, S.value === "sticker"]]) : r("", !0)
544
625
  ], 512), [[C, g.value]])], 512));
545
626
  }
546
- }), St = {
627
+ }), At = {
547
628
  class: "kun-editor__format-toolbar",
548
629
  role: "toolbar"
549
- }, Ct = ["aria-label"], wt = {
630
+ }, jt = ["aria-label"], Mt = {
550
631
  value: "",
551
632
  disabled: "",
552
633
  selected: ""
553
- }, Tt = ["value"], Et = [
634
+ }, Nt = ["value"], Pt = [
554
635
  "title",
555
636
  "aria-label",
556
637
  "aria-pressed",
557
638
  "data-active",
558
639
  "onClick"
559
- ], Dt = ["innerHTML"], Ot = ["title", "aria-label"], kt = ["innerHTML"], At = /* @__PURE__ */ s({
640
+ ], Ft = ["innerHTML"], It = ["title", "aria-label"], Lt = ["innerHTML"], Rt = /* @__PURE__ */ s({
560
641
  __name: "EditorToolbar",
561
- setup(n) {
562
- let [, s] = M(), c = l(X), u = c?.activeMarks ?? Y, d = t(() => c?.adapters.uploadImage), f = t(() => c?.features.sticker !== !1), p = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = (e, t) => {
563
- s()?.action(U(e, t));
564
- }, g = async () => {
565
- let e = "";
566
- s()?.action((t) => {
567
- let n = t.get(R), { from: r, to: i } = n.state.selection;
568
- e = n.state.doc.textBetween(r, i, " ");
569
- });
570
- let t = c?.adapters.linkPrompt, n = (t ? await t({ text: e }) : window.prompt(p.value ? "Link URL" : "链接 URL"))?.trim();
571
- n && h(q.key, { href: n });
642
+ setup(s) {
643
+ let [, c] = M(), u = l(X), d = u?.activeMarks ?? Ie, f = t(() => u?.adapters.uploadImage), p = t(() => u?.features.sticker !== !1), h = t(() => (u?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = (e, t) => {
644
+ c()?.action(W(e, t));
572
645
  }, y = t(() => {
573
- let e = p.value;
646
+ let e = h.value;
574
647
  return {
575
648
  textSize: e ? "Text size" : "文本大小",
576
649
  bold: e ? "Bold" : "加粗",
577
650
  italic: e ? "Italic" : "斜体",
578
651
  strike: e ? "Strikethrough" : "删除线",
579
652
  code: e ? "Inline code" : "行内代码",
580
- link: e ? "Link" : "链接",
581
653
  bulletList: e ? "Bullet list" : "无序列表",
582
654
  orderedList: e ? "Ordered list" : "有序列表",
583
655
  quote: e ? "Blockquote" : "引用块",
@@ -587,7 +659,7 @@ var Pe = [
587
659
  image: e ? "Upload image" : "上传图片"
588
660
  };
589
661
  }), S = t(() => {
590
- let e = p.value;
662
+ let e = h.value;
591
663
  return [
592
664
  "正文",
593
665
  "一级标题",
@@ -602,110 +674,106 @@ var Pe = [
602
674
  }));
603
675
  }), C = (e) => {
604
676
  let t = e.target;
605
- h(Ee.key, Number(t.value)), t.selectedIndex = 0;
677
+ g(Te.key, Number(t.value)), t.selectedIndex = 0;
606
678
  }, w = t(() => [
607
679
  [
608
680
  {
609
681
  svg: $.bold,
610
682
  title: y.value.bold,
611
- run: () => h(ge.key),
683
+ run: () => g(he.key),
612
684
  mark: "bold"
613
685
  },
614
686
  {
615
687
  svg: $.italic,
616
688
  title: y.value.italic,
617
- run: () => h(me.key),
689
+ run: () => g(pe.key),
618
690
  mark: "italic"
619
691
  },
620
692
  {
621
693
  svg: $.strike,
622
694
  title: y.value.strike,
623
- run: () => h(ke.key),
695
+ run: () => g(Oe.key),
624
696
  mark: "strike"
625
697
  },
626
698
  {
627
699
  svg: $.code,
628
700
  title: y.value.code,
629
- run: () => h(he.key),
701
+ run: () => g(me.key),
630
702
  mark: "code"
631
703
  },
632
- {
633
- svg: $.link,
634
- title: y.value.link,
635
- run: g
636
- }
704
+ { link: !0 }
637
705
  ],
638
706
  [
639
707
  {
640
708
  svg: $.bulletList,
641
709
  title: y.value.bulletList,
642
- run: () => h(ve.key)
710
+ run: () => g(_e.key)
643
711
  },
644
712
  {
645
713
  svg: $.orderedList,
646
714
  title: y.value.orderedList,
647
- run: () => h(ye.key)
715
+ run: () => g(ve.key)
648
716
  },
649
717
  {
650
718
  svg: $.quote,
651
719
  title: y.value.quote,
652
- run: () => h(_e.key)
720
+ run: () => g(ge.key)
653
721
  },
654
722
  {
655
723
  svg: $.codeBlock,
656
724
  title: y.value.codeBlock,
657
- run: () => h(K.key, "")
725
+ run: () => g(q.key, "")
658
726
  },
659
727
  {
660
728
  svg: $.hr,
661
729
  title: y.value.hr,
662
- run: () => h(ue.key)
730
+ run: () => g(le.key)
663
731
  }
664
732
  ],
665
733
  [{
666
734
  svg: $.spoiler,
667
735
  title: y.value.spoiler,
668
- run: () => h(xe.key)
736
+ run: () => g(be.key)
669
737
  }]
670
738
  ]), T = _(null), E = () => T.value?.click(), D = (e) => {
671
739
  let t = e.target, n = t.files?.[0];
672
740
  t.value = "";
673
- let r = d.value;
674
- !n || !r || s()?.action((e) => {
675
- De(e.get(R), n, {
741
+ let r = f.value;
742
+ !n || !r || c()?.action((e) => {
743
+ Ee(e.get(R), n, {
676
744
  uploadImage: r,
677
- notify: c?.adapters.notify,
678
- locale: c?.locale
745
+ notify: u?.adapters.notify,
746
+ locale: u?.locale
679
747
  });
680
748
  });
681
749
  };
682
- return (t, n) => (m(), i("div", St, [
750
+ return (t, s) => (m(), i("div", At, [
683
751
  a("select", {
684
752
  class: "kun-editor__heading-select",
685
753
  "aria-label": y.value.textSize,
686
754
  onChange: C
687
- }, [a("option", wt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
755
+ }, [a("option", Mt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
688
756
  key: e.level,
689
757
  value: e.level
690
- }, b(e.label), 9, Tt))), 128))], 40, Ct),
691
- (m(!0), i(e, null, v(w.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
758
+ }, b(e.label), 9, Nt))), 128))], 40, jt),
759
+ (m(!0), i(e, null, v(w.value, (t, r) => (m(), i(e, { key: r }, [s[0] ||= a("span", {
692
760
  class: "kun-editor__toolbar-divider",
693
761
  "aria-hidden": "true"
694
- }, null, -1), (m(!0), i(e, null, v(t, (e, t) => (m(), i("button", {
695
- key: t,
762
+ }, null, -1), (m(!0), i(e, null, v(t, (t, r) => (m(), i(e, { key: r }, ["link" in t ? (m(), n(pt, { key: 0 })) : (m(), i("button", {
763
+ key: 1,
696
764
  type: "button",
697
765
  class: "kun-editor__tool",
698
- title: e.title,
699
- "aria-label": e.title,
700
- "aria-pressed": e.mark ? x(u)[e.mark] : void 0,
701
- "data-active": e.mark ? x(u)[e.mark] : void 0,
702
- onClick: (t) => e.run()
766
+ title: t.title,
767
+ "aria-label": t.title,
768
+ "aria-pressed": t.mark ? x(d)[t.mark] : void 0,
769
+ "data-active": t.mark ? x(d)[t.mark] : void 0,
770
+ onClick: (e) => t.run()
703
771
  }, [a("span", {
704
772
  class: "kun-editor__icon",
705
- innerHTML: e.svg
706
- }, null, 8, Dt)], 8, Et))), 128))], 64))), 128)),
707
- d.value ? (m(), i(e, { key: 0 }, [
708
- n[1] ||= a("span", {
773
+ innerHTML: t.svg
774
+ }, null, 8, Ft)], 8, Pt))], 64))), 128))], 64))), 128)),
775
+ f.value ? (m(), i(e, { key: 0 }, [
776
+ s[1] ||= a("span", {
709
777
  class: "kun-editor__toolbar-divider",
710
778
  "aria-hidden": "true"
711
779
  }, null, -1),
@@ -718,7 +786,7 @@ var Pe = [
718
786
  }, [a("span", {
719
787
  class: "kun-editor__icon",
720
788
  innerHTML: x($).image
721
- }, null, 8, kt)], 8, Ot),
789
+ }, null, 8, Lt)], 8, It),
722
790
  a("input", {
723
791
  ref_key: "fileInput",
724
792
  ref: T,
@@ -728,23 +796,23 @@ var Pe = [
728
796
  onChange: D
729
797
  }, null, 544)
730
798
  ], 64)) : r("", !0),
731
- f.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
799
+ p.value ? (m(), i(e, { key: 1 }, [s[2] ||= a("span", {
732
800
  class: "kun-editor__toolbar-divider",
733
801
  "aria-hidden": "true"
734
- }, null, -1), o(xt)], 64)) : r("", !0)
802
+ }, null, -1), o(kt)], 64)) : r("", !0)
735
803
  ]));
736
804
  }
737
- }), jt = /* @__PURE__ */ s({
805
+ }), zt = /* @__PURE__ */ s({
738
806
  __name: "ToolbarHost",
739
807
  setup(e) {
740
808
  let [, t] = M(), n = l(X, void 0), r = (e, n) => {
741
- t()?.action(U(e, n));
809
+ t()?.action(W(e, n));
742
810
  }, i = () => {
743
811
  t()?.action((e) => e.get(R).focus());
744
812
  }, a = {
745
813
  run: r,
746
814
  get activeMarks() {
747
- return n?.activeMarks ?? Y;
815
+ return n?.activeMarks ?? Ie;
748
816
  },
749
817
  insertText: (e) => {
750
818
  t()?.action((t) => {
@@ -755,7 +823,7 @@ var Pe = [
755
823
  uploadImage: (e) => {
756
824
  let r = n?.adapters.uploadImage, i = t();
757
825
  !r || !i || i.action((t) => {
758
- De(t.get(R), e, {
826
+ Ee(t.get(R), e, {
759
827
  uploadImage: r,
760
828
  notify: n?.adapters.notify,
761
829
  locale: n?.locale
@@ -763,20 +831,20 @@ var Pe = [
763
831
  });
764
832
  },
765
833
  insertLink: (e) => {
766
- r(q.key, e), i();
834
+ r(J.key, e), i();
767
835
  },
768
836
  insertImage: (e) => {
769
- r(de.key, {
837
+ r(ue.key, {
770
838
  src: e.src,
771
839
  alt: e.alt ?? "",
772
840
  title: e.title ?? ""
773
841
  }), i();
774
842
  },
775
843
  insertQuote: (e) => {
776
- r(Ce.key, e), i();
844
+ r(Se.key, e), i();
777
845
  },
778
846
  insertMention: (e) => {
779
- r(Se.key, e), i();
847
+ r(xe.key, e), i();
780
848
  },
781
849
  focus: i,
782
850
  get adapters() {
@@ -791,7 +859,7 @@ var Pe = [
791
859
  };
792
860
  return (e, t) => y(e.$slots, "default", d(c(a)));
793
861
  }
794
- }), Mt = /* @__PURE__ */ s({
862
+ }), Bt = /* @__PURE__ */ s({
795
863
  __name: "MarkdownSource",
796
864
  props: {
797
865
  modelValue: {},
@@ -799,21 +867,21 @@ var Pe = [
799
867
  },
800
868
  emits: ["update:modelValue"],
801
869
  setup(e, { expose: t, emit: n }) {
802
- let r = e, a = n, o = _(null), s = null, c = Ae.define(), l = (e) => je.create({
870
+ let r = e, a = n, o = _(null), s = null, c = ke.define(), l = (e) => Ae.create({
803
871
  doc: e,
804
872
  extensions: [
805
- we(),
806
- J.lineWrapping,
807
- Ne,
808
- Me(),
809
- J.editable.of(!r.readonly),
810
- J.updateListener.of((e) => {
873
+ Ce(),
874
+ Y.lineWrapping,
875
+ Me,
876
+ je(),
877
+ Y.editable.of(!r.readonly),
878
+ Y.updateListener.of((e) => {
811
879
  e.docChanged && !e.transactions.some((e) => e.annotation(c)) && a("update:modelValue", e.state.doc.toString());
812
880
  })
813
881
  ]
814
882
  });
815
883
  p(() => {
816
- o.value && (s = new J({
884
+ o.value && (s = new Y({
817
885
  state: l(r.modelValue),
818
886
  parent: o.value
819
887
  }));
@@ -863,23 +931,23 @@ var Pe = [
863
931
  class: "kun-editor__source"
864
932
  }, null, 512));
865
933
  }
866
- }), Nt = ["data-mode"], Pt = {
934
+ }), Vt = ["data-mode"], Ht = {
867
935
  key: 0,
868
936
  class: "kun-editor__toolbar",
869
937
  role: "tablist"
870
- }, Ft = [
938
+ }, Ut = [
871
939
  "aria-selected",
872
940
  "data-active",
873
941
  "onClick"
874
- ], It = ["title", "aria-label"], Lt = [
942
+ ], Wt = ["title", "aria-label"], Gt = [
875
943
  "data-active",
876
944
  "title",
877
945
  "aria-pressed"
878
- ], Rt = ["data-swap"], zt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Bt = {
946
+ ], Kt = ["data-swap"], qt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Jt = {
879
947
  key: 1,
880
948
  class: "kun-editor__loading",
881
949
  "aria-hidden": "true"
882
- }, Vt = /* @__PURE__ */ s({
950
+ }, Yt = /* @__PURE__ */ s({
883
951
  __name: "KunEditor",
884
952
  props: {
885
953
  modelValue: {},
@@ -926,7 +994,7 @@ var Pe = [
926
994
  M.value = e, k("update:loading", e);
927
995
  };
928
996
  w(() => O.modelValue, (e) => k("update:headings", I(e)), { immediate: !0 });
929
- let P = g(Ie());
997
+ let P = g(Fe());
930
998
  h(X, {
931
999
  get adapters() {
932
1000
  return O.adapters;
@@ -950,15 +1018,15 @@ var Pe = [
950
1018
  w(() => O.views, (e) => {
951
1019
  e.includes(L.value) || (L.value = e[0] ?? "wysiwyg");
952
1020
  });
953
- let R = _(!1), ne = () => {
1021
+ let R = _(!1), z = () => {
954
1022
  R.value = !R.value;
955
- }, z = _(O.scrollSync);
1023
+ }, B = _(O.scrollSync);
956
1024
  w(() => O.scrollSync, (e) => {
957
- z.value = e;
1025
+ B.value = e;
958
1026
  });
959
- let re = () => {
960
- z.value = !z.value;
961
- }, ie = t(() => O.locale.toLowerCase().startsWith("en")), B = t(() => ie.value ? {
1027
+ let ne = () => {
1028
+ B.value = !B.value;
1029
+ }, re = t(() => O.locale.toLowerCase().startsWith("en")), V = t(() => re.value ? {
962
1030
  wysiwyg: "Preview",
963
1031
  source: "Markdown",
964
1032
  split: "Split",
@@ -970,103 +1038,103 @@ var Pe = [
970
1038
  split: "分栏",
971
1039
  swap: "左右互换",
972
1040
  scrollSync: "同步滚动"
973
- }), ae = _(null), V = null, H = null, U = null, W = () => {
974
- V?.(), V = null, H = null;
975
- }, oe = () => {
976
- W();
977
- let e = ae.value;
1041
+ }), ie = _(null), H = null, U = null, W = null, G = () => {
1042
+ H?.(), H = null, U = null;
1043
+ }, ae = () => {
1044
+ G();
1045
+ let e = ie.value;
978
1046
  if (!e) return;
979
1047
  let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
980
1048
  if (!t || !n) return;
981
1049
  let r = (e, t) => () => {
982
- if (H && H !== e) return;
983
- H = e;
1050
+ if (U && U !== e) return;
1051
+ U = e;
984
1052
  let n = e.scrollHeight - e.clientHeight, r = n > 0 ? e.scrollTop / n : 0, i = t.scrollHeight - t.clientHeight;
985
- t.scrollTop = r * (i > 0 ? i : 0), U && clearTimeout(U), U = setTimeout(() => {
986
- H = null;
1053
+ t.scrollTop = r * (i > 0 ? i : 0), W && clearTimeout(W), W = setTimeout(() => {
1054
+ U = null;
987
1055
  }, 120);
988
1056
  }, i = r(t, n), a = r(n, t);
989
- t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), V = () => {
1057
+ t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), H = () => {
990
1058
  t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
991
1059
  };
992
1060
  };
993
- w([L, z], ([e, t]) => {
994
- W(), e === "split" && t && u(oe);
995
- }), f(W);
996
- let se = t(() => O.readonly || L.value === "split"), G = (e) => k("update:modelValue", e), K = _(null), ce = _(null);
1061
+ w([L, B], ([e, t]) => {
1062
+ G(), e === "split" && t && u(ae);
1063
+ }), f(G);
1064
+ let oe = t(() => O.readonly || L.value === "split"), K = (e) => k("update:modelValue", e), q = _(null), se = _(null);
997
1065
  return l({
998
- insertQuote: (e) => K.value?.insertQuote(e),
999
- insertMention: (e) => K.value?.insertMention(e),
1000
- insertImage: (e) => K.value?.insertImage(e),
1001
- uploadImage: (e) => K.value?.uploadImage(e),
1002
- focus: () => K.value?.focus(),
1066
+ insertQuote: (e) => q.value?.insertQuote(e),
1067
+ insertMention: (e) => q.value?.insertMention(e),
1068
+ insertImage: (e) => q.value?.insertImage(e),
1069
+ uploadImage: (e) => q.value?.uploadImage(e),
1070
+ focus: () => q.value?.focus(),
1003
1071
  scrollToHeading: (e) => {
1004
- L.value === "source" || L.value === "split" ? ce.value?.scrollToHeading(e) : K.value?.scrollToHeading(e);
1072
+ L.value === "source" || L.value === "split" ? se.value?.scrollToHeading(e) : q.value?.scrollToHeading(e);
1005
1073
  }
1006
1074
  }), (t, l) => (m(), i("div", {
1007
1075
  ref_key: "rootEl",
1008
- ref: ae,
1076
+ ref: ie,
1009
1077
  class: "kun-editor",
1010
1078
  "data-kun-editor": "",
1011
1079
  "data-mode": L.value
1012
1080
  }, [j.value ? (m(), i(e, { key: 0 }, [y(t.$slots, "view-switch", {
1013
1081
  mode: L.value,
1014
1082
  setMode: te,
1015
- labels: B.value,
1083
+ labels: V.value,
1016
1084
  views: s.views,
1017
1085
  swapped: R.value,
1018
- swap: ne,
1019
- scrollSync: z.value,
1020
- toggleScrollSync: re
1021
- }, () => [s.views.length > 1 ? (m(), i("div", Pt, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
1086
+ swap: z,
1087
+ scrollSync: B.value,
1088
+ toggleScrollSync: ne
1089
+ }, () => [s.views.length > 1 ? (m(), i("div", Ht, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
1022
1090
  key: e,
1023
1091
  type: "button",
1024
1092
  class: "kun-editor__tab",
1025
1093
  "aria-selected": L.value === e,
1026
1094
  "data-active": L.value === e,
1027
1095
  onClick: (t) => te(e)
1028
- }, b(B.value[e]), 9, Ft))), 128)), L.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
1096
+ }, b(V.value[e]), 9, Ut))), 128)), L.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
1029
1097
  type: "button",
1030
1098
  class: "kun-editor__tab kun-editor__swap",
1031
- title: B.value.swap,
1032
- "aria-label": B.value.swap,
1033
- onClick: l[0] ||= (e) => ne()
1034
- }, " ⇄ ", 8, It), a("button", {
1099
+ title: V.value.swap,
1100
+ "aria-label": V.value.swap,
1101
+ onClick: l[0] ||= (e) => z()
1102
+ }, " ⇄ ", 8, Wt), a("button", {
1035
1103
  type: "button",
1036
1104
  class: "kun-editor__tab",
1037
- "data-active": z.value,
1038
- title: B.value.scrollSync,
1039
- "aria-pressed": z.value,
1040
- onClick: l[1] ||= (e) => re()
1041
- }, b(B.value.scrollSync), 9, Lt)], 64)) : r("", !0)])) : r("", !0)]), o(x(A), null, {
1105
+ "data-active": B.value,
1106
+ title: V.value.scrollSync,
1107
+ "aria-pressed": B.value,
1108
+ onClick: l[1] ||= (e) => ne()
1109
+ }, b(V.value.scrollSync), 9, Gt)], 64)) : r("", !0)])) : r("", !0)]), o(x(A), null, {
1042
1110
  default: T(() => [o(x(N), null, {
1043
- default: T(() => [E(a("div", null, [o(jt, null, {
1044
- default: T((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(At)])]),
1111
+ default: T(() => [E(a("div", null, [o(zt, null, {
1112
+ default: T((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(Rt)])]),
1045
1113
  _: 3
1046
1114
  })], 512), [[C, L.value === "wysiwyg" && !s.readonly]]), a("div", {
1047
1115
  class: "kun-editor__panes",
1048
1116
  "data-swap": R.value
1049
- }, [L.value === "source" || L.value === "split" ? (m(), n(Mt, {
1117
+ }, [L.value === "source" || L.value === "split" ? (m(), n(Bt, {
1050
1118
  key: 0,
1051
1119
  ref_key: "source",
1052
- ref: ce,
1120
+ ref: se,
1053
1121
  class: "kun-editor__pane",
1054
1122
  "model-value": s.modelValue,
1055
1123
  readonly: s.readonly,
1056
- "onUpdate:modelValue": G
1057
- }, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", zt, [o(at, {
1124
+ "onUpdate:modelValue": K
1125
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", qt, [o(ot, {
1058
1126
  ref_key: "inner",
1059
- ref: K,
1127
+ ref: q,
1060
1128
  "model-value": s.modelValue,
1061
1129
  adapters: s.adapters,
1062
1130
  features: s.features,
1063
1131
  locale: s.locale,
1064
- readonly: se.value,
1132
+ readonly: oe.value,
1065
1133
  placeholder: s.placeholder,
1066
1134
  "placeholder-mode": s.placeholderMode,
1067
1135
  active: L.value === "wysiwyg" && !s.readonly,
1068
1136
  "selection-toolbar": F.value,
1069
- "onUpdate:modelValue": G,
1137
+ "onUpdate:modelValue": K,
1070
1138
  "onUpdate:loading": ee
1071
1139
  }, null, 8, [
1072
1140
  "model-value",
@@ -1078,18 +1146,18 @@ var Pe = [
1078
1146
  "placeholder-mode",
1079
1147
  "active",
1080
1148
  "selection-toolbar"
1081
- ])], 512), [[C, L.value === "wysiwyg" || L.value === "split"]])], 8, Rt)]),
1149
+ ])], 512), [[C, L.value === "wysiwyg" || L.value === "split"]])], 8, Kt)]),
1082
1150
  _: 3
1083
1151
  })]),
1084
1152
  _: 3
1085
- })], 64)) : r("", !0), !j.value || M.value ? (m(), i("div", Bt, [y(t.$slots, "loading", {}, () => [
1153
+ })], 64)) : r("", !0), !j.value || M.value ? (m(), i("div", Jt, [y(t.$slots, "loading", {}, () => [
1086
1154
  l[2] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
1087
1155
  l[3] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
1088
1156
  l[4] ||= a("div", { class: "kun-editor__skeleton" }, null, -1)
1089
- ])])) : r("", !0)], 8, Nt));
1157
+ ])])) : r("", !0)], 8, Vt));
1090
1158
  }
1091
- }), Ht = { install(e) {
1092
- e.component("KunEditor", Vt);
1159
+ }), Xt = { install(e) {
1160
+ e.component("KunEditor", Yt);
1093
1161
  } };
1094
1162
  //#endregion
1095
- export { ot as EMOJI, Vt as KunEditor, Ht as KunEditorPlugin, F as parseHeadings };
1163
+ export { mt as EMOJI, Yt as KunEditor, Xt as KunEditorPlugin, F as parseHeadings };
@@ -0,0 +1,5 @@
1
+ import type { Ctx } from '@milkdown/kit/ctx';
2
+ import type { EditorState } from '@milkdown/kit/prose/state';
3
+ /** The first link href in the selection, or '' when the selection is plain. */
4
+ export declare const readSelectedHref: (state: EditorState, ctx: Ctx) => string;
5
+ //# sourceMappingURL=selected-href.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selected-href.d.ts","sourceRoot":"","sources":["../src/selected-href.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,GAAI,OAAO,WAAW,EAAE,KAAK,GAAG,KAAG,MAe/D,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-vue",
3
- "version": "0.33.0",
3
+ "version": "0.35.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.33.0"
43
+ "@kungal/editor-core": "0.35.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.33.0"
83
+ "@kungal/editor-core": "0.35.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",