Skip to content

Commit 06b52ac

Browse files
committed
docs: add type explain code
1 parent eda423d commit 06b52ac

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/module.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineNuxtModule, addComponent, createResolver, addImports } from '@nuxt/kit'
1+
import { defineNuxtModule, addComponent, createResolver, addImports, extendViteConfig } from '@nuxt/kit'
22

33
// Module options TypeScript interface definition
44
export interface ModuleOptions {}
@@ -24,11 +24,18 @@ export default defineNuxtModule<ModuleOptions>({
2424
from: resolve('./runtime/composables/useNuxtCodeMirror.ts'),
2525
})
2626

27-
_nuxt.hook('vite:extendConfig', (config) => {
27+
// _nuxt.hook('vite:extendConfig', (config) => {
28+
// config.resolve = config.resolve || {}
29+
// config.resolve.alias = config.resolve.alias || {}
30+
31+
// // @ts-expect-error - Add alias for @codemirror/view
32+
// config.resolve.alias['@codemirror/state'] = resolve(_nuxt.options.rootDir, 'node_modules/@codemirror/state')
33+
// })
34+
extendViteConfig((config) => {
2835
config.resolve = config.resolve || {}
2936
config.resolve.alias = config.resolve.alias || {}
3037

31-
// @ts-expect-error - Add alias for @codemirror/view
38+
// @ts-expect-error - Add alias for @codemirror/state
3239
config.resolve.alias['@codemirror/state'] = resolve(_nuxt.options.rootDir, 'node_modules/@codemirror/state')
3340
})
3441
},

src/runtime/types/nuxt-codemirror.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface NuxtCodeMirrorProps
7979
}
8080

8181
export interface UseCodeMirrorProps extends NuxtCodeMirrorProps {
82+
/** Container element of the CodeMirror instance */
8283
container?: HTMLDivElement | null
8384
viewRef: Ref<EditorView | undefined>
8485
stateRef: Ref<EditorState | undefined>
@@ -116,8 +117,12 @@ export interface Statistics {
116117
}
117118

118119
export interface CodeMirrorRef {
120+
/** Container element of the CodeMirror instance */
119121
container: HTMLDivElement | null
122+
/** The EditorView of the CodeMirror instance */
120123
view: EditorView | undefined
124+
/** The EditorState of the CodeMirror instance */
121125
state: EditorState | undefined
126+
/** Editor element of the CodeMirror instance */
122127
editor: HTMLDivElement | null
123128
}

0 commit comments

Comments
 (0)