@cicctencent/low-code-editor 0.0.0-stage → 1.1.9-beta.5

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 (97) hide show
  1. package/README.md +2 -2
  2. package/api-extractor.json +36 -0
  3. package/dist/ActivityBar/index.vue.d.ts +29 -0
  4. package/dist/ComponentTree/components/List.vue.d.ts +29 -0
  5. package/dist/ComponentTree/index.vue.d.ts +32 -0
  6. package/dist/DataSource/index.vue.d.ts +34 -0
  7. package/dist/HeaderBar/components/BarTooltip.vue.d.ts +37 -0
  8. package/dist/HeaderBar/index.vue.d.ts +49 -0
  9. package/dist/NavTree/index.vue.d.ts +48 -0
  10. package/dist/SchemaConfig/index.vue.d.ts +36 -0
  11. package/dist/SidebarPane/index.vue.d.ts +38 -0
  12. package/dist/components/ComponentTreeFavorites/components/List.vue.d.ts +41 -0
  13. package/dist/components/ComponentTreeFavorites/components/Tips.vue.d.ts +16 -0
  14. package/dist/components/ComponentTreeFavorites/index.vue.d.ts +44 -0
  15. package/dist/components/ImageGuide/index.vue.d.ts +45 -0
  16. package/dist/components.d.ts +7 -0
  17. package/dist/composables/useComponentTree.d.ts +13 -0
  18. package/dist/config/ace.config.d.ts +3 -0
  19. package/dist/domain/EditorDomain.d.ts +89 -0
  20. package/dist/editor.d.ts +286 -0
  21. package/dist/editor.vue.d.ts +104 -0
  22. package/dist/formily/ActivityBar/index.d.ts +4 -0
  23. package/dist/formily/ComponentTree/index.d.ts +4 -0
  24. package/dist/formily/DataBinding/index.d.ts +4 -0
  25. package/dist/formily/DataBinding/index.vue.d.ts +26 -0
  26. package/dist/formily/DataSource/index.d.ts +4 -0
  27. package/dist/formily/MenuTable/PageList.vue.d.ts +28 -0
  28. package/dist/formily/MenuTable/index.d.ts +4 -0
  29. package/dist/formily/MenuTable/index.vue.d.ts +30 -0
  30. package/dist/formily/MenuTable/useMenuTable.d.ts +227 -0
  31. package/dist/formily/NavTree/index.d.ts +4 -0
  32. package/dist/formily/SidebarPane/index.d.ts +4 -0
  33. package/dist/formily/index.d.ts +2 -0
  34. package/dist/index.css +1167 -0
  35. package/dist/index.d.ts +250 -0
  36. package/dist/index.js +34171 -0
  37. package/dist/utils/base64.d.ts +4 -0
  38. package/dist/utils/index.d.ts +27 -0
  39. package/package.json +58 -4
  40. package/rollup.config.js +3 -0
  41. package/src/ActivityBar/index.vue +71 -0
  42. package/src/ComponentTree/components/List.vue +310 -0
  43. package/src/ComponentTree/index.vue +77 -0
  44. package/src/DataSource/index.vue +640 -0
  45. package/src/HeaderBar/components/BarDialog.vue +43 -0
  46. package/src/HeaderBar/components/BarTooltip.vue +33 -0
  47. package/src/HeaderBar/index.vue +513 -0
  48. package/src/NavTree/index.vue +345 -0
  49. package/src/SchemaConfig/index.vue +150 -0
  50. package/src/SidebarPane/index.vue +199 -0
  51. package/src/SynBarComponent/index.vue +31 -0
  52. package/src/assets/font/NotoSansSC.ttf +0 -0
  53. package/src/assets/img/header/edit.png +0 -0
  54. package/src/assets/img/header/link.png +0 -0
  55. package/src/assets/img/header/link.svg +9 -0
  56. package/src/assets/img/header/preview.png +0 -0
  57. package/src/assets/img/header/preview.svg +9 -0
  58. package/src/assets/img/header/redo.svg +1 -0
  59. package/src/assets/img/header/undo.svg +1 -0
  60. package/src/assets/img/tool/all-select.svg +9 -0
  61. package/src/assets/img/tool/all.svg +9 -0
  62. package/src/assets/img/tool/collect.svg +6 -0
  63. package/src/assets/img/tool/collection-select.svg +3 -0
  64. package/src/assets/img/tool/collection-tag.svg +5 -0
  65. package/src/assets/img/tool/info.svg +4 -0
  66. package/src/assets/img/tool/union.svg +4 -0
  67. package/src/components/ComponentTreeFavorites/components/List.vue +452 -0
  68. package/src/components/ComponentTreeFavorites/components/Tips.vue +108 -0
  69. package/src/components/ComponentTreeFavorites/index.vue +180 -0
  70. package/src/components/ImageGuide/index.vue +100 -0
  71. package/src/components.ts +23 -0
  72. package/src/composables/useComponentTree.ts +38 -0
  73. package/src/config/ace.config.ts +22 -0
  74. package/src/domain/EditorDomain.ts +265 -0
  75. package/src/editor.ts +645 -0
  76. package/src/editor.vue +380 -0
  77. package/src/formily/ActivityBar/index.ts +23 -0
  78. package/src/formily/ActivityBar/index.vue +121 -0
  79. package/src/formily/ComponentTree/index.ts +22 -0
  80. package/src/formily/DataBinding/index.ts +22 -0
  81. package/src/formily/DataBinding/index.vue +285 -0
  82. package/src/formily/DataSource/index.ts +22 -0
  83. package/src/formily/MenuTable/PageList.vue +132 -0
  84. package/src/formily/MenuTable/index.ts +19 -0
  85. package/src/formily/MenuTable/index.vue +218 -0
  86. package/src/formily/MenuTable/useMenuTable.ts +147 -0
  87. package/src/formily/NavTree/index.ts +20 -0
  88. package/src/formily/SidebarPane/index.ts +23 -0
  89. package/src/formily/SidebarPane/index.vue +174 -0
  90. package/src/formily/index.ts +12 -0
  91. package/src/index.ts +29 -0
  92. package/src/typings/vue-shim.d.ts +13 -0
  93. package/src/utils/base64.ts +5 -0
  94. package/src/utils/index.ts +57 -0
  95. package/test/case.ts +67 -0
  96. package/test/utils/index.test.ts +27 -0
  97. package/tsconfig.json +8 -0
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <el-tooltip
3
+ class="box-item"
4
+ effect="dark"
5
+ :content="content"
6
+ placement="bottom"
7
+ :show-after="showAfter"
8
+ :disabled="disabled"
9
+ >
10
+ <slot></slot>
11
+ <template #content>
12
+ <slot name="content"></slot>
13
+ </template>
14
+ </el-tooltip>
15
+ </template>
16
+
17
+ <script lang="ts" setup>
18
+ import { defineProps, withDefaults } from 'vue';
19
+
20
+ const props = withDefaults(
21
+ defineProps<{
22
+ content?: string;
23
+ showAfter?: number;
24
+ disabled?: boolean;
25
+ }>(),
26
+ {
27
+ showAfter: 1000,
28
+ disabled: false,
29
+ }
30
+ );
31
+ </script>
32
+
33
+ <style lang="scss" scoped></style>
@@ -0,0 +1,513 @@
1
+ <template>
2
+ <div class="header-bar">
3
+ <div class="header-bar__left">
4
+ <div class="title">
5
+ <span :class="functionData?.status?.value === '已发布' ? '' : 'status'">
6
+ {{ `${functionData?.status?.value ?? ''} · ` }}
7
+ </span>
8
+ <bar-tooltip
9
+ :show-after="0"
10
+ :content="functionData?.title?.value ?? ''"
11
+ >
12
+ <span>{{ functionData?.title?.value ?? '' }}</span>
13
+ </bar-tooltip>
14
+ </div>
15
+ <img
16
+ class="title-edit"
17
+ src="../assets/img/header/edit.png"
18
+ :class="[readOnly ? 'read-only' : '']"
19
+ @click="emitFunc('editTitle', functionData?.title?.key)"
20
+ />
21
+ </div>
22
+ <div class="header-bar__center">
23
+ <div class="history-btn" v-if="showDoBtn">
24
+ <bar-tooltip content="撤销">
25
+ <div
26
+ :class="[
27
+ 'undo',
28
+ functionData?.undo?.clickable ? '' : 'disable',
29
+ readOnly ? 'read-only' : '',
30
+ ]"
31
+ @click="onUndo"
32
+ >
33
+ <img src="../assets/img/header/undo.svg" />
34
+ </div>
35
+ </bar-tooltip>
36
+ <bar-tooltip content="重做">
37
+ <div
38
+ :class="[
39
+ 'redo',
40
+ functionData?.redo?.clickable ? '' : 'disable',
41
+ readOnly ? 'read-only' : '',
42
+ ]"
43
+ @click="onRedo"
44
+ >
45
+ <img src="../assets/img/header/redo.svg" />
46
+ </div>
47
+ </bar-tooltip>
48
+ </div>
49
+ <div class="label">页面尺寸</div>
50
+ <el-select
51
+ v-if="functionData && functionData.simulatorSizeList"
52
+ :key="functionData.simulatorSizeList.key"
53
+ v-model="curSelectViewPort.all"
54
+ style="width: 250px"
55
+ class="select-wrap"
56
+ placeholder="设备尺寸"
57
+ @change="selectView"
58
+ >
59
+ <el-option
60
+ v-for="opt in simulatorSizeList"
61
+ :key="opt.value.name"
62
+ :label="`${opt.value.label} (${opt.value.value.width} * ${opt.value.value.height})`"
63
+ :value="opt.value.name"
64
+ />
65
+ </el-select>
66
+ <bar-tooltip :content="`切换${viewPortTypeIsRow ? '竖屏' : '横屏'}`">
67
+ <div class="img-box" @click="onToggle">
68
+ <div :class="['box-1', viewPortTypeIsRow ? '' : 'inactive']" />
69
+ <div :class="['box-2', viewPortTypeIsRow ? 'inactive' : '']" />
70
+ <div :class="['box-3', viewPortTypeIsRow ? 'inactive' : '']" />
71
+ </div>
72
+ </bar-tooltip>
73
+ <bar-tooltip content="缩放画布">
74
+ <div class="scale-area">
75
+ <div
76
+ :class="['scale', percent < 15 ? 'disabled' : '']"
77
+ @click="onScale('-')"
78
+ >
79
+ -
80
+ </div>
81
+ <div class="percent">{{ percent }}%</div>
82
+ <div class="scale" @click="onScale('+')">+</div>
83
+ </div>
84
+ </bar-tooltip>
85
+ </div>
86
+ <div class="header-bar__right">
87
+ <div class="tips">
88
+ <bar-tooltip content="预览">
89
+ <div class="img-box" @click="$emit('preview')">
90
+ <img src="../assets/img/header/preview.svg" />
91
+ </div>
92
+ </bar-tooltip>
93
+ <bar-tooltip content="复制地址">
94
+ <div class="img-box" @click="$emit('copyUrl')">
95
+ <img src="../assets/img/header/link.svg" />
96
+ </div>
97
+ </bar-tooltip>
98
+ </div>
99
+ <div class="btns">
100
+ <bar-tooltip
101
+ :disabled="!showTooltip"
102
+ :show-after="0"
103
+ content="页面正在审核中,请完成审核后再来操作"
104
+ >
105
+ <span>
106
+ <el-button
107
+ :class="[readOnly ? 'read-only' : '']"
108
+ @click="emitFunc('save')"
109
+ >
110
+ 保存
111
+ </el-button>
112
+ </span>
113
+ </bar-tooltip>
114
+ <bar-tooltip
115
+ :disabled="!showTooltip"
116
+ :show-after="0"
117
+ content="页面正在审核中,请完成审核后再来操作"
118
+ >
119
+ <span style="margin-left: 12px">
120
+ <el-button
121
+ type="primary"
122
+ :class="[readOnly ? 'read-only' : '']"
123
+ @click="emitFunc('publish')"
124
+ color="#F5DBC1"
125
+ >
126
+ 发布
127
+ </el-button>
128
+ </span>
129
+ </bar-tooltip>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </template>
134
+
135
+ <script lang="ts" setup>
136
+ // @ts-nocheck
137
+ import {
138
+ ref,
139
+ reactive,
140
+ watch,
141
+ defineProps,
142
+ withDefaults,
143
+ defineEmits,
144
+ computed,
145
+ } from 'vue';
146
+
147
+ import { FunctionData, Simulator } from '@jt/low-code-core';
148
+ import { changeEnum2Array } from '../utils';
149
+ import BarTooltip from './components/BarTooltip.vue';
150
+ import { debounce } from '@jt/ark-util';
151
+
152
+ const props = withDefaults(
153
+ defineProps<{
154
+ functionData?: FunctionData;
155
+ readOnly?: boolean;
156
+ scalePercent?: number;
157
+ }>(),
158
+ {
159
+ functionData: null,
160
+ readOnly: false,
161
+ scalePercent: null,
162
+ }
163
+ );
164
+
165
+ const emits = defineEmits([
166
+ 'updateScale',
167
+ 'save',
168
+ 'preview',
169
+ 'publish',
170
+ 'editTitle',
171
+ 'copyUrl',
172
+ 'undo',
173
+ 'redo',
174
+ ]);
175
+
176
+ const curSelectViewPort = reactive({
177
+ phone: '',
178
+ pad: '',
179
+ desktop: '',
180
+ all: '',
181
+ });
182
+ let curViewPortConfig = reactive<Simulator>(null);
183
+
184
+ // 当前原始模拟器数据 没有则返回null😅 有什么用 => 只要切换竖屏或者改变百分比就返回null
185
+ // 如果通讯器不更新数据这里是不会变化的
186
+ const viewPort = computed(() => {
187
+ const width = parseInt(
188
+ props.functionData?.simulatorSizeList?.value?.data?.width
189
+ );
190
+ const height = parseInt(
191
+ props.functionData?.simulatorSizeList?.value?.data?.height
192
+ );
193
+ if (isNaN(width) || isNaN(height)) return null;
194
+ if (width && height) {
195
+ const viewPort = props.functionData.simulatorSizeList.value.options.find(
196
+ v => v.value.height === height && v.value.width === width
197
+ );
198
+ if (viewPort) return viewPort;
199
+ }
200
+ return null;
201
+ });
202
+
203
+ // 是否展示撤销重做按钮
204
+ const showDoBtn = computed(() => {
205
+ const isShowUndo = props.functionData?.undo?.value;
206
+ const isShowRedo = props.functionData?.redo?.value;
207
+ return isShowRedo && isShowUndo;
208
+ });
209
+
210
+ // 撤销重做改变缩放比例
211
+ watch(
212
+ () => props.scalePercent,
213
+ newVal => {
214
+ percent.value = newVal || 100;
215
+ }
216
+ );
217
+
218
+ // 当前原始模拟器宽高 重新选择和切换竖屏能改变它
219
+ const viewSize = ref({
220
+ width: 414,
221
+ height: 736,
222
+ });
223
+
224
+ // 是否展示提示弹窗
225
+ const showTooltip = computed(
226
+ () => props?.functionData?.status?.value === '审核中'
227
+ );
228
+ const simulatorSizeList = computed(() => {
229
+ if (props.functionData) {
230
+ return changeEnum2Array(props.functionData.simulatorSizeList.value.options);
231
+ }
232
+ return [];
233
+ });
234
+
235
+ watch(viewPort, val => {
236
+ if (val) {
237
+ curSelectViewPort.all = val.name;
238
+ curViewPortConfig = { ...val };
239
+ viewSize.value = { ...val.value };
240
+ }
241
+ });
242
+
243
+ const emitFunc = (key, value?) => {
244
+ if (!props.readOnly) emits(key, value);
245
+ };
246
+
247
+ const selectView = (name: string) => {
248
+ let curItem = {} as Simulator;
249
+ props.functionData.simulatorSizeList.value.options.forEach(item => {
250
+ if (item.name === name) {
251
+ const multiplier = percent.value / 100;
252
+ // 如果是竖屏
253
+ if (!viewPortTypeIsRow.value) {
254
+ curItem = Object.assign({
255
+ percent: percent.value,
256
+ }, item, {
257
+ value: {
258
+ normalWidth: item.value.width,
259
+ normalHeight: item.value.height,
260
+ width: item.value.width * multiplier,
261
+ height: item.value.height * multiplier,
262
+ },
263
+ });
264
+ } else {
265
+ curItem = Object.assign({
266
+ percent: percent.value,
267
+ }, item, {
268
+ value: {
269
+ normalWidth: item.value.width,
270
+ normalHeight: item.value.height,
271
+ width: item.value.height * multiplier,
272
+ height: item.value.width * multiplier,
273
+ },
274
+ });
275
+ }
276
+ curViewPortConfig = curItem;
277
+ viewSize.value = item.value;
278
+ }
279
+ });
280
+ emits('updateScale', {
281
+ key: props.functionData.simulatorSizeList.key,
282
+ scale: curItem.value,
283
+ });
284
+ };
285
+
286
+ // 缩放百分比
287
+ const percent = ref(100);
288
+ const onScale = (type: string) => {
289
+ percent.value =
290
+ type === '+'
291
+ ? percent.value + 15
292
+ : percent.value >= 15
293
+ ? percent.value - 15
294
+ : percent.value;
295
+
296
+ if (curViewPortConfig?.name) {
297
+ // 需要用原始大小去计算 => 但是只要切换竖屏或者改变百分比就拿不到原始大小
298
+ const { width, height } = viewSize.value;
299
+ const curScale = {
300
+ normalWidth: width,
301
+ normalHeight: height,
302
+ width: (width * percent.value) / 100,
303
+ height: (height * percent.value) / 100,
304
+ percent: percent.value,
305
+ };
306
+ curViewPortConfig.value = curScale;
307
+ emits('updateScale', {
308
+ key: props.functionData.simulatorSizeList.key,
309
+ scale: curScale,
310
+ });
311
+ }
312
+ };
313
+
314
+ // 竖屏激活
315
+ const viewPortTypeIsRow = ref(false);
316
+ const onToggle = () => {
317
+ viewPortTypeIsRow.value = !viewPortTypeIsRow.value;
318
+ if (curViewPortConfig?.name) {
319
+ const { width, height } = curViewPortConfig.value;
320
+ const curScale = { width: height, height: width };
321
+ curViewPortConfig.value = curScale;
322
+ viewSize.value = curScale;
323
+ emits('updateScale', {
324
+ key: props.functionData.simulatorSizeList.key,
325
+ scale: curScale,
326
+ });
327
+ }
328
+ };
329
+
330
+ // 撤销
331
+ const onUndo = debounce(() => {
332
+ emits('undo', {
333
+ key: props.functionData.undo.key,
334
+ });
335
+ }, 100);
336
+
337
+ // 重做
338
+ const onRedo = debounce(() => {
339
+ emits('redo', {
340
+ key: props.functionData.redo.key,
341
+ });
342
+ }, 100);
343
+ </script>
344
+
345
+ <style lang="scss" scoped>
346
+ .header-bar {
347
+ display: flex;
348
+ align-items: center;
349
+ width: 100%;
350
+ white-space: nowrap;
351
+ // overflow-x: auto;
352
+ .read-only {
353
+ opacity: 0.4;
354
+ pointer-events: none;
355
+ cursor: not-allowed;
356
+ }
357
+ &__left {
358
+ flex: 1 1 320px;
359
+ display: flex;
360
+ align-items: center;
361
+ .title {
362
+ margin-right: 10px;
363
+ font-weight: 500;
364
+ font-size: 16px;
365
+ line-height: 22px;
366
+ color: #4b515e;
367
+ width: 300px;
368
+ white-space: nowrap;
369
+ overflow: hidden;
370
+ text-overflow: ellipsis;
371
+ .status {
372
+ color: #b7b7b7;
373
+ }
374
+ }
375
+ .title-edit {
376
+ cursor: pointer;
377
+ }
378
+ }
379
+ &__center {
380
+ flex: 1 1 auto;
381
+ display: flex;
382
+ align-items: center;
383
+ justify-content: center;
384
+ .label {
385
+ font-size: 14px;
386
+ line-height: 20px;
387
+ color: #1e1917;
388
+ }
389
+ .select-wrap {
390
+ margin: 0 24px 0 9px;
391
+ }
392
+ .img-box {
393
+ position: relative;
394
+ .box-1 {
395
+ @extend .box-2;
396
+ transform: rotate(90deg);
397
+ transform-origin: 6px 14px;
398
+ }
399
+ .box-2 {
400
+ box-sizing: border-box;
401
+ height: 20px;
402
+ width: 12px;
403
+ position: absolute;
404
+ left: 15px;
405
+ top: 10px;
406
+ border: 1px solid #4f5052;
407
+ border-radius: 2px;
408
+ background-color: #fff;
409
+ z-index: 10;
410
+ }
411
+ .box-3 {
412
+ position: absolute;
413
+ height: 1px;
414
+ width: 3px;
415
+ top: 26px;
416
+ left: 19px;
417
+ background-color: #4f5052;
418
+ z-index: 10;
419
+ }
420
+ .inactive {
421
+ opacity: 0.2;
422
+ z-index: 1;
423
+ }
424
+ }
425
+ .scale-area {
426
+ margin-left: 10px;
427
+ font-family: 'Noto Sans SC';
428
+ width: 150px;
429
+ display: flex;
430
+ align-items: center;
431
+ justify-content: space-evenly;
432
+ background-color: #fff;
433
+ border-radius: 6px;
434
+ .scale {
435
+ font-size: 20px;
436
+ cursor: pointer;
437
+ flex: 1;
438
+ text-align: center;
439
+ }
440
+ .disabled {
441
+ cursor: not-allowed;
442
+ color: #a8abb2;
443
+ }
444
+ .percent {
445
+ width: 62px;
446
+ height: 40px;
447
+ line-height: 40px;
448
+ text-align: center;
449
+ border-left: 1px solid #dbdbdb;
450
+ border-right: 1px solid #dbdbdb;
451
+ }
452
+ }
453
+ .history-btn {
454
+ margin-left: 20px;
455
+ margin-right: 10px;
456
+ display: flex;
457
+ .undo,
458
+ .redo {
459
+ display: flex;
460
+ margin-right: 10px;
461
+ cursor: pointer;
462
+ line-height: 40px;
463
+ img {
464
+ width: 25px;
465
+ vertical-align: middle;
466
+ }
467
+ }
468
+ .disable {
469
+ pointer-events: none;
470
+ cursor: not-allowed !important;
471
+ opacity: 0.3;
472
+ }
473
+ }
474
+ }
475
+ &__right {
476
+ flex: 1 1 485px;
477
+ display: flex;
478
+ align-items: center;
479
+ justify-content: space-between;
480
+ .tips {
481
+ .img-box:first-child {
482
+ margin-right: 10px;
483
+ }
484
+ }
485
+ .btns {
486
+ .el-button:first-child {
487
+ &:focus,
488
+ &:hover {
489
+ color: #704528;
490
+ border-color: #f5dbc1;
491
+ background-color: #f5dbc1;
492
+ }
493
+ }
494
+ .el-button--primary {
495
+ color: #704528;
496
+ }
497
+ }
498
+ }
499
+
500
+ .img-box {
501
+ display: inline-block;
502
+ width: 51px;
503
+ height: 40px;
504
+ line-height: 40px;
505
+ text-align: center;
506
+ background-color: #fff;
507
+ cursor: pointer;
508
+ img {
509
+ vertical-align: middle;
510
+ }
511
+ }
512
+ }
513
+ </style>