cloud-web-corejs 1.1.0-dev.34 → 1.1.0-dev.35
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/bin/core-resources.js +16 -0
- package/docs/child-app/README.md +6 -3
- package/docs/child-app/activiti-resources.md +63 -0
- package/docs/child-app/generate-prompt.md +7 -1
- package/docs/child-app/luckysheet-resources.md +80 -0
- package/docs/child-app/public-resources-plan.md +288 -0
- package/docs/child-app/resources-implementation.md +101 -0
- package/docs/child-app/tinymce-resources.md +88 -0
- package/docs/child-app/validation.md +4 -3
- package/package.json +10 -2
- package/resource-tools/index.js +126 -0
- package/src/app-bootstrap.js +7 -2
- package/src/components/Tinymce/dynamicLoadScript.js +51 -59
- package/src/components/Tinymce/index.vue +382 -339
- package/src/components/code-editor/index.vue +361 -343
- package/src/components/luckysheet/loadResources.js +64 -0
- package/src/components/luckysheet/view.vue +239 -210
- package/src/components/xform/form-designer/form-widget/field-widget/dropdown-widget.vue +34 -3
- package/src/utils/featureResources.js +57 -0
- package/src/views/bd/setting/form_template/mixins/list.js +7 -6
- package/src/views/bd/setting/form_template/mixins/list2.js +412 -411
- package/src/views/bd/setting/form_template/mixins/wf_list.js +431 -430
- package/src/views/user/form/form_template/list.vue +513 -512
- package/src/views/user/wf/wf_obj_config/activiti_wf.vue +134 -133
- package/src/views/user/wf/wf_obj_config/list.vue +747 -746
- package/src/views/user/wf/wf_obj_config/list_form.vue +374 -373
- package/templates/child-app/README.md +2 -0
- package/templates/child-app/core-resources.config.js +15 -0
- package/templates/child-app/gitignore +1 -0
- package/templates/child-app/package.json +5 -0
- package/templates/child-app/vue.config.js +2 -1
|
@@ -1,343 +1,361 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="ace-container">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
<div
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
import "ace-builds/src-min-noconflict/
|
|
22
|
-
import "ace-builds/src-min-noconflict/mode-
|
|
23
|
-
import "ace-builds/src-min-noconflict/mode-
|
|
24
|
-
import "ace-builds/src-min-noconflict/mode-
|
|
25
|
-
import "ace-builds/src-min-noconflict/mode-
|
|
26
|
-
import "ace-builds/src-min-noconflict/
|
|
27
|
-
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
ace.config.set(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.$emit(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.aceEditor
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this.aceEditor.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
this.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ace-container">
|
|
3
|
+
<div v-if="resourceError" role="alert" class="ace-resource-error">{{ resourceError }}</div>
|
|
4
|
+
<!-- 官方文档中使用id,这里禁止使用,在后期打包后容易出现问题,使用 ref 或者 DOM 就行 -->
|
|
5
|
+
<div class="ace-editor" ref="ace" :style="editorStyle"></div>
|
|
6
|
+
<template v-if="resize && !resourceError">
|
|
7
|
+
<div id="editor-resize-bar" @mousedown="btnMouseDown"></div>
|
|
8
|
+
<div class="icon-drag" @mousedown="btnMouseDown"></div>
|
|
9
|
+
</template>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import ace from "ace-builds";
|
|
15
|
+
/* 启用此行后webpack打包回生成很多动态加载的js文件,不便于部署,故禁用!!
|
|
16
|
+
特别提示:禁用此行后,需要调用ace.config.set('basePath', 'path...')指定动态js加载URL!!
|
|
17
|
+
*/
|
|
18
|
+
//import 'ace-builds/webpack-resolver'
|
|
19
|
+
|
|
20
|
+
//import 'ace-builds/src-min-noconflict/theme-monokai' // 默认设置的主题
|
|
21
|
+
import "ace-builds/src-min-noconflict/theme-sqlserver"; // 新设主题
|
|
22
|
+
import "ace-builds/src-min-noconflict/mode-javascript"; // 默认设置的语言模式
|
|
23
|
+
import "ace-builds/src-min-noconflict/mode-json"; //
|
|
24
|
+
import "ace-builds/src-min-noconflict/mode-css"; //
|
|
25
|
+
import "ace-builds/src-min-noconflict/mode-java"; //
|
|
26
|
+
import "ace-builds/src-min-noconflict/mode-text"; //
|
|
27
|
+
import "ace-builds/src-min-noconflict/ext-language_tools";
|
|
28
|
+
import { codeEditorResourcePath } from "../../utils/featureResources";
|
|
29
|
+
import indexUtil from "../../utils/index.js";
|
|
30
|
+
export default {
|
|
31
|
+
name: "CodeEditor",
|
|
32
|
+
props: {
|
|
33
|
+
value: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "",
|
|
36
|
+
},
|
|
37
|
+
readonly: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
mode: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "javascript",
|
|
44
|
+
},
|
|
45
|
+
userWorker: {
|
|
46
|
+
//是否开启语法检查,默认开启
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: true,
|
|
49
|
+
},
|
|
50
|
+
maxLines: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: 20,
|
|
53
|
+
},
|
|
54
|
+
minLines: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 20,
|
|
57
|
+
},
|
|
58
|
+
height: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "450px",
|
|
61
|
+
},
|
|
62
|
+
resize: {
|
|
63
|
+
//是否开启语法检查,默认开启
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
computed: {
|
|
69
|
+
editorStyle: function () {
|
|
70
|
+
// 对象形式绑定,避免调用方传入的 height 拼出非法 CSS。
|
|
71
|
+
// 历史调用方存在 height="414px;" 这种带分号的写法,对象形式下会被浏览器丢弃,需先清理。
|
|
72
|
+
let height = (this.height || "").trim().replace(/;+$/, "").trim();
|
|
73
|
+
return { height: height || "450px" };
|
|
74
|
+
},
|
|
75
|
+
modePath: function () {
|
|
76
|
+
return "ace/mode/" + this.mode;
|
|
77
|
+
},
|
|
78
|
+
acData: function () {
|
|
79
|
+
let acData = [];
|
|
80
|
+
if (this.mode == "javascript") {
|
|
81
|
+
acData = [
|
|
82
|
+
{
|
|
83
|
+
meta: "VForm API",
|
|
84
|
+
caption: "getWidgetRef",
|
|
85
|
+
value: "getWidgetRef()",
|
|
86
|
+
score: 1,
|
|
87
|
+
},
|
|
88
|
+
{ meta: "VForm API", caption: "getFormRef", value: "getFormRef()", score: 1 },
|
|
89
|
+
{
|
|
90
|
+
meta: "VForm API",
|
|
91
|
+
caption: "addExtraAccessData",
|
|
92
|
+
value: "addExtraAccessData()",
|
|
93
|
+
score: 1,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
meta: "VForm API",
|
|
97
|
+
caption: "clearExtraAccessData",
|
|
98
|
+
value: "clearExtraAccessData()",
|
|
99
|
+
score: 1,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
meta: "VForm API",
|
|
103
|
+
caption: "getFormParam",
|
|
104
|
+
value: "getFormParam()",
|
|
105
|
+
score: 1,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
meta: "VForm API",
|
|
109
|
+
caption: "getGlobalConfig",
|
|
110
|
+
value: "getGlobalConfig()",
|
|
111
|
+
score: 1,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
meta: "snippet",
|
|
115
|
+
caption: "setInterval",
|
|
116
|
+
value: "setInterval(function() {}, 5000);",
|
|
117
|
+
score: 1,
|
|
118
|
+
},
|
|
119
|
+
//TODO: 待补充!!
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
return acData;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
mounted() {
|
|
126
|
+
//ace.config.set('basePath', 'https://ks3-cn-beijing.ksyun.com/vform2021/ace')
|
|
127
|
+
if (!this.configureResources()) return;
|
|
128
|
+
|
|
129
|
+
this.addAutoCompletion(ace); //添加自定义代码提示!!
|
|
130
|
+
|
|
131
|
+
this.aceEditor = ace.edit(this.$refs.ace, {
|
|
132
|
+
// maxLines: this.maxLines, // 最大行数,超过会自动出现滚动条
|
|
133
|
+
// minLines: this.minLines, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
|
|
134
|
+
fontSize: 12, // 编辑器内字体大小
|
|
135
|
+
theme: this.themePath, // 默认设置的主题
|
|
136
|
+
mode: this.modePath, // 默认设置的语言模式
|
|
137
|
+
tabSize: 2, // 制表符设置为2个空格大小
|
|
138
|
+
readOnly: this.readonly,
|
|
139
|
+
highlightActiveLine: true,
|
|
140
|
+
value: this.codeValue,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
this.aceEditor.setOptions({
|
|
144
|
+
enableBasicAutocompletion: true,
|
|
145
|
+
enableSnippets: true, // 设置代码片段提示
|
|
146
|
+
enableLiveAutocompletion: true, // 设置自动提示
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (this.mode === "json") {
|
|
150
|
+
this.setJsonMode();
|
|
151
|
+
} else if (this.mode === "css") {
|
|
152
|
+
this.setCssMode();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!this.userWorker) {
|
|
156
|
+
this.aceEditor.getSession().setUseWorker(false);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//编辑时同步数据
|
|
160
|
+
this.aceEditor.getSession().on("change", (ev) => {
|
|
161
|
+
//this.$emit('update:value', this.aceEditor.getValue()) // 触发更新事件, 实现.sync双向绑定!!
|
|
162
|
+
this.$emit("input", this.aceEditor.getValue());
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
this.observeSizeChange();
|
|
166
|
+
},
|
|
167
|
+
activated() {
|
|
168
|
+
// keep-alive 页签切回时 DOM 重新插入,需重新测量,否则内容不渲染
|
|
169
|
+
this.refresh();
|
|
170
|
+
},
|
|
171
|
+
beforeDestroy() {
|
|
172
|
+
this.disconnectObserver();
|
|
173
|
+
if (this.aceEditor) {
|
|
174
|
+
// ace 仅在 destroy 时才解绑它自己注册的 window resize 监听
|
|
175
|
+
this.aceEditor.destroy();
|
|
176
|
+
this.aceEditor = null;
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
data() {
|
|
180
|
+
return {
|
|
181
|
+
resourceError: "",
|
|
182
|
+
aceEditor: null,
|
|
183
|
+
themePath: "ace/theme/sqlserver", // 不导入 webpack-resolver,该模块路径会报错
|
|
184
|
+
// modePath: 'ace/mode/javascript', // 同上
|
|
185
|
+
codeValue: this.value || "",
|
|
186
|
+
resizeObserver: null,
|
|
187
|
+
resizeRaf: null,
|
|
188
|
+
refreshPending: false,
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
watch: {
|
|
192
|
+
value(val) {
|
|
193
|
+
if (!this.aceEditor) {
|
|
194
|
+
// 实例尚未创建(异步组件解析中)时不能丢弃,否则这次赋值永久丢失
|
|
195
|
+
this.codeValue = val || "";
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const newVal = val || "";
|
|
199
|
+
if (this.aceEditor.getValue() !== newVal) {
|
|
200
|
+
this.aceEditor.setValue(newVal, -1);
|
|
201
|
+
this.aceEditor.clearSelection();
|
|
202
|
+
this.aceEditor.resize();
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
mode() {
|
|
206
|
+
if (!this.aceEditor) return;
|
|
207
|
+
if (!this.configureResources()) return;
|
|
208
|
+
if (this.mode === "json") {
|
|
209
|
+
this.setJsonMode();
|
|
210
|
+
} else if (this.mode === "css") {
|
|
211
|
+
this.setCssMode();
|
|
212
|
+
} else {
|
|
213
|
+
this.aceEditor.getSession().setMode(this.modePath);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
height() {
|
|
217
|
+
this.$nextTick(() => {
|
|
218
|
+
this.refresh();
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
methods: {
|
|
223
|
+
configureResources() {
|
|
224
|
+
try {
|
|
225
|
+
const resourcePath = codeEditorResourcePath(this.mode);
|
|
226
|
+
ace.config.set("basePath", resourcePath);
|
|
227
|
+
ace.config.set("workerPath", resourcePath);
|
|
228
|
+
ace.config.set("modePath", resourcePath);
|
|
229
|
+
ace.config.set("themePath", resourcePath);
|
|
230
|
+
this.resourceError = "";
|
|
231
|
+
return true;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
this.resourceError = error.message;
|
|
234
|
+
this.$emit("resource-error", error);
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
/**
|
|
239
|
+
* ace 在 mounted 时同步初始化,若此刻祖先为 display:none(隐藏字段、非激活 tab、
|
|
240
|
+
* 未展开的弹窗等),字符与容器尺寸都会被测成 0,之后没有任何时机重新测量
|
|
241
|
+
* —— ace 自身只监听 window 的 resize。这里观测编辑器元素本身,尺寸一旦可用就重测。
|
|
242
|
+
*/
|
|
243
|
+
observeSizeChange() {
|
|
244
|
+
if (typeof ResizeObserver !== "function" || !this.$refs.ace) return;
|
|
245
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
246
|
+
this.refresh();
|
|
247
|
+
});
|
|
248
|
+
this.resizeObserver.observe(this.$refs.ace);
|
|
249
|
+
},
|
|
250
|
+
disconnectObserver() {
|
|
251
|
+
if (this.resizeRaf !== null) {
|
|
252
|
+
cancelAnimationFrame(this.resizeRaf);
|
|
253
|
+
this.resizeRaf = null;
|
|
254
|
+
}
|
|
255
|
+
this.refreshPending = false;
|
|
256
|
+
if (this.resizeObserver) {
|
|
257
|
+
this.resizeObserver.disconnect();
|
|
258
|
+
this.resizeObserver = null;
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
/** 重新测量并重绘。尺寸不可用时跳过,等下一次可见再触发。 */
|
|
262
|
+
refresh() {
|
|
263
|
+
if (this.refreshPending) return;
|
|
264
|
+
this.refreshPending = true;
|
|
265
|
+
this.resizeRaf = requestAnimationFrame(() => {
|
|
266
|
+
this.refreshPending = false;
|
|
267
|
+
this.resizeRaf = null;
|
|
268
|
+
const el = this.$refs.ace;
|
|
269
|
+
if (!this.aceEditor || !el) return;
|
|
270
|
+
// 仍不可见时跳过,等真正显示后 ResizeObserver 会再次触发
|
|
271
|
+
if (!el.offsetWidth || !el.offsetHeight) return;
|
|
272
|
+
this.aceEditor.resize(true);
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
addAutoCompletion(ace) {
|
|
276
|
+
let acData = this.acData;
|
|
277
|
+
let langTools = ace.require("ace/ext/language_tools");
|
|
278
|
+
langTools.addCompleter({
|
|
279
|
+
getCompletions: function (editor, session, pos, prefix, callback) {
|
|
280
|
+
if (prefix.length === 0) {
|
|
281
|
+
return callback(null, []);
|
|
282
|
+
} else {
|
|
283
|
+
return callback(null, acData);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
setJsonMode() {
|
|
290
|
+
this.aceEditor.getSession().setMode("ace/mode/json");
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
setCssMode() {
|
|
294
|
+
this.aceEditor.getSession().setMode("ace/mode/css");
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
getEditorAnnotations() {
|
|
298
|
+
return this.aceEditor ? this.aceEditor.getSession().getAnnotations() : [];
|
|
299
|
+
},
|
|
300
|
+
setValue(val) {
|
|
301
|
+
if (!this.aceEditor) return;
|
|
302
|
+
this.aceEditor.setValue(val || "", -1);
|
|
303
|
+
this.aceEditor.clearSelection();
|
|
304
|
+
},
|
|
305
|
+
btnMouseDown(event) {
|
|
306
|
+
let rootDom = document.body.querySelector("#app");
|
|
307
|
+
indexUtil.addClass(rootDom, "ns-resize-ing");
|
|
308
|
+
const editor = this.aceEditor;
|
|
309
|
+
const startY = event.clientY;
|
|
310
|
+
const startHeight = editor.container.clientHeight;
|
|
311
|
+
|
|
312
|
+
const onMouseMove = (moveEvent) => {
|
|
313
|
+
const deltaY = moveEvent.clientY - startY;
|
|
314
|
+
editor.container.style.height = startHeight + deltaY + "px";
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const onMouseUp = () => {
|
|
318
|
+
indexUtil.removeClass(rootDom, "ns-resize-ing");
|
|
319
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
320
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
321
|
+
editor.resize();
|
|
322
|
+
editor.focus();
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
326
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
</script>
|
|
331
|
+
|
|
332
|
+
<style lang="scss">
|
|
333
|
+
@import "./ace-chrome.scss";
|
|
334
|
+
</style>
|
|
335
|
+
<style lang="scss" scoped>
|
|
336
|
+
#editor-resize-bar {
|
|
337
|
+
width: 100%;
|
|
338
|
+
height: 5px;
|
|
339
|
+
cursor: ns-resize;
|
|
340
|
+
position: absolute;
|
|
341
|
+
bottom: 0;
|
|
342
|
+
left: 0;
|
|
343
|
+
}
|
|
344
|
+
.ace-container {
|
|
345
|
+
position: relative;
|
|
346
|
+
.icon-drag {
|
|
347
|
+
position: absolute;
|
|
348
|
+
right: 3px;
|
|
349
|
+
bottom: 3px;
|
|
350
|
+
font-family: "iconfont";
|
|
351
|
+
font-size: 10px;
|
|
352
|
+
cursor: n-resize;
|
|
353
|
+
width: 12px;
|
|
354
|
+
height: 12px;
|
|
355
|
+
line-height: 12px;
|
|
356
|
+
&:before {
|
|
357
|
+
content: "\e61e";
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
</style>
|