nuxt-codemirror 0.0.6 → 0.0.8

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 CHANGED
@@ -22,6 +22,152 @@ Codemirror as a Nuxt module. Demo preview: Coming soon
22
22
  - 🌲 Custom useNuxtCodeMirror composable for creating your own editor
23
23
  - Built for CodeMirror 6 and above
24
24
 
25
+ ## Documentation
26
+
27
+ This module consists of one Component, one Composable and a few types for you to use.
28
+ Read the CodeMirror Reference guide for more in depth information: [CodeMirror docs](https://codemirror.net/docs/ref/)
29
+
30
+ ### NuxtCodeMirror.vue
31
+ This component is auto imported and is the CodeMirror wrapper.
32
+
33
+ Component props:
34
+ ```
35
+ interface NuxtCodeMirrorProps
36
+ extends Omit<EditorStateConfig, 'doc' | 'extensions'> {
37
+ /** value of the auto created model in the editor. Works as underlying logic of a V-Model */
38
+ modelValue?: string This is linked to a Vue V-Model
39
+ /** The height value of the editor. */
40
+ height?: string
41
+ /** The minimum height value of the editor. */
42
+ minHeight?: string
43
+ /** The maximum height value of the editor. */
44
+ maxHeight?: string
45
+ /** The width value of the editor. */
46
+ width?: string
47
+ /** The minimum width value of the editor. */
48
+ minWidth?: string
49
+ /** The maximum width value of the editor. */
50
+ maxWidth?: string
51
+ /** focus on the editor. */
52
+ autoFocus?: boolean
53
+ /** Enables a placeholder—a piece of example content to show when the editor is empty. */
54
+ placeholder?: string | HTMLElement
55
+ /**
56
+ * `light` / `dark` / `Extension` Defaults to `light`.
57
+ * @default light
58
+ */
59
+ theme?: 'light' | 'dark' | 'none' | Extension
60
+ /**
61
+ * Whether to optional basicSetup by default
62
+ * @default true
63
+ */
64
+ basicSetup?: boolean | BasicSetupOptions
65
+ /**
66
+ * This disables editing of the editor content by the user.
67
+ * @default true
68
+ */
69
+ editable?: boolean
70
+ /**
71
+ * This disables editing of the editor content by the user.
72
+ * @default false
73
+ */
74
+ readOnly?: boolean
75
+ /**
76
+ * Controls whether pressing the `Tab` key inserts a tab character and indents the text (`true`)
77
+ * or behaves according to the browser's default behavior (`false`).
78
+ * @default true
79
+ */
80
+ indentWithTab?: boolean
81
+ /** Fired whenever a change occurs to the document. */
82
+ onChange?(value: string, viewUpdate: ViewUpdate): void
83
+ /** Some data on the statistics editor. */
84
+ onStatistics?(data: Statistics): void
85
+ /** Fired whenever any state change occurs within the editor, including non-document changes like lint results. */
86
+ onUpdate?(viewUpdate: ViewUpdate): void
87
+ /** The first time the editor executes the event. */
88
+ onCreateEditor?(view: EditorView, state: EditorState): void
89
+ /** Fired whenever the editor is focused. */
90
+ onFocus?(view: ViewUpdate): void
91
+ /** Fired whenever the editor is blurred. */
92
+ onBlur?(view: ViewUpdate): void
93
+ /**
94
+ * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.
95
+ * They can either be built-in extension-providing objects,
96
+ * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),
97
+ * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.
98
+ */
99
+ extensions?: Extension[]
100
+ /**
101
+ * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.
102
+ * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)
103
+ */
104
+ root?: ShadowRoot | Document
105
+ /**
106
+ * Create a state from its JSON representation serialized with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function
107
+ */
108
+ initialState?: {
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ json: any
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ fields?: Record<string, StateField<any>>
113
+ }
114
+ }
115
+ ```
116
+
117
+ The NuxtCodeMirror component accepts a Template ref and exposes The CodeMirror div element, the Editor view and the Editor State
118
+
119
+ ```
120
+ interface CodeMirrorRef {
121
+ /** Container element of the CodeMirror instance */
122
+ container: HTMLDivElement | null
123
+ /** The EditorView of the CodeMirror instance */
124
+ view: EditorView | undefined
125
+ /** The EditorState of the CodeMirror instance */
126
+ state: EditorState | undefined
127
+ /** Editor element of the CodeMirror instance */
128
+ editor: HTMLDivElement | null
129
+ }
130
+ ```
131
+
132
+ If you need access to the underlying CodeMirror instance You can do so by adding a ref with the same name as your Template ref.
133
+ An example on how to do this can be found here: [🏀 Online playground](https://stackblitz.com/edit/nuxt-starter-ev2hgm?file=app.vue)
134
+
135
+
136
+ If for some reason you want to write your own CodeMirror component then you can do that too :)
137
+
138
+ ### UseNuxtCodeMirror.ts
139
+ This composable is the underlying magic of the NuxtCodeMirror component and is also auto imported.
140
+
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
+
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>
152
+
153
+ const editor = ref<HTMLDivElement | null>(null)
154
+ const container = ref<HTMLDivElement | null>(null)
155
+ const view = ref<EditorView>()
156
+ const state = ref<EditorState>()
157
+
158
+ onMounted(() => {
159
+ useNuxtCodeMirror({
160
+ ...props,
161
+ container: editor.value,
162
+ viewRef: view,
163
+ stateRef: state,
164
+ containerRef: container,
165
+ })
166
+ })
167
+ ```
168
+
169
+ For more information on how this is implemented see the [source](https://github.com/ThimoDEV/nuxt-codemirror/blob/master/src/runtime/components/NuxtCodeMirror.vue), to get inspiration for your own version
170
+
25
171
  ## Credits
26
172
 
27
173
  This Nuxt module wouldn't be possible without:
@@ -39,8 +185,25 @@ npx nuxi module add nuxt-codemirror
39
185
 
40
186
  That's it! You can now use Nuxt-codemirror in your Nuxt app ✨
41
187
 
188
+ ### Tested extensions
189
+
190
+ Below is a list of tested extensions you can use as of @codemirror/view version 6.29.1 and @codemirror/state verion 6.4.1
191
+
192
+ - [LineNumbersRelative](https://www.npmjs.com/package/@uiw/codemirror-extensions-line-numbers-relative)
193
+ - [lang-javascript](https://www.npmjs.com/package/@codemirror/lang-javascript)
194
+ - [IndentationMarkers](https://github.com/replit/codemirror-indentation-markers)
195
+ - [interact](https://github.com/replit/codemirror-interact)
196
+ - [Themes -- like](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia)
197
+ - [Zebra Stripes](https://www.npmjs.com/package/@uiw/codemirror-extensions-zebra-stripes)
198
+
199
+ and many more...
200
+
42
201
  ## Contribution
43
202
 
203
+ If you have ideas or bugs feel free to start by opening an issue. For ideas please start a Discussion.
204
+
205
+ I welcome any kind of contribution Thank you in advance!!
206
+
44
207
  <details>
45
208
  <summary>Local development</summary>
46
209
 
@@ -88,6 +251,8 @@ That's it! You can now use Nuxt-codemirror in your Nuxt app ✨
88
251
 
89
252
  ## FAQ
90
253
 
91
- - I get an extension duplicate error: Fix Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.
254
+ Issue
255
+ - I get errors when starting the dev server with your module: `Pre-transform error: Failed to resolve import "@codemirror/view"`, `Pre-transform error: Failed to resolve import "@codemirror/state"`.
92
256
 
93
- For now write shamefully-hoist=true in your .npmrc file to solve this. We are working on a better solution
257
+ Solution
258
+ - Assuming you use pnpm with `shamefully-hoist=false` install `@codemirror/state` and `@codemirror/view` and these errors should disappear
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-codemirror",
3
3
  "configKey": "nuxtCodemirror",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.1",
7
7
  "unbuild": "2.0.0"
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, nextTick, computed } from '#imports'
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(async () => {
35
- await nextTick()
36
-
34
+ onMounted(() => {
37
35
  useNuxtCodeMirror({
38
36
  ...props,
39
37
  modelValue: modelValue.value,
@@ -51,10 +49,13 @@ onMounted(async () => {
51
49
  stateRef: state,
52
50
  containerRef: container,
53
51
  })
52
+ })
54
53
 
55
- /** DEBUGGING the variables exposed by defineExpose */
56
- // await nextTick()
57
- // console.log('test: ', view.value)
54
+ onBeforeUnmount(() => {
55
+ if (view.value) {
56
+ view.value?.destroy()
57
+ view.value = undefined
58
+ }
58
59
  })
59
60
 
60
61
  watch(() => modelValue, (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 { onUnmounted, watch, watchEffect } from "#imports";
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
  }
@@ -1,128 +1,137 @@
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 { Ref } from '#imports'
5
-
6
- export interface NuxtCodeMirrorProps
7
- extends Omit<EditorStateConfig, 'doc' | 'extensions'> {
8
- /** value of the auto created model in the editor. */
9
- modelValue?: string
10
- height?: string
11
- minHeight?: string
12
- maxHeight?: string
13
- width?: string
14
- minWidth?: string
15
- maxWidth?: string
16
- /** focus on the editor. */
17
- autoFocus?: boolean
18
- /** Enables a placeholder—a piece of example content to show when the editor is empty. */
19
- placeholder?: string | HTMLElement
20
- /**
21
- * `light` / `dark` / `Extension` Defaults to `light`.
22
- * @default light
23
- */
24
- theme?: 'light' | 'dark' | 'none' | Extension
25
- /**
26
- * Whether to optional basicSetup by default
27
- * @default true
28
- */
29
- basicSetup?: boolean | BasicSetupOptions
30
- /**
31
- * This disables editing of the editor content by the user.
32
- * @default true
33
- */
34
- editable?: boolean
35
- /**
36
- * This disables editing of the editor content by the user.
37
- * @default false
38
- */
39
- readOnly?: boolean
40
- /**
41
- * Controls whether pressing the `Tab` key inserts a tab character and indents the text (`true`)
42
- * or behaves according to the browser's default behavior (`false`).
43
- * @default true
44
- */
45
- indentWithTab?: boolean
46
- /** Fired whenever a change occurs to the document. */
47
- onChange?(value: string, viewUpdate: ViewUpdate): void
48
- /** Some data on the statistics editor. */
49
- onStatistics?(data: Statistics): void
50
- /** Fired whenever any state change occurs within the editor, including non-document changes like lint results. */
51
- onUpdate?(viewUpdate: ViewUpdate): void
52
- /** The first time the editor executes the event. */
53
- onCreateEditor?(view: EditorView, state: EditorState): void
54
- /** Fired whenever the editor is focused. */
55
- onFocus?(view: ViewUpdate): void
56
- /** Fired whenever the editor is blurred. */
57
- onBlur?(view: ViewUpdate): void
58
- /**
59
- * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.
60
- * They can either be built-in extension-providing objects,
61
- * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),
62
- * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.
63
- */
64
- extensions?: Extension[]
65
- /**
66
- * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.
67
- * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)
68
- */
69
- root?: ShadowRoot | Document
70
- /**
71
- * Create a state from its JSON representation serialized with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function
72
- */
73
- initialState?: {
74
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
- json: any
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- fields?: Record<string, StateField<any>>
78
- }
79
- }
80
-
81
- export interface UseCodeMirrorProps extends NuxtCodeMirrorProps {
82
- /** Container element of the CodeMirror instance */
83
- container?: HTMLDivElement | null
84
- viewRef: Ref<EditorView | undefined>
85
- stateRef: Ref<EditorState | undefined>
86
- containerRef: Ref<HTMLDivElement | null>
87
- }
88
-
89
- export interface Statistics {
90
- /** total length of the document */
91
- length: number
92
- /** Get the number of lines in the editor. */
93
- lineCount: number
94
- /** Get the currently line description around the given position. */
95
- line: Line
96
- /** Get the proper [line-break](https://codemirror.net/docs/ref/#state.EditorState^lineSeparator) string for this state. */
97
- lineBreak: string
98
- /** Returns true when the editor is [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only. */
99
- readOnly: boolean
100
- /** The size (in columns) of a tab in the document, determined by the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet. */
101
- tabSize: number
102
- /** Cursor Position */
103
- selection: EditorSelection
104
- /** Make sure the selection only has one range. */
105
- selectionAsSingle: SelectionRange
106
- /** Retrieves a list of all current selections. */
107
- ranges: readonly SelectionRange[]
108
- /** Get the currently selected code. */
109
- selectionCode: string
110
- /**
111
- * The length of the given array should be the same as the number of active selections.
112
- * Replaces the content of the selections with the strings in the array.
113
- */
114
- selections: string[]
115
- /** Return true if any text is selected. */
116
- selectedText: boolean
117
- }
118
-
119
- export interface CodeMirrorRef {
120
- /** Container element of the CodeMirror instance */
121
- container: HTMLDivElement | null
122
- /** The EditorView of the CodeMirror instance */
123
- view: EditorView | undefined
124
- /** The EditorState of the CodeMirror instance */
125
- state: EditorState | undefined
126
- /** Editor element of the CodeMirror instance */
127
- editor: HTMLDivElement | null
128
- }
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 { Ref } from '#imports'
5
+
6
+ export interface NuxtCodeMirrorProps
7
+ extends Omit<EditorStateConfig, 'doc' | 'extensions'> {
8
+ /** value of the auto created model in the editor. Works as underlying logic of a V-Model */
9
+ modelValue?: string
10
+ /** The height value of the editor. */
11
+ height?: string
12
+ /** The minimum height value of the editor. */
13
+ minHeight?: string
14
+ /** The maximum height value of the editor. */
15
+ maxHeight?: string
16
+ /** The width value of the editor. */
17
+ width?: string
18
+ /** The minimum width value of the editor. */
19
+ minWidth?: string
20
+ /** The maximum width value of the editor. */
21
+ maxWidth?: string
22
+ /** focus on the editor. */
23
+ autoFocus?: boolean
24
+ /** Enables a placeholder—a piece of example content to show when the editor is empty. */
25
+ placeholder?: string | HTMLElement
26
+ /**
27
+ * `light` / `dark` / `Extension` Defaults to `light`.
28
+ * @default light
29
+ */
30
+ theme?: 'light' | 'dark' | 'none' | Extension
31
+ /**
32
+ * Whether to optional basicSetup by default
33
+ * @default true
34
+ */
35
+ basicSetup?: boolean | BasicSetupOptions
36
+ /**
37
+ * This disables editing of the editor content by the user.
38
+ * @default true
39
+ */
40
+ editable?: boolean
41
+ /**
42
+ * This disables editing of the editor content by the user.
43
+ * @default false
44
+ */
45
+ readOnly?: boolean
46
+ /**
47
+ * Controls whether pressing the `Tab` key inserts a tab character and indents the text (`true`)
48
+ * or behaves according to the browser's default behavior (`false`).
49
+ * @default true
50
+ */
51
+ indentWithTab?: boolean
52
+ /** Fired whenever a change occurs to the document. */
53
+ onChange?(value: string, viewUpdate: ViewUpdate): void
54
+ /** Some data on the statistics editor. */
55
+ onStatistics?(data: Statistics): void
56
+ /** Fired whenever any state change occurs within the editor, including non-document changes like lint results. */
57
+ onUpdate?(viewUpdate: ViewUpdate): void
58
+ /** The first time the editor executes the event. */
59
+ onCreateEditor?(view: EditorView, state: EditorState): void
60
+ /** Fired whenever the editor is focused. */
61
+ onFocus?(view: ViewUpdate): void
62
+ /** Fired whenever the editor is blurred. */
63
+ onBlur?(view: ViewUpdate): void
64
+ /**
65
+ * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.
66
+ * They can either be built-in extension-providing objects,
67
+ * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),
68
+ * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.
69
+ */
70
+ extensions?: Extension[]
71
+ /**
72
+ * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.
73
+ * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)
74
+ */
75
+ root?: ShadowRoot | Document
76
+ /**
77
+ * Create a state from its JSON representation serialized with [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) function
78
+ */
79
+ initialState?: {
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ json: any
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ fields?: Record<string, StateField<any>>
84
+ }
85
+ }
86
+
87
+ export interface UseCodeMirrorProps extends NuxtCodeMirrorProps {
88
+ /** Container element of the CodeMirror instance */
89
+ container?: HTMLDivElement | null
90
+ /** The EditorView of the CodeMirror instance */
91
+ viewRef: Ref<EditorView | undefined>
92
+ /** The EditorState of the CodeMirror instance */
93
+ stateRef: Ref<EditorState | undefined>
94
+ /** Editor element of the CodeMirror instance */
95
+ containerRef: Ref<HTMLDivElement | null>
96
+ }
97
+
98
+ export interface Statistics {
99
+ /** total length of the document */
100
+ length: number
101
+ /** Get the number of lines in the editor. */
102
+ lineCount: number
103
+ /** Get the currently line description around the given position. */
104
+ line: Line
105
+ /** Get the proper [line-break](https://codemirror.net/docs/ref/#state.EditorState^lineSeparator) string for this state. */
106
+ lineBreak: string
107
+ /** Returns true when the editor is [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only. */
108
+ readOnly: boolean
109
+ /** The size (in columns) of a tab in the document, determined by the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet. */
110
+ tabSize: number
111
+ /** Cursor Position */
112
+ selection: EditorSelection
113
+ /** Make sure the selection only has one range. */
114
+ selectionAsSingle: SelectionRange
115
+ /** Retrieves a list of all current selections. */
116
+ ranges: readonly SelectionRange[]
117
+ /** Get the currently selected code. */
118
+ selectionCode: string
119
+ /**
120
+ * The length of the given array should be the same as the number of active selections.
121
+ * Replaces the content of the selections with the strings in the array.
122
+ */
123
+ selections: string[]
124
+ /** Return true if any text is selected. */
125
+ selectedText: boolean
126
+ }
127
+
128
+ export interface CodeMirrorRef {
129
+ /** Container element of the CodeMirror instance */
130
+ container: HTMLDivElement | null
131
+ /** The EditorView of the CodeMirror instance */
132
+ view: EditorView | undefined
133
+ /** The EditorState of the CodeMirror instance */
134
+ state: EditorState | undefined
135
+ /** Editor element of the CodeMirror instance */
136
+ editor: HTMLDivElement | null
137
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-codemirror",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Nuxt codemirror module",
5
5
  "repository": "https://github.com/ThimoDEV/nuxt-codemirror",
6
6
  "license": "MIT",
@@ -29,10 +29,11 @@
29
29
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
30
30
  },
31
31
  "dependencies": {
32
+ "@babel/runtime": "^7.25.0",
32
33
  "@codemirror/commands": "^6.6.0",
33
34
  "@codemirror/state": "6.4.1",
34
35
  "@codemirror/theme-one-dark": "^6.1.1",
35
- "@codemirror/view": "6.28.1",
36
+ "@codemirror/view": "6.29.1",
36
37
  "@nuxt/kit": "^3.12.4",
37
38
  "@uiw/codemirror-extensions-basic-setup": "^4.23.0"
38
39
  },
@@ -50,4 +51,4 @@
50
51
  "vitest": "^2.0.3",
51
52
  "vue-tsc": "^2.0.26"
52
53
  }
53
- }
54
+ }