nuxt-codemirror 0.0.18 → 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.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-codemirror",
3
3
  "configKey": "nuxtCodemirror",
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,3 +1,5 @@
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
5
  const module$1 = defineNuxtModule({
@@ -10,6 +12,24 @@ const module$1 = 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,8 +47,13 @@ const module$1 = 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
  });
@@ -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;
@@ -16,7 +16,7 @@ const props = defineProps({
16
16
  autoFocus: { type: Boolean, required: false },
17
17
  placeholder: { type: null, required: false },
18
18
  theme: { type: [String, Object, Array], required: false, default: "light" },
19
- basicSetup: { type: Boolean, required: false, skipCheck: true },
19
+ basicSetup: { type: [Boolean, Object], required: false },
20
20
  editable: { type: Boolean, required: false },
21
21
  readOnly: { type: Boolean, required: false },
22
22
  indentWithTab: { type: Boolean, required: false },
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-codemirror",
3
- "version": "0.0.18",
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",