@kungal/editor-vue 0.35.0 → 0.37.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,72 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.37.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a473708: 隐藏文本:选区里的换行不再写出读不回来的 markdown,选区气泡里也有了这颗按钮
8
+
9
+ - **`insertKunSpoilerCommand` 把选区里的换行折成空格。** `||…||` 在每一个读它的地方
10
+ 都只在同一行内配对(这里的 remark 转换、共用同一语法的服务端渲染器),而 commonmark 的
11
+ hardbreak 声明了 `leafText: () => '\n'` —— 所以选中跨行的文字点「隐藏文本」,按钮会写出
12
+ `||第一行\n第二行||`:一段它自己都读不回来、渲染出来是两条光秃秃竖线的 markdown。现在
13
+ `textBetween` 的**两个**分隔符都给 `' '`(块级的本来就是),跨行选区并成一个单行 spoiler。
14
+ - **选区里一个字都没有时返回 `false`**,而不是把选中的东西替换掉 —— 单独选中一张图片点
15
+ 「隐藏文本」不再删图。(选中的是节点、或在代码块里,原本就已经返回 `false`。)
16
+ - **选区气泡工具栏加入 `spoiler`**:`KunSelectionItem` 多一个成员,默认那一排变成
17
+ `bold / italic / strike / code / spoiler / link`。按下态走已有的 `activeMarks.spoiler`,
18
+ 光标在 spoiler 里时按钮点亮、点一下揭示,和固定工具栏完全一致。
19
+ - 顺手把气泡默认按钮表收成**一份** `DEFAULT_SELECTION_ITEMS`(`context.ts`)。原本
20
+ `<KunEditor>` 和气泡各存一份,只改气泡那份等于没改 —— 真实编辑器读的是 context 那份。
21
+
22
+ **跨行剧透不在此列**:`||…||` 是行内语法(schema `inline: true`,mdast 里开闭两个 `||`
23
+ 根本落在不同的 text 节点上),要藏整段多行内容需要的是一个块级容器语法,得全生态(渲染器
24
+ 先行)另行约定,不是把 `||…||` 拉长。
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [a473708]
29
+ - @kungal/editor-core@0.37.0
30
+
31
+ ## 0.36.0
32
+
33
+ ### Minor Changes
34
+
35
+ - f7c65c2: fix(editor): the spoiler toolbar button hides the selection instead of deleting it
36
+
37
+ `insertKunSpoilerCommand` built an EMPTY `kun-spoiler` node and dropped it over
38
+ the selection with `replaceSelectionWith`, so clicking 隐藏文本 with text selected
39
+ deleted the text and left a bare `||||` — and the next thing typed landed
40
+ outside the node, so nothing was hidden either. The JSDoc said "wraps the
41
+ current selection"; the code never wrapped anything.
42
+
43
+ The command now covers the three cases the `||…||` syntax does:
44
+
45
+ - **a selection** → its text moves inside the node. The schema is `marks: ''`
46
+ (inline formatting cannot round-trip through `||…||`), so bold is what's
47
+ dropped, never the words. Selections spanning paragraphs collapse into one
48
+ spoiler; select-all (an `AllSelection`) works too.
49
+ - **an empty selection** → a new spoiler with the caret INSIDE it: type and it
50
+ is hidden. It holds a zero-width caret anchor, because a caret cannot sit in
51
+ an inline node with no text node in it — the serializer strips anchors, and a
52
+ spoiler holding nothing else serializes to nothing, so a stray click cannot
53
+ leave `||||` behind.
54
+ - **the caret already inside a spoiler** → reveal it, leaving the text selected.
55
+ Nesting would have produced `||||text||||`, which reads back as nothing.
56
+
57
+ The button is therefore a toggle, and both toolbars (the headless one and the
58
+ KunUI one in `@kungal/editor-nuxt`) now show it pressed while the caret is
59
+ inside a spoiler — `KunToggleMark` gains a `'spoiler'` member for that, so
60
+ `activeMarks` carries one more key.
61
+
62
+ It returns `false` — no document change — inside a code block and with a node
63
+ selected (an image is not text; replacing it would delete it).
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [f7c65c2]
68
+ - @kungal/editor-core@0.36.0
69
+
3
70
  ## 0.35.0
4
71
 
5
72
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"active-marks.d.ts","sourceRoot":"","sources":["../src/active-marks.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D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CAAA"}
@@ -31,8 +31,9 @@ type __VLS_Props = {
31
31
  scrollSync?: boolean;
32
32
  /**
33
33
  * The floating toolbar shown on text selection. `true` (default) = the
34
- * standard buttons; `false` = off; or pass an ordered `KunSelectionItem[]`
35
- * to reorder / subset them (`'|'` is a divider). Its look is styled via the
34
+ * standard buttons (bold / italic / strike / code / spoiler / link);
35
+ * `false` = off; or pass an ordered `KunSelectionItem[]` to reorder /
36
+ * subset them (`'|'` is a divider). Its look is styled via the
36
37
  * `.kun-editor__bubble` / `.kun-editor__bubble-btn` class hooks.
37
38
  */
38
39
  selectionToolbar?: boolean | KunSelectionItem[];
@@ -1 +1 @@
1
- {"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AA8bA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,UAAU,EACX,MAAM,qBAAqB,CAAA;AAQ5B,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;;;;;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1hBE,MAAM;cART,iBAAiB;cAEjB,iBAAiB;YAEnB,eAAe;cAEb,OAAO;qBAQA,KAAK,GAAG,OAAO;sBAiBd,OAAO,GAAG,gBAAgB,EAAE;WAXvC,QAAQ,EAAE;gBAGL,OAAO;6EAghBtB,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":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AAukBA,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":"AAilBA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarHost.vue.d.ts","sourceRoot":"","sources":["../../src/components/ToolbarHost.vue"],"names":[],"mappings":"AA6GA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AA2GhD,QAAA,IAAI,OAAO;oCA5GX,CAlEiE;;;;;;WAkEjE,CApBE;aAoBF,CApBkB;;;;YAYmD,CAAC;;;;;;;;;;;;;;CAoHhD,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":"AA6GA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AA2GhD,QAAA,IAAI,OAAO;oCA5GX,CA9DkB;;;;;;WAsDZ,CAAC;aAAe,CAAC;;;;YAC+E,CAAC;;;;;;;;;;;;;;CAmHjF,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/context.d.ts CHANGED
@@ -18,4 +18,15 @@ export interface KunEditorContext {
18
18
  readonly activeMarks: Record<KunToggleMark, boolean>;
19
19
  }
20
20
  export declare const KUN_EDITOR_CONTEXT: InjectionKey<KunEditorContext>;
21
+ /**
22
+ * The bubble's default button row — ONE copy, read by <KunEditor> (which puts it
23
+ * on the context) and by the bubble itself (for the no-context case). Two copies
24
+ * drift: adding a button to the bubble's own fallback did nothing at all,
25
+ * because every real editor gets the list from the context.
26
+ *
27
+ * `spoiler` is in it: hiding a selection is the KUN-specific inline action, and
28
+ * the bubble only ever shows on a text selection — exactly the case the command
29
+ * wraps (and, with the caret inside a spoiler, reveals).
30
+ */
31
+ export declare const DEFAULT_SELECTION_ITEMS: KunSelectionItem[];
21
32
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,iFAAiF;IACjF,QAAQ,CAAC,qBAAqB,EAAE,gBAAgB,EAAE,CAAA;IAClD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;CACrD;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,gBAAgB,CAChC,CAAA"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,iFAAiF;IACjF,QAAQ,CAAC,qBAAqB,EAAE,gBAAgB,EAAE,CAAA;IAClD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;CACrD;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,gBAAgB,CAChC,CAAA;AAE9B;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,EAOrD,CAAA"}
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r
2
2
  import { Milkdown as k, MilkdownProvider as A, useEditor as j, useInstance as M } from "@milkdown/vue";
3
3
  import { ProsemirrorAdapterProvider as N, usePluginViewContext as ee, usePluginViewFactory as P } from "@prosemirror-adapter/vue";
4
4
  import { parseHeadings as F, parseHeadings as I } from "@kungal/editor-core";
5
- import { Editor as L, defaultValueCtx as te, editorViewCtx as R, editorViewOptionsCtx as z, rootCtx as B } from "@milkdown/kit/core";
6
- import { listenerCtx as ne } from "@milkdown/kit/plugin/listener";
7
- import { SlashProvider as re, slashFactory as V } from "@milkdown/kit/plugin/slash";
8
- import { TooltipProvider as ie, tooltipFactory as H } from "@milkdown/kit/plugin/tooltip";
9
- import { $prose as U, callCommand as W, replaceAll as G } from "@milkdown/kit/utils";
10
- import { Plugin as ae, PluginKey as oe, TextSelection as K } from "@milkdown/kit/prose/state";
11
- import { createCodeBlockCommand as q, emphasisSchema as se, inlineCodeSchema as ce, insertHrCommand as le, insertImageCommand as ue, linkSchema as de, strongSchema as fe, toggleEmphasisCommand as pe, toggleInlineCodeCommand as me, toggleStrongCommand as he, wrapInBlockquoteCommand as ge, wrapInBulletListCommand as _e, wrapInOrderedListCommand as ve } from "@milkdown/kit/preset/commonmark";
5
+ import { Editor as L, defaultValueCtx as R, editorViewCtx as z, editorViewOptionsCtx as B, rootCtx as V } from "@milkdown/kit/core";
6
+ import { listenerCtx as te } from "@milkdown/kit/plugin/listener";
7
+ import { SlashProvider as H, slashFactory as ne } from "@milkdown/kit/plugin/slash";
8
+ import { TooltipProvider as U, tooltipFactory as W } from "@milkdown/kit/plugin/tooltip";
9
+ import { $prose as G, callCommand as K, replaceAll as re } from "@milkdown/kit/utils";
10
+ import { Plugin as ie, PluginKey as ae, TextSelection as q } from "@milkdown/kit/prose/state";
11
+ import { createCodeBlockCommand as oe, emphasisSchema as se, inlineCodeSchema as ce, insertHrCommand as le, insertImageCommand as ue, linkSchema as de, strongSchema as fe, toggleEmphasisCommand as pe, toggleInlineCodeCommand as me, toggleStrongCommand as he, wrapInBlockquoteCommand as ge, wrapInBulletListCommand as _e, wrapInOrderedListCommand as ve } from "@milkdown/kit/preset/commonmark";
12
12
  import { createKunEditorPlugins as ye, insertKunSpoilerCommand as be, insertLinkCommand as J, insertMentionCommand as xe, insertQuoteCommand as Se, kunCM as Ce, mentionId as we, setHeadingCommand as Te, startImageUpload as Ee } from "@kungal/editor-core/preset";
13
13
  import { strikethroughSchema as De, toggleStrikethroughCommand as Oe } from "@milkdown/kit/preset/gfm";
14
14
  import { Annotation as ke, EditorState as Ae } from "@codemirror/state";
@@ -30,39 +30,53 @@ var Ne = [
30
30
  bold: !1,
31
31
  italic: !1,
32
32
  strike: !1,
33
- code: !1
34
- }), Ie = Object.freeze(Fe()), Le = (e, t) => {
33
+ code: !1,
34
+ spoiler: !1
35
+ }), Ie = Object.freeze(Fe()), Le = (e) => {
36
+ let t = e.schema.nodes["kun-spoiler"];
37
+ if (!t) return !1;
38
+ let { $from: n } = e.selection;
39
+ for (let e = n.depth; e > 0; e--) if (n.node(e).type === t) return !0;
40
+ return !1;
41
+ }, Re = (e, t) => {
35
42
  let { from: n, $from: r, to: i, empty: a } = e.selection, o = Fe();
36
43
  for (let s of Ne) {
37
44
  let c = Pe[s].type(t);
38
45
  o[s] = a ? !!c.isInSet(e.storedMarks ?? r.marks()) : e.doc.rangeHasMark(n, i, c);
39
46
  }
40
- return o;
41
- }, Re = (e, t, n) => {
42
- let r = Le(e, t);
43
- for (let e of Ne) n[e] !== r[e] && (n[e] = r[e]);
44
- }, ze = new oe("KUN_ACTIVE_MARKS"), Be = (e) => U((t) => new ae({
45
- key: ze,
46
- view: (n) => (Re(n.state, t, e), { update(n) {
47
- Re(n.state, t, e);
47
+ return o.spoiler = Le(e), o;
48
+ }, ze = (e, t, n) => {
49
+ let r = Re(e, t);
50
+ for (let e of Object.keys(r)) n[e] !== r[e] && (n[e] = r[e]);
51
+ }, Be = new ae("KUN_ACTIVE_MARKS"), Ve = (e) => G((t) => new ie({
52
+ key: Be,
53
+ view: (n) => (ze(n.state, t, e), { update(n) {
54
+ ze(n.state, t, e);
48
55
  } })
49
- })), X = Symbol("kun-editor-context"), Ve = [
56
+ })), X = Symbol("kun-editor-context"), He = [
57
+ "bold",
58
+ "italic",
59
+ "strike",
60
+ "code",
61
+ "spoiler",
62
+ "link"
63
+ ], Ue = [
50
64
  "data-active",
51
65
  "onMousedown",
52
66
  "onMouseenter"
53
- ], He = ["src", "alt"], Ue = {
67
+ ], We = ["src", "alt"], Ge = {
54
68
  key: 1,
55
69
  class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
56
- }, We = { class: "kun-mention-dropdown__name" }, Ge = {
70
+ }, Ke = { class: "kun-mention-dropdown__name" }, qe = {
57
71
  key: 1,
58
72
  class: "kun-mention-dropdown__hint"
59
- }, Ke = {
73
+ }, Je = {
60
74
  key: 2,
61
75
  class: "kun-mention-dropdown__hint"
62
- }, qe = {
76
+ }, Ye = {
63
77
  key: 3,
64
78
  class: "kun-mention-dropdown__hint"
65
- }, Je = /* @__PURE__ */ s({
79
+ }, Xe = /* @__PURE__ */ s({
66
80
  __name: "MentionDropdown",
67
81
  setup(n) {
68
82
  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 ? {
@@ -111,7 +125,7 @@ var Ne = [
111
125
  userId: e.id,
112
126
  name: e.name
113
127
  }), { from: i, to: a } = D, o = t.state.tr.replaceWith(i, a, r), s = i + r.nodeSize;
114
- o.insertText(" ", s), o.setSelection(K.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), y.hide();
128
+ o.insertText(" ", s), o.setSelection(q.create(o.doc, s + 1)), t.dispatch(o.scrollIntoView()), t.focus(), y.hide();
115
129
  }, I = (e) => {
116
130
  if (!x.value || !C.value.length) {
117
131
  x.value && e.key === "Escape" && (e.preventDefault(), y.hide());
@@ -137,7 +151,7 @@ var Ne = [
137
151
  }
138
152
  };
139
153
  return p(() => {
140
- y = new re({
154
+ y = new H({
141
155
  content: g.value,
142
156
  trigger: "@",
143
157
  shouldShow: P,
@@ -168,9 +182,9 @@ var Ne = [
168
182
  src: e.avatar,
169
183
  alt: e.name,
170
184
  class: "kun-mention-dropdown__avatar"
171
- }, null, 8, He)) : (m(), i("span", Ue, b(e.name.charAt(0)), 1)), a("span", We, b(e.name), 1)], 40, Ve))), 128)) : E.value ? (m(), i("div", Ge, b(u.value.searching), 1)) : S.value ? (m(), i("div", Ke, b(u.value.empty), 1)) : (m(), i("div", qe, b(u.value.prompt), 1))], 512));
185
+ }, null, 8, We)) : (m(), i("span", Ge, b(e.name.charAt(0)), 1)), a("span", Ke, b(e.name), 1)], 40, Ue))), 128)) : E.value ? (m(), i("div", qe, b(u.value.searching), 1)) : S.value ? (m(), i("div", Je, b(u.value.empty), 1)) : (m(), i("div", Ye, b(u.value.prompt), 1))], 512));
172
186
  }
173
- }), Ye = (e, t) => {
187
+ }), Ze = (e, t) => {
174
188
  let n = de.type(t), { from: r, to: i } = e.selection, a = "";
175
189
  return e.doc.nodesBetween(r, i, (e) => {
176
190
  if (a) return !1;
@@ -197,17 +211,17 @@ var Ne = [
197
211
  check: Z("<path d=\"m5 13 4 4L19 7\"/>"),
198
212
  close: Z("<line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/>"),
199
213
  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\"/>")
200
- }, Xe = ["data-mode"], Ze = ["placeholder", "aria-label"], Qe = ["title", "aria-label"], $e = ["innerHTML"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = {
214
+ }, Qe = ["data-mode"], $e = ["placeholder", "aria-label"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = ["title", "aria-label"], rt = ["innerHTML"], it = {
201
215
  key: 0,
202
216
  class: "kun-editor__toolbar-divider",
203
217
  "aria-hidden": "true"
204
- }, rt = [
218
+ }, at = [
205
219
  "title",
206
220
  "aria-label",
207
221
  "aria-pressed",
208
222
  "data-active",
209
223
  "onMousedown"
210
- ], it = ["innerHTML"], at = /* @__PURE__ */ s({
224
+ ], ot = ["innerHTML"], st = /* @__PURE__ */ s({
211
225
  __name: "SelectionTooltip",
212
226
  setup(n) {
213
227
  let { view: r, prevState: o } = ee(), [, s] = M(), c = l(X), d = c?.activeMarks ?? Ie, h = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = t(() => {
@@ -217,18 +231,19 @@ var Ne = [
217
231
  italic: e ? "Italic" : "斜体",
218
232
  strike: e ? "Strikethrough" : "删除线",
219
233
  code: e ? "Inline code" : "行内代码",
234
+ spoiler: e ? "Spoiler" : "隐藏文本",
220
235
  link: e ? "Link" : "链接",
221
236
  linkUrl: e ? "Link URL" : "链接 URL",
222
237
  apply: e ? "Apply" : "确定",
223
238
  cancel: e ? "Cancel" : "取消"
224
239
  };
225
240
  }), y = _(null), b, C = (e, t) => {
226
- s()?.action(W(e, t));
241
+ s()?.action(K(e, t));
227
242
  }, T = _(!1), k = _(""), A = _(null), j = () => {
228
243
  let e = "";
229
244
  return s()?.action((t) => {
230
245
  let n = r.value?.state;
231
- n && (e = Ye(n, t));
246
+ n && (e = Ze(n, t));
232
247
  }), e;
233
248
  }, N = () => {
234
249
  T.value = !1, k.value = "", r.value?.focus();
@@ -271,19 +286,19 @@ var Ne = [
271
286
  run: () => C(me.key),
272
287
  mark: "code"
273
288
  },
289
+ spoiler: {
290
+ svg: $.spoiler,
291
+ title: g.value.spoiler,
292
+ run: () => C(be.key),
293
+ mark: "spoiler"
294
+ },
274
295
  link: {
275
296
  svg: $.link,
276
297
  title: g.value.link,
277
298
  run: F
278
299
  }
279
300
  })), L = t(() => {
280
- let e = I.value, t = (c?.selectionToolbarItems ?? [
281
- "bold",
282
- "italic",
283
- "strike",
284
- "code",
285
- "link"
286
- ]).map((t) => t === "|" ? { divider: !0 } : e[t] ? {
301
+ let e = I.value, t = (c?.selectionToolbarItems ?? He).map((t) => t === "|" ? { divider: !0 } : e[t] ? {
287
302
  divider: !1,
288
303
  ...e[t]
289
304
  } : null).filter((e) => e !== null), n = [];
@@ -292,7 +307,7 @@ var Ne = [
292
307
  return n;
293
308
  });
294
309
  return p(() => {
295
- b = new ie({
310
+ b = new U({
296
311
  content: y.value,
297
312
  offset: 8
298
313
  }), b.onHide = () => {
@@ -321,7 +336,7 @@ var Ne = [
321
336
  spellcheck: "false",
322
337
  autocomplete: "off",
323
338
  onKeydown: [n[1] ||= D(O((e) => P(), ["prevent"]), ["enter"]), n[2] ||= D(O((e) => N(), ["stop", "prevent"]), ["esc"])]
324
- }, null, 40, Ze), [[S, k.value]]),
339
+ }, null, 40, $e), [[S, k.value]]),
325
340
  a("button", {
326
341
  type: "button",
327
342
  class: "kun-editor__bubble-btn",
@@ -331,7 +346,7 @@ var Ne = [
331
346
  }, [a("span", {
332
347
  class: "kun-editor__icon",
333
348
  innerHTML: x($).check
334
- }, null, 8, $e)], 40, Qe),
349
+ }, null, 8, tt)], 40, et),
335
350
  a("button", {
336
351
  type: "button",
337
352
  class: "kun-editor__bubble-btn",
@@ -341,8 +356,8 @@ var Ne = [
341
356
  }, [a("span", {
342
357
  class: "kun-editor__icon",
343
358
  innerHTML: x($).close
344
- }, null, 8, tt)], 40, et)
345
- ], 64)) : (m(!0), i(e, { key: 1 }, v(L.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", nt)) : (m(), i("button", {
359
+ }, null, 8, rt)], 40, nt)
360
+ ], 64)) : (m(!0), i(e, { key: 1 }, v(L.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", it)) : (m(), i("button", {
346
361
  key: 1,
347
362
  type: "button",
348
363
  class: "kun-editor__bubble-btn",
@@ -354,9 +369,9 @@ var Ne = [
354
369
  }, [a("span", {
355
370
  class: "kun-editor__icon",
356
371
  innerHTML: t.svg
357
- }, null, 8, it)], 40, rt))], 64))), 128))], 8, Xe));
372
+ }, null, 8, ot)], 40, at))], 64))), 128))], 8, Qe));
358
373
  }
359
- }), ot = /* @__PURE__ */ s({
374
+ }), ct = /* @__PURE__ */ s({
360
375
  __name: "MilkdownEditor",
361
376
  props: {
362
377
  modelValue: {},
@@ -371,44 +386,44 @@ var Ne = [
371
386
  },
372
387
  emits: ["update:modelValue", "update:loading"],
373
388
  setup(e, { expose: t, emit: r }) {
374
- let i = e, a = r, o = i.modelValue, s = !1, c = l(X), u = P(), d = V("kunMention"), f = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!u, p = H("kunSelectionTooltip"), h = i.selectionToolbar && !!u, g = j((e) => {
389
+ let i = e, a = r, o = i.modelValue, s = !1, c = l(X), u = P(), d = ne("kunMention"), f = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!u, p = W("kunSelectionTooltip"), h = i.selectionToolbar && !!u, g = j((e) => {
375
390
  let t = L.make().config((t) => {
376
- t.set(B, e), t.set(te, i.modelValue), t.get(ne).markdownUpdated((e, t, n) => {
391
+ t.set(V, e), t.set(R, i.modelValue), t.get(te).markdownUpdated((e, t, n) => {
377
392
  !i.active || s || t === n || (o = t, a("update:modelValue", t));
378
- }), t.update(z, (e) => ({
393
+ }), t.update(B, (e) => ({
379
394
  ...e,
380
395
  editable: () => !i.readonly
381
- })), f && t.set(d.key, { view: u({ component: Je }) }), h && t.set(p.key, { view: u({ component: at }) });
396
+ })), f && t.set(d.key, { view: u({ component: Xe }) }), h && t.set(p.key, { view: u({ component: st }) });
382
397
  }).use(ye(i.adapters, i.features, {
383
398
  locale: i.locale,
384
399
  placeholder: i.placeholder,
385
400
  placeholderMode: i.placeholderMode
386
401
  }));
387
- return f && t.use(d), h && t.use(p), c && t.use(Be(c.activeMarks)), t;
402
+ return f && t.use(d), h && t.use(p), c && t.use(Ve(c.activeMarks)), t;
388
403
  });
389
404
  w(g.loading, (e) => a("update:loading", e), { immediate: !0 }), w(() => i.modelValue, (e) => {
390
405
  if (e === o) return;
391
406
  o = e;
392
407
  let t = g.get();
393
- t && (s = !0, t.action(G(e)), s = !1);
408
+ t && (s = !0, t.action(re(e)), s = !1);
394
409
  }), w(() => i.readonly, () => {
395
410
  g.get()?.action((e) => {
396
- let t = e.get(R);
411
+ let t = e.get(z);
397
412
  t.dispatch(t.state.tr);
398
413
  });
399
414
  });
400
415
  let _ = () => {
401
- g.get()?.action((e) => e.get(R).focus());
416
+ g.get()?.action((e) => e.get(z).focus());
402
417
  };
403
418
  return t({
404
419
  insertQuote: (e) => {
405
- g.get()?.action(W(Se.key, e)), _();
420
+ g.get()?.action(K(Se.key, e)), _();
406
421
  },
407
422
  insertMention: (e) => {
408
- g.get()?.action(W(xe.key, e)), _();
423
+ g.get()?.action(K(xe.key, e)), _();
409
424
  },
410
425
  insertImage: (e) => {
411
- g.get()?.action(W(ue.key, {
426
+ g.get()?.action(K(ue.key, {
412
427
  src: e.src,
413
428
  alt: e.alt ?? "",
414
429
  title: e.title ?? ""
@@ -417,7 +432,7 @@ var Ne = [
417
432
  uploadImage: (e) => {
418
433
  let t = i.adapters.uploadImage, n = g.get();
419
434
  !t || !n || n.action((n) => {
420
- Ee(n.get(R), e, {
435
+ Ee(n.get(z), e, {
421
436
  uploadImage: t,
422
437
  notify: i.adapters.notify,
423
438
  locale: i.locale
@@ -427,25 +442,25 @@ var Ne = [
427
442
  focus: _,
428
443
  scrollToHeading: (e) => {
429
444
  g.get()?.action((t) => {
430
- let n = t.get(R), r = 0, i = -1;
445
+ let n = t.get(z), r = 0, i = -1;
431
446
  if (n.state.doc.forEach((t, n) => {
432
447
  t.type.name === "heading" && (r === e && (i = n), r += 1);
433
448
  }), !(i < 0) && (n.nodeDOM(i)?.scrollIntoView({
434
449
  behavior: "smooth",
435
450
  block: "start"
436
451
  }), n.editable)) {
437
- let e = K.near(n.state.doc.resolve(i + 1));
452
+ let e = q.near(n.state.doc.resolve(i + 1));
438
453
  n.dispatch(n.state.tr.setSelection(e)), n.focus();
439
454
  }
440
455
  });
441
456
  }
442
457
  }), (e, t) => (m(), n(x(k)));
443
458
  }
444
- }), st = [
459
+ }), lt = [
445
460
  "title",
446
461
  "aria-label",
447
462
  "aria-expanded"
448
- ], ct = ["innerHTML"], lt = { class: "kun-editor__link-panel" }, ut = ["placeholder", "aria-label"], dt = ["title", "aria-label"], ft = ["innerHTML"], pt = /* @__PURE__ */ s({
463
+ ], ut = ["innerHTML"], dt = { class: "kun-editor__link-panel" }, ft = ["placeholder", "aria-label"], pt = ["title", "aria-label"], mt = ["innerHTML"], ht = /* @__PURE__ */ s({
449
464
  __name: "LinkInput",
450
465
  setup(e) {
451
466
  let [, n] = M(), r = l(X), o = t(() => (r?.locale ?? "zh-cn").toLowerCase().startsWith("en")), s = t(() => {
@@ -456,11 +471,11 @@ var Ne = [
456
471
  apply: e ? "Apply" : "确定"
457
472
  };
458
473
  }), c = _(!1), d = _(""), h = _(null), g = _(null), v = (e) => {
459
- e && n()?.action(W(J.key, { href: e }));
474
+ e && n()?.action(K(J.key, { href: e }));
460
475
  }, y = () => {
461
476
  c.value = !1, d.value = "";
462
477
  }, b = () => {
463
- y(), n()?.action((e) => e.get(R).focus());
478
+ y(), n()?.action((e) => e.get(z).focus());
464
479
  }, w = () => {
465
480
  v(d.value.trim()), b();
466
481
  }, T = async () => {
@@ -468,7 +483,7 @@ var Ne = [
468
483
  if (e) {
469
484
  let t = "";
470
485
  n()?.action((e) => {
471
- let { state: n } = e.get(R), { from: r, to: i } = n.selection;
486
+ let { state: n } = e.get(z), { from: r, to: i } = n.selection;
472
487
  t = n.doc.textBetween(r, i, " ");
473
488
  }), v((await e({ text: t }))?.trim() ?? "");
474
489
  return;
@@ -478,7 +493,7 @@ var Ne = [
478
493
  return;
479
494
  }
480
495
  n()?.action((e) => {
481
- d.value = Ye(e.get(R).state, e);
496
+ d.value = Ze(e.get(z).state, e);
482
497
  }), c.value = !0, await u(), g.value?.focus(), g.value?.select();
483
498
  }, k = (e) => {
484
499
  c.value && h.value && !h.value.contains(e.target) && y();
@@ -497,7 +512,7 @@ var Ne = [
497
512
  }, [a("span", {
498
513
  class: "kun-editor__icon",
499
514
  innerHTML: x($).link
500
- }, null, 8, ct)], 8, st), E(a("div", lt, [E(a("input", {
515
+ }, null, 8, ut)], 8, lt), E(a("div", dt, [E(a("input", {
501
516
  ref_key: "inputRef",
502
517
  ref: g,
503
518
  "onUpdate:modelValue": t[0] ||= (e) => d.value = e,
@@ -509,7 +524,7 @@ var Ne = [
509
524
  spellcheck: "false",
510
525
  autocomplete: "off",
511
526
  onKeydown: [t[1] ||= D(O((e) => w(), ["prevent"]), ["enter"]), t[2] ||= D(O((e) => b(), ["stop", "prevent"]), ["esc"])]
512
- }, null, 40, ut), [[S, d.value]]), a("button", {
527
+ }, null, 40, ft), [[S, d.value]]), a("button", {
513
528
  type: "button",
514
529
  class: "kun-editor__tool",
515
530
  title: s.value.apply,
@@ -518,23 +533,23 @@ var Ne = [
518
533
  }, [a("span", {
519
534
  class: "kun-editor__icon",
520
535
  innerHTML: x($).check
521
- }, null, 8, ft)], 8, dt)], 512), [[C, c.value]])], 512));
536
+ }, null, 8, mt)], 8, pt)], 512), [[C, c.value]])], 512));
522
537
  }
523
- }), mt = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), ht = [
538
+ }), gt = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), _t = [
524
539
  "title",
525
540
  "aria-label",
526
541
  "aria-expanded"
527
- ], gt = ["innerHTML"], _t = { class: "kun-editor__picker-panel" }, vt = {
542
+ ], vt = ["innerHTML"], yt = { class: "kun-editor__picker-panel" }, bt = {
528
543
  key: 0,
529
544
  class: "kun-editor__picker-tabs",
530
545
  role: "tablist"
531
- }, yt = ["data-active"], bt = ["data-active"], xt = { class: "kun-editor__emoji-grid" }, St = ["onClick"], Ct = {
546
+ }, xt = ["data-active"], St = ["data-active"], Ct = { class: "kun-editor__emoji-grid" }, wt = ["onClick"], Tt = {
532
547
  key: 1,
533
548
  class: "kun-editor__sticker-body"
534
- }, wt = { class: "kun-editor__pack-name" }, Tt = { class: "kun-editor__sticker-grid" }, Et = ["title", "onClick"], Dt = ["src", "alt"], Ot = {
549
+ }, Et = { class: "kun-editor__pack-name" }, Dt = { class: "kun-editor__sticker-grid" }, Ot = ["title", "onClick"], kt = ["src", "alt"], At = {
535
550
  key: 1,
536
551
  class: "kun-editor__picker-hint"
537
- }, kt = /* @__PURE__ */ s({
552
+ }, jt = /* @__PURE__ */ s({
538
553
  __name: "StickerPicker",
539
554
  setup(n) {
540
555
  let [, o] = M(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
@@ -566,11 +581,11 @@ var Ne = [
566
581
  p(() => document.addEventListener("click", A)), f(() => document.removeEventListener("click", A));
567
582
  let j = (e) => {
568
583
  o()?.action((t) => {
569
- let n = t.get(R), { state: r } = n;
584
+ let n = t.get(z), { state: r } = n;
570
585
  n.dispatch(r.tr.insertText(e, r.selection.from));
571
586
  });
572
587
  }, N = (e, t) => {
573
- o()?.action(W(ue.key, {
588
+ o()?.action(K(ue.key, {
574
589
  src: e,
575
590
  title: t,
576
591
  alt: t
@@ -590,28 +605,28 @@ var Ne = [
590
605
  }, [a("span", {
591
606
  class: "kun-editor__icon",
592
607
  innerHTML: x($).smile
593
- }, null, 8, gt)], 8, ht), E(a("div", _t, [
594
- u ? (m(), i("div", vt, [a("button", {
608
+ }, null, 8, vt)], 8, _t), E(a("div", yt, [
609
+ u ? (m(), i("div", bt, [a("button", {
595
610
  type: "button",
596
611
  class: "kun-editor__picker-tab",
597
612
  "data-active": S.value === "emoji",
598
613
  onClick: n[0] ||= (e) => S.value = "emoji"
599
- }, b(h.value.emoji), 9, yt), a("button", {
614
+ }, b(h.value.emoji), 9, xt), a("button", {
600
615
  type: "button",
601
616
  class: "kun-editor__picker-tab",
602
617
  "data-active": S.value === "sticker",
603
618
  onClick: n[1] ||= (e) => S.value = "sticker"
604
- }, b(h.value.sticker), 9, bt)])) : r("", !0),
605
- E(a("div", xt, [(m(!0), i(e, null, v(x(mt), (e, t) => (m(), i("button", {
619
+ }, b(h.value.sticker), 9, St)])) : r("", !0),
620
+ E(a("div", Ct, [(m(!0), i(e, null, v(x(gt), (e, t) => (m(), i("button", {
606
621
  key: t,
607
622
  type: "button",
608
623
  class: "kun-editor__emoji",
609
624
  onClick: (t) => j(e)
610
- }, b(e), 9, St))), 128))], 512), [[C, !u || S.value === "emoji"]]),
611
- u ? E((m(), i("div", Ct, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
625
+ }, b(e), 9, wt))), 128))], 512), [[C, !u || S.value === "emoji"]]),
626
+ u ? E((m(), i("div", Tt, [w.value.length ? (m(!0), i(e, { key: 0 }, v(w.value, (t) => (m(), i("div", {
612
627
  key: t.name,
613
628
  class: "kun-editor__pack"
614
- }, [a("div", wt, b(t.name), 1), a("div", Tt, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
629
+ }, [a("div", Et, b(t.name), 1), a("div", Dt, [(m(!0), i(e, null, v(t.stickers, (e, t) => (m(), i("button", {
615
630
  key: t,
616
631
  type: "button",
617
632
  class: "kun-editor__sticker",
@@ -621,27 +636,27 @@ var Ne = [
621
636
  src: e.src,
622
637
  alt: e.name,
623
638
  loading: "lazy"
624
- }, null, 8, Dt)], 8, Et))), 128))])]))), 128)) : (m(), i("div", Ot, b(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[C, S.value === "sticker"]]) : r("", !0)
639
+ }, null, 8, kt)], 8, Ot))), 128))])]))), 128)) : (m(), i("div", At, b(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[C, S.value === "sticker"]]) : r("", !0)
625
640
  ], 512), [[C, g.value]])], 512));
626
641
  }
627
- }), At = {
642
+ }), Mt = {
628
643
  class: "kun-editor__format-toolbar",
629
644
  role: "toolbar"
630
- }, jt = ["aria-label"], Mt = {
645
+ }, Nt = ["aria-label"], Pt = {
631
646
  value: "",
632
647
  disabled: "",
633
648
  selected: ""
634
- }, Nt = ["value"], Pt = [
649
+ }, Ft = ["value"], It = [
635
650
  "title",
636
651
  "aria-label",
637
652
  "aria-pressed",
638
653
  "data-active",
639
654
  "onClick"
640
- ], Ft = ["innerHTML"], It = ["title", "aria-label"], Lt = ["innerHTML"], Rt = /* @__PURE__ */ s({
655
+ ], Lt = ["innerHTML"], Rt = ["title", "aria-label"], zt = ["innerHTML"], Bt = /* @__PURE__ */ s({
641
656
  __name: "EditorToolbar",
642
657
  setup(s) {
643
658
  let [, c] = M(), u = l(X), d = u?.activeMarks ?? Ie, f = t(() => u?.adapters.uploadImage), p = t(() => u?.features.sticker !== !1), h = t(() => (u?.locale ?? "zh-cn").toLowerCase().startsWith("en")), g = (e, t) => {
644
- c()?.action(W(e, t));
659
+ c()?.action(K(e, t));
645
660
  }, y = t(() => {
646
661
  let e = h.value;
647
662
  return {
@@ -722,7 +737,7 @@ var Ne = [
722
737
  {
723
738
  svg: $.codeBlock,
724
739
  title: y.value.codeBlock,
725
- run: () => g(q.key, "")
740
+ run: () => g(oe.key, "")
726
741
  },
727
742
  {
728
743
  svg: $.hr,
@@ -733,33 +748,34 @@ var Ne = [
733
748
  [{
734
749
  svg: $.spoiler,
735
750
  title: y.value.spoiler,
736
- run: () => g(be.key)
751
+ run: () => g(be.key),
752
+ mark: "spoiler"
737
753
  }]
738
754
  ]), T = _(null), E = () => T.value?.click(), D = (e) => {
739
755
  let t = e.target, n = t.files?.[0];
740
756
  t.value = "";
741
757
  let r = f.value;
742
758
  !n || !r || c()?.action((e) => {
743
- Ee(e.get(R), n, {
759
+ Ee(e.get(z), n, {
744
760
  uploadImage: r,
745
761
  notify: u?.adapters.notify,
746
762
  locale: u?.locale
747
763
  });
748
764
  });
749
765
  };
750
- return (t, s) => (m(), i("div", At, [
766
+ return (t, s) => (m(), i("div", Mt, [
751
767
  a("select", {
752
768
  class: "kun-editor__heading-select",
753
769
  "aria-label": y.value.textSize,
754
770
  onChange: C
755
- }, [a("option", Mt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
771
+ }, [a("option", Pt, b(y.value.textSize), 1), (m(!0), i(e, null, v(S.value, (e) => (m(), i("option", {
756
772
  key: e.level,
757
773
  value: e.level
758
- }, b(e.label), 9, Nt))), 128))], 40, jt),
774
+ }, b(e.label), 9, Ft))), 128))], 40, Nt),
759
775
  (m(!0), i(e, null, v(w.value, (t, r) => (m(), i(e, { key: r }, [s[0] ||= a("span", {
760
776
  class: "kun-editor__toolbar-divider",
761
777
  "aria-hidden": "true"
762
- }, null, -1), (m(!0), i(e, null, v(t, (t, r) => (m(), i(e, { key: r }, ["link" in t ? (m(), n(pt, { key: 0 })) : (m(), i("button", {
778
+ }, null, -1), (m(!0), i(e, null, v(t, (t, r) => (m(), i(e, { key: r }, ["link" in t ? (m(), n(ht, { key: 0 })) : (m(), i("button", {
763
779
  key: 1,
764
780
  type: "button",
765
781
  class: "kun-editor__tool",
@@ -771,7 +787,7 @@ var Ne = [
771
787
  }, [a("span", {
772
788
  class: "kun-editor__icon",
773
789
  innerHTML: t.svg
774
- }, null, 8, Ft)], 8, Pt))], 64))), 128))], 64))), 128)),
790
+ }, null, 8, Lt)], 8, It))], 64))), 128))], 64))), 128)),
775
791
  f.value ? (m(), i(e, { key: 0 }, [
776
792
  s[1] ||= a("span", {
777
793
  class: "kun-editor__toolbar-divider",
@@ -786,7 +802,7 @@ var Ne = [
786
802
  }, [a("span", {
787
803
  class: "kun-editor__icon",
788
804
  innerHTML: x($).image
789
- }, null, 8, Lt)], 8, It),
805
+ }, null, 8, zt)], 8, Rt),
790
806
  a("input", {
791
807
  ref_key: "fileInput",
792
808
  ref: T,
@@ -799,16 +815,16 @@ var Ne = [
799
815
  p.value ? (m(), i(e, { key: 1 }, [s[2] ||= a("span", {
800
816
  class: "kun-editor__toolbar-divider",
801
817
  "aria-hidden": "true"
802
- }, null, -1), o(kt)], 64)) : r("", !0)
818
+ }, null, -1), o(jt)], 64)) : r("", !0)
803
819
  ]));
804
820
  }
805
- }), zt = /* @__PURE__ */ s({
821
+ }), Vt = /* @__PURE__ */ s({
806
822
  __name: "ToolbarHost",
807
823
  setup(e) {
808
824
  let [, t] = M(), n = l(X, void 0), r = (e, n) => {
809
- t()?.action(W(e, n));
825
+ t()?.action(K(e, n));
810
826
  }, i = () => {
811
- t()?.action((e) => e.get(R).focus());
827
+ t()?.action((e) => e.get(z).focus());
812
828
  }, a = {
813
829
  run: r,
814
830
  get activeMarks() {
@@ -816,14 +832,14 @@ var Ne = [
816
832
  },
817
833
  insertText: (e) => {
818
834
  t()?.action((t) => {
819
- let n = t.get(R);
835
+ let n = t.get(z);
820
836
  n.dispatch(n.state.tr.insertText(e));
821
837
  }), i();
822
838
  },
823
839
  uploadImage: (e) => {
824
840
  let r = n?.adapters.uploadImage, i = t();
825
841
  !r || !i || i.action((t) => {
826
- Ee(t.get(R), e, {
842
+ Ee(t.get(z), e, {
827
843
  uploadImage: r,
828
844
  notify: n?.adapters.notify,
829
845
  locale: n?.locale
@@ -859,7 +875,7 @@ var Ne = [
859
875
  };
860
876
  return (e, t) => y(e.$slots, "default", d(c(a)));
861
877
  }
862
- }), Bt = /* @__PURE__ */ s({
878
+ }), Ht = /* @__PURE__ */ s({
863
879
  __name: "MarkdownSource",
864
880
  props: {
865
881
  modelValue: {},
@@ -931,23 +947,23 @@ var Ne = [
931
947
  class: "kun-editor__source"
932
948
  }, null, 512));
933
949
  }
934
- }), Vt = ["data-mode"], Ht = {
950
+ }), Ut = ["data-mode"], Wt = {
935
951
  key: 0,
936
952
  class: "kun-editor__toolbar",
937
953
  role: "tablist"
938
- }, Ut = [
954
+ }, Gt = [
939
955
  "aria-selected",
940
956
  "data-active",
941
957
  "onClick"
942
- ], Wt = ["title", "aria-label"], Gt = [
958
+ ], Kt = ["title", "aria-label"], qt = [
943
959
  "data-active",
944
960
  "title",
945
961
  "aria-pressed"
946
- ], Kt = ["data-swap"], qt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Jt = {
962
+ ], Jt = ["data-swap"], Yt = { class: "kun-editor__wysiwyg kun-editor__pane" }, Xt = {
947
963
  key: 1,
948
964
  class: "kun-editor__loading",
949
965
  "aria-hidden": "true"
950
- }, Yt = /* @__PURE__ */ s({
966
+ }, Zt = /* @__PURE__ */ s({
951
967
  __name: "KunEditor",
952
968
  props: {
953
969
  modelValue: {},
@@ -980,53 +996,47 @@ var Ne = [
980
996
  "update:loading"
981
997
  ],
982
998
  setup(s, { expose: l, emit: S }) {
983
- let D = [
984
- "bold",
985
- "italic",
986
- "strike",
987
- "code",
988
- "link"
989
- ], O = s, k = S, j = _(!1);
999
+ let D = s, O = S, k = _(!1);
990
1000
  p(() => {
991
- j.value = !0;
1001
+ k.value = !0;
992
1002
  });
993
- let M = _(!0), ee = (e) => {
994
- M.value = e, k("update:loading", e);
1003
+ let j = _(!0), M = (e) => {
1004
+ j.value = e, O("update:loading", e);
995
1005
  };
996
- w(() => O.modelValue, (e) => k("update:headings", I(e)), { immediate: !0 });
997
- let P = g(Fe());
1006
+ w(() => D.modelValue, (e) => O("update:headings", I(e)), { immediate: !0 });
1007
+ let ee = g(Fe());
998
1008
  h(X, {
999
1009
  get adapters() {
1000
- return O.adapters;
1010
+ return D.adapters;
1001
1011
  },
1002
1012
  get features() {
1003
- return O.features;
1013
+ return D.features;
1004
1014
  },
1005
1015
  get locale() {
1006
- return O.locale;
1016
+ return D.locale;
1007
1017
  },
1008
1018
  get selectionToolbarItems() {
1009
- return Array.isArray(O.selectionToolbar) ? O.selectionToolbar : D;
1019
+ return Array.isArray(D.selectionToolbar) ? D.selectionToolbar : He;
1010
1020
  },
1011
1021
  get activeMarks() {
1012
- return P;
1022
+ return ee;
1013
1023
  }
1014
1024
  });
1015
- let F = t(() => O.selectionToolbar !== !1), L = _(O.views.includes("wysiwyg") ? "wysiwyg" : O.views[0] ?? "wysiwyg"), te = (e) => {
1016
- L.value = e;
1025
+ let P = t(() => D.selectionToolbar !== !1), F = _(D.views.includes("wysiwyg") ? "wysiwyg" : D.views[0] ?? "wysiwyg"), L = (e) => {
1026
+ F.value = e;
1017
1027
  };
1018
- w(() => O.views, (e) => {
1019
- e.includes(L.value) || (L.value = e[0] ?? "wysiwyg");
1028
+ w(() => D.views, (e) => {
1029
+ e.includes(F.value) || (F.value = e[0] ?? "wysiwyg");
1020
1030
  });
1021
1031
  let R = _(!1), z = () => {
1022
1032
  R.value = !R.value;
1023
- }, B = _(O.scrollSync);
1024
- w(() => O.scrollSync, (e) => {
1033
+ }, B = _(D.scrollSync);
1034
+ w(() => D.scrollSync, (e) => {
1025
1035
  B.value = e;
1026
1036
  });
1027
- let ne = () => {
1037
+ let V = () => {
1028
1038
  B.value = !B.value;
1029
- }, re = t(() => O.locale.toLowerCase().startsWith("en")), V = t(() => re.value ? {
1039
+ }, te = t(() => D.locale.toLowerCase().startsWith("en")), H = t(() => te.value ? {
1030
1040
  wysiwyg: "Preview",
1031
1041
  source: "Markdown",
1032
1042
  split: "Split",
@@ -1038,30 +1048,30 @@ var Ne = [
1038
1048
  split: "分栏",
1039
1049
  swap: "左右互换",
1040
1050
  scrollSync: "同步滚动"
1041
- }), ie = _(null), H = null, U = null, W = null, G = () => {
1042
- H?.(), H = null, U = null;
1043
- }, ae = () => {
1044
- G();
1045
- let e = ie.value;
1051
+ }), ne = _(null), U = null, W = null, G = null, K = () => {
1052
+ U?.(), U = null, W = null;
1053
+ }, re = () => {
1054
+ K();
1055
+ let e = ne.value;
1046
1056
  if (!e) return;
1047
1057
  let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
1048
1058
  if (!t || !n) return;
1049
1059
  let r = (e, t) => () => {
1050
- if (U && U !== e) return;
1051
- U = e;
1060
+ if (W && W !== e) return;
1061
+ W = e;
1052
1062
  let n = e.scrollHeight - e.clientHeight, r = n > 0 ? e.scrollTop / n : 0, i = t.scrollHeight - t.clientHeight;
1053
- t.scrollTop = r * (i > 0 ? i : 0), W && clearTimeout(W), W = setTimeout(() => {
1054
- U = null;
1063
+ t.scrollTop = r * (i > 0 ? i : 0), G && clearTimeout(G), G = setTimeout(() => {
1064
+ W = null;
1055
1065
  }, 120);
1056
1066
  }, i = r(t, n), a = r(n, t);
1057
- t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), H = () => {
1067
+ t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), U = () => {
1058
1068
  t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
1059
1069
  };
1060
1070
  };
1061
- w([L, B], ([e, t]) => {
1062
- G(), e === "split" && t && u(ae);
1063
- }), f(G);
1064
- let oe = t(() => O.readonly || L.value === "split"), K = (e) => k("update:modelValue", e), q = _(null), se = _(null);
1071
+ w([F, B], ([e, t]) => {
1072
+ K(), e === "split" && t && u(re);
1073
+ }), f(K);
1074
+ let ie = t(() => D.readonly || F.value === "split"), ae = (e) => O("update:modelValue", e), q = _(null), oe = _(null);
1065
1075
  return l({
1066
1076
  insertQuote: (e) => q.value?.insertQuote(e),
1067
1077
  insertMention: (e) => q.value?.insertMention(e),
@@ -1069,73 +1079,73 @@ var Ne = [
1069
1079
  uploadImage: (e) => q.value?.uploadImage(e),
1070
1080
  focus: () => q.value?.focus(),
1071
1081
  scrollToHeading: (e) => {
1072
- L.value === "source" || L.value === "split" ? se.value?.scrollToHeading(e) : q.value?.scrollToHeading(e);
1082
+ F.value === "source" || F.value === "split" ? oe.value?.scrollToHeading(e) : q.value?.scrollToHeading(e);
1073
1083
  }
1074
1084
  }), (t, l) => (m(), i("div", {
1075
1085
  ref_key: "rootEl",
1076
- ref: ie,
1086
+ ref: ne,
1077
1087
  class: "kun-editor",
1078
1088
  "data-kun-editor": "",
1079
- "data-mode": L.value
1080
- }, [j.value ? (m(), i(e, { key: 0 }, [y(t.$slots, "view-switch", {
1081
- mode: L.value,
1082
- setMode: te,
1083
- labels: V.value,
1089
+ "data-mode": F.value
1090
+ }, [k.value ? (m(), i(e, { key: 0 }, [y(t.$slots, "view-switch", {
1091
+ mode: F.value,
1092
+ setMode: L,
1093
+ labels: H.value,
1084
1094
  views: s.views,
1085
1095
  swapped: R.value,
1086
1096
  swap: z,
1087
1097
  scrollSync: B.value,
1088
- toggleScrollSync: ne
1089
- }, () => [s.views.length > 1 ? (m(), i("div", Ht, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
1098
+ toggleScrollSync: V
1099
+ }, () => [s.views.length > 1 ? (m(), i("div", Wt, [(m(!0), i(e, null, v(s.views, (e) => (m(), i("button", {
1090
1100
  key: e,
1091
1101
  type: "button",
1092
1102
  class: "kun-editor__tab",
1093
- "aria-selected": L.value === e,
1094
- "data-active": L.value === e,
1095
- onClick: (t) => te(e)
1096
- }, b(V.value[e]), 9, Ut))), 128)), L.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
1103
+ "aria-selected": F.value === e,
1104
+ "data-active": F.value === e,
1105
+ onClick: (t) => L(e)
1106
+ }, b(H.value[e]), 9, Gt))), 128)), F.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
1097
1107
  type: "button",
1098
1108
  class: "kun-editor__tab kun-editor__swap",
1099
- title: V.value.swap,
1100
- "aria-label": V.value.swap,
1109
+ title: H.value.swap,
1110
+ "aria-label": H.value.swap,
1101
1111
  onClick: l[0] ||= (e) => z()
1102
- }, " ⇄ ", 8, Wt), a("button", {
1112
+ }, " ⇄ ", 8, Kt), a("button", {
1103
1113
  type: "button",
1104
1114
  class: "kun-editor__tab",
1105
1115
  "data-active": B.value,
1106
- title: V.value.scrollSync,
1116
+ title: H.value.scrollSync,
1107
1117
  "aria-pressed": B.value,
1108
- onClick: l[1] ||= (e) => ne()
1109
- }, b(V.value.scrollSync), 9, Gt)], 64)) : r("", !0)])) : r("", !0)]), o(x(A), null, {
1118
+ onClick: l[1] ||= (e) => V()
1119
+ }, b(H.value.scrollSync), 9, qt)], 64)) : r("", !0)])) : r("", !0)]), o(x(A), null, {
1110
1120
  default: T(() => [o(x(N), null, {
1111
- default: T(() => [E(a("div", null, [o(zt, null, {
1112
- default: T((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(Rt)])]),
1121
+ default: T(() => [E(a("div", null, [o(Vt, null, {
1122
+ default: T((e) => [y(t.$slots, "toolbar", d(c(e)), () => [o(Bt)])]),
1113
1123
  _: 3
1114
- })], 512), [[C, L.value === "wysiwyg" && !s.readonly]]), a("div", {
1124
+ })], 512), [[C, F.value === "wysiwyg" && !s.readonly]]), a("div", {
1115
1125
  class: "kun-editor__panes",
1116
1126
  "data-swap": R.value
1117
- }, [L.value === "source" || L.value === "split" ? (m(), n(Bt, {
1127
+ }, [F.value === "source" || F.value === "split" ? (m(), n(Ht, {
1118
1128
  key: 0,
1119
1129
  ref_key: "source",
1120
- ref: se,
1130
+ ref: oe,
1121
1131
  class: "kun-editor__pane",
1122
1132
  "model-value": s.modelValue,
1123
1133
  readonly: s.readonly,
1124
- "onUpdate:modelValue": K
1125
- }, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", qt, [o(ot, {
1134
+ "onUpdate:modelValue": ae
1135
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), E(a("div", Yt, [o(ct, {
1126
1136
  ref_key: "inner",
1127
1137
  ref: q,
1128
1138
  "model-value": s.modelValue,
1129
1139
  adapters: s.adapters,
1130
1140
  features: s.features,
1131
1141
  locale: s.locale,
1132
- readonly: oe.value,
1142
+ readonly: ie.value,
1133
1143
  placeholder: s.placeholder,
1134
1144
  "placeholder-mode": s.placeholderMode,
1135
- active: L.value === "wysiwyg" && !s.readonly,
1136
- "selection-toolbar": F.value,
1137
- "onUpdate:modelValue": K,
1138
- "onUpdate:loading": ee
1145
+ active: F.value === "wysiwyg" && !s.readonly,
1146
+ "selection-toolbar": P.value,
1147
+ "onUpdate:modelValue": ae,
1148
+ "onUpdate:loading": M
1139
1149
  }, null, 8, [
1140
1150
  "model-value",
1141
1151
  "adapters",
@@ -1146,18 +1156,18 @@ var Ne = [
1146
1156
  "placeholder-mode",
1147
1157
  "active",
1148
1158
  "selection-toolbar"
1149
- ])], 512), [[C, L.value === "wysiwyg" || L.value === "split"]])], 8, Kt)]),
1159
+ ])], 512), [[C, F.value === "wysiwyg" || F.value === "split"]])], 8, Jt)]),
1150
1160
  _: 3
1151
1161
  })]),
1152
1162
  _: 3
1153
- })], 64)) : r("", !0), !j.value || M.value ? (m(), i("div", Jt, [y(t.$slots, "loading", {}, () => [
1163
+ })], 64)) : r("", !0), !k.value || j.value ? (m(), i("div", Xt, [y(t.$slots, "loading", {}, () => [
1154
1164
  l[2] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
1155
1165
  l[3] ||= a("div", { class: "kun-editor__skeleton" }, null, -1),
1156
1166
  l[4] ||= a("div", { class: "kun-editor__skeleton" }, null, -1)
1157
- ])])) : r("", !0)], 8, Vt));
1167
+ ])])) : r("", !0)], 8, Ut));
1158
1168
  }
1159
- }), Xt = { install(e) {
1160
- e.component("KunEditor", Yt);
1169
+ }), Qt = { install(e) {
1170
+ e.component("KunEditor", Zt);
1161
1171
  } };
1162
1172
  //#endregion
1163
- export { mt as EMOJI, Yt as KunEditor, Xt as KunEditorPlugin, F as parseHeadings };
1173
+ export { gt as EMOJI, Zt as KunEditor, Qt as KunEditorPlugin, F as parseHeadings };
package/dist/types.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import type { CmdKey } from '@milkdown/kit/core';
2
2
  import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
3
3
  export type KunToolbarItem = 'heading' | 'bold' | 'italic' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'quote' | 'codeBlock' | 'hr' | 'spoiler' | 'link' | 'image' | 'picker' | '|';
4
- export type KunSelectionItem = 'bold' | 'italic' | 'strike' | 'code' | 'link' | '|';
5
- export type KunToggleMark = 'bold' | 'italic' | 'strike' | 'code';
4
+ export type KunSelectionItem = 'bold' | 'italic' | 'strike' | 'code' | 'spoiler' | 'link' | '|';
5
+ export type KunToggleMark = 'bold' | 'italic' | 'strike' | 'code' | 'spoiler';
6
6
  export interface KunEditorToolbarApi {
7
7
  /** Run a Milkdown command (import its key from the preset/commonmark/gfm). */
8
8
  run: <T>(key: CmdKey<T>, payload?: T) => void;
9
9
  /**
10
- * Live toggle-mark state at the caret / selection (bold / italic / strike /
11
- * code). The same record drives the default toolbar and the selection
10
+ * Live toggle state at the caret / selection (bold / italic / strike / code,
11
+ * and `spoiler` when the caret is inside one its button toggles too). The
12
+ * same record drives the default toolbar and the selection
12
13
  * bubble; a custom `#toolbar` reads it here. Updated on every editor view
13
14
  * tick, including stored-mark-only toggles.
14
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":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I,CAAA;IAC7B,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.35.0",
3
+ "version": "0.37.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.35.0"
43
+ "@kungal/editor-core": "0.37.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.35.0"
83
+ "@kungal/editor-core": "0.37.0"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",