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 CHANGED
@@ -5,4 +5,5 @@ interface ModuleOptions {
5
5
  }
6
6
  declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
7
7
 
8
- export { type ModuleOptions, _default as default };
8
+ export { _default as default };
9
+ export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "nuxt-codemirror",
3
3
  "configKey": "nuxtCodemirror",
4
- "version": "0.0.16",
4
+ "version": "0.0.19",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.8.4",
7
- "unbuild": "2.0.0"
6
+ "@nuxt/module-builder": "1.0.2",
7
+ "unbuild": "3.6.1"
8
8
  }
9
9
  }
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.alias["@codemirror/state"] = resolver.resolve(_nuxt.options.rootDir, "node_modules/@codemirror/state");
31
- config.resolve.alias["@codemirror/view"] = resolver.resolve(_nuxt.options.rootDir, "node_modules/@codemirror/view");
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 lang="ts">
2
- import type { ViewUpdate, EditorView } from '@codemirror/view'
3
- import type { EditorState } from '@codemirror/state'
4
- import { useNuxtCodeMirror } from '../composables/useNuxtCodeMirror'
5
- import type { NuxtCodeMirrorProps, Statistics } from '../types/nuxt-codemirror'
6
- import { onMounted, ref, watch, computed, onBeforeUnmount } from '#imports'
7
-
8
- const editor = ref<HTMLDivElement | null>(null)
9
- const container = ref<HTMLDivElement | null>(null)
10
- const view = ref<EditorView>()
11
- const state = ref<EditorState>()
12
-
13
- const modelValue = defineModel<string>({ default: '' })
14
-
15
- const props = withDefaults(defineProps<Omit<NuxtCodeMirrorProps, 'modelValue'>>(), {
16
- extensions: () => [],
17
- theme: 'light',
18
- })
19
-
20
- defineExpose({
21
- container,
22
- view,
23
- state,
24
- editor,
25
- })
26
-
27
- const emit = defineEmits<{
28
- (event: 'onChange', value: string, viewUpdate: ViewUpdate): void
29
- (event: 'onStatistics', data: Statistics): void
30
- (event: 'onCreateEditor', editor: { view: EditorView, state: EditorState }): void
31
- (event: 'onUpdate' | 'onFocus' | 'onBlur', update: ViewUpdate): void
32
- }>()
33
-
34
- onMounted(() => {
35
- useNuxtCodeMirror({
36
- ...props,
37
- modelValue: modelValue,
38
- onChange: (value, viewUpdate) => {
39
- modelValue.value = value
40
- emit('onChange', value, viewUpdate)
41
- },
42
- onStatistics: data => emit('onStatistics', data),
43
- onCreateEditor: (view, state) => emit('onCreateEditor', { view, state }),
44
- onUpdate: viewUpdate => emit('onUpdate', viewUpdate),
45
- onFocus: viewUpdate => emit('onFocus', viewUpdate),
46
- onBlur: viewUpdate => emit('onBlur', viewUpdate),
47
- container: editor.value,
48
- viewRef: view,
49
- stateRef: state,
50
- containerRef: container,
51
- })
52
- })
53
-
54
- onBeforeUnmount(() => {
55
- if (view.value) {
56
- view.value?.destroy()
57
- view.value = undefined
58
- }
59
- })
60
-
61
- watch(() => modelValue, (newValue) => {
62
- if (typeof newValue !== 'string') {
63
- console.error(`value must be typeof string but got ${typeof newValue}`)
64
- }
65
- })
66
-
67
- const defaultClassNames = computed(() =>
68
- typeof props.theme === 'string' ? `cm-theme-${props.theme}` : 'cm-theme',
69
- )
70
- </script>
71
-
72
- <template>
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 { BasicSetupOptions } from '@uiw/codemirror-extensions-basic-setup'
4
- import type { ModelRef } from 'vue'
5
- import type { Ref } from '#imports'
6
-
7
- export interface NuxtCodeMirrorProps
8
- extends Omit<EditorStateConfig, 'doc' | 'extensions'> {
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
@@ -1 +1,3 @@
1
- export { type ModuleOptions, default } from './module.js'
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-codemirror",
3
- "version": "0.0.16",
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.ts",
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.cjs",
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.26.10",
47
- "@codemirror/autocomplete": "^6.18.6",
48
- "@codemirror/commands": "^6.8.0",
49
- "@codemirror/language": "^6.10.8",
50
- "@codemirror/lint": "^6.8.4",
51
- "@codemirror/search": "^6.5.10",
52
- "@codemirror/state": "6.5.2",
53
- "@codemirror/theme-one-dark": "^6.1.2",
54
- "@codemirror/view": "6.36.4",
55
- "@nuxt/kit": "^3.16.1"
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.1",
59
- "@nuxt/devtools-ui-kit": "^1.6.4",
60
- "@nuxt/eslint-config": "^1.2.0",
61
- "@nuxt/module-builder": "^0.8.4",
62
- "@nuxt/schema": "^3.16.0",
63
- "@nuxt/test-utils": "^3.17.2",
64
- "@types/node": "^22.13.10",
65
- "changelogen": "^0.6.1",
66
- "eslint": "^9.22.0",
67
- "nuxt": "^3.16.0",
68
- "typescript": "5.3.2",
69
- "vitest": "^3.0.8",
70
- "vue-tsc": "2.0.29"
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
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
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'