@tmagic/editor 1.5.0 → 1.5.1

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 (72) hide show
  1. package/dist/{style.css → tmagic-editor.css} +153 -6
  2. package/dist/tmagic-editor.js +906 -527
  3. package/dist/tmagic-editor.umd.cjs +931 -551
  4. package/package.json +10 -10
  5. package/src/Editor.vue +18 -5
  6. package/src/components/CodeBlockEditor.vue +3 -3
  7. package/src/components/CodeParams.vue +2 -2
  8. package/src/components/ContentMenu.vue +18 -18
  9. package/src/components/FloatingBox.vue +3 -3
  10. package/src/components/Resizer.vue +4 -4
  11. package/src/components/ScrollBar.vue +3 -3
  12. package/src/components/ScrollViewer.vue +3 -3
  13. package/src/components/SplitView.vue +2 -2
  14. package/src/components/ToolButton.vue +2 -1
  15. package/src/editorProps.ts +3 -1
  16. package/src/fields/DataSourceInput.vue +2 -2
  17. package/src/fields/DataSourceMethods.vue +2 -2
  18. package/src/fields/DataSourceMocks.vue +0 -1
  19. package/src/fields/EventSelect.vue +0 -1
  20. package/src/fields/KeyValue.vue +2 -2
  21. package/src/hooks/use-code-block-edit.ts +2 -2
  22. package/src/hooks/use-getso.ts +7 -7
  23. package/src/index.ts +2 -1
  24. package/src/layouts/CodeEditor.vue +2 -2
  25. package/src/layouts/Framework.vue +5 -8
  26. package/src/layouts/NavMenu.vue +2 -2
  27. package/src/layouts/page-bar/PageBar.vue +3 -3
  28. package/src/layouts/page-bar/PageBarScrollContainer.vue +3 -3
  29. package/src/layouts/props-panel/FormPanel.vue +123 -0
  30. package/src/layouts/props-panel/PropsPanel.vue +146 -0
  31. package/src/layouts/props-panel/use-style-panel.ts +29 -0
  32. package/src/layouts/sidebar/Sidebar.vue +4 -1
  33. package/src/layouts/sidebar/code-block/CodeBlockList.vue +12 -1
  34. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +35 -4
  35. package/src/layouts/sidebar/code-block/useContentMenu.ts +83 -0
  36. package/src/layouts/sidebar/data-source/DataSourceList.vue +8 -8
  37. package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +40 -4
  38. package/src/layouts/sidebar/data-source/useContentMenu.ts +81 -0
  39. package/src/layouts/sidebar/layer/LayerMenu.vue +7 -13
  40. package/src/layouts/sidebar/layer/LayerPanel.vue +11 -4
  41. package/src/layouts/sidebar/layer/use-click.ts +2 -2
  42. package/src/layouts/sidebar/layer/use-keybinding.ts +2 -2
  43. package/src/layouts/workspace/Workspace.vue +9 -2
  44. package/src/layouts/workspace/viewer/NodeListMenu.vue +3 -3
  45. package/src/layouts/workspace/viewer/Stage.vue +18 -6
  46. package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
  47. package/src/layouts/workspace/viewer/ViewerMenu.vue +4 -6
  48. package/src/services/storage.ts +2 -1
  49. package/src/services/ui.ts +1 -0
  50. package/src/theme/common/var.scss +12 -10
  51. package/src/theme/component-list-panel.scss +9 -7
  52. package/src/theme/content-menu.scss +7 -5
  53. package/src/theme/data-source.scss +3 -1
  54. package/src/theme/floating-box.scss +4 -2
  55. package/src/theme/framework.scss +7 -5
  56. package/src/theme/index.scss +4 -5
  57. package/src/theme/key-value.scss +2 -2
  58. package/src/theme/layer-panel.scss +3 -1
  59. package/src/theme/layout.scss +1 -1
  60. package/src/theme/nav-menu.scss +7 -5
  61. package/src/theme/page-bar.scss +17 -15
  62. package/src/theme/props-panel.scss +81 -1
  63. package/src/theme/resizer.scss +1 -1
  64. package/src/theme/sidebar.scss +4 -2
  65. package/src/theme/stage.scss +3 -1
  66. package/src/theme/theme.scss +28 -28
  67. package/src/theme/tree.scss +14 -12
  68. package/src/type.ts +8 -0
  69. package/src/utils/content-menu.ts +2 -2
  70. package/src/utils/props.ts +45 -3
  71. package/types/index.d.ts +1796 -1230
  72. package/src/layouts/PropsPanel.vue +0 -131
@@ -1,3 +1,5 @@
1
+ @use "common/var" as *;
2
+
1
3
  .m-editor-page-bar-tabs {
2
4
  position: fixed;
3
5
  bottom: 0;
@@ -9,24 +11,24 @@
9
11
  .m-editor-page-list-item {
10
12
  display: flex;
11
13
  width: 100%;
12
- height: $--page-bar-height;
13
- line-height: $--page-bar-height;
14
- color: $--font-color;
14
+ height: $page-bar-height;
15
+ line-height: $page-bar-height;
16
+ color: $font-color;
15
17
  z-index: 2;
16
18
  overflow: hidden;
17
19
  &:hover {
18
- background-color: $--hover-color;
20
+ background-color: $hover-color;
19
21
  }
20
22
  }
21
23
 
22
24
  .m-editor-page-bar {
23
25
  display: flex;
24
26
  width: 100%;
25
- height: $--page-bar-height;
26
- line-height: $--page-bar-height;
27
- color: $--font-color;
27
+ height: $page-bar-height;
28
+ line-height: $page-bar-height;
29
+ color: $font-color;
28
30
  background-color: #f3f3f3;
29
- border-top: 1px solid $--border-color;
31
+ border-top: 1px solid $border-color;
30
32
  z-index: 2;
31
33
  overflow: hidden;
32
34
 
@@ -38,7 +40,7 @@
38
40
  &-item {
39
41
  padding: 0 10px;
40
42
  cursor: pointer;
41
- border-right: 1px solid $--border-color;
43
+ border-right: 1px solid $border-color;
42
44
  display: flex;
43
45
  justify-items: center;
44
46
  align-items: center;
@@ -60,7 +62,7 @@
60
62
 
61
63
  .icon-active {
62
64
  font-weight: bold;
63
- color: $--theme-color;
65
+ color: $theme-color;
64
66
  }
65
67
  }
66
68
 
@@ -96,16 +98,16 @@
96
98
  padding: 5px 14px;
97
99
 
98
100
  .tmagic-design-button {
99
- color: $--font-color;
101
+ color: $font-color;
100
102
  }
101
103
 
102
104
  &:hover {
103
- background-color: $--hover-color;
105
+ background-color: $hover-color;
104
106
  }
105
107
 
106
108
  &.active {
107
109
  .tmagic-design-button {
108
- color: $--theme-color;
110
+ color: $theme-color;
109
111
  }
110
112
  }
111
113
  }
@@ -113,8 +115,8 @@
113
115
 
114
116
  .m-editor-page-bar-search-panel {
115
117
  position: absolute;
116
- bottom: $--page-bar-height;
117
- border: 1px solid $--border-color;
118
+ bottom: $page-bar-height;
119
+ border: 1px solid $border-color;
118
120
  padding: 6px 10px;
119
121
  width: 100%;
120
122
  box-sizing: border-box;
@@ -1,5 +1,78 @@
1
+ @use "common/var" as *;
2
+
1
3
  .m-editor-props-panel {
2
- padding: 0 10px 50px 10px;
4
+ height: 100%;
5
+ position: relative;
6
+
7
+ --props-style-panel-width: 300px;
8
+
9
+ .m-editor-props-form-panel {
10
+ padding-bottom: 10px;
11
+ position: relative;
12
+ height: 100%;
13
+ box-sizing: border-box;
14
+
15
+ .tmagic-design-scrollbar {
16
+ height: 100%;
17
+ }
18
+ }
19
+
20
+ .m-editor-props-property-panel {
21
+ &.show-style-panel {
22
+ padding-right: var(--props-style-panel-width);
23
+
24
+ .m-editor-props-panel-src-icon {
25
+ right: calc(15px + var(--props-style-panel-width));
26
+ }
27
+ }
28
+
29
+ .tmagic-design-form {
30
+ padding-right: 10px;
31
+ padding-left: 10px;
32
+
33
+ > .m-container-tab {
34
+ > .tmagic-design-tabs {
35
+ > .el-tabs__content {
36
+ padding-top: 55px;
37
+ }
38
+ > .el-tabs__header.is-top {
39
+ position: absolute;
40
+ top: 0;
41
+ width: 100%;
42
+ background: #fff;
43
+ z-index: 2;
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ .m-editor-props-style-panel {
51
+ position: absolute;
52
+ width: var(--props-style-panel-width);
53
+ right: 0;
54
+ top: 0;
55
+ background: #fff;
56
+ z-index: 12;
57
+
58
+ $style-panel-title-height: 38px;
59
+
60
+ .tmagic-design-scrollbar {
61
+ height: calc(100% - $style-panel-title-height - 1px);
62
+ }
63
+
64
+ .m-editor-props-style-panel-title {
65
+ text-align: center;
66
+ font-size: 14px;
67
+ font-weight: 600;
68
+ padding: 0 5px;
69
+ height: $style-panel-title-height;
70
+ display: flex;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+ border-bottom: 2px solid $border-color;
74
+ }
75
+ }
3
76
 
4
77
  .m-editor-props-panel-src-icon {
5
78
  position: absolute;
@@ -8,6 +81,13 @@
8
81
  z-index: 30;
9
82
  }
10
83
 
84
+ .m-editor-props-panel-style-icon {
85
+ position: absolute;
86
+ right: 15px;
87
+ bottom: 60px;
88
+ z-index: 30;
89
+ }
90
+
11
91
  .m-editor-props-panel-src-code.magic-code-editor {
12
92
  position: absolute;
13
93
  left: 0;
@@ -20,7 +20,7 @@
20
20
  }
21
21
  }
22
22
 
23
- &.m-editor-resizer-draging {
23
+ &.m-editor-resizer-dragging {
24
24
  &::after {
25
25
  content: "";
26
26
  position: absolute;
@@ -1,9 +1,11 @@
1
+ @use "common/var" as *;
2
+
1
3
  .m-editor-sidebar {
2
4
  display: flex;
3
5
  height: 100%;
4
6
 
5
7
  .m-editor-sidebar-header {
6
- background: $--sidebar-heder-background-color;
8
+ background: $sidebar-heder-background-color;
7
9
  height: 100%;
8
10
  width: 40px;
9
11
 
@@ -16,7 +18,7 @@
16
18
  cursor: pointer;
17
19
 
18
20
  &.is-active {
19
- background: $--sidebar-content-background-color;
21
+ background: $sidebar-content-background-color;
20
22
 
21
23
  i {
22
24
  color: #353140;
@@ -1,7 +1,9 @@
1
+ @use "common/var" as *;
2
+
1
3
  .m-editor-stage {
2
4
  position: relative;
3
5
  width: 100%;
4
- height: calc(100% - #{$--page-bar-height});
6
+ height: calc(100% - #{$page-bar-height});
5
7
  overflow: hidden;
6
8
  display: flex;
7
9
  justify-content: center;
@@ -1,28 +1,28 @@
1
- @import "./search-input.scss";
2
- @import "./nav-menu.scss";
3
- @import "./framework.scss";
4
- @import "./sidebar.scss";
5
- @import "./layer-panel.scss";
6
- @import "./component-list-panel.scss";
7
- @import "./resizer.scss";
8
- @import "./workspace.scss";
9
- @import "./page-bar.scss";
10
- @import "./props-panel.scss";
11
- @import "./content-menu.scss";
12
- @import "./stage.scss";
13
- @import "./code-editor.scss";
14
- @import "./icon.scss";
15
- @import "./code-block.scss";
16
- @import "./event.scss";
17
- @import "./layout.scss";
18
- @import "./breadcrumb.scss";
19
- @import "./data-source.scss";
20
- @import "./data-source-fields.scss";
21
- @import "./data-source-methods.scss";
22
- @import "./data-source-input.scss";
23
- @import "./key-value.scss";
24
- @import "./tree.scss";
25
- @import "./floating-box.scss";
26
- @import "./page-fragment-select.scss";
27
- @import "./data-source-field.scss";
28
- @import "./data-source-field-select.scss";
1
+ @use "./search-input.scss";
2
+ @use "./nav-menu.scss";
3
+ @use "./framework.scss";
4
+ @use "./sidebar.scss";
5
+ @use "./layer-panel.scss";
6
+ @use "./component-list-panel.scss";
7
+ @use "./resizer.scss";
8
+ @use "./workspace.scss";
9
+ @use "./page-bar.scss";
10
+ @use "./props-panel.scss";
11
+ @use "./content-menu.scss";
12
+ @use "./stage.scss";
13
+ @use "./code-editor.scss";
14
+ @use "./icon.scss";
15
+ @use "./code-block.scss";
16
+ @use "./event.scss";
17
+ @use "./layout.scss";
18
+ @use "./breadcrumb.scss";
19
+ @use "./data-source.scss";
20
+ @use "./data-source-fields.scss";
21
+ @use "./data-source-methods.scss";
22
+ @use "./data-source-input.scss";
23
+ @use "./key-value.scss";
24
+ @use "./tree.scss";
25
+ @use "./floating-box.scss";
26
+ @use "./page-fragment-select.scss";
27
+ @use "./data-source-field.scss";
28
+ @use "./data-source-field-select.scss";
@@ -1,6 +1,8 @@
1
+ @use "common/var" as *;
2
+
1
3
  .m-editor-tree {
2
- $--node-height: 22px;
3
- color: $--font-color;
4
+ $node-height: 22px;
5
+ color: $font-color;
4
6
  font-size: 13px;
5
7
 
6
8
  .m-editor-tree-node {
@@ -12,31 +14,31 @@
12
14
  align-items: center;
13
15
 
14
16
  &:hover {
15
- background-color: $--hover-color;
16
- color: $--font-color;
17
+ background-color: $hover-color;
18
+ color: $font-color;
17
19
  }
18
20
 
19
21
  &.selected {
20
- background-color: $--theme-color;
21
- color: $--hover-color;
22
+ background-color: $theme-color;
23
+ color: $hover-color;
22
24
  }
23
25
 
24
26
  &.drag-inner {
25
27
  .tree-node-content {
26
- background-color: rgba($color: $--theme-color, $alpha: 0.5);
27
- color: $--hover-color;
28
+ background-color: rgba($color: $theme-color, $alpha: 0.5);
29
+ color: $hover-color;
28
30
  }
29
31
  }
30
32
 
31
33
  &.drag-before {
32
34
  .tree-node-content {
33
- border-top-color: rgba($color: $--theme-color, $alpha: 0.5);
35
+ border-top-color: rgba($color: $theme-color, $alpha: 0.5);
34
36
  }
35
37
  }
36
38
 
37
39
  &.drag-after {
38
40
  .tree-node-content {
39
- border-bottom-color: rgba($color: $--theme-color, $alpha: 0.5);
41
+ border-bottom-color: rgba($color: $theme-color, $alpha: 0.5);
40
42
  }
41
43
  }
42
44
 
@@ -50,11 +52,11 @@
50
52
  display: flex;
51
53
  flex: 1;
52
54
  justify-content: space-between;
53
- height: $--node-height;
55
+ height: $node-height;
54
56
  border-top: 2px solid transparent;
55
57
  border-bottom: 2px solid transparent;
56
58
  .tree-node-label {
57
- line-height: $--node-height;
59
+ line-height: $node-height;
58
60
  flex: 1;
59
61
  width: 100px;
60
62
  overflow: hidden;
package/src/type.ts CHANGED
@@ -231,6 +231,8 @@ export interface UiState {
231
231
  uiSelectMode: boolean;
232
232
  /** 是否显示整个配置源码, true: 显示, false: 不显示,默认为false */
233
233
  showSrc: boolean;
234
+ /** 是否将样式配置单独一列显示, true: 显示, false: 不显示,默认为true */
235
+ showStylePanel: boolean;
234
236
  /** 画布显示放大倍数,默认为 1 */
235
237
  zoom: number;
236
238
  /** 画布容器的宽高 */
@@ -766,6 +768,7 @@ export type SyncHookPlugin<
766
768
 
767
769
  export interface EventBusEvent {
768
770
  'edit-data-source': [id: string];
771
+ 'remove-data-source': [id: string];
769
772
  'edit-code': [id: string];
770
773
  }
771
774
 
@@ -787,3 +790,8 @@ export interface PageBarSortOptions extends PartSortableOptions {
787
790
  /** 在onStart之前调用 */
788
791
  beforeStart?: (event: SortableEvent, sortable: Sortable) => void | Promise<void>;
789
792
  }
793
+
794
+ export type CustomContentMenuFunction = (
795
+ menus: (MenuButton | MenuComponent)[],
796
+ type: 'layer' | 'data-source' | 'viewer' | 'code-block',
797
+ ) => (MenuButton | MenuComponent)[];
@@ -1,4 +1,4 @@
1
- import { computed, markRaw, Ref } from 'vue';
1
+ import { computed, markRaw, type ShallowRef } from 'vue';
2
2
  import { CopyDocument, Delete, DocumentCopy } from '@element-plus/icons-vue';
3
3
 
4
4
  import { Id, MContainer, NodeType } from '@tmagic/core';
@@ -33,7 +33,7 @@ export const useCopyMenu = (): MenuButton => ({
33
33
  },
34
34
  });
35
35
 
36
- export const usePasteMenu = (menu?: Ref<InstanceType<typeof ContentMenu> | undefined>): MenuButton => ({
36
+ export const usePasteMenu = (menu?: ShallowRef<InstanceType<typeof ContentMenu> | null>): MenuButton => ({
37
37
  type: 'button',
38
38
  text: '粘贴',
39
39
  icon: markRaw(DocumentCopy),
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import { NODE_CONDS_KEY } from '@tmagic/core';
21
+ import { tMagicMessage } from '@tmagic/design';
21
22
  import type { FormConfig, FormState, TabPaneConfig } from '@tmagic/form';
22
23
 
23
24
  export const arrayOptions = [
@@ -41,6 +42,7 @@ export const numberOptions = [
41
42
 
42
43
  export const styleTabConfig: TabPaneConfig = {
43
44
  title: '样式',
45
+ display: ({ services }: any) => !(services.uiService.get('showStylePanel') ?? true),
44
46
  items: [
45
47
  {
46
48
  name: 'style',
@@ -53,6 +55,7 @@ export const styleTabConfig: TabPaneConfig = {
53
55
  type: 'data-source-field-select',
54
56
  name: 'position',
55
57
  text: '固定定位',
58
+ labelPosition: 'left',
56
59
  checkStrictly: false,
57
60
  dataSourceFieldType: ['string'],
58
61
  fieldConfig: {
@@ -112,6 +115,27 @@ export const styleTabConfig: TabPaneConfig = {
112
115
  type: 'fieldset',
113
116
  legend: '盒子',
114
117
  items: [
118
+ {
119
+ type: 'data-source-field-select',
120
+ name: 'display',
121
+ text: 'display',
122
+ checkStrictly: false,
123
+ dataSourceFieldType: ['string'],
124
+ fieldConfig: {
125
+ type: 'select',
126
+ clearable: true,
127
+ allowCreate: true,
128
+ options: [
129
+ { text: 'block', value: 'block' },
130
+ { text: 'flex', value: 'flex' },
131
+ { text: 'none', value: 'none' },
132
+ { text: 'inline-block', value: 'inline-block' },
133
+ { text: 'grid', value: 'grid' },
134
+ { text: 'inline', value: 'inline' },
135
+ { text: 'initial', value: 'initial' },
136
+ ],
137
+ },
138
+ },
115
139
  {
116
140
  type: 'data-source-field-select',
117
141
  name: 'width',
@@ -140,6 +164,8 @@ export const styleTabConfig: TabPaneConfig = {
140
164
  dataSourceFieldType: ['string'],
141
165
  fieldConfig: {
142
166
  type: 'select',
167
+ clearable: true,
168
+ allowCreate: true,
143
169
  options: [
144
170
  { text: 'visible', value: 'visible' },
145
171
  { text: 'hidden', value: 'hidden' },
@@ -147,6 +173,7 @@ export const styleTabConfig: TabPaneConfig = {
147
173
  { text: 'scroll', value: 'scroll' },
148
174
  { text: 'auto', value: 'auto' },
149
175
  { text: 'overlay', value: 'overlay' },
176
+ { text: 'initial', value: 'initial' },
150
177
  ],
151
178
  },
152
179
  },
@@ -213,7 +240,7 @@ export const styleTabConfig: TabPaneConfig = {
213
240
  checkStrictly: false,
214
241
  dataSourceFieldType: ['string'],
215
242
  fieldConfig: {
216
- type: 'text',
243
+ type: 'img-upload',
217
244
  },
218
245
  },
219
246
  {
@@ -344,11 +371,13 @@ export const advancedTabConfig: TabPaneConfig = {
344
371
  {
345
372
  name: 'created',
346
373
  text: 'created',
374
+ labelPosition: 'top',
347
375
  type: 'code-select',
348
376
  },
349
377
  {
350
378
  name: 'mounted',
351
379
  text: 'mounted',
380
+ labelPosition: 'top',
352
381
  type: 'code-select',
353
382
  },
354
383
  ],
@@ -389,8 +418,21 @@ export const fillConfig = (config: FormConfig = [], labelWidth = '80px'): FormCo
389
418
  // 组件id,必须要有
390
419
  {
391
420
  name: 'id',
392
- type: 'display',
393
- text: 'id',
421
+ text: 'ID',
422
+ type: 'text',
423
+ disabled: true,
424
+ append: {
425
+ type: 'button',
426
+ text: '复制',
427
+ handler: async (vm, { model }) => {
428
+ try {
429
+ await navigator.clipboard.writeText(`${model.id}`);
430
+ tMagicMessage.success('已复制');
431
+ } catch (err) {
432
+ tMagicMessage.error('复制失败');
433
+ }
434
+ },
435
+ },
394
436
  },
395
437
  {
396
438
  name: 'name',