nuxt-codemirror 0.0.6 → 0.0.7
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/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addComponent, addImports, extendViteConfig } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addComponent, addImports, addTypeTemplate, extendViteConfig } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
@@ -18,10 +18,15 @@ const module = defineNuxtModule({
|
|
|
18
18
|
as: "useNuxtCodeMirror",
|
|
19
19
|
from: resolve("./runtime/composables/useNuxtCodeMirror.ts")
|
|
20
20
|
});
|
|
21
|
+
addTypeTemplate({
|
|
22
|
+
filename: "nuxt-codemirror.d.ts",
|
|
23
|
+
src: resolve("./runtime/types/nuxt-codemirror.d.ts")
|
|
24
|
+
});
|
|
21
25
|
extendViteConfig((config) => {
|
|
22
26
|
config.resolve = config.resolve || {};
|
|
23
27
|
config.resolve.alias = config.resolve.alias || {};
|
|
24
28
|
config.resolve.alias["@codemirror/state"] = resolve(_nuxt.options.rootDir, "node_modules/@codemirror/state");
|
|
29
|
+
config.resolve.alias["@codemirror/view"] = resolve(_nuxt.options.rootDir, "node_modules/@codemirror/view");
|
|
25
30
|
});
|
|
26
31
|
}
|
|
27
32
|
});
|
|
@@ -3,7 +3,7 @@ import type { ViewUpdate, EditorView } from '@codemirror/view'
|
|
|
3
3
|
import type { EditorState } from '@codemirror/state'
|
|
4
4
|
import { useNuxtCodeMirror } from '../composables/useNuxtCodeMirror'
|
|
5
5
|
import type { NuxtCodeMirrorProps, Statistics } from '../types/nuxt-codemirror'
|
|
6
|
-
import { onMounted, ref, watch,
|
|
6
|
+
import { onMounted, ref, watch, computed, onBeforeUnmount } from '#imports'
|
|
7
7
|
|
|
8
8
|
const editor = ref<HTMLDivElement | null>(null)
|
|
9
9
|
const container = ref<HTMLDivElement | null>(null)
|
|
@@ -31,9 +31,7 @@ const emit = defineEmits<{
|
|
|
31
31
|
(event: 'onUpdate' | 'onFocus' | 'onBlur', update: ViewUpdate): void
|
|
32
32
|
}>()
|
|
33
33
|
|
|
34
|
-
onMounted(
|
|
35
|
-
await nextTick()
|
|
36
|
-
|
|
34
|
+
onMounted(() => {
|
|
37
35
|
useNuxtCodeMirror({
|
|
38
36
|
...props,
|
|
39
37
|
modelValue: modelValue.value,
|
|
@@ -57,6 +55,13 @@ onMounted(async () => {
|
|
|
57
55
|
// console.log('test: ', view.value)
|
|
58
56
|
})
|
|
59
57
|
|
|
58
|
+
onBeforeUnmount(() => {
|
|
59
|
+
if (view.value) {
|
|
60
|
+
view.value?.destroy()
|
|
61
|
+
view.value = undefined
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
60
65
|
watch(() => modelValue, (newValue) => {
|
|
61
66
|
if (typeof newValue !== 'string') {
|
|
62
67
|
console.error(`value must be typeof string but got ${typeof newValue}`)
|
|
@@ -2,7 +2,7 @@ import { Annotation, EditorState, StateEffect } from "@codemirror/state";
|
|
|
2
2
|
import { EditorView } from "@codemirror/view";
|
|
3
3
|
import { getDefaultExtensions } from "../getDefaultExtensions.js";
|
|
4
4
|
import { getStatistics } from "../utils/utils.js";
|
|
5
|
-
import {
|
|
5
|
+
import { watch, watchEffect } from "#imports";
|
|
6
6
|
const External = Annotation.define();
|
|
7
7
|
const emptyExtensions = [];
|
|
8
8
|
export function useNuxtCodeMirror(props) {
|
|
@@ -146,10 +146,4 @@ export function useNuxtCodeMirror(props) {
|
|
|
146
146
|
},
|
|
147
147
|
{ immediate: true }
|
|
148
148
|
);
|
|
149
|
-
onUnmounted(() => {
|
|
150
|
-
if (viewRef) {
|
|
151
|
-
viewRef.value?.destroy();
|
|
152
|
-
viewRef.value = void 0;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-codemirror",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Nuxt codemirror module",
|
|
5
5
|
"repository": "https://github.com/ThimoDEV/nuxt-codemirror",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@codemirror/commands": "^6.6.0",
|
|
33
33
|
"@codemirror/state": "6.4.1",
|
|
34
34
|
"@codemirror/theme-one-dark": "^6.1.1",
|
|
35
|
-
"@codemirror/view": "6.
|
|
35
|
+
"@codemirror/view": "6.29.1",
|
|
36
36
|
"@nuxt/kit": "^3.12.4",
|
|
37
37
|
"@uiw/codemirror-extensions-basic-setup": "^4.23.0"
|
|
38
38
|
},
|