@kungal/editor-vue 0.26.0 → 0.28.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,71 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8d278e5: Make the insert-link URL entry customizable via a `linkPrompt` adapter.
8
+
9
+ The headless toolbar and the selection bubble asked for the link URL with the
10
+ native `window.prompt` (the KunUI toolbar used an inline popover). Hosts can now
11
+ supply their own UI instead — a modal, an article picker, etc.:
12
+
13
+ ```ts
14
+ const adapters = {
15
+ // …uploadImage, notify…
16
+ linkPrompt: async ({ text }) => await openLinkModal(text), // return the URL, or null to cancel
17
+ };
18
+ ```
19
+
20
+ - **editor-core**: new `LinkPrompt` type + `linkPrompt?` on `KunEditorAdapters`.
21
+ It receives the selected text (to prefill / search).
22
+ - **editor-vue**: the default toolbar and the selection bubble use `linkPrompt`
23
+ when supplied, else fall back to `window.prompt`.
24
+ - **editor-nuxt**: when `linkPrompt` is set, `<KunEditorToolbar>`'s link button
25
+ uses it instead of its inline popover — so one override covers every link entry
26
+ point (toolbar, default toolbar, bubble).
27
+
28
+ Verified in the docs production build: with a `linkPrompt` that derives a URL from
29
+ the selected text, the selection bubble inserts
30
+ `[…](https://example.com/search?q=…)` with no native dialog, and the KunUI
31
+ toolbar link becomes a plain button (no popover); 0 console errors.
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [8d278e5]
36
+ - @kungal/editor-core@0.28.0
37
+
38
+ ## 0.27.0
39
+
40
+ ### Minor Changes
41
+
42
+ - ac86c0a: Add a heading-outline API for building a table of contents (TOC).
43
+
44
+ A host (e.g. a desktop editor with a left-side outline) can now render its own TOC
45
+ and navigate the editor, without reaching into editor internals:
46
+
47
+ - **`@update:headings`** on `<KunEditor>` — emits the ordered outline
48
+ (`KunHeading[]` = `{ level, text }`) whenever the content changes.
49
+ - **`ref.scrollToHeading(index)`** — scrolls to that heading in the _current_ view
50
+ and places the caret there: the WYSIWYG heading in wysiwyg mode, the CodeMirror
51
+ heading line in source/split mode (so a click navigates the editable pane).
52
+ - **editor-core** exports the pure `parseHeadings(markdown)` (and `KunHeading`) it's
53
+ built on — usable server-side too. Parses ATX headings, skipping code fences.
54
+
55
+ The TOC's styling, colour, indentation and layout (e.g. reserving space on the
56
+ left of the split editor) are entirely the host's — the editor only exposes the
57
+ data + navigation, matching the headless design.
58
+
59
+ Verified in a new docs example (`/examples/toc`): the outline tracks the content;
60
+ clicking an item scrolls + carets to that heading in wysiwyg (scrollTop 0→386,
61
+ caret in the target) and in source (CodeMirror scrolled, cursor on `## …`); new
62
+ `parseHeadings` unit tests pass; 0 console errors.
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [ac86c0a]
67
+ - @kungal/editor-core@0.27.0
68
+
3
69
  ## 0.26.0
4
70
 
5
71
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAieA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"EditorToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/EditorToolbar.vue"],"names":[],"mappings":"AAufA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,4 +1,4 @@
1
- import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
1
+ import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale, KunHeading } from '@kungal/editor-core';
2
2
  import type { KunEditorExpose, KunSelectionItem } from '../types';
3
3
  type ViewMode = 'wysiwyg' | 'source' | 'split';
4
4
  type __VLS_Props = {
@@ -80,8 +80,10 @@ type __VLS_Slots = {} & {
80
80
  };
81
81
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, KunEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
82
82
  "update:modelValue": (markdown: string) => any;
83
+ "update:headings": (headings: KunHeading[]) => any;
83
84
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
84
85
  "onUpdate:modelValue"?: ((markdown: string) => any) | undefined;
86
+ "onUpdate:headings"?: ((headings: KunHeading[]) => any) | undefined;
85
87
  }>, {
86
88
  adapters: KunEditorAdapters;
87
89
  features: KunEditorFeatures;
@@ -1 +1 @@
1
- {"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AAwWA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAUjE,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE9C,KAAK,WAAW,GAAG;IACf,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,qDAAqD;IACrD,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,KAAK,GAAG,OAAO,CAAA;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;IAClB;oEACgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,gBAAg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ChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -2,7 +2,9 @@ type __VLS_Props = {
2
2
  modelValue: string;
3
3
  readonly: boolean;
4
4
  };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
6
+ scrollToHeading: (index: number) => void;
7
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
8
  "update:modelValue": (markdown: string) => any;
7
9
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
10
  "onUpdate:modelValue"?: ((markdown: string) => any) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownSource.vue.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownSource.vue"],"names":[],"mappings":"AA2GA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AA2FF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"MarkdownSource.vue.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownSource.vue"],"names":[],"mappings":"AAkJA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AAmIF,QAAA,MAAM,YAAY;6BA/Ec,MAAM;;;;;kFAmFpC,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"AAsOA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,KAAK,GAAG,OAAO,CAAA;IAChC,gBAAgB,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB,CAAC;AA+KF,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"AA0QA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,KAAK,GAAG,OAAO,CAAA;IAChC,gBAAgB,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB,CAAC;AAiNF,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AAiTA,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":"AAiUA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export type { KunToolbarItem } from './types';
7
7
  export type { KunSelectionItem } from './types';
8
8
  export type { KunEditorViewSwitchApi } from './types';
9
9
  export { EMOJI } from './emoji';
10
+ export type { KunHeading } from '@kungal/editor-core';
11
+ export { parseHeadings } from '@kungal/editor-core';
10
12
  export type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale, UploadImage, SearchMentionUsers, StickerSource, Notify, NotifyLevel, MentionUser, StickerItem, StickerPack } from '@kungal/editor-core';
11
13
  /** Vue plugin: `app.use(KunEditorPlugin)` to register <KunEditor> globally. */
12
14
  export declare const KunEditorPlugin: Plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,CAAA;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAA;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,MAI7B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,CAAA;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAA;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,MAI7B,CAAA"}
package/dist/index.js CHANGED
@@ -1,37 +1,38 @@
1
1
  import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, guardReactiveProps as c, inject as l, nextTick as u, normalizeProps as d, onBeforeUnmount as f, onMounted as p, openBlock as m, provide as h, ref as g, renderList as _, renderSlot as v, toDisplayString as y, unref as b, vShow as x, watch as S, withCtx as C, withDirectives as w, withModifiers as T } from "vue";
2
2
  import { Milkdown as E, MilkdownProvider as D, useEditor as O, useInstance as k } from "@milkdown/vue";
3
3
  import { ProsemirrorAdapterProvider as A, usePluginViewContext as j, usePluginViewFactory as M } from "@prosemirror-adapter/vue";
4
- import { Editor as N, defaultValueCtx as P, editorViewCtx as F, editorViewOptionsCtx as I, rootCtx as L } from "@milkdown/kit/core";
5
- import { listenerCtx as R } from "@milkdown/kit/plugin/listener";
6
- import { SlashProvider as z, slashFactory as B } from "@milkdown/kit/plugin/slash";
7
- import { TooltipProvider as V, tooltipFactory as H } from "@milkdown/kit/plugin/tooltip";
8
- import { callCommand as U, replaceAll as ee } from "@milkdown/kit/utils";
9
- import { createKunEditorPlugins as te, insertKunSpoilerCommand as W, insertLinkCommand as G, insertMentionCommand as ne, insertQuoteCommand as re, kunCM as ie, mentionId as ae, setHeadingCommand as oe, startImageUpload as K } from "@kungal/editor-core/preset";
10
- import { TextSelection as se } from "@milkdown/kit/prose/state";
11
- import { createCodeBlockCommand as ce, insertHrCommand as le, insertImageCommand as ue, toggleEmphasisCommand as q, toggleInlineCodeCommand as de, toggleStrongCommand as fe, wrapInBlockquoteCommand as pe, wrapInBulletListCommand as me, wrapInOrderedListCommand as he } from "@milkdown/kit/preset/commonmark";
12
- import { toggleStrikethroughCommand as J } from "@milkdown/kit/preset/gfm";
13
- import { Annotation as ge, EditorState as _e } from "@codemirror/state";
4
+ import { parseHeadings as N, parseHeadings as ee } from "@kungal/editor-core";
5
+ import { Editor as P, defaultValueCtx as F, editorViewCtx as I, editorViewOptionsCtx as L, rootCtx as R } from "@milkdown/kit/core";
6
+ import { listenerCtx as z } from "@milkdown/kit/plugin/listener";
7
+ import { SlashProvider as B, slashFactory as V } from "@milkdown/kit/plugin/slash";
8
+ import { TooltipProvider as H, tooltipFactory as U } from "@milkdown/kit/plugin/tooltip";
9
+ import { callCommand as W, replaceAll as te } from "@milkdown/kit/utils";
10
+ import { TextSelection as G } from "@milkdown/kit/prose/state";
11
+ import { createKunEditorPlugins as K, insertKunSpoilerCommand as q, insertLinkCommand as J, insertMentionCommand as ne, insertQuoteCommand as re, kunCM as ie, mentionId as ae, setHeadingCommand as oe, startImageUpload as se } from "@kungal/editor-core/preset";
12
+ import { createCodeBlockCommand as ce, insertHrCommand as le, insertImageCommand as ue, toggleEmphasisCommand as de, toggleInlineCodeCommand as fe, toggleStrongCommand as pe, wrapInBlockquoteCommand as me, wrapInBulletListCommand as he, wrapInOrderedListCommand as ge } from "@milkdown/kit/preset/commonmark";
13
+ import { toggleStrikethroughCommand as _e } from "@milkdown/kit/preset/gfm";
14
+ import { Annotation as ve, EditorState as ye } from "@codemirror/state";
14
15
  import { EditorView as Y } from "@codemirror/view";
15
- import { markdown as ve } from "@codemirror/lang-markdown";
16
- import { basicSetup as ye } from "codemirror";
16
+ import { markdown as be } from "@codemirror/lang-markdown";
17
+ import { basicSetup as xe } from "codemirror";
17
18
  //#region src/context.ts
18
- var X = Symbol("kun-editor-context"), be = [
19
+ var X = Symbol("kun-editor-context"), Se = [
19
20
  "data-active",
20
21
  "onMousedown",
21
22
  "onMouseenter"
22
- ], xe = ["src", "alt"], Se = {
23
+ ], Ce = ["src", "alt"], we = {
23
24
  key: 1,
24
25
  class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
25
- }, Ce = { class: "kun-mention-dropdown__name" }, we = {
26
+ }, Te = { class: "kun-mention-dropdown__name" }, Ee = {
26
27
  key: 1,
27
28
  class: "kun-mention-dropdown__hint"
28
- }, Te = {
29
+ }, De = {
29
30
  key: 2,
30
31
  class: "kun-mention-dropdown__hint"
31
- }, Ee = {
32
+ }, Oe = {
32
33
  key: 3,
33
34
  class: "kun-mention-dropdown__hint"
34
- }, De = /* @__PURE__ */ s({
35
+ }, ke = /* @__PURE__ */ s({
35
36
  __name: "MentionDropdown",
36
37
  setup(n) {
37
38
  let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(X), s = o?.adapters.searchMentionUsers, c = t(() => (o?.locale ?? "zh-cn").toLowerCase().startsWith("en")), u = t(() => c.value ? {
@@ -58,20 +59,20 @@ var X = Symbol("kun-editor-context"), be = [
58
59
  }
59
60
  t === k && (w.value = n ?? [], E.value = 0, D.value = !1);
60
61
  }, 180);
61
- }, P = (e) => {
62
+ }, ee = (e) => {
62
63
  let { selection: t } = e.state;
63
64
  if (!t.empty) return null;
64
65
  let { $from: n } = t, i = n.parent.textBetween(Math.max(0, n.parentOffset - 100), n.parentOffset, void 0, "").match(r);
65
66
  return i ? i[1] ?? "" : null;
66
- }, F = (e) => {
67
- let t = P(e);
67
+ }, P = (e) => {
68
+ let t = ee(e);
68
69
  if (t === null) return !1;
69
70
  let n = e.state.selection.$from.pos;
70
71
  return O = {
71
72
  from: n - (t.length + 1),
72
73
  to: n
73
74
  }, t !== C.value && (C.value = t, N(t)), !0;
74
- }, I = (e) => {
75
+ }, F = (e) => {
75
76
  let t = d.value;
76
77
  if (!t || !O) return;
77
78
  let n = t.state.schema.nodes[ae];
@@ -80,8 +81,8 @@ var X = Symbol("kun-editor-context"), be = [
80
81
  userId: e.id,
81
82
  name: e.name
82
83
  }), { from: i, to: a } = O, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
83
- o.insertText(" ", s), o.setSelection(se.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
84
- }, L = (e) => {
84
+ o.insertText(" ", s), o.setSelection(G.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
85
+ }, I = (e) => {
85
86
  if (!x.value || !w.value.length) {
86
87
  x.value && e.key === "Escape" && (e.preventDefault(), b.hide());
87
88
  return;
@@ -97,7 +98,7 @@ var X = Symbol("kun-editor-context"), be = [
97
98
  case "Enter":
98
99
  case "Tab": {
99
100
  let t = w.value[E.value];
100
- t && (e.preventDefault(), e.stopPropagation(), I(t));
101
+ t && (e.preventDefault(), e.stopPropagation(), F(t));
101
102
  break;
102
103
  }
103
104
  case "Escape":
@@ -106,20 +107,20 @@ var X = Symbol("kun-editor-context"), be = [
106
107
  }
107
108
  };
108
109
  return p(() => {
109
- b = new z({
110
+ b = new B({
110
111
  content: v.value,
111
112
  trigger: "@",
112
- shouldShow: F,
113
+ shouldShow: P,
113
114
  debounce: 0
114
115
  }), b.onShow = () => {
115
116
  x.value = !0;
116
117
  }, b.onHide = () => {
117
118
  x.value = !1, M();
118
- }, b.update(d.value, h.value), window.addEventListener("keydown", L, !0);
119
+ }, b.update(d.value, h.value), window.addEventListener("keydown", I, !0);
119
120
  }), S([d, h], () => {
120
121
  b?.update(d.value, h.value);
121
122
  }), f(() => {
122
- A && clearTimeout(A), window.removeEventListener("keydown", L, !0), b?.destroy();
123
+ A && clearTimeout(A), window.removeEventListener("keydown", I, !0), b?.destroy();
123
124
  }), (t, n) => (m(), i("div", {
124
125
  ref_key: "divRef",
125
126
  ref: v,
@@ -130,14 +131,14 @@ var X = Symbol("kun-editor-context"), be = [
130
131
  type: "button",
131
132
  class: "kun-mention-dropdown__item",
132
133
  "data-active": t === E.value,
133
- onMousedown: T((t) => I(e), ["prevent"]),
134
+ onMousedown: T((t) => F(e), ["prevent"]),
134
135
  onMouseenter: (e) => E.value = t
135
136
  }, [e.avatar ? (m(), i("img", {
136
137
  key: 0,
137
138
  src: e.avatar,
138
139
  alt: e.name,
139
140
  class: "kun-mention-dropdown__avatar"
140
- }, null, 8, xe)) : (m(), i("span", Se, y(e.name.charAt(0)), 1)), a("span", Ce, y(e.name), 1)], 40, be))), 128)) : D.value ? (m(), i("div", we, y(u.value.searching), 1)) : C.value ? (m(), i("div", Te, y(u.value.empty), 1)) : (m(), i("div", Ee, y(u.value.prompt), 1))], 512));
141
+ }, null, 8, Ce)) : (m(), i("span", we, y(e.name.charAt(0)), 1)), a("span", Te, y(e.name), 1)], 40, Se))), 128)) : D.value ? (m(), i("div", Ee, y(u.value.searching), 1)) : C.value ? (m(), i("div", De, y(u.value.empty), 1)) : (m(), i("div", Oe, y(u.value.prompt), 1))], 512));
141
142
  }
142
143
  }), Z = (e) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`, Q = (e, t = 13) => `<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><text x="12" y="12" dominant-baseline="central" text-anchor="middle" font-size="${t}" font-weight="700" font-family="ui-sans-serif, system-ui, sans-serif" fill="currentColor">${e}</text></svg>`, $ = {
143
144
  bold: Z("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
@@ -157,44 +158,47 @@ var X = Symbol("kun-editor-context"), be = [
157
158
  link: Z("<path d=\"M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/>"),
158
159
  latex: Q("Σ", 15),
159
160
  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\"/>")
160
- }, Oe = {
161
+ }, Ae = {
161
162
  key: 0,
162
163
  class: "kun-editor__toolbar-divider",
163
164
  "aria-hidden": "true"
164
- }, ke = [
165
+ }, je = [
165
166
  "title",
166
167
  "aria-label",
167
168
  "onMousedown"
168
- ], Ae = ["innerHTML"], je = /* @__PURE__ */ s({
169
+ ], Me = ["innerHTML"], Ne = /* @__PURE__ */ s({
169
170
  __name: "SelectionTooltip",
170
171
  setup(n) {
171
172
  let { view: r, prevState: o } = j(), [, s] = k(), c = l(X), u = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), d = g(null), h, v = (e, t) => {
172
- s()?.action(U(e, t));
173
- }, y = () => {
174
- let e = window.prompt(u.value ? "Link URL" : "链接 URL")?.trim();
175
- e && v(G.key, { href: e });
173
+ s()?.action(W(e, t));
174
+ }, y = async () => {
175
+ let e = r.value, { from: t, to: n } = e?.state.selection ?? {
176
+ from: 0,
177
+ to: 0
178
+ }, i = e ? e.state.doc.textBetween(t, n, " ") : "", a = c?.adapters.linkPrompt, o = (a ? await a({ text: i }) : window.prompt(u.value ? "Link URL" : "链接 URL"))?.trim();
179
+ o && v(J.key, { href: o });
176
180
  }, b = t(() => {
177
181
  let e = u.value;
178
182
  return {
179
183
  bold: {
180
184
  svg: $.bold,
181
185
  title: e ? "Bold" : "加粗",
182
- run: () => v(fe.key)
186
+ run: () => v(pe.key)
183
187
  },
184
188
  italic: {
185
189
  svg: $.italic,
186
190
  title: e ? "Italic" : "斜体",
187
- run: () => v(q.key)
191
+ run: () => v(de.key)
188
192
  },
189
193
  strike: {
190
194
  svg: $.strike,
191
195
  title: e ? "Strikethrough" : "删除线",
192
- run: () => v(J.key)
196
+ run: () => v(_e.key)
193
197
  },
194
198
  code: {
195
199
  svg: $.code,
196
200
  title: e ? "Inline code" : "行内代码",
197
- run: () => v(de.key)
201
+ run: () => v(fe.key)
198
202
  },
199
203
  link: {
200
204
  svg: $.link,
@@ -218,7 +222,7 @@ var X = Symbol("kun-editor-context"), be = [
218
222
  return n;
219
223
  });
220
224
  return p(() => {
221
- h = new V({
225
+ h = new H({
222
226
  content: d.value,
223
227
  offset: 8
224
228
  }), h.update(r.value, o.value);
@@ -231,7 +235,7 @@ var X = Symbol("kun-editor-context"), be = [
231
235
  ref: d,
232
236
  class: "kun-editor__bubble",
233
237
  "data-show": "false"
234
- }, [(m(!0), i(e, null, _(x.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", Oe)) : (m(), i("button", {
238
+ }, [(m(!0), i(e, null, _(x.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", Ae)) : (m(), i("button", {
235
239
  key: 1,
236
240
  type: "button",
237
241
  class: "kun-editor__bubble-btn",
@@ -241,9 +245,9 @@ var X = Symbol("kun-editor-context"), be = [
241
245
  }, [a("span", {
242
246
  class: "kun-editor__icon",
243
247
  innerHTML: t.svg
244
- }, null, 8, Ae)], 40, ke))], 64))), 128))], 512));
248
+ }, null, 8, Me)], 40, je))], 64))), 128))], 512));
245
249
  }
246
- }), Me = /* @__PURE__ */ s({
250
+ }), Pe = /* @__PURE__ */ s({
247
251
  __name: "MilkdownEditor",
248
252
  props: {
249
253
  modelValue: {},
@@ -258,15 +262,15 @@ var X = Symbol("kun-editor-context"), be = [
258
262
  },
259
263
  emits: ["update:modelValue"],
260
264
  setup(e, { expose: t, emit: r }) {
261
- let i = e, a = r, o = i.modelValue, s = !1, c = M(), l = B("kunMention"), u = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!c, d = H("kunSelectionTooltip"), f = i.selectionToolbar && !!c, p = O((e) => {
262
- let t = N.make().config((t) => {
263
- t.set(L, e), t.set(P, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
265
+ let i = e, a = r, o = i.modelValue, s = !1, c = M(), l = V("kunMention"), u = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!c, d = U("kunSelectionTooltip"), f = i.selectionToolbar && !!c, p = O((e) => {
266
+ let t = P.make().config((t) => {
267
+ t.set(R, e), t.set(F, i.modelValue), t.get(z).markdownUpdated((e, t, n) => {
264
268
  !i.active || s || t === n || (o = t, a("update:modelValue", t));
265
- }), t.update(I, (e) => ({
269
+ }), t.update(L, (e) => ({
266
270
  ...e,
267
271
  editable: () => !i.readonly
268
- })), u && t.set(l.key, { view: c({ component: De }) }), f && t.set(d.key, { view: c({ component: je }) });
269
- }).use(te(i.adapters, i.features, {
272
+ })), u && t.set(l.key, { view: c({ component: ke }) }), f && t.set(d.key, { view: c({ component: Ne }) });
273
+ }).use(K(i.adapters, i.features, {
270
274
  locale: i.locale,
271
275
  placeholder: i.placeholder,
272
276
  placeholderMode: i.placeholderMode
@@ -277,41 +281,55 @@ var X = Symbol("kun-editor-context"), be = [
277
281
  if (e === o) return;
278
282
  o = e;
279
283
  let t = p.get();
280
- t && (s = !0, t.action(ee(e)), s = !1);
284
+ t && (s = !0, t.action(te(e)), s = !1);
281
285
  }), S(() => i.readonly, () => {
282
286
  p.get()?.action((e) => {
283
- let t = e.get(F);
287
+ let t = e.get(I);
284
288
  t.dispatch(t.state.tr);
285
289
  });
286
290
  });
287
291
  let h = () => {
288
- p.get()?.action((e) => e.get(F).focus());
292
+ p.get()?.action((e) => e.get(I).focus());
289
293
  };
290
294
  return t({
291
295
  insertQuote: (e) => {
292
- p.get()?.action(U(re.key, e)), h();
296
+ p.get()?.action(W(re.key, e)), h();
293
297
  },
294
298
  insertMention: (e) => {
295
- p.get()?.action(U(ne.key, e)), h();
299
+ p.get()?.action(W(ne.key, e)), h();
296
300
  },
297
- focus: h
301
+ focus: h,
302
+ scrollToHeading: (e) => {
303
+ p.get()?.action((t) => {
304
+ let n = t.get(I), r = 0, i = -1;
305
+ if (n.state.doc.forEach((t, n) => {
306
+ t.type.name === "heading" && (r === e && (i = n), r += 1);
307
+ }), !(i < 0) && (n.nodeDOM(i)?.scrollIntoView({
308
+ behavior: "smooth",
309
+ block: "start"
310
+ }), n.editable)) {
311
+ let e = G.near(n.state.doc.resolve(i + 1));
312
+ n.dispatch(n.state.tr.setSelection(e)), n.focus();
313
+ }
314
+ });
315
+ }
298
316
  }), (e, t) => (m(), n(b(E)));
299
317
  }
300
- }), Ne = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Pe = [
318
+ }), Fe = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ie = [
301
319
  "title",
302
320
  "aria-label",
303
321
  "aria-expanded"
304
- ], Fe = ["innerHTML"], Ie = { class: "kun-editor__picker-panel" }, Le = {
322
+ ], Le = ["innerHTML"], Re = { class: "kun-editor__picker-panel" }, ze = {
305
323
  key: 0,
306
324
  class: "kun-editor__picker-tabs",
307
325
  role: "tablist"
308
- }, Re = ["data-active"], ze = ["data-active"], Be = { class: "kun-editor__emoji-grid" }, Ve = ["onClick"], He = {
326
+ }, Be = ["data-active"], Ve = ["data-active"], He = { class: "kun-editor__emoji-grid" }, Ue = ["onClick"], We = {
309
327
  key: 1,
310
328
  class: "kun-editor__sticker-body"
311
- }, Ue = { class: "kun-editor__pack-name" }, We = { class: "kun-editor__sticker-grid" }, Ge = ["title", "onClick"], Ke = ["src", "alt"], qe = {
329
+ }, Ge = { class: "kun-editor__pack-name" }, Ke = { class: "kun-editor__sticker-grid" }, qe = ["title", "onClick"], Je = ["src", "alt"], Ye = {
312
330
  key: 1,
313
331
  class: "kun-editor__picker-hint"
314
- }, Je = /* @__PURE__ */ s({
332
+ }, Xe = /* @__PURE__ */ s({
315
333
  __name: "StickerPicker",
316
334
  setup(n) {
317
335
  let [, o] = k(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
@@ -343,11 +361,11 @@ var X = Symbol("kun-editor-context"), be = [
343
361
  p(() => document.addEventListener("click", j)), f(() => document.removeEventListener("click", j));
344
362
  let M = (e) => {
345
363
  o()?.action((t) => {
346
- let n = t.get(F), { state: r } = n;
364
+ let n = t.get(I), { state: r } = n;
347
365
  n.dispatch(r.tr.insertText(e, r.selection.from));
348
366
  });
349
367
  }, N = (e, t) => {
350
- o()?.action(U(ue.key, {
368
+ o()?.action(W(ue.key, {
351
369
  src: e,
352
370
  title: t,
353
371
  alt: t
@@ -367,28 +385,28 @@ var X = Symbol("kun-editor-context"), be = [
367
385
  }, [a("span", {
368
386
  class: "kun-editor__icon",
369
387
  innerHTML: b($).smile
370
- }, null, 8, Fe)], 8, Pe), w(a("div", Ie, [
371
- u ? (m(), i("div", Le, [a("button", {
388
+ }, null, 8, Le)], 8, Ie), w(a("div", Re, [
389
+ u ? (m(), i("div", ze, [a("button", {
372
390
  type: "button",
373
391
  class: "kun-editor__picker-tab",
374
392
  "data-active": C.value === "emoji",
375
393
  onClick: n[0] ||= (e) => C.value = "emoji"
376
- }, y(h.value.emoji), 9, Re), a("button", {
394
+ }, y(h.value.emoji), 9, Be), a("button", {
377
395
  type: "button",
378
396
  class: "kun-editor__picker-tab",
379
397
  "data-active": C.value === "sticker",
380
398
  onClick: n[1] ||= (e) => C.value = "sticker"
381
- }, y(h.value.sticker), 9, ze)])) : r("", !0),
382
- w(a("div", Be, [(m(!0), i(e, null, _(b(Ne), (e, t) => (m(), i("button", {
399
+ }, y(h.value.sticker), 9, Ve)])) : r("", !0),
400
+ w(a("div", He, [(m(!0), i(e, null, _(b(Fe), (e, t) => (m(), i("button", {
383
401
  key: t,
384
402
  type: "button",
385
403
  class: "kun-editor__emoji",
386
404
  onClick: (t) => M(e)
387
- }, y(e), 9, Ve))), 128))], 512), [[x, !u || C.value === "emoji"]]),
388
- u ? w((m(), i("div", He, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
405
+ }, y(e), 9, Ue))), 128))], 512), [[x, !u || C.value === "emoji"]]),
406
+ u ? w((m(), i("div", We, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
389
407
  key: t.name,
390
408
  class: "kun-editor__pack"
391
- }, [a("div", Ue, y(t.name), 1), a("div", We, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
409
+ }, [a("div", Ge, y(t.name), 1), a("div", Ke, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
392
410
  key: t,
393
411
  type: "button",
394
412
  class: "kun-editor__sticker",
@@ -398,28 +416,33 @@ var X = Symbol("kun-editor-context"), be = [
398
416
  src: e.src,
399
417
  alt: e.name,
400
418
  loading: "lazy"
401
- }, null, 8, Ke)], 8, Ge))), 128))])]))), 128)) : (m(), i("div", qe, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
419
+ }, null, 8, Je)], 8, qe))), 128))])]))), 128)) : (m(), i("div", Ye, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
402
420
  ], 512), [[x, v.value]])], 512));
403
421
  }
404
- }), Ye = {
422
+ }), Ze = {
405
423
  class: "kun-editor__format-toolbar",
406
424
  role: "toolbar"
407
- }, Xe = ["aria-label"], Ze = {
425
+ }, Qe = ["aria-label"], $e = {
408
426
  value: "",
409
427
  disabled: "",
410
428
  selected: ""
411
- }, Qe = ["value"], $e = [
429
+ }, et = ["value"], tt = [
412
430
  "title",
413
431
  "aria-label",
414
432
  "onClick"
415
- ], et = ["innerHTML"], tt = ["title", "aria-label"], nt = ["innerHTML"], rt = /* @__PURE__ */ s({
433
+ ], nt = ["innerHTML"], rt = ["title", "aria-label"], it = ["innerHTML"], at = /* @__PURE__ */ s({
416
434
  __name: "EditorToolbar",
417
435
  setup(n) {
418
436
  let [, s] = k(), c = l(X), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), p = (e, t) => {
419
- s()?.action(U(e, t));
420
- }, h = () => {
421
- let e = window.prompt(f.value ? "Link URL" : "链接 URL")?.trim();
422
- e && p(G.key, { href: e });
437
+ s()?.action(W(e, t));
438
+ }, h = async () => {
439
+ let e = "";
440
+ s()?.action((t) => {
441
+ let n = t.get(I), { from: r, to: i } = n.state.selection;
442
+ e = n.state.doc.textBetween(r, i, " ");
443
+ });
444
+ let t = c?.adapters.linkPrompt, n = (t ? await t({ text: e }) : window.prompt(f.value ? "Link URL" : "链接 URL"))?.trim();
445
+ n && p(J.key, { href: n });
423
446
  }, v = t(() => {
424
447
  let e = f.value;
425
448
  return {
@@ -459,22 +482,22 @@ var X = Symbol("kun-editor-context"), be = [
459
482
  {
460
483
  svg: $.bold,
461
484
  title: v.value.bold,
462
- run: () => p(fe.key)
485
+ run: () => p(pe.key)
463
486
  },
464
487
  {
465
488
  svg: $.italic,
466
489
  title: v.value.italic,
467
- run: () => p(q.key)
490
+ run: () => p(de.key)
468
491
  },
469
492
  {
470
493
  svg: $.strike,
471
494
  title: v.value.strike,
472
- run: () => p(J.key)
495
+ run: () => p(_e.key)
473
496
  },
474
497
  {
475
498
  svg: $.code,
476
499
  title: v.value.code,
477
- run: () => p(de.key)
500
+ run: () => p(fe.key)
478
501
  },
479
502
  {
480
503
  svg: $.link,
@@ -486,17 +509,17 @@ var X = Symbol("kun-editor-context"), be = [
486
509
  {
487
510
  svg: $.bulletList,
488
511
  title: v.value.bulletList,
489
- run: () => p(me.key)
512
+ run: () => p(he.key)
490
513
  },
491
514
  {
492
515
  svg: $.orderedList,
493
516
  title: v.value.orderedList,
494
- run: () => p(he.key)
517
+ run: () => p(ge.key)
495
518
  },
496
519
  {
497
520
  svg: $.quote,
498
521
  title: v.value.quote,
499
- run: () => p(pe.key)
522
+ run: () => p(me.key)
500
523
  },
501
524
  {
502
525
  svg: $.codeBlock,
@@ -512,29 +535,29 @@ var X = Symbol("kun-editor-context"), be = [
512
535
  [{
513
536
  svg: $.spoiler,
514
537
  title: v.value.spoiler,
515
- run: () => p(W.key)
538
+ run: () => p(q.key)
516
539
  }]
517
540
  ]), w = g(null), T = () => w.value?.click(), E = (e) => {
518
541
  let t = e.target, n = t.files?.[0];
519
542
  t.value = "";
520
543
  let r = u.value;
521
544
  !n || !r || s()?.action((e) => {
522
- K(e.get(F), n, {
545
+ se(e.get(I), n, {
523
546
  uploadImage: r,
524
547
  notify: c?.adapters.notify,
525
548
  locale: c?.locale
526
549
  });
527
550
  });
528
551
  };
529
- return (t, n) => (m(), i("div", Ye, [
552
+ return (t, n) => (m(), i("div", Ze, [
530
553
  a("select", {
531
554
  class: "kun-editor__heading-select",
532
555
  "aria-label": v.value.textSize,
533
556
  onChange: S
534
- }, [a("option", Ze, y(v.value.textSize), 1), (m(!0), i(e, null, _(x.value, (e) => (m(), i("option", {
557
+ }, [a("option", $e, y(v.value.textSize), 1), (m(!0), i(e, null, _(x.value, (e) => (m(), i("option", {
535
558
  key: e.level,
536
559
  value: e.level
537
- }, y(e.label), 9, Qe))), 128))], 40, Xe),
560
+ }, y(e.label), 9, et))), 128))], 40, Qe),
538
561
  (m(!0), i(e, null, _(C.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
539
562
  class: "kun-editor__toolbar-divider",
540
563
  "aria-hidden": "true"
@@ -548,7 +571,7 @@ var X = Symbol("kun-editor-context"), be = [
548
571
  }, [a("span", {
549
572
  class: "kun-editor__icon",
550
573
  innerHTML: e.svg
551
- }, null, 8, et)], 8, $e))), 128))], 64))), 128)),
574
+ }, null, 8, nt)], 8, tt))), 128))], 64))), 128)),
552
575
  u.value ? (m(), i(e, { key: 0 }, [
553
576
  n[1] ||= a("span", {
554
577
  class: "kun-editor__toolbar-divider",
@@ -563,7 +586,7 @@ var X = Symbol("kun-editor-context"), be = [
563
586
  }, [a("span", {
564
587
  class: "kun-editor__icon",
565
588
  innerHTML: b($).image
566
- }, null, 8, nt)], 8, tt),
589
+ }, null, 8, it)], 8, rt),
567
590
  a("input", {
568
591
  ref_key: "fileInput",
569
592
  ref: w,
@@ -576,28 +599,28 @@ var X = Symbol("kun-editor-context"), be = [
576
599
  d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
577
600
  class: "kun-editor__toolbar-divider",
578
601
  "aria-hidden": "true"
579
- }, null, -1), o(Je)], 64)) : r("", !0)
602
+ }, null, -1), o(Xe)], 64)) : r("", !0)
580
603
  ]));
581
604
  }
582
- }), it = /* @__PURE__ */ s({
605
+ }), ot = /* @__PURE__ */ s({
583
606
  __name: "ToolbarHost",
584
607
  setup(e) {
585
608
  let [, t] = k(), n = l(X, void 0), r = (e, n) => {
586
- t()?.action(U(e, n));
609
+ t()?.action(W(e, n));
587
610
  }, i = () => {
588
- t()?.action((e) => e.get(F).focus());
611
+ t()?.action((e) => e.get(I).focus());
589
612
  }, a = {
590
613
  run: r,
591
614
  insertText: (e) => {
592
615
  t()?.action((t) => {
593
- let n = t.get(F);
616
+ let n = t.get(I);
594
617
  n.dispatch(n.state.tr.insertText(e));
595
618
  }), i();
596
619
  },
597
620
  uploadImage: (e) => {
598
621
  let r = n?.adapters.uploadImage, i = t();
599
622
  !r || !i || i.action((t) => {
600
- K(t.get(F), e, {
623
+ se(t.get(I), e, {
601
624
  uploadImage: r,
602
625
  notify: n?.adapters.notify,
603
626
  locale: n?.locale
@@ -605,7 +628,7 @@ var X = Symbol("kun-editor-context"), be = [
605
628
  });
606
629
  },
607
630
  insertLink: (e) => {
608
- r(G.key, e), i();
631
+ r(J.key, e), i();
609
632
  },
610
633
  insertQuote: (e) => {
611
634
  r(re.key, e), i();
@@ -626,68 +649,91 @@ var X = Symbol("kun-editor-context"), be = [
626
649
  };
627
650
  return (e, t) => v(e.$slots, "default", d(c(a)));
628
651
  }
629
- }), at = /* @__PURE__ */ s({
652
+ }), st = /* @__PURE__ */ s({
630
653
  __name: "MarkdownSource",
631
654
  props: {
632
655
  modelValue: {},
633
656
  readonly: { type: Boolean }
634
657
  },
635
658
  emits: ["update:modelValue"],
636
- setup(e, { emit: t }) {
637
- let n = e, r = t, a = g(null), o = null, s = ge.define(), c = (e) => _e.create({
659
+ setup(e, { expose: t, emit: n }) {
660
+ let r = e, a = n, o = g(null), s = null, c = ve.define(), l = (e) => ye.create({
638
661
  doc: e,
639
662
  extensions: [
640
663
  ie(),
641
664
  Y.lineWrapping,
642
- ye,
643
- ve(),
644
- Y.editable.of(!n.readonly),
665
+ xe,
666
+ be(),
667
+ Y.editable.of(!r.readonly),
645
668
  Y.updateListener.of((e) => {
646
- e.docChanged && !e.transactions.some((e) => e.annotation(s)) && r("update:modelValue", e.state.doc.toString());
669
+ e.docChanged && !e.transactions.some((e) => e.annotation(c)) && a("update:modelValue", e.state.doc.toString());
647
670
  })
648
671
  ]
649
672
  });
650
- return p(() => {
651
- a.value && (o = new Y({
652
- state: c(n.modelValue),
653
- parent: a.value
673
+ p(() => {
674
+ o.value && (s = new Y({
675
+ state: l(r.modelValue),
676
+ parent: o.value
654
677
  }));
655
678
  }), f(() => {
656
- o?.destroy(), o = null;
657
- }), S(() => n.modelValue, (e) => {
658
- if (!o || o.state.doc.toString() === e) return;
659
- let { anchor: t, head: n } = o.state.selection.main, r = e.length;
660
- o.dispatch({
679
+ s?.destroy(), s = null;
680
+ });
681
+ let u = /^\s{0,3}(?:```|~~~)/, d = /^ {0,3}#{1,6}\s+/;
682
+ return t({ scrollToHeading: (e) => {
683
+ if (!s) return;
684
+ let { doc: t } = s.state, n = 0, r = !1, i = -1;
685
+ for (let a = 1; a <= t.lines; a += 1) {
686
+ let o = t.line(a);
687
+ if (u.test(o.text)) {
688
+ r = !r;
689
+ continue;
690
+ }
691
+ if (!r && d.test(o.text)) {
692
+ if (n === e) {
693
+ i = o.from;
694
+ break;
695
+ }
696
+ n += 1;
697
+ }
698
+ }
699
+ i < 0 || (s.dispatch({
700
+ selection: { anchor: i },
701
+ scrollIntoView: !0
702
+ }), s.focus());
703
+ } }), S(() => r.modelValue, (e) => {
704
+ if (!s || s.state.doc.toString() === e) return;
705
+ let { anchor: t, head: n } = s.state.selection.main, r = e.length;
706
+ s.dispatch({
661
707
  changes: {
662
708
  from: 0,
663
- to: o.state.doc.length,
709
+ to: s.state.doc.length,
664
710
  insert: e
665
711
  },
666
712
  selection: {
667
713
  anchor: Math.min(t, r),
668
714
  head: Math.min(n, r)
669
715
  },
670
- annotations: s.of(!0)
716
+ annotations: c.of(!0)
671
717
  });
672
718
  }), (e, t) => (m(), i("div", {
673
719
  ref_key: "host",
674
- ref: a,
720
+ ref: o,
675
721
  class: "kun-editor__source"
676
722
  }, null, 512));
677
723
  }
678
- }), ot = ["data-mode"], st = {
724
+ }), ct = ["data-mode"], lt = {
679
725
  key: 0,
680
726
  class: "kun-editor__toolbar",
681
727
  role: "tablist"
682
- }, ct = [
728
+ }, ut = [
683
729
  "aria-selected",
684
730
  "data-active",
685
731
  "onClick"
686
- ], lt = ["title", "aria-label"], ut = [
732
+ ], dt = ["title", "aria-label"], ft = [
687
733
  "data-active",
688
734
  "title",
689
735
  "aria-pressed"
690
- ], dt = ["data-swap"], ft = { class: "kun-editor__wysiwyg kun-editor__pane" }, pt = /* @__PURE__ */ s({
736
+ ], pt = ["data-swap"], mt = { class: "kun-editor__wysiwyg kun-editor__pane" }, ht = /* @__PURE__ */ s({
691
737
  __name: "KunEditor",
692
738
  props: {
693
739
  modelValue: {},
@@ -714,7 +760,7 @@ var X = Symbol("kun-editor-context"), be = [
714
760
  default: !0
715
761
  }
716
762
  },
717
- emits: ["update:modelValue"],
763
+ emits: ["update:modelValue", "update:headings"],
718
764
  setup(s, { expose: l, emit: p }) {
719
765
  let T = [
720
766
  "bold",
@@ -723,7 +769,7 @@ var X = Symbol("kun-editor-context"), be = [
723
769
  "code",
724
770
  "link"
725
771
  ], E = s, O = p;
726
- h(X, {
772
+ S(() => E.modelValue, (e) => O("update:headings", ee(e)), { immediate: !0 }), h(X, {
727
773
  get adapters() {
728
774
  return E.adapters;
729
775
  },
@@ -765,7 +811,7 @@ var X = Symbol("kun-editor-context"), be = [
765
811
  scrollSync: "同步滚动"
766
812
  }), z = g(null), B = null, V = null, H = null, U = () => {
767
813
  B?.(), B = null, V = null;
768
- }, ee = () => {
814
+ }, W = () => {
769
815
  U();
770
816
  let e = z.value;
771
817
  if (!e) return;
@@ -784,13 +830,16 @@ var X = Symbol("kun-editor-context"), be = [
784
830
  };
785
831
  };
786
832
  S([j, F], ([e, t]) => {
787
- U(), e === "split" && t && u(ee);
833
+ U(), e === "split" && t && u(W);
788
834
  }), f(U);
789
- let te = t(() => E.readonly || j.value === "split"), W = (e) => O("update:modelValue", e), G = g(null);
835
+ let te = t(() => E.readonly || j.value === "split"), G = (e) => O("update:modelValue", e), K = g(null), q = g(null);
790
836
  return l({
791
- insertQuote: (e) => G.value?.insertQuote(e),
792
- insertMention: (e) => G.value?.insertMention(e),
793
- focus: () => G.value?.focus()
837
+ insertQuote: (e) => K.value?.insertQuote(e),
838
+ insertMention: (e) => K.value?.insertMention(e),
839
+ focus: () => K.value?.focus(),
840
+ scrollToHeading: (e) => {
841
+ j.value === "source" || j.value === "split" ? q.value?.scrollToHeading(e) : K.value?.scrollToHeading(e);
842
+ }
794
843
  }), (t, l) => (m(), i("div", {
795
844
  ref_key: "rootEl",
796
845
  ref: z,
@@ -806,43 +855,45 @@ var X = Symbol("kun-editor-context"), be = [
806
855
  swap: P,
807
856
  scrollSync: F.value,
808
857
  toggleScrollSync: I
809
- }, () => [s.views.length > 1 ? (m(), i("div", st, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
858
+ }, () => [s.views.length > 1 ? (m(), i("div", lt, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
810
859
  key: e,
811
860
  type: "button",
812
861
  class: "kun-editor__tab",
813
862
  "aria-selected": j.value === e,
814
863
  "data-active": j.value === e,
815
864
  onClick: (t) => M(e)
816
- }, y(R.value[e]), 9, ct))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
865
+ }, y(R.value[e]), 9, ut))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
817
866
  type: "button",
818
867
  class: "kun-editor__tab kun-editor__swap",
819
868
  title: R.value.swap,
820
869
  "aria-label": R.value.swap,
821
870
  onClick: l[0] ||= (e) => P()
822
- }, " ⇄ ", 8, lt), a("button", {
871
+ }, " ⇄ ", 8, dt), a("button", {
823
872
  type: "button",
824
873
  class: "kun-editor__tab",
825
874
  "data-active": F.value,
826
875
  title: R.value.scrollSync,
827
876
  "aria-pressed": F.value,
828
877
  onClick: l[1] ||= (e) => I()
829
- }, y(R.value.scrollSync), 9, ut)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
878
+ }, y(R.value.scrollSync), 9, ft)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
830
879
  default: C(() => [o(b(A), null, {
831
- default: C(() => [w(a("div", null, [o(it, null, {
832
- default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(rt)])]),
880
+ default: C(() => [w(a("div", null, [o(ot, null, {
881
+ default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(at)])]),
833
882
  _: 3
834
883
  })], 512), [[x, j.value === "wysiwyg" && !s.readonly]]), a("div", {
835
884
  class: "kun-editor__panes",
836
885
  "data-swap": N.value
837
- }, [j.value === "source" || j.value === "split" ? (m(), n(at, {
886
+ }, [j.value === "source" || j.value === "split" ? (m(), n(st, {
838
887
  key: 0,
888
+ ref_key: "source",
889
+ ref: q,
839
890
  class: "kun-editor__pane",
840
891
  "model-value": s.modelValue,
841
892
  readonly: s.readonly,
842
- "onUpdate:modelValue": W
843
- }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ft, [o(Me, {
893
+ "onUpdate:modelValue": G
894
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", mt, [o(Pe, {
844
895
  ref_key: "inner",
845
- ref: G,
896
+ ref: K,
846
897
  "model-value": s.modelValue,
847
898
  adapters: s.adapters,
848
899
  features: s.features,
@@ -852,7 +903,7 @@ var X = Symbol("kun-editor-context"), be = [
852
903
  "placeholder-mode": s.placeholderMode,
853
904
  active: j.value === "wysiwyg" && !s.readonly,
854
905
  "selection-toolbar": k.value,
855
- "onUpdate:modelValue": W
906
+ "onUpdate:modelValue": G
856
907
  }, null, 8, [
857
908
  "model-value",
858
909
  "adapters",
@@ -863,14 +914,14 @@ var X = Symbol("kun-editor-context"), be = [
863
914
  "placeholder-mode",
864
915
  "active",
865
916
  "selection-toolbar"
866
- ])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, dt)]),
917
+ ])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, pt)]),
867
918
  _: 3
868
919
  })]),
869
920
  _: 3
870
- })], 8, ot));
921
+ })], 8, ct));
871
922
  }
872
- }), mt = { install(e) {
873
- e.component("KunEditor", pt);
923
+ }), gt = { install(e) {
924
+ e.component("KunEditor", ht);
874
925
  } };
875
926
  //#endregion
876
- export { Ne as EMOJI, pt as KunEditor, mt as KunEditorPlugin };
927
+ export { Fe as EMOJI, ht as KunEditor, gt as KunEditorPlugin, N as parseHeadings };
package/dist/types.d.ts CHANGED
@@ -83,5 +83,11 @@ export interface KunEditorExpose {
83
83
  }): void;
84
84
  /** Focus the WYSIWYG editor. */
85
85
  focus(): void;
86
+ /**
87
+ * Scroll to the index-th heading (matching the `update:headings` outline order)
88
+ * in the active view, placing the caret there when editable. Powers a
89
+ * host-rendered table of contents.
90
+ */
91
+ scrollToHeading(index: number): void;
86
92
  }
87
93
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAK5B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,GACP,WAAW,GACX,IAAI,GACJ,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,GAAG,CAAA;AAIP,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,GAAG,CAAA;AAMP,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KA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,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAA;IAChB,gDAAgD;IAChD,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAA;IACnB,qCAAqC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B;AASD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC5D;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9D,gCAAgC;IAChC,KAAK,IAAI,IAAI,CAAA;IACb;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-vue",
3
- "version": "0.26.0",
3
+ "version": "0.28.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.26.0"
43
+ "@kungal/editor-core": "0.28.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.26.0"
83
+ "@kungal/editor-core": "0.28.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",