vue-codemirror6 1.1.2 → 1.1.4
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/CHANGELOG.md +18 -1
- package/LICENSE +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.iife.js +4 -4
- package/dist/index.umd.js +4 -4
- package/package.json +26 -20
- package/dist/Meta.d.ts +0 -4
- package/dist/Meta.d.ts.map +0 -1
- package/dist/Meta.js +0 -6
- package/dist/components/CodeMirror.d.ts +0 -418
- package/dist/components/CodeMirror.d.ts.map +0 -1
- package/dist/components/CodeMirror.js +0 -494
- package/dist/helpers/h-demi.d.ts +0 -19
- package/dist/helpers/h-demi.d.ts.map +0 -1
- package/dist/helpers/h-demi.js +0 -27
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/interfaces/MetaInterface.d.ts +0 -8
- package/dist/interfaces/MetaInterface.d.ts.map +0 -1
- package/dist/interfaces/MetaInterface.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,28 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [1.1.4](https://github.com/logue/vue-codemirror6/compare/1.1.4...1.1.4)
|
|
8
|
+
|
|
9
|
+
> 12 January 2023
|
|
10
|
+
|
|
11
|
+
- Update dependencies. [`febe5f1`](https://github.com/logue/vue-codemirror6/commit/febe5f1822d86a8e30d38fc6440b13209b41186d)
|
|
12
|
+
- release v1.1.2 [`903af1f`](https://github.com/logue/vue-codemirror6/commit/903af1fcf128ea7958ca9ae40fc97f062d8696d1)
|
|
13
|
+
|
|
14
|
+
#### [1.1.3](https://github.com/logue/vue-codemirror6/compare/1.1.2...1.1.3)
|
|
15
|
+
|
|
16
|
+
> 9 January 2023
|
|
17
|
+
|
|
18
|
+
- Bump json5 from 1.0.1 to 1.0.2 [`#10`](https://github.com/logue/vue-codemirror6/pull/10)
|
|
19
|
+
- Consolidated demo code generation settings into a single vite.config.ts [`7fe3ad2`](https://github.com/logue/vue-codemirror6/commit/7fe3ad25676eb34844b7bfe64b5dc73f30211a5b)
|
|
20
|
+
- Update dependencies. [`75b984e`](https://github.com/logue/vue-codemirror6/commit/75b984e38c13114ce30b853fba64493c55368be3)
|
|
21
|
+
|
|
7
22
|
#### [1.1.2](https://github.com/logue/vue-codemirror6/compare/1.1.1...1.1.2)
|
|
8
23
|
|
|
24
|
+
> 24 December 2022
|
|
25
|
+
|
|
26
|
+
- Update CHANGELOG.md. [`72efba5`](https://github.com/logue/vue-codemirror6/commit/72efba5e9e272da2dcb3bd941079ee415d1b4c53)
|
|
9
27
|
- Minor fix. [`d1e3118`](https://github.com/logue/vue-codemirror6/commit/d1e3118ca2f2efe4d63f64e505d8a01a7c29a104)
|
|
10
28
|
- Update dependencies. [`d747a21`](https://github.com/logue/vue-codemirror6/commit/d747a21778b42ed12921dd468a91a910895925e8)
|
|
11
|
-
- Matched tsconfig to vue's standard settings as much as possible. [`59d16b1`](https://github.com/logue/vue-codemirror6/commit/59d16b1b1bfa27a0447da04404cf840f856adefd)
|
|
12
29
|
|
|
13
30
|
#### [1.1.1](https://github.com/logue/vue-codemirror6/compare/1.1.0...1.1.1)
|
|
14
31
|
|
package/LICENSE
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
6
|
+
* @copyright 2022-2023 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.1.
|
|
8
|
+
* @version 1.1.3
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -319,8 +319,8 @@ var CodeMirror = defineComponent({
|
|
|
319
319
|
});
|
|
320
320
|
|
|
321
321
|
const meta = {
|
|
322
|
-
version: "1.1.
|
|
323
|
-
date: "
|
|
322
|
+
version: "1.1.3",
|
|
323
|
+
date: "2023-01-12T02:58:45.012Z"
|
|
324
324
|
};
|
|
325
325
|
|
|
326
326
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
package/dist/index.iife.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
6
|
+
* @copyright 2022-2023 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.1.
|
|
8
|
+
* @version 1.1.3
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -318,8 +318,8 @@ var CodeMirror = (function (exports, vueDemi, compact, trim, codemirror, state,
|
|
|
318
318
|
});
|
|
319
319
|
|
|
320
320
|
const meta = {
|
|
321
|
-
version: "1.1.
|
|
322
|
-
date: "
|
|
321
|
+
version: "1.1.3",
|
|
322
|
+
date: "2023-01-12T02:58:45.012Z"
|
|
323
323
|
};
|
|
324
324
|
|
|
325
325
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
package/dist/index.umd.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
6
|
+
* @copyright 2022-2023 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.1.
|
|
8
|
+
* @version 1.1.3
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -321,8 +321,8 @@
|
|
|
321
321
|
});
|
|
322
322
|
|
|
323
323
|
const meta = {
|
|
324
|
-
version: "1.1.
|
|
325
|
-
date: "
|
|
324
|
+
version: "1.1.3",
|
|
325
|
+
date: "2023-01-12T02:58:45.012Z"
|
|
326
326
|
};
|
|
327
327
|
|
|
328
328
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "vue-codemirror6",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "CodeMirror6 Component for vue2 and vue3.",
|
|
7
7
|
"keywords": [
|
|
@@ -61,19 +61,20 @@
|
|
|
61
61
|
"scripts": {
|
|
62
62
|
"dev": "vite",
|
|
63
63
|
"clean": "rimraf node_modules/.vite",
|
|
64
|
-
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
65
64
|
"type-check": "tsc --noEmit --composite false",
|
|
66
65
|
"build": "run-p type-check build-only build-declaration",
|
|
67
|
-
"build:
|
|
66
|
+
"build:analyze": "vite build --mode=analyze",
|
|
67
|
+
"build:clean": "rimraf dist docs",
|
|
68
|
+
"build:docs": "vite build --mode=docs",
|
|
68
69
|
"build-only": "vite build",
|
|
69
|
-
"build-declaration": "tsc -p tsconfig.app.json --composite false --declaration --declarationMap --
|
|
70
|
+
"build-declaration": "tsc -p tsconfig.app.json --composite false --declaration --declarationMap --declarationDir dist",
|
|
71
|
+
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
72
|
+
"preview": "vite preview --mode=docs",
|
|
70
73
|
"prepare": "husky install",
|
|
71
74
|
"version": "auto-changelog -p && git add CHANGELOG.md"
|
|
72
75
|
},
|
|
73
76
|
"dependencies": {
|
|
74
77
|
"codemirror": "^6.0.1",
|
|
75
|
-
"lodash.compact": "^3.0.1",
|
|
76
|
-
"lodash.trim": "^4.5.1",
|
|
77
78
|
"vue-demi": "latest"
|
|
78
79
|
},
|
|
79
80
|
"peerDependencies": {
|
|
@@ -90,40 +91,42 @@
|
|
|
90
91
|
"@codemirror/lang-json": "^6.0.1",
|
|
91
92
|
"@codemirror/lang-markdown": "^6.0.5",
|
|
92
93
|
"@types/lodash": "^4.14.191",
|
|
93
|
-
"@types/node": "^18.11.
|
|
94
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
95
|
-
"@typescript-eslint/parser": "^5.
|
|
94
|
+
"@types/node": "^18.11.18",
|
|
95
|
+
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
96
|
+
"@typescript-eslint/parser": "^5.48.1",
|
|
96
97
|
"@vitejs/plugin-vue": "^4.0.0",
|
|
97
98
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
98
99
|
"@vue/tsconfig": "^0.1.3",
|
|
99
|
-
"
|
|
100
|
+
"@vueuse/core": "^9.10.0",
|
|
101
|
+
"eslint": "^8.31.0",
|
|
100
102
|
"eslint-config-google": "^0.14.0",
|
|
101
|
-
"eslint-config-prettier": "^8.
|
|
103
|
+
"eslint-config-prettier": "^8.6.0",
|
|
102
104
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
103
|
-
"eslint-import-resolver-typescript": "^3.5.
|
|
104
|
-
"eslint-linter-browserify": "^8.
|
|
105
|
+
"eslint-import-resolver-typescript": "^3.5.3",
|
|
106
|
+
"eslint-linter-browserify": "^8.31.0",
|
|
105
107
|
"eslint-plugin-html": "^7.1.0",
|
|
106
|
-
"eslint-plugin-import": "^2.
|
|
108
|
+
"eslint-plugin-import": "^2.27.2",
|
|
107
109
|
"eslint-plugin-jsdoc": "^39.6.4",
|
|
110
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
108
111
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
109
112
|
"eslint-plugin-vue": "^9.8.0",
|
|
110
113
|
"eslint-plugin-vuejs-accessibility": "^2.0.0",
|
|
111
114
|
"eslint-plugin-yaml": "^0.5.0",
|
|
112
|
-
"husky": "^8.0.
|
|
115
|
+
"husky": "^8.0.3",
|
|
113
116
|
"lint-staged": "^13.1.0",
|
|
114
117
|
"lodash": "^4.17.21",
|
|
115
118
|
"npm-run-all": "^4.1.5",
|
|
116
|
-
"prettier": "^2.8.
|
|
119
|
+
"prettier": "^2.8.2",
|
|
117
120
|
"rimraf": "^3.0.2",
|
|
118
|
-
"rollup-plugin-visualizer": "^5.
|
|
121
|
+
"rollup-plugin-visualizer": "^5.9.0",
|
|
119
122
|
"typescript": "^4.9.4",
|
|
120
|
-
"vite": "^4.0.
|
|
123
|
+
"vite": "^4.0.4",
|
|
121
124
|
"vite-plugin-banner": "^0.7.0",
|
|
122
125
|
"vite-plugin-checker": "^0.5.3",
|
|
123
126
|
"vue": "^3.2.45",
|
|
124
127
|
"vue-eslint-parser": "^9.1.0",
|
|
125
|
-
"vue-markdown-wasm": "^0.0
|
|
126
|
-
"vue-tsc": "^1.0.
|
|
128
|
+
"vue-markdown-wasm": "^0.2.0",
|
|
129
|
+
"vue-tsc": "^1.0.24"
|
|
127
130
|
},
|
|
128
131
|
"husky": {
|
|
129
132
|
"hooks": {
|
|
@@ -133,5 +136,8 @@
|
|
|
133
136
|
"lint-staged": {
|
|
134
137
|
"*.{js,ts,json,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
|
|
135
138
|
"*": "prettier -w -u"
|
|
139
|
+
},
|
|
140
|
+
"resolutions": {
|
|
141
|
+
"json5": "^2.2.3"
|
|
136
142
|
}
|
|
137
143
|
}
|
package/dist/Meta.d.ts
DELETED
package/dist/Meta.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAC;AAG5D,QAAA,MAAM,IAAI,EAAE,aAGX,CAAC;AACF,eAAe,IAAI,CAAC"}
|
package/dist/Meta.js
DELETED
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
import { type ObjectEmitsOptions, type PropType, type Ref } from 'vue-demi';
|
|
2
|
-
import { EditorState, type Extension, type Text } from '@codemirror/state';
|
|
3
|
-
import { EditorView, type ViewUpdate } from '@codemirror/view';
|
|
4
|
-
import { type LintSource } from '@codemirror/lint';
|
|
5
|
-
import type { LanguageSupport } from '@codemirror/language';
|
|
6
|
-
import type { StyleSpec } from 'style-mod';
|
|
7
|
-
/** Emit Interface */
|
|
8
|
-
export interface CodeMirrorEmitsOptions extends ObjectEmitsOptions {
|
|
9
|
-
/** Model Update */
|
|
10
|
-
(e: 'update:modelValue', value: string | Text): void;
|
|
11
|
-
/** CodeMirror ViewUpdate */
|
|
12
|
-
(e: 'update', value: ViewUpdate): void;
|
|
13
|
-
/** CodeMirror onFocus */
|
|
14
|
-
(e: 'focus', value: boolean): void;
|
|
15
|
-
/** CodeMirror onReady */
|
|
16
|
-
(e: 'ready', value: {
|
|
17
|
-
view: EditorView;
|
|
18
|
-
state: EditorState;
|
|
19
|
-
container: HTMLElement;
|
|
20
|
-
}): void;
|
|
21
|
-
/** CodeMirror onDestroy */
|
|
22
|
-
(e: 'destroy'): void;
|
|
23
|
-
/** State Changed */
|
|
24
|
-
(e: 'change', value: EditorState): void;
|
|
25
|
-
}
|
|
26
|
-
/** CodeMirror Component */
|
|
27
|
-
declare const _default: import("vue-demi").DefineComponent<{
|
|
28
|
-
/** Model value */
|
|
29
|
-
modelValue: {
|
|
30
|
-
type: PropType<string | Text>;
|
|
31
|
-
default: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Theme
|
|
35
|
-
*
|
|
36
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
|
|
37
|
-
*/
|
|
38
|
-
theme: {
|
|
39
|
-
type: PropType<{
|
|
40
|
-
[selector: string]: StyleSpec;
|
|
41
|
-
}>;
|
|
42
|
-
default: () => void;
|
|
43
|
-
};
|
|
44
|
-
/** Dark Mode */
|
|
45
|
-
dark: {
|
|
46
|
-
type: BooleanConstructor;
|
|
47
|
-
default: boolean;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Use Basic Setup
|
|
51
|
-
*
|
|
52
|
-
* @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
|
|
53
|
-
*/
|
|
54
|
-
basic: {
|
|
55
|
-
type: BooleanConstructor;
|
|
56
|
-
default: boolean;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Use Minimal Setup (The basic setting has priority.)
|
|
60
|
-
*
|
|
61
|
-
* @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
|
|
62
|
-
*/
|
|
63
|
-
minimal: {
|
|
64
|
-
type: BooleanConstructor;
|
|
65
|
-
default: boolean;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Placeholder
|
|
69
|
-
*
|
|
70
|
-
* @see {@link https://codemirror.net/docs/ref/#view.placeholder}
|
|
71
|
-
*/
|
|
72
|
-
placeholder: {
|
|
73
|
-
type: PropType<string | HTMLElement>;
|
|
74
|
-
default: undefined;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Line wrapping
|
|
78
|
-
*
|
|
79
|
-
* An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
|
|
80
|
-
*
|
|
81
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
|
|
82
|
-
*/
|
|
83
|
-
wrap: {
|
|
84
|
-
type: BooleanConstructor;
|
|
85
|
-
default: boolean;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Allow tab key indent.
|
|
89
|
-
*
|
|
90
|
-
* @see {@link https://codemirror.net/examples/tab/}
|
|
91
|
-
*/
|
|
92
|
-
tab: {
|
|
93
|
-
type: BooleanConstructor;
|
|
94
|
-
default: boolean;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Tab size
|
|
98
|
-
*
|
|
99
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
|
|
100
|
-
*/
|
|
101
|
-
tabSize: {
|
|
102
|
-
type: NumberConstructor;
|
|
103
|
-
default: undefined;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Set line break (separetor) char.
|
|
107
|
-
*
|
|
108
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
|
|
109
|
-
*/
|
|
110
|
-
lineSeparator: {
|
|
111
|
-
type: StringConstructor;
|
|
112
|
-
default: undefined;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Readonly
|
|
116
|
-
*
|
|
117
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
|
|
118
|
-
*/
|
|
119
|
-
readonly: {
|
|
120
|
-
type: BooleanConstructor;
|
|
121
|
-
default: boolean;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Disable input.
|
|
125
|
-
*
|
|
126
|
-
* This is the reversed value of the CodeMirror editable.
|
|
127
|
-
* Similar to `readonly`, but setting this value to true disables dragging.
|
|
128
|
-
*
|
|
129
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
|
|
130
|
-
*/
|
|
131
|
-
disabled: {
|
|
132
|
-
type: BooleanConstructor;
|
|
133
|
-
default: boolean;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Additional Extension
|
|
137
|
-
*
|
|
138
|
-
* @see {@link https://codemirror.net/docs/ref/#state.Extension}
|
|
139
|
-
*/
|
|
140
|
-
extensions: {
|
|
141
|
-
type: PropType<Extension[]>;
|
|
142
|
-
default: () => never[];
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Language Phreses
|
|
146
|
-
*
|
|
147
|
-
* @see {@link https://codemirror.net/examples/translate/}
|
|
148
|
-
*/
|
|
149
|
-
phrases: {
|
|
150
|
-
type: PropType<Record<string, string>>;
|
|
151
|
-
default: () => undefined;
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* CodeMirror Language
|
|
155
|
-
*
|
|
156
|
-
* @see {@link https://codemirror.net/docs/ref/#language}
|
|
157
|
-
*/
|
|
158
|
-
lang: {
|
|
159
|
-
type: PropType<LanguageSupport>;
|
|
160
|
-
default: () => undefined;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* CodeMirror Linter
|
|
164
|
-
*
|
|
165
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.linter}
|
|
166
|
-
*/
|
|
167
|
-
linter: {
|
|
168
|
-
type: PropType<LintSource>;
|
|
169
|
-
default: undefined;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Linter Config
|
|
173
|
-
*
|
|
174
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
|
|
175
|
-
*/
|
|
176
|
-
linterConfig: {
|
|
177
|
-
type: ObjectConstructor;
|
|
178
|
-
default: () => void;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Show Linter Gutter
|
|
182
|
-
*
|
|
183
|
-
* An area to 🔴 the lines with errors will be displayed.
|
|
184
|
-
* This feature is not enabled if `linter` is not specified.
|
|
185
|
-
*
|
|
186
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
|
|
187
|
-
*/
|
|
188
|
-
gutter: {
|
|
189
|
-
type: BooleanConstructor;
|
|
190
|
-
defalt: boolean;
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* Gutter Config
|
|
194
|
-
*
|
|
195
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
|
|
196
|
-
*/
|
|
197
|
-
gutterConfig: {
|
|
198
|
-
type: ObjectConstructor;
|
|
199
|
-
default: () => void;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Using tag
|
|
203
|
-
*/
|
|
204
|
-
tag: {
|
|
205
|
-
type: StringConstructor;
|
|
206
|
-
default: string;
|
|
207
|
-
};
|
|
208
|
-
}, {
|
|
209
|
-
editor: Ref<HTMLElement | undefined>;
|
|
210
|
-
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, CodeMirrorEmitsOptions, "update:modelValue" | "update" | "focus" | "ready" | "destroy" | "change", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
211
|
-
/** Model value */
|
|
212
|
-
modelValue: {
|
|
213
|
-
type: PropType<string | Text>;
|
|
214
|
-
default: string;
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Theme
|
|
218
|
-
*
|
|
219
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
|
|
220
|
-
*/
|
|
221
|
-
theme: {
|
|
222
|
-
type: PropType<{
|
|
223
|
-
[selector: string]: StyleSpec;
|
|
224
|
-
}>;
|
|
225
|
-
default: () => void;
|
|
226
|
-
};
|
|
227
|
-
/** Dark Mode */
|
|
228
|
-
dark: {
|
|
229
|
-
type: BooleanConstructor;
|
|
230
|
-
default: boolean;
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
|
-
* Use Basic Setup
|
|
234
|
-
*
|
|
235
|
-
* @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
|
|
236
|
-
*/
|
|
237
|
-
basic: {
|
|
238
|
-
type: BooleanConstructor;
|
|
239
|
-
default: boolean;
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* Use Minimal Setup (The basic setting has priority.)
|
|
243
|
-
*
|
|
244
|
-
* @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
|
|
245
|
-
*/
|
|
246
|
-
minimal: {
|
|
247
|
-
type: BooleanConstructor;
|
|
248
|
-
default: boolean;
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Placeholder
|
|
252
|
-
*
|
|
253
|
-
* @see {@link https://codemirror.net/docs/ref/#view.placeholder}
|
|
254
|
-
*/
|
|
255
|
-
placeholder: {
|
|
256
|
-
type: PropType<string | HTMLElement>;
|
|
257
|
-
default: undefined;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Line wrapping
|
|
261
|
-
*
|
|
262
|
-
* An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
|
|
263
|
-
*
|
|
264
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
|
|
265
|
-
*/
|
|
266
|
-
wrap: {
|
|
267
|
-
type: BooleanConstructor;
|
|
268
|
-
default: boolean;
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* Allow tab key indent.
|
|
272
|
-
*
|
|
273
|
-
* @see {@link https://codemirror.net/examples/tab/}
|
|
274
|
-
*/
|
|
275
|
-
tab: {
|
|
276
|
-
type: BooleanConstructor;
|
|
277
|
-
default: boolean;
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Tab size
|
|
281
|
-
*
|
|
282
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
|
|
283
|
-
*/
|
|
284
|
-
tabSize: {
|
|
285
|
-
type: NumberConstructor;
|
|
286
|
-
default: undefined;
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* Set line break (separetor) char.
|
|
290
|
-
*
|
|
291
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
|
|
292
|
-
*/
|
|
293
|
-
lineSeparator: {
|
|
294
|
-
type: StringConstructor;
|
|
295
|
-
default: undefined;
|
|
296
|
-
};
|
|
297
|
-
/**
|
|
298
|
-
* Readonly
|
|
299
|
-
*
|
|
300
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
|
|
301
|
-
*/
|
|
302
|
-
readonly: {
|
|
303
|
-
type: BooleanConstructor;
|
|
304
|
-
default: boolean;
|
|
305
|
-
};
|
|
306
|
-
/**
|
|
307
|
-
* Disable input.
|
|
308
|
-
*
|
|
309
|
-
* This is the reversed value of the CodeMirror editable.
|
|
310
|
-
* Similar to `readonly`, but setting this value to true disables dragging.
|
|
311
|
-
*
|
|
312
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
|
|
313
|
-
*/
|
|
314
|
-
disabled: {
|
|
315
|
-
type: BooleanConstructor;
|
|
316
|
-
default: boolean;
|
|
317
|
-
};
|
|
318
|
-
/**
|
|
319
|
-
* Additional Extension
|
|
320
|
-
*
|
|
321
|
-
* @see {@link https://codemirror.net/docs/ref/#state.Extension}
|
|
322
|
-
*/
|
|
323
|
-
extensions: {
|
|
324
|
-
type: PropType<Extension[]>;
|
|
325
|
-
default: () => never[];
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Language Phreses
|
|
329
|
-
*
|
|
330
|
-
* @see {@link https://codemirror.net/examples/translate/}
|
|
331
|
-
*/
|
|
332
|
-
phrases: {
|
|
333
|
-
type: PropType<Record<string, string>>;
|
|
334
|
-
default: () => undefined;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* CodeMirror Language
|
|
338
|
-
*
|
|
339
|
-
* @see {@link https://codemirror.net/docs/ref/#language}
|
|
340
|
-
*/
|
|
341
|
-
lang: {
|
|
342
|
-
type: PropType<LanguageSupport>;
|
|
343
|
-
default: () => undefined;
|
|
344
|
-
};
|
|
345
|
-
/**
|
|
346
|
-
* CodeMirror Linter
|
|
347
|
-
*
|
|
348
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.linter}
|
|
349
|
-
*/
|
|
350
|
-
linter: {
|
|
351
|
-
type: PropType<LintSource>;
|
|
352
|
-
default: undefined;
|
|
353
|
-
};
|
|
354
|
-
/**
|
|
355
|
-
* Linter Config
|
|
356
|
-
*
|
|
357
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
|
|
358
|
-
*/
|
|
359
|
-
linterConfig: {
|
|
360
|
-
type: ObjectConstructor;
|
|
361
|
-
default: () => void;
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* Show Linter Gutter
|
|
365
|
-
*
|
|
366
|
-
* An area to 🔴 the lines with errors will be displayed.
|
|
367
|
-
* This feature is not enabled if `linter` is not specified.
|
|
368
|
-
*
|
|
369
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
|
|
370
|
-
*/
|
|
371
|
-
gutter: {
|
|
372
|
-
type: BooleanConstructor;
|
|
373
|
-
defalt: boolean;
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* Gutter Config
|
|
377
|
-
*
|
|
378
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
|
|
379
|
-
*/
|
|
380
|
-
gutterConfig: {
|
|
381
|
-
type: ObjectConstructor;
|
|
382
|
-
default: () => void;
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* Using tag
|
|
386
|
-
*/
|
|
387
|
-
tag: {
|
|
388
|
-
type: StringConstructor;
|
|
389
|
-
default: string;
|
|
390
|
-
};
|
|
391
|
-
}>> & {
|
|
392
|
-
[x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
|
|
393
|
-
}, {
|
|
394
|
-
modelValue: string | Text;
|
|
395
|
-
theme: {
|
|
396
|
-
[selector: string]: StyleSpec;
|
|
397
|
-
};
|
|
398
|
-
dark: boolean;
|
|
399
|
-
basic: boolean;
|
|
400
|
-
minimal: boolean;
|
|
401
|
-
placeholder: string | HTMLElement;
|
|
402
|
-
wrap: boolean;
|
|
403
|
-
tab: boolean;
|
|
404
|
-
tabSize: number;
|
|
405
|
-
lineSeparator: string;
|
|
406
|
-
readonly: boolean;
|
|
407
|
-
disabled: boolean;
|
|
408
|
-
extensions: Extension[];
|
|
409
|
-
phrases: Record<string, string>;
|
|
410
|
-
lang: LanguageSupport;
|
|
411
|
-
linter: LintSource;
|
|
412
|
-
linterConfig: Record<string, any>;
|
|
413
|
-
gutter: boolean;
|
|
414
|
-
gutterConfig: Record<string, any>;
|
|
415
|
-
tag: string;
|
|
416
|
-
}>;
|
|
417
|
-
export default _default;
|
|
418
|
-
//# sourceMappingURL=CodeMirror.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,GAAG,EAIT,MAAM,UAAU,CAAC;AASlB,OAAO,EAEL,WAAW,EAEX,KAAK,SAAS,EAEd,KAAK,IAAI,EACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,UAAU,EAGV,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAqB;AACrB,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,mBAAmB;IACnB,CAAC,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACrD,4BAA4B;IAC5B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACvC,yBAAyB;IACzB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,yBAAyB;IACzB,CACE,CAAC,EAAE,OAAO,EACV,KAAK,EAAE;QACL,IAAI,EAAE,UAAU,CAAC;QACjB,KAAK,EAAE,WAAW,CAAC;QACnB,SAAS,EAAE,WAAW,CAAC;KACxB,GACA,IAAI,CAAC;IACR,2BAA2B;IAC3B,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACrB,oBAAoB;IACpB,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CACzC;AAED,2BAA2B;;IAWvB,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;OAMG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;;OAOG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;;OAOG;;;;;IAKH;;;;OAIG;;;;;IAKH;;OAEG;;;;;;;;IA/KH,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;OAMG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;;OAOG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;;OAOG;;;;;IAKH;;;;OAIG;;;;;IAKH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzLP,wBAoiBG"}
|
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
import { computed, defineComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, watch, } from 'vue-demi';
|
|
2
|
-
// Helpers
|
|
3
|
-
import h, { slot } from '@/helpers/h-demi';
|
|
4
|
-
import compact from 'lodash/compact';
|
|
5
|
-
import trim from 'lodash/trim';
|
|
6
|
-
// CodeMirror
|
|
7
|
-
import { basicSetup, minimalSetup } from 'codemirror';
|
|
8
|
-
import { EditorSelection, EditorState, StateEffect, } from '@codemirror/state';
|
|
9
|
-
import { EditorView, keymap, placeholder, } from '@codemirror/view';
|
|
10
|
-
import { indentWithTab } from '@codemirror/commands';
|
|
11
|
-
import { forceLinting, linter, lintGutter, } from '@codemirror/lint';
|
|
12
|
-
/** CodeMirror Component */
|
|
13
|
-
export default defineComponent({
|
|
14
|
-
/** Component Name */
|
|
15
|
-
name: 'CodeMirror',
|
|
16
|
-
/** Model Definition */
|
|
17
|
-
model: {
|
|
18
|
-
prop: 'modelValue',
|
|
19
|
-
event: 'update:modelValue',
|
|
20
|
-
},
|
|
21
|
-
/** Props Definition */
|
|
22
|
-
props: {
|
|
23
|
-
/** Model value */
|
|
24
|
-
modelValue: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: '',
|
|
27
|
-
},
|
|
28
|
-
/**
|
|
29
|
-
* Theme
|
|
30
|
-
*
|
|
31
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
|
|
32
|
-
*/
|
|
33
|
-
theme: {
|
|
34
|
-
type: Object,
|
|
35
|
-
default: () => { },
|
|
36
|
-
},
|
|
37
|
-
/** Dark Mode */
|
|
38
|
-
dark: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: false,
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Use Basic Setup
|
|
44
|
-
*
|
|
45
|
-
* @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
|
|
46
|
-
*/
|
|
47
|
-
basic: {
|
|
48
|
-
type: Boolean,
|
|
49
|
-
default: false,
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Use Minimal Setup (The basic setting has priority.)
|
|
53
|
-
*
|
|
54
|
-
* @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
|
|
55
|
-
*/
|
|
56
|
-
minimal: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false,
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* Placeholder
|
|
62
|
-
*
|
|
63
|
-
* @see {@link https://codemirror.net/docs/ref/#view.placeholder}
|
|
64
|
-
*/
|
|
65
|
-
placeholder: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: undefined,
|
|
68
|
-
},
|
|
69
|
-
/**
|
|
70
|
-
* Line wrapping
|
|
71
|
-
*
|
|
72
|
-
* An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
|
|
73
|
-
*
|
|
74
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
|
|
75
|
-
*/
|
|
76
|
-
wrap: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
default: false,
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* Allow tab key indent.
|
|
82
|
-
*
|
|
83
|
-
* @see {@link https://codemirror.net/examples/tab/}
|
|
84
|
-
*/
|
|
85
|
-
tab: {
|
|
86
|
-
type: Boolean,
|
|
87
|
-
default: false,
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Tab size
|
|
91
|
-
*
|
|
92
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
|
|
93
|
-
*/
|
|
94
|
-
tabSize: {
|
|
95
|
-
type: Number,
|
|
96
|
-
default: undefined,
|
|
97
|
-
},
|
|
98
|
-
/**
|
|
99
|
-
* Set line break (separetor) char.
|
|
100
|
-
*
|
|
101
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
|
|
102
|
-
*/
|
|
103
|
-
lineSeparator: {
|
|
104
|
-
type: String,
|
|
105
|
-
default: undefined,
|
|
106
|
-
},
|
|
107
|
-
/**
|
|
108
|
-
* Readonly
|
|
109
|
-
*
|
|
110
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
|
|
111
|
-
*/
|
|
112
|
-
readonly: {
|
|
113
|
-
type: Boolean,
|
|
114
|
-
default: false,
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* Disable input.
|
|
118
|
-
*
|
|
119
|
-
* This is the reversed value of the CodeMirror editable.
|
|
120
|
-
* Similar to `readonly`, but setting this value to true disables dragging.
|
|
121
|
-
*
|
|
122
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
|
|
123
|
-
*/
|
|
124
|
-
disabled: {
|
|
125
|
-
type: Boolean,
|
|
126
|
-
default: false,
|
|
127
|
-
},
|
|
128
|
-
/**
|
|
129
|
-
* Additional Extension
|
|
130
|
-
*
|
|
131
|
-
* @see {@link https://codemirror.net/docs/ref/#state.Extension}
|
|
132
|
-
*/
|
|
133
|
-
extensions: {
|
|
134
|
-
type: Array,
|
|
135
|
-
default: () => {
|
|
136
|
-
return [];
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
/**
|
|
140
|
-
* Language Phreses
|
|
141
|
-
*
|
|
142
|
-
* @see {@link https://codemirror.net/examples/translate/}
|
|
143
|
-
*/
|
|
144
|
-
phrases: {
|
|
145
|
-
type: Object,
|
|
146
|
-
default: () => undefined,
|
|
147
|
-
},
|
|
148
|
-
/**
|
|
149
|
-
* CodeMirror Language
|
|
150
|
-
*
|
|
151
|
-
* @see {@link https://codemirror.net/docs/ref/#language}
|
|
152
|
-
*/
|
|
153
|
-
lang: {
|
|
154
|
-
type: Object,
|
|
155
|
-
default: () => undefined,
|
|
156
|
-
},
|
|
157
|
-
/**
|
|
158
|
-
* CodeMirror Linter
|
|
159
|
-
*
|
|
160
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.linter}
|
|
161
|
-
*/
|
|
162
|
-
linter: {
|
|
163
|
-
type: Function,
|
|
164
|
-
default: undefined,
|
|
165
|
-
},
|
|
166
|
-
/**
|
|
167
|
-
* Linter Config
|
|
168
|
-
*
|
|
169
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
|
|
170
|
-
*/
|
|
171
|
-
linterConfig: {
|
|
172
|
-
type: Object,
|
|
173
|
-
default: () => { },
|
|
174
|
-
},
|
|
175
|
-
/**
|
|
176
|
-
* Show Linter Gutter
|
|
177
|
-
*
|
|
178
|
-
* An area to 🔴 the lines with errors will be displayed.
|
|
179
|
-
* This feature is not enabled if `linter` is not specified.
|
|
180
|
-
*
|
|
181
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
|
|
182
|
-
*/
|
|
183
|
-
gutter: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
defalt: false,
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* Gutter Config
|
|
189
|
-
*
|
|
190
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
|
|
191
|
-
*/
|
|
192
|
-
gutterConfig: {
|
|
193
|
-
type: Object,
|
|
194
|
-
default: () => { },
|
|
195
|
-
},
|
|
196
|
-
/**
|
|
197
|
-
* Using tag
|
|
198
|
-
*/
|
|
199
|
-
tag: {
|
|
200
|
-
type: String,
|
|
201
|
-
default: 'div',
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
/** Emits */
|
|
205
|
-
emits: ['update:modelValue', 'update', 'ready', 'focus', 'change', 'destroy'],
|
|
206
|
-
/**
|
|
207
|
-
* Setup
|
|
208
|
-
*
|
|
209
|
-
* @param props - Props
|
|
210
|
-
* @param context - Context
|
|
211
|
-
*/
|
|
212
|
-
setup(props, context) {
|
|
213
|
-
/** Editor DOM */
|
|
214
|
-
const editor = ref();
|
|
215
|
-
/** Internal value */
|
|
216
|
-
const doc = ref(props.modelValue);
|
|
217
|
-
/**
|
|
218
|
-
* CodeMirror Editor View
|
|
219
|
-
*
|
|
220
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView}
|
|
221
|
-
*/
|
|
222
|
-
const view = shallowRef(new EditorView());
|
|
223
|
-
/**
|
|
224
|
-
* Editor Selection
|
|
225
|
-
*
|
|
226
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorSelection}
|
|
227
|
-
*/
|
|
228
|
-
const selection = computed({
|
|
229
|
-
get: () => view.value.state.selection,
|
|
230
|
-
set: s => view.value.dispatch({ selection: s }),
|
|
231
|
-
});
|
|
232
|
-
/**
|
|
233
|
-
* Editor State
|
|
234
|
-
*
|
|
235
|
-
* @see {@link https://codemirror.net/docs/ref/#state.EditorState}
|
|
236
|
-
*/
|
|
237
|
-
const state = computed({
|
|
238
|
-
get: () => view.value.state,
|
|
239
|
-
set: s => view.value.setState(s),
|
|
240
|
-
});
|
|
241
|
-
/** Cursor Position */
|
|
242
|
-
const cursor = computed({
|
|
243
|
-
get: () => view.value.state.selection.main.head || 0,
|
|
244
|
-
set: a => view.value.dispatch({ selection: { anchor: a } }),
|
|
245
|
-
});
|
|
246
|
-
/**
|
|
247
|
-
* Focus
|
|
248
|
-
*
|
|
249
|
-
* @see {@link https://codemirror.net/docs/ref/#view.EditorView.hasFocus}
|
|
250
|
-
*/
|
|
251
|
-
const focus = computed({
|
|
252
|
-
get: () => view.value.hasFocus,
|
|
253
|
-
set: f => {
|
|
254
|
-
if (f) {
|
|
255
|
-
view.value.focus();
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
/** Text length */
|
|
260
|
-
const length = computed(() => view.value.state.doc.length);
|
|
261
|
-
/** Get CodeMirror Extension */
|
|
262
|
-
const extensions = computed(() =>
|
|
263
|
-
// TODO: Ignore previous prop was not changed.
|
|
264
|
-
compact([
|
|
265
|
-
// Toggle basic setup
|
|
266
|
-
props.basic ? basicSetup : undefined,
|
|
267
|
-
// Toggle minimal setup
|
|
268
|
-
props.minimal && !props.basic ? minimalSetup : undefined,
|
|
269
|
-
// ViewUpdate event listener
|
|
270
|
-
EditorView.updateListener.of((update) => context.emit('update', update)),
|
|
271
|
-
// Toggle light/dark mode.
|
|
272
|
-
EditorView.theme(props.theme, { dark: props.dark }),
|
|
273
|
-
// Toggle line wrapping
|
|
274
|
-
props.wrap ? EditorView.lineWrapping : undefined,
|
|
275
|
-
// Indent with tab
|
|
276
|
-
props.tab ? keymap.of([indentWithTab]) : undefined,
|
|
277
|
-
// Indent tab size
|
|
278
|
-
props.tabSize ? EditorState.tabSize.of(props.tabSize) : undefined,
|
|
279
|
-
// locale settings
|
|
280
|
-
props.phrases ? EditorState.phrases.of(props.phrases) : undefined,
|
|
281
|
-
// Readonly option
|
|
282
|
-
EditorState.readOnly.of(props.readonly),
|
|
283
|
-
// Editable option
|
|
284
|
-
EditorView.editable.of(!props.disabled),
|
|
285
|
-
// Set Line break char
|
|
286
|
-
props.lineSeparator
|
|
287
|
-
? EditorState.lineSeparator.of(props.lineSeparator)
|
|
288
|
-
: undefined,
|
|
289
|
-
// Lang
|
|
290
|
-
props.lang ? props.lang : undefined,
|
|
291
|
-
// Append Linter settings
|
|
292
|
-
props.linter ? linter(props.linter, props.linterConfig) : undefined,
|
|
293
|
-
// Show 🔴 to error line when linter enabled.
|
|
294
|
-
props.linter && props.gutter
|
|
295
|
-
? lintGutter(props.gutterConfig)
|
|
296
|
-
: undefined,
|
|
297
|
-
// Placeholder
|
|
298
|
-
props.placeholder ? placeholder(props.placeholder) : undefined,
|
|
299
|
-
// Append Extensions (such as basic-setup)
|
|
300
|
-
...props.extensions,
|
|
301
|
-
]));
|
|
302
|
-
// for parent-to-child binding.
|
|
303
|
-
watch(() => props.modelValue, value => {
|
|
304
|
-
if (view.value.composing) {
|
|
305
|
-
// IME fix
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
// Update
|
|
309
|
-
view.value.dispatch({
|
|
310
|
-
changes: { from: 0, to: view.value.state.doc.length, insert: value },
|
|
311
|
-
selection: view.value.state.selection,
|
|
312
|
-
scrollIntoView: true,
|
|
313
|
-
});
|
|
314
|
-
}, { immediate: true });
|
|
315
|
-
// Extension (mostly props) Changed
|
|
316
|
-
watch(extensions, exts =>
|
|
317
|
-
// TODO: Reduce unchanched value
|
|
318
|
-
view.value.dispatch({
|
|
319
|
-
effects: StateEffect.reconfigure.of(exts),
|
|
320
|
-
}));
|
|
321
|
-
// focus changed
|
|
322
|
-
watch(focus, isFocus => context.emit('focus', isFocus));
|
|
323
|
-
/** When loaded */
|
|
324
|
-
onMounted(async () => {
|
|
325
|
-
/** Initial value */
|
|
326
|
-
let value = doc.value;
|
|
327
|
-
if (editor.value && editor.value.childNodes[0]) {
|
|
328
|
-
// when slot mode, overwrite initial value
|
|
329
|
-
if (doc.value !== '') {
|
|
330
|
-
console.warn('[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values.');
|
|
331
|
-
}
|
|
332
|
-
value = trim(editor.value.childNodes[0].innerText);
|
|
333
|
-
}
|
|
334
|
-
// Register Codemirror
|
|
335
|
-
view.value = new EditorView({
|
|
336
|
-
doc: value,
|
|
337
|
-
extensions: extensions.value,
|
|
338
|
-
parent: editor.value,
|
|
339
|
-
dispatch: tr => {
|
|
340
|
-
view.value.update([tr]);
|
|
341
|
-
// TODO: Emit lint error event
|
|
342
|
-
// console.log(view.state.doc.toString(), tr);
|
|
343
|
-
if (tr.changes.empty)
|
|
344
|
-
return;
|
|
345
|
-
// child-to-parent binding
|
|
346
|
-
const v = view.value.state.doc.toString();
|
|
347
|
-
context.emit('update:modelValue', v);
|
|
348
|
-
context.emit('change', view.value.state);
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
await nextTick();
|
|
352
|
-
context.emit('ready', {
|
|
353
|
-
view: view,
|
|
354
|
-
state: view.value.state,
|
|
355
|
-
container: editor.value,
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
/** Destroy */
|
|
359
|
-
onUnmounted(() => {
|
|
360
|
-
if (view.value) {
|
|
361
|
-
view.value.destroy();
|
|
362
|
-
context.emit('destroy');
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
/**
|
|
366
|
-
* Forces any linters configured to run when the editor is idle to run right away.
|
|
367
|
-
*
|
|
368
|
-
* @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
|
|
369
|
-
*/
|
|
370
|
-
const lint = () => {
|
|
371
|
-
if (props.linter) {
|
|
372
|
-
forceLinting(view.value);
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
/* ----- Bellow is experimental. ------ */
|
|
376
|
-
/**
|
|
377
|
-
* Get the text between the given points in the editor.
|
|
378
|
-
*
|
|
379
|
-
* @param from - start line number
|
|
380
|
-
* @param to - end line number
|
|
381
|
-
*/
|
|
382
|
-
const getRange = (from, to) => view.value.state.sliceDoc(from, to);
|
|
383
|
-
/**
|
|
384
|
-
* Get the content of line.
|
|
385
|
-
*
|
|
386
|
-
* @param number - line number
|
|
387
|
-
*/
|
|
388
|
-
const getLine = (number) => view.value.state.doc.line(number + 1).text;
|
|
389
|
-
/** Get the number of lines in the editor. */
|
|
390
|
-
const lineCount = () => view.value.state.doc.lines;
|
|
391
|
-
/** Retrieve one end of the primary selection. */
|
|
392
|
-
const getCursor = () => cursor.value;
|
|
393
|
-
/** Retrieves a list of all current selections. */
|
|
394
|
-
const listSelections = () => view.value.state.selection.ranges;
|
|
395
|
-
/** Get the currently selected code. */
|
|
396
|
-
const getSelection = () => view.value.state.sliceDoc(view.value.state.selection.main.from, view.value.state.selection.main.to);
|
|
397
|
-
/**
|
|
398
|
-
* The length of the given array should be the same as the number of active selections.
|
|
399
|
-
* Replaces the content of the selections with the strings in the array.
|
|
400
|
-
*/
|
|
401
|
-
const getSelections = () => view.value.state.selection.ranges.map((r) => view.value.state.sliceDoc(r.from, r.to));
|
|
402
|
-
/** Return true if any text is selected. */
|
|
403
|
-
const somethingSelected = () => view.value.state.selection.ranges.some((r) => !r.empty);
|
|
404
|
-
/**
|
|
405
|
-
* Replace the part of the document between from and to with the given string.
|
|
406
|
-
*
|
|
407
|
-
* @param replacement - replacement text
|
|
408
|
-
* @param from - start string at position
|
|
409
|
-
* @param to - insert the string at position
|
|
410
|
-
*/
|
|
411
|
-
const replaceRange = (replacement, from, to) => view.value.dispatch({
|
|
412
|
-
changes: { from, to, insert: replacement },
|
|
413
|
-
});
|
|
414
|
-
/**
|
|
415
|
-
* Replace the selection(s) with the given string.
|
|
416
|
-
* By default, the new selection ends up after the inserted text.
|
|
417
|
-
*
|
|
418
|
-
* @param replacement - replacement text
|
|
419
|
-
*/
|
|
420
|
-
const replaceSelection = (replacement) => view.value.dispatch(view.value.state.replaceSelection(replacement));
|
|
421
|
-
/**
|
|
422
|
-
* Set the cursor position.
|
|
423
|
-
*
|
|
424
|
-
* @param position - position.
|
|
425
|
-
*/
|
|
426
|
-
const setCursor = (position) => (cursor.value = position);
|
|
427
|
-
/**
|
|
428
|
-
* Set a single selection range.
|
|
429
|
-
*
|
|
430
|
-
* @param anchor - anchor position
|
|
431
|
-
* @param head -
|
|
432
|
-
*/
|
|
433
|
-
const setSelection = (anchor, head) => view.value.dispatch({ selection: { anchor, head } });
|
|
434
|
-
/**
|
|
435
|
-
* Sets a new set of selections. There must be at least one selection in the given array.
|
|
436
|
-
*
|
|
437
|
-
* @param ranges - Selection range
|
|
438
|
-
* @param primary -
|
|
439
|
-
*/
|
|
440
|
-
const setSelections = (ranges, primary) => view.value.dispatch({
|
|
441
|
-
selection: EditorSelection.create(ranges, primary),
|
|
442
|
-
});
|
|
443
|
-
/**
|
|
444
|
-
* Applies the given function to all existing selections, and calls extendSelections on the result.
|
|
445
|
-
*
|
|
446
|
-
* @param f - function
|
|
447
|
-
*/
|
|
448
|
-
const extendSelectionsBy = (f) => view.value.dispatch({
|
|
449
|
-
selection: EditorSelection.create(selection.value.ranges.map((r) => r.extend(f(r)))),
|
|
450
|
-
});
|
|
451
|
-
/** Export properties and functions */
|
|
452
|
-
context.expose({
|
|
453
|
-
editor,
|
|
454
|
-
cursor,
|
|
455
|
-
selection,
|
|
456
|
-
state,
|
|
457
|
-
focus,
|
|
458
|
-
length,
|
|
459
|
-
lint,
|
|
460
|
-
// Bellow is CodeMirror5's function
|
|
461
|
-
getRange,
|
|
462
|
-
getLine,
|
|
463
|
-
lineCount,
|
|
464
|
-
getCursor,
|
|
465
|
-
listSelections,
|
|
466
|
-
getSelection,
|
|
467
|
-
getSelections,
|
|
468
|
-
somethingSelected,
|
|
469
|
-
replaceRange,
|
|
470
|
-
replaceSelection,
|
|
471
|
-
setCursor,
|
|
472
|
-
setSelection,
|
|
473
|
-
setSelections,
|
|
474
|
-
extendSelectionsBy,
|
|
475
|
-
});
|
|
476
|
-
return {
|
|
477
|
-
editor,
|
|
478
|
-
};
|
|
479
|
-
},
|
|
480
|
-
render() {
|
|
481
|
-
// <template>
|
|
482
|
-
// <div ref="editor" class="vue-codemirror">
|
|
483
|
-
// <aside v-show="!context.slots.default" aria-hidden><slot /></aside>
|
|
484
|
-
// </div>
|
|
485
|
-
// </template>
|
|
486
|
-
return h(this.$props.tag, {
|
|
487
|
-
ref: 'editor',
|
|
488
|
-
class: 'vue-codemirror',
|
|
489
|
-
}, this.$slots.default
|
|
490
|
-
? // Hide original content
|
|
491
|
-
h('aside', { style: 'display: none;', 'aria-hidden': 'true' }, slot(this.$slots.default))
|
|
492
|
-
: undefined);
|
|
493
|
-
},
|
|
494
|
-
});
|
package/dist/helpers/h-demi.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* h-demi - h function for Vue 2 and 3
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://github.com/vueuse/vue-demi/issues/65}
|
|
5
|
-
*/
|
|
6
|
-
import { type VNode } from 'vue-demi';
|
|
7
|
-
interface Options {
|
|
8
|
-
class?: string;
|
|
9
|
-
domProps?: Record<any, any>;
|
|
10
|
-
on?: Record<any, any>;
|
|
11
|
-
props?: Record<any, any>;
|
|
12
|
-
ref?: string;
|
|
13
|
-
style?: string;
|
|
14
|
-
'aria-hidden'?: string;
|
|
15
|
-
}
|
|
16
|
-
declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => VNode;
|
|
17
|
-
declare const slot: (defaultSlots: any) => any;
|
|
18
|
-
export { slot, h as default };
|
|
19
|
-
//# sourceMappingURL=h-demi.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAsB,KAAK,KAAK,EAAQ,MAAM,UAAU,CAAC;AAEhE,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG,KACZ,KAcF,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QACoC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/helpers/h-demi.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* h-demi - h function for Vue 2 and 3
|
|
3
|
-
*
|
|
4
|
-
* @see {@link https://github.com/vueuse/vue-demi/issues/65}
|
|
5
|
-
*/
|
|
6
|
-
import { h as hDemi, isVue2, Vue2 } from 'vue-demi';
|
|
7
|
-
const adaptOnsV3 = (ons) => {
|
|
8
|
-
if (!ons)
|
|
9
|
-
return {};
|
|
10
|
-
return Object.entries(ons).reduce((ret, [key, handler]) => {
|
|
11
|
-
key = key.charAt(0).toUpperCase() + key.slice(1);
|
|
12
|
-
key = `on${key}`;
|
|
13
|
-
return { ...ret, [key]: handler };
|
|
14
|
-
}, {});
|
|
15
|
-
};
|
|
16
|
-
const h = (type, options = {}, chidren) => {
|
|
17
|
-
if (isVue2 && parseInt(Vue2.version) < 2.7) {
|
|
18
|
-
// Makeshift support :(
|
|
19
|
-
// Since Vue2.7 includes the Composition API, the functions in vue-demi are not used.
|
|
20
|
-
return hDemi(type, options, chidren);
|
|
21
|
-
}
|
|
22
|
-
const { props, domProps, on, ...extraOptions } = options;
|
|
23
|
-
const ons = on ? adaptOnsV3(on) : {};
|
|
24
|
-
return hDemi(type, { ...extraOptions, ...props, ...domProps, ...ons }, chidren);
|
|
25
|
-
};
|
|
26
|
-
const slot = (defaultSlots) => typeof defaultSlots == 'function' ? defaultSlots() : defaultSlots;
|
|
27
|
-
export { slot, h as default };
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,IAAI,MAAM,QAAQ,CAAC;AAG1B,QAAA,MAAM,iBAAiB,QAAS,GAAG,QAA4C,CAAC;AAEhF,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import CodeMirror from './components/CodeMirror';
|
|
2
|
-
import Meta from './Meta';
|
|
3
|
-
// TODO: Move phrases props to option.
|
|
4
|
-
const installCodeMirror = (app) => app.component('CodeMirror', CodeMirror);
|
|
5
|
-
export { CodeMirror as default, installCodeMirror as install, Meta };
|
|
6
|
-
// For CDN. (Maybe Vue2 only)
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
if (typeof window !== 'undefined' && window.Vue) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
window.Vue.use(CodeMirror);
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MetaInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/MetaInterface.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,CAAC,OAAO,WAAW,aAAa;IACpC,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|