@kungal/editor-vue 0.19.0 → 0.21.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,69 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9556a51: `<KunEditorToolbar>` gains an `items` prop to reorder / subset the buttons.
8
+
9
+ Previously the toolbar's button order was fixed, so a host that wanted a different
10
+ order had to rebuild a whole custom toolbar via the `#toolbar` slot — which drifts
11
+ from the default toolbar used elsewhere (e.g. a topic-edit page vs reply/comment).
12
+
13
+ Now pass `:items` — an ordered `KunToolbarItem[]` (`'heading' | 'bold' | 'italic'
14
+ | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'quote' | 'codeBlock' | 'hr'
15
+ | 'spoiler' | 'image' | 'picker' | '|'`, where `'|'` is a divider):
16
+
17
+ ```vue
18
+ <KunEditorToolbar
19
+ v-bind="api"
20
+ :items="['picker', '|', 'bold', 'italic', '|', 'image', '|', 'heading']"
21
+ />
22
+ ```
23
+
24
+ Apply the same array to every editor for a consistent site-wide order without
25
+ rebuilding a toolbar. Defaults to the standard layout. `image`/`picker` are still
26
+ auto-dropped without their adapter/feature, and dividers collapse around removed
27
+ items. `KunToolbarItem` is exported from `@kungal/editor-vue`.
28
+
29
+ ### Patch Changes
30
+
31
+ - @kungal/editor-core@0.21.0
32
+
33
+ ## 0.20.0
34
+
35
+ ### Minor Changes
36
+
37
+ - 62e14f5: Split view: sync scrolling between the panes, with an off switch.
38
+
39
+ Scrolling the markdown source pane now scrolls the WYSIWYG preview to the same
40
+ position (and vice-versa) — proportional/percentage sync (source↔preview line
41
+ mapping is impractical across two separate renderers), with an active-pane +
42
+ idle-timeout guard so the echoed scroll doesn't feed back into a loop.
43
+
44
+ Turn it off two ways (for downstream customization):
45
+
46
+ - **`scrollSync` prop** on `<KunEditor>` (default `true`) — pass
47
+ `:scroll-sync="false"` to disable entirely.
48
+ - **A runtime toggle** in the view switch: `KunEditorViewSwitchApi` gains
49
+ `scrollSync` / `toggleScrollSync()` (+ `labels.scrollSync`). The default view
50
+ switch shows a 同步滚动 toggle in split mode; `<KunEditorViewSwitch>` (editor-nuxt)
51
+ shows a KunUI link/unlink toggle button. Or replace the whole control via the
52
+ `#view-switch` slot.
53
+
54
+ Sync needs each pane to scroll internally, so the reference `kun-editor.css` now
55
+ gives split panes a bounded height (`--kun-editor-split-height`, default `60vh`,
56
+ overridable) with `overflow: auto`. editor-vue still ships zero CSS.
57
+
58
+ Verified in the docs production build (headless + KunUI view switches): with the
59
+ panes overflowing, scrolling the source drives the preview to the same ratio;
60
+ toggling off makes them scroll independently; toggling on resumes; 0 console
61
+ errors.
62
+
63
+ ### Patch Changes
64
+
65
+ - @kungal/editor-core@0.20.0
66
+
3
67
  ## 0.19.0
4
68
 
5
69
  ### Minor Changes
@@ -13,6 +13,9 @@ type __VLS_Props = {
13
13
  readonly?: boolean;
14
14
  /** Placeholder text shown while the editor is empty. */
15
15
  placeholder?: string;
16
+ /** Sync scrolling between the split panes. Default `true`; set `false` to
17
+ * disable (or toggle it at runtime via the view-switch API). */
18
+ scrollSync?: boolean;
16
19
  };
17
20
  type ViewMode = 'wysiwyg' | 'source' | 'split';
18
21
  declare var __VLS_1: {
@@ -23,9 +26,12 @@ declare var __VLS_1: {
23
26
  source: string;
24
27
  split: string;
25
28
  swap: string;
29
+ scrollSync: string;
26
30
  };
27
31
  swapped: boolean;
28
32
  swap: () => void;
33
+ scrollSync: boolean;
34
+ toggleScrollSync: () => void;
29
35
  }, __VLS_22: {
30
36
  run: <T>(key: import("@milkdown/kit/core").CmdKey<T>, payload?: T) => void;
31
37
  insertText: (text: string) => void;
@@ -58,6 +64,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, KunEditorEx
58
64
  locale: KunEditorLocale;
59
65
  readonly: boolean;
60
66
  placeholder: string;
67
+ scrollSync: boolean;
61
68
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
62
69
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
63
70
  declare const _default: typeof __VLS_export;
@@ -1 +1 @@
1
- {"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AA6NA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,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,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAC;AAqCJ,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAkQ9C,QAAA,IAAI,OAAO;;iBAhQS,QAAQ;;;;;;;;;CAgQP,EAAE,QAAQ;iEAnU/B,CAjNuE;;;;;;;;;;;;;;;CAohBP,CAAE;AAClE,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAClD;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAOhD,QAAA,MAAM,UAAU;;;;;cA1TD,iBAAiB;cAEjB,iBAAiB;YAEnB,eAAe;cAEb,OAAO;iBAEJ,MAAM;6EAuTtB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AA6TA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,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,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;oEACgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC;AAsCJ,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAsW9C,QAAA,IAAI,OAAO;;iBApWS,QAAQ;;;;;;;;;;;;CAoWP,EAAE,QAAQ;iEA3a/B,CAtS+C;;;;;;;;;;;;;;;CAitBiB,CAAE;AAClE,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAClD;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAQhD,QAAA,MAAM,UAAU;;;;;cAnaD,iBAAiB;cAEjB,iBAAiB;YAEnB,eAAe;cAEb,OAAO;iBAEJ,MAAM;gBAGP,OAAO;6EA6ZtB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarHost.vue.d.ts","sourceRoot":"","sources":["../../src/components/ToolbarHost.vue"],"names":[],"mappings":"AAyFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuFhD,QAAA,IAAI,OAAO;oCAxFX,CA9Ee;;;;;;;;;;;;;;;CAsKO,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"ToolbarHost.vue.d.ts","sourceRoot":"","sources":["../../src/components/ToolbarHost.vue"],"names":[],"mappings":"AAyFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuFhD,QAAA,IAAI,OAAO;oCAxFX,CA9DM;;;;;;;;;;;;;;;CAsJgB,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import KunEditor from './components/KunEditor.vue';
3
3
  export { KunEditor };
4
4
  export type { KunEditorExpose } from './types';
5
5
  export type { KunEditorToolbarApi } from './types';
6
+ export type { KunToolbarItem } from './types';
6
7
  export type { KunEditorViewSwitchApi } from './types';
7
8
  export { EMOJI } from './emoji';
8
9
  export type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale, UploadImage, SearchMentionUsers, StickerSource, Notify, NotifyLevel, MentionUser, StickerItem, StickerPack } from '@kungal/editor-core';
@@ -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,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,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"}
package/dist/index.js CHANGED
@@ -1,39 +1,39 @@
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, normalizeProps as u, onBeforeUnmount as d, onMounted as f, openBlock as p, provide as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, vShow as b, watch as x, withCtx as S, withDirectives as C, withModifiers as w } from "vue";
2
- import { Milkdown as T, MilkdownProvider as E, useEditor as D, useInstance as O } from "@milkdown/vue";
3
- import { ProsemirrorAdapterProvider as k, usePluginViewContext as A, usePluginViewFactory as j } from "@prosemirror-adapter/vue";
4
- import { Editor as M, defaultValueCtx as N, editorViewCtx as P, editorViewOptionsCtx as F, rootCtx as I } from "@milkdown/kit/core";
5
- import { listenerCtx as L } from "@milkdown/kit/plugin/listener";
6
- import { SlashProvider as ee, slashFactory as te } from "@milkdown/kit/plugin/slash";
7
- import { callCommand as R, replaceAll as ne } from "@milkdown/kit/utils";
8
- import { createKunEditorPlugins as re, insertKunSpoilerCommand as ie, insertMentionCommand as z, insertQuoteCommand as B, kunCM as ae, mentionId as oe, setHeadingCommand as se, startImageUpload as V } from "@kungal/editor-core/preset";
9
- import { TextSelection as ce } from "@milkdown/kit/prose/state";
10
- import { createCodeBlockCommand as H, insertHrCommand as U, insertImageCommand as W, toggleEmphasisCommand as G, toggleInlineCodeCommand as le, toggleStrongCommand as ue, wrapInBlockquoteCommand as de, wrapInBulletListCommand as fe, wrapInOrderedListCommand as pe } from "@milkdown/kit/preset/commonmark";
11
- import { toggleStrikethroughCommand as me } from "@milkdown/kit/preset/gfm";
12
- import { EditorState as he } from "@codemirror/state";
13
- import { EditorView as K } from "@codemirror/view";
14
- import { markdown as ge } from "@codemirror/lang-markdown";
15
- import { basicSetup as _e } from "codemirror";
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
+ import { Milkdown as E, MilkdownProvider as D, useEditor as O, useInstance as k } from "@milkdown/vue";
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 { callCommand as V, replaceAll as H } from "@milkdown/kit/utils";
8
+ import { createKunEditorPlugins as U, insertKunSpoilerCommand as W, insertMentionCommand as G, insertQuoteCommand as K, kunCM as ee, mentionId as te, setHeadingCommand as ne, startImageUpload as q } from "@kungal/editor-core/preset";
9
+ import { TextSelection as re } from "@milkdown/kit/prose/state";
10
+ import { createCodeBlockCommand as ie, insertHrCommand as ae, insertImageCommand as oe, toggleEmphasisCommand as se, toggleInlineCodeCommand as ce, toggleStrongCommand as le, wrapInBlockquoteCommand as ue, wrapInBulletListCommand as de, wrapInOrderedListCommand as fe } from "@milkdown/kit/preset/commonmark";
11
+ import { toggleStrikethroughCommand as pe } from "@milkdown/kit/preset/gfm";
12
+ import { EditorState as me } from "@codemirror/state";
13
+ import { EditorView as J } from "@codemirror/view";
14
+ import { markdown as he } from "@codemirror/lang-markdown";
15
+ import { basicSetup as ge } from "codemirror";
16
16
  //#region src/context.ts
17
- var q = Symbol("kun-editor-context"), ve = [
17
+ var Y = Symbol("kun-editor-context"), _e = [
18
18
  "data-active",
19
19
  "onMousedown",
20
20
  "onMouseenter"
21
- ], ye = ["src", "alt"], be = {
21
+ ], ve = ["src", "alt"], ye = {
22
22
  key: 1,
23
23
  class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
24
- }, xe = { class: "kun-mention-dropdown__name" }, Se = {
24
+ }, be = { class: "kun-mention-dropdown__name" }, xe = {
25
25
  key: 1,
26
26
  class: "kun-mention-dropdown__hint"
27
- }, Ce = {
27
+ }, Se = {
28
28
  key: 2,
29
29
  class: "kun-mention-dropdown__hint"
30
- }, we = {
30
+ }, Ce = {
31
31
  key: 3,
32
32
  class: "kun-mention-dropdown__hint"
33
- }, Te = /* @__PURE__ */ s({
33
+ }, we = /* @__PURE__ */ s({
34
34
  __name: "MentionDropdown",
35
35
  setup(n) {
36
- let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(q), s = o?.adapters.searchMentionUsers, c = t(() => (o?.locale ?? "zh-cn").toLowerCase().startsWith("en")), u = t(() => c.value ? {
36
+ let r = /(?:^|\s)@([^\s@]{0,30})$/, o = l(Y), s = o?.adapters.searchMentionUsers, c = t(() => (o?.locale ?? "zh-cn").toLowerCase().startsWith("en")), u = t(() => c.value ? {
37
37
  searching: "Searching…",
38
38
  empty: "No matching users",
39
39
  prompt: "Type a username to search"
@@ -41,21 +41,21 @@ var q = Symbol("kun-editor-context"), ve = [
41
41
  searching: "搜索中…",
42
42
  empty: "无匹配用户",
43
43
  prompt: "输入用户名以搜索"
44
- }), { view: m, prevState: _ } = A(), y = h(null), b, S = h(!1), C = h(""), T = h([]), E = h(0), D = h(!1), O = null, k = 0, j = null, M = () => {
45
- j &&= (clearTimeout(j), null), C.value = "", T.value = [], E.value = 0, D.value = !1, O = null;
44
+ }), { view: d, prevState: h } = j(), v = g(null), b, x = g(!1), C = g(""), w = g([]), E = g(0), D = g(!1), O = null, k = 0, A = null, M = () => {
45
+ A &&= (clearTimeout(A), null), C.value = "", w.value = [], E.value = 0, D.value = !1, O = null;
46
46
  }, N = (e) => {
47
- if (j &&= (clearTimeout(j), null), !e || !s) {
48
- T.value = [], D.value = !1;
47
+ if (A &&= (clearTimeout(A), null), !e || !s) {
48
+ w.value = [], D.value = !1;
49
49
  return;
50
50
  }
51
- D.value = !0, j = setTimeout(async () => {
51
+ D.value = !0, A = setTimeout(async () => {
52
52
  let t = ++k, n = [];
53
53
  try {
54
54
  n = await s(e);
55
55
  } catch {
56
56
  n = [];
57
57
  }
58
- t === k && (T.value = n ?? [], E.value = 0, D.value = !1);
58
+ t === k && (w.value = n ?? [], E.value = 0, D.value = !1);
59
59
  }, 180);
60
60
  }, P = (e) => {
61
61
  let { selection: t } = e.state;
@@ -71,21 +71,21 @@ var q = Symbol("kun-editor-context"), ve = [
71
71
  to: n
72
72
  }, t !== C.value && (C.value = t, N(t)), !0;
73
73
  }, I = (e) => {
74
- let t = m.value;
74
+ let t = d.value;
75
75
  if (!t || !O) return;
76
- let n = t.state.schema.nodes[oe];
76
+ let n = t.state.schema.nodes[te];
77
77
  if (!n) return;
78
78
  let r = n.create({
79
79
  userId: e.id,
80
80
  name: e.name
81
81
  }), { from: i, to: a } = O, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
82
- o.insertText(" ", s), o.setSelection(ce.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
82
+ o.insertText(" ", s), o.setSelection(re.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), b.hide();
83
83
  }, L = (e) => {
84
- if (!S.value || !T.value.length) {
85
- S.value && e.key === "Escape" && (e.preventDefault(), b.hide());
84
+ if (!x.value || !w.value.length) {
85
+ x.value && e.key === "Escape" && (e.preventDefault(), b.hide());
86
86
  return;
87
87
  }
88
- let t = T.value.length - 1;
88
+ let t = w.value.length - 1;
89
89
  switch (e.key) {
90
90
  case "ArrowDown":
91
91
  e.preventDefault(), e.stopPropagation(), E.value = E.value >= t ? 0 : E.value + 1;
@@ -95,7 +95,7 @@ var q = Symbol("kun-editor-context"), ve = [
95
95
  break;
96
96
  case "Enter":
97
97
  case "Tab": {
98
- let t = T.value[E.value];
98
+ let t = w.value[E.value];
99
99
  t && (e.preventDefault(), e.stopPropagation(), I(t));
100
100
  break;
101
101
  }
@@ -104,41 +104,41 @@ var q = Symbol("kun-editor-context"), ve = [
104
104
  break;
105
105
  }
106
106
  };
107
- return f(() => {
108
- b = new ee({
109
- content: y.value,
107
+ return p(() => {
108
+ b = new z({
109
+ content: v.value,
110
110
  trigger: "@",
111
111
  shouldShow: F,
112
112
  debounce: 0
113
113
  }), b.onShow = () => {
114
- S.value = !0;
114
+ x.value = !0;
115
115
  }, b.onHide = () => {
116
- S.value = !1, M();
117
- }, b.update(m.value, _.value), window.addEventListener("keydown", L, !0);
118
- }), x([m, _], () => {
119
- b?.update(m.value, _.value);
120
- }), d(() => {
121
- j && clearTimeout(j), window.removeEventListener("keydown", L, !0), b?.destroy();
122
- }), (t, n) => (p(), i("div", {
116
+ x.value = !1, M();
117
+ }, b.update(d.value, h.value), window.addEventListener("keydown", L, !0);
118
+ }), S([d, h], () => {
119
+ b?.update(d.value, h.value);
120
+ }), f(() => {
121
+ A && clearTimeout(A), window.removeEventListener("keydown", L, !0), b?.destroy();
122
+ }), (t, n) => (m(), i("div", {
123
123
  ref_key: "divRef",
124
- ref: y,
124
+ ref: v,
125
125
  class: "kun-mention-dropdown",
126
126
  "data-show": "false"
127
- }, [T.value.length ? (p(!0), i(e, { key: 0 }, g(T.value, (e, t) => (p(), i("button", {
127
+ }, [w.value.length ? (m(!0), i(e, { key: 0 }, _(w.value, (e, t) => (m(), i("button", {
128
128
  key: e.id,
129
129
  type: "button",
130
130
  class: "kun-mention-dropdown__item",
131
131
  "data-active": t === E.value,
132
- onMousedown: w((t) => I(e), ["prevent"]),
132
+ onMousedown: T((t) => I(e), ["prevent"]),
133
133
  onMouseenter: (e) => E.value = t
134
- }, [e.avatar ? (p(), i("img", {
134
+ }, [e.avatar ? (m(), i("img", {
135
135
  key: 0,
136
136
  src: e.avatar,
137
137
  alt: e.name,
138
138
  class: "kun-mention-dropdown__avatar"
139
- }, null, 8, ye)) : (p(), i("span", be, v(e.name.charAt(0)), 1)), a("span", xe, v(e.name), 1)], 40, ve))), 128)) : D.value ? (p(), i("div", Se, v(u.value.searching), 1)) : C.value ? (p(), i("div", Ce, v(u.value.empty), 1)) : (p(), i("div", we, v(u.value.prompt), 1))], 512));
139
+ }, null, 8, ve)) : (m(), i("span", ye, y(e.name.charAt(0)), 1)), a("span", be, y(e.name), 1)], 40, _e))), 128)) : D.value ? (m(), i("div", xe, y(u.value.searching), 1)) : C.value ? (m(), i("div", Se, y(u.value.empty), 1)) : (m(), i("div", Ce, y(u.value.prompt), 1))], 512));
140
140
  }
141
- }), Ee = /* @__PURE__ */ s({
141
+ }), Te = /* @__PURE__ */ s({
142
142
  __name: "MilkdownEditor",
143
143
  props: {
144
144
  modelValue: {},
@@ -150,76 +150,76 @@ var q = Symbol("kun-editor-context"), ve = [
150
150
  },
151
151
  emits: ["update:modelValue"],
152
152
  setup(e, { expose: t, emit: r }) {
153
- let i = e, a = r, o = i.modelValue, s = j(), c = te("kunMention"), l = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!s, u = D((e) => {
154
- let t = M.make().config((t) => {
155
- t.set(I, e), t.set(N, i.modelValue), t.get(L).markdownUpdated((e, t, n) => {
153
+ let i = e, a = r, o = i.modelValue, s = M(), c = B("kunMention"), l = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!s, u = O((e) => {
154
+ let t = N.make().config((t) => {
155
+ t.set(L, e), t.set(P, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
156
156
  t !== n && (o = t, a("update:modelValue", t));
157
- }), t.update(F, (e) => ({
157
+ }), t.update(I, (e) => ({
158
158
  ...e,
159
159
  editable: () => !i.readonly
160
- })), l && t.set(c.key, { view: s({ component: Te }) });
161
- }).use(re(i.adapters, i.features, {
160
+ })), l && t.set(c.key, { view: s({ component: we }) });
161
+ }).use(U(i.adapters, i.features, {
162
162
  locale: i.locale,
163
163
  placeholder: i.placeholder
164
164
  }));
165
165
  return l && t.use(c), t;
166
166
  });
167
- x(() => i.modelValue, (e) => {
168
- e !== o && (o = e, u.get()?.action(ne(e)));
169
- }), x(() => i.readonly, () => {
167
+ S(() => i.modelValue, (e) => {
168
+ e !== o && (o = e, u.get()?.action(H(e)));
169
+ }), S(() => i.readonly, () => {
170
170
  u.get()?.action((e) => {
171
- let t = e.get(P);
171
+ let t = e.get(F);
172
172
  t.dispatch(t.state.tr);
173
173
  });
174
174
  });
175
175
  let d = () => {
176
- u.get()?.action((e) => e.get(P).focus());
176
+ u.get()?.action((e) => e.get(F).focus());
177
177
  };
178
178
  return t({
179
179
  insertQuote: (e) => {
180
- u.get()?.action(R(B.key, e)), d();
180
+ u.get()?.action(V(K.key, e)), d();
181
181
  },
182
182
  insertMention: (e) => {
183
- u.get()?.action(R(z.key, e)), d();
183
+ u.get()?.action(V(G.key, e)), d();
184
184
  },
185
185
  focus: d
186
- }), (e, t) => (p(), n(y(T)));
186
+ }), (e, t) => (m(), n(b(E)));
187
187
  }
188
- }), J = (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>`, Y = (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>`, X = {
189
- bold: J("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
190
- italic: J("<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\"/>"),
191
- strike: J("<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\"/>"),
192
- code: J("<path d=\"m18 16 4-4-4-4\"/><path d=\"m6 8-4 4 4 4\"/><path d=\"m14.5 4-5 16\"/>"),
193
- h1: Y("H1", 11),
194
- h2: Y("H2", 11),
195
- h3: Y("H3", 11),
196
- bulletList: J("<line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><circle cx=\"3.5\" cy=\"6\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3.5\" cy=\"12\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3.5\" cy=\"18\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/>"),
197
- orderedList: J("<line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-1.5 2-2.5S5 14 4 14.5\"/>"),
198
- quote: J("<path d=\"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z\" fill=\"currentColor\" stroke=\"none\"/>"),
199
- codeBlock: J("<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\"/><path d=\"m9 10-2 2 2 2\"/><path d=\"m15 10 2 2-2 2\"/>"),
200
- hr: J("<line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/>"),
201
- image: J("<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"1.8\" fill=\"currentColor\" stroke=\"none\"/><path d=\"m21 15-4.5-4.5a2 2 0 0 0-2.8 0L5 19\"/>"),
202
- spoiler: J("<path d=\"M9.9 4.24A9.1 9.1 0 0 1 12 4c7 0 10 8 10 8a13.2 13.2 0 0 1-1.67 2.68\"/><path d=\"M6.6 6.6A13.5 13.5 0 0 0 2 12s3 8 10 8a9.7 9.7 0 0 0 5.4-1.6\"/><line x1=\"2\" y1=\"2\" x2=\"22\" y2=\"22\"/>"),
203
- latex: Y("Σ", 15),
204
- smile: J("<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\"/>")
205
- }, Z = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), De = [
188
+ }), X = (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>`, Z = (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>`, Q = {
189
+ bold: X("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
190
+ italic: X("<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\"/>"),
191
+ strike: X("<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\"/>"),
192
+ code: X("<path d=\"m18 16 4-4-4-4\"/><path d=\"m6 8-4 4 4 4\"/><path d=\"m14.5 4-5 16\"/>"),
193
+ h1: Z("H1", 11),
194
+ h2: Z("H2", 11),
195
+ h3: Z("H3", 11),
196
+ bulletList: X("<line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><circle cx=\"3.5\" cy=\"6\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3.5\" cy=\"12\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"3.5\" cy=\"18\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/>"),
197
+ orderedList: X("<line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-1.5 2-2.5S5 14 4 14.5\"/>"),
198
+ quote: X("<path d=\"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z\" fill=\"currentColor\" stroke=\"none\"/>"),
199
+ codeBlock: X("<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2\"/><path d=\"m9 10-2 2 2 2\"/><path d=\"m15 10 2 2-2 2\"/>"),
200
+ hr: X("<line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/>"),
201
+ image: X("<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"1.8\" fill=\"currentColor\" stroke=\"none\"/><path d=\"m21 15-4.5-4.5a2 2 0 0 0-2.8 0L5 19\"/>"),
202
+ spoiler: X("<path d=\"M9.9 4.24A9.1 9.1 0 0 1 12 4c7 0 10 8 10 8a13.2 13.2 0 0 1-1.67 2.68\"/><path d=\"M6.6 6.6A13.5 13.5 0 0 0 2 12s3 8 10 8a9.7 9.7 0 0 0 5.4-1.6\"/><line x1=\"2\" y1=\"2\" x2=\"22\" y2=\"22\"/>"),
203
+ latex: Z("Σ", 15),
204
+ smile: X("<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\"/>")
205
+ }, $ = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ee = [
206
206
  "title",
207
207
  "aria-label",
208
208
  "aria-expanded"
209
- ], Oe = ["innerHTML"], ke = { class: "kun-editor__picker-panel" }, Ae = {
209
+ ], De = ["innerHTML"], Oe = { class: "kun-editor__picker-panel" }, ke = {
210
210
  key: 0,
211
211
  class: "kun-editor__picker-tabs",
212
212
  role: "tablist"
213
- }, je = ["data-active"], Me = ["data-active"], Ne = { class: "kun-editor__emoji-grid" }, Pe = ["onClick"], Fe = {
213
+ }, Ae = ["data-active"], je = ["data-active"], Me = { class: "kun-editor__emoji-grid" }, Ne = ["onClick"], Pe = {
214
214
  key: 1,
215
215
  class: "kun-editor__sticker-body"
216
- }, Ie = { class: "kun-editor__pack-name" }, Le = { class: "kun-editor__sticker-grid" }, Re = ["title", "onClick"], ze = ["src", "alt"], Be = {
216
+ }, Fe = { class: "kun-editor__pack-name" }, Ie = { class: "kun-editor__sticker-grid" }, Le = ["title", "onClick"], Re = ["src", "alt"], ze = {
217
217
  key: 1,
218
218
  class: "kun-editor__picker-hint"
219
- }, Ve = /* @__PURE__ */ s({
219
+ }, Be = /* @__PURE__ */ s({
220
220
  __name: "StickerPicker",
221
221
  setup(n) {
222
- let [, o] = O(), s = l(q), c = s?.adapters.stickerSource, u = !!c, m = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), _ = t(() => m.value ? {
222
+ let [, o] = k(), s = l(Y), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
223
223
  trigger: "Emoji & stickers",
224
224
  emoji: "Emoji",
225
225
  sticker: "Stickers",
@@ -231,7 +231,7 @@ var q = Symbol("kun-editor-context"), ve = [
231
231
  sticker: "贴纸",
232
232
  empty: "暂无贴纸",
233
233
  failed: "贴纸加载失败"
234
- }), x = h(!1), S = h(null), w = h("emoji"), T = h([]), E = h(!1), D = h(!1), k = async () => {
234
+ }), v = g(!1), S = g(null), C = g("emoji"), T = g([]), E = g(!1), D = g(!1), O = async () => {
235
235
  if (!(E.value || !c)) {
236
236
  E.value = !0;
237
237
  try {
@@ -241,59 +241,59 @@ var q = Symbol("kun-editor-context"), ve = [
241
241
  }
242
242
  }
243
243
  }, A = () => {
244
- x.value = !x.value, x.value && u && k();
244
+ v.value = !v.value, v.value && u && O();
245
245
  }, j = (e) => {
246
- x.value && S.value && !S.value.contains(e.target) && (x.value = !1);
246
+ v.value && S.value && !S.value.contains(e.target) && (v.value = !1);
247
247
  };
248
- f(() => document.addEventListener("click", j)), d(() => document.removeEventListener("click", j));
248
+ p(() => document.addEventListener("click", j)), f(() => document.removeEventListener("click", j));
249
249
  let M = (e) => {
250
250
  o()?.action((t) => {
251
- let n = t.get(P), { state: r } = n;
251
+ let n = t.get(F), { state: r } = n;
252
252
  n.dispatch(r.tr.insertText(e, r.selection.from));
253
253
  });
254
254
  }, N = (e, t) => {
255
- o()?.action(R(W.key, {
255
+ o()?.action(V(oe.key, {
256
256
  src: e,
257
257
  title: t,
258
258
  alt: t
259
259
  }));
260
260
  };
261
- return (t, n) => (p(), i("div", {
261
+ return (t, n) => (m(), i("div", {
262
262
  ref_key: "rootRef",
263
263
  ref: S,
264
264
  class: "kun-editor__picker"
265
265
  }, [a("button", {
266
266
  type: "button",
267
267
  class: "kun-editor__tool",
268
- title: _.value.trigger,
269
- "aria-label": _.value.trigger,
270
- "aria-expanded": x.value,
268
+ title: h.value.trigger,
269
+ "aria-label": h.value.trigger,
270
+ "aria-expanded": v.value,
271
271
  onClick: A
272
272
  }, [a("span", {
273
273
  class: "kun-editor__icon",
274
- innerHTML: y(X).smile
275
- }, null, 8, Oe)], 8, De), C(a("div", ke, [
276
- u ? (p(), i("div", Ae, [a("button", {
274
+ innerHTML: b(Q).smile
275
+ }, null, 8, De)], 8, Ee), w(a("div", Oe, [
276
+ u ? (m(), i("div", ke, [a("button", {
277
277
  type: "button",
278
278
  class: "kun-editor__picker-tab",
279
- "data-active": w.value === "emoji",
280
- onClick: n[0] ||= (e) => w.value = "emoji"
281
- }, v(_.value.emoji), 9, je), a("button", {
279
+ "data-active": C.value === "emoji",
280
+ onClick: n[0] ||= (e) => C.value = "emoji"
281
+ }, y(h.value.emoji), 9, Ae), a("button", {
282
282
  type: "button",
283
283
  class: "kun-editor__picker-tab",
284
- "data-active": w.value === "sticker",
285
- onClick: n[1] ||= (e) => w.value = "sticker"
286
- }, v(_.value.sticker), 9, Me)])) : r("", !0),
287
- C(a("div", Ne, [(p(!0), i(e, null, g(y(Z), (e, t) => (p(), i("button", {
284
+ "data-active": C.value === "sticker",
285
+ onClick: n[1] ||= (e) => C.value = "sticker"
286
+ }, y(h.value.sticker), 9, je)])) : r("", !0),
287
+ w(a("div", Me, [(m(!0), i(e, null, _(b($), (e, t) => (m(), i("button", {
288
288
  key: t,
289
289
  type: "button",
290
290
  class: "kun-editor__emoji",
291
291
  onClick: (t) => M(e)
292
- }, v(e), 9, Pe))), 128))], 512), [[b, !u || w.value === "emoji"]]),
293
- u ? C((p(), i("div", Fe, [T.value.length ? (p(!0), i(e, { key: 0 }, g(T.value, (t) => (p(), i("div", {
292
+ }, y(e), 9, Ne))), 128))], 512), [[x, !u || C.value === "emoji"]]),
293
+ u ? w((m(), i("div", Pe, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
294
294
  key: t.name,
295
295
  class: "kun-editor__pack"
296
- }, [a("div", Ie, v(t.name), 1), a("div", Le, [(p(!0), i(e, null, g(t.stickers, (e, t) => (p(), i("button", {
296
+ }, [a("div", Fe, y(t.name), 1), a("div", Ie, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
297
297
  key: t,
298
298
  type: "button",
299
299
  class: "kun-editor__sticker",
@@ -303,26 +303,26 @@ var q = Symbol("kun-editor-context"), ve = [
303
303
  src: e.src,
304
304
  alt: e.name,
305
305
  loading: "lazy"
306
- }, null, 8, ze)], 8, Re))), 128))])]))), 128)) : (p(), i("div", Be, v(D.value ? _.value.failed : _.value.empty), 1))], 512)), [[b, w.value === "sticker"]]) : r("", !0)
307
- ], 512), [[b, x.value]])], 512));
306
+ }, null, 8, Re)], 8, Le))), 128))])]))), 128)) : (m(), i("div", ze, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
307
+ ], 512), [[x, v.value]])], 512));
308
308
  }
309
- }), He = {
309
+ }), Ve = {
310
310
  class: "kun-editor__format-toolbar",
311
311
  role: "toolbar"
312
- }, Ue = ["aria-label"], We = {
312
+ }, He = ["aria-label"], Ue = {
313
313
  value: "",
314
314
  disabled: "",
315
315
  selected: ""
316
- }, Ge = ["value"], Ke = [
316
+ }, We = ["value"], Ge = [
317
317
  "title",
318
318
  "aria-label",
319
319
  "onClick"
320
- ], qe = ["innerHTML"], Je = ["title", "aria-label"], Ye = ["innerHTML"], Q = /* @__PURE__ */ s({
320
+ ], Ke = ["innerHTML"], qe = ["title", "aria-label"], Je = ["innerHTML"], Ye = /* @__PURE__ */ s({
321
321
  __name: "EditorToolbar",
322
322
  setup(n) {
323
- let [, s] = O(), c = l(q), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), m = (e, t) => {
324
- s()?.action(R(e, t));
325
- }, _ = t(() => {
323
+ let [, s] = k(), c = l(Y), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), p = (e, t) => {
324
+ s()?.action(V(e, t));
325
+ }, h = t(() => {
326
326
  let e = f.value;
327
327
  return {
328
328
  textSize: e ? "Text size" : "文本大小",
@@ -338,7 +338,7 @@ var q = Symbol("kun-editor-context"), ve = [
338
338
  spoiler: e ? "Spoiler" : "隐藏文本",
339
339
  image: e ? "Upload image" : "上传图片"
340
340
  };
341
- }), b = t(() => {
341
+ }), v = t(() => {
342
342
  let e = f.value;
343
343
  return [
344
344
  "正文",
@@ -354,87 +354,87 @@ var q = Symbol("kun-editor-context"), ve = [
354
354
  }));
355
355
  }), x = (e) => {
356
356
  let t = e.target;
357
- m(se.key, Number(t.value)), t.selectedIndex = 0;
357
+ p(ne.key, Number(t.value)), t.selectedIndex = 0;
358
358
  }, S = t(() => [
359
359
  [
360
360
  {
361
- svg: X.bold,
362
- title: _.value.bold,
363
- run: () => m(ue.key)
361
+ svg: Q.bold,
362
+ title: h.value.bold,
363
+ run: () => p(le.key)
364
364
  },
365
365
  {
366
- svg: X.italic,
367
- title: _.value.italic,
368
- run: () => m(G.key)
366
+ svg: Q.italic,
367
+ title: h.value.italic,
368
+ run: () => p(se.key)
369
369
  },
370
370
  {
371
- svg: X.strike,
372
- title: _.value.strike,
373
- run: () => m(me.key)
371
+ svg: Q.strike,
372
+ title: h.value.strike,
373
+ run: () => p(pe.key)
374
374
  },
375
375
  {
376
- svg: X.code,
377
- title: _.value.code,
378
- run: () => m(le.key)
376
+ svg: Q.code,
377
+ title: h.value.code,
378
+ run: () => p(ce.key)
379
379
  }
380
380
  ],
381
381
  [
382
382
  {
383
- svg: X.bulletList,
384
- title: _.value.bulletList,
385
- run: () => m(fe.key)
383
+ svg: Q.bulletList,
384
+ title: h.value.bulletList,
385
+ run: () => p(de.key)
386
386
  },
387
387
  {
388
- svg: X.orderedList,
389
- title: _.value.orderedList,
390
- run: () => m(pe.key)
388
+ svg: Q.orderedList,
389
+ title: h.value.orderedList,
390
+ run: () => p(fe.key)
391
391
  },
392
392
  {
393
- svg: X.quote,
394
- title: _.value.quote,
395
- run: () => m(de.key)
393
+ svg: Q.quote,
394
+ title: h.value.quote,
395
+ run: () => p(ue.key)
396
396
  },
397
397
  {
398
- svg: X.codeBlock,
399
- title: _.value.codeBlock,
400
- run: () => m(H.key, "")
398
+ svg: Q.codeBlock,
399
+ title: h.value.codeBlock,
400
+ run: () => p(ie.key, "")
401
401
  },
402
402
  {
403
- svg: X.hr,
404
- title: _.value.hr,
405
- run: () => m(U.key)
403
+ svg: Q.hr,
404
+ title: h.value.hr,
405
+ run: () => p(ae.key)
406
406
  }
407
407
  ],
408
408
  [{
409
- svg: X.spoiler,
410
- title: _.value.spoiler,
411
- run: () => m(ie.key)
409
+ svg: Q.spoiler,
410
+ title: h.value.spoiler,
411
+ run: () => p(W.key)
412
412
  }]
413
- ]), C = h(null), w = () => C.value?.click(), T = (e) => {
413
+ ]), C = g(null), w = () => C.value?.click(), T = (e) => {
414
414
  let t = e.target, n = t.files?.[0];
415
415
  t.value = "";
416
416
  let r = u.value;
417
417
  !n || !r || s()?.action((e) => {
418
- V(e.get(P), n, {
418
+ q(e.get(F), n, {
419
419
  uploadImage: r,
420
420
  notify: c?.adapters.notify,
421
421
  locale: c?.locale
422
422
  });
423
423
  });
424
424
  };
425
- return (t, n) => (p(), i("div", He, [
425
+ return (t, n) => (m(), i("div", Ve, [
426
426
  a("select", {
427
427
  class: "kun-editor__heading-select",
428
- "aria-label": _.value.textSize,
428
+ "aria-label": h.value.textSize,
429
429
  onChange: x
430
- }, [a("option", We, v(_.value.textSize), 1), (p(!0), i(e, null, g(b.value, (e) => (p(), i("option", {
430
+ }, [a("option", Ue, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("option", {
431
431
  key: e.level,
432
432
  value: e.level
433
- }, v(e.label), 9, Ge))), 128))], 40, Ue),
434
- (p(!0), i(e, null, g(S.value, (t, r) => (p(), i(e, { key: r }, [n[0] ||= a("span", {
433
+ }, y(e.label), 9, We))), 128))], 40, He),
434
+ (m(!0), i(e, null, _(S.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
435
435
  class: "kun-editor__toolbar-divider",
436
436
  "aria-hidden": "true"
437
- }, null, -1), (p(!0), i(e, null, g(t, (e, t) => (p(), i("button", {
437
+ }, null, -1), (m(!0), i(e, null, _(t, (e, t) => (m(), i("button", {
438
438
  key: t,
439
439
  type: "button",
440
440
  class: "kun-editor__tool",
@@ -444,8 +444,8 @@ var q = Symbol("kun-editor-context"), ve = [
444
444
  }, [a("span", {
445
445
  class: "kun-editor__icon",
446
446
  innerHTML: e.svg
447
- }, null, 8, qe)], 8, Ke))), 128))], 64))), 128)),
448
- u.value ? (p(), i(e, { key: 0 }, [
447
+ }, null, 8, Ke)], 8, Ge))), 128))], 64))), 128)),
448
+ u.value ? (m(), i(e, { key: 0 }, [
449
449
  n[1] ||= a("span", {
450
450
  class: "kun-editor__toolbar-divider",
451
451
  "aria-hidden": "true"
@@ -453,13 +453,13 @@ var q = Symbol("kun-editor-context"), ve = [
453
453
  a("button", {
454
454
  type: "button",
455
455
  class: "kun-editor__tool",
456
- title: _.value.image,
457
- "aria-label": _.value.image,
456
+ title: h.value.image,
457
+ "aria-label": h.value.image,
458
458
  onClick: w
459
459
  }, [a("span", {
460
460
  class: "kun-editor__icon",
461
- innerHTML: y(X).image
462
- }, null, 8, Ye)], 8, Je),
461
+ innerHTML: b(Q).image
462
+ }, null, 8, Je)], 8, qe),
463
463
  a("input", {
464
464
  ref_key: "fileInput",
465
465
  ref: C,
@@ -469,31 +469,31 @@ var q = Symbol("kun-editor-context"), ve = [
469
469
  onChange: T
470
470
  }, null, 544)
471
471
  ], 64)) : r("", !0),
472
- d.value ? (p(), i(e, { key: 1 }, [n[2] ||= a("span", {
472
+ d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
473
473
  class: "kun-editor__toolbar-divider",
474
474
  "aria-hidden": "true"
475
- }, null, -1), o(Ve)], 64)) : r("", !0)
475
+ }, null, -1), o(Be)], 64)) : r("", !0)
476
476
  ]));
477
477
  }
478
478
  }), Xe = /* @__PURE__ */ s({
479
479
  __name: "ToolbarHost",
480
480
  setup(e) {
481
- let [, t] = O(), n = l(q, void 0), r = (e, n) => {
482
- t()?.action(R(e, n));
481
+ let [, t] = k(), n = l(Y, void 0), r = (e, n) => {
482
+ t()?.action(V(e, n));
483
483
  }, i = () => {
484
- t()?.action((e) => e.get(P).focus());
484
+ t()?.action((e) => e.get(F).focus());
485
485
  }, a = {
486
486
  run: r,
487
487
  insertText: (e) => {
488
488
  t()?.action((t) => {
489
- let n = t.get(P);
489
+ let n = t.get(F);
490
490
  n.dispatch(n.state.tr.insertText(e));
491
491
  }), i();
492
492
  },
493
493
  uploadImage: (e) => {
494
494
  let r = n?.adapters.uploadImage, i = t();
495
495
  !r || !i || i.action((t) => {
496
- V(t.get(P), e, {
496
+ q(t.get(F), e, {
497
497
  uploadImage: r,
498
498
  notify: n?.adapters.notify,
499
499
  locale: n?.locale
@@ -501,10 +501,10 @@ var q = Symbol("kun-editor-context"), ve = [
501
501
  });
502
502
  },
503
503
  insertQuote: (e) => {
504
- r(B.key, e), i();
504
+ r(K.key, e), i();
505
505
  },
506
506
  insertMention: (e) => {
507
- r(z.key, e), i();
507
+ r(G.key, e), i();
508
508
  },
509
509
  focus: i,
510
510
  get adapters() {
@@ -517,7 +517,7 @@ var q = Symbol("kun-editor-context"), ve = [
517
517
  return n?.locale ?? "zh-cn";
518
518
  }
519
519
  };
520
- return (e, t) => _(e.$slots, "default", u(c(a)));
520
+ return (e, t) => v(e.$slots, "default", d(c(a)));
521
521
  }
522
522
  }), Ze = /* @__PURE__ */ s({
523
523
  __name: "MarkdownSource",
@@ -527,29 +527,29 @@ var q = Symbol("kun-editor-context"), ve = [
527
527
  },
528
528
  emits: ["update:modelValue"],
529
529
  setup(e, { emit: t }) {
530
- let n = e, r = t, a = h(null), o = null, s = (e) => he.create({
530
+ let n = e, r = t, a = g(null), o = null, s = (e) => me.create({
531
531
  doc: e,
532
532
  extensions: [
533
- ae(),
534
- K.lineWrapping,
535
- _e,
536
- ge(),
537
- K.editable.of(!n.readonly),
538
- K.updateListener.of((e) => {
533
+ ee(),
534
+ J.lineWrapping,
535
+ ge,
536
+ he(),
537
+ J.editable.of(!n.readonly),
538
+ J.updateListener.of((e) => {
539
539
  e.docChanged && r("update:modelValue", e.state.doc.toString());
540
540
  })
541
541
  ]
542
542
  });
543
- return f(() => {
544
- a.value && (o = new K({
543
+ return p(() => {
544
+ a.value && (o = new J({
545
545
  state: s(n.modelValue),
546
546
  parent: a.value
547
547
  }));
548
- }), d(() => {
548
+ }), f(() => {
549
549
  o?.destroy(), o = null;
550
- }), x(() => n.modelValue, (e) => {
550
+ }), S(() => n.modelValue, (e) => {
551
551
  o && o.state.doc.toString() !== e && o.setState(s(e));
552
- }), (e, t) => (p(), i("div", {
552
+ }), (e, t) => (m(), i("div", {
553
553
  ref_key: "host",
554
554
  ref: a,
555
555
  class: "kun-editor__source"
@@ -558,7 +558,11 @@ var q = Symbol("kun-editor-context"), ve = [
558
558
  }), Qe = ["data-mode"], $e = {
559
559
  class: "kun-editor__toolbar",
560
560
  role: "tablist"
561
- }, et = ["aria-selected", "data-active"], tt = ["aria-selected", "data-active"], nt = ["aria-selected", "data-active"], rt = ["title", "aria-label"], it = ["data-swap"], at = { class: "kun-editor__wysiwyg kun-editor__pane" }, $ = /* @__PURE__ */ s({
561
+ }, et = ["aria-selected", "data-active"], tt = ["aria-selected", "data-active"], nt = ["aria-selected", "data-active"], rt = ["title", "aria-label"], it = [
562
+ "data-active",
563
+ "title",
564
+ "aria-pressed"
565
+ ], at = ["data-swap"], ot = { class: "kun-editor__wysiwyg kun-editor__pane" }, st = /* @__PURE__ */ s({
562
566
  __name: "KunEditor",
563
567
  props: {
564
568
  modelValue: {},
@@ -569,105 +573,150 @@ var q = Symbol("kun-editor-context"), ve = [
569
573
  type: Boolean,
570
574
  default: !1
571
575
  },
572
- placeholder: { default: "" }
576
+ placeholder: { default: "" },
577
+ scrollSync: {
578
+ type: Boolean,
579
+ default: !0
580
+ }
573
581
  },
574
582
  emits: ["update:modelValue"],
575
- setup(e, { expose: s, emit: l }) {
576
- let d = e, f = l;
577
- m(q, {
583
+ setup(s, { expose: l, emit: p }) {
584
+ let _ = s, T = p;
585
+ h(Y, {
578
586
  get adapters() {
579
- return d.adapters;
587
+ return _.adapters;
580
588
  },
581
589
  get features() {
582
- return d.features;
590
+ return _.features;
583
591
  },
584
592
  get locale() {
585
- return d.locale;
593
+ return _.locale;
586
594
  }
587
595
  });
588
- let g = h("wysiwyg"), x = (e) => {
589
- g.value = e;
590
- }, w = h(!1), T = () => {
591
- w.value = !w.value;
592
- }, D = t(() => d.locale.toLowerCase().startsWith("en")), O = t(() => D.value ? {
596
+ let E = g("wysiwyg"), O = (e) => {
597
+ E.value = e;
598
+ }, k = g(!1), j = () => {
599
+ k.value = !k.value;
600
+ }, M = g(_.scrollSync);
601
+ S(() => _.scrollSync, (e) => {
602
+ M.value = e;
603
+ });
604
+ let N = () => {
605
+ M.value = !M.value;
606
+ }, P = t(() => _.locale.toLowerCase().startsWith("en")), F = t(() => P.value ? {
593
607
  wysiwyg: "Preview",
594
608
  source: "Markdown",
595
609
  split: "Split",
596
- swap: "Swap sides"
610
+ swap: "Swap sides",
611
+ scrollSync: "Sync scroll"
597
612
  } : {
598
613
  wysiwyg: "预览",
599
614
  source: "Markdown",
600
615
  split: "分栏",
601
- swap: "左右互换"
602
- }), A = t(() => d.readonly || g.value === "split"), j = (e) => f("update:modelValue", e), M = h(null);
603
- return s({
604
- insertQuote: (e) => M.value?.insertQuote(e),
605
- insertMention: (e) => M.value?.insertMention(e),
606
- focus: () => M.value?.focus()
607
- }), (t, s) => (p(), i("div", {
616
+ swap: "左右互换",
617
+ scrollSync: "同步滚动"
618
+ }), I = g(null), L = null, R = null, z = null, B = () => {
619
+ L?.(), L = null, R = null;
620
+ }, V = () => {
621
+ B();
622
+ let e = I.value;
623
+ if (!e) return;
624
+ let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
625
+ if (!t || !n) return;
626
+ let r = (e, t) => () => {
627
+ if (R && R !== e) return;
628
+ R = e;
629
+ let n = e.scrollHeight - e.clientHeight, r = n > 0 ? e.scrollTop / n : 0, i = t.scrollHeight - t.clientHeight;
630
+ t.scrollTop = r * (i > 0 ? i : 0), z && clearTimeout(z), z = setTimeout(() => {
631
+ R = null;
632
+ }, 120);
633
+ }, i = r(t, n), a = r(n, t);
634
+ t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), L = () => {
635
+ t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
636
+ };
637
+ };
638
+ S([E, M], ([e, t]) => {
639
+ B(), e === "split" && t && u(V);
640
+ }), f(B);
641
+ let H = t(() => _.readonly || E.value === "split"), U = (e) => T("update:modelValue", e), W = g(null);
642
+ return l({
643
+ insertQuote: (e) => W.value?.insertQuote(e),
644
+ insertMention: (e) => W.value?.insertMention(e),
645
+ focus: () => W.value?.focus()
646
+ }), (t, l) => (m(), i("div", {
647
+ ref_key: "rootEl",
648
+ ref: I,
608
649
  class: "kun-editor",
609
650
  "data-kun-editor": "",
610
- "data-mode": g.value
611
- }, [_(t.$slots, "view-switch", {
612
- mode: g.value,
613
- setMode: x,
614
- labels: O.value,
615
- swapped: w.value,
616
- swap: T
651
+ "data-mode": E.value
652
+ }, [v(t.$slots, "view-switch", {
653
+ mode: E.value,
654
+ setMode: O,
655
+ labels: F.value,
656
+ swapped: k.value,
657
+ swap: j,
658
+ scrollSync: M.value,
659
+ toggleScrollSync: N
617
660
  }, () => [a("div", $e, [
618
661
  a("button", {
619
662
  type: "button",
620
663
  class: "kun-editor__tab",
621
- "aria-selected": g.value === "wysiwyg",
622
- "data-active": g.value === "wysiwyg",
623
- onClick: s[0] ||= (e) => x("wysiwyg")
624
- }, v(O.value.wysiwyg), 9, et),
664
+ "aria-selected": E.value === "wysiwyg",
665
+ "data-active": E.value === "wysiwyg",
666
+ onClick: l[0] ||= (e) => O("wysiwyg")
667
+ }, y(F.value.wysiwyg), 9, et),
625
668
  a("button", {
626
669
  type: "button",
627
670
  class: "kun-editor__tab",
628
- "aria-selected": g.value === "source",
629
- "data-active": g.value === "source",
630
- onClick: s[1] ||= (e) => x("source")
631
- }, v(O.value.source), 9, tt),
671
+ "aria-selected": E.value === "source",
672
+ "data-active": E.value === "source",
673
+ onClick: l[1] ||= (e) => O("source")
674
+ }, y(F.value.source), 9, tt),
632
675
  a("button", {
633
676
  type: "button",
634
677
  class: "kun-editor__tab",
635
- "aria-selected": g.value === "split",
636
- "data-active": g.value === "split",
637
- onClick: s[2] ||= (e) => x("split")
638
- }, v(O.value.split), 9, nt),
639
- g.value === "split" ? (p(), i("button", {
640
- key: 0,
678
+ "aria-selected": E.value === "split",
679
+ "data-active": E.value === "split",
680
+ onClick: l[2] ||= (e) => O("split")
681
+ }, y(F.value.split), 9, nt),
682
+ E.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
641
683
  type: "button",
642
684
  class: "kun-editor__tab kun-editor__swap",
643
- title: O.value.swap,
644
- "aria-label": O.value.swap,
645
- onClick: s[3] ||= (e) => T()
646
- }, " ⇄ ", 8, rt)) : r("", !0)
647
- ])]), o(y(E), null, {
648
- default: S(() => [o(y(k), null, {
649
- default: S(() => [C(a("div", null, [o(Xe, null, {
650
- default: S((e) => [_(t.$slots, "toolbar", u(c(e)), () => [o(Q)])]),
685
+ title: F.value.swap,
686
+ "aria-label": F.value.swap,
687
+ onClick: l[3] ||= (e) => j()
688
+ }, " ⇄ ", 8, rt), a("button", {
689
+ type: "button",
690
+ class: "kun-editor__tab",
691
+ "data-active": M.value,
692
+ title: F.value.scrollSync,
693
+ "aria-pressed": M.value,
694
+ onClick: l[4] ||= (e) => N()
695
+ }, y(F.value.scrollSync), 9, it)], 64)) : r("", !0)
696
+ ])]), o(b(D), null, {
697
+ default: C(() => [o(b(A), null, {
698
+ default: C(() => [w(a("div", null, [o(Xe, null, {
699
+ default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(Ye)])]),
651
700
  _: 3
652
- })], 512), [[b, g.value === "wysiwyg" && !e.readonly]]), a("div", {
701
+ })], 512), [[x, E.value === "wysiwyg" && !s.readonly]]), a("div", {
653
702
  class: "kun-editor__panes",
654
- "data-swap": w.value
655
- }, [g.value === "source" || g.value === "split" ? (p(), n(Ze, {
703
+ "data-swap": k.value
704
+ }, [E.value === "source" || E.value === "split" ? (m(), n(Ze, {
656
705
  key: 0,
657
706
  class: "kun-editor__pane",
658
- "model-value": e.modelValue,
659
- readonly: e.readonly,
660
- "onUpdate:modelValue": j
661
- }, null, 8, ["model-value", "readonly"])) : r("", !0), C(a("div", at, [o(Ee, {
707
+ "model-value": s.modelValue,
708
+ readonly: s.readonly,
709
+ "onUpdate:modelValue": U
710
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ot, [o(Te, {
662
711
  ref_key: "inner",
663
- ref: M,
664
- "model-value": e.modelValue,
665
- adapters: e.adapters,
666
- features: e.features,
667
- locale: e.locale,
668
- readonly: A.value,
669
- placeholder: e.placeholder,
670
- "onUpdate:modelValue": j
712
+ ref: W,
713
+ "model-value": s.modelValue,
714
+ adapters: s.adapters,
715
+ features: s.features,
716
+ locale: s.locale,
717
+ readonly: H.value,
718
+ placeholder: s.placeholder,
719
+ "onUpdate:modelValue": U
671
720
  }, null, 8, [
672
721
  "model-value",
673
722
  "adapters",
@@ -675,14 +724,14 @@ var q = Symbol("kun-editor-context"), ve = [
675
724
  "locale",
676
725
  "readonly",
677
726
  "placeholder"
678
- ])], 512), [[b, g.value === "wysiwyg" || g.value === "split"]])], 8, it)]),
727
+ ])], 512), [[x, E.value === "wysiwyg" || E.value === "split"]])], 8, at)]),
679
728
  _: 3
680
729
  })]),
681
730
  _: 3
682
731
  })], 8, Qe));
683
732
  }
684
- }), ot = { install(e) {
685
- e.component("KunEditor", $);
733
+ }), ct = { install(e) {
734
+ e.component("KunEditor", st);
686
735
  } };
687
736
  //#endregion
688
- export { Z as EMOJI, $ as KunEditor, ot as KunEditorPlugin };
737
+ export { $ as EMOJI, st as KunEditor, ct as KunEditorPlugin };
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { CmdKey } from '@milkdown/kit/core';
2
2
  import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
3
+ export type KunToolbarItem = 'heading' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'quote' | 'codeBlock' | 'hr' | 'spoiler' | 'image' | 'picker' | '|';
3
4
  export interface KunEditorToolbarApi {
4
5
  /** Run a Milkdown command (import its key from the preset/commonmark/gfm). */
5
6
  run: <T>(key: CmdKey<T>, payload?: T) => void;
@@ -41,11 +42,16 @@ export interface KunEditorViewSwitchApi {
41
42
  source: string;
42
43
  split: string;
43
44
  swap: string;
45
+ scrollSync: string;
44
46
  };
45
47
  /** Whether the split panes are swapped (source on the right). */
46
48
  swapped: boolean;
47
49
  /** Toggle the split panes' left/right order. */
48
50
  swap: () => void;
51
+ /** Whether split-pane scroll sync is on. */
52
+ scrollSync: boolean;
53
+ /** Toggle split-pane scroll sync. */
54
+ toggleScrollSync: () => void;
49
55
  }
50
56
  export interface KunEditorExpose {
51
57
  /**
@@ -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;AAM5B,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC7C,uDAAuD;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC;;;;OAIG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChE,6CAA6C;IAC7C,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAClE,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CACjC;AAMD,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACpC,8BAA8B;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAA;IACvD,qDAAqD;IACrD,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxE,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAA;IAChB,gDAAgD;IAChD,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AASD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC5D;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9D,gCAAgC;IAChC,KAAK,IAAI,IAAI,CAAA;CACd"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAK5B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,GACP,WAAW,GACX,IAAI,GACJ,SAAS,GACT,OAAO,GACP,QAAQ,GACR,GAAG,CAAA;AAMP,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC7C,uDAAuD;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC;;;;OAIG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChE,6CAA6C;IAC7C,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAClE,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CACjC;AAMD,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACpC,8BAA8B;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAA;IACvD,qDAAqD;IACrD,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,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;CACd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-vue",
3
- "version": "0.19.0",
3
+ "version": "0.21.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.19.0"
43
+ "@kungal/editor-core": "0.21.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.19.0"
83
+ "@kungal/editor-core": "0.21.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",