@kungal/editor-vue 0.33.0 → 0.34.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,46 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ab7fbc2: No native `prompt` left: the headless toolbar gets a link URL panel too
8
+
9
+ 0.33.0 gave the selection bubble an inline URL input; the fixed (headless)
10
+ toolbar still popped `window.prompt`. It now opens a small panel under the link
11
+ button — Enter applies, Esc cancels, clicking outside closes, and the editor
12
+ gets focus back. Same behaviour as the bubble otherwise: an existing href is
13
+ prefilled (and selected), and with nothing selected the URL is inserted as
14
+ linked text. A panel rather than an in-place swap because a fixed toolbar row
15
+ that rearranges itself is jarring; the bubble is already a floating layer, so
16
+ there the swap is the right shape.
17
+
18
+ **Breaking (CSS hook, one version old):** `.kun-editor__bubble-input` →
19
+ `.kun-editor__link-input`. Both entry points render the same input, so the hook
20
+ is named after the thing, not the place. Hosts importing
21
+ `@kungal/editor-nuxt/editor.css` need no change; a copied stylesheet wants the
22
+ rename plus the two new hooks:
23
+
24
+ ```css
25
+ .kun-editor__link {
26
+ position: relative;
27
+ } /* structural */
28
+ .kun-editor__link-panel {
29
+ position: absolute;
30
+ } /* structural */
31
+ .kun-editor__link-input {
32
+ /* shared by the toolbar panel and the bubble */
33
+ }
34
+ ```
35
+
36
+ `linkPrompt` keeps taking precedence over all three built-in entries (bubble
37
+ input, toolbar panel, KunUI popover), so a host modal is still one override.
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [ab7fbc2]
42
+ - @kungal/editor-core@0.34.0
43
+
3
44
  ## 0.33.0
4
45
 
5
46
  ### 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":"AA0UA,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":"AAkkBA,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 = () => {
@@ -313,13 +314,13 @@ var Pe = [
313
314
  ref: A,
314
315
  "onUpdate:modelValue": n[0] ||= (e) => k.value = e,
315
316
  type: "url",
316
- class: "kun-editor__bubble-input",
317
+ class: "kun-editor__link-input",
317
318
  placeholder: g.value.linkUrl,
318
319
  "aria-label": g.value.linkUrl,
319
320
  spellcheck: "false",
320
321
  autocomplete: "off",
321
322
  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]]),
323
+ }, null, 40, Ze), [[S, k.value]]),
323
324
  a("button", {
324
325
  type: "button",
325
326
  class: "kun-editor__bubble-btn",
@@ -329,7 +330,7 @@ var Pe = [
329
330
  }, [a("span", {
330
331
  class: "kun-editor__icon",
331
332
  innerHTML: x($).check
332
- }, null, 8, Qe)], 40, Ze),
333
+ }, null, 8, $e)], 40, Qe),
333
334
  a("button", {
334
335
  type: "button",
335
336
  class: "kun-editor__bubble-btn",
@@ -339,8 +340,8 @@ var Pe = [
339
340
  }, [a("span", {
340
341
  class: "kun-editor__icon",
341
342
  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", {
343
+ }, null, 8, tt)], 40, et)
344
+ ], 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
345
  key: 1,
345
346
  type: "button",
346
347
  class: "kun-editor__bubble-btn",
@@ -352,9 +353,9 @@ var Pe = [
352
353
  }, [a("span", {
353
354
  class: "kun-editor__icon",
354
355
  innerHTML: t.svg
355
- }, null, 8, rt)], 40, nt))], 64))), 128))], 8, Ye));
356
+ }, null, 8, it)], 40, rt))], 64))), 128))], 8, Xe));
356
357
  }
357
- }), at = /* @__PURE__ */ s({
358
+ }), ot = /* @__PURE__ */ s({
358
359
  __name: "MilkdownEditor",
359
360
  props: {
360
361
  modelValue: {},
@@ -369,15 +370,15 @@ var Pe = [
369
370
  },
370
371
  emits: ["update:modelValue", "update:loading"],
371
372
  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) => {
373
+ 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
374
  let t = L.make().config((t) => {
374
- t.set(z, e), t.set(te, i.modelValue), t.get(re).markdownUpdated((e, t, n) => {
375
+ t.set(B, e), t.set(te, i.modelValue), t.get(ne).markdownUpdated((e, t, n) => {
375
376
  !i.active || s || t === n || (o = t, a("update:modelValue", t));
376
- }), t.update(ne, (e) => ({
377
+ }), t.update(z, (e) => ({
377
378
  ...e,
378
379
  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, {
380
+ })), f && t.set(d.key, { view: u({ component: Je }) }), h && t.set(p.key, { view: u({ component: at }) });
381
+ }).use(ye(i.adapters, i.features, {
381
382
  locale: i.locale,
382
383
  placeholder: i.placeholder,
383
384
  placeholderMode: i.placeholderMode
@@ -388,7 +389,7 @@ var Pe = [
388
389
  if (e === o) return;
389
390
  o = e;
390
391
  let t = g.get();
391
- t && (s = !0, t.action(W(e)), s = !1);
392
+ t && (s = !0, t.action(G(e)), s = !1);
392
393
  }), w(() => i.readonly, () => {
393
394
  g.get()?.action((e) => {
394
395
  let t = e.get(R);
@@ -400,13 +401,13 @@ var Pe = [
400
401
  };
401
402
  return t({
402
403
  insertQuote: (e) => {
403
- g.get()?.action(U(Ce.key, e)), _();
404
+ g.get()?.action(W(Se.key, e)), _();
404
405
  },
405
406
  insertMention: (e) => {
406
- g.get()?.action(U(Se.key, e)), _();
407
+ g.get()?.action(W(xe.key, e)), _();
407
408
  },
408
409
  insertImage: (e) => {
409
- g.get()?.action(U(de.key, {
410
+ g.get()?.action(W(ue.key, {
410
411
  src: e.src,
411
412
  alt: e.alt ?? "",
412
413
  title: e.title ?? ""
@@ -415,7 +416,7 @@ var Pe = [
415
416
  uploadImage: (e) => {
416
417
  let t = i.adapters.uploadImage, n = g.get();
417
418
  !t || !n || n.action((n) => {
418
- De(n.get(R), e, {
419
+ Ee(n.get(R), e, {
419
420
  uploadImage: t,
420
421
  notify: i.adapters.notify,
421
422
  locale: i.locale
@@ -432,28 +433,106 @@ var Pe = [
432
433
  behavior: "smooth",
433
434
  block: "start"
434
435
  }), n.editable)) {
435
- let e = G.near(n.state.doc.resolve(i + 1));
436
+ let e = K.near(n.state.doc.resolve(i + 1));
436
437
  n.dispatch(n.state.tr.setSelection(e)), n.focus();
437
438
  }
438
439
  });
439
440
  }
440
441
  }), (e, t) => (m(), n(x(k)));
441
442
  }
442
- }), ot = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), st = [
443
+ }), st = [
444
+ "title",
445
+ "aria-label",
446
+ "aria-expanded"
447
+ ], ct = ["innerHTML"], lt = { class: "kun-editor__link-panel" }, ut = ["placeholder", "aria-label"], dt = ["title", "aria-label"], ft = ["innerHTML"], pt = /* @__PURE__ */ s({
448
+ __name: "LinkInput",
449
+ setup(e) {
450
+ let [, n] = M(), r = l(X), o = t(() => (r?.locale ?? "zh-cn").toLowerCase().startsWith("en")), s = t(() => {
451
+ let e = o.value;
452
+ return {
453
+ link: e ? "Link" : "链接",
454
+ linkUrl: e ? "Link URL" : "链接 URL",
455
+ apply: e ? "Apply" : "确定"
456
+ };
457
+ }), c = _(!1), d = _(""), h = _(null), g = _(null), v = (e) => {
458
+ e && n()?.action(W(J.key, { href: e }));
459
+ }, y = () => {
460
+ c.value = !1, d.value = "";
461
+ }, b = () => {
462
+ y(), n()?.action((e) => e.get(R).focus());
463
+ }, w = () => {
464
+ v(d.value.trim()), b();
465
+ }, T = async () => {
466
+ let e = r?.adapters.linkPrompt;
467
+ if (e) {
468
+ let t = "";
469
+ n()?.action((e) => {
470
+ let { state: n } = e.get(R), { from: r, to: i } = n.selection;
471
+ t = n.doc.textBetween(r, i, " ");
472
+ }), v((await e({ text: t }))?.trim() ?? "");
473
+ return;
474
+ }
475
+ if (c.value) {
476
+ y();
477
+ return;
478
+ }
479
+ n()?.action((e) => {
480
+ d.value = Ye(e.get(R).state, e);
481
+ }), c.value = !0, await u(), g.value?.focus(), g.value?.select();
482
+ }, k = (e) => {
483
+ c.value && h.value && !h.value.contains(e.target) && y();
484
+ };
485
+ return p(() => document.addEventListener("click", k)), f(() => document.removeEventListener("click", k)), (e, t) => (m(), i("div", {
486
+ ref_key: "rootRef",
487
+ ref: h,
488
+ class: "kun-editor__link"
489
+ }, [a("button", {
490
+ type: "button",
491
+ class: "kun-editor__tool",
492
+ title: s.value.link,
493
+ "aria-label": s.value.link,
494
+ "aria-expanded": c.value,
495
+ onClick: T
496
+ }, [a("span", {
497
+ class: "kun-editor__icon",
498
+ innerHTML: x($).link
499
+ }, null, 8, ct)], 8, st), E(a("div", lt, [E(a("input", {
500
+ ref_key: "inputRef",
501
+ ref: g,
502
+ "onUpdate:modelValue": t[0] ||= (e) => d.value = e,
503
+ type: "url",
504
+ class: "kun-editor__link-input",
505
+ placeholder: s.value.linkUrl,
506
+ "aria-label": s.value.linkUrl,
507
+ spellcheck: "false",
508
+ autocomplete: "off",
509
+ onKeydown: [t[1] ||= D(O((e) => w(), ["prevent"]), ["enter"]), t[2] ||= D(O((e) => b(), ["stop", "prevent"]), ["esc"])]
510
+ }, null, 40, ut), [[S, d.value]]), a("button", {
511
+ type: "button",
512
+ class: "kun-editor__tool",
513
+ title: s.value.apply,
514
+ "aria-label": s.value.apply,
515
+ onClick: t[3] ||= (e) => w()
516
+ }, [a("span", {
517
+ class: "kun-editor__icon",
518
+ innerHTML: x($).check
519
+ }, null, 8, ft)], 8, dt)], 512), [[C, c.value]])], 512));
520
+ }
521
+ }), mt = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), ht = [
443
522
  "title",
444
523
  "aria-label",
445
524
  "aria-expanded"
446
- ], ct = ["innerHTML"], lt = { class: "kun-editor__picker-panel" }, ut = {
525
+ ], gt = ["innerHTML"], _t = { class: "kun-editor__picker-panel" }, vt = {
447
526
  key: 0,
448
527
  class: "kun-editor__picker-tabs",
449
528
  role: "tablist"
450
- }, dt = ["data-active"], ft = ["data-active"], pt = { class: "kun-editor__emoji-grid" }, mt = ["onClick"], ht = {
529
+ }, yt = ["data-active"], bt = ["data-active"], xt = { class: "kun-editor__emoji-grid" }, St = ["onClick"], Ct = {
451
530
  key: 1,
452
531
  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 = {
532
+ }, wt = { class: "kun-editor__pack-name" }, Tt = { class: "kun-editor__sticker-grid" }, Et = ["title", "onClick"], Dt = ["src", "alt"], Ot = {
454
533
  key: 1,
455
534
  class: "kun-editor__picker-hint"
456
- }, xt = /* @__PURE__ */ s({
535
+ }, kt = /* @__PURE__ */ s({
457
536
  __name: "StickerPicker",
458
537
  setup(n) {
459
538
  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 +568,7 @@ var Pe = [
489
568
  n.dispatch(r.tr.insertText(e, r.selection.from));
490
569
  });
491
570
  }, N = (e, t) => {
492
- o()?.action(U(de.key, {
571
+ o()?.action(W(ue.key, {
493
572
  src: e,
494
573
  title: t,
495
574
  alt: t
@@ -509,28 +588,28 @@ var Pe = [
509
588
  }, [a("span", {
510
589
  class: "kun-editor__icon",
511
590
  innerHTML: x($).smile
512
- }, null, 8, ct)], 8, st), E(a("div", lt, [
513
- u ? (m(), i("div", ut, [a("button", {
591
+ }, null, 8, gt)], 8, ht), E(a("div", _t, [
592
+ u ? (m(), i("div", vt, [a("button", {
514
593
  type: "button",
515
594
  class: "kun-editor__picker-tab",
516
595
  "data-active": S.value === "emoji",
517
596
  onClick: n[0] ||= (e) => S.value = "emoji"
518
- }, b(h.value.emoji), 9, dt), a("button", {
597
+ }, b(h.value.emoji), 9, yt), a("button", {
519
598
  type: "button",
520
599
  class: "kun-editor__picker-tab",
521
600
  "data-active": S.value === "sticker",
522
601
  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", {
602
+ }, b(h.value.sticker), 9, bt)])) : r("", !0),
603
+ E(a("div", xt, [(m(!0), i(e, null, v(x(mt), (e, t) => (m(), i("button", {
525
604
  key: t,
526
605
  type: "button",
527
606
  class: "kun-editor__emoji",
528
607
  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", {
608
+ }, b(e), 9, St))), 128))], 512), [[C, !u || S.value === "emoji"]]),
609
+ u ? E((m(), i("div", Ct, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
531
610
  key: t.name,
532
611
  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", {
612
+ }, [a("div", wt, b(t.name), 1), a("div", Tt, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
534
613
  key: t,
535
614
  type: "button",
536
615
  class: "kun-editor__sticker",
@@ -540,44 +619,35 @@ var Pe = [
540
619
  src: e.src,
541
620
  alt: e.name,
542
621
  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)
622
+ }, 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
623
  ], 512), [[C, g.value]])], 512));
545
624
  }
546
- }), St = {
625
+ }), At = {
547
626
  class: "kun-editor__format-toolbar",
548
627
  role: "toolbar"
549
- }, Ct = ["aria-label"], wt = {
628
+ }, jt = ["aria-label"], Mt = {
550
629
  value: "",
551
630
  disabled: "",
552
631
  selected: ""
553
- }, Tt = ["value"], Et = [
632
+ }, Nt = ["value"], Pt = [
554
633
  "title",
555
634
  "aria-label",
556
635
  "aria-pressed",
557
636
  "data-active",
558
637
  "onClick"
559
- ], Dt = ["innerHTML"], Ot = ["title", "aria-label"], kt = ["innerHTML"], At = /* @__PURE__ */ s({
638
+ ], Ft = ["innerHTML"], It = ["title", "aria-label"], Lt = ["innerHTML"], Rt = /* @__PURE__ */ s({
560
639
  __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 });
640
+ setup(s) {
641
+ 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) => {
642
+ c()?.action(W(e, t));
572
643
  }, y = t(() => {
573
- let e = p.value;
644
+ let e = h.value;
574
645
  return {
575
646
  textSize: e ? "Text size" : "文本大小",
576
647
  bold: e ? "Bold" : "加粗",
577
648
  italic: e ? "Italic" : "斜体",
578
649
  strike: e ? "Strikethrough" : "删除线",
579
650
  code: e ? "Inline code" : "行内代码",
580
- link: e ? "Link" : "链接",
581
651
  bulletList: e ? "Bullet list" : "无序列表",
582
652
  orderedList: e ? "Ordered list" : "有序列表",
583
653
  quote: e ? "Blockquote" : "引用块",
@@ -587,7 +657,7 @@ var Pe = [
587
657
  image: e ? "Upload image" : "上传图片"
588
658
  };
589
659
  }), S = t(() => {
590
- let e = p.value;
660
+ let e = h.value;
591
661
  return [
592
662
  "正文",
593
663
  "一级标题",
@@ -602,110 +672,106 @@ var Pe = [
602
672
  }));
603
673
  }), C = (e) => {
604
674
  let t = e.target;
605
- h(Ee.key, Number(t.value)), t.selectedIndex = 0;
675
+ g(Te.key, Number(t.value)), t.selectedIndex = 0;
606
676
  }, w = t(() => [
607
677
  [
608
678
  {
609
679
  svg: $.bold,
610
680
  title: y.value.bold,
611
- run: () => h(ge.key),
681
+ run: () => g(he.key),
612
682
  mark: "bold"
613
683
  },
614
684
  {
615
685
  svg: $.italic,
616
686
  title: y.value.italic,
617
- run: () => h(me.key),
687
+ run: () => g(pe.key),
618
688
  mark: "italic"
619
689
  },
620
690
  {
621
691
  svg: $.strike,
622
692
  title: y.value.strike,
623
- run: () => h(ke.key),
693
+ run: () => g(Oe.key),
624
694
  mark: "strike"
625
695
  },
626
696
  {
627
697
  svg: $.code,
628
698
  title: y.value.code,
629
- run: () => h(he.key),
699
+ run: () => g(me.key),
630
700
  mark: "code"
631
701
  },
632
- {
633
- svg: $.link,
634
- title: y.value.link,
635
- run: g
636
- }
702
+ { link: !0 }
637
703
  ],
638
704
  [
639
705
  {
640
706
  svg: $.bulletList,
641
707
  title: y.value.bulletList,
642
- run: () => h(ve.key)
708
+ run: () => g(_e.key)
643
709
  },
644
710
  {
645
711
  svg: $.orderedList,
646
712
  title: y.value.orderedList,
647
- run: () => h(ye.key)
713
+ run: () => g(ve.key)
648
714
  },
649
715
  {
650
716
  svg: $.quote,
651
717
  title: y.value.quote,
652
- run: () => h(_e.key)
718
+ run: () => g(ge.key)
653
719
  },
654
720
  {
655
721
  svg: $.codeBlock,
656
722
  title: y.value.codeBlock,
657
- run: () => h(K.key, "")
723
+ run: () => g(q.key, "")
658
724
  },
659
725
  {
660
726
  svg: $.hr,
661
727
  title: y.value.hr,
662
- run: () => h(ue.key)
728
+ run: () => g(le.key)
663
729
  }
664
730
  ],
665
731
  [{
666
732
  svg: $.spoiler,
667
733
  title: y.value.spoiler,
668
- run: () => h(xe.key)
734
+ run: () => g(be.key)
669
735
  }]
670
736
  ]), T = _(null), E = () => T.value?.click(), D = (e) => {
671
737
  let t = e.target, n = t.files?.[0];
672
738
  t.value = "";
673
- let r = d.value;
674
- !n || !r || s()?.action((e) => {
675
- De(e.get(R), n, {
739
+ let r = f.value;
740
+ !n || !r || c()?.action((e) => {
741
+ Ee(e.get(R), n, {
676
742
  uploadImage: r,
677
- notify: c?.adapters.notify,
678
- locale: c?.locale
743
+ notify: u?.adapters.notify,
744
+ locale: u?.locale
679
745
  });
680
746
  });
681
747
  };
682
- return (t, n) => (m(), i("div", St, [
748
+ return (t, s) => (m(), i("div", At, [
683
749
  a("select", {
684
750
  class: "kun-editor__heading-select",
685
751
  "aria-label": y.value.textSize,
686
752
  onChange: C
687
- }, [a("option", wt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
753
+ }, [a("option", Mt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
688
754
  key: e.level,
689
755
  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", {
756
+ }, b(e.label), 9, Nt))), 128))], 40, jt),
757
+ (m(!0), i(e, null, v(w.value, (t, r) => (m(), i(e, { key: r }, [s[0] ||= a("span", {
692
758
  class: "kun-editor__toolbar-divider",
693
759
  "aria-hidden": "true"
694
- }, null, -1), (m(!0), i(e, null, v(t, (e, t) => (m(), i("button", {
695
- key: t,
760
+ }, 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", {
761
+ key: 1,
696
762
  type: "button",
697
763
  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()
764
+ title: t.title,
765
+ "aria-label": t.title,
766
+ "aria-pressed": t.mark ? x(d)[t.mark] : void 0,
767
+ "data-active": t.mark ? x(d)[t.mark] : void 0,
768
+ onClick: (e) => t.run()
703
769
  }, [a("span", {
704
770
  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", {
771
+ innerHTML: t.svg
772
+ }, null, 8, Ft)], 8, Pt))], 64))), 128))], 64))), 128)),
773
+ f.value ? (m(), i(e, { key: 0 }, [
774
+ s[1] ||= a("span", {
709
775
  class: "kun-editor__toolbar-divider",
710
776
  "aria-hidden": "true"
711
777
  }, null, -1),
@@ -718,7 +784,7 @@ var Pe = [
718
784
  }, [a("span", {
719
785
  class: "kun-editor__icon",
720
786
  innerHTML: x($).image
721
- }, null, 8, kt)], 8, Ot),
787
+ }, null, 8, Lt)], 8, It),
722
788
  a("input", {
723
789
  ref_key: "fileInput",
724
790
  ref: T,
@@ -728,23 +794,23 @@ var Pe = [
728
794
  onChange: D
729
795
  }, null, 544)
730
796
  ], 64)) : r("", !0),
731
- f.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
797
+ p.value ? (m(), i(e, { key: 1 }, [s[2] ||= a("span", {
732
798
  class: "kun-editor__toolbar-divider",
733
799
  "aria-hidden": "true"
734
- }, null, -1), o(xt)], 64)) : r("", !0)
800
+ }, null, -1), o(kt)], 64)) : r("", !0)
735
801
  ]));
736
802
  }
737
- }), jt = /* @__PURE__ */ s({
803
+ }), zt = /* @__PURE__ */ s({
738
804
  __name: "ToolbarHost",
739
805
  setup(e) {
740
806
  let [, t] = M(), n = l(X, void 0), r = (e, n) => {
741
- t()?.action(U(e, n));
807
+ t()?.action(W(e, n));
742
808
  }, i = () => {
743
809
  t()?.action((e) => e.get(R).focus());
744
810
  }, a = {
745
811
  run: r,
746
812
  get activeMarks() {
747
- return n?.activeMarks ?? Y;
813
+ return n?.activeMarks ?? Ie;
748
814
  },
749
815
  insertText: (e) => {
750
816
  t()?.action((t) => {
@@ -755,7 +821,7 @@ var Pe = [
755
821
  uploadImage: (e) => {
756
822
  let r = n?.adapters.uploadImage, i = t();
757
823
  !r || !i || i.action((t) => {
758
- De(t.get(R), e, {
824
+ Ee(t.get(R), e, {
759
825
  uploadImage: r,
760
826
  notify: n?.adapters.notify,
761
827
  locale: n?.locale
@@ -763,20 +829,20 @@ var Pe = [
763
829
  });
764
830
  },
765
831
  insertLink: (e) => {
766
- r(q.key, e), i();
832
+ r(J.key, e), i();
767
833
  },
768
834
  insertImage: (e) => {
769
- r(de.key, {
835
+ r(ue.key, {
770
836
  src: e.src,
771
837
  alt: e.alt ?? "",
772
838
  title: e.title ?? ""
773
839
  }), i();
774
840
  },
775
841
  insertQuote: (e) => {
776
- r(Ce.key, e), i();
842
+ r(Se.key, e), i();
777
843
  },
778
844
  insertMention: (e) => {
779
- r(Se.key, e), i();
845
+ r(xe.key, e), i();
780
846
  },
781
847
  focus: i,
782
848
  get adapters() {
@@ -791,7 +857,7 @@ var Pe = [
791
857
  };
792
858
  return (e, t) => y(e.$slots, "default", d(c(a)));
793
859
  }
794
- }), Mt = /* @__PURE__ */ s({
860
+ }), Bt = /* @__PURE__ */ s({
795
861
  __name: "MarkdownSource",
796
862
  props: {
797
863
  modelValue: {},
@@ -799,21 +865,21 @@ var Pe = [
799
865
  },
800
866
  emits: ["update:modelValue"],
801
867
  setup(e, { expose: t, emit: n }) {
802
- let r = e, a = n, o = _(null), s = null, c = Ae.define(), l = (e) => je.create({
868
+ let r = e, a = n, o = _(null), s = null, c = ke.define(), l = (e) => Ae.create({
803
869
  doc: e,
804
870
  extensions: [
805
- we(),
806
- J.lineWrapping,
807
- Ne,
808
- Me(),
809
- J.editable.of(!r.readonly),
810
- J.updateListener.of((e) => {
871
+ Ce(),
872
+ Y.lineWrapping,
873
+ Me,
874
+ je(),
875
+ Y.editable.of(!r.readonly),
876
+ Y.updateListener.of((e) => {
811
877
  e.docChanged && !e.transactions.some((e) => e.annotation(c)) && a("update:modelValue", e.state.doc.toString());
812
878
  })
813
879
  ]
814
880
  });
815
881
  p(() => {
816
- o.value && (s = new J({
882
+ o.value && (s = new Y({
817
883
  state: l(r.modelValue),
818
884
  parent: o.value
819
885
  }));
@@ -863,23 +929,23 @@ var Pe = [
863
929
  class: "kun-editor__source"
864
930
  }, null, 512));
865
931
  }
866
- }), Nt = ["data-mode"], Pt = {
932
+ }), Vt = ["data-mode"], Ht = {
867
933
  key: 0,
868
934
  class: "kun-editor__toolbar",
869
935
  role: "tablist"
870
- }, Ft = [
936
+ }, Ut = [
871
937
  "aria-selected",
872
938
  "data-active",
873
939
  "onClick"
874
- ], It = ["title", "aria-label"], Lt = [
940
+ ], Wt = ["title", "aria-label"], Gt = [
875
941
  "data-active",
876
942
  "title",
877
943
  "aria-pressed"
878
- ], Rt = ["data-swap"], zt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Bt = {
944
+ ], Kt = ["data-swap"], qt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Jt = {
879
945
  key: 1,
880
946
  class: "kun-editor__loading",
881
947
  "aria-hidden": "true"
882
- }, Vt = /* @__PURE__ */ s({
948
+ }, Yt = /* @__PURE__ */ s({
883
949
  __name: "KunEditor",
884
950
  props: {
885
951
  modelValue: {},
@@ -926,7 +992,7 @@ var Pe = [
926
992
  M.value = e, k("update:loading", e);
927
993
  };
928
994
  w(() => O.modelValue, (e) => k("update:headings", I(e)), { immediate: !0 });
929
- let P = g(Ie());
995
+ let P = g(Fe());
930
996
  h(X, {
931
997
  get adapters() {
932
998
  return O.adapters;
@@ -950,15 +1016,15 @@ var Pe = [
950
1016
  w(() => O.views, (e) => {
951
1017
  e.includes(L.value) || (L.value = e[0] ?? "wysiwyg");
952
1018
  });
953
- let R = _(!1), ne = () => {
1019
+ let R = _(!1), z = () => {
954
1020
  R.value = !R.value;
955
- }, z = _(O.scrollSync);
1021
+ }, B = _(O.scrollSync);
956
1022
  w(() => O.scrollSync, (e) => {
957
- z.value = e;
1023
+ B.value = e;
958
1024
  });
959
- let re = () => {
960
- z.value = !z.value;
961
- }, ie = t(() => O.locale.toLowerCase().startsWith("en")), B = t(() => ie.value ? {
1025
+ let ne = () => {
1026
+ B.value = !B.value;
1027
+ }, re = t(() => O.locale.toLowerCase().startsWith("en")), V = t(() => re.value ? {
962
1028
  wysiwyg: "Preview",
963
1029
  source: "Markdown",
964
1030
  split: "Split",
@@ -970,103 +1036,103 @@ var Pe = [
970
1036
  split: "分栏",
971
1037
  swap: "左右互换",
972
1038
  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;
1039
+ }), ie = _(null), H = null, U = null, W = null, G = () => {
1040
+ H?.(), H = null, U = null;
1041
+ }, ae = () => {
1042
+ G();
1043
+ let e = ie.value;
978
1044
  if (!e) return;
979
1045
  let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
980
1046
  if (!t || !n) return;
981
1047
  let r = (e, t) => () => {
982
- if (H && H !== e) return;
983
- H = e;
1048
+ if (U && U !== e) return;
1049
+ U = e;
984
1050
  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;
1051
+ t.scrollTop = r * (i > 0 ? i : 0), W && clearTimeout(W), W = setTimeout(() => {
1052
+ U = null;
987
1053
  }, 120);
988
1054
  }, i = r(t, n), a = r(n, t);
989
- t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), V = () => {
1055
+ t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), H = () => {
990
1056
  t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
991
1057
  };
992
1058
  };
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);
1059
+ w([L, B], ([e, t]) => {
1060
+ G(), e === "split" && t && u(ae);
1061
+ }), f(G);
1062
+ let oe = t(() => O.readonly || L.value === "split"), K = (e) => k("update:modelValue", e), q = _(null), se = _(null);
997
1063
  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(),
1064
+ insertQuote: (e) => q.value?.insertQuote(e),
1065
+ insertMention: (e) => q.value?.insertMention(e),
1066
+ insertImage: (e) => q.value?.insertImage(e),
1067
+ uploadImage: (e) => q.value?.uploadImage(e),
1068
+ focus: () => q.value?.focus(),
1003
1069
  scrollToHeading: (e) => {
1004
- L.value === "source" || L.value === "split" ? ce.value?.scrollToHeading(e) : K.value?.scrollToHeading(e);
1070
+ L.value === "source" || L.value === "split" ? se.value?.scrollToHeading(e) : q.value?.scrollToHeading(e);
1005
1071
  }
1006
1072
  }), (t, l) => (m(), i("div", {
1007
1073
  ref_key: "rootEl",
1008
- ref: ae,
1074
+ ref: ie,
1009
1075
  class: "kun-editor",
1010
1076
  "data-kun-editor": "",
1011
1077
  "data-mode": L.value
1012
1078
  }, [j.value ? (m(), i(e, { key: 0 }, [y(t.$slots, "view-switch", {
1013
1079
  mode: L.value,
1014
1080
  setMode: te,
1015
- labels: B.value,
1081
+ labels: V.value,
1016
1082
  views: s.views,
1017
1083
  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", {
1084
+ swap: z,
1085
+ scrollSync: B.value,
1086
+ toggleScrollSync: ne
1087
+ }, () => [s.views.length > 1 ? (m(), i("div", Ht, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
1022
1088
  key: e,
1023
1089
  type: "button",
1024
1090
  class: "kun-editor__tab",
1025
1091
  "aria-selected": L.value === e,
1026
1092
  "data-active": L.value === e,
1027
1093
  onClick: (t) => te(e)
1028
- }, b(B.value[e]), 9, Ft))), 128)), L.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
1094
+ }, b(V.value[e]), 9, Ut))), 128)), L.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
1029
1095
  type: "button",
1030
1096
  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", {
1097
+ title: V.value.swap,
1098
+ "aria-label": V.value.swap,
1099
+ onClick: l[0] ||= (e) => z()
1100
+ }, " ⇄ ", 8, Wt), a("button", {
1035
1101
  type: "button",
1036
1102
  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, {
1103
+ "data-active": B.value,
1104
+ title: V.value.scrollSync,
1105
+ "aria-pressed": B.value,
1106
+ onClick: l[1] ||= (e) => ne()
1107
+ }, b(V.value.scrollSync), 9, Gt)], 64)) : r("", !0)])) : r("", !0)]), o(x(A), null, {
1042
1108
  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)])]),
1109
+ default: T(() => [E(a("div", null, [o(zt, null, {
1110
+ default: T((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(Rt)])]),
1045
1111
  _: 3
1046
1112
  })], 512), [[C, L.value === "wysiwyg" && !s.readonly]]), a("div", {
1047
1113
  class: "kun-editor__panes",
1048
1114
  "data-swap": R.value
1049
- }, [L.value === "source" || L.value === "split" ? (m(), n(Mt, {
1115
+ }, [L.value === "source" || L.value === "split" ? (m(), n(Bt, {
1050
1116
  key: 0,
1051
1117
  ref_key: "source",
1052
- ref: ce,
1118
+ ref: se,
1053
1119
  class: "kun-editor__pane",
1054
1120
  "model-value": s.modelValue,
1055
1121
  readonly: s.readonly,
1056
- "onUpdate:modelValue": G
1057
- }, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", zt, [o(at, {
1122
+ "onUpdate:modelValue": K
1123
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", qt, [o(ot, {
1058
1124
  ref_key: "inner",
1059
- ref: K,
1125
+ ref: q,
1060
1126
  "model-value": s.modelValue,
1061
1127
  adapters: s.adapters,
1062
1128
  features: s.features,
1063
1129
  locale: s.locale,
1064
- readonly: se.value,
1130
+ readonly: oe.value,
1065
1131
  placeholder: s.placeholder,
1066
1132
  "placeholder-mode": s.placeholderMode,
1067
1133
  active: L.value === "wysiwyg" && !s.readonly,
1068
1134
  "selection-toolbar": F.value,
1069
- "onUpdate:modelValue": G,
1135
+ "onUpdate:modelValue": K,
1070
1136
  "onUpdate:loading": ee
1071
1137
  }, null, 8, [
1072
1138
  "model-value",
@@ -1078,18 +1144,18 @@ var Pe = [
1078
1144
  "placeholder-mode",
1079
1145
  "active",
1080
1146
  "selection-toolbar"
1081
- ])], 512), [[C, L.value === "wysiwyg" || L.value === "split"]])], 8, Rt)]),
1147
+ ])], 512), [[C, L.value === "wysiwyg" || L.value === "split"]])], 8, Kt)]),
1082
1148
  _: 3
1083
1149
  })]),
1084
1150
  _: 3
1085
- })], 64)) : r("", !0), !j.value || M.value ? (m(), i("div", Bt, [y(t.$slots, "loading", {}, () => [
1151
+ })], 64)) : r("", !0), !j.value || M.value ? (m(), i("div", Jt, [y(t.$slots, "loading", {}, () => [
1086
1152
  l[2] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
1087
1153
  l[3] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
1088
1154
  l[4] ||= a("div", { class: "kun-editor__skeleton" }, null, -1)
1089
- ])])) : r("", !0)], 8, Nt));
1155
+ ])])) : r("", !0)], 8, Vt));
1090
1156
  }
1091
- }), Ht = { install(e) {
1092
- e.component("KunEditor", Vt);
1157
+ }), Xt = { install(e) {
1158
+ e.component("KunEditor", Yt);
1093
1159
  } };
1094
1160
  //#endregion
1095
- export { ot as EMOJI, Vt as KunEditor, Ht as KunEditorPlugin, F as parseHeadings };
1161
+ 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.34.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.34.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.34.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",