nuxt-codemirror 0.0.9 → 0.0.10
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/README.md +8 -15
- package/dist/module.d.mts +2 -4
- package/dist/module.d.ts +2 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/useNuxtCodeMirror.d.ts +1 -1
- package/dist/runtime/composables/useNuxtCodeMirror.js +7 -4
- package/dist/runtime/getDefaultExtensions.d.ts +1 -1
- package/dist/types.d.mts +7 -1
- package/dist/types.d.ts +7 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# Nuxt CodeMirror
|
|
4
2
|
|
|
5
3
|
[![npm version][npm-version-src]][npm-version-href]
|
|
@@ -31,11 +29,12 @@ Read the CodeMirror Reference guide for more in depth information: [CodeMirror d
|
|
|
31
29
|
This component is auto imported and is the CodeMirror wrapper.
|
|
32
30
|
|
|
33
31
|
Component props:
|
|
34
|
-
|
|
32
|
+
|
|
33
|
+
```ts
|
|
35
34
|
interface NuxtCodeMirrorProps
|
|
36
35
|
extends Omit<EditorStateConfig, 'doc' | 'extensions'> {
|
|
37
36
|
/** value of the auto created model in the editor. Works as underlying logic of a V-Model */
|
|
38
|
-
modelValue?: string
|
|
37
|
+
modelValue?: string
|
|
39
38
|
/** The height value of the editor. */
|
|
40
39
|
height?: string
|
|
41
40
|
/** The minimum height value of the editor. */
|
|
@@ -116,7 +115,7 @@ interface NuxtCodeMirrorProps
|
|
|
116
115
|
|
|
117
116
|
The NuxtCodeMirror component accepts a Template ref and exposes The CodeMirror div element, the Editor view and the Editor State
|
|
118
117
|
|
|
119
|
-
```
|
|
118
|
+
```ts
|
|
120
119
|
interface CodeMirrorRef {
|
|
121
120
|
/** Container element of the CodeMirror instance */
|
|
122
121
|
container: HTMLDivElement | null
|
|
@@ -136,26 +135,20 @@ An example on how to do this can be found here: [🏀 Online playground](https:/
|
|
|
136
135
|
If for some reason you want to write your own CodeMirror component then you can do that too :)
|
|
137
136
|
|
|
138
137
|
### UseNuxtCodeMirror.ts
|
|
138
|
+
|
|
139
139
|
This composable is the underlying magic of the NuxtCodeMirror component and is also auto imported.
|
|
140
140
|
|
|
141
141
|
It requires minimum 3 Refs, one for the div element CodeMirror will connect to, one for the CodeMirror view, and one for the CodeMirror state
|
|
142
142
|
|
|
143
|
-
Make sure you execute the composable in onMounted otherwise you will get an eror because codemirror can't be linked to the DOM.
|
|
144
|
-
|
|
145
|
-
```
|
|
146
|
-
/** The EditorView of the CodeMirror instance */
|
|
147
|
-
viewRef: Ref<EditorView | undefined>
|
|
148
|
-
/** The EditorState of the CodeMirror instance */
|
|
149
|
-
stateRef: Ref<EditorState | undefined>
|
|
150
|
-
/** Editor element of the CodeMirror instance */
|
|
151
|
-
containerRef: Ref<HTMLDivElement | null>
|
|
143
|
+
Make sure you execute the composable in `onMounted` otherwise you will get an eror because codemirror can't be linked to the DOM.
|
|
152
144
|
|
|
145
|
+
```ts
|
|
153
146
|
const editor = ref<HTMLDivElement | null>(null)
|
|
154
147
|
const container = ref<HTMLDivElement | null>(null)
|
|
155
148
|
const view = ref<EditorView>()
|
|
156
149
|
const state = ref<EditorState>()
|
|
157
150
|
|
|
158
|
-
|
|
151
|
+
onMounted(() => {
|
|
159
152
|
useNuxtCodeMirror({
|
|
160
153
|
...props,
|
|
161
154
|
container: editor.value,
|
package/dist/module.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
3
|
+
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions>;
|
|
6
4
|
|
|
7
|
-
export {
|
|
5
|
+
export { _default as default };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
3
|
+
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions>;
|
|
6
4
|
|
|
7
|
-
export {
|
|
5
|
+
export { _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { UseCodeMirrorProps } from '../types/nuxt-codemirror.js';
|
|
2
2
|
export declare function useNuxtCodeMirror(props: UseCodeMirrorProps): void;
|
|
@@ -54,10 +54,13 @@ export function useNuxtCodeMirror(props) {
|
|
|
54
54
|
const value2 = doc.toString();
|
|
55
55
|
onChange(value2, viewUpdate);
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
onStatistics?.(getStatistics(viewUpdate));
|
|
58
|
+
if (!viewUpdate.focusChanged) return;
|
|
59
|
+
if (viewUpdate.view.hasFocus) {
|
|
60
|
+
onFocus?.(viewUpdate);
|
|
61
|
+
} else {
|
|
62
|
+
onBlur?.(viewUpdate);
|
|
59
63
|
}
|
|
60
|
-
onStatistics && onStatistics(getStatistics(viewUpdate));
|
|
61
64
|
});
|
|
62
65
|
const defaultExtensions = getDefaultExtensions({
|
|
63
66
|
theme,
|
|
@@ -88,7 +91,7 @@ export function useNuxtCodeMirror(props) {
|
|
|
88
91
|
root
|
|
89
92
|
});
|
|
90
93
|
viewRef.value = viewCurrent;
|
|
91
|
-
onCreateEditor
|
|
94
|
+
onCreateEditor?.(viewCurrent, stateCurrent);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
});
|
package/dist/types.d.mts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.js'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-codemirror",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Nuxt codemirror module",
|
|
5
5
|
"repository": "https://github.com/ThimoDEV/nuxt-codemirror",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"@codemirror/commands": "^6.6.0",
|
|
38
38
|
"@codemirror/state": "6.4.1",
|
|
39
39
|
"@codemirror/theme-one-dark": "^6.1.1",
|
|
40
|
-
"@codemirror/view": "6.
|
|
40
|
+
"@codemirror/view": "6.30.0",
|
|
41
41
|
"@nuxt/kit": "^3.12.4",
|
|
42
42
|
"@uiw/codemirror-extensions-basic-setup": "^4.23.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nuxt/devtools": "^1.3.9",
|
|
46
|
-
"@nuxt/eslint-config": "^0.
|
|
46
|
+
"@nuxt/eslint-config": "^0.5.0",
|
|
47
47
|
"@nuxt/module-builder": "^0.8.1",
|
|
48
48
|
"@nuxt/schema": "^3.12.4",
|
|
49
49
|
"@nuxt/test-utils": "^3.13.1",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"codemirror",
|
|
61
61
|
"vue"
|
|
62
62
|
],
|
|
63
|
-
"packageManager": "pnpm@9.
|
|
64
|
-
}
|
|
63
|
+
"packageManager": "pnpm@9.7.0"
|
|
64
|
+
}
|