Skip to content

Commit b35d6e1

Browse files
committed
feat: 去除不必要的dependencies依赖
1 parent ccae87b commit b35d6e1

File tree

8 files changed

+1799
-1625
lines changed

8 files changed

+1799
-1625
lines changed

.eslintrc-auto-import.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"onServerPrefetch": true,
4444
"onUnmounted": true,
4545
"onUpdated": true,
46+
"onWatcherCleanup": true,
4647
"provide": true,
4748
"reactive": true,
4849
"readonly": true,
@@ -60,10 +61,13 @@
6061
"useAttrs": true,
6162
"useCssModule": true,
6263
"useCssVars": true,
64+
"useId": true,
6365
"useLink": true,
66+
"useModel": true,
6467
"useRoute": true,
6568
"useRouter": true,
6669
"useSlots": true,
70+
"useTemplateRef": true,
6771
"watch": true,
6872
"watchEffect": true,
6973
"watchPostEffect": true,

docs/demo/examples/lint/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const schemas = [
2828
comp: defineAsyncComponent(() => import("./jsonLint.vue")),
2929
describe: "校验 json 数据, 在任意位置输入字符尝试校验功能",
3030
lang: "application/json",
31-
deps: ["jsonlint"],
31+
deps: ["jsonlint-mod-fixed"],
3232
},
3333
];
3434

docs/demo/examples/lint/jsonLint.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { ref, reactive } from "vue";
1414
import { Editor, EditorConfiguration } from "codemirror";
1515
import Codemirror from "codemirror-editor-vue3";
16-
import jsonlint from "jsonlint-mod";
16+
import jsonlint from "jsonlint-mod-fixed";
1717
// language json or js
1818
import "codemirror/mode/javascript/javascript.js";
1919
import "codemirror/addon/lint/lint.css";

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"repository": {
3434
"type": "git",
35-
"url": "https://github.com/rennzhang/codemirror-editor-vue3/"
35+
"url": "git+https://github.com/rennzhang/codemirror-editor-vue3.git"
3636
},
3737
"keywords": [
3838
"codemirror-editor-vue3",
@@ -58,20 +58,20 @@
5858
"prepublishOnly": "npm run build"
5959
},
6060
"dependencies": {
61-
"@unocss/transformer-directives": "^0.58.8",
62-
"@wdns/vue-code-block": "^2.3.2",
6361
"codemirror": "^5",
64-
"diff-match-patch": "^1.0.5",
65-
"element-plus": "^2.6.3",
66-
"jsonlint-mod": "^1.7.6",
67-
"unplugin-vue-components": "^0.26.0"
62+
"diff-match-patch": "^1.0.5"
6863
},
6964
"peerDependencies": {
7065
"codemirror": "^5",
7166
"diff-match-patch": "^1.0.5",
7267
"vue": "^3.x"
7368
},
7469
"devDependencies": {
70+
"@unocss/transformer-directives": "^0.58.8",
71+
"@wdns/vue-code-block": "^2.3.2",
72+
"unplugin-vue-components": "^0.26.0",
73+
"element-plus": "^2.6.3",
74+
"jsonlint-mod-fixed": "^1.7.7",
7575
"@commitlint/cli": "^16.1.0",
7676
"@commitlint/config-conventional": "^16.0.0",
7777
"@types/codemirror": "^5.60.15",

playground/demo/json.vue

Lines changed: 76 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,91 @@
11
<template>
2-
<div>
3-
darcula theme:
4-
<Codemirror v-model:value="code" :options="cmOptions" border :height="200" />
5-
</div>
2+
<Codemirror
3+
v-model:value="code"
4+
:options="cmOptions"
5+
:height="300"
6+
width="90%"
7+
class="cm-component"
8+
:border="true"
9+
@ready="onReady"
10+
/>
611
</template>
7-
<script lang="ts">
8-
import { ref } from "vue";
9-
import type { EditorConfiguration } from "codemirror";
12+
<script lang="ts" setup>
13+
import { ref, reactive } from "vue";
14+
import { Editor, EditorConfiguration } from "codemirror";
1015
import Codemirror from "codemirror-editor-vue3";
11-
12-
// language
16+
import jsonlint from "jsonlint-mod-fixed";
17+
// language json or js
1318
import "codemirror/mode/javascript/javascript.js";
1419
import "codemirror/addon/lint/lint.css";
15-
// import 'codemirror/addon/fold/foldgutter.css'
16-
// import 'codemirror/addon/fold/foldcode.js'
17-
// import 'codemirror/addon/fold/foldgutter.js'
18-
// import 'codemirror/addon/fold/brace-fold.js'
20+
import "codemirror/addon/lint/lint.js";
21+
import "codemirror/addon/lint/json-lint";
1922
20-
export default defineComponent({
21-
components: {
22-
Codemirror,
23-
},
24-
setup() {
25-
const code = ref(`{
26-
"name": "codemirror-editor-vue3",
27-
"description": "CodeMirror component for Vue3",
28-
"version": "2.4.1",
29-
"license": "MIT",
30-
"files": [
31-
"dist"
32-
],
33-
"type": "module",
34-
"types": "./dist/packages/index.d.ts",
35-
"main": "./dist/codemirror-editor-vue3.umd.cjs",
36-
"module": "./dist/codemirror-editor-vue3.js",
37-
"exports": {
38-
".": {
39-
"import": "./dist/codemirror-editor-vue3.js",
40-
"require": "./dist/codemirror-editor-vue3.umd.cjs"
23+
window.jsonlint = jsonlint;
24+
25+
const code = ref(`{
26+
"compilerOptions": {
27+
"baseUrl": ".",
28+
"module": "ESNext",
29+
"target": "esnext",
30+
"lib": ["DOM", "ESNext"],
31+
"types": ["vite/client"],
32+
"jsx": "preserve",
33+
"allowJs": true,
34+
"strict": true,
35+
"esModuleInterop": true,
36+
"incremental": false,
37+
"skipLibCheck": true,
38+
"moduleResolution": "node",
39+
"resolveJsonModule": true,
40+
"noUnusedLocals": true,
41+
"strictNullChecks": true,
42+
"declaration": true,
43+
"forceConsistentCasingInFileNames": true,
44+
"paths": {
45+
"@/*": ["packages/*"],
46+
"./*": ["./*"],
47+
"codemirror-editor-vue3": ["packages/index.ts"]
4148
}
4249
},
43-
"private": false,
44-
"author": {
45-
"name": "RennCheung",
46-
"email": "906155099@qq.com"
47-
},
48-
"homepage": "https://rennzhang.github.io/codemirror-editor-vue3/",
49-
"unpkg": "dist/codemirror-editor-vue3.js",
50-
"jsnext:main": "dist/codemirror-editor-vue3.js",
51-
"jspm": {
52-
"main": "dist/codemirror-editor-vue3.js",
53-
"registry": "npm",
54-
"format": "esm"
55-
},
56-
"repository": {
57-
"type": "git",
58-
"url": "https://github.com/rennzhang/codemirror-editor-vue3/"
59-
},
60-
"keywords": [
61-
"codemirror-editor-vue3",
62-
"vue3 codemirror",
63-
"codemirror",
64-
"vue3",
65-
"log mode",
66-
"log"
67-
],
68-
"scripts": {
69-
"dev": "vite",
70-
"build": "vite build",
71-
"docs-dev": "vitepress dev docs --open",
72-
"docs-build": "vitepress build docs",
73-
"docs-serve": "vitepress serve docs",
74-
"deploy-docs": "bash scripts/deploy-docs.sh",
75-
"release": "tsx scripts/release.ts",
76-
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
77-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
78-
"tsc": "tsc",
79-
"prepublishOnly": "npm run build"
80-
},
81-
"dependencies": {
82-
"codemirror": "^5.65.16",
83-
"diff-match-patch": "^1.0.5"
84-
},
85-
"peerDependencies": {
86-
"codemirror": "^5.65.16",
87-
"diff-match-patch": "^1.0.5",
88-
"vue": "^3.x"
89-
},
90-
"devDependencies": {
91-
"@commitlint/cli": "^16.1.0",
92-
"@commitlint/config-conventional": "^16.0.0",
93-
"@types/codemirror": "^5.60.15",
94-
"@types/diff-match-patch": "^1.0.32",
95-
"@types/node": "^16.11.13",
96-
"@typescript-eslint/eslint-plugin": "^5.54.0",
97-
"@typescript-eslint/parser": "^5.54.0",
98-
"@vitejs/plugin-vue": "^4.0.0",
99-
"@vitejs/plugin-vue-jsx": "^3.0.0",
100-
"@vue/cli-plugin-typescript": "~4.5.15",
101-
"chalk": "^4.1.2",
102-
"conventional-changelog-cli": "^2.0.31",
103-
"dedent": "^0.7.0",
104-
"diff-match-patch": "^1.0.5",
105-
"eslint": "^8.35.0",
106-
"eslint-config-airbnb-base": "^15.0.0",
107-
"eslint-config-prettier": "^8.6.0",
108-
"eslint-plugin-import": "^2.27.5",
109-
"eslint-plugin-prettier": "^4.2.1",
110-
"eslint-plugin-vue": "^9.9.0",
111-
"execa": "^7.0.0",
112-
"less": "^4.1.3",
113-
"lint-staged": "^10.2.10",
114-
"minimist": "^1.2.6",
115-
"picocolors": "^1.0.0",
116-
"prettier": "^2.8.4",
117-
"prompts": "^2.4.2",
118-
"rollup-plugin-vue": "^6.0.0",
119-
"semver": "^7.3.5",
120-
"tsx": "^3.12.3",
121-
"enquirer": "^2.3.6",
122-
"typescript": "^4.9.5",
123-
"unplugin-auto-import": "^0.15.0",
124-
"vite": "^4.1.4",
125-
"vite-plugin-checker": "^0.5.6",
126-
"vite-plugin-dts": "^2.0.2",
127-
"vite-plugin-pages": "^0.28.0",
128-
"vite-plugin-windicss": "^1.8.10",
129-
"vitepress": "1.0.0-alpha.49",
130-
"vue": "^3.2.47",
131-
"vue-router": "^4.1.6",
132-
"vue-tsc": "^1.2.0",
133-
"windicss": "^3.5.6",
134-
"yorkie-pnpm": "^2.0.1"
135-
}
50+
"include": [
51+
"packages/**/*",
52+
"playground/**/*",
53+
"docs/**/*",
54+
"docs/demo/**/*",
55+
"script",
56+
"types",
57+
"*.ts",
58+
"*.tsx",
59+
"*.vue",
60+
"*.d.ts",
61+
"*.md"
62+
]
13663
}
13764
`);
13865
139-
const cmOptions: EditorConfiguration = {
140-
// json编辑器选项
141-
mode: "application/json",
142-
indentWithTabs: true,
143-
smartIndent: true,
144-
lineNumbers: true,
145-
autofocus: false,
146-
foldGutter: false,
147-
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
148-
};
66+
const cmOptions: EditorConfiguration = reactive({
67+
mode: "application/json",
68+
lineNumbers: true,
69+
lineWiseCopyCut: true,
70+
gutters: ["CodeMirror-lint-markers"],
71+
lint: true,
72+
});
73+
74+
const cminstance = ref<Editor | null>(null);
75+
const onReady = (cm: Editor) => {
76+
cminstance.value = cm;
77+
console.log(cm.getValue());
78+
};
14979
150-
return {
151-
code,
152-
cmOptions,
153-
};
80+
defineExpose({
81+
setTheme: (theme: string) => {
82+
console.log(" theme", theme);
83+
cminstance.value?.setOption("theme", theme);
15484
},
15585
});
15686
</script>
87+
<style lang="less" scoped>
88+
.cm-component {
89+
font-family: monospace;
90+
}
91+
</style>

0 commit comments

Comments
 (0)