@tmagic/editor 1.5.2 → 1.5.4

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 (89) hide show
  1. package/dist/style.css +366 -6
  2. package/dist/tmagic-editor.js +1749 -829
  3. package/dist/tmagic-editor.umd.cjs +1764 -843
  4. package/package.json +7 -7
  5. package/src/components/CodeBlockEditor.vue +3 -3
  6. package/src/components/CodeParams.vue +2 -2
  7. package/src/components/ContentMenu.vue +13 -13
  8. package/src/components/FloatingBox.vue +9 -9
  9. package/src/components/Resizer.vue +2 -2
  10. package/src/components/ScrollBar.vue +6 -7
  11. package/src/components/ScrollViewer.vue +6 -6
  12. package/src/components/SplitView.vue +3 -3
  13. package/src/fields/DataSourceInput.vue +3 -3
  14. package/src/fields/DataSourceMethods.vue +4 -4
  15. package/src/fields/DisplayConds.vue +2 -1
  16. package/src/fields/StyleSetter/Index.vue +69 -0
  17. package/src/fields/StyleSetter/components/BackgroundPosition.vue +71 -0
  18. package/src/fields/StyleSetter/components/Border.vue +104 -0
  19. package/src/fields/StyleSetter/components/Box.vue +73 -0
  20. package/src/fields/StyleSetter/components/Position.vue +54 -0
  21. package/src/fields/StyleSetter/icons/background-position/LeftBottom.vue +7 -0
  22. package/src/fields/StyleSetter/icons/background-position/LeftCenter.vue +7 -0
  23. package/src/fields/StyleSetter/icons/background-position/LeftTop.vue +12 -0
  24. package/src/fields/StyleSetter/icons/background-position/index.ts +3 -0
  25. package/src/fields/StyleSetter/icons/background-repeat/NoRepeat.vue +8 -0
  26. package/src/fields/StyleSetter/icons/background-repeat/Repeat.vue +31 -0
  27. package/src/fields/StyleSetter/icons/background-repeat/RepeatX.vue +8 -0
  28. package/src/fields/StyleSetter/icons/background-repeat/RepeatY.vue +8 -0
  29. package/src/fields/StyleSetter/icons/background-repeat/index.ts +4 -0
  30. package/src/fields/StyleSetter/icons/display/Block.vue +7 -0
  31. package/src/fields/StyleSetter/icons/display/Flex.vue +7 -0
  32. package/src/fields/StyleSetter/icons/display/Inline.vue +7 -0
  33. package/src/fields/StyleSetter/icons/display/InlineBlock.vue +7 -0
  34. package/src/fields/StyleSetter/icons/display/None.vue +7 -0
  35. package/src/fields/StyleSetter/icons/display/index.ts +5 -0
  36. package/src/fields/StyleSetter/icons/flex-direction/Column.vue +7 -0
  37. package/src/fields/StyleSetter/icons/flex-direction/ColumnReverse.vue +7 -0
  38. package/src/fields/StyleSetter/icons/flex-direction/Row.vue +7 -0
  39. package/src/fields/StyleSetter/icons/flex-direction/RowReverse.vue +7 -0
  40. package/src/fields/StyleSetter/icons/flex-direction/index.ts +4 -0
  41. package/src/fields/StyleSetter/icons/justify-content/Center.vue +5 -0
  42. package/src/fields/StyleSetter/icons/justify-content/FlexEnd.vue +5 -0
  43. package/src/fields/StyleSetter/icons/justify-content/FlexStart.vue +5 -0
  44. package/src/fields/StyleSetter/icons/justify-content/SpaceAround.vue +7 -0
  45. package/src/fields/StyleSetter/icons/justify-content/SpaceBetween.vue +5 -0
  46. package/src/fields/StyleSetter/icons/justify-content/index.ts +5 -0
  47. package/src/fields/StyleSetter/icons/text-align/Center.vue +7 -0
  48. package/src/fields/StyleSetter/icons/text-align/Left.vue +7 -0
  49. package/src/fields/StyleSetter/icons/text-align/Right.vue +7 -0
  50. package/src/fields/StyleSetter/icons/text-align/index.ts +3 -0
  51. package/src/fields/StyleSetter/pro/Background.vue +78 -0
  52. package/src/fields/StyleSetter/pro/Border.vue +35 -0
  53. package/src/fields/StyleSetter/pro/Font.vue +90 -0
  54. package/src/fields/StyleSetter/pro/Layout.vue +164 -0
  55. package/src/fields/StyleSetter/pro/Position.vue +48 -0
  56. package/src/fields/StyleSetter/pro/index.ts +5 -0
  57. package/src/hooks/use-code-block-edit.ts +5 -5
  58. package/src/index.ts +3 -0
  59. package/src/initService.ts +104 -66
  60. package/src/layouts/CodeEditor.vue +6 -6
  61. package/src/layouts/Framework.vue +5 -5
  62. package/src/layouts/NavMenu.vue +6 -3
  63. package/src/layouts/page-bar/PageBar.vue +13 -13
  64. package/src/layouts/page-bar/PageBarScrollContainer.vue +12 -11
  65. package/src/layouts/props-panel/FormPanel.vue +7 -7
  66. package/src/layouts/props-panel/PropsPanel.vue +36 -4
  67. package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +3 -3
  68. package/src/layouts/sidebar/layer/LayerMenu.vue +2 -2
  69. package/src/layouts/sidebar/layer/LayerPanel.vue +5 -4
  70. package/src/layouts/sidebar/layer/use-click.ts +4 -6
  71. package/src/layouts/workspace/viewer/NodeListMenu.vue +5 -5
  72. package/src/layouts/workspace/viewer/Stage.vue +13 -13
  73. package/src/layouts/workspace/viewer/StageOverlay.vue +2 -2
  74. package/src/layouts/workspace/viewer/ViewerMenu.vue +3 -3
  75. package/src/services/componentList.ts +2 -2
  76. package/src/services/dep.ts +8 -2
  77. package/src/services/editor.ts +2 -2
  78. package/src/services/stageOverlay.ts +2 -2
  79. package/src/services/ui.ts +2 -2
  80. package/src/theme/props-panel.scss +13 -0
  81. package/src/theme/resizer.scss +2 -2
  82. package/src/theme/style-setter/background.scss +113 -0
  83. package/src/theme/style-setter/border.scss +53 -0
  84. package/src/theme/style-setter/index.scss +28 -0
  85. package/src/theme/style-setter/layout.scss +199 -0
  86. package/src/theme/theme.scss +1 -0
  87. package/src/utils/idle-task.ts +26 -10
  88. package/src/utils/props.ts +52 -297
  89. package/types/index.d.ts +432 -170
@@ -0,0 +1,113 @@
1
+ .background-position-container {
2
+ display: flex;
3
+ width: 100%;
4
+ .presets-value-list {
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+ width: 80px;
8
+ height: auto;
9
+ .el-button {
10
+ & + .el-button {
11
+ margin-left: 2px;
12
+ }
13
+ &:nth-child(3n + 1) {
14
+ margin-left: 0 !important;
15
+ }
16
+ }
17
+
18
+ .position-icon {
19
+ position: relative;
20
+ width: 14px;
21
+ height: 14px;
22
+ border: 1px solid #1d1f24;
23
+ &.active {
24
+ background-color: var(--el-color-primary);
25
+ &::after {
26
+ border: 1px solid #fff;
27
+ }
28
+ }
29
+ &::after {
30
+ position: absolute;
31
+ content: "";
32
+ border: 1px solid #1d1f24;
33
+ box-sizing: border-box;
34
+ }
35
+ &.left-top {
36
+ &::after {
37
+ top: 1px;
38
+ left: 1px;
39
+ width: 6px;
40
+ height: 6px;
41
+ }
42
+ }
43
+ &.center-top {
44
+ &::after {
45
+ top: 1px;
46
+ left: 1px;
47
+ width: 12px;
48
+ height: 6px;
49
+ }
50
+ }
51
+ &.right-top {
52
+ &::after {
53
+ top: 1px;
54
+ right: 1px;
55
+ width: 6px;
56
+ height: 6px;
57
+ }
58
+ }
59
+ &.left-center {
60
+ &::after {
61
+ top: 1px;
62
+ left: 1px;
63
+ width: 6px;
64
+ height: 12px;
65
+ }
66
+ }
67
+ &.center-center {
68
+ &::after {
69
+ top: 1px;
70
+ left: 1px;
71
+ width: 12px;
72
+ height: 12px;
73
+ }
74
+ }
75
+ &.right-center {
76
+ &::after {
77
+ top: 1px;
78
+ right: 1px;
79
+ width: 6px;
80
+ height: 12px;
81
+ }
82
+ }
83
+ &.left-bottom {
84
+ &::after {
85
+ bottom: 1px;
86
+ left: 1px;
87
+ width: 6px;
88
+ height: 6px;
89
+ }
90
+ }
91
+ &.center-bottom {
92
+ &::after {
93
+ bottom: 1px;
94
+ left: 1px;
95
+ width: 12px;
96
+ height: 6px;
97
+ }
98
+ }
99
+ &.right-bottom {
100
+ &::after {
101
+ bottom: 1px;
102
+ right: 1px;
103
+ width: 6px;
104
+ height: 6px;
105
+ }
106
+ }
107
+ }
108
+ }
109
+ .custom-value {
110
+ position: relative;
111
+ flex: 1;
112
+ }
113
+ }
@@ -0,0 +1,53 @@
1
+ .border-box-container {
2
+ display: flex;
3
+ .border-icon-container {
4
+ display: flex;
5
+ flex-direction: column;
6
+ justify-content: center;
7
+ width: 88px;
8
+ &-row {
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ & + .border-icon-container-row {
13
+ margin-top: 8px;
14
+ }
15
+ }
16
+ .border-icon {
17
+ box-sizing: border-box;
18
+ width: 16px;
19
+ height: 16px;
20
+ border-width: 1px;
21
+ border-color: #111;
22
+ border-style: solid;
23
+ cursor: pointer;
24
+ & + .border-icon {
25
+ margin-left: 8px;
26
+ }
27
+ &.active {
28
+ border-width: 1px;
29
+ border-color: var(--el-color-primary);
30
+ }
31
+ &.border-icon-top {
32
+ border-top-width: 2px;
33
+ border-style: solid dashed dashed dashed;
34
+ }
35
+ &.border-icon-right {
36
+ border-right-width: 2px;
37
+ border-style: dashed solid dashed dashed;
38
+ }
39
+ &.border-icon-bottom {
40
+ border-bottom-width: 2px;
41
+ border-style: dashed dashed solid dashed;
42
+ }
43
+ &.border-icon-left {
44
+ border-left-width: 2px;
45
+ border-style: dashed dashed dashed solid;
46
+ }
47
+ }
48
+ }
49
+ .border-value-container {
50
+ margin-left: 16px;
51
+ flex: 1;
52
+ }
53
+ }
@@ -0,0 +1,28 @@
1
+ @use "./border.scss";
2
+ @use "./layout.scss";
3
+ @use "./background.scss";
4
+
5
+ .m-fields-style-setter {
6
+ width: 100%;
7
+
8
+ .tmagic-design-collapse-item {
9
+ > .el-collapse-item__header {
10
+ background-color: #f2f3f7;
11
+ height: 36px;
12
+ padding: 10px;
13
+ }
14
+
15
+ .el-collapse-item__wrap {
16
+ padding: 0 10px;
17
+ }
18
+ }
19
+ }
20
+
21
+ .text-align-list {
22
+ display: flex;
23
+ height: 100%;
24
+
25
+ .btn-active {
26
+ color: var(--el-color-primary) !important;
27
+ }
28
+ }
@@ -0,0 +1,199 @@
1
+ // 盒子模型
2
+ .layout-box-container {
3
+ position: relative;
4
+ width: 100%;
5
+ height: 150px;
6
+
7
+ .help-txt {
8
+ float: left;
9
+ margin-left: -10px;
10
+ transform: scale(0.75);
11
+ }
12
+
13
+ .outer-top-border,
14
+ .inner-top-border,
15
+ .outer-right-border,
16
+ .inner-right-border,
17
+ .outer-bottom-border,
18
+ .inner-bottom-border,
19
+ .outer-left-border,
20
+ .inner-left-border {
21
+ position: absolute;
22
+ transition: all 0.3s ease;
23
+ .next-input {
24
+ position: absolute;
25
+ height: 20px;
26
+ input {
27
+ padding: 0;
28
+ width: 100%;
29
+ border: none;
30
+ outline: none;
31
+ margin: 0;
32
+ font-weight: 400;
33
+ vertical-align: top;
34
+ background-color: transparent;
35
+ color: #333;
36
+ text-align: center;
37
+ line-height: 20px;
38
+ height: 20px;
39
+ }
40
+ }
41
+ }
42
+
43
+ // top
44
+ .outer-top-border,
45
+ .inner-top-border {
46
+ height: 0;
47
+ border-left: 20px solid transparent;
48
+ border-right: 20px solid transparent;
49
+ border-top: 20px solid #d6e4ff;
50
+ .next-input {
51
+ left: 0;
52
+ right: 0;
53
+ top: -20px;
54
+ }
55
+ }
56
+
57
+ .outer-top-border {
58
+ top: 0;
59
+ left: 0;
60
+ right: 0;
61
+ }
62
+
63
+ .inner-top-border {
64
+ top: 25px;
65
+ left: 25px;
66
+ right: 25px;
67
+ }
68
+
69
+ .outer-top-border,
70
+ .inner-top-border {
71
+ &:hover {
72
+ border-top: 20px solid #bfd4fb;
73
+ }
74
+ }
75
+
76
+ // right
77
+ .outer-right-border,
78
+ .inner-right-border {
79
+ width: 0;
80
+ border-top: 20px solid transparent;
81
+ border-bottom: 20px solid transparent;
82
+ border-right: 20px solid #d6e4ff;
83
+
84
+ .next-input {
85
+ top: 0;
86
+ bottom: 0;
87
+ right: -20px;
88
+ width: 20px;
89
+ margin: auto;
90
+ input {
91
+ position: absolute;
92
+ top: 0;
93
+ bottom: 0;
94
+ left: 0;
95
+ margin: auto;
96
+ width: 20px;
97
+ }
98
+ }
99
+ }
100
+
101
+ .outer-right-border {
102
+ top: 5px;
103
+ bottom: 5px;
104
+ right: 0;
105
+ }
106
+
107
+ .inner-right-border {
108
+ top: 30px;
109
+ bottom: 30px;
110
+ right: 25px;
111
+ }
112
+
113
+ .outer-right-border,
114
+ .inner-right-border {
115
+ &:hover {
116
+ border-right: 20px solid #bfd4fb;
117
+ }
118
+ }
119
+
120
+ // bottom
121
+ .outer-bottom-border,
122
+ .inner-bottom-border {
123
+ height: 0;
124
+ border-left: 20px solid transparent;
125
+ border-right: 20px solid transparent;
126
+ border-bottom: 20px solid #d6e4ff;
127
+
128
+ .next-input {
129
+ position: absolute;
130
+ left: 0;
131
+ right: 0;
132
+ bottom: -20px;
133
+ }
134
+ }
135
+
136
+ .outer-bottom-border {
137
+ bottom: 0;
138
+ left: 0;
139
+ right: 0;
140
+ }
141
+
142
+ .inner-bottom-border {
143
+ bottom: 25px;
144
+ left: 25px;
145
+ right: 25px;
146
+ }
147
+
148
+ .outer-bottom-border,
149
+ .inner-bottom-border {
150
+ &:hover {
151
+ border-bottom: 20px solid #bfd4fb;
152
+ }
153
+ }
154
+
155
+ // left
156
+ .outer-left-border,
157
+ .inner-left-border {
158
+ width: 0;
159
+ border-top: 20px solid transparent;
160
+ border-bottom: 20px solid transparent;
161
+ border-left: 20px solid #d6e4ff;
162
+
163
+ .next-input {
164
+ position: absolute;
165
+ top: 0;
166
+ bottom: 0;
167
+ left: -20px;
168
+ width: 20px;
169
+ margin: auto;
170
+ input {
171
+ position: absolute;
172
+ top: 0;
173
+ bottom: 0;
174
+ right: 0;
175
+ margin: auto;
176
+ width: 20px;
177
+ }
178
+ }
179
+ }
180
+
181
+ .outer-left-border {
182
+ top: 5px;
183
+ bottom: 5px;
184
+ left: 0;
185
+ }
186
+
187
+ .inner-left-border {
188
+ top: 30px;
189
+ bottom: 30px;
190
+ left: 25px;
191
+ }
192
+
193
+ .outer-left-border,
194
+ .inner-left-border {
195
+ &:hover {
196
+ border-left: 20px solid #bfd4fb;
197
+ }
198
+ }
199
+ }
@@ -26,3 +26,4 @@
26
26
  @use "./page-fragment-select.scss";
27
27
  @use "./data-source-field.scss";
28
28
  @use "./data-source-field-select.scss";
29
+ @use "./style-setter/index.scss";
@@ -2,8 +2,14 @@ import { EventEmitter } from 'events';
2
2
 
3
3
  export interface IdleTaskEvents {
4
4
  finish: [];
5
+ 'hight-level-finish': [];
5
6
  }
6
7
 
8
+ type TaskList<T> = {
9
+ handler: (data: T) => void;
10
+ data: T;
11
+ }[];
12
+
7
13
  globalThis.requestIdleCallback =
8
14
  globalThis.requestIdleCallback ||
9
15
  function (cb) {
@@ -19,10 +25,9 @@ globalThis.requestIdleCallback =
19
25
  };
20
26
 
21
27
  export class IdleTask<T = any> extends EventEmitter {
22
- private taskList: {
23
- handler: (data: T) => void;
24
- data: T;
25
- }[] = [];
28
+ private taskList: TaskList<T> = [];
29
+
30
+ private hightLevelTaskList: TaskList<T> = [];
26
31
 
27
32
  private taskHandle: number | null = null;
28
33
 
@@ -31,8 +36,8 @@ export class IdleTask<T = any> extends EventEmitter {
31
36
  this.setMaxListeners(1000);
32
37
  }
33
38
 
34
- public enqueueTask(taskHandler: (data: T) => void, taskData: T) {
35
- this.taskList.push({
39
+ public enqueueTask(taskHandler: (data: T) => void, taskData: T, isHightLevel = false) {
40
+ (isHightLevel ? this.hightLevelTaskList : this.taskList).push({
36
41
  handler: taskHandler,
37
42
  data: taskData,
38
43
  });
@@ -43,6 +48,11 @@ export class IdleTask<T = any> extends EventEmitter {
43
48
  }
44
49
 
45
50
  public clearTasks() {
51
+ if (this.taskHandle) {
52
+ globalThis.cancelIdleCallback(this.taskHandle);
53
+ }
54
+
55
+ this.hightLevelTaskList = [];
46
56
  this.taskList = [];
47
57
  }
48
58
 
@@ -65,10 +75,12 @@ export class IdleTask<T = any> extends EventEmitter {
65
75
  }
66
76
 
67
77
  private runTaskQueue(deadline: IdleDeadline) {
78
+ const { hightLevelTaskList, taskList } = this;
79
+
68
80
  // 动画会占用空闲时间,当任务一直无法执行时,看看是否有动画正在播放
69
81
  // 根据空闲时间的多少来决定执行的任务数,保证页面不卡死的情况下尽量多执行任务,不然当任务数巨大时,执行时间会很久
70
82
  // 执行不完不会影响配置,但是会影响画布渲染
71
- while (deadline.timeRemaining() > 0 && this.taskList.length) {
83
+ while (deadline.timeRemaining() > 0 && taskList.length) {
72
84
  const timeRemaining = deadline.timeRemaining();
73
85
  let times = 0;
74
86
  if (timeRemaining <= 5) {
@@ -82,18 +94,22 @@ export class IdleTask<T = any> extends EventEmitter {
82
94
  }
83
95
 
84
96
  for (let i = 0; i < times; i++) {
85
- const task = this.taskList.shift();
97
+ const task = hightLevelTaskList.length > 0 ? hightLevelTaskList.shift() : taskList.shift();
86
98
  if (task) {
87
99
  task.handler(task.data);
88
100
  }
89
101
 
90
- if (this.taskList.length === 0) {
102
+ if (hightLevelTaskList.length === 0 && taskList.length === 0) {
91
103
  break;
92
104
  }
93
105
  }
94
106
  }
95
107
 
96
- if (this.taskList.length) {
108
+ if (!hightLevelTaskList.length) {
109
+ this.emit('hight-level-finish');
110
+ }
111
+
112
+ if (hightLevelTaskList.length || taskList.length) {
97
113
  this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 300 });
98
114
  } else {
99
115
  this.taskHandle = 0;