change code editor to codemirror.

This commit is contained in:
2023-04-07 10:00:29 +08:00
parent 007de440d6
commit 0862b0ff91
14 changed files with 335 additions and 2744 deletions

336
package-lock.json generated
View File

@@ -8,13 +8,17 @@
"name": "oj-next",
"version": "0.0.1",
"dependencies": {
"@codemirror/lang-cpp": "^6.0.2",
"@codemirror/lang-java": "^6.0.1",
"@codemirror/lang-javascript": "^6.1.5",
"@codemirror/lang-python": "^6.1.2",
"@element-plus/icons-vue": "^2.1.0",
"@monaco-editor/loader": "^1.3.3",
"@vueuse/core": "^9.13.0",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12",
"axios": "1.3.4",
"chart.js": "^4.2.1",
"codemirror": "^6.0.1",
"copy-text-to-clipboard": "^3.1.0",
"date-fns": "^2.29.3",
"highlight.js": "^11.7.0",
@@ -24,6 +28,7 @@
"pinia": "^2.0.33",
"vue": "^3.2.47",
"vue-chartjs": "^5.2.0",
"vue-codemirror": "^6.1.1",
"vue-router": "^4.1.6"
},
"devDependencies": {
@@ -32,7 +37,6 @@
"@vitejs/plugin-legacy": "^4.0.2",
"@vitejs/plugin-vue": "^4.1.0",
"markdown-it-shiki": "^0.8.0",
"monaco-editor": "^0.30.1",
"prettier": "^2.8.7",
"terser": "^5.16.8",
"typescript": "^5.0.3",
@@ -1723,6 +1727,124 @@
"node": ">=6.9.0"
}
},
"node_modules/@codemirror/autocomplete": {
"version": "6.4.2",
"resolved": "https://registry.npmmirror.com/@codemirror/autocomplete/-/autocomplete-6.4.2.tgz",
"integrity": "sha512-8WE2xp+D0MpWEv5lZ6zPW1/tf4AGb358T5GWYiKEuCP8MvFfT3tH2mIF9Y2yr2e3KbHuSvsVhosiEyqCpiJhZQ==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.6.0",
"@lezer/common": "^1.0.0"
},
"peerDependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0"
}
},
"node_modules/@codemirror/commands": {
"version": "6.2.2",
"resolved": "https://registry.npmmirror.com/@codemirror/commands/-/commands-6.2.2.tgz",
"integrity": "sha512-s9lPVW7TxXrI/7voZ+HmD/yiAlwAYn9PH5SUVSUhsxXHhv4yl5eZ3KLntSoTynfdgVYM0oIpccQEWRBQgmNZyw==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0"
}
},
"node_modules/@codemirror/lang-cpp": {
"version": "6.0.2",
"resolved": "https://registry.npmmirror.com/@codemirror/lang-cpp/-/lang-cpp-6.0.2.tgz",
"integrity": "sha512-6oYEYUKHvrnacXxWxYa6t4puTlbN3dgV662BDfSH8+MfjQjVmP697/KYTDOqpxgerkvoNm7q5wlFMBeX8ZMocg==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/cpp": "^1.0.0"
}
},
"node_modules/@codemirror/lang-java": {
"version": "6.0.1",
"resolved": "https://registry.npmmirror.com/@codemirror/lang-java/-/lang-java-6.0.1.tgz",
"integrity": "sha512-OOnmhH67h97jHzCuFaIEspbmsT98fNdhVhmA3zCxW0cn7l8rChDhZtwiwJ/JOKXgfm4J+ELxQihxaI7bj7mJRg==",
"dependencies": {
"@codemirror/language": "^6.0.0",
"@lezer/java": "^1.0.0"
}
},
"node_modules/@codemirror/lang-javascript": {
"version": "6.1.5",
"resolved": "https://registry.npmmirror.com/@codemirror/lang-javascript/-/lang-javascript-6.1.5.tgz",
"integrity": "sha512-BS2SmI1IXxWqMPhbJ0DC3eAHAK9V9XvdHMSqwvTBnmh5xFALt+cVDg7XE/A1dxdxzXYXyeqGddgqx1rQv7AYaw==",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/language": "^6.6.0",
"@codemirror/lint": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/javascript": "^1.0.0"
}
},
"node_modules/@codemirror/lang-python": {
"version": "6.1.2",
"resolved": "https://registry.npmmirror.com/@codemirror/lang-python/-/lang-python-6.1.2.tgz",
"integrity": "sha512-nbQfifLBZstpt6Oo4XxA2LOzlSp4b/7Bc5cmodG1R+Cs5PLLCTUvsMNWDnziiCfTOG/SW1rVzXq/GbIr6WXlcw==",
"dependencies": {
"@codemirror/autocomplete": "^6.3.2",
"@codemirror/language": "^6.0.0",
"@lezer/python": "^1.0.0"
}
},
"node_modules/@codemirror/language": {
"version": "6.6.0",
"resolved": "https://registry.npmmirror.com/@codemirror/language/-/language-6.6.0.tgz",
"integrity": "sha512-cwUd6lzt3MfNYOobdjf14ZkLbJcnv4WtndYaoBkbor/vF+rCNguMPK0IRtvZJG4dsWiaWPcK8x1VijhvSxnstg==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"@lezer/common": "^1.0.0",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0",
"style-mod": "^4.0.0"
}
},
"node_modules/@codemirror/lint": {
"version": "6.2.0",
"resolved": "https://registry.npmmirror.com/@codemirror/lint/-/lint-6.2.0.tgz",
"integrity": "sha512-KVCECmR2fFeYBr1ZXDVue7x3q5PMI0PzcIbA+zKufnkniMBo1325t0h1jM85AKp8l3tj67LRxVpZfgDxEXlQkg==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"
}
},
"node_modules/@codemirror/search": {
"version": "6.3.0",
"resolved": "https://registry.npmmirror.com/@codemirror/search/-/search-6.3.0.tgz",
"integrity": "sha512-rBhZxzT34CarfhgCZGhaLBScABDN3iqJxixzNuINp9lrb3lzm0nTpR77G1VrxGO3HOGK7j62jcJftQM7eCOIuw==",
"dependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0",
"crelt": "^1.0.5"
}
},
"node_modules/@codemirror/state": {
"version": "6.2.0",
"resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-6.2.0.tgz",
"integrity": "sha512-69QXtcrsc3RYtOtd+GsvczJ319udtBf1PTrr2KbLWM/e2CXUPnh0Nz9AUo8WfhSQ7GeL8dPVNUmhQVgpmuaNGA=="
},
"node_modules/@codemirror/view": {
"version": "6.9.3",
"resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-6.9.3.tgz",
"integrity": "sha512-BJ5mvEIhFM+SrNwc5X8pLIvMM9ffjkviVbxpg84Xk2OE8ZyKaEbId8kX+nAYEEso7+qnbwsXe1bkAHsasebMow==",
"dependencies": {
"@codemirror/state": "^6.1.4",
"style-mod": "^4.0.0",
"w3c-keyname": "^2.2.4"
}
},
"node_modules/@css-render/plugin-bem": {
"version": "0.15.12",
"resolved": "https://registry.npmmirror.com/@css-render/plugin-bem/-/plugin-bem-0.15.12.tgz",
@@ -2214,6 +2336,63 @@
"resolved": "https://registry.npmmirror.com/@kurkle/color/-/color-0.3.2.tgz",
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
},
"node_modules/@lezer/common": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/@lezer/common/-/common-1.0.2.tgz",
"integrity": "sha512-SVgiGtMnMnW3ActR8SXgsDhw7a0w0ChHSYAyAUxxrOiJ1OqYWEKk/xJd84tTSPo1mo6DXLObAJALNnd0Hrv7Ng=="
},
"node_modules/@lezer/cpp": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/@lezer/cpp/-/cpp-1.1.0.tgz",
"integrity": "sha512-zUHrjNFuY/DOZCkOBJ6qItQIkcopHM/Zv/QOE0a4XNG3HDNahxTNu5fQYl8dIuKCpxCqRdMl5cEwl5zekFc7BA==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/highlight": {
"version": "1.1.4",
"resolved": "https://registry.npmmirror.com/@lezer/highlight/-/highlight-1.1.4.tgz",
"integrity": "sha512-IECkFmw2l7sFcYXrV8iT9GeY4W0fU4CxX0WMwhmhMIVjoDdD1Hr6q3G2NqVtLg/yVe5n7i4menG3tJ2r4eCrPQ==",
"dependencies": {
"@lezer/common": "^1.0.0"
}
},
"node_modules/@lezer/java": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/@lezer/java/-/java-1.0.3.tgz",
"integrity": "sha512-kKN17wmgP1cgHb8juR4pwVSPMKkDMzY/lAPbBsZ1fpXwbk2sg3N1kIrf0q+LefxgrANaQb/eNO7+m2QPruTFng==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@lezer/javascript": {
"version": "1.4.2",
"resolved": "https://registry.npmmirror.com/@lezer/javascript/-/javascript-1.4.2.tgz",
"integrity": "sha512-77qdAD4zanmImPiAu4ibrMUzRc79UHoccdPa+Ey5iwS891TAkhnMAodUe17T7zV7tnF7e9HXM0pfmjoGEhrppg==",
"dependencies": {
"@lezer/highlight": "^1.1.3",
"@lezer/lr": "^1.3.0"
}
},
"node_modules/@lezer/lr": {
"version": "1.3.3",
"resolved": "https://registry.npmmirror.com/@lezer/lr/-/lr-1.3.3.tgz",
"integrity": "sha512-JPQe3mwJlzEVqy67iQiiGozhcngbO8QBgpqZM6oL1Wj/dXckrEexpBLeFkq0edtW5IqnPRFxA24BHJni8Js69w==",
"dependencies": {
"@lezer/common": "^1.0.0"
}
},
"node_modules/@lezer/python": {
"version": "1.1.4",
"resolved": "https://registry.npmmirror.com/@lezer/python/-/python-1.1.4.tgz",
"integrity": "sha512-x82XgYxqqX0Yiw7uIemQJ3z2QyQme5BYpectkPfNg99OQrakqfwqVolqEVIrsj4QO9rVDLFZZ49J0Vbne7UbAA==",
"dependencies": {
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
}
},
"node_modules/@mdit-vue/plugin-component": {
"version": "0.11.2",
"resolved": "https://registry.npmmirror.com/@mdit-vue/plugin-component/-/plugin-component-0.11.2.tgz",
@@ -2242,17 +2421,6 @@
"integrity": "sha512-ygCGP7vFpqS02hpZwEe1uz8cfImWX06+zRs08J+tCZRKb6k+easIaIHFtY9ZSxt7j9L/gAPLDo/5RmOT6z0DPQ==",
"dev": true
},
"node_modules/@monaco-editor/loader": {
"version": "1.3.3",
"resolved": "https://registry.npmmirror.com/@monaco-editor/loader/-/loader-1.3.3.tgz",
"integrity": "sha512-6KKF4CTzcJiS8BJwtxtfyYt9shBiEv32ateQ9T4UVogwn4HM/uPo9iJd2Dmbkpz8CM6Y0PDUpjnZzCwC+eYo2Q==",
"dependencies": {
"state-local": "^1.0.6"
},
"peerDependencies": {
"monaco-editor": ">= 0.21.0 < 1"
}
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@@ -2753,28 +2921,6 @@
"vue-demi": "*"
}
},
"node_modules/@vueuse/core/node_modules/vue-demi": {
"version": "0.13.11",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.13.11.tgz",
"integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==",
"hasInstallScript": true,
"bin": {
"vue-demi-fix": "bin/vue-demi-fix.js",
"vue-demi-switch": "bin/vue-demi-switch.js"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue": "^3.0.0-0 || ^2.6.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
},
"node_modules/@vueuse/metadata": {
"version": "9.13.0",
"resolved": "https://registry.npmmirror.com/@vueuse/metadata/-/metadata-9.13.0.tgz",
@@ -2788,28 +2934,6 @@
"vue-demi": "*"
}
},
"node_modules/@vueuse/shared/node_modules/vue-demi": {
"version": "0.13.11",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.13.11.tgz",
"integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==",
"hasInstallScript": true,
"bin": {
"vue-demi-fix": "bin/vue-demi-fix.js",
"vue-demi-switch": "bin/vue-demi-switch.js"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue": "^3.0.0-0 || ^2.6.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
},
"node_modules/@wangeditor/basic-modules": {
"version": "1.1.7",
"resolved": "https://registry.npmmirror.com/@wangeditor/basic-modules/-/basic-modules-1.1.7.tgz",
@@ -3244,6 +3368,20 @@
"node": ">=10"
}
},
"node_modules/codemirror": {
"version": "6.0.1",
"resolved": "https://registry.npmmirror.com/codemirror/-/codemirror-6.0.1.tgz",
"integrity": "sha512-J8j+nZ+CdWmIeFIGXEFbFPtpiYacFMDR8GlHK3IyHQJMCaVRfGx9NT+Hxivv1ckLWPvNdZqndbr/7lVhrf/Svg==",
"dependencies": {
"@codemirror/autocomplete": "^6.0.0",
"@codemirror/commands": "^6.0.0",
"@codemirror/language": "^6.0.0",
"@codemirror/lint": "^6.0.0",
"@codemirror/search": "^6.0.0",
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
}
},
"node_modules/color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-1.9.3.tgz",
@@ -3343,6 +3481,11 @@
"optional": true,
"peer": true
},
"node_modules/crelt": {
"version": "1.0.5",
"resolved": "https://registry.npmmirror.com/crelt/-/crelt-1.0.5.tgz",
"integrity": "sha512-+BO9wPPi+DWTDcNYhr/W90myha8ptzftZT+LwcmUbbok0rcP/fequmFYCw8NMoH7pkAZQzU78b3kYrlua5a9eA=="
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz",
@@ -4603,11 +4746,6 @@
"ufo": "^1.1.1"
}
},
"node_modules/monaco-editor": {
"version": "0.30.1",
"resolved": "https://registry.npmmirror.com/monaco-editor/-/monaco-editor-0.30.1.tgz",
"integrity": "sha512-B/y4+b2O5G2gjuxIFtCE2EkM17R2NM7/3F8x0qcPsqy4V83bitJTIO4TIeZpYlzu/xy6INiY/+84BEm6+7Cmzg=="
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",
@@ -4852,28 +4990,6 @@
}
}
},
"node_modules/pinia/node_modules/vue-demi": {
"version": "0.13.11",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.13.11.tgz",
"integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==",
"hasInstallScript": true,
"bin": {
"vue-demi-fix": "bin/vue-demi-fix.js",
"vue-demi-switch": "bin/vue-demi-switch.js"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue": "^3.0.0-0 || ^2.6.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
},
"node_modules/pkg-types": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/pkg-types/-/pkg-types-1.0.2.tgz",
@@ -5301,11 +5417,6 @@
"resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-3.0.0.tgz",
"integrity": "sha512-q+8UfWDg9Itrg0yWK7oe5p/XRCJpJF9OBtXfOPgSJl+u3Xd5KI328RUEvUqSMVM9CiQUEf1QdBzJMkYGErj9QA=="
},
"node_modules/state-local": {
"version": "1.0.7",
"resolved": "https://registry.npmmirror.com/state-local/-/state-local-1.0.7.tgz",
"integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w=="
},
"node_modules/std-env": {
"version": "3.3.2",
"resolved": "https://registry.npmmirror.com/std-env/-/std-env-3.3.2.tgz",
@@ -5352,6 +5463,11 @@
"acorn": "^8.8.2"
}
},
"node_modules/style-mod": {
"version": "4.0.2",
"resolved": "https://registry.npmmirror.com/style-mod/-/style-mod-4.0.2.tgz",
"integrity": "sha512-C4myMmRTO8iaC5Gg+N1ftK2WT4eXUTMAa+HEFPPrfVeO/NtqLTtAmV1HbqnuGtLwCek44Ra76fdGUkSqjiMPcQ=="
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-5.5.0.tgz",
@@ -5917,6 +6033,43 @@
"vue": "^3.0.0-0 || ^2.7.0"
}
},
"node_modules/vue-codemirror": {
"version": "6.1.1",
"resolved": "https://registry.npmmirror.com/vue-codemirror/-/vue-codemirror-6.1.1.tgz",
"integrity": "sha512-rTAYo44owd282yVxKtJtnOi7ERAcXTeviwoPXjIc6K/IQYUsoDkzPvw/JDFtSP6T7Cz/2g3EHaEyeyaQCKoDMg==",
"dependencies": {
"@codemirror/commands": "6.x",
"@codemirror/language": "6.x",
"@codemirror/state": "6.x",
"@codemirror/view": "6.x"
},
"peerDependencies": {
"codemirror": "6.x",
"vue": "3.x"
}
},
"node_modules/vue-demi": {
"version": "0.13.11",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.13.11.tgz",
"integrity": "sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==",
"hasInstallScript": true,
"bin": {
"vue-demi-fix": "bin/vue-demi-fix.js",
"vue-demi-switch": "bin/vue-demi-switch.js"
},
"engines": {
"node": ">=12"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue": "^3.0.0-0 || ^2.6.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
},
"node_modules/vue-router": {
"version": "4.1.6",
"resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.1.6.tgz",
@@ -5971,6 +6124,11 @@
"vue": "^3.0.11"
}
},
"node_modules/w3c-keyname": {
"version": "2.2.6",
"resolved": "https://registry.npmmirror.com/w3c-keyname/-/w3c-keyname-2.2.6.tgz",
"integrity": "sha512-f+fciywl1SJEniZHD6H+kUO8gOnwIr7f4ijKA6+ZvJFjeGi1r4PDLl53Ayud9O/rk64RqgoQine0feoeOU0kXg=="
},
"node_modules/webpack-sources": {
"version": "3.2.3",
"resolved": "https://registry.npmmirror.com/webpack-sources/-/webpack-sources-3.2.3.tgz",

View File

@@ -10,13 +10,17 @@
"fmt": "prettier --write src *.ts"
},
"dependencies": {
"@codemirror/lang-cpp": "^6.0.2",
"@codemirror/lang-java": "^6.0.1",
"@codemirror/lang-javascript": "^6.1.5",
"@codemirror/lang-python": "^6.1.2",
"@element-plus/icons-vue": "^2.1.0",
"@monaco-editor/loader": "^1.3.3",
"@vueuse/core": "^9.13.0",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12",
"axios": "1.3.4",
"chart.js": "^4.2.1",
"codemirror": "^6.0.1",
"copy-text-to-clipboard": "^3.1.0",
"date-fns": "^2.29.3",
"highlight.js": "^11.7.0",
@@ -26,6 +30,7 @@
"pinia": "^2.0.33",
"vue": "^3.2.47",
"vue-chartjs": "^5.2.0",
"vue-codemirror": "^6.1.1",
"vue-router": "^4.1.6"
},
"devDependencies": {
@@ -34,7 +39,6 @@
"@vitejs/plugin-legacy": "^4.0.2",
"@vitejs/plugin-vue": "^4.1.0",
"markdown-it-shiki": "^0.8.0",
"monaco-editor": "0.30.1",
"prettier": "^2.8.7",
"terser": "^5.16.8",
"typescript": "^5.0.3",

File diff suppressed because it is too large Load Diff

View File

@@ -1,208 +0,0 @@
{
"base": "vs-dark",
"inherit": true,
"rules": [
{
"background": "282a36",
"token": ""
},
{
"foreground": "6272a4",
"token": "comment"
},
{
"foreground": "f1fa8c",
"token": "string"
},
{
"foreground": "bd93f9",
"token": "constant.numeric"
},
{
"foreground": "bd93f9",
"token": "constant.language"
},
{
"foreground": "bd93f9",
"token": "constant.character"
},
{
"foreground": "bd93f9",
"token": "constant.other"
},
{
"foreground": "ffb86c",
"token": "variable.other.readwrite.instance"
},
{
"foreground": "ff79c6",
"token": "constant.character.escaped"
},
{
"foreground": "ff79c6",
"token": "constant.character.escape"
},
{
"foreground": "ff79c6",
"token": "string source"
},
{
"foreground": "ff79c6",
"token": "string source.ruby"
},
{
"foreground": "ff79c6",
"token": "keyword"
},
{
"foreground": "ff79c6",
"token": "storage"
},
{
"foreground": "8be9fd",
"fontStyle": "italic",
"token": "storage.type"
},
{
"foreground": "50fa7b",
"fontStyle": "underline",
"token": "entity.name.class"
},
{
"foreground": "50fa7b",
"fontStyle": "italic underline",
"token": "entity.other.inherited-class"
},
{
"foreground": "50fa7b",
"token": "entity.name.function"
},
{
"foreground": "ffb86c",
"fontStyle": "italic",
"token": "variable.parameter"
},
{
"foreground": "ff79c6",
"token": "entity.name.tag"
},
{
"foreground": "50fa7b",
"token": "entity.other.attribute-name"
},
{
"foreground": "8be9fd",
"token": "support.function"
},
{
"foreground": "6be5fd",
"token": "support.constant"
},
{
"foreground": "66d9ef",
"fontStyle": " italic",
"token": "support.type"
},
{
"foreground": "66d9ef",
"fontStyle": " italic",
"token": "support.class"
},
{
"foreground": "f8f8f0",
"background": "ff79c6",
"token": "invalid"
},
{
"foreground": "f8f8f0",
"background": "bd93f9",
"token": "invalid.deprecated"
},
{
"foreground": "cfcfc2",
"token": "meta.structure.dictionary.json string.quoted.double.json"
},
{
"foreground": "6272a4",
"token": "meta.diff"
},
{
"foreground": "6272a4",
"token": "meta.diff.header"
},
{
"foreground": "ff79c6",
"token": "markup.deleted"
},
{
"foreground": "50fa7b",
"token": "markup.inserted"
},
{
"foreground": "e6db74",
"token": "markup.changed"
},
{
"foreground": "bd93f9",
"token": "constant.numeric.line-number.find-in-files - match"
},
{
"foreground": "e6db74",
"token": "entity.name.filename"
},
{
"foreground": "f83333",
"token": "message.error"
},
{
"foreground": "eeeeee",
"token": "punctuation.definition.string.begin.json - meta.structure.dictionary.value.json"
},
{
"foreground": "eeeeee",
"token": "punctuation.definition.string.end.json - meta.structure.dictionary.value.json"
},
{
"foreground": "8be9fd",
"token": "meta.structure.dictionary.json string.quoted.double.json"
},
{
"foreground": "f1fa8c",
"token": "meta.structure.dictionary.value.json string.quoted.double.json"
},
{
"foreground": "50fa7b",
"token": "meta meta meta meta meta meta meta.structure.dictionary.value string"
},
{
"foreground": "ffb86c",
"token": "meta meta meta meta meta meta.structure.dictionary.value string"
},
{
"foreground": "ff79c6",
"token": "meta meta meta meta meta.structure.dictionary.value string"
},
{
"foreground": "bd93f9",
"token": "meta meta meta meta.structure.dictionary.value string"
},
{
"foreground": "50fa7b",
"token": "meta meta meta.structure.dictionary.value string"
},
{
"foreground": "ffb86c",
"token": "meta meta.structure.dictionary.value string"
}
],
"colors": {
"editor.foreground": "#f8f8f2",
"editor.background": "#282a36",
"editor.selectionBackground": "#44475a",
"editor.lineHighlightBackground": "#44475a",
"editorCursor.foreground": "#f8f8f0",
"editorWhitespace.foreground": "#3B3A32",
"editorIndentGuide.activeBackground": "#9D550FB0",
"editor.selectionHighlightBorder": "#222218"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ import {
uploadTestcases,
} from "../api"
const Monaco = defineAsyncComponent(() => import("~/shared/Monaco.vue"))
const CodeEditor = defineAsyncComponent(() => import("~/shared/CodeEditor.vue"))
interface Props {
problemID?: string
@@ -429,7 +429,7 @@ watch([fromExistingTags, newTags], (tags) => {
:key="index"
:name="lang"
>
<Monaco
<CodeEditor
v-model:value="template[lang]"
:language="lang"
:font-size="16"

View File

@@ -2,7 +2,7 @@
import { isDesktop } from "~/shared/composables/breakpoints"
import { code } from "~/shared/composables/learn"
const Monaco = defineAsyncComponent(() => import("~/shared/Monaco.vue"))
const CodeEditor = defineAsyncComponent(() => import("~/shared/CodeEditor.vue"))
const route = useRoute()
const router = useRouter()
@@ -57,7 +57,7 @@ function next() {
</n-scrollbar>
</n-gi>
<n-gi :span="14">
<Monaco v-model:value="code" />
<CodeEditor v-model:value="code" />
</n-gi>
</n-grid>
<div v-else>
@@ -72,7 +72,7 @@ function next() {
</n-button>
</n-space>
</n-scrollbar>
<Monaco v-model:value="code" height="calc(50vh - 42px)" />
<CodeEditor v-model:value="code" height="calc(50vh - 42px)" />
</div>
</template>

View File

@@ -5,7 +5,7 @@ import { code } from "oj/composables/code"
import { isDesktop } from "~/shared/composables/breakpoints"
import Form from "./Form.vue"
const Monaco = defineAsyncComponent(() => import("~/shared/Monaco.vue"))
const CodeEditor = defineAsyncComponent(() => import("~/shared/CodeEditor.vue"))
interface Props {
problem: Problem
@@ -23,16 +23,11 @@ const editorHeight = computed(() =>
<template>
<Form :problem="props.problem" />
<Monaco
class="editor"
<CodeEditor
v-model:value="code.value"
:language="code.language"
:height="editorHeight"
/>
</template>
<style scoped>
.editor {
min-height: 200px;
}
</style>
<style scoped></style>

View File

@@ -2,7 +2,7 @@
import { code } from "oj/composables/code"
import party from "party-js"
import { Ref } from "vue"
import { SOURCES, JUDGE_STATUS, SubmissionStatus } from "utils/constants"
import { JUDGE_STATUS, SubmissionStatus } from "utils/constants"
import { submissionMemoryFormat, submissionTimeFormat } from "utils/functions"
import { Problem, Submission, SubmitCodePayload } from "utils/types"
import { getSubmission, submitCode } from "oj/api"
@@ -65,12 +65,7 @@ const submitDisabled = computed(() => {
if (!userStore.isAuthed) {
return true
}
const value = code.value
if (
value.trim() === "" ||
value === problem!.value.template[code.language] ||
value === SOURCES[code.language]
) {
if (code.value.trim() === "") {
return true
}
if (judging.value || pending.value || submitting.value) {

55
src/shared/CodeEditor.vue Normal file
View File

@@ -0,0 +1,55 @@
<script lang="ts" setup>
import { Codemirror } from "vue-codemirror"
import { cpp } from "@codemirror/lang-cpp"
import { python } from "@codemirror/lang-python"
import { java } from "@codemirror/lang-java"
import { javascript } from "@codemirror/lang-javascript"
import { LANGUAGE } from "~/utils/types"
import { EditorView } from "@codemirror/view"
const styleTheme = EditorView.baseTheme({
"&.cm-editor.cm-focused": {
outline: "none",
},
})
interface Props {
value: string
language?: LANGUAGE
fontSize?: number
height?: string
}
const props = withDefaults(defineProps<Props>(), {
language: "C",
fontSize: 20,
height: "100%",
})
const code = ref(props.value)
const emit = defineEmits(["update:value"])
const lang = computed(() => {
if (props.language === "C" || props.language === "C++") return cpp()
if (props.language === "Java") return java()
if (props.language === "JavaScript") return javascript()
return python()
})
function onChange(v: string) {
emit("update:value", v)
}
</script>
<template>
<Codemirror
v-model="code"
:extensions="[styleTheme, lang]"
indentWithTab
:tabSize="4"
@change="onChange"
:style="{
height: props.height,
fontSize: props.fontSize + 'px',
}"
/>
</template>

View File

@@ -35,7 +35,6 @@ onMounted(() => {
const menus = computed<MenuOption[]>(() => [
{
show: false,
label: () =>
h(RouterLink, { to: "/learn/step-1" }, { default: () => "自学" }),
key: "learn",

View File

@@ -1,107 +0,0 @@
<script setup lang="ts">
import type * as Monaco from "monaco-editor"
import { LANGUAGE_FORMAT_VALUE } from "utils/constants"
import { LANGUAGE } from "utils/types"
import { isMobile } from "~/shared/composables/breakpoints"
import { isDark } from "./composables/dark"
import { init, monaco } from "./composables/monaco"
interface Props {
value: string
language?: LANGUAGE
height?: string
fontSize?: number
class?: string
}
const props = withDefaults(defineProps<Props>(), {
language: "C",
height: "calc(100vh - 92px)",
fontSize: 20,
class: "",
})
const emit = defineEmits<{
(e: "update:value", value: string): void
}>()
const monacoEditorRef = ref()
let editor: Monaco.editor.IStandaloneCodeEditor
let model: Monaco.editor.ITextModel
onMounted(async () => {
if (!monaco.value) await init()
model = monaco.value!.editor.createModel(
props.value,
LANGUAGE_FORMAT_VALUE[props.language]
)
editor = monaco.value!.editor.create(monacoEditorRef.value, {
model,
theme: isDark.value ? "dark" : "light", // 官方自带三种主题vs, hc-black, or vs-dark
minimap: {
enabled: false,
},
lineNumbersMinChars: 2,
automaticLayout: true, // 自适应布局
tabSize: 4,
fontSize: props.fontSize || (isMobile.value ? 20 : 22), // 字体大小
scrollBeyondLastLine: false,
lineDecorationsWidth: 0,
scrollBeyondLastColumn: 0,
glyphMargin: false,
scrollbar: {
useShadows: false,
vertical: "hidden",
horizontal: "hidden",
},
overviewRulerLanes: 0,
})
model.onDidChangeContent(() => {
const value = model.getValue().toString()
emit("update:value", value)
})
editor.onKeyDown((e) => {
if ((e.ctrlKey || e.metaKey) && e.code === "KeyS") {
e.preventDefault()
}
if ((e.ctrlKey || e.metaKey) && e.code === "KeyR") {
e.preventDefault()
}
})
watchEffect(() => {
if (!monaco.value) return
monaco.value.editor.setModelLanguage(
model,
LANGUAGE_FORMAT_VALUE[props.language]
)
})
watchEffect(() => {
if (props.value !== model.getValue()) {
model.setValue(props.value)
}
})
watchEffect(() => {
if (!monaco.value) return
monaco.value.editor.setTheme(isDark.value ? "dark" : "light")
})
})
onUnmounted(() => {
editor && editor.dispose()
})
</script>
<template>
<div
v-if="monaco"
ref="monacoEditorRef"
:class="props.class"
:style="{ height: props.height }"
></div>
<div v-else :style="{ height: props.height }"></div>
</template>
<style scoped></style>

View File

@@ -1,25 +0,0 @@
import loader, { Monaco } from "@monaco-editor/loader"
import * as monaco0301 from "monaco-editor"
import { isLowVersion } from "~/utils/functions"
export const monaco = ref<Monaco>()
export async function init() {
if (isLowVersion) {
loader.config({ monaco: monaco0301 })
} else {
loader.config({
paths: { vs: "https://cdn.staticfile.org/monaco-editor/0.36.1/min/vs" },
"vs/nls": { availableLanguages: { "*": "zh-cn" } },
})
}
const [m, light, dark] = await Promise.all([
loader.init(),
fetch("/light.json").then((t) => t.json()),
fetch("/dark.json").then((t) => t.json()),
])
monaco.value = m
monaco.value.editor.defineTheme("light", light)
monaco.value.editor.defineTheme("dark", dark)
}

View File

@@ -25,7 +25,23 @@ export default defineConfig({
fancy: ["highlight.js", "party-js"],
chart: ["vue-chartjs", "chart.js"],
editor: ["@wangeditor/editor"],
monaco: ["monaco-editor"],
codemirror: [
"vue-codemirror6",
"codemirror",
"@codemirror/autocomplete",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
],
"codemirror-lang": [
"@codemirror/lang-cpp",
"@codemirror/lang-javascript",
"@codemirror/lang-java",
"@codemirror/lang-python",
],
},
},
},