@kungal/editor-vue 0.23.0 → 0.25.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 +63 -0
- package/dist/components/KunEditor.vue.d.ts +17 -5
- package/dist/components/KunEditor.vue.d.ts.map +1 -1
- package/dist/components/MilkdownEditor.vue.d.ts +1 -0
- package/dist/components/MilkdownEditor.vue.d.ts.map +1 -1
- package/dist/components/SelectionTooltip.vue.d.ts.map +1 -1
- package/dist/components/ToolbarHost.vue.d.ts.map +1 -1
- package/dist/context.d.ts +3 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +162 -132
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# @kungal/editor-vue
|
|
2
2
|
|
|
3
|
+
## 0.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a103220: Placeholder: default to `'doc'` mode + expose `placeholderMode`.
|
|
8
|
+
|
|
9
|
+
The placeholder used to appear on **every empty line** (the cursor's empty
|
|
10
|
+
block) — that's the Milkdown/Notion `'block'` behavior, which was the default but
|
|
11
|
+
is surprising for a reply/comment editor. `<KunEditor>` now defaults to `'doc'`:
|
|
12
|
+
the placeholder shows **only while the whole editor is empty** (the conventional
|
|
13
|
+
empty-state hint), and the new `placeholderMode` prop opts back into per-line
|
|
14
|
+
`'block'`:
|
|
15
|
+
|
|
16
|
+
```vue
|
|
17
|
+
<KunEditor v-model="md" placeholder="写点什么…" />
|
|
18
|
+
<!-- only when empty -->
|
|
19
|
+
<KunEditor v-model="md" placeholder="写点什么…" placeholder-mode="block" />
|
|
20
|
+
<!-- on each empty line -->
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
(The lower-level `createKunEditorPlugins(..., { placeholderMode })` /
|
|
24
|
+
`createPlaceholderPlugin` still default to `'block'` for parity with Crepe; the
|
|
25
|
+
opinion lives in the `<KunEditor>` component.)
|
|
26
|
+
|
|
27
|
+
Verified in the docs production build: empty editor shows the placeholder; typing
|
|
28
|
+
a line then Enter (an empty line in a non-empty doc) does not; `placeholder-mode="block"`
|
|
29
|
+
brings back the per-line hint. 47 core tests pass (incl. new doc-vs-block cases).
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- @kungal/editor-core@0.25.0
|
|
34
|
+
|
|
35
|
+
## 0.24.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 5c981df: The selection bubble toolbar's buttons are now configurable.
|
|
40
|
+
|
|
41
|
+
`<KunEditor>`'s `selectionToolbar` prop now accepts `boolean | KunSelectionItem[]`:
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<KunEditor v-model="md" />
|
|
45
|
+
<!-- default 4 buttons -->
|
|
46
|
+
<KunEditor v-model="md" :selection-toolbar="['bold', 'italic']" />
|
|
47
|
+
<!-- reorder / subset -->
|
|
48
|
+
<KunEditor v-model="md" :selection-toolbar="false" />
|
|
49
|
+
<!-- off -->
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`KunSelectionItem` is `'bold' | 'italic' | 'strike' | 'code' | '|'` (`'|'` a
|
|
53
|
+
divider), exported from `@kungal/editor-vue`. The resolved items reach the bubble
|
|
54
|
+
(a plugin view) through the editor context; dividers collapse around removed
|
|
55
|
+
items. The bubble's **look** is (and was) styled via the `.kun-editor__bubble` /
|
|
56
|
+
`.kun-editor__bubble-btn` class hooks — headless, no new API.
|
|
57
|
+
|
|
58
|
+
Verified in the docs production build: an editor with
|
|
59
|
+
`:selection-toolbar="['bold','italic']"` shows a 2-button bubble while the default
|
|
60
|
+
shows 4; 0 console errors.
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- @kungal/editor-core@0.24.0
|
|
65
|
+
|
|
3
66
|
## 0.23.0
|
|
4
67
|
|
|
5
68
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
|
|
2
|
-
import type { KunEditorExpose } from '../types';
|
|
2
|
+
import type { KunEditorExpose, KunSelectionItem } from '../types';
|
|
3
3
|
type ViewMode = 'wysiwyg' | 'source' | 'split';
|
|
4
4
|
type __VLS_Props = {
|
|
5
5
|
/** Bound markdown (v-model). */
|
|
@@ -12,8 +12,14 @@ type __VLS_Props = {
|
|
|
12
12
|
locale?: KunEditorLocale;
|
|
13
13
|
/** Read-only render (no editing). */
|
|
14
14
|
readonly?: boolean;
|
|
15
|
-
/** Placeholder text shown while
|
|
15
|
+
/** Placeholder text shown while empty. */
|
|
16
16
|
placeholder?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When the placeholder shows: `'doc'` (default) only while the whole editor
|
|
19
|
+
* is empty (the conventional empty-state hint); `'block'` on any empty block
|
|
20
|
+
* at the cursor (Notion style — a hint on every new empty line).
|
|
21
|
+
*/
|
|
22
|
+
placeholderMode?: 'doc' | 'block';
|
|
17
23
|
/**
|
|
18
24
|
* Which view modes to offer in the switch. Default all three. Drop `'split'`
|
|
19
25
|
* (or use just `['wysiwyg']`) for compact editors like a reply/comment box —
|
|
@@ -23,8 +29,13 @@ type __VLS_Props = {
|
|
|
23
29
|
/** Sync scrolling between the split panes. Default `true`; set `false` to
|
|
24
30
|
* disable (or toggle it at runtime via the view-switch API). */
|
|
25
31
|
scrollSync?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
|
|
32
|
+
/**
|
|
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
|
|
36
|
+
* `.kun-editor__bubble` / `.kun-editor__bubble-btn` class hooks.
|
|
37
|
+
*/
|
|
38
|
+
selectionToolbar?: boolean | KunSelectionItem[];
|
|
28
39
|
};
|
|
29
40
|
declare var __VLS_1: {
|
|
30
41
|
mode: ViewMode;
|
|
@@ -73,7 +84,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, KunEditorEx
|
|
|
73
84
|
locale: KunEditorLocale;
|
|
74
85
|
readonly: boolean;
|
|
75
86
|
placeholder: string;
|
|
76
|
-
|
|
87
|
+
placeholderMode: "doc" | "block";
|
|
88
|
+
selectionToolbar: boolean | KunSelectionItem[];
|
|
77
89
|
views: ViewMode[];
|
|
78
90
|
scrollSync: boolean;
|
|
79
91
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KunEditor.vue.d.ts","sourceRoot":"","sources":["../../src/components/KunEditor.vue"],"names":[],"mappings":"
|
|
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;;iBArWS,QAAQ;;;;;;;;;;;;;CAqWP,EAAE,QAAQ;iEAzd/B,CAzUkC;;;;;;;;;;;;;;;CAkyB8B,CAAE;AAClE,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GAClD;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAQhD,QAAA,MAAM,UAAU;;;;;cAxcD,iBAAiB;cAEjB,iBAAiB;YAEnB,eAAe;cAEb,OAAO;iBAEJ,MAAM;qBAMF,KAAK,GAAG,OAAO;sBAgBd,OAAO,GAAG,gBAAgB,EAAE;WAVvC,QAAQ,EAAE;gBAGL,OAAO;6EAsbtB,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"}
|
|
@@ -7,6 +7,7 @@ type __VLS_Props = {
|
|
|
7
7
|
locale: KunEditorLocale;
|
|
8
8
|
readonly: boolean;
|
|
9
9
|
placeholder: string;
|
|
10
|
+
placeholderMode: 'doc' | 'block';
|
|
10
11
|
selectionToolbar: boolean;
|
|
11
12
|
};
|
|
12
13
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, KunEditorExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -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":"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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectionTooltip.vue.d.ts","sourceRoot":"","sources":["../../src/components/SelectionTooltip.vue"],"names":[],"mappings":"AA2RA,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":"AAyFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuFhD,QAAA,IAAI,OAAO;oCAxFX,
|
|
1
|
+
{"version":3,"file":"ToolbarHost.vue.d.ts","sourceRoot":"","sources":["../../src/components/ToolbarHost.vue"],"names":[],"mappings":"AAyFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuFhD,QAAA,IAAI,OAAO;oCAxFX,CArDQ;;;;;;;;;;;;;;;CA6Ic,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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InjectionKey } from 'vue';
|
|
2
2
|
import type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale } from '@kungal/editor-core';
|
|
3
|
+
import type { KunSelectionItem } from './types';
|
|
3
4
|
export interface KunEditorContext {
|
|
4
5
|
/** The host policy bundle (searchMentionUsers, stickerSource, notify, …). */
|
|
5
6
|
readonly adapters: KunEditorAdapters;
|
|
@@ -7,6 +8,8 @@ export interface KunEditorContext {
|
|
|
7
8
|
readonly features: KunEditorFeatures;
|
|
8
9
|
/** UI language, for view chrome (dropdown hints, picker tabs, etc.). */
|
|
9
10
|
readonly locale: KunEditorLocale;
|
|
11
|
+
/** Ordered buttons for the selection bubble toolbar (a plugin view reads it). */
|
|
12
|
+
readonly selectionToolbarItems: KunSelectionItem[];
|
|
10
13
|
}
|
|
11
14
|
export declare const KUN_EDITOR_CONTEXT: InjectionKey<KunEditorContext>;
|
|
12
15
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -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;
|
|
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,MAAM,SAAS,CAAA;AAE/C,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;CACnD;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,gBAAgB,CAChC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { KunEditor };
|
|
|
4
4
|
export type { KunEditorExpose } from './types';
|
|
5
5
|
export type { KunEditorToolbarApi } from './types';
|
|
6
6
|
export type { KunToolbarItem } from './types';
|
|
7
|
+
export type { KunSelectionItem } from './types';
|
|
7
8
|
export type { KunEditorViewSwitchApi } from './types';
|
|
8
9
|
export { EMOJI } from './emoji';
|
|
9
10
|
export type { KunEditorAdapters, KunEditorFeatures, KunEditorLocale, UploadImage, SearchMentionUsers, StickerSource, Notify, NotifyLevel, MentionUser, StickerItem, StickerPack } from '@kungal/editor-core';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,CAAA;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAA;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,MAI7B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,CAAA;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAGrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAA;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,MAI7B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { listenerCtx as R } from "@milkdown/kit/plugin/listener";
|
|
|
6
6
|
import { SlashProvider as z, slashFactory as B } from "@milkdown/kit/plugin/slash";
|
|
7
7
|
import { TooltipProvider as V, tooltipFactory as H } from "@milkdown/kit/plugin/tooltip";
|
|
8
8
|
import { callCommand as U, replaceAll as W } from "@milkdown/kit/utils";
|
|
9
|
-
import { createKunEditorPlugins as G, insertKunSpoilerCommand as
|
|
9
|
+
import { createKunEditorPlugins as G, insertKunSpoilerCommand as K, insertMentionCommand as q, insertQuoteCommand as J, kunCM as ee, mentionId as te, setHeadingCommand as ne, startImageUpload as re } from "@kungal/editor-core/preset";
|
|
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";
|
|
@@ -74,7 +74,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
74
74
|
}, I = (e) => {
|
|
75
75
|
let t = d.value;
|
|
76
76
|
if (!t || !O) return;
|
|
77
|
-
let n = t.state.schema.nodes[
|
|
77
|
+
let n = t.state.schema.nodes[te];
|
|
78
78
|
if (!n) return;
|
|
79
79
|
let r = n.create({
|
|
80
80
|
userId: e.id,
|
|
@@ -156,39 +156,56 @@ 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
|
+
}, Ee = {
|
|
160
|
+
key: 0,
|
|
161
|
+
class: "kun-editor__toolbar-divider",
|
|
162
|
+
"aria-hidden": "true"
|
|
163
|
+
}, De = [
|
|
160
164
|
"title",
|
|
161
165
|
"aria-label",
|
|
162
166
|
"onMousedown"
|
|
163
|
-
],
|
|
167
|
+
], Oe = ["innerHTML"], ke = /* @__PURE__ */ s({
|
|
164
168
|
__name: "SelectionTooltip",
|
|
165
169
|
setup(n) {
|
|
166
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) => {
|
|
167
171
|
s()?.action(U(e, t));
|
|
168
172
|
}, y = t(() => {
|
|
169
173
|
let e = u.value;
|
|
170
|
-
return
|
|
171
|
-
{
|
|
174
|
+
return {
|
|
175
|
+
bold: {
|
|
172
176
|
svg: $.bold,
|
|
173
177
|
title: e ? "Bold" : "加粗",
|
|
174
178
|
run: () => v(ue.key)
|
|
175
179
|
},
|
|
176
|
-
{
|
|
180
|
+
italic: {
|
|
177
181
|
svg: $.italic,
|
|
178
182
|
title: e ? "Italic" : "斜体",
|
|
179
183
|
run: () => v(ce.key)
|
|
180
184
|
},
|
|
181
|
-
{
|
|
185
|
+
strike: {
|
|
182
186
|
svg: $.strike,
|
|
183
187
|
title: e ? "Strikethrough" : "删除线",
|
|
184
188
|
run: () => v(me.key)
|
|
185
189
|
},
|
|
186
|
-
{
|
|
190
|
+
code: {
|
|
187
191
|
svg: $.code,
|
|
188
192
|
title: e ? "Inline code" : "行内代码",
|
|
189
193
|
run: () => v(le.key)
|
|
190
194
|
}
|
|
191
|
-
|
|
195
|
+
};
|
|
196
|
+
}), b = t(() => {
|
|
197
|
+
let e = y.value, t = (c?.selectionToolbarItems ?? [
|
|
198
|
+
"bold",
|
|
199
|
+
"italic",
|
|
200
|
+
"strike",
|
|
201
|
+
"code"
|
|
202
|
+
]).map((t) => t === "|" ? { divider: !0 } : e[t] ? {
|
|
203
|
+
divider: !1,
|
|
204
|
+
...e[t]
|
|
205
|
+
} : null).filter((e) => e !== null), n = [];
|
|
206
|
+
for (let e of t) e.divider && (n.length === 0 || n[n.length - 1]?.divider) || n.push(e);
|
|
207
|
+
for (; n.length && n[n.length - 1]?.divider;) n.pop();
|
|
208
|
+
return n;
|
|
192
209
|
});
|
|
193
210
|
return p(() => {
|
|
194
211
|
h = new V({
|
|
@@ -204,19 +221,19 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
204
221
|
ref: d,
|
|
205
222
|
class: "kun-editor__bubble",
|
|
206
223
|
"data-show": "false"
|
|
207
|
-
}, [(m(!0), i(e, null, _(
|
|
208
|
-
key:
|
|
224
|
+
}, [(m(!0), i(e, null, _(b.value, (t, n) => (m(), i(e, { key: n }, [t.divider ? (m(), i("span", Ee)) : (m(), i("button", {
|
|
225
|
+
key: 1,
|
|
209
226
|
type: "button",
|
|
210
227
|
class: "kun-editor__bubble-btn",
|
|
211
|
-
title:
|
|
212
|
-
"aria-label":
|
|
213
|
-
onMousedown: T((
|
|
228
|
+
title: t.title,
|
|
229
|
+
"aria-label": t.title,
|
|
230
|
+
onMousedown: T((e) => t.run(), ["prevent"])
|
|
214
231
|
}, [a("span", {
|
|
215
232
|
class: "kun-editor__icon",
|
|
216
|
-
innerHTML:
|
|
217
|
-
}, null, 8,
|
|
233
|
+
innerHTML: t.svg
|
|
234
|
+
}, null, 8, Oe)], 40, De))], 64))), 128))], 512));
|
|
218
235
|
}
|
|
219
|
-
}),
|
|
236
|
+
}), Ae = /* @__PURE__ */ s({
|
|
220
237
|
__name: "MilkdownEditor",
|
|
221
238
|
props: {
|
|
222
239
|
modelValue: {},
|
|
@@ -225,6 +242,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
225
242
|
locale: {},
|
|
226
243
|
readonly: { type: Boolean },
|
|
227
244
|
placeholder: {},
|
|
245
|
+
placeholderMode: {},
|
|
228
246
|
selectionToolbar: { type: Boolean }
|
|
229
247
|
},
|
|
230
248
|
emits: ["update:modelValue"],
|
|
@@ -236,10 +254,11 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
236
254
|
}), t.update(I, (e) => ({
|
|
237
255
|
...e,
|
|
238
256
|
editable: () => !i.readonly
|
|
239
|
-
})), l && t.set(c.key, { view: s({ component: Te }) }), d && t.set(u.key, { view: s({ component:
|
|
257
|
+
})), l && t.set(c.key, { view: s({ component: Te }) }), d && t.set(u.key, { view: s({ component: ke }) });
|
|
240
258
|
}).use(G(i.adapters, i.features, {
|
|
241
259
|
locale: i.locale,
|
|
242
|
-
placeholder: i.placeholder
|
|
260
|
+
placeholder: i.placeholder,
|
|
261
|
+
placeholderMode: i.placeholderMode
|
|
243
262
|
}));
|
|
244
263
|
return l && t.use(c), d && t.use(u), t;
|
|
245
264
|
});
|
|
@@ -256,29 +275,29 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
256
275
|
};
|
|
257
276
|
return t({
|
|
258
277
|
insertQuote: (e) => {
|
|
259
|
-
f.get()?.action(U(
|
|
278
|
+
f.get()?.action(U(J.key, e)), p();
|
|
260
279
|
},
|
|
261
280
|
insertMention: (e) => {
|
|
262
|
-
f.get()?.action(U(
|
|
281
|
+
f.get()?.action(U(q.key, e)), p();
|
|
263
282
|
},
|
|
264
283
|
focus: p
|
|
265
284
|
}), (e, t) => (m(), n(b(E)));
|
|
266
285
|
}
|
|
267
|
-
}),
|
|
286
|
+
}), je = /* @__PURE__ */ "😀.😃.😄.😁.😆.😅.🤣.😂.🙂.🙃.😉.😊.😇.🥰.😍.🤩.😘.😗.😚.😋.😛.😜.🤪.😝.🤗.🤭.🤔.🤐.😐.😑.😶.😏.😒.🙄.😬.😌.😔.😪.🤤.😴.😷.🤒.🤕.🥵.🥶.🥴.😵.🤯.🤠.🥳.😎.🤓.🧐.😕.😟.🙁.😮.😯.😲.😳.🥺.😦.😧.😨.😰.😥.😢.😭.😱.😖.😣.😞.😓.😩.😫.🥱.😤.😡.😠.🤬.😈.👿.💀.💩.🤡.👻.👽.🤖.😺.😸.👍.👎.👌.🤌.🤏.✌️.🤞.🤟.🤘.👋.🤚.🖐️.✋.👏.🙌.🤝.🙏.💪.👀.👁️.❤️.🧡.💛.💚.💙.💜.🖤.🤍.💔.💕.💞.💓.💗.💖.💘.💝.💯.✨.⭐.🌟.🔥.💥.💫.⚡.☀️.🌈.🎉.🎊.🎁.🏆.🐶.🐱.🐭.🦊.🐻.🐼.🐨.🦄.🐢.🐳.🍎.🍑.🍓.🍉.🍰.🍺.🍵.☕.🍜.🍙.✅.❌.❓.❗.💤.👑.🎮.🎵.📌.🔖".split("."), Me = [
|
|
268
287
|
"title",
|
|
269
288
|
"aria-label",
|
|
270
289
|
"aria-expanded"
|
|
271
|
-
],
|
|
290
|
+
], Ne = ["innerHTML"], Pe = { class: "kun-editor__picker-panel" }, Fe = {
|
|
272
291
|
key: 0,
|
|
273
292
|
class: "kun-editor__picker-tabs",
|
|
274
293
|
role: "tablist"
|
|
275
|
-
},
|
|
294
|
+
}, Ie = ["data-active"], Le = ["data-active"], Re = { class: "kun-editor__emoji-grid" }, ze = ["onClick"], Be = {
|
|
276
295
|
key: 1,
|
|
277
296
|
class: "kun-editor__sticker-body"
|
|
278
|
-
},
|
|
297
|
+
}, Ve = { class: "kun-editor__pack-name" }, He = { class: "kun-editor__sticker-grid" }, Ue = ["title", "onClick"], We = ["src", "alt"], Ge = {
|
|
279
298
|
key: 1,
|
|
280
299
|
class: "kun-editor__picker-hint"
|
|
281
|
-
},
|
|
300
|
+
}, Ke = /* @__PURE__ */ s({
|
|
282
301
|
__name: "StickerPicker",
|
|
283
302
|
setup(n) {
|
|
284
303
|
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 ? {
|
|
@@ -334,28 +353,28 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
334
353
|
}, [a("span", {
|
|
335
354
|
class: "kun-editor__icon",
|
|
336
355
|
innerHTML: b($).smile
|
|
337
|
-
}, null, 8,
|
|
338
|
-
u ? (m(), i("div",
|
|
356
|
+
}, null, 8, Ne)], 8, Me), w(a("div", Pe, [
|
|
357
|
+
u ? (m(), i("div", Fe, [a("button", {
|
|
339
358
|
type: "button",
|
|
340
359
|
class: "kun-editor__picker-tab",
|
|
341
360
|
"data-active": C.value === "emoji",
|
|
342
361
|
onClick: n[0] ||= (e) => C.value = "emoji"
|
|
343
|
-
}, y(h.value.emoji), 9,
|
|
362
|
+
}, y(h.value.emoji), 9, Ie), a("button", {
|
|
344
363
|
type: "button",
|
|
345
364
|
class: "kun-editor__picker-tab",
|
|
346
365
|
"data-active": C.value === "sticker",
|
|
347
366
|
onClick: n[1] ||= (e) => C.value = "sticker"
|
|
348
|
-
}, y(h.value.sticker), 9,
|
|
349
|
-
w(a("div",
|
|
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", {
|
|
350
369
|
key: t,
|
|
351
370
|
type: "button",
|
|
352
371
|
class: "kun-editor__emoji",
|
|
353
372
|
onClick: (t) => M(e)
|
|
354
|
-
}, y(e), 9,
|
|
355
|
-
u ? w((m(), i("div",
|
|
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", {
|
|
356
375
|
key: t.name,
|
|
357
376
|
class: "kun-editor__pack"
|
|
358
|
-
}, [a("div",
|
|
377
|
+
}, [a("div", Ve, y(t.name), 1), a("div", He, [(m(!0), i(e, null, _(t.stickers, (e, t) => (m(), i("button", {
|
|
359
378
|
key: t,
|
|
360
379
|
type: "button",
|
|
361
380
|
class: "kun-editor__sticker",
|
|
@@ -365,21 +384,21 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
365
384
|
src: e.src,
|
|
366
385
|
alt: e.name,
|
|
367
386
|
loading: "lazy"
|
|
368
|
-
}, null, 8,
|
|
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)
|
|
369
388
|
], 512), [[x, v.value]])], 512));
|
|
370
389
|
}
|
|
371
|
-
}),
|
|
390
|
+
}), qe = {
|
|
372
391
|
class: "kun-editor__format-toolbar",
|
|
373
392
|
role: "toolbar"
|
|
374
|
-
},
|
|
393
|
+
}, Je = ["aria-label"], Ye = {
|
|
375
394
|
value: "",
|
|
376
395
|
disabled: "",
|
|
377
396
|
selected: ""
|
|
378
|
-
},
|
|
397
|
+
}, Xe = ["value"], Ze = [
|
|
379
398
|
"title",
|
|
380
399
|
"aria-label",
|
|
381
400
|
"onClick"
|
|
382
|
-
],
|
|
401
|
+
], Qe = ["innerHTML"], $e = ["title", "aria-label"], et = ["innerHTML"], tt = /* @__PURE__ */ s({
|
|
383
402
|
__name: "EditorToolbar",
|
|
384
403
|
setup(n) {
|
|
385
404
|
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) => {
|
|
@@ -416,7 +435,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
416
435
|
}));
|
|
417
436
|
}), x = (e) => {
|
|
418
437
|
let t = e.target;
|
|
419
|
-
p(
|
|
438
|
+
p(ne.key, Number(t.value)), t.selectedIndex = 0;
|
|
420
439
|
}, S = t(() => [
|
|
421
440
|
[
|
|
422
441
|
{
|
|
@@ -470,29 +489,29 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
470
489
|
[{
|
|
471
490
|
svg: $.spoiler,
|
|
472
491
|
title: h.value.spoiler,
|
|
473
|
-
run: () => p(
|
|
492
|
+
run: () => p(K.key)
|
|
474
493
|
}]
|
|
475
494
|
]), C = g(null), w = () => C.value?.click(), T = (e) => {
|
|
476
495
|
let t = e.target, n = t.files?.[0];
|
|
477
496
|
t.value = "";
|
|
478
497
|
let r = u.value;
|
|
479
498
|
!n || !r || s()?.action((e) => {
|
|
480
|
-
|
|
499
|
+
re(e.get(F), n, {
|
|
481
500
|
uploadImage: r,
|
|
482
501
|
notify: c?.adapters.notify,
|
|
483
502
|
locale: c?.locale
|
|
484
503
|
});
|
|
485
504
|
});
|
|
486
505
|
};
|
|
487
|
-
return (t, n) => (m(), i("div",
|
|
506
|
+
return (t, n) => (m(), i("div", qe, [
|
|
488
507
|
a("select", {
|
|
489
508
|
class: "kun-editor__heading-select",
|
|
490
509
|
"aria-label": h.value.textSize,
|
|
491
510
|
onChange: x
|
|
492
|
-
}, [a("option",
|
|
511
|
+
}, [a("option", Ye, y(h.value.textSize), 1), (m(!0), i(e, null, _(v.value, (e) => (m(), i("option", {
|
|
493
512
|
key: e.level,
|
|
494
513
|
value: e.level
|
|
495
|
-
}, y(e.label), 9,
|
|
514
|
+
}, y(e.label), 9, Xe))), 128))], 40, Je),
|
|
496
515
|
(m(!0), i(e, null, _(S.value, (t, r) => (m(), i(e, { key: r }, [n[0] ||= a("span", {
|
|
497
516
|
class: "kun-editor__toolbar-divider",
|
|
498
517
|
"aria-hidden": "true"
|
|
@@ -506,7 +525,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
506
525
|
}, [a("span", {
|
|
507
526
|
class: "kun-editor__icon",
|
|
508
527
|
innerHTML: e.svg
|
|
509
|
-
}, null, 8,
|
|
528
|
+
}, null, 8, Qe)], 8, Ze))), 128))], 64))), 128)),
|
|
510
529
|
u.value ? (m(), i(e, { key: 0 }, [
|
|
511
530
|
n[1] ||= a("span", {
|
|
512
531
|
class: "kun-editor__toolbar-divider",
|
|
@@ -521,7 +540,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
521
540
|
}, [a("span", {
|
|
522
541
|
class: "kun-editor__icon",
|
|
523
542
|
innerHTML: b($).image
|
|
524
|
-
}, null, 8,
|
|
543
|
+
}, null, 8, et)], 8, $e),
|
|
525
544
|
a("input", {
|
|
526
545
|
ref_key: "fileInput",
|
|
527
546
|
ref: C,
|
|
@@ -534,10 +553,10 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
534
553
|
d.value ? (m(), i(e, { key: 1 }, [n[2] ||= a("span", {
|
|
535
554
|
class: "kun-editor__toolbar-divider",
|
|
536
555
|
"aria-hidden": "true"
|
|
537
|
-
}, null, -1), o(
|
|
556
|
+
}, null, -1), o(Ke)], 64)) : r("", !0)
|
|
538
557
|
]));
|
|
539
558
|
}
|
|
540
|
-
}),
|
|
559
|
+
}), nt = /* @__PURE__ */ s({
|
|
541
560
|
__name: "ToolbarHost",
|
|
542
561
|
setup(e) {
|
|
543
562
|
let [, t] = k(), n = l(X, void 0), r = (e, n) => {
|
|
@@ -555,7 +574,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
555
574
|
uploadImage: (e) => {
|
|
556
575
|
let r = n?.adapters.uploadImage, i = t();
|
|
557
576
|
!r || !i || i.action((t) => {
|
|
558
|
-
|
|
577
|
+
re(t.get(F), e, {
|
|
559
578
|
uploadImage: r,
|
|
560
579
|
notify: n?.adapters.notify,
|
|
561
580
|
locale: n?.locale
|
|
@@ -563,10 +582,10 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
563
582
|
});
|
|
564
583
|
},
|
|
565
584
|
insertQuote: (e) => {
|
|
566
|
-
r(
|
|
585
|
+
r(J.key, e), i();
|
|
567
586
|
},
|
|
568
587
|
insertMention: (e) => {
|
|
569
|
-
r(
|
|
588
|
+
r(q.key, e), i();
|
|
570
589
|
},
|
|
571
590
|
focus: i,
|
|
572
591
|
get adapters() {
|
|
@@ -581,7 +600,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
581
600
|
};
|
|
582
601
|
return (e, t) => v(e.$slots, "default", d(c(a)));
|
|
583
602
|
}
|
|
584
|
-
}),
|
|
603
|
+
}), rt = /* @__PURE__ */ s({
|
|
585
604
|
__name: "MarkdownSource",
|
|
586
605
|
props: {
|
|
587
606
|
modelValue: {},
|
|
@@ -592,7 +611,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
592
611
|
let n = e, r = t, a = g(null), o = null, s = (e) => he.create({
|
|
593
612
|
doc: e,
|
|
594
613
|
extensions: [
|
|
595
|
-
|
|
614
|
+
ee(),
|
|
596
615
|
Y.lineWrapping,
|
|
597
616
|
_e,
|
|
598
617
|
ge(),
|
|
@@ -617,19 +636,19 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
617
636
|
class: "kun-editor__source"
|
|
618
637
|
}, null, 512));
|
|
619
638
|
}
|
|
620
|
-
}),
|
|
639
|
+
}), it = ["data-mode"], at = {
|
|
621
640
|
key: 0,
|
|
622
641
|
class: "kun-editor__toolbar",
|
|
623
642
|
role: "tablist"
|
|
624
|
-
},
|
|
643
|
+
}, ot = [
|
|
625
644
|
"aria-selected",
|
|
626
645
|
"data-active",
|
|
627
646
|
"onClick"
|
|
628
|
-
],
|
|
647
|
+
], st = ["title", "aria-label"], ct = [
|
|
629
648
|
"data-active",
|
|
630
649
|
"title",
|
|
631
650
|
"aria-pressed"
|
|
632
|
-
],
|
|
651
|
+
], lt = ["data-swap"], ut = { class: "kun-editor__wysiwyg kun-editor__pane" }, dt = /* @__PURE__ */ s({
|
|
633
652
|
__name: "KunEditor",
|
|
634
653
|
props: {
|
|
635
654
|
modelValue: {},
|
|
@@ -641,6 +660,7 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
641
660
|
default: !1
|
|
642
661
|
},
|
|
643
662
|
placeholder: { default: "" },
|
|
663
|
+
placeholderMode: { default: "doc" },
|
|
644
664
|
views: { default: () => [
|
|
645
665
|
"wysiwyg",
|
|
646
666
|
"source",
|
|
@@ -651,39 +671,47 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
651
671
|
default: !0
|
|
652
672
|
},
|
|
653
673
|
selectionToolbar: {
|
|
654
|
-
type: Boolean,
|
|
674
|
+
type: [Boolean, Array],
|
|
655
675
|
default: !0
|
|
656
676
|
}
|
|
657
677
|
},
|
|
658
678
|
emits: ["update:modelValue"],
|
|
659
679
|
setup(s, { expose: l, emit: p }) {
|
|
660
|
-
let T =
|
|
680
|
+
let T = [
|
|
681
|
+
"bold",
|
|
682
|
+
"italic",
|
|
683
|
+
"strike",
|
|
684
|
+
"code"
|
|
685
|
+
], E = s, O = p;
|
|
661
686
|
h(X, {
|
|
662
687
|
get adapters() {
|
|
663
|
-
return
|
|
688
|
+
return E.adapters;
|
|
664
689
|
},
|
|
665
690
|
get features() {
|
|
666
|
-
return
|
|
691
|
+
return E.features;
|
|
667
692
|
},
|
|
668
693
|
get locale() {
|
|
669
|
-
return
|
|
694
|
+
return E.locale;
|
|
695
|
+
},
|
|
696
|
+
get selectionToolbarItems() {
|
|
697
|
+
return Array.isArray(E.selectionToolbar) ? E.selectionToolbar : T;
|
|
670
698
|
}
|
|
671
699
|
});
|
|
672
|
-
let
|
|
673
|
-
|
|
700
|
+
let k = t(() => E.selectionToolbar !== !1), j = g(E.views.includes("wysiwyg") ? "wysiwyg" : E.views[0] ?? "wysiwyg"), M = (e) => {
|
|
701
|
+
j.value = e;
|
|
674
702
|
};
|
|
675
|
-
S(() =>
|
|
676
|
-
e.includes(
|
|
703
|
+
S(() => E.views, (e) => {
|
|
704
|
+
e.includes(j.value) || (j.value = e[0] ?? "wysiwyg");
|
|
677
705
|
});
|
|
678
|
-
let
|
|
679
|
-
j.value = !j.value;
|
|
680
|
-
}, N = g(T.scrollSync);
|
|
681
|
-
S(() => T.scrollSync, (e) => {
|
|
682
|
-
N.value = e;
|
|
683
|
-
});
|
|
684
|
-
let P = () => {
|
|
706
|
+
let N = g(!1), P = () => {
|
|
685
707
|
N.value = !N.value;
|
|
686
|
-
}, F =
|
|
708
|
+
}, F = g(E.scrollSync);
|
|
709
|
+
S(() => E.scrollSync, (e) => {
|
|
710
|
+
F.value = e;
|
|
711
|
+
});
|
|
712
|
+
let I = () => {
|
|
713
|
+
F.value = !F.value;
|
|
714
|
+
}, L = t(() => E.locale.toLowerCase().startsWith("en")), R = t(() => L.value ? {
|
|
687
715
|
wysiwyg: "Preview",
|
|
688
716
|
source: "Markdown",
|
|
689
717
|
split: "Split",
|
|
@@ -695,94 +723,95 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
695
723
|
split: "分栏",
|
|
696
724
|
swap: "左右互换",
|
|
697
725
|
scrollSync: "同步滚动"
|
|
698
|
-
}),
|
|
699
|
-
|
|
700
|
-
},
|
|
701
|
-
|
|
702
|
-
let e =
|
|
726
|
+
}), z = g(null), B = null, V = null, H = null, U = () => {
|
|
727
|
+
B?.(), B = null, V = null;
|
|
728
|
+
}, W = () => {
|
|
729
|
+
U();
|
|
730
|
+
let e = z.value;
|
|
703
731
|
if (!e) return;
|
|
704
732
|
let t = e.querySelector(".cm-scroller"), n = e.querySelector(".kun-editor__wysiwyg");
|
|
705
733
|
if (!t || !n) return;
|
|
706
734
|
let r = (e, t) => () => {
|
|
707
|
-
if (
|
|
708
|
-
|
|
735
|
+
if (V && V !== e) return;
|
|
736
|
+
V = e;
|
|
709
737
|
let n = e.scrollHeight - e.clientHeight, r = n > 0 ? e.scrollTop / n : 0, i = t.scrollHeight - t.clientHeight;
|
|
710
|
-
t.scrollTop = r * (i > 0 ? i : 0),
|
|
711
|
-
|
|
738
|
+
t.scrollTop = r * (i > 0 ? i : 0), H && clearTimeout(H), H = setTimeout(() => {
|
|
739
|
+
V = null;
|
|
712
740
|
}, 120);
|
|
713
741
|
}, i = r(t, n), a = r(n, t);
|
|
714
|
-
t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }),
|
|
742
|
+
t.addEventListener("scroll", i, { passive: !0 }), n.addEventListener("scroll", a, { passive: !0 }), B = () => {
|
|
715
743
|
t.removeEventListener("scroll", i), n.removeEventListener("scroll", a);
|
|
716
744
|
};
|
|
717
745
|
};
|
|
718
|
-
S([
|
|
719
|
-
|
|
720
|
-
}), f(
|
|
721
|
-
let
|
|
746
|
+
S([j, F], ([e, t]) => {
|
|
747
|
+
U(), e === "split" && t && u(W);
|
|
748
|
+
}), f(U);
|
|
749
|
+
let G = t(() => E.readonly || j.value === "split"), K = (e) => O("update:modelValue", e), q = g(null);
|
|
722
750
|
return l({
|
|
723
|
-
insertQuote: (e) =>
|
|
724
|
-
insertMention: (e) =>
|
|
725
|
-
focus: () =>
|
|
751
|
+
insertQuote: (e) => q.value?.insertQuote(e),
|
|
752
|
+
insertMention: (e) => q.value?.insertMention(e),
|
|
753
|
+
focus: () => q.value?.focus()
|
|
726
754
|
}), (t, l) => (m(), i("div", {
|
|
727
755
|
ref_key: "rootEl",
|
|
728
|
-
ref:
|
|
756
|
+
ref: z,
|
|
729
757
|
class: "kun-editor",
|
|
730
758
|
"data-kun-editor": "",
|
|
731
|
-
"data-mode":
|
|
759
|
+
"data-mode": j.value
|
|
732
760
|
}, [v(t.$slots, "view-switch", {
|
|
733
|
-
mode:
|
|
734
|
-
setMode:
|
|
735
|
-
labels:
|
|
761
|
+
mode: j.value,
|
|
762
|
+
setMode: M,
|
|
763
|
+
labels: R.value,
|
|
736
764
|
views: s.views,
|
|
737
|
-
swapped:
|
|
738
|
-
swap:
|
|
739
|
-
scrollSync:
|
|
740
|
-
toggleScrollSync:
|
|
741
|
-
}, () => [s.views.length > 1 ? (m(), i("div",
|
|
765
|
+
swapped: N.value,
|
|
766
|
+
swap: P,
|
|
767
|
+
scrollSync: F.value,
|
|
768
|
+
toggleScrollSync: I
|
|
769
|
+
}, () => [s.views.length > 1 ? (m(), i("div", at, [(m(!0), i(e, null, _(s.views, (e) => (m(), i("button", {
|
|
742
770
|
key: e,
|
|
743
771
|
type: "button",
|
|
744
772
|
class: "kun-editor__tab",
|
|
745
|
-
"aria-selected":
|
|
746
|
-
"data-active":
|
|
747
|
-
onClick: (t) =>
|
|
748
|
-
}, y(
|
|
773
|
+
"aria-selected": j.value === e,
|
|
774
|
+
"data-active": j.value === e,
|
|
775
|
+
onClick: (t) => M(e)
|
|
776
|
+
}, y(R.value[e]), 9, ot))), 128)), j.value === "split" ? (m(), i(e, { key: 0 }, [a("button", {
|
|
749
777
|
type: "button",
|
|
750
778
|
class: "kun-editor__tab kun-editor__swap",
|
|
751
|
-
title:
|
|
752
|
-
"aria-label":
|
|
753
|
-
onClick: l[0] ||= (e) =>
|
|
754
|
-
}, " ⇄ ", 8,
|
|
779
|
+
title: R.value.swap,
|
|
780
|
+
"aria-label": R.value.swap,
|
|
781
|
+
onClick: l[0] ||= (e) => P()
|
|
782
|
+
}, " ⇄ ", 8, st), a("button", {
|
|
755
783
|
type: "button",
|
|
756
784
|
class: "kun-editor__tab",
|
|
757
|
-
"data-active":
|
|
758
|
-
title:
|
|
759
|
-
"aria-pressed":
|
|
760
|
-
onClick: l[1] ||= (e) =>
|
|
761
|
-
}, y(
|
|
785
|
+
"data-active": F.value,
|
|
786
|
+
title: R.value.scrollSync,
|
|
787
|
+
"aria-pressed": F.value,
|
|
788
|
+
onClick: l[1] ||= (e) => I()
|
|
789
|
+
}, y(R.value.scrollSync), 9, ct)], 64)) : r("", !0)])) : r("", !0)]), o(b(D), null, {
|
|
762
790
|
default: C(() => [o(b(A), null, {
|
|
763
|
-
default: C(() => [w(a("div", null, [o(
|
|
764
|
-
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(
|
|
791
|
+
default: C(() => [w(a("div", null, [o(nt, null, {
|
|
792
|
+
default: C((e) => [v(t.$slots, "toolbar", d(c(e)), () => [o(tt)])]),
|
|
765
793
|
_: 3
|
|
766
|
-
})], 512), [[x,
|
|
794
|
+
})], 512), [[x, j.value === "wysiwyg" && !s.readonly]]), a("div", {
|
|
767
795
|
class: "kun-editor__panes",
|
|
768
|
-
"data-swap":
|
|
769
|
-
}, [
|
|
796
|
+
"data-swap": N.value
|
|
797
|
+
}, [j.value === "source" || j.value === "split" ? (m(), n(rt, {
|
|
770
798
|
key: 0,
|
|
771
799
|
class: "kun-editor__pane",
|
|
772
800
|
"model-value": s.modelValue,
|
|
773
801
|
readonly: s.readonly,
|
|
774
|
-
"onUpdate:modelValue":
|
|
775
|
-
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div",
|
|
802
|
+
"onUpdate:modelValue": K
|
|
803
|
+
}, null, 8, ["model-value", "readonly"])) : r("", !0), w(a("div", ut, [o(Ae, {
|
|
776
804
|
ref_key: "inner",
|
|
777
|
-
ref:
|
|
805
|
+
ref: q,
|
|
778
806
|
"model-value": s.modelValue,
|
|
779
807
|
adapters: s.adapters,
|
|
780
808
|
features: s.features,
|
|
781
809
|
locale: s.locale,
|
|
782
|
-
readonly:
|
|
810
|
+
readonly: G.value,
|
|
783
811
|
placeholder: s.placeholder,
|
|
784
|
-
"
|
|
785
|
-
"
|
|
812
|
+
"placeholder-mode": s.placeholderMode,
|
|
813
|
+
"selection-toolbar": k.value,
|
|
814
|
+
"onUpdate:modelValue": K
|
|
786
815
|
}, null, 8, [
|
|
787
816
|
"model-value",
|
|
788
817
|
"adapters",
|
|
@@ -790,15 +819,16 @@ var X = Symbol("kun-editor-context"), ve = [
|
|
|
790
819
|
"locale",
|
|
791
820
|
"readonly",
|
|
792
821
|
"placeholder",
|
|
822
|
+
"placeholder-mode",
|
|
793
823
|
"selection-toolbar"
|
|
794
|
-
])], 512), [[x,
|
|
824
|
+
])], 512), [[x, j.value === "wysiwyg" || j.value === "split"]])], 8, lt)]),
|
|
795
825
|
_: 3
|
|
796
826
|
})]),
|
|
797
827
|
_: 3
|
|
798
|
-
})], 8,
|
|
828
|
+
})], 8, it));
|
|
799
829
|
}
|
|
800
|
-
}),
|
|
801
|
-
e.component("KunEditor",
|
|
830
|
+
}), ft = { install(e) {
|
|
831
|
+
e.component("KunEditor", dt);
|
|
802
832
|
} };
|
|
803
833
|
//#endregion
|
|
804
|
-
export {
|
|
834
|
+
export { je as EMOJI, dt as KunEditor, ft as KunEditorPlugin };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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' | 'image' | 'picker' | '|';
|
|
4
|
+
export type KunSelectionItem = 'bold' | 'italic' | 'strike' | 'code' | '|';
|
|
4
5
|
export interface KunEditorToolbarApi {
|
|
5
6
|
/** Run a Milkdown command (import its key from the preset/commonmark/gfm). */
|
|
6
7
|
run: <T>(key: CmdKey<T>, payload?: T) => void;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAK5B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,GACP,WAAW,GACX,IAAI,GACJ,SAAS,GACT,OAAO,GACP,QAAQ,GACR,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAK5B,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,OAAO,GACP,WAAW,GACX,IAAI,GACJ,SAAS,GACT,OAAO,GACP,QAAQ,GACR,GAAG,CAAA;AAIP,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,GAAG,CAAA;AAM1E,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC7C,uDAAuD;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC;;;;OAIG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACjC,0EAA0E;IAC1E,WAAW,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChE,6CAA6C;IAC7C,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAClE,gCAAgC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CACjC;AAMD,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACpC,8BAA8B;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAA;IACvD,8EAA8E;IAC9E,KAAK,EAAE,CAAC,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC,EAAE,CAAA;IACzC,qDAAqD;IACrD,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAA;IAChB,gDAAgD;IAChD,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAA;IACnB,qCAAqC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B;AASD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC5D;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9D,gCAAgC;IAChC,KAAK,IAAI,IAAI,CAAA;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungal/editor-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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.
|
|
43
|
+
"@kungal/editor-core": "0.25.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.
|
|
83
|
+
"@kungal/editor-core": "0.25.0"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "vite build && vue-tsc -p tsconfig.build.json",
|