cloud-web-corejs 1.0.196 → 1.0.197

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.196",
4
+ "version": "1.0.197",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -2,85 +2,124 @@
2
2
  <div class="ace-container">
3
3
  <!-- 官方文档中使用id,这里禁止使用,在后期打包后容易出现问题,使用 ref 或者 DOM 就行 -->
4
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>
5
9
  </div>
6
10
  </template>
7
11
 
8
12
  <script>
9
- import ace from 'ace-builds';
13
+ import ace from "ace-builds";
10
14
  /* 启用此行后webpack打包回生成很多动态加载的js文件,不便于部署,故禁用!!
11
15
  特别提示:禁用此行后,需要调用ace.config.set('basePath', 'path...')指定动态js加载URL!!
12
16
  */
13
17
  //import 'ace-builds/webpack-resolver'
14
18
 
15
19
  //import 'ace-builds/src-min-noconflict/theme-monokai' // 默认设置的主题
16
- import 'ace-builds/src-min-noconflict/theme-sqlserver'; // 新设主题
17
- import 'ace-builds/src-min-noconflict/mode-javascript'; // 默认设置的语言模式
18
- import 'ace-builds/src-min-noconflict/mode-json'; //
19
- import 'ace-builds/src-min-noconflict/mode-css'; //
20
- import 'ace-builds/src-min-noconflict/mode-java'; //
21
- import 'ace-builds/src-min-noconflict/ext-language_tools';
22
- const ACE_BASE_PATH = window.WEB_PREFIX + '/base/ace/src-min-noconflict'
23
-
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/ext-language_tools";
26
+ const ACE_BASE_PATH = window.WEB_PREFIX + "/base/ace/src-min-noconflict";
27
+ import indexUtil from "../../utils/index.js";
24
28
  export default {
25
- name: 'CodeEditor',
29
+ name: "CodeEditor",
26
30
  props: {
27
31
  value: {
28
32
  type: String,
29
- default: ''
33
+ default: "",
30
34
  },
31
35
  readonly: {
32
36
  type: Boolean,
33
- default: false
37
+ default: false,
34
38
  },
35
39
  mode: {
36
40
  type: String,
37
- default: 'javascript'
41
+ default: "javascript",
38
42
  },
39
43
  userWorker: {
40
44
  //是否开启语法检查,默认开启
41
45
  type: Boolean,
42
- default: true
46
+ default: true,
43
47
  },
44
48
  maxLines: {
45
49
  type: Number,
46
- default: 20
50
+ default: 20,
47
51
  },
48
52
  minLines: {
49
53
  type: Number,
50
- default: 20
54
+ default: 20,
51
55
  },
52
56
  height: {
53
57
  type: String,
54
- default: '280px;'
58
+ default: "450px;",
59
+ },
60
+ resize: {
61
+ //是否开启语法检查,默认开启
62
+ type: Boolean,
63
+ default: true,
55
64
  },
56
65
  },
57
66
  computed: {
58
- editorStyle:function(){
59
- return 'height:'+this.height;
67
+ editorStyle: function () {
68
+ return "height:" + this.height;
60
69
  },
61
- modePath: function() {
62
- return 'ace/mode/' + this.mode;
70
+ modePath: function () {
71
+ return "ace/mode/" + this.mode;
63
72
  },
64
- acData: function() {
73
+ acData: function () {
65
74
  let acData = [];
66
- if (this.mode == 'javascript') {
75
+ if (this.mode == "javascript") {
67
76
  acData = [
68
- { meta: 'VForm API', caption: 'getWidgetRef', value: 'getWidgetRef()', score: 1 },
69
- { meta: 'VForm API', caption: 'getFormRef', value: 'getFormRef()', score: 1 },
70
- { meta: 'VForm API', caption: 'addExtraAccessData', value: 'addExtraAccessData()', score: 1 },
71
- { meta: 'VForm API', caption: 'clearExtraAccessData', value: 'clearExtraAccessData()', score: 1 },
72
- { meta: 'snippet', caption: 'setInterval', value: 'setInterval(function() {}, 5000);', score: 1 },
73
- { meta: 'VForm API', caption: 'getFormParam', value: 'getFormParam()', score: 1 },
74
- { meta: 'VForm API', caption: 'getGlobalConfig', value: 'getGlobalConfig()', score: 1 },
77
+ {
78
+ meta: "VForm API",
79
+ caption: "getWidgetRef",
80
+ value: "getWidgetRef()",
81
+ score: 1,
82
+ },
83
+ { meta: "VForm API", caption: "getFormRef", value: "getFormRef()", score: 1 },
84
+ {
85
+ meta: "VForm API",
86
+ caption: "addExtraAccessData",
87
+ value: "addExtraAccessData()",
88
+ score: 1,
89
+ },
90
+ {
91
+ meta: "VForm API",
92
+ caption: "clearExtraAccessData",
93
+ value: "clearExtraAccessData()",
94
+ score: 1,
95
+ },
96
+ {
97
+ meta: "VForm API",
98
+ caption: "getFormParam",
99
+ value: "getFormParam()",
100
+ score: 1,
101
+ },
102
+ {
103
+ meta: "VForm API",
104
+ caption: "getGlobalConfig",
105
+ value: "getGlobalConfig()",
106
+ score: 1,
107
+ },
108
+ {
109
+ meta: "snippet",
110
+ caption: "setInterval",
111
+ value: "setInterval(function() {}, 5000);",
112
+ score: 1,
113
+ },
75
114
  //TODO: 待补充!!
76
115
  ];
77
116
  }
78
117
  return acData;
79
- }
118
+ },
80
119
  },
81
120
  mounted() {
82
121
  //ace.config.set('basePath', 'https://ks3-cn-beijing.ksyun.com/vform2021/ace')
83
- ace.config.set('basePath', ACE_BASE_PATH);
122
+ ace.config.set("basePath", ACE_BASE_PATH);
84
123
 
85
124
  this.addAutoCompletion(ace); //添加自定义代码提示!!
86
125
 
@@ -93,18 +132,18 @@ export default {
93
132
  tabSize: 2, // 制表符设置为2个空格大小
94
133
  readOnly: this.readonly,
95
134
  highlightActiveLine: true,
96
- value: this.codeValue
135
+ value: this.codeValue,
97
136
  });
98
137
 
99
138
  this.aceEditor.setOptions({
100
139
  enableBasicAutocompletion: true,
101
140
  enableSnippets: true, // 设置代码片段提示
102
- enableLiveAutocompletion: true // 设置自动提示
141
+ enableLiveAutocompletion: true, // 设置自动提示
103
142
  });
104
143
 
105
- if (this.mode === 'json') {
144
+ if (this.mode === "json") {
106
145
  this.setJsonMode();
107
- } else if (this.mode === 'css') {
146
+ } else if (this.mode === "css") {
108
147
  this.setCssMode();
109
148
  }
110
149
 
@@ -113,54 +152,100 @@ export default {
113
152
  }
114
153
 
115
154
  //编辑时同步数据
116
- this.aceEditor.getSession().on('change', ev => {
155
+ this.aceEditor.getSession().on("change", (ev) => {
117
156
  //this.$emit('update:value', this.aceEditor.getValue()) // 触发更新事件, 实现.sync双向绑定!!
118
- this.$emit('input', this.aceEditor.getValue());
157
+ this.$emit("input", this.aceEditor.getValue());
119
158
  });
120
159
  },
121
160
  data() {
122
161
  return {
123
162
  aceEditor: null,
124
- themePath: 'ace/theme/sqlserver', // 不导入 webpack-resolver,该模块路径会报错
163
+ themePath: "ace/theme/sqlserver", // 不导入 webpack-resolver,该模块路径会报错
125
164
  // modePath: 'ace/mode/javascript', // 同上
126
- codeValue: this.value || ''
165
+ codeValue: this.value || "",
127
166
  };
128
167
  },
129
- watch: {
130
-
131
- },
168
+ watch: {},
132
169
  methods: {
133
170
  addAutoCompletion(ace) {
134
171
  let acData = this.acData;
135
- let langTools = ace.require('ace/ext/language_tools');
172
+ let langTools = ace.require("ace/ext/language_tools");
136
173
  langTools.addCompleter({
137
- getCompletions: function(editor, session, pos, prefix, callback) {
174
+ getCompletions: function (editor, session, pos, prefix, callback) {
138
175
  if (prefix.length === 0) {
139
176
  return callback(null, []);
140
177
  } else {
141
178
  return callback(null, acData);
142
179
  }
143
- }
180
+ },
144
181
  });
145
182
  },
146
183
 
147
184
  setJsonMode() {
148
- this.aceEditor.getSession().setMode('ace/mode/json');
185
+ this.aceEditor.getSession().setMode("ace/mode/json");
149
186
  },
150
187
 
151
188
  setCssMode() {
152
- this.aceEditor.getSession().setMode('ace/mode/css');
189
+ this.aceEditor.getSession().setMode("ace/mode/css");
153
190
  },
154
191
 
155
192
  getEditorAnnotations() {
156
193
  return this.aceEditor.getSession().getAnnotations();
157
194
  },
158
- setValue(val){
195
+ setValue(val) {
159
196
  this.aceEditor.setValue(val);
160
- }
161
- }
197
+ },
198
+ btnMouseDown(event) {
199
+ let rootDom = document.body.querySelector("#app");
200
+ indexUtil.addClass(rootDom, "ns-resize-ing");
201
+ const editor = this.aceEditor;
202
+ const startY = event.clientY;
203
+ const startHeight = editor.container.clientHeight;
204
+
205
+ const onMouseMove = (moveEvent) => {
206
+ const deltaY = moveEvent.clientY - startY;
207
+ editor.container.style.height = startHeight + deltaY + "px";
208
+ };
209
+
210
+ const onMouseUp = () => {
211
+ indexUtil.removeClass(rootDom, "ns-resize-ing");
212
+ document.removeEventListener("mousemove", onMouseMove);
213
+ document.removeEventListener("mouseup", onMouseUp);
214
+ editor.resize();
215
+ editor.focus();
216
+ };
217
+
218
+ document.addEventListener("mousemove", onMouseMove);
219
+ document.addEventListener("mouseup", onMouseUp);
220
+ },
221
+ },
162
222
  };
163
223
  </script>
164
224
 
165
225
  <style lang="scss" scoped>
226
+ #editor-resize-bar {
227
+ width: 100%;
228
+ height: 5px;
229
+ cursor: ns-resize;
230
+ position: absolute;
231
+ bottom: 0;
232
+ left: 0;
233
+ }
234
+ .ace-container {
235
+ position: relative;
236
+ .icon-drag {
237
+ position: absolute;
238
+ right: 3px;
239
+ bottom: 3px;
240
+ font-family: "iconfont";
241
+ font-size: 10px;
242
+ cursor: n-resize;
243
+ width: 12px;
244
+ height: 12px;
245
+ line-height: 12px;
246
+ &:before {
247
+ content: "\e61e";
248
+ }
249
+ }
250
+ }
166
251
  </style>
@@ -1,5 +1,5 @@
1
1
  let modules;
2
- import {treeScolly} from "../../../utils/global.js";
2
+ import {treeScolly} from "@base/utils/global.js";
3
3
 
4
4
  modules = {
5
5
  props: {
@@ -1,5 +1,5 @@
1
1
  let modules;
2
- import {treeScolly} from "../../../utils/global.js";
2
+ import {treeScolly} from "@base/utils/global.js";
3
3
 
4
4
  modules = {
5
5
  props: {
@@ -1,5 +1,5 @@
1
- import {selectDialogMixins} from '../../../mixins/selectDialog/index.js';
2
- import ElImageViewer from '../../../components/VabUpload/image-viewer';
1
+ import {selectDialogMixins} from '@base/mixins/selectDialog/index.js';
2
+ import ElImageViewer from '@base/components/VabUpload/image-viewer';
3
3
 
4
4
  let modules;
5
5
  modules = {