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