@kungal/editor-nuxt 0.18.0 → 0.20.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 +70 -0
- package/package.json +3 -3
- package/runtime/KunEditorViewSwitch.vue +43 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# @kungal/editor-nuxt
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 62e14f5: Split view: sync scrolling between the panes, with an off switch.
|
|
8
|
+
|
|
9
|
+
Scrolling the markdown source pane now scrolls the WYSIWYG preview to the same
|
|
10
|
+
position (and vice-versa) — proportional/percentage sync (source↔preview line
|
|
11
|
+
mapping is impractical across two separate renderers), with an active-pane +
|
|
12
|
+
idle-timeout guard so the echoed scroll doesn't feed back into a loop.
|
|
13
|
+
|
|
14
|
+
Turn it off two ways (for downstream customization):
|
|
15
|
+
|
|
16
|
+
- **`scrollSync` prop** on `<KunEditor>` (default `true`) — pass
|
|
17
|
+
`:scroll-sync="false"` to disable entirely.
|
|
18
|
+
- **A runtime toggle** in the view switch: `KunEditorViewSwitchApi` gains
|
|
19
|
+
`scrollSync` / `toggleScrollSync()` (+ `labels.scrollSync`). The default view
|
|
20
|
+
switch shows a 同步滚动 toggle in split mode; `<KunEditorViewSwitch>` (editor-nuxt)
|
|
21
|
+
shows a KunUI link/unlink toggle button. Or replace the whole control via the
|
|
22
|
+
`#view-switch` slot.
|
|
23
|
+
|
|
24
|
+
Sync needs each pane to scroll internally, so the reference `kun-editor.css` now
|
|
25
|
+
gives split panes a bounded height (`--kun-editor-split-height`, default `60vh`,
|
|
26
|
+
overridable) with `overflow: auto`. editor-vue still ships zero CSS.
|
|
27
|
+
|
|
28
|
+
Verified in the docs production build (headless + KunUI view switches): with the
|
|
29
|
+
panes overflowing, scrolling the source drives the preview to the same ratio;
|
|
30
|
+
toggling off makes them scroll independently; toggling on resumes; 0 console
|
|
31
|
+
errors.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [62e14f5]
|
|
36
|
+
- @kungal/editor-vue@0.20.0
|
|
37
|
+
- @kungal/editor-core@0.20.0
|
|
38
|
+
|
|
39
|
+
## 0.19.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- f111b82: Add a desktop **split view** for long-form writing.
|
|
44
|
+
|
|
45
|
+
`<KunEditor>` now has a third view mode, `split`, alongside WYSIWYG and Markdown:
|
|
46
|
+
an editable markdown source pane + a live **read-only WYSIWYG preview**, side by
|
|
47
|
+
side and left/right swappable. The markdown string stays the single source of
|
|
48
|
+
truth and the preview is derived — the industry-standard model (VS Code /
|
|
49
|
+
StackEdit / Dillinger), so there's no two-editor bidirectional-sync problem.
|
|
50
|
+
|
|
51
|
+
- **editor-vue**: the view mode gains `'split'`; `KunEditorViewSwitchApi` gains
|
|
52
|
+
`swap()` / `swapped` and `labels.split` / `labels.swap`. The WYSIWYG becomes a
|
|
53
|
+
read-only preview in split (its editability now reacts to the `readonly` prop).
|
|
54
|
+
The default hand-rolled view switch gets a 分栏 tab + a ⇄ swap button.
|
|
55
|
+
- **editor-nuxt**: `<KunEditorViewSwitch>` gets the 分栏 KunTab + a KunUI swap
|
|
56
|
+
button (shown in split).
|
|
57
|
+
- **Headless**: the layout is class hooks only — `.kun-editor__panes` /
|
|
58
|
+
`.kun-editor__pane` under `[data-mode='split']` (+ `[data-swap]`). Styled by the
|
|
59
|
+
reference `kun-editor.css`: stacked on narrow screens, side-by-side (swappable)
|
|
60
|
+
from `md` up. editor-vue still ships zero CSS.
|
|
61
|
+
|
|
62
|
+
Verified in the docs production build (headless + KunUI view switches): 分栏 shows
|
|
63
|
+
both panes side by side, typing markdown in the source updates the preview live,
|
|
64
|
+
the WYSIWYG preview is `contenteditable=false`, swap reverses the panes; 0 console
|
|
65
|
+
errors. (Synced scrolling between panes is a possible follow-up.)
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [f111b82]
|
|
70
|
+
- @kungal/editor-vue@0.19.0
|
|
71
|
+
- @kungal/editor-core@0.19.0
|
|
72
|
+
|
|
3
73
|
## 0.18.0
|
|
4
74
|
|
|
5
75
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungal/editor-nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "KunEditor Nuxt Layer — wraps @kungal/editor-vue and auto-imports <KunEditor> so an existing Nuxt app keeps its exact DX (no import needed).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"nuxt.config.ts"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@kungal/editor-core": "0.
|
|
35
|
-
"@kungal/editor-vue": "0.
|
|
34
|
+
"@kungal/editor-core": "0.20.0",
|
|
35
|
+
"@kungal/editor-vue": "0.20.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@kungal/ui-vue": "^2.7.0",
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
// KunUI view switch for <KunEditor>'s #view-switch slot —
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// layer (not headless editor-vue) and is driven purely
|
|
2
|
+
// KunUI view switch for <KunEditor>'s #view-switch slot — 预览 / Markdown / 分栏
|
|
3
|
+
// as a real <KunTab variant="underlined"> (keyboard nav, sliding indicator, a11y),
|
|
4
|
+
// plus a swap button in split mode. Same pattern as <KunEditorToolbar>: it lives
|
|
5
|
+
// in this ui-nuxt-assuming layer (not headless editor-vue) and is driven purely
|
|
6
|
+
// by the slot API.
|
|
6
7
|
//
|
|
7
8
|
// <KunEditor v-model="md">
|
|
8
9
|
// <template #view-switch="s"><KunEditorViewSwitch v-bind="s" /></template>
|
|
9
10
|
// </KunEditor>
|
|
10
11
|
//
|
|
11
|
-
// KunTab
|
|
12
|
+
// KunTab / KunButton / KunIcon are auto-imported by @kungal/ui-nuxt.
|
|
12
13
|
import { computed } from 'vue'
|
|
13
14
|
import type { KunEditorViewSwitchApi } from '@kungal/editor-vue'
|
|
14
15
|
|
|
@@ -16,21 +17,48 @@ const props = defineProps<KunEditorViewSwitchApi>()
|
|
|
16
17
|
|
|
17
18
|
const items = computed(() => [
|
|
18
19
|
{ value: 'wysiwyg', textValue: props.labels.wysiwyg },
|
|
19
|
-
{ value: 'source', textValue: props.labels.source }
|
|
20
|
+
{ value: 'source', textValue: props.labels.source },
|
|
21
|
+
{ value: 'split', textValue: props.labels.split }
|
|
20
22
|
])
|
|
21
23
|
|
|
22
24
|
const onChange = (value: string) => {
|
|
23
|
-
props.setMode(
|
|
25
|
+
props.setMode(
|
|
26
|
+
value === 'source' ? 'source' : value === 'split' ? 'split' : 'wysiwyg'
|
|
27
|
+
)
|
|
24
28
|
}
|
|
25
29
|
</script>
|
|
26
30
|
|
|
27
31
|
<template>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
<div class="flex items-center gap-1">
|
|
33
|
+
<KunTab
|
|
34
|
+
:model-value="mode"
|
|
35
|
+
:items="items"
|
|
36
|
+
variant="underlined"
|
|
37
|
+
color="primary"
|
|
38
|
+
size="sm"
|
|
39
|
+
@update:model-value="onChange"
|
|
40
|
+
/>
|
|
41
|
+
<template v-if="mode === 'split'">
|
|
42
|
+
<KunButton
|
|
43
|
+
variant="light"
|
|
44
|
+
size="sm"
|
|
45
|
+
:is-icon-only="true"
|
|
46
|
+
:aria-label="labels.swap"
|
|
47
|
+
@click="swap()"
|
|
48
|
+
>
|
|
49
|
+
<KunIcon name="lucide:arrow-left-right" />
|
|
50
|
+
</KunButton>
|
|
51
|
+
<KunButton
|
|
52
|
+
:variant="scrollSync ? 'flat' : 'light'"
|
|
53
|
+
:color="scrollSync ? 'primary' : 'default'"
|
|
54
|
+
size="sm"
|
|
55
|
+
:is-icon-only="true"
|
|
56
|
+
:aria-label="labels.scrollSync"
|
|
57
|
+
:aria-pressed="scrollSync"
|
|
58
|
+
@click="toggleScrollSync()"
|
|
59
|
+
>
|
|
60
|
+
<KunIcon :name="scrollSync ? 'lucide:link' : 'lucide:unlink'" />
|
|
61
|
+
</KunButton>
|
|
62
|
+
</template>
|
|
63
|
+
</div>
|
|
36
64
|
</template>
|