nuxt-codemirror 0.0.16 → 0.0.19
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.d.mts +2 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +29 -4
- package/dist/runtime/components/NuxtCodeMirror.d.vue.ts +20 -0
- package/dist/runtime/components/NuxtCodeMirror.vue +77 -73
- package/dist/runtime/components/NuxtCodeMirror.vue.d.ts +20 -0
- package/dist/runtime/getDefaultExtensions.js +1 -1
- package/dist/runtime/types/nuxt-codemirror.d.ts +35 -8
- package/dist/types.d.mts +3 -1
- package/package.json +28 -30
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -8
- package/dist/types.d.ts +0 -1
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
1
3
|
import { defineNuxtModule, createResolver, addComponent, addImports, addTypeTemplate, extendViteConfig } from '@nuxt/kit';
|
|
2
4
|
|
|
3
|
-
const module = defineNuxtModule({
|
|
5
|
+
const module$1 = defineNuxtModule({
|
|
4
6
|
meta: {
|
|
5
7
|
name: "nuxt-codemirror",
|
|
6
8
|
configKey: "nuxtCodemirror"
|
|
@@ -10,6 +12,24 @@ const module = defineNuxtModule({
|
|
|
10
12
|
},
|
|
11
13
|
setup(_options, _nuxt) {
|
|
12
14
|
const resolver = createResolver(import.meta.url);
|
|
15
|
+
const codemirrorSingletonPackages = ["@codemirror/state", "@codemirror/view", "@codemirror/language", "@lezer/highlight"];
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const resolvePackageRoot = (packageName) => {
|
|
18
|
+
try {
|
|
19
|
+
return dirname(require.resolve(`${packageName}/package.json`));
|
|
20
|
+
} catch {
|
|
21
|
+
if (packageName === "@lezer/highlight") {
|
|
22
|
+
try {
|
|
23
|
+
const languagePackagePath = require.resolve("@codemirror/language/package.json");
|
|
24
|
+
const languageRequire = createRequire(languagePackagePath);
|
|
25
|
+
return dirname(languageRequire.resolve("@lezer/highlight/package.json"));
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
13
33
|
_nuxt.options.alias["#codemirror"] = resolver.resolve("./runtime");
|
|
14
34
|
addComponent({
|
|
15
35
|
name: "NuxtCodeMirror",
|
|
@@ -27,10 +47,15 @@ const module = defineNuxtModule({
|
|
|
27
47
|
extendViteConfig((config) => {
|
|
28
48
|
config.resolve = config.resolve || {};
|
|
29
49
|
config.resolve.alias = config.resolve.alias || {};
|
|
30
|
-
config.resolve.
|
|
31
|
-
|
|
50
|
+
config.resolve.dedupe = Array.from(/* @__PURE__ */ new Set([...config.resolve.dedupe || [], ...codemirrorSingletonPackages]));
|
|
51
|
+
for (const packageName of codemirrorSingletonPackages) {
|
|
52
|
+
const packageRoot = resolvePackageRoot(packageName);
|
|
53
|
+
if (packageRoot) {
|
|
54
|
+
config.resolve.alias[packageName] = packageRoot;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
32
57
|
});
|
|
33
58
|
}
|
|
34
59
|
});
|
|
35
60
|
|
|
36
|
-
export { module as default };
|
|
61
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EditorView } from '@codemirror/view';
|
|
2
|
+
import type { EditorState } from '@codemirror/state';
|
|
3
|
+
import type { NuxtCodeMirrorProps } from '../types/nuxt-codemirror.js';
|
|
4
|
+
type __VLS_Props = Omit<NuxtCodeMirrorProps, 'modelValue'>;
|
|
5
|
+
type __VLS_PublicProps = {
|
|
6
|
+
modelValue?: string;
|
|
7
|
+
} & __VLS_Props;
|
|
8
|
+
type __VLS_TemplateRefs = {
|
|
9
|
+
editor: typeof __VLS_nativeElements['div'];
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
12
|
+
container: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
13
|
+
view: import("vue").Ref<EditorView | undefined, EditorView | undefined>;
|
|
14
|
+
state: import("vue").Ref<EditorState | undefined, EditorState | undefined>;
|
|
15
|
+
editor: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
16
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{}>, {
|
|
17
|
+
theme: "light" | "dark" | "none" | import("@codemirror/state").Extension;
|
|
18
|
+
extensions: import("@codemirror/state").Extension[];
|
|
19
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, __VLS_TemplateRefs, any>;
|
|
20
|
+
export default _default;
|
|
@@ -1,78 +1,82 @@
|
|
|
1
|
-
<script setup
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useNuxtCodeMirror } from "../composables/useNuxtCodeMirror";
|
|
3
|
+
import { onMounted, ref, watch, computed, onBeforeUnmount } from "#imports";
|
|
4
|
+
const editor = ref(null);
|
|
5
|
+
const container = ref(null);
|
|
6
|
+
const view = ref();
|
|
7
|
+
const state = ref();
|
|
8
|
+
const modelValue = defineModel({ type: String, ...{ default: "" } });
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
height: { type: String, required: false },
|
|
11
|
+
minHeight: { type: String, required: false },
|
|
12
|
+
maxHeight: { type: String, required: false },
|
|
13
|
+
width: { type: String, required: false },
|
|
14
|
+
minWidth: { type: String, required: false },
|
|
15
|
+
maxWidth: { type: String, required: false },
|
|
16
|
+
autoFocus: { type: Boolean, required: false },
|
|
17
|
+
placeholder: { type: null, required: false },
|
|
18
|
+
theme: { type: [String, Object, Array], required: false, default: "light" },
|
|
19
|
+
basicSetup: { type: [Boolean, Object], required: false },
|
|
20
|
+
editable: { type: Boolean, required: false },
|
|
21
|
+
readOnly: { type: Boolean, required: false },
|
|
22
|
+
indentWithTab: { type: Boolean, required: false },
|
|
23
|
+
onChange: { type: Function, required: false },
|
|
24
|
+
onStatistics: { type: Function, required: false },
|
|
25
|
+
onUpdate: { type: Function, required: false },
|
|
26
|
+
onCreateEditor: { type: Function, required: false },
|
|
27
|
+
onFocus: { type: Function, required: false },
|
|
28
|
+
onBlur: { type: Function, required: false },
|
|
29
|
+
extensions: { type: Array, required: false, default: () => [] },
|
|
30
|
+
root: { type: null, required: false },
|
|
31
|
+
initialState: { type: Object, required: false },
|
|
32
|
+
selection: { type: Object, required: false }
|
|
33
|
+
});
|
|
34
|
+
defineExpose({
|
|
35
|
+
container,
|
|
36
|
+
view,
|
|
37
|
+
state,
|
|
38
|
+
editor
|
|
39
|
+
});
|
|
40
|
+
const emit = defineEmits(["onChange", "onStatistics", "onCreateEditor", "onUpdate", "onFocus", "onBlur"]);
|
|
41
|
+
onMounted(() => {
|
|
42
|
+
useNuxtCodeMirror({
|
|
43
|
+
...props,
|
|
44
|
+
modelValue,
|
|
45
|
+
onChange: (value, viewUpdate) => {
|
|
46
|
+
modelValue.value = value;
|
|
47
|
+
emit("onChange", value, viewUpdate);
|
|
48
|
+
},
|
|
49
|
+
onStatistics: (data) => emit("onStatistics", data),
|
|
50
|
+
onCreateEditor: (view2, state2) => emit("onCreateEditor", { view: view2, state: state2 }),
|
|
51
|
+
onUpdate: (viewUpdate) => emit("onUpdate", viewUpdate),
|
|
52
|
+
onFocus: (viewUpdate) => emit("onFocus", viewUpdate),
|
|
53
|
+
onBlur: (viewUpdate) => emit("onBlur", viewUpdate),
|
|
54
|
+
container: editor.value,
|
|
55
|
+
viewRef: view,
|
|
56
|
+
stateRef: state,
|
|
57
|
+
containerRef: container
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
onBeforeUnmount(() => {
|
|
61
|
+
if (view.value) {
|
|
62
|
+
view.value?.destroy();
|
|
63
|
+
view.value = void 0;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
watch(() => modelValue, (newValue) => {
|
|
67
|
+
if (typeof newValue !== "string") {
|
|
68
|
+
console.error(`value must be typeof string but got ${typeof newValue}`);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const defaultClassNames = computed(
|
|
72
|
+
() => typeof props.theme === "string" ? `cm-theme-${props.theme}` : "cm-theme"
|
|
73
|
+
);
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
73
77
|
<div
|
|
74
78
|
ref="editor"
|
|
75
79
|
:class="`${defaultClassNames}${$attrs.class ? ` ${$attrs.class}` : ''}`"
|
|
76
80
|
v-bind="$attrs"
|
|
77
81
|
/>
|
|
78
|
-
</template>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EditorView } from '@codemirror/view';
|
|
2
|
+
import type { EditorState } from '@codemirror/state';
|
|
3
|
+
import type { NuxtCodeMirrorProps } from '../types/nuxt-codemirror.js';
|
|
4
|
+
type __VLS_Props = Omit<NuxtCodeMirrorProps, 'modelValue'>;
|
|
5
|
+
type __VLS_PublicProps = {
|
|
6
|
+
modelValue?: string;
|
|
7
|
+
} & __VLS_Props;
|
|
8
|
+
type __VLS_TemplateRefs = {
|
|
9
|
+
editor: typeof __VLS_nativeElements['div'];
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
12
|
+
container: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
13
|
+
view: import("vue").Ref<EditorView | undefined, EditorView | undefined>;
|
|
14
|
+
state: import("vue").Ref<EditorState | undefined, EditorState | undefined>;
|
|
15
|
+
editor: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
16
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{}>, {
|
|
17
|
+
theme: "light" | "dark" | "none" | import("@codemirror/state").Extension;
|
|
18
|
+
extensions: import("@codemirror/state").Extension[];
|
|
19
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, __VLS_TemplateRefs, any>;
|
|
20
|
+
export default _default;
|
|
@@ -63,7 +63,7 @@ export const basicSetup = (options = {}) => {
|
|
|
63
63
|
if (options.allowMultipleSelections !== false) extensions.push(EditorState.allowMultipleSelections.of(true));
|
|
64
64
|
if (options.indentOnInput !== false) extensions.push(indentOnInput());
|
|
65
65
|
if (options.syntaxHighlighting !== false)
|
|
66
|
-
extensions.push(syntaxHighlighting(defaultHighlightStyle));
|
|
66
|
+
extensions.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true }));
|
|
67
67
|
if (options.bracketMatching !== false) extensions.push(bracketMatching());
|
|
68
68
|
if (options.closeBrackets !== false) extensions.push(closeBrackets());
|
|
69
69
|
if (options.autocompletion !== false) extensions.push(autocompletion());
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
-
import type { EditorState, EditorStateConfig, Extension, StateField, EditorSelection, SelectionRange, Line } from '@codemirror/state'
|
|
2
|
-
import type { EditorView, ViewUpdate } from '@codemirror/view'
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { EditorState, EditorStateConfig, Extension, StateField, EditorSelection, SelectionRange, Line } from '@codemirror/state'
|
|
2
|
+
import type { EditorView, ViewUpdate } from '@codemirror/view'
|
|
3
|
+
import type { ModelRef } from 'vue'
|
|
4
|
+
import type { Ref } from '#imports'
|
|
5
|
+
|
|
6
|
+
export interface BasicSetupOptions {
|
|
7
|
+
lineNumbers?: boolean
|
|
8
|
+
highlightActiveLineGutter?: boolean
|
|
9
|
+
highlightSpecialChars?: boolean
|
|
10
|
+
history?: boolean
|
|
11
|
+
foldGutter?: boolean
|
|
12
|
+
drawSelection?: boolean
|
|
13
|
+
dropCursor?: boolean
|
|
14
|
+
allowMultipleSelections?: boolean
|
|
15
|
+
indentOnInput?: boolean
|
|
16
|
+
syntaxHighlighting?: boolean
|
|
17
|
+
bracketMatching?: boolean
|
|
18
|
+
closeBrackets?: boolean
|
|
19
|
+
autocompletion?: boolean
|
|
20
|
+
rectangularSelection?: boolean
|
|
21
|
+
crosshairCursor?: boolean
|
|
22
|
+
highlightActiveLine?: boolean
|
|
23
|
+
highlightSelectionMatches?: boolean
|
|
24
|
+
defaultKeymap?: boolean
|
|
25
|
+
closeBracketsKeymap?: boolean
|
|
26
|
+
searchKeymap?: boolean
|
|
27
|
+
historyKeymap?: boolean
|
|
28
|
+
foldKeymap?: boolean
|
|
29
|
+
completionKeymap?: boolean
|
|
30
|
+
lintKeymap?: boolean
|
|
31
|
+
tabSize?: number
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface NuxtCodeMirrorProps
|
|
35
|
+
extends Omit<EditorStateConfig, 'doc' | 'extensions'> {
|
|
9
36
|
/** value of the auto created model in the editor. Works as underlying logic of a V-Model */
|
|
10
37
|
modelValue?: ModelRef<string | undefined, string>
|
|
11
38
|
/** The height value of the editor. */
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-codemirror",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Nuxt codemirror module",
|
|
5
5
|
"repository": "https://github.com/ThimoDEV/nuxt-codemirror",
|
|
6
6
|
"homepage": "https://github.com/ThimoDEV/nuxt-codemirror#readme",
|
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"types": "./dist/types.d.
|
|
16
|
-
"import": "./dist/module.mjs"
|
|
17
|
-
"require": "./dist/module.cjs"
|
|
15
|
+
"types": "./dist/types.d.mts",
|
|
16
|
+
"import": "./dist/module.mjs"
|
|
18
17
|
}
|
|
19
18
|
},
|
|
20
|
-
"main": "./dist/module.
|
|
21
|
-
"types": "./dist/types.d.ts",
|
|
19
|
+
"main": "./dist/module.mjs",
|
|
22
20
|
"files": [
|
|
23
21
|
"dist"
|
|
24
22
|
],
|
|
@@ -43,31 +41,31 @@
|
|
|
43
41
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
44
42
|
},
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@babel/runtime": "^7.
|
|
47
|
-
"@codemirror/autocomplete": "^6.
|
|
48
|
-
"@codemirror/commands": "^6.
|
|
49
|
-
"@codemirror/language": "^6.
|
|
50
|
-
"@codemirror/lint": "^6.
|
|
51
|
-
"@codemirror/search": "^6.
|
|
52
|
-
"@codemirror/state": "6.5.
|
|
53
|
-
"@codemirror/theme-one-dark": "^6.1.
|
|
54
|
-
"@codemirror/view": "6.
|
|
55
|
-
"@nuxt/kit": "^3.
|
|
44
|
+
"@babel/runtime": "^7.28.6",
|
|
45
|
+
"@codemirror/autocomplete": "^6.20.0",
|
|
46
|
+
"@codemirror/commands": "^6.10.2",
|
|
47
|
+
"@codemirror/language": "^6.12.2",
|
|
48
|
+
"@codemirror/lint": "^6.9.4",
|
|
49
|
+
"@codemirror/search": "^6.6.0",
|
|
50
|
+
"@codemirror/state": "6.5.4",
|
|
51
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
52
|
+
"@codemirror/view": "6.39.15",
|
|
53
|
+
"@nuxt/kit": "^4.3.1"
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|
|
58
|
-
"@nuxt/devtools": "^2.2
|
|
59
|
-
"@nuxt/devtools-ui-kit": "^
|
|
60
|
-
"@nuxt/eslint-config": "^1.2
|
|
61
|
-
"@nuxt/module-builder": "^0.
|
|
62
|
-
"@nuxt/schema": "^3.
|
|
63
|
-
"@nuxt/test-utils": "^
|
|
64
|
-
"@types/node": "^
|
|
65
|
-
"changelogen": "^0.6.
|
|
66
|
-
"eslint": "^
|
|
67
|
-
"nuxt": "^3.
|
|
68
|
-
"typescript": "5.3
|
|
69
|
-
"vitest": "^
|
|
70
|
-
"vue-tsc": "2.
|
|
56
|
+
"@nuxt/devtools": "^3.2.2",
|
|
57
|
+
"@nuxt/devtools-ui-kit": "^3.2.2",
|
|
58
|
+
"@nuxt/eslint-config": "^1.15.2",
|
|
59
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
60
|
+
"@nuxt/schema": "^4.3.1",
|
|
61
|
+
"@nuxt/test-utils": "^4.0.0",
|
|
62
|
+
"@types/node": "^25.3.2",
|
|
63
|
+
"changelogen": "^0.6.2",
|
|
64
|
+
"eslint": "^10.0.2",
|
|
65
|
+
"nuxt": "^4.3.1",
|
|
66
|
+
"typescript": "5.9.3",
|
|
67
|
+
"vitest": "^4.0.18",
|
|
68
|
+
"vue-tsc": "3.2.5"
|
|
71
69
|
},
|
|
72
70
|
"resolutions": {
|
|
73
71
|
"vue-tsc": "2.2.2"
|
|
@@ -78,4 +76,4 @@
|
|
|
78
76
|
"vue"
|
|
79
77
|
],
|
|
80
78
|
"packageManager": "pnpm@10.6.5"
|
|
81
|
-
}
|
|
79
|
+
}
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
|
|
3
|
-
interface ModuleOptions {
|
|
4
|
-
devtools?: boolean;
|
|
5
|
-
}
|
|
6
|
-
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
|
|
7
|
-
|
|
8
|
-
export { type ModuleOptions, _default as default };
|
package/dist/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { type ModuleOptions, default } from './module'
|