Skip to content

Commit 9b5a572

Browse files
committed
Fixed wrong typing of computed value.
1 parent b13628a commit 9b5a572

File tree

3 files changed

+268
-319
lines changed

3 files changed

+268
-319
lines changed

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "vue-codemirror6",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"license": "MIT",
66
"description": "CodeMirror6 Component for vue2 and vue3.",
77
"keywords": [
@@ -51,7 +51,7 @@
5151
"./sfc": "./src/components/CodeMirror.ts"
5252
},
5353
"engines": {
54-
"node": ">=16.17.1",
54+
"node": ">=16.18.0",
5555
"yarn": ">=1.22.10"
5656
},
5757
"packageManager": "[email protected]",
@@ -85,22 +85,22 @@
8585
"@codemirror/lang-javascript": "^6.1.0",
8686
"@codemirror/lang-markdown": "^6.0.2",
8787
"@types/lodash": "^4.14.186",
88-
"@types/node": "^18.8.4",
89-
"@typescript-eslint/eslint-plugin": "^5.40.0",
90-
"@typescript-eslint/parser": "^5.40.0",
88+
"@types/node": "^18.11.4",
89+
"@typescript-eslint/eslint-plugin": "^5.40.1",
90+
"@typescript-eslint/parser": "^5.40.1",
9191
"@vitejs/plugin-vue": "^3.1.2",
9292
"@vue/eslint-config-prettier": "^7.0.0",
9393
"@vue/tsconfig": "^0.1.3",
9494
"codemirror": "^6.0.1",
95-
"eslint": "^8.25.0",
95+
"eslint": "^8.26.0",
9696
"eslint-config-google": "^0.14.0",
9797
"eslint-config-prettier": "^8.5.0",
9898
"eslint-import-resolver-alias": "^1.1.2",
99-
"eslint-import-resolver-typescript": "^3.5.1",
100-
"eslint-linter-browserify": "^8.25.0",
99+
"eslint-import-resolver-typescript": "^3.5.2",
100+
"eslint-linter-browserify": "^8.26.0",
101101
"eslint-plugin-html": "^7.1.0",
102102
"eslint-plugin-import": "^2.26.0",
103-
"eslint-plugin-jsdoc": "^39.3.6",
103+
"eslint-plugin-jsdoc": "^39.3.23",
104104
"eslint-plugin-tsdoc": "^0.2.17",
105105
"eslint-plugin-vue": "^9.6.0",
106106
"eslint-plugin-vuejs-accessibility": "^1.2.0",
@@ -110,14 +110,14 @@
110110
"lodash": "^4.17.21",
111111
"prettier": "^2.7.1",
112112
"rimraf": "^3.0.2",
113-
"rollup-plugin-visualizer": "^5.8.2",
113+
"rollup-plugin-visualizer": "^5.8.3",
114114
"typescript": "^4.8.4",
115-
"vite": "^3.1.7",
115+
"vite": "^3.1.8",
116116
"vite-plugin-banner": "^0.5.0",
117117
"vite-plugin-checker": "^0.5.1",
118-
"vue": "^3.2.40",
118+
"vue": "^3.2.41",
119119
"vue-eslint-parser": "^9.1.0",
120-
"vue-tsc": "^1.0.5"
120+
"vue-tsc": "^1.0.9"
121121
},
122122
"husky": {
123123
"hooks": {

src/components/CodeMirror.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type Ref,
1515
type SetupContext,
1616
type ShallowRef,
17+
type WritableComputedRef,
1718
} from 'vue-demi';
1819

1920
// Helpers
@@ -52,11 +53,11 @@ export interface CodeMirrorEmitsOptions extends ObjectEmitsOptions {
5253
value: {
5354
view: EditorView;
5455
state: EditorState;
55-
container: HTMLDivElement;
56+
container: HTMLElement;
5657
}
5758
): void;
58-
/** onChanged (same as update:modelValue) */
59-
(e: 'changed', value: string | Text): void;
59+
/** onChange (same as update:modelValue) */
60+
(e: 'change', value: string | Text): void;
6061
}
6162

6263
/** CodeMirror Component */
@@ -213,25 +214,25 @@ export default defineComponent({
213214
const view: ShallowRef<EditorView> = shallowRef(new EditorView());
214215

215216
/** Selection */
216-
const selection: Ref<EditorSelection> = computed({
217+
const selection: WritableComputedRef<EditorSelection> = computed({
217218
get: () => view.value.state.selection,
218219
set: s => view.value.dispatch({ selection: s }),
219220
});
220221

221222
/** Cursor Position */
222-
const cursor: Ref<number> = computed({
223+
const cursor: WritableComputedRef<number> = computed({
223224
get: () => selection.value.main.head || 0,
224225
set: a => view.value.dispatch({ selection: { anchor: a } }),
225226
});
226227

227228
/** Editor State */
228-
const state: Ref<EditorState> = computed({
229+
const state: WritableComputedRef<EditorState> = computed({
229230
get: () => view.value.state,
230231
set: s => view.value.setState(s),
231232
});
232233

233234
/** Focus */
234-
const focus: Ref<boolean> = computed({
235+
const focus: WritableComputedRef<boolean> = computed({
235236
get: () => view.value.hasFocus,
236237
set: f => {
237238
if (f) {

0 commit comments

Comments
 (0)