@kungal/editor-vue 0.25.0 → 0.25.1
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,33 @@
|
|
|
1
1
|
# @kungal/editor-vue
|
|
2
2
|
|
|
3
|
+
## 0.25.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 177df55: Fix the cursor jumping to the start when editing the source pane in split mode.
|
|
8
|
+
|
|
9
|
+
Typing a character on an empty line (or deleting the first character of a line)
|
|
10
|
+
in the split-view source editor jumped the caret back to the document start. Cause:
|
|
11
|
+
a feedback loop — the source (CodeMirror) edit updated the shared `v-model`, the
|
|
12
|
+
read-only WYSIWYG preview re-rendered and echoed its _re-serialized_ (normalized)
|
|
13
|
+
markdown back into `v-model`, and CodeMirror then rebuilt its whole state
|
|
14
|
+
(`setState`) to match, resetting the selection.
|
|
15
|
+
|
|
16
|
+
Two fixes:
|
|
17
|
+
|
|
18
|
+
- **MilkdownEditor** no longer echoes changes it applied from an external
|
|
19
|
+
`v-model` update (it only emits genuine user edits), so the preview stops
|
|
20
|
+
feeding normalized markdown back.
|
|
21
|
+
- **MarkdownSource** now re-syncs external changes with a content-replacing
|
|
22
|
+
transaction that preserves (clamps) the selection, instead of a full `setState`
|
|
23
|
+
rebuild — so the caret and undo history survive.
|
|
24
|
+
|
|
25
|
+
Verified in the docs production build (split mode): typing `x y z` on an empty
|
|
26
|
+
line yields `xyz` in order; deleting the first char of a line keeps the caret on
|
|
27
|
+
that line; 0 console errors.
|
|
28
|
+
|
|
29
|
+
- @kungal/editor-core@0.25.1
|
|
30
|
+
|
|
3
31
|
## 0.25.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownSource.vue.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownSource.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarkdownSource.vue.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownSource.vue"],"names":[],"mappings":"AA2GA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AA2FF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MilkdownEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/MilkdownEditor.vue"],"names":[],"mappings":"AA2NA,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;AA0KF,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 {
|
|
13
|
+
import { Annotation as he, EditorState as ge } from "@codemirror/state";
|
|
14
14
|
import { EditorView as Y } from "@codemirror/view";
|
|
15
|
-
import { markdown as
|
|
16
|
-
import { basicSetup as
|
|
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"),
|
|
18
|
+
var X = Symbol("kun-editor-context"), ye = [
|
|
19
19
|
"data-active",
|
|
20
20
|
"onMousedown",
|
|
21
21
|
"onMouseenter"
|
|
22
|
-
],
|
|
22
|
+
], be = ["src", "alt"], xe = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "kun-mention-dropdown__avatar kun-mention-dropdown__avatar--fallback"
|
|
25
|
-
},
|
|
25
|
+
}, Se = { class: "kun-mention-dropdown__name" }, Ce = {
|
|
26
26
|
key: 1,
|
|
27
27
|
class: "kun-mention-dropdown__hint"
|
|
28
|
-
},
|
|
28
|
+
}, we = {
|
|
29
29
|
key: 2,
|
|
30
30
|
class: "kun-mention-dropdown__hint"
|
|
31
|
-
},
|
|
31
|
+
}, Te = {
|
|
32
32
|
key: 3,
|
|
33
33
|
class: "kun-mention-dropdown__hint"
|
|
34
|
-
},
|
|
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,
|
|
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
|
-
},
|
|
159
|
+
}, De = {
|
|
160
160
|
key: 0,
|
|
161
161
|
class: "kun-editor__toolbar-divider",
|
|
162
162
|
"aria-hidden": "true"
|
|
163
|
-
},
|
|
163
|
+
}, Oe = [
|
|
164
164
|
"title",
|
|
165
165
|
"aria-label",
|
|
166
166
|
"onMousedown"
|
|
167
|
-
],
|
|
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",
|
|
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,
|
|
234
|
+
}, null, 8, ke)], 40, Oe))], 64))), 128))], 512));
|
|
235
235
|
}
|
|
236
|
-
}),
|
|
236
|
+
}), je = /* @__PURE__ */ s({
|
|
237
237
|
__name: "MilkdownEditor",
|
|
238
238
|
props: {
|
|
239
239
|
modelValue: {},
|
|
@@ -247,57 +247,60 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
247
247
|
},
|
|
248
248
|
emits: ["update:modelValue"],
|
|
249
249
|
setup(e, { expose: t, emit: r }) {
|
|
250
|
-
let i = e, a = r, o = i.modelValue, s = M(),
|
|
250
|
+
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
251
|
let t = N.make().config((t) => {
|
|
252
252
|
t.set(L, e), t.set(P, i.modelValue), t.get(R).markdownUpdated((e, t, n) => {
|
|
253
|
-
t
|
|
253
|
+
s || t === n || (o = t, a("update:modelValue", t));
|
|
254
254
|
}), t.update(I, (e) => ({
|
|
255
255
|
...e,
|
|
256
256
|
editable: () => !i.readonly
|
|
257
|
-
})),
|
|
257
|
+
})), u && t.set(l.key, { view: c({ component: Ee }) }), f && t.set(d.key, { view: c({ component: Ae }) });
|
|
258
258
|
}).use(G(i.adapters, i.features, {
|
|
259
259
|
locale: i.locale,
|
|
260
260
|
placeholder: i.placeholder,
|
|
261
261
|
placeholderMode: i.placeholderMode
|
|
262
262
|
}));
|
|
263
|
-
return
|
|
263
|
+
return u && t.use(l), f && t.use(d), t;
|
|
264
264
|
});
|
|
265
265
|
S(() => i.modelValue, (e) => {
|
|
266
|
-
e
|
|
266
|
+
if (e === o) return;
|
|
267
|
+
o = e;
|
|
268
|
+
let t = p.get();
|
|
269
|
+
t && (s = !0, t.action(W(e)), s = !1);
|
|
267
270
|
}), S(() => i.readonly, () => {
|
|
268
|
-
|
|
271
|
+
p.get()?.action((e) => {
|
|
269
272
|
let t = e.get(F);
|
|
270
273
|
t.dispatch(t.state.tr);
|
|
271
274
|
});
|
|
272
275
|
});
|
|
273
|
-
let
|
|
274
|
-
|
|
276
|
+
let h = () => {
|
|
277
|
+
p.get()?.action((e) => e.get(F).focus());
|
|
275
278
|
};
|
|
276
279
|
return t({
|
|
277
280
|
insertQuote: (e) => {
|
|
278
|
-
|
|
281
|
+
p.get()?.action(U(J.key, e)), h();
|
|
279
282
|
},
|
|
280
283
|
insertMention: (e) => {
|
|
281
|
-
|
|
284
|
+
p.get()?.action(U(q.key, e)), h();
|
|
282
285
|
},
|
|
283
|
-
focus:
|
|
286
|
+
focus: h
|
|
284
287
|
}), (e, t) => (m(), n(b(E)));
|
|
285
288
|
}
|
|
286
|
-
}),
|
|
289
|
+
}), Me = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Ne = [
|
|
287
290
|
"title",
|
|
288
291
|
"aria-label",
|
|
289
292
|
"aria-expanded"
|
|
290
|
-
],
|
|
293
|
+
], Pe = ["innerHTML"], Fe = { class: "kun-editor__picker-panel" }, Ie = {
|
|
291
294
|
key: 0,
|
|
292
295
|
class: "kun-editor__picker-tabs",
|
|
293
296
|
role: "tablist"
|
|
294
|
-
},
|
|
297
|
+
}, Le = ["data-active"], Re = ["data-active"], ze = { class: "kun-editor__emoji-grid" }, Be = ["onClick"], Ve = {
|
|
295
298
|
key: 1,
|
|
296
299
|
class: "kun-editor__sticker-body"
|
|
297
|
-
},
|
|
300
|
+
}, He = { class: "kun-editor__pack-name" }, Ue = { class: "kun-editor__sticker-grid" }, We = ["title", "onClick"], Ge = ["src", "alt"], Ke = {
|
|
298
301
|
key: 1,
|
|
299
302
|
class: "kun-editor__picker-hint"
|
|
300
|
-
},
|
|
303
|
+
}, qe = /* @__PURE__ */ s({
|
|
301
304
|
__name: "StickerPicker",
|
|
302
305
|
setup(n) {
|
|
303
306
|
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 +356,28 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
353
356
|
}, [a("span", {
|
|
354
357
|
class: "kun-editor__icon",
|
|
355
358
|
innerHTML: b($).smile
|
|
356
|
-
}, null, 8,
|
|
357
|
-
u ? (m(), i("div",
|
|
359
|
+
}, null, 8, Pe)], 8, Ne), w(a("div", Fe, [
|
|
360
|
+
u ? (m(), i("div", Ie, [a("button", {
|
|
358
361
|
type: "button",
|
|
359
362
|
class: "kun-editor__picker-tab",
|
|
360
363
|
"data-active": C.value === "emoji",
|
|
361
364
|
onClick: n[0] ||= (e) => C.value = "emoji"
|
|
362
|
-
}, y(h.value.emoji), 9,
|
|
365
|
+
}, y(h.value.emoji), 9, Le), a("button", {
|
|
363
366
|
type: "button",
|
|
364
367
|
class: "kun-editor__picker-tab",
|
|
365
368
|
"data-active": C.value === "sticker",
|
|
366
369
|
onClick: n[1] ||= (e) => C.value = "sticker"
|
|
367
|
-
}, y(h.value.sticker), 9,
|
|
368
|
-
w(a("div",
|
|
370
|
+
}, y(h.value.sticker), 9, Re)])) : r("", !0),
|
|
371
|
+
w(a("div", ze, [(m(!0), i(e, null, _(b(Me), (e, t) => (m(), i("button", {
|
|
369
372
|
key: t,
|
|
370
373
|
type: "button",
|
|
371
374
|
class: "kun-editor__emoji",
|
|
372
375
|
onClick: (t) => M(e)
|
|
373
|
-
}, y(e), 9,
|
|
374
|
-
u ? w((m(), i("div",
|
|
376
|
+
}, y(e), 9, Be))), 128))], 512), [[x, !u || C.value === "emoji"]]),
|
|
377
|
+
u ? w((m(), i("div", Ve, [T.value.length ? (m(!0), i(e, { key: 0 }, _(T.value, (t) => (m(), i("div", {
|
|
375
378
|
key: t.name,
|
|
376
379
|
class: "kun-editor__pack"
|
|
377
|
-
}, [a("div",
|
|
380
|
+
}, [a("div", He, y(t.name), 1), a("div", Ue, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
|
|
378
381
|
key: t,
|
|
379
382
|
type: "button",
|
|
380
383
|
class: "kun-editor__sticker",
|
|
@@ -384,21 +387,21 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
384
387
|
src: e.src,
|
|
385
388
|
alt: e.name,
|
|
386
389
|
loading: "lazy"
|
|
387
|
-
}, null, 8,
|
|
390
|
+
}, 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
391
|
], 512), [[x, v.value]])], 512));
|
|
389
392
|
}
|
|
390
|
-
}),
|
|
393
|
+
}), Je = {
|
|
391
394
|
class: "kun-editor__format-toolbar",
|
|
392
395
|
role: "toolbar"
|
|
393
|
-
},
|
|
396
|
+
}, Ye = ["aria-label"], Xe = {
|
|
394
397
|
value: "",
|
|
395
398
|
disabled: "",
|
|
396
399
|
selected: ""
|
|
397
|
-
},
|
|
400
|
+
}, Ze = ["value"], Qe = [
|
|
398
401
|
"title",
|
|
399
402
|
"aria-label",
|
|
400
403
|
"onClick"
|
|
401
|
-
],
|
|
404
|
+
], $e = ["innerHTML"], et = ["title", "aria-label"], tt = ["innerHTML"], nt = /* @__PURE__ */ s({
|
|
402
405
|
__name: "EditorToolbar",
|
|
403
406
|
setup(n) {
|
|
404
407
|
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 +506,15 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
503
506
|
});
|
|
504
507
|
});
|
|
505
508
|
};
|
|
506
|
-
return (t, n) => (m(), i("div",
|
|
509
|
+
return (t, n) => (m(), i("div", Je, [
|
|
507
510
|
a("select", {
|
|
508
511
|
class: "kun-editor__heading-select",
|
|
509
512
|
"aria-label": h.value.textSize,
|
|
510
513
|
onChange: x
|
|
511
|
-
}, [a("option",
|
|
514
|
+
}, [a("option", Xe, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("option", {
|
|
512
515
|
key: e.level,
|
|
513
516
|
value: e.level
|
|
514
|
-
}, y(e.label), 9,
|
|
517
|
+
}, y(e.label), 9, Ze))), 128))], 40, Ye),
|
|
515
518
|
(m(!0), i(e, null, _(S.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
|
|
516
519
|
class: "kun-editor__toolbar-divider",
|
|
517
520
|
"aria-hidden": "true"
|
|
@@ -525,7 +528,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
525
528
|
}, [a("span", {
|
|
526
529
|
class: "kun-editor__icon",
|
|
527
530
|
innerHTML: e.svg
|
|
528
|
-
}, null, 8,
|
|
531
|
+
}, null, 8, $e)], 8, Qe))), 128))], 64))), 128)),
|
|
529
532
|
u.value ? (m(), i(e, { key: 0 }, [
|
|
530
533
|
n[1] ||= a("span", {
|
|
531
534
|
class: "kun-editor__toolbar-divider",
|
|
@@ -540,7 +543,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
540
543
|
}, [a("span", {
|
|
541
544
|
class: "kun-editor__icon",
|
|
542
545
|
innerHTML: b($).image
|
|
543
|
-
}, null, 8,
|
|
546
|
+
}, null, 8, tt)], 8, et),
|
|
544
547
|
a("input", {
|
|
545
548
|
ref_key: "fileInput",
|
|
546
549
|
ref: C,
|
|
@@ -553,10 +556,10 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
553
556
|
d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
|
|
554
557
|
class: "kun-editor__toolbar-divider",
|
|
555
558
|
"aria-hidden": "true"
|
|
556
|
-
}, null, -1), o(
|
|
559
|
+
}, null, -1), o(qe)], 64)) : r("", !0)
|
|
557
560
|
]));
|
|
558
561
|
}
|
|
559
|
-
}),
|
|
562
|
+
}), rt = /* @__PURE__ */ s({
|
|
560
563
|
__name: "ToolbarHost",
|
|
561
564
|
setup(e) {
|
|
562
565
|
let [, t] = k(), n = l(X, void 0), r = (e, n) => {
|
|
@@ -600,7 +603,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
600
603
|
};
|
|
601
604
|
return (e, t) => v(e.$slots, "default", d(c(a)));
|
|
602
605
|
}
|
|
603
|
-
}),
|
|
606
|
+
}), it = /* @__PURE__ */ s({
|
|
604
607
|
__name: "MarkdownSource",
|
|
605
608
|
props: {
|
|
606
609
|
modelValue: {},
|
|
@@ -608,47 +611,60 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
608
611
|
},
|
|
609
612
|
emits: ["update:modelValue"],
|
|
610
613
|
setup(e, { emit: t }) {
|
|
611
|
-
let n = e, r = t, a = g(null), o = null, s = (e) =>
|
|
614
|
+
let n = e, r = t, a = g(null), o = null, s = he.define(), c = (e) => ge.create({
|
|
612
615
|
doc: e,
|
|
613
616
|
extensions: [
|
|
614
617
|
ee(),
|
|
615
618
|
Y.lineWrapping,
|
|
616
|
-
|
|
617
|
-
|
|
619
|
+
ve,
|
|
620
|
+
_e(),
|
|
618
621
|
Y.editable.of(!n.readonly),
|
|
619
622
|
Y.updateListener.of((e) => {
|
|
620
|
-
e.docChanged && r("update:modelValue", e.state.doc.toString());
|
|
623
|
+
e.docChanged && !e.transactions.some((e) => e.annotation(s)) && r("update:modelValue", e.state.doc.toString());
|
|
621
624
|
})
|
|
622
625
|
]
|
|
623
626
|
});
|
|
624
627
|
return p(() => {
|
|
625
628
|
a.value && (o = new Y({
|
|
626
|
-
state:
|
|
629
|
+
state: c(n.modelValue),
|
|
627
630
|
parent: a.value
|
|
628
631
|
}));
|
|
629
632
|
}), f(() => {
|
|
630
633
|
o?.destroy(), o = null;
|
|
631
634
|
}), S(() => n.modelValue, (e) => {
|
|
632
|
-
o
|
|
635
|
+
if (!o || o.state.doc.toString() === e) return;
|
|
636
|
+
let { anchor: t, head: n } = o.state.selection.main, r = e.length;
|
|
637
|
+
o.dispatch({
|
|
638
|
+
changes: {
|
|
639
|
+
from: 0,
|
|
640
|
+
to: o.state.doc.length,
|
|
641
|
+
insert: e
|
|
642
|
+
},
|
|
643
|
+
selection: {
|
|
644
|
+
anchor: Math.min(t, r),
|
|
645
|
+
head: Math.min(n, r)
|
|
646
|
+
},
|
|
647
|
+
annotations: s.of(!0)
|
|
648
|
+
});
|
|
633
649
|
}), (e, t) => (m(), i("div", {
|
|
634
650
|
ref_key: "host",
|
|
635
651
|
ref: a,
|
|
636
652
|
class: "kun-editor__source"
|
|
637
653
|
}, null, 512));
|
|
638
654
|
}
|
|
639
|
-
}),
|
|
655
|
+
}), at = ["data-mode"], ot = {
|
|
640
656
|
key: 0,
|
|
641
657
|
class: "kun-editor__toolbar",
|
|
642
658
|
role: "tablist"
|
|
643
|
-
},
|
|
659
|
+
}, st = [
|
|
644
660
|
"aria-selected",
|
|
645
661
|
"data-active",
|
|
646
662
|
"onClick"
|
|
647
|
-
],
|
|
663
|
+
], ct = ["title", "aria-label"], lt = [
|
|
648
664
|
"data-active",
|
|
649
665
|
"title",
|
|
650
666
|
"aria-pressed"
|
|
651
|
-
],
|
|
667
|
+
], ut = ["data-swap"], dt = { class: "kun-editor__wysiwyg kun-editor__pane" }, ft = /* @__PURE__ */ s({
|
|
652
668
|
__name: "KunEditor",
|
|
653
669
|
props: {
|
|
654
670
|
modelValue: {},
|
|
@@ -766,41 +782,41 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
766
782
|
swap: P,
|
|
767
783
|
scrollSync: F.value,
|
|
768
784
|
toggleScrollSync: I
|
|
769
|
-
}, () => [s.views.length > 1 ? (m(), i("div",
|
|
785
|
+
}, () => [s.views.length > 1 ? (m(), i("div", ot, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
|
|
770
786
|
key: e,
|
|
771
787
|
type: "button",
|
|
772
788
|
class: "kun-editor__tab",
|
|
773
789
|
"aria-selected": j.value === e,
|
|
774
790
|
"data-active": j.value === e,
|
|
775
791
|
onClick: (t) => M(e)
|
|
776
|
-
}, y(R.value[e]), 9,
|
|
792
|
+
}, y(R.value[e]), 9, st))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
|
|
777
793
|
type: "button",
|
|
778
794
|
class: "kun-editor__tab kun-editor__swap",
|
|
779
795
|
title: R.value.swap,
|
|
780
796
|
"aria-label": R.value.swap,
|
|
781
797
|
onClick: l[0] ||= (e) => P()
|
|
782
|
-
}, " ⇄ ", 8,
|
|
798
|
+
}, " ⇄ ", 8, ct), a("button", {
|
|
783
799
|
type: "button",
|
|
784
800
|
class: "kun-editor__tab",
|
|
785
801
|
"data-active": F.value,
|
|
786
802
|
title: R.value.scrollSync,
|
|
787
803
|
"aria-pressed": F.value,
|
|
788
804
|
onClick: l[1] ||= (e) => I()
|
|
789
|
-
}, y(R.value.scrollSync), 9,
|
|
805
|
+
}, y(R.value.scrollSync), 9, lt)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
|
|
790
806
|
default: C(() => [o(b(A), null, {
|
|
791
|
-
default: C(() => [w(a("div", null, [o(
|
|
792
|
-
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(
|
|
807
|
+
default: C(() => [w(a("div", null, [o(rt, null, {
|
|
808
|
+
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(nt)])]),
|
|
793
809
|
_: 3
|
|
794
810
|
})], 512), [[x, j.value === "wysiwyg" && !s.readonly]]), a("div", {
|
|
795
811
|
class: "kun-editor__panes",
|
|
796
812
|
"data-swap": N.value
|
|
797
|
-
}, [j.value === "source" || j.value === "split" ? (m(), n(
|
|
813
|
+
}, [j.value === "source" || j.value === "split" ? (m(), n(it, {
|
|
798
814
|
key: 0,
|
|
799
815
|
class: "kun-editor__pane",
|
|
800
816
|
"model-value": s.modelValue,
|
|
801
817
|
readonly: s.readonly,
|
|
802
818
|
"onUpdate:modelValue": K
|
|
803
|
-
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div",
|
|
819
|
+
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", dt, [o(je, {
|
|
804
820
|
ref_key: "inner",
|
|
805
821
|
ref: q,
|
|
806
822
|
"model-value": s.modelValue,
|
|
@@ -821,14 +837,14 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
821
837
|
"placeholder",
|
|
822
838
|
"placeholder-mode",
|
|
823
839
|
"selection-toolbar"
|
|
824
|
-
])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8,
|
|
840
|
+
])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, ut)]),
|
|
825
841
|
_: 3
|
|
826
842
|
})]),
|
|
827
843
|
_: 3
|
|
828
|
-
})], 8,
|
|
844
|
+
})], 8, at));
|
|
829
845
|
}
|
|
830
|
-
}),
|
|
831
|
-
e.component("KunEditor",
|
|
846
|
+
}), pt = { install(e) {
|
|
847
|
+
e.component("KunEditor", ft);
|
|
832
848
|
} };
|
|
833
849
|
//#endregion
|
|
834
|
-
export {
|
|
850
|
+
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.
|
|
3
|
+
"version": "0.25.1",
|
|
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.
|
|
43
|
+
"@kungal/editor-core": "0.25.1"
|
|
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.
|
|
83
|
+
"@kungal/editor-core": "0.25.1"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "vite build && vue-tsc -p tsconfig.build.json",
|