dnhyxc-ui-vue 1.0.0

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.
Files changed (75) hide show
  1. package/.prettierrc.json +22 -0
  2. package/docs/.vitepress/config.mts +55 -0
  3. package/docs/.vitepress/theme/index.ts +30 -0
  4. package/docs/.vitepress/theme/style.css +130 -0
  5. package/docs/api-examples.md +49 -0
  6. package/docs/auto-imports.d.ts +10 -0
  7. package/docs/components/icon.md +75 -0
  8. package/docs/components.d.ts +13 -0
  9. package/docs/guide/installation.md +1 -0
  10. package/docs/guide/quick-start.md +1 -0
  11. package/docs/index.md +24 -0
  12. package/docs/markdown-examples.md +85 -0
  13. package/docs/package.json +30 -0
  14. package/docs/vite.config.ts +20 -0
  15. package/eslint.config.mjs +90 -0
  16. package/package.json +78 -0
  17. package/packages/components/button/index.ts +13 -0
  18. package/packages/components/button/src/button.ts +20 -0
  19. package/packages/components/button/src/button.vue +39 -0
  20. package/packages/components/button/src/index.scss +3 -0
  21. package/packages/components/icon/index.ts +14 -0
  22. package/packages/components/icon/src/icon.ts +16 -0
  23. package/packages/components/icon/src/icon.vue +35 -0
  24. package/packages/components/icon2/index.ts +14 -0
  25. package/packages/components/icon2/src/icon2.ts +16 -0
  26. package/packages/components/icon2/src/icon2.vue +35 -0
  27. package/packages/components/index.ts +5 -0
  28. package/packages/components/input/index.ts +13 -0
  29. package/packages/components/input/src/index.scss +3 -0
  30. package/packages/components/input/src/input.ts +22 -0
  31. package/packages/components/input/src/input.vue +50 -0
  32. package/packages/components/monaco/index.ts +8 -0
  33. package/packages/components/monaco/src/custom.ts +124 -0
  34. package/packages/components/monaco/src/index.scss +235 -0
  35. package/packages/components/monaco/src/monaco.ts +46 -0
  36. package/packages/components/monaco/src/monaco.vue +472 -0
  37. package/packages/components/package.json +29 -0
  38. package/packages/components/tsconfig.json +34 -0
  39. package/packages/components/tsconfig.tsbuildinfo +1 -0
  40. package/packages/script/build/build.ts +90 -0
  41. package/packages/script/build/buildfull.ts +77 -0
  42. package/packages/script/build/external.ts +21 -0
  43. package/packages/script/build/index.ts +22 -0
  44. package/packages/script/utils/delPath.ts +30 -0
  45. package/packages/script/utils/paths.ts +7 -0
  46. package/packages/theme/gulpfile.js +41 -0
  47. package/packages/theme/package.json +16 -0
  48. package/packages/theme/src/icon.scss +8 -0
  49. package/packages/theme/src/icon2.scss +8 -0
  50. package/packages/theme/src/index.scss +2 -0
  51. package/packages/theme/src/mixins/config.scss +4 -0
  52. package/packages/theme/src/mixins/mixins.scss +80 -0
  53. package/packages/utils/bem.ts +60 -0
  54. package/packages/utils/index.ts +2 -0
  55. package/packages/utils/package.json +16 -0
  56. package/packages/utils/vite.config.ts +61 -0
  57. package/packages/utils/with-install.ts +12 -0
  58. package/play/.vscode/extensions.json +3 -0
  59. package/play/README.md +5 -0
  60. package/play/auto-imports.d.ts +10 -0
  61. package/play/components.d.ts +14 -0
  62. package/play/index.html +13 -0
  63. package/play/package.json +30 -0
  64. package/play/public/vite.svg +1 -0
  65. package/play/src/App.vue +32 -0
  66. package/play/src/assets/vue.svg +1 -0
  67. package/play/src/components/MyInput.vue +25 -0
  68. package/play/src/main.ts +12 -0
  69. package/play/src/vite-env.d.ts +7 -0
  70. package/play/tsconfig.app.json +14 -0
  71. package/play/tsconfig.json +7 -0
  72. package/play/tsconfig.node.json +24 -0
  73. package/play/vite.config.ts +20 -0
  74. package/pnpm-workspace.yaml +5 -0
  75. package/tsconfig.json +35 -0
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "dnhyxc-ui-vue",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "type": "module",
6
+ "keywords": [],
7
+ "author": "",
8
+ "license": "ISC",
9
+ "description": "",
10
+ "devDependencies": {
11
+ "@babel/eslint-parser": "^7.27.5",
12
+ "@babel/preset-env": "^7.27.2",
13
+ "@eslint/js": "^9.30.1",
14
+ "@types/glob": "^9.0.0",
15
+ "@types/gulp": "^4.0.17",
16
+ "@types/gulp-autoprefixer": "^0.0.37",
17
+ "@types/gulp-clean-css": "^4.3.4",
18
+ "@types/gulp-sass": "^5.0.4",
19
+ "@types/node": "^24.0.10",
20
+ "@typescript-eslint/eslint-plugin": "^8.35.1",
21
+ "@typescript-eslint/parser": "^8.35.1",
22
+ "@vitejs/plugin-vue": "^5.2.1",
23
+ "eslint": "^9.30.1",
24
+ "eslint-config-prettier": "^10.1.5",
25
+ "eslint-plugin-prettier": "^5.5.1",
26
+ "eslint-plugin-vue": "^9.25.0",
27
+ "glob": "^11.0.3",
28
+ "globals": "^16.3.0",
29
+ "gulp": "^5.0.1",
30
+ "gulp-autoprefixer": "^9.0.0",
31
+ "gulp-clean-css": "^4.3.0",
32
+ "gulp-sass": "^6.0.1",
33
+ "husky": "^8.0.3",
34
+ "prettier": "^3.6.2",
35
+ "rimraf": "^6.0.1",
36
+ "sass": "^1.89.2",
37
+ "sucrase": "^3.35.0",
38
+ "typescript": "^5.3.3",
39
+ "typescript-eslint": "^8.35.1",
40
+ "unplugin-auto-import": "^19.3.0",
41
+ "unplugin-vue-components": "^28.8.0",
42
+ "vite": "^7.0.0",
43
+ "vite-plugin-dts": "^4.5.4",
44
+ "vue-eslint-parser": "^10.2.0"
45
+ },
46
+ "dependencies": {
47
+ "element-plus": "^2.10.3",
48
+ "vue": "^3.5.17",
49
+ "@dnhyxc-ui/utils": "^1.0.0"
50
+ },
51
+ "lint-staged": {
52
+ "*.{js,ts,tsx,jsx,vue}": [
53
+ "eslint --fix",
54
+ "prettier --write",
55
+ "git add"
56
+ ],
57
+ "{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [
58
+ "prettier --write--parser json"
59
+ ],
60
+ "package.json": [
61
+ "prettier --write"
62
+ ],
63
+ "*.md": [
64
+ "prettier --write"
65
+ ]
66
+ },
67
+ "scripts": {
68
+ "dev:play": "pnpm -C play dev",
69
+ "build:scss": "gulp -f packages/script/build/index.ts",
70
+ "build": "pnpm -C packages/components build && pnpm build:scss",
71
+ "build:full": "pnpm -C packages/components build:full",
72
+ "build:ui": "pnpm -C packages/components build",
73
+ "dev:docs": "pnpm -C docs dev",
74
+ "build:docs": "pnpm -C docs build",
75
+ "preview:docs": "pnpm -C docs preview",
76
+ "test": "npx eslint ./packages --ext ts,vue,js --fix"
77
+ }
78
+ }
@@ -0,0 +1,13 @@
1
+ import { withInstall, type SFCWithInstall } from '@dnhyxc-ui/utils';
2
+ import Button from './src/button.vue';
3
+
4
+ export const NButton: SFCWithInstall<typeof Button> = withInstall(Button);
5
+
6
+ export default NButton;
7
+
8
+ // declare module 'vue' {
9
+ // export interface GlobalComponents {
10
+ // NIcon: typeof Icon;
11
+ // }
12
+ // }
13
+ export * from './src/button';
@@ -0,0 +1,20 @@
1
+ import { type ExtractPropTypes, type PropType } from 'vue';
2
+ import type Button from './button.vue';
3
+ export const buttonProps = {
4
+ size: String as PropType<'large' | 'default' | 'small'>,
5
+ color: String,
6
+ disabled: Boolean,
7
+ loading: Boolean,
8
+ link: Boolean,
9
+ type: String as PropType<'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' | 'never'>
10
+ } as const;
11
+
12
+ export type ButtonProps = ExtractPropTypes<typeof buttonProps>;
13
+
14
+ export type ButtonInstance = InstanceType<typeof Button> & unknown;
15
+
16
+ declare module 'vue' {
17
+ export interface GlobalComponents {
18
+ NButton: typeof Button;
19
+ }
20
+ }
@@ -0,0 +1,39 @@
1
+ <!--
2
+ * Icon - 图标组件
3
+ * @author: dnhyxc
4
+ * @since: 2025-07-02
5
+ * index.vue
6
+ -->
7
+ <template>
8
+ <div :class="bem.b()" v-bind="$attrs">
9
+ <el-button type="primary" :link="link" :size="size" :disabled="disabled" :loading="loading" :style="styles">
10
+ <slot></slot>
11
+ </el-button>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { computed } from 'vue';
17
+ import { ElButton } from 'element-plus';
18
+ import type { CSSProperties } from 'vue';
19
+ import { createNamespace } from '@dnhyxc-ui/utils';
20
+ import { buttonProps } from './button';
21
+ import './index.scss';
22
+
23
+ defineOptions({
24
+ name: 'NIcon',
25
+ inheritAttrs: false // 禁用继承父组件的属性
26
+ });
27
+
28
+ const bem = createNamespace('button');
29
+
30
+ const props = defineProps(buttonProps);
31
+
32
+ const styles = computed<CSSProperties>(() => {
33
+ if (!props.size && !props.color) return {};
34
+ return {
35
+ ...(props.size ? { 'font-size': props.size + 'px' } : {}),
36
+ ...(props.color ? { color: props.color } : {})
37
+ };
38
+ });
39
+ </script>
@@ -0,0 +1,3 @@
1
+ .n-button {
2
+ border: 1px solid red;
3
+ }
@@ -0,0 +1,14 @@
1
+ import { withInstall, type SFCWithInstall } from '@dnhyxc-ui/utils';
2
+ import Icon from './src/icon.vue';
3
+
4
+ // const NIcon = withInstall(Icon);
5
+ export const NIcon: SFCWithInstall<typeof Icon> = withInstall(Icon);
6
+
7
+ export default NIcon;
8
+
9
+ // declare module 'vue' {
10
+ // export interface GlobalComponents {
11
+ // NIcon: typeof Icon;
12
+ // }
13
+ // }
14
+ export * from './src/icon';
@@ -0,0 +1,16 @@
1
+ import { type ExtractPropTypes, type PropType } from 'vue';
2
+ import type Icon from './icon.vue';
3
+ export const iconProps = {
4
+ size: Number as PropType<number | string>,
5
+ color: String
6
+ } as const;
7
+
8
+ export type IconProps = ExtractPropTypes<typeof iconProps>;
9
+
10
+ export type IconInstance = InstanceType<typeof Icon> & unknown;
11
+
12
+ declare module 'vue' {
13
+ export interface GlobalComponents {
14
+ NIcon: typeof Icon;
15
+ }
16
+ }
@@ -0,0 +1,35 @@
1
+ <!--
2
+ * Icon - 图标组件
3
+ * @author: dnhyxc
4
+ * @since: 2025-07-02
5
+ * index.vue
6
+ -->
7
+ <template>
8
+ <i :class="bem.b()" :style="styles" v-bind="$attrs">
9
+ <slot></slot>
10
+ </i>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { computed } from 'vue';
15
+ import type { CSSProperties } from 'vue';
16
+ import { createNamespace } from '@dnhyxc-ui/utils';
17
+ import { iconProps } from './icon';
18
+
19
+ defineOptions({
20
+ name: 'NIcon',
21
+ inheritAttrs: false // 禁用继承父组件的属性
22
+ });
23
+
24
+ const bem = createNamespace('icon');
25
+
26
+ const props = defineProps(iconProps);
27
+
28
+ const styles = computed<CSSProperties>(() => {
29
+ if (!props.size && !props.color) return {};
30
+ return {
31
+ ...(props.size ? { 'font-size': props.size + 'px' } : {}),
32
+ ...(props.color ? { color: props.color } : {})
33
+ };
34
+ });
35
+ </script>
@@ -0,0 +1,14 @@
1
+ import { withInstall, type SFCWithInstall } from '@dnhyxc-ui/utils';
2
+ import Icon from './src/icon2.vue';
3
+
4
+ // const NIcon = withInstall(Icon);
5
+ export const NIcon2: SFCWithInstall<typeof Icon> = withInstall(Icon);
6
+
7
+ export default NIcon2;
8
+
9
+ // declare module 'vue' {
10
+ // export interface GlobalComponents {
11
+ // NIcon: typeof Icon;
12
+ // }
13
+ // }
14
+ export * from './src/icon2';
@@ -0,0 +1,16 @@
1
+ import { type ExtractPropTypes, type PropType } from 'vue';
2
+ import type Icon from './icon2.vue';
3
+ export const iconProps2 = {
4
+ size: Number as PropType<number | string>,
5
+ color: String
6
+ } as const;
7
+
8
+ export type IconProps2 = ExtractPropTypes<typeof iconProps2>;
9
+
10
+ export type IconInstance2 = InstanceType<typeof Icon> & unknown;
11
+
12
+ declare module 'vue' {
13
+ export interface GlobalComponents {
14
+ NIcon2: typeof Icon;
15
+ }
16
+ }
@@ -0,0 +1,35 @@
1
+ <!--
2
+ * Icon - 图标组件
3
+ * @author: dnhyxc
4
+ * @since: 2025-07-02
5
+ * index.vue
6
+ -->
7
+ <template>
8
+ <i :class="bem.b()" :style="styles" v-bind="$attrs">
9
+ <slot></slot>
10
+ </i>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { computed } from 'vue';
15
+ import type { CSSProperties } from 'vue';
16
+ import { createNamespace } from '@dnhyxc-ui/utils';
17
+ import { iconProps2 } from './icon2';
18
+
19
+ defineOptions({
20
+ name: 'NIcon2',
21
+ inheritAttrs: false // 禁用继承父组件的属性
22
+ });
23
+
24
+ const bem = createNamespace('icon');
25
+
26
+ const props = defineProps(iconProps2);
27
+
28
+ const styles = computed<CSSProperties>(() => {
29
+ if (!props.size && !props.color) return {};
30
+ return {
31
+ ...(props.size ? { 'font-size': props.size + 'px' } : {}),
32
+ ...(props.color ? { color: props.color } : {})
33
+ };
34
+ });
35
+ </script>
@@ -0,0 +1,5 @@
1
+ export * from './icon';
2
+ export * from './icon2';
3
+ export * from './button';
4
+ export * from './input';
5
+ export * from './monaco';
@@ -0,0 +1,13 @@
1
+ import { withInstall, type SFCWithInstall } from '@dnhyxc-ui/utils';
2
+ import Input from './src/input.vue';
3
+
4
+ export const NInput: SFCWithInstall<typeof Input> = withInstall(Input);
5
+
6
+ export default NInput;
7
+
8
+ // declare module 'vue' {
9
+ // export interface GlobalComponents {
10
+ // NIcon: typeof Icon;
11
+ // }
12
+ // }
13
+ export * from './src/input';
@@ -0,0 +1,3 @@
1
+ .n-input {
2
+ border: 1px solid red;
3
+ }
@@ -0,0 +1,22 @@
1
+ import { type ExtractPropTypes, type PropType } from 'vue';
2
+ import type Input from './input.vue';
3
+ export const inputProps = {
4
+ size: String as PropType<'large' | 'default' | 'small'>,
5
+ color: String,
6
+ placeholder: String,
7
+ disabled: Boolean,
8
+ loading: Boolean,
9
+ link: Boolean,
10
+ value: String,
11
+ type: String as PropType<'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' | 'never'>
12
+ } as const;
13
+
14
+ export type InputProps = ExtractPropTypes<typeof inputProps>;
15
+
16
+ export type InputInstance = InstanceType<typeof Input> & unknown;
17
+
18
+ declare module 'vue' {
19
+ export interface GlobalComponents {
20
+ NInput: typeof Input;
21
+ }
22
+ }
@@ -0,0 +1,50 @@
1
+ <!--
2
+ * Icon - 图标组件
3
+ * @author: dnhyxc
4
+ * @since: 2025-07-02
5
+ * index.vue
6
+ -->
7
+ <template>
8
+ <div :class="bem.b()" v-bind="$attrs">
9
+ <el-input v-model="keyword" :size="size" :style="styles" :disabled="disabled" :placeholder="placeholder">
10
+ <slot></slot>
11
+ </el-input>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { computed } from 'vue';
17
+ import { ElInput } from 'element-plus';
18
+ import type { CSSProperties } from 'vue';
19
+ import { createNamespace } from '@dnhyxc-ui/utils';
20
+ import { inputProps } from './input';
21
+ import './index.scss';
22
+
23
+ defineOptions({
24
+ name: 'NInput',
25
+ inheritAttrs: false // 禁用继承父组件的属性
26
+ });
27
+
28
+ const bem = createNamespace('input');
29
+
30
+ const emit = defineEmits(['update:value']);
31
+
32
+ const props = defineProps(inputProps);
33
+
34
+ const keyword = computed({
35
+ get() {
36
+ return props.value;
37
+ },
38
+ set(val) {
39
+ emit('update:value', val);
40
+ }
41
+ });
42
+
43
+ const styles = computed<CSSProperties>(() => {
44
+ if (!props.size && !props.color) return {};
45
+ return {
46
+ ...(props.size ? { 'font-size': props.size + 'px' } : {}),
47
+ ...(props.color ? { color: props.color } : {})
48
+ };
49
+ });
50
+ </script>
@@ -0,0 +1,8 @@
1
+ import { withInstall, type SFCWithInstall } from '@dnhyxc-ui/utils';
2
+ import Monaco from './src/monaco.vue';
3
+
4
+ export const NMonaco: SFCWithInstall<typeof Monaco> = withInstall(Monaco);
5
+
6
+ export default NMonaco;
7
+
8
+ export * from './src/monaco';
@@ -0,0 +1,124 @@
1
+ import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api.js';
2
+ import prettier from 'prettier';
3
+ import parserMarkdown from 'prettier/parser-markdown';
4
+ import parserBabel from 'prettier/parser-babel';
5
+ import parserTypescript from 'prettier/parser-typescript';
6
+ import parserHtml from 'prettier/parser-html';
7
+ import parserYaml from 'prettier/parser-yaml';
8
+ import parserPostcss from 'prettier/parser-postcss';
9
+
10
+ // 自定义主题
11
+ export const beauty = (bg = '#00000000') => {
12
+ return {
13
+ base: 'vs-dark',
14
+ inherit: true,
15
+ rules: [
16
+ { token: '', foreground: '6ae5c7' }, // 默认文本颜色
17
+ { token: 'comment', foreground: '9c9c9c' }, // 注释颜色 #9c9c9c 6a9955
18
+ { token: 'keyword', foreground: 'b955e5', fontStyle: 'bold' }, // 关键字颜色 #b955e5
19
+ { token: 'variable', foreground: '9cdcfe' }, // 变量颜色 #6ae5c7
20
+ { token: 'variable.language', foreground: '6ae5c7' }, // 语言变量颜色 #6ae5c7
21
+ { token: 'variable.parameter', foreground: '6ae5c7' }, // 参数变量颜色 #6ae5c7
22
+ { token: 'type', foreground: 'fbe77f' }, // 类型颜色 #fbe77f
23
+ { token: 'function', foreground: 'fbe77f' }, // 函数颜色 #fbe77f
24
+ { token: 'string', foreground: 'a6de7f' }, // 字符串颜色 #a6de7f
25
+ { token: 'number', foreground: 'e7a03c' }, // 数字颜色 #e7a03c
26
+ { token: 'regexp', foreground: '89b5f9' }, // 正则表达式颜色 #89b5f9
27
+ { token: 'operator', foreground: 'dd664d' }, // 操作符颜色 #dd664d
28
+ { token: 'property', foreground: '6ae5c7' }, // 属性颜色 #6ae5c7
29
+ { token: 'constant', foreground: '6ae5c7' }, // 常量颜色 #6ae5c7
30
+ { token: 'namespace', foreground: 'b955e5' }, // 命名空间颜色 #b955e5
31
+ { token: 'comment.block.documentation', foreground: '9c9c9c' }, // 文档注释颜色
32
+ { token: 'comment.block', foreground: '9c9c9c' }, // 块注释颜色
33
+ { token: 'comment.line', foreground: '9c9c9c' }, // 行注释颜色
34
+ { token: 'meta.tag', foreground: 'e53f73' }, // 元标记颜色 #e53f73
35
+ { token: 'meta.attribute.name', foreground: '000000' }, // 元属性名称颜色 #6ae5c7
36
+ { token: 'meta.selector', foreground: 'e53f73' }, // 元选择器颜色 #e53f73
37
+ { token: 'tag', foreground: 'e53f73' },
38
+ { token: 'attribute.name', foreground: 'fbe77f' }, // html 属性名颜色
39
+ { token: 'attribute.value', foreground: 'a6de7f' } // html 属性值颜色
40
+ ],
41
+ colors: {
42
+ 'editor.foreground': '#d5d5d5', // 编辑器前景色
43
+ 'editor.background': bg, // 编辑器背景色
44
+ 'editor.lineHighlightBackground': '#00000000', // 当前行高亮背景色
45
+ 'editor.lineHighlightBorder': '#ffffff5c' // 隐藏当前行边框颜色
46
+ }
47
+ };
48
+ };
49
+
50
+ // 注册自定义格式化配置
51
+ export const registerDocumentFormatInfo = (monaco: typeof monacoEditor) => {
52
+ const prettierFormat = ({ text, parser = 'markdown' }: { text: string; parser: string }) => {
53
+ console.log(prettier, 'prettier', text, parser);
54
+ return prettier.format(text, {
55
+ parser,
56
+ singleQuote: true,
57
+ tabWidth: 2, // 设置 tabSize 为 2
58
+ semi: true, // 在语句末尾添加分号
59
+ arrowParens: 'avoid', // 如果只有一个参数则不加括号
60
+ plugins: [parserMarkdown, parserBabel, parserTypescript, parserHtml, parserPostcss, parserYaml]
61
+ });
62
+ };
63
+
64
+ const provider: monacoEditor.languages.DocumentFormattingEditProvider = {
65
+ provideDocumentFormattingEdits: (
66
+ model: monacoEditor.editor.ITextModel
67
+ ): monacoEditor.languages.ProviderResult<monacoEditor.languages.TextEdit[]> => {
68
+ const text = model.getValue();
69
+ const language = model.getLanguageId(); // 获取当前语言标识符
70
+
71
+ if (language === 'c' || language === 'python') return [];
72
+
73
+ let formattedText;
74
+
75
+ switch (language) {
76
+ case 'markdown':
77
+ formattedText = prettierFormat({ text, parser: 'markdown' });
78
+ break;
79
+ case 'javascript':
80
+ formattedText = prettierFormat({ text, parser: 'babel' });
81
+ break;
82
+ case 'typescript':
83
+ formattedText = prettierFormat({ text, parser: 'typescript' });
84
+ break;
85
+ case 'html':
86
+ formattedText = prettierFormat({ text, parser: 'html' });
87
+ break;
88
+ case 'css':
89
+ formattedText = prettierFormat({ text, parser: 'postcss' });
90
+ break;
91
+ case 'less':
92
+ formattedText = prettierFormat({ text, parser: 'postcss' });
93
+ break;
94
+ case 'scss':
95
+ formattedText = prettierFormat({ text, parser: 'postcss' });
96
+ break;
97
+ case 'yaml':
98
+ formattedText = prettierFormat({ text, parser: 'yaml' });
99
+ break;
100
+ default:
101
+ formattedText = prettierFormat({ text, parser: 'markdown' });
102
+ }
103
+
104
+ return [
105
+ {
106
+ range: model.getFullModelRange(),
107
+ text: formattedText as unknown as string
108
+ }
109
+ ];
110
+ }
111
+ };
112
+
113
+ // 注册格式化
114
+ monaco.languages.registerDocumentFormattingEditProvider('markdown', provider);
115
+ monaco.languages.registerDocumentFormattingEditProvider('javascript', provider);
116
+ monaco.languages.registerDocumentFormattingEditProvider('typescript', provider);
117
+ monaco.languages.registerDocumentFormattingEditProvider('html', provider);
118
+ monaco.languages.registerDocumentFormattingEditProvider('css', provider);
119
+ monaco.languages.registerDocumentFormattingEditProvider('less', provider);
120
+ monaco.languages.registerDocumentFormattingEditProvider('scss', provider);
121
+ monaco.languages.registerDocumentFormattingEditProvider('yaml', provider);
122
+ monaco.languages.registerDocumentFormattingEditProvider('c', provider);
123
+ monaco.languages.registerDocumentFormattingEditProvider('python', provider);
124
+ };