@kungal/editor-nuxt 0.12.0 → 0.14.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 +61 -0
- package/nuxt.config.ts +40 -5
- package/package.json +3 -3
- package/runtime/KunEditorViewSwitch.vue +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @kungal/editor-nuxt
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 506813b: Add a `#view-switch` slot and a KunUI view switch — the Preview/Markdown tabs are
|
|
8
|
+
now a swappable layer too.
|
|
9
|
+
|
|
10
|
+
`<KunEditor>` exposes a `#view-switch` scoped slot whose props are
|
|
11
|
+
`KunEditorViewSwitchApi` (`mode` / `setMode` / `labels`). The hand-rolled tabs
|
|
12
|
+
are the slot's fallback — omit the slot and nothing changes. This lets a host
|
|
13
|
+
render a real component (or anything) for the view switch and drive the editor
|
|
14
|
+
via `setMode`, without reaching into internals.
|
|
15
|
+
|
|
16
|
+
`@kungal/editor-nuxt` ships `<KunEditorViewSwitch>` (auto-imported): the tabs as a
|
|
17
|
+
real `<KunTab variant="underlined">` (keyboard nav, sliding indicator, a11y):
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<KunEditor v-model="md">
|
|
21
|
+
<template #view-switch="s"><KunEditorViewSwitch v-bind="s" /></template>
|
|
22
|
+
<template #toolbar="api"><KunEditorToolbar v-bind="api" /></template>
|
|
23
|
+
</KunEditor>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Same "headless core + optional KunUI layer" pattern as `#toolbar` /
|
|
27
|
+
`<KunEditorToolbar>`: `@kungal/editor-vue` stays UI-kit-free (default tabs), the
|
|
28
|
+
KunUI ecosystem gets native chrome. Exports `KunEditorViewSwitchApi`.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [506813b]
|
|
33
|
+
- @kungal/editor-vue@0.14.0
|
|
34
|
+
- @kungal/editor-core@0.14.0
|
|
35
|
+
|
|
36
|
+
## 0.13.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- 8ce8210: The Nuxt layer now preconfigures Vite's dev dependency optimizer, so consumers
|
|
41
|
+
never hit the micromark/`debug` dev error.
|
|
42
|
+
|
|
43
|
+
Under `nuxt dev`, Milkdown's tokenizer (micromark) resolves to its DEV build,
|
|
44
|
+
which does `import debug from 'debug'`. `debug` is CommonJS; unless Vite
|
|
45
|
+
pre-bundles it, its browser build is served raw with no `default` export and the
|
|
46
|
+
editor throws at load — `SyntaxError: 'debug' does not provide an export named
|
|
47
|
+
'default'` (create-tokenizer.js), which also aborts app init. Whether it fires is
|
|
48
|
+
non-deterministic per app (it depends on whether Vite's dep scan reaches the
|
|
49
|
+
editor before it evaluates).
|
|
50
|
+
|
|
51
|
+
The layer now sets `vite.optimizeDeps.include` for the editor + Milkdown entry
|
|
52
|
+
points, which Nuxt merges into every consuming app — so esbuild pre-bundles that
|
|
53
|
+
subgraph and resolves micromark's CJS `debug` inside the bundle. No app needs to
|
|
54
|
+
configure this itself. Dev-only: the production build strips micromark's debug
|
|
55
|
+
calls, so `nuxt build` is unaffected. (Plain non-Nuxt Vite apps that use
|
|
56
|
+
`@kungal/editor-vue` directly still add the same `optimizeDeps.include` manually —
|
|
57
|
+
a layer can inject Vite config, a plain package cannot.)
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- @kungal/editor-core@0.13.0
|
|
62
|
+
- @kungal/editor-vue@0.13.0
|
|
63
|
+
|
|
3
64
|
## 0.12.0
|
|
4
65
|
|
|
5
66
|
### Minor Changes
|
package/nuxt.config.ts
CHANGED
|
@@ -5,10 +5,12 @@ import { defineNuxtModule, addComponent, createResolver } from '@nuxt/kit'
|
|
|
5
5
|
// downstream templates use `<KunEditor>` with no import (and Nuxt generates its
|
|
6
6
|
// types, keeping the tag type-checked in consumer templates).
|
|
7
7
|
//
|
|
8
|
-
// It also ships
|
|
9
|
-
// #toolbar
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// It also ships the KunUI chrome for <KunEditor>'s slots — <KunEditorToolbar>
|
|
9
|
+
// (#toolbar) and <KunEditorViewSwitch> (#view-switch, the Preview/Markdown tabs
|
|
10
|
+
// as a real <KunTab>). They belong HERE (this layer already assumes
|
|
11
|
+
// @kungal/ui-nuxt), not in headless @kungal/editor-vue — so editor-vue stays
|
|
12
|
+
// UI-kit-free while the KunUI ecosystem gets native chrome. Same shape as
|
|
13
|
+
// TipTap's optional UI package.
|
|
12
14
|
export default defineNuxtConfig({
|
|
13
15
|
modules: [
|
|
14
16
|
defineNuxtModule({
|
|
@@ -24,9 +26,42 @@ export default defineNuxtConfig({
|
|
|
24
26
|
name: 'KunEditorToolbar',
|
|
25
27
|
filePath: resolve('./runtime/KunEditorToolbar.vue')
|
|
26
28
|
})
|
|
29
|
+
addComponent({
|
|
30
|
+
name: 'KunEditorViewSwitch',
|
|
31
|
+
filePath: resolve('./runtime/KunEditorViewSwitch.vue')
|
|
32
|
+
})
|
|
27
33
|
}
|
|
28
34
|
})
|
|
29
|
-
]
|
|
35
|
+
],
|
|
36
|
+
|
|
37
|
+
// Under `nuxt dev`, Milkdown's markdown tokenizer (micromark) resolves to its
|
|
38
|
+
// DEV build, which does `import debug from 'debug'`. `debug` is CommonJS, so
|
|
39
|
+
// unless Vite pre-bundles it, its browser.js is served raw with no `default`
|
|
40
|
+
// export and the editor throws at load:
|
|
41
|
+
// SyntaxError: … 'debug' does not provide an export named 'default'
|
|
42
|
+
// (create-tokenizer.js)
|
|
43
|
+
// which also aborts app init. Whether it fires is non-deterministic per app —
|
|
44
|
+
// it depends on whether Vite's dep scan reaches the editor before it evaluates
|
|
45
|
+
// (the docs happens to get auto-scanned; other consumers don't). So pin it
|
|
46
|
+
// HERE, in the layer: force-including the editor/milkdown ENTRY points makes
|
|
47
|
+
// esbuild pre-bundle their whole subgraph and resolve micromark's CJS `debug`
|
|
48
|
+
// INSIDE the bundle. Merged into every consumer that extends this layer, so no
|
|
49
|
+
// app configures it. Dev-only: the prod build strips micromark's debug calls.
|
|
50
|
+
//
|
|
51
|
+
// NB: include the resolvable ENTRY points, not `'debug'` — under pnpm's
|
|
52
|
+
// non-hoisted layout `debug` isn't resolvable from the app root, so Vite would
|
|
53
|
+
// silently skip it. Unresolvable entries below are skipped too (harmless).
|
|
54
|
+
vite: {
|
|
55
|
+
optimizeDeps: {
|
|
56
|
+
include: [
|
|
57
|
+
'@kungal/editor-vue',
|
|
58
|
+
'@kungal/editor-core',
|
|
59
|
+
'@kungal/editor-core/preset',
|
|
60
|
+
'@milkdown/kit/preset/commonmark',
|
|
61
|
+
'@milkdown/kit/preset/gfm'
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
30
65
|
})
|
|
31
66
|
|
|
32
67
|
// NOTE: this layer does NOT own a Tailwind entry or import editor styles. The
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungal/editor-nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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": [
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"nuxt.config.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@kungal/editor-core": "0.
|
|
34
|
-
"@kungal/editor-vue": "0.
|
|
33
|
+
"@kungal/editor-core": "0.14.0",
|
|
34
|
+
"@kungal/editor-vue": "0.14.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@kungal/ui-vue": "^2.7.0",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// KunUI view switch for <KunEditor>'s #view-switch slot — the Preview/Markdown
|
|
3
|
+
// tabs as a real <KunTab variant="underlined"> (keyboard nav, sliding indicator,
|
|
4
|
+
// a11y). Same pattern as <KunEditorToolbar>: it lives in this ui-nuxt-assuming
|
|
5
|
+
// layer (not headless editor-vue) and is driven purely by the slot API.
|
|
6
|
+
//
|
|
7
|
+
// <KunEditor v-model="md">
|
|
8
|
+
// <template #view-switch="s"><KunEditorViewSwitch v-bind="s" /></template>
|
|
9
|
+
// </KunEditor>
|
|
10
|
+
//
|
|
11
|
+
// KunTab is auto-imported by @kungal/ui-nuxt in the consuming app.
|
|
12
|
+
import { computed } from 'vue'
|
|
13
|
+
import type { KunEditorViewSwitchApi } from '@kungal/editor-vue'
|
|
14
|
+
|
|
15
|
+
const props = defineProps<KunEditorViewSwitchApi>()
|
|
16
|
+
|
|
17
|
+
const items = computed(() => [
|
|
18
|
+
{ value: 'wysiwyg', textValue: props.labels.wysiwyg },
|
|
19
|
+
{ value: 'source', textValue: props.labels.source }
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
const onChange = (value: string) => {
|
|
23
|
+
props.setMode(value === 'source' ? 'source' : 'wysiwyg')
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<KunTab
|
|
29
|
+
:model-value="mode"
|
|
30
|
+
:items="items"
|
|
31
|
+
variant="underlined"
|
|
32
|
+
color="primary"
|
|
33
|
+
size="sm"
|
|
34
|
+
@update:model-value="onChange"
|
|
35
|
+
/>
|
|
36
|
+
</template>
|