x-star-design 0.0.99 → 0.0.100
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.
|
@@ -30,6 +30,14 @@ export interface CodeMirrorWrapperProps {
|
|
|
30
30
|
cpp?: `ws://${string}` | `wss://${string}`;
|
|
31
31
|
py?: `ws://${string}` | `wss://${string}`;
|
|
32
32
|
};
|
|
33
|
+
lspConfig?: {
|
|
34
|
+
rootUri?: string;
|
|
35
|
+
workspaceFolders?: {
|
|
36
|
+
name: string;
|
|
37
|
+
uri: string;
|
|
38
|
+
}[];
|
|
39
|
+
documentUri?: string;
|
|
40
|
+
};
|
|
33
41
|
}
|
|
34
|
-
declare const CodeMirrorWrapper: ({ className, value, theme, onChange, lang, readOnly, tabSize, lspServerUrl, ...props }: CodeMirrorWrapperProps) => React.JSX.Element;
|
|
42
|
+
declare const CodeMirrorWrapper: ({ className, value, theme, onChange, lang, readOnly, tabSize, lspServerUrl, lspConfig, ...props }: CodeMirrorWrapperProps) => React.JSX.Element;
|
|
35
43
|
export default CodeMirrorWrapper;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["className", "value", "theme", "onChange", "lang", "readOnly", "tabSize", "lspServerUrl"];
|
|
4
|
+
var _excluded = ["className", "value", "theme", "onChange", "lang", "readOnly", "tabSize", "lspServerUrl", "lspConfig"];
|
|
5
5
|
import { autocompletion } from '@codemirror/autocomplete';
|
|
6
6
|
import { cpp } from '@codemirror/lang-cpp';
|
|
7
7
|
import { java } from '@codemirror/lang-java';
|
|
8
8
|
import { python } from '@codemirror/lang-python';
|
|
9
9
|
import { syntaxTree } from '@codemirror/language';
|
|
10
10
|
import { linter } from '@codemirror/lint';
|
|
11
|
+
import { EditorView } from '@codemirror/view';
|
|
12
|
+
import { languageServer } from '@marimo-team/codemirror-languageserver';
|
|
11
13
|
import CodeMirror from '@uiw/react-codemirror';
|
|
12
14
|
import classNames from 'classnames';
|
|
13
|
-
import { languageServer } from 'codemirror-languageserver';
|
|
14
15
|
import React, { useCallback, useMemo } from 'react';
|
|
15
16
|
import { prefix } from "../utils/global";
|
|
16
17
|
import { LangId, Language, Theme, langCompleteOptionsMap, themeMap } from "./define";
|
|
@@ -27,7 +28,16 @@ var CodeMirrorWrapper = function CodeMirrorWrapper(_ref) {
|
|
|
27
28
|
_ref$tabSize = _ref.tabSize,
|
|
28
29
|
tabSize = _ref$tabSize === void 0 ? 2 : _ref$tabSize,
|
|
29
30
|
lspServerUrl = _ref.lspServerUrl,
|
|
31
|
+
lspConfig = _ref.lspConfig,
|
|
30
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
// 添加全局样式来隐藏文档提示气泡
|
|
34
|
+
var hideTooltip = EditorView.baseTheme({
|
|
35
|
+
'.cm-tooltip-autocomplete': {
|
|
36
|
+
'& .cm-completionInfo': {
|
|
37
|
+
display: 'none !important'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
31
41
|
var langCompletions = function langCompletions(context, lang) {
|
|
32
42
|
var options = _toConsumableArray(langCompleteOptionsMap[lang]);
|
|
33
43
|
syntaxTree(context.state).cursor().iterate(function (node) {
|
|
@@ -74,13 +84,15 @@ var CodeMirrorWrapper = function CodeMirrorWrapper(_ref) {
|
|
|
74
84
|
if (lspServerUrl !== null && lspServerUrl !== void 0 && lspServerUrl.cpp) {
|
|
75
85
|
extensions.push(languageServer({
|
|
76
86
|
serverUri: lspServerUrl.cpp,
|
|
77
|
-
rootUri: 'file:///virtual',
|
|
78
|
-
workspaceFolders: [{
|
|
87
|
+
rootUri: (lspConfig === null || lspConfig === void 0 ? void 0 : lspConfig.rootUri) || 'file:///virtual',
|
|
88
|
+
workspaceFolders: (lspConfig === null || lspConfig === void 0 ? void 0 : lspConfig.workspaceFolders) || [{
|
|
79
89
|
name: 'editor',
|
|
80
90
|
uri: 'file:///virtual'
|
|
81
91
|
}],
|
|
82
|
-
documentUri: 'file:///virtual/document.cpp',
|
|
83
|
-
languageId: 'cpp'
|
|
92
|
+
documentUri: (lspConfig === null || lspConfig === void 0 ? void 0 : lspConfig.documentUri) || 'file:///virtual/document.cpp',
|
|
93
|
+
languageId: 'cpp',
|
|
94
|
+
allowHTMLContent: true,
|
|
95
|
+
hoverEnabled: false
|
|
84
96
|
}));
|
|
85
97
|
} else {
|
|
86
98
|
extensions.push(autocompletion({
|
|
@@ -89,20 +101,22 @@ var CodeMirrorWrapper = function CodeMirrorWrapper(_ref) {
|
|
|
89
101
|
}]
|
|
90
102
|
}), regexpLinter());
|
|
91
103
|
}
|
|
92
|
-
|
|
104
|
+
return extensions;
|
|
93
105
|
case LangId.PY2:
|
|
94
106
|
case LangId.PY3:
|
|
95
107
|
extensions = [python()];
|
|
96
108
|
if (lspServerUrl !== null && lspServerUrl !== void 0 && lspServerUrl.py) {
|
|
97
109
|
extensions.push(languageServer({
|
|
98
110
|
serverUri: lspServerUrl.py,
|
|
99
|
-
rootUri: 'file:///virtual',
|
|
100
|
-
workspaceFolders: [{
|
|
111
|
+
rootUri: (lspConfig === null || lspConfig === void 0 ? void 0 : lspConfig.rootUri) || 'file:///virtual',
|
|
112
|
+
workspaceFolders: (lspConfig === null || lspConfig === void 0 ? void 0 : lspConfig.workspaceFolders) || [{
|
|
101
113
|
name: 'editor',
|
|
102
114
|
uri: 'file:///virtual'
|
|
103
115
|
}],
|
|
104
|
-
documentUri: 'file:///virtual/document.py',
|
|
105
|
-
languageId: 'python'
|
|
116
|
+
documentUri: (lspConfig === null || lspConfig === void 0 ? void 0 : lspConfig.documentUri) || 'file:///virtual/document.py',
|
|
117
|
+
languageId: 'python',
|
|
118
|
+
allowHTMLContent: true,
|
|
119
|
+
hoverEnabled: false
|
|
106
120
|
}));
|
|
107
121
|
} else {
|
|
108
122
|
extensions.push(autocompletion({
|
|
@@ -111,23 +125,21 @@ var CodeMirrorWrapper = function CodeMirrorWrapper(_ref) {
|
|
|
111
125
|
}]
|
|
112
126
|
}), regexpLinter());
|
|
113
127
|
}
|
|
114
|
-
|
|
128
|
+
return extensions;
|
|
115
129
|
case LangId.JAVA:
|
|
116
|
-
|
|
130
|
+
return [java(), autocompletion({
|
|
117
131
|
override: [function (context) {
|
|
118
132
|
return langCompletions(context, Language.JAVA);
|
|
119
133
|
}]
|
|
120
134
|
}), regexpLinter()];
|
|
121
|
-
break;
|
|
122
135
|
default:
|
|
123
136
|
return [];
|
|
124
137
|
}
|
|
125
|
-
|
|
126
|
-
}, [lang, lspServerUrl, regexpLinter]);
|
|
138
|
+
}, [lang, lspServerUrl, lspConfig]);
|
|
127
139
|
return /*#__PURE__*/React.createElement(CodeMirror, _extends({
|
|
128
140
|
className: classNames(className, "".concat(prefix, "-codeMirror")),
|
|
129
141
|
value: value,
|
|
130
|
-
extensions: langConfigMap,
|
|
142
|
+
extensions: [hideTooltip].concat(_toConsumableArray(langConfigMap)),
|
|
131
143
|
onChange: onChange,
|
|
132
144
|
theme: themeMap[theme],
|
|
133
145
|
readOnly: readOnly,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-star-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.100",
|
|
4
4
|
"description": "A react component library developed by turingstar",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
64
64
|
"@dnd-kit/sortable": "^8.0.0",
|
|
65
65
|
"@dnd-kit/utilities": "^3.2.2",
|
|
66
|
+
"@marimo-team/codemirror-languageserver": "^1.15.14",
|
|
66
67
|
"@types/classnames": "^2.3.4",
|
|
67
68
|
"@uiw/codemirror-theme-bbedit": "^4.21.9",
|
|
68
69
|
"@uiw/codemirror-theme-eclipse": "^4.21.9",
|
|
@@ -71,7 +72,6 @@
|
|
|
71
72
|
"@uiw/react-codemirror": "^4.21.9",
|
|
72
73
|
"ahooks": "3.8.0",
|
|
73
74
|
"classnames": "^2.5.1",
|
|
74
|
-
"codemirror-languageserver": "1.12.1",
|
|
75
75
|
"html2canvas": "^1.4.1",
|
|
76
76
|
"province-city-china": "^8.5.8",
|
|
77
77
|
"qiankun": "^2.10.16",
|