st-comp 0.0.185 → 0.0.186
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/es/CustomFunction.cjs +1 -1
- package/es/CustomFunction.js +7 -7
- package/es/VarSelectDialog.cjs +3 -3
- package/es/VarSelectDialog.js +268 -265
- package/es/VarietySearch.cjs +10 -10
- package/es/VarietySearch.js +940 -937
- package/es/style.css +1 -1
- package/lib/bundle.js +1 -1
- package/lib/bundle.umd.cjs +6 -6
- package/lib/{index-5955b737.js → index-26fab3e5.js} +26 -20
- package/lib/{python-cf7a203d.js → python-c34eeb40.js} +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/packages/CustomFunction/index.vue +1 -1
- package/packages/VarSelectDialog/index.vue +21 -2
- package/packages/VarietySearch/components/FactorScreen/index.vue +22 -2
package/package.json
CHANGED
|
@@ -94,7 +94,7 @@ const handleSubmit = async () => {
|
|
|
94
94
|
// 自定义函数: 插入
|
|
95
95
|
const handleInsert = () => {
|
|
96
96
|
if (!customFunctionName.value) return ElMessage.error("请先选择自定义函数后, 再执行插入");
|
|
97
|
-
emit("insert",
|
|
97
|
+
emit("insert", customFunctionName.value);
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
// 变量选择器: 打开
|
|
@@ -70,13 +70,32 @@ const handleInsetVarContent = (configList) => {
|
|
|
70
70
|
|
|
71
71
|
const currentValue = editorRef.value.getValue();
|
|
72
72
|
const lines = currentValue.split("\n");
|
|
73
|
+
|
|
73
74
|
// 如果光标位置有效
|
|
74
75
|
if (position.lineNumber <= lines.length) {
|
|
75
76
|
const lineIndex = position.lineNumber - 1;
|
|
76
77
|
const line = lines[lineIndex];
|
|
78
|
+
const columnIndex = position.column - 1;
|
|
79
|
+
|
|
80
|
+
// 获取光标前后的字符
|
|
81
|
+
const prevChar = columnIndex > 0 ? line[columnIndex - 1] : "";
|
|
82
|
+
const nextChar = columnIndex < line.length ? line[columnIndex] : "";
|
|
83
|
+
|
|
84
|
+
// 检测是否需要添加空格
|
|
85
|
+
let contentToInsert = content;
|
|
86
|
+
|
|
87
|
+
// 如果前面有内容且不是空格或行首,在前面添加空格
|
|
88
|
+
if (prevChar && prevChar !== " " && !/[\s({[ ]/.test(prevChar)) {
|
|
89
|
+
contentToInsert = " " + contentToInsert;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 如果后面有内容且不是空格或行尾,在后面添加空格
|
|
93
|
+
if (nextChar && nextChar !== " " && !/[\s)}\]]/.test(nextChar)) {
|
|
94
|
+
contentToInsert = contentToInsert + " ";
|
|
95
|
+
}
|
|
77
96
|
|
|
78
97
|
// 在光标位置插入内容
|
|
79
|
-
const newLine = line.substring(0,
|
|
98
|
+
const newLine = line.substring(0, columnIndex) + contentToInsert + line.substring(columnIndex);
|
|
80
99
|
lines[lineIndex] = newLine;
|
|
81
100
|
|
|
82
101
|
// 更新编辑器内容
|
|
@@ -84,7 +103,7 @@ const handleInsetVarContent = (configList) => {
|
|
|
84
103
|
editorRef.value.setValue(newValue);
|
|
85
104
|
|
|
86
105
|
// 将光标移动到插入内容之后
|
|
87
|
-
const newColumn = position.column +
|
|
106
|
+
const newColumn = position.column + contentToInsert.length;
|
|
88
107
|
editorIns.setPosition({
|
|
89
108
|
lineNumber: position.lineNumber,
|
|
90
109
|
column: newColumn,
|
|
@@ -248,18 +248,38 @@ const open = () => {
|
|
|
248
248
|
// 插入自定义函数
|
|
249
249
|
const handleInsertCustomFunction = (value) => {
|
|
250
250
|
if (!monacoEditorRef.value) return ElMessage.error("未检测到编辑器实例");
|
|
251
|
+
|
|
251
252
|
const content = value;
|
|
252
253
|
const editorIns = monacoEditorRef.value.getInstance();
|
|
253
254
|
const position = editorIns.getPosition();
|
|
254
255
|
const currentValue = monacoEditorRef.value.getValue();
|
|
255
256
|
const lines = currentValue.split("\n");
|
|
257
|
+
|
|
256
258
|
// 如果光标位置有效
|
|
257
259
|
if (position.lineNumber <= lines.length) {
|
|
258
260
|
const lineIndex = position.lineNumber - 1;
|
|
259
261
|
const line = lines[lineIndex];
|
|
262
|
+
const columnIndex = position.column - 1;
|
|
263
|
+
|
|
264
|
+
// 获取光标前后的字符
|
|
265
|
+
const prevChar = columnIndex > 0 ? line[columnIndex - 1] : "";
|
|
266
|
+
const nextChar = columnIndex < line.length ? line[columnIndex] : "";
|
|
267
|
+
|
|
268
|
+
// 检测是否需要添加空格
|
|
269
|
+
let contentToInsert = content;
|
|
270
|
+
|
|
271
|
+
// 如果前面有内容且不是空格或行首,在前面添加空格
|
|
272
|
+
if (prevChar && prevChar !== " " && !/[\s({[ ]/.test(prevChar)) {
|
|
273
|
+
contentToInsert = " " + contentToInsert;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 如果后面有内容且不是空格或行尾,在后面添加空格
|
|
277
|
+
if (nextChar && nextChar !== " " && !/[\s)}\]]/.test(nextChar)) {
|
|
278
|
+
contentToInsert = contentToInsert + " ";
|
|
279
|
+
}
|
|
260
280
|
|
|
261
281
|
// 在光标位置插入内容
|
|
262
|
-
const newLine = line.substring(0,
|
|
282
|
+
const newLine = line.substring(0, columnIndex) + contentToInsert + line.substring(columnIndex);
|
|
263
283
|
lines[lineIndex] = newLine;
|
|
264
284
|
|
|
265
285
|
// 更新编辑器内容
|
|
@@ -267,7 +287,7 @@ const handleInsertCustomFunction = (value) => {
|
|
|
267
287
|
monacoEditorRef.value.setValue(newValue);
|
|
268
288
|
|
|
269
289
|
// 将光标移动到插入内容之后
|
|
270
|
-
const newColumn = position.column +
|
|
290
|
+
const newColumn = position.column + contentToInsert.length;
|
|
271
291
|
editorIns.setPosition({
|
|
272
292
|
lineNumber: position.lineNumber,
|
|
273
293
|
column: newColumn,
|