@kungal/editor-vue 0.25.0 → 0.25.2

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,56 @@
1
1
  # @kungal/editor-vue
2
2
 
3
+ ## 0.25.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8e1b8ac: Fix the source pane rewriting raw markdown in split/source mode.
8
+
9
+ Typing `>` turned into `> <br />`, and `~~` / `**` / `[` became `\~\~` / `\*\*` /
10
+ `\[` in the markdown source. Cause: those are Milkdown's WYSIWYG→markdown
11
+ serialization (empty-blockquote → `<br />`, and remark-stringify escaping special
12
+ characters) — correct when Milkdown is the editor, but in split/source mode the
13
+ CodeMirror source owns the raw markdown, and the read-only preview was echoing its
14
+ re-serialized markdown back into the shared `v-model`, clobbering what you typed.
15
+
16
+ Fix: the WYSIWYG editor now emits only when it is the ACTIVE editor (WYSIWYG
17
+ mode). In source/split mode it's a derived preview and never writes back, so the
18
+ source keeps your exact raw markdown. The preview still renders it correctly.
19
+
20
+ Verified in the docs production build (split mode): `> `, `~~strike~~`,
21
+ `**bold**`, and a lone `>` all stay verbatim in the source (no `<br />`, no
22
+ backslash escapes); WYSIWYG-mode editing still updates the value; 0 console errors.
23
+
24
+ - @kungal/editor-core@0.25.2
25
+
26
+ ## 0.25.1
27
+
28
+ ### Patch Changes
29
+
30
+ - 177df55: Fix the cursor jumping to the start when editing the source pane in split mode.
31
+
32
+ Typing a character on an empty line (or deleting the first character of a line)
33
+ in the split-view source editor jumped the caret back to the document start. Cause:
34
+ a feedback loop — the source (CodeMirror) edit updated the shared `v-model`, the
35
+ read-only WYSIWYG preview re-rendered and echoed its _re-serialized_ (normalized)
36
+ markdown back into `v-model`, and CodeMirror then rebuilt its whole state
37
+ (`setState`) to match, resetting the selection.
38
+
39
+ Two fixes:
40
+
41
+ - **MilkdownEditor** no longer echoes changes it applied from an external
42
+ `v-model` update (it only emits genuine user edits), so the preview stops
43
+ feeding normalized markdown back.
44
+ - **MarkdownSource** now re-syncs external changes with a content-replacing
45
+ transaction that preserves (clamps) the selection, instead of a full `setState`
46
+ rebuild — so the caret and undo history survive.
47
+
48
+ Verified in the docs production build (split mode): typing `x y z` on an empty
49
+ line yields `xyz` in order; deleting the first char of a line keeps the caret on
50
+ that line; 0 console errors.
51
+
52
+ - @kungal/editor-core@0.25.1
53
+
3
54
  ## 0.25.0
4
55
 
5
56
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"AAsWA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAM5B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AASjE,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE9C,KAAK,WAAW,GAAG;IACf,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,qDAAqD;IACrD,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,KAAK,GAAG,OAAO,CAAA;IACjC;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;IAClB;oEACgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAAA;CAChD,CAAC;AA8ZJ,QAAA,IAAI,OAAO;;iBArW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ue.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownSource.vue"],"names":[],"mappings":"AA2FA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AA2EF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"MarkdownSource.vue.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownSource.vue"],"names":[],"mappings":"AA2GA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AA2FF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -9,6 +9,12 @@ type __VLS_Props = {
9
9
  placeholder: string;
10
10
  placeholderMode: 'doc' | 'block';
11
11
  selectionToolbar: boolean;
12
+ /**
13
+ * Whether this WYSIWYG is the ACTIVE editor (source of truth). False in
14
+ * source/split mode, where the CodeMirror source owns the raw markdown and this
15
+ * is only a derived preview — so it must NOT emit its re-serialized markdown.
16
+ */
17
+ active: boolean;
12
18
  };
13
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, KunEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
20
  "update:modelValue": (markdown: string) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"AA8MA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,KAAK,GAAG,OAAO,CAAA;IAChC,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAC;AA6JF,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"AAsOA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,KAAK,GAAG,OAAO,CAAA;IAChC,gBAAgB,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB,CAAC;AA+KF,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
package/dist/index.js CHANGED
@@ -10,28 +10,28 @@ import { createKunEditorPlugins as G, insertKunSpoilerCommand as K, insertMentio
10
10
  import { TextSelection as ie } from "@milkdown/kit/prose/state";
11
11
  import { createCodeBlockCommand as ae, insertHrCommand as oe, insertImageCommand as se, toggleEmphasisCommand as ce, toggleInlineCodeCommand as le, toggleStrongCommand as ue, wrapInBlockquoteCommand as de, wrapInBulletListCommand as fe, wrapInOrderedListCommand as pe } from "@milkdown/kit/preset/commonmark";
12
12
  import { toggleStrikethroughCommand as me } from "@milkdown/kit/preset/gfm";
13
- import { EditorState as he } from "@codemirror/state";
13
+ import { Annotation as he, EditorState as ge } from "@codemirror/state";
14
14
  import { EditorView as Y } from "@codemirror/view";
15
- import { markdown as ge } from "@codemirror/lang-markdown";
16
- import { basicSetup as _e } from "codemirror";
15
+ import { markdown as _e } from "@codemirror/lang-markdown";
16
+ import { basicSetup as ve } from "codemirror";
17
17
  //#region src/context.ts
18
- var X = Symbol("kun-editor-context"), ve = [
18
+ var X = Symbol("kun-editor-context"), ye = [
19
19
  "data-active",
20
20
  "onMousedown",
21
21
  "onMouseenter"
22
- ], ye = ["src", "alt"], be = {
22
+ ], be = ["src", "alt"], xe = {
23
23
  key: 1,
24
24
  class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
25
- }, xe = { class: "kun-mention-dropdown__name" }, Se = {
25
+ }, Se = { class: "kun-mention-dropdown__name" }, Ce = {
26
26
  key: 1,
27
27
  class: "kun-mention-dropdown__hint"
28
- }, Ce = {
28
+ }, we = {
29
29
  key: 2,
30
30
  class: "kun-mention-dropdown__hint"
31
- }, we = {
31
+ }, Te = {
32
32
  key: 3,
33
33
  class: "kun-mention-dropdown__hint"
34
- }, Te = /* @__PURE__ */ s({
34
+ }, Ee = /* @__PURE__ */ s({
35
35
  __name: "MentionDropdown",
36
36
  setup(n) {
37
37
  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 ? {
@@ -137,7 +137,7 @@ var X = Symbol("kun-editor-context"), ve = [
137
137
  src: e.avatar,
138
138
  alt: e.name,
139
139
  class: "kun-mention-dropdown__avatar"
140
- }, null, 8, ye)) : (m(), i("span", be, y(e.name.charAt(0)), 1)), a("span", xe, y(e.name), 1)], 40, ve))), 128)) : D.value ? (m(), i("div", Se, y(u.value.searching), 1)) : C.value ? (m(), i("div", Ce, y(u.value.empty), 1)) : (m(), i("div", we, y(u.value.prompt), 1))], 512));
140
+ }, null, 8, be)) : (m(), i("span", xe, y(e.name.charAt(0)), 1)), a("span", Se, y(e.name), 1)], 40, ye))), 128)) : D.value ? (m(), i("div", Ce, y(u.value.searching), 1)) : C.value ? (m(), i("div", we, y(u.value.empty), 1)) : (m(), i("div", Te, y(u.value.prompt), 1))], 512));
141
141
  }
142
142
  }), Z = (e) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`, Q = (e, t = 13) => `<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><text x="12" y="12" dominant-baseline="central" text-anchor="middle" font-size="${t}" font-weight="700" font-family="ui-sans-serif, system-ui, sans-serif" fill="currentColor">${e}</text></svg>`, $ = {
143
143
  bold: Z("<path d=\"M6 4h8a4 4 0 0 1 0 8H6z\"/><path d=\"M6 12h9a4 4 0 0 1 0 8H6z\"/>"),
@@ -156,15 +156,15 @@ var X = Symbol("kun-editor-context"), ve = [
156
156
  spoiler: Z("<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\"/>"),
157
157
  latex: Q("Σ", 15),
158
158
  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\"/>")
159
- }, Ee = {
159
+ }, De = {
160
160
  key: 0,
161
161
  class: "kun-editor__toolbar-divider",
162
162
  "aria-hidden": "true"
163
- }, De = [
163
+ }, Oe = [
164
164
  "title",
165
165
  "aria-label",
166
166
  "onMousedown"
167
- ], Oe = ["innerHTML"], ke = /* @__PURE__ */ s({
167
+ ], ke = ["innerHTML"], Ae = /* @__PURE__ */ s({
168
168
  __name: "SelectionTooltip",
169
169
  setup(n) {
170
170
  let { view: r, prevState: o } = j(), [, s] = k(), c = l(X), u = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), d = g(null), h, v = (e, t) => {
@@ -221,7 +221,7 @@ var X = Symbol("kun-editor-context"), ve = [
221
221
  ref: d,
222
222
  class: "kun-editor__bubble",
223
223
  "data-show": "false"
224
- }, [(m(!0), i(e, null, _(b.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", Ee)) : (m(), i("button", {
224
+ }, [(m(!0), i(e, null, _(b.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", De)) : (m(), i("button", {
225
225
  key: 1,
226
226
  type: "button",
227
227
  class: "kun-editor__bubble-btn",
@@ -231,9 +231,9 @@ var X = Symbol("kun-editor-context"), ve = [
231
231
  }, [a("span", {
232
232
  class: "kun-editor__icon",
233
233
  innerHTML: t.svg
234
- }, null, 8, Oe)], 40, De))], 64))), 128))], 512));
234
+ }, null, 8, ke)], 40, Oe))], 64))), 128))], 512));
235
235
  }
236
- }), Ae = /* @__PURE__ */ s({
236
+ }), je = /* @__PURE__ */ s({
237
237
  __name: "MilkdownEditor",
238
238
  props: {
239
239
  modelValue: {},
@@ -243,61 +243,65 @@ var X = Symbol("kun-editor-context"), ve = [
243
243
  readonly: { type: Boolean },
244
244
  placeholder: {},
245
245
  placeholderMode: {},
246
- selectionToolbar: { type: Boolean }
246
+ selectionToolbar: { type: Boolean },
247
+ active: { type: Boolean }
247
248
  },
248
249
  emits: ["update:modelValue"],
249
250
  setup(e, { expose: t, emit: r }) {
250
- let i = e, a = r, o = i.modelValue, s = M(), c = B("kunMention"), l = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!s, u = H("kunSelectionTooltip"), d = i.selectionToolbar && !!s, f = O((e) => {
251
+ let i = e, a = r, o = i.modelValue, s = !1, c = M(), l = B("kunMention"), u = i.features.mention !== !1 && !!i.adapters.searchMentionUsers && !!c, d = H("kunSelectionTooltip"), f = i.selectionToolbar && !!c, p = O((e) => {
251
252
  let t = N.make().config((t) => {
252
253
  t.set(L, e), t.set(P, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
253
- t !== n && (o = t, a("update:modelValue", t));
254
+ !i.active || s || t === n || (o = t, a("update:modelValue", t));
254
255
  }), t.update(I, (e) => ({
255
256
  ...e,
256
257
  editable: () => !i.readonly
257
- })), l && t.set(c.key, { view: s({ component: Te }) }), d && t.set(u.key, { view: s({ component: ke }) });
258
+ })), u && t.set(l.key, { view: c({ component: Ee }) }), f && t.set(d.key, { view: c({ component: Ae }) });
258
259
  }).use(G(i.adapters, i.features, {
259
260
  locale: i.locale,
260
261
  placeholder: i.placeholder,
261
262
  placeholderMode: i.placeholderMode
262
263
  }));
263
- return l && t.use(c), d && t.use(u), t;
264
+ return u && t.use(l), f && t.use(d), t;
264
265
  });
265
266
  S(() => i.modelValue, (e) => {
266
- e !== o && (o = e, f.get()?.action(W(e)));
267
+ if (e === o) return;
268
+ o = e;
269
+ let t = p.get();
270
+ t && (s = !0, t.action(W(e)), s = !1);
267
271
  }), S(() => i.readonly, () => {
268
- f.get()?.action((e) => {
272
+ p.get()?.action((e) => {
269
273
  let t = e.get(F);
270
274
  t.dispatch(t.state.tr);
271
275
  });
272
276
  });
273
- let p = () => {
274
- f.get()?.action((e) => e.get(F).focus());
277
+ let h = () => {
278
+ p.get()?.action((e) => e.get(F).focus());
275
279
  };
276
280
  return t({
277
281
  insertQuote: (e) => {
278
- f.get()?.action(U(J.key, e)), p();
282
+ p.get()?.action(U(J.key, e)), h();
279
283
  },
280
284
  insertMention: (e) => {
281
- f.get()?.action(U(q.key, e)), p();
285
+ p.get()?.action(U(q.key, e)), h();
282
286
  },
283
- focus: p
287
+ focus: h
284
288
  }), (e, t) => (m(), n(b(E)));
285
289
  }
286
- }), je = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Me = [
290
+ }), Me = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ne = [
287
291
  "title",
288
292
  "aria-label",
289
293
  "aria-expanded"
290
- ], Ne = ["innerHTML"], Pe = { class: "kun-editor__picker-panel" }, Fe = {
294
+ ], Pe = ["innerHTML"], Fe = { class: "kun-editor__picker-panel" }, Ie = {
291
295
  key: 0,
292
296
  class: "kun-editor__picker-tabs",
293
297
  role: "tablist"
294
- }, Ie = ["data-active"], Le = ["data-active"], Re = { class: "kun-editor__emoji-grid" }, ze = ["onClick"], Be = {
298
+ }, Le = ["data-active"], Re = ["data-active"], ze = { class: "kun-editor__emoji-grid" }, Be = ["onClick"], Ve = {
295
299
  key: 1,
296
300
  class: "kun-editor__sticker-body"
297
- }, Ve = { class: "kun-editor__pack-name" }, He = { class: "kun-editor__sticker-grid" }, Ue = ["title", "onClick"], We = ["src", "alt"], Ge = {
301
+ }, He = { class: "kun-editor__pack-name" }, Ue = { class: "kun-editor__sticker-grid" }, We = ["title", "onClick"], Ge = ["src", "alt"], Ke = {
298
302
  key: 1,
299
303
  class: "kun-editor__picker-hint"
300
- }, Ke = /* @__PURE__ */ s({
304
+ }, qe = /* @__PURE__ */ s({
301
305
  __name: "StickerPicker",
302
306
  setup(n) {
303
307
  let [, o] = k(), s = l(X), c = s?.adapters.stickerSource, u = !!c, d = t(() => (s?.locale ?? "zh-cn").toLowerCase().startsWith("en")), h = t(() => d.value ? {
@@ -353,28 +357,28 @@ var X = Symbol("kun-editor-context"), ve = [
353
357
  }, [a("span", {
354
358
  class: "kun-editor__icon",
355
359
  innerHTML: b($).smile
356
- }, null, 8, Ne)], 8, Me), w(a("div", Pe, [
357
- u ? (m(), i("div", Fe, [a("button", {
360
+ }, null, 8, Pe)], 8, Ne), w(a("div", Fe, [
361
+ u ? (m(), i("div", Ie, [a("button", {
358
362
  type: "button",
359
363
  class: "kun-editor__picker-tab",
360
364
  "data-active": C.value === "emoji",
361
365
  onClick: n[0] ||= (e) => C.value = "emoji"
362
- }, y(h.value.emoji), 9, Ie), a("button", {
366
+ }, y(h.value.emoji), 9, Le), a("button", {
363
367
  type: "button",
364
368
  class: "kun-editor__picker-tab",
365
369
  "data-active": C.value === "sticker",
366
370
  onClick: n[1] ||= (e) => C.value = "sticker"
367
- }, y(h.value.sticker), 9, Le)])) : r("", !0),
368
- w(a("div", Re, [(m(!0), i(e, null, _(b(je), (e, t) => (m(), i("button", {
371
+ }, y(h.value.sticker), 9, Re)])) : r("", !0),
372
+ w(a("div", ze, [(m(!0), i(e, null, _(b(Me), (e, t) => (m(), i("button", {
369
373
  key: t,
370
374
  type: "button",
371
375
  class: "kun-editor__emoji",
372
376
  onClick: (t) => M(e)
373
- }, y(e), 9, ze))), 128))], 512), [[x, !u || C.value === "emoji"]]),
374
- u ? w((m(), i("div", Be, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
377
+ }, y(e), 9, Be))), 128))], 512), [[x, !u || C.value === "emoji"]]),
378
+ u ? w((m(), i("div", Ve, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
375
379
  key: t.name,
376
380
  class: "kun-editor__pack"
377
- }, [a("div", Ve, y(t.name), 1), a("div", He, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
381
+ }, [a("div", He, y(t.name), 1), a("div", Ue, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
378
382
  key: t,
379
383
  type: "button",
380
384
  class: "kun-editor__sticker",
@@ -384,21 +388,21 @@ var X = Symbol("kun-editor-context"), ve = [
384
388
  src: e.src,
385
389
  alt: e.name,
386
390
  loading: "lazy"
387
- }, null, 8, We)], 8, Ue))), 128))])]))), 128)) : (m(), i("div", Ge, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
391
+ }, null, 8, Ge)], 8, We))), 128))])]))), 128)) : (m(), i("div", Ke, y(D.value ? h.value.failed : h.value.empty), 1))], 512)), [[x, C.value === "sticker"]]) : r("", !0)
388
392
  ], 512), [[x, v.value]])], 512));
389
393
  }
390
- }), qe = {
394
+ }), Je = {
391
395
  class: "kun-editor__format-toolbar",
392
396
  role: "toolbar"
393
- }, Je = ["aria-label"], Ye = {
397
+ }, Ye = ["aria-label"], Xe = {
394
398
  value: "",
395
399
  disabled: "",
396
400
  selected: ""
397
- }, Xe = ["value"], Ze = [
401
+ }, Ze = ["value"], Qe = [
398
402
  "title",
399
403
  "aria-label",
400
404
  "onClick"
401
- ], Qe = ["innerHTML"], $e = ["title", "aria-label"], et = ["innerHTML"], tt = /* @__PURE__ */ s({
405
+ ], $e = ["innerHTML"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = /* @__PURE__ */ s({
402
406
  __name: "EditorToolbar",
403
407
  setup(n) {
404
408
  let [, s] = k(), c = l(X), u = t(() => c?.adapters.uploadImage), d = t(() => c?.features.sticker !== !1), f = t(() => (c?.locale ?? "zh-cn").toLowerCase().startsWith("en")), p = (e, t) => {
@@ -503,15 +507,15 @@ var X = Symbol("kun-editor-context"), ve = [
503
507
  });
504
508
  });
505
509
  };
506
- return (t, n) => (m(), i("div", qe, [
510
+ return (t, n) => (m(), i("div", Je, [
507
511
  a("select", {
508
512
  class: "kun-editor__heading-select",
509
513
  "aria-label": h.value.textSize,
510
514
  onChange: x
511
- }, [a("option", Ye, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("option", {
515
+ }, [a("option", Xe, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("option", {
512
516
  key: e.level,
513
517
  value: e.level
514
- }, y(e.label), 9, Xe))), 128))], 40, Je),
518
+ }, y(e.label), 9, Ze))), 128))], 40, Ye),
515
519
  (m(!0), i(e, null, _(S.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
516
520
  class: "kun-editor__toolbar-divider",
517
521
  "aria-hidden": "true"
@@ -525,7 +529,7 @@ var X = Symbol("kun-editor-context"), ve = [
525
529
  }, [a("span", {
526
530
  class: "kun-editor__icon",
527
531
  innerHTML: e.svg
528
- }, null, 8, Qe)], 8, Ze))), 128))], 64))), 128)),
532
+ }, null, 8, $e)], 8, Qe))), 128))], 64))), 128)),
529
533
  u.value ? (m(), i(e, { key: 0 }, [
530
534
  n[1] ||= a("span", {
531
535
  class: "kun-editor__toolbar-divider",
@@ -540,7 +544,7 @@ var X = Symbol("kun-editor-context"), ve = [
540
544
  }, [a("span", {
541
545
  class: "kun-editor__icon",
542
546
  innerHTML: b($).image
543
- }, null, 8, et)], 8, $e),
547
+ }, null, 8, tt)], 8, et),
544
548
  a("input", {
545
549
  ref_key: "fileInput",
546
550
  ref: C,
@@ -553,10 +557,10 @@ var X = Symbol("kun-editor-context"), ve = [
553
557
  d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
554
558
  class: "kun-editor__toolbar-divider",
555
559
  "aria-hidden": "true"
556
- }, null, -1), o(Ke)], 64)) : r("", !0)
560
+ }, null, -1), o(qe)], 64)) : r("", !0)
557
561
  ]));
558
562
  }
559
- }), nt = /* @__PURE__ */ s({
563
+ }), rt = /* @__PURE__ */ s({
560
564
  __name: "ToolbarHost",
561
565
  setup(e) {
562
566
  let [, t] = k(), n = l(X, void 0), r = (e, n) => {
@@ -600,7 +604,7 @@ var X = Symbol("kun-editor-context"), ve = [
600
604
  };
601
605
  return (e, t) => v(e.$slots, "default", d(c(a)));
602
606
  }
603
- }), rt = /* @__PURE__ */ s({
607
+ }), it = /* @__PURE__ */ s({
604
608
  __name: "MarkdownSource",
605
609
  props: {
606
610
  modelValue: {},
@@ -608,47 +612,60 @@ var X = Symbol("kun-editor-context"), ve = [
608
612
  },
609
613
  emits: ["update:modelValue"],
610
614
  setup(e, { emit: t }) {
611
- let n = e, r = t, a = g(null), o = null, s = (e) => he.create({
615
+ let n = e, r = t, a = g(null), o = null, s = he.define(), c = (e) => ge.create({
612
616
  doc: e,
613
617
  extensions: [
614
618
  ee(),
615
619
  Y.lineWrapping,
616
- _e,
617
- ge(),
620
+ ve,
621
+ _e(),
618
622
  Y.editable.of(!n.readonly),
619
623
  Y.updateListener.of((e) => {
620
- e.docChanged && r("update:modelValue", e.state.doc.toString());
624
+ e.docChanged && !e.transactions.some((e) => e.annotation(s)) && r("update:modelValue", e.state.doc.toString());
621
625
  })
622
626
  ]
623
627
  });
624
628
  return p(() => {
625
629
  a.value && (o = new Y({
626
- state: s(n.modelValue),
630
+ state: c(n.modelValue),
627
631
  parent: a.value
628
632
  }));
629
633
  }), f(() => {
630
634
  o?.destroy(), o = null;
631
635
  }), S(() => n.modelValue, (e) => {
632
- o && o.state.doc.toString() !== e && o.setState(s(e));
636
+ if (!o || o.state.doc.toString() === e) return;
637
+ let { anchor: t, head: n } = o.state.selection.main, r = e.length;
638
+ o.dispatch({
639
+ changes: {
640
+ from: 0,
641
+ to: o.state.doc.length,
642
+ insert: e
643
+ },
644
+ selection: {
645
+ anchor: Math.min(t, r),
646
+ head: Math.min(n, r)
647
+ },
648
+ annotations: s.of(!0)
649
+ });
633
650
  }), (e, t) => (m(), i("div", {
634
651
  ref_key: "host",
635
652
  ref: a,
636
653
  class: "kun-editor__source"
637
654
  }, null, 512));
638
655
  }
639
- }), it = ["data-mode"], at = {
656
+ }), at = ["data-mode"], ot = {
640
657
  key: 0,
641
658
  class: "kun-editor__toolbar",
642
659
  role: "tablist"
643
- }, ot = [
660
+ }, st = [
644
661
  "aria-selected",
645
662
  "data-active",
646
663
  "onClick"
647
- ], st = ["title", "aria-label"], ct = [
664
+ ], ct = ["title", "aria-label"], lt = [
648
665
  "data-active",
649
666
  "title",
650
667
  "aria-pressed"
651
- ], lt = ["data-swap"], ut = { class: "kun-editor__wysiwyg kun-editor__pane" }, dt = /* @__PURE__ */ s({
668
+ ], ut = ["data-swap"], dt = { class: "kun-editor__wysiwyg kun-editor__pane" }, ft = /* @__PURE__ */ s({
652
669
  __name: "KunEditor",
653
670
  props: {
654
671
  modelValue: {},
@@ -766,41 +783,41 @@ var X = Symbol("kun-editor-context"), ve = [
766
783
  swap: P,
767
784
  scrollSync: F.value,
768
785
  toggleScrollSync: I
769
- }, () => [s.views.length > 1 ? (m(), i("div", at, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
786
+ }, () => [s.views.length > 1 ? (m(), i("div", ot, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
770
787
  key: e,
771
788
  type: "button",
772
789
  class: "kun-editor__tab",
773
790
  "aria-selected": j.value === e,
774
791
  "data-active": j.value === e,
775
792
  onClick: (t) => M(e)
776
- }, y(R.value[e]), 9, ot))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
793
+ }, y(R.value[e]), 9, st))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
777
794
  type: "button",
778
795
  class: "kun-editor__tab kun-editor__swap",
779
796
  title: R.value.swap,
780
797
  "aria-label": R.value.swap,
781
798
  onClick: l[0] ||= (e) => P()
782
- }, " ⇄ ", 8, st), a("button", {
799
+ }, " ⇄ ", 8, ct), a("button", {
783
800
  type: "button",
784
801
  class: "kun-editor__tab",
785
802
  "data-active": F.value,
786
803
  title: R.value.scrollSync,
787
804
  "aria-pressed": F.value,
788
805
  onClick: l[1] ||= (e) => I()
789
- }, y(R.value.scrollSync), 9, ct)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
806
+ }, y(R.value.scrollSync), 9, lt)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
790
807
  default: C(() => [o(b(A), null, {
791
- default: C(() => [w(a("div", null, [o(nt, null, {
792
- default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(tt)])]),
808
+ default: C(() => [w(a("div", null, [o(rt, null, {
809
+ default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(nt)])]),
793
810
  _: 3
794
811
  })], 512), [[x, j.value === "wysiwyg" && !s.readonly]]), a("div", {
795
812
  class: "kun-editor__panes",
796
813
  "data-swap": N.value
797
- }, [j.value === "source" || j.value === "split" ? (m(), n(rt, {
814
+ }, [j.value === "source" || j.value === "split" ? (m(), n(it, {
798
815
  key: 0,
799
816
  class: "kun-editor__pane",
800
817
  "model-value": s.modelValue,
801
818
  readonly: s.readonly,
802
819
  "onUpdate:modelValue": K
803
- }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ut, [o(Ae, {
820
+ }, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", dt, [o(je, {
804
821
  ref_key: "inner",
805
822
  ref: q,
806
823
  "model-value": s.modelValue,
@@ -810,6 +827,7 @@ var X = Symbol("kun-editor-context"), ve = [
810
827
  readonly: G.value,
811
828
  placeholder: s.placeholder,
812
829
  "placeholder-mode": s.placeholderMode,
830
+ active: j.value === "wysiwyg" && !s.readonly,
813
831
  "selection-toolbar": k.value,
814
832
  "onUpdate:modelValue": K
815
833
  }, null, 8, [
@@ -820,15 +838,16 @@ var X = Symbol("kun-editor-context"), ve = [
820
838
  "readonly",
821
839
  "placeholder",
822
840
  "placeholder-mode",
841
+ "active",
823
842
  "selection-toolbar"
824
- ])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, lt)]),
843
+ ])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, ut)]),
825
844
  _: 3
826
845
  })]),
827
846
  _: 3
828
- })], 8, it));
847
+ })], 8, at));
829
848
  }
830
- }), ft = { install(e) {
831
- e.component("KunEditor", dt);
849
+ }), pt = { install(e) {
850
+ e.component("KunEditor", ft);
832
851
  } };
833
852
  //#endregion
834
- export { je as EMOJI, dt as KunEditor, ft as KunEditorPlugin };
853
+ export { Me as EMOJI, ft as KunEditor, pt as KunEditorPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungal/editor-vue",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
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.25.0"
43
+ "@kungal/editor-core": "0.25.2"
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.25.0"
83
+ "@kungal/editor-core": "0.25.2"
84
84
  },
85
85
  "scripts": {
86
86
  "build": "vite build && vue-tsc -p tsconfig.build.json",