@tmagic/editor 1.0.0-rc.6 → 1.0.0-rc.9

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 (82) hide show
  1. package/dist/style.css +3 -0
  2. package/dist/tmagic-editor.es.js +93 -91
  3. package/dist/tmagic-editor.es.js.map +1 -1
  4. package/dist/tmagic-editor.umd.js +92 -92
  5. package/dist/tmagic-editor.umd.js.map +1 -1
  6. package/dist/types/src/Editor.vue.d.ts +17 -1
  7. package/dist/types/src/fields/Code.vue.d.ts +4 -4
  8. package/dist/types/src/fields/CodeLink.vue.d.ts +1 -3
  9. package/dist/types/src/layouts/PropsPanel.vue.d.ts +2 -4
  10. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +3 -31
  11. package/dist/types/src/services/history.d.ts +1 -18
  12. package/dist/types/src/services/props.d.ts +8 -2
  13. package/dist/types/src/type.d.ts +9 -0
  14. package/dist/types/src/utils/editor.d.ts +0 -6
  15. package/dist/types/src/utils/props.d.ts +8 -1
  16. package/package.json +11 -20
  17. package/src/Editor.vue +21 -8
  18. package/src/layouts/workspace/Stage.vue +11 -31
  19. package/src/layouts/workspace/Workspace.vue +2 -28
  20. package/src/services/editor.ts +1 -2
  21. package/src/services/props.ts +62 -7
  22. package/src/theme/workspace.scss +4 -0
  23. package/src/type.ts +10 -0
  24. package/src/utils/editor.ts +1 -50
  25. package/src/utils/props.ts +30 -7
  26. package/LICENSE +0 -5432
  27. package/coverage/clover.xml +0 -1615
  28. package/coverage/coverage-final.json +0 -36
  29. package/coverage/lcov-report/base.css +0 -224
  30. package/coverage/lcov-report/block-navigation.js +0 -87
  31. package/coverage/lcov-report/favicon.png +0 -0
  32. package/coverage/lcov-report/index.html +0 -206
  33. package/coverage/lcov-report/prettify.css +0 -1
  34. package/coverage/lcov-report/prettify.js +0 -2
  35. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  36. package/coverage/lcov-report/sorter.js +0 -196
  37. package/coverage/lcov-report/src/Editor.vue.html +0 -853
  38. package/coverage/lcov-report/src/components/ContentMenu.vue.html +0 -505
  39. package/coverage/lcov-report/src/components/Icon.vue.html +0 -172
  40. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +0 -283
  41. package/coverage/lcov-report/src/components/ToolButton.vue.html +0 -772
  42. package/coverage/lcov-report/src/components/index.html +0 -161
  43. package/coverage/lcov-report/src/index.html +0 -131
  44. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +0 -214
  45. package/coverage/lcov-report/src/layouts/Framework.vue.html +0 -343
  46. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +0 -208
  47. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +0 -319
  48. package/coverage/lcov-report/src/layouts/Resizer.vue.html +0 -268
  49. package/coverage/lcov-report/src/layouts/index.html +0 -176
  50. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +0 -358
  51. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +0 -430
  52. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +0 -775
  53. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +0 -226
  54. package/coverage/lcov-report/src/layouts/sidebar/TabPane.vue.html +0 -289
  55. package/coverage/lcov-report/src/layouts/sidebar/index.html +0 -176
  56. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +0 -718
  57. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +0 -766
  58. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +0 -577
  59. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +0 -649
  60. package/coverage/lcov-report/src/layouts/workspace/index.html +0 -161
  61. package/coverage/lcov-report/src/services/BaseService.ts.html +0 -643
  62. package/coverage/lcov-report/src/services/componentList.ts.html +0 -229
  63. package/coverage/lcov-report/src/services/editor.ts.html +0 -2167
  64. package/coverage/lcov-report/src/services/events.ts.html +0 -331
  65. package/coverage/lcov-report/src/services/history.ts.html +0 -478
  66. package/coverage/lcov-report/src/services/index.html +0 -206
  67. package/coverage/lcov-report/src/services/props.ts.html +0 -415
  68. package/coverage/lcov-report/src/services/ui.ts.html +0 -580
  69. package/coverage/lcov-report/src/type.ts.html +0 -850
  70. package/coverage/lcov-report/src/utils/compose.ts.html +0 -184
  71. package/coverage/lcov-report/src/utils/config.ts.html +0 -172
  72. package/coverage/lcov-report/src/utils/editor.ts.html +0 -850
  73. package/coverage/lcov-report/src/utils/index.html +0 -221
  74. package/coverage/lcov-report/src/utils/index.ts.html +0 -151
  75. package/coverage/lcov-report/src/utils/logger.ts.html +0 -226
  76. package/coverage/lcov-report/src/utils/props.ts.html +0 -796
  77. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +0 -733
  78. package/coverage/lcov-report/src/utils/undo-redo.ts.html +0 -313
  79. package/coverage/lcov.info +0 -3893
  80. package/dist/types/src/components/ToolButton.vue.d.ts +0 -46
  81. package/dist/types/src/fields/UISelect.vue.d.ts +0 -35
  82. package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +0 -18
package/src/type.ts CHANGED
@@ -21,6 +21,7 @@ import type { Component } from 'vue';
21
21
  import type { FormConfig } from '@tmagic/form';
22
22
  import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
23
23
  import type StageCore from '@tmagic/stage';
24
+ import type { MoveableOptions } from '@tmagic/stage';
24
25
 
25
26
  import type { ComponentListService } from '@editor/services/componentList';
26
27
  import type { EditorService } from '@editor/services/editor';
@@ -45,6 +46,15 @@ export interface Services {
45
46
  uiService: UiService;
46
47
  }
47
48
 
49
+ export interface StageOptions {
50
+ runtimeUrl: string;
51
+ autoScrollIntoView: boolean;
52
+ render: () => HTMLDivElement;
53
+ moveableOptions: MoveableOptions | ((core?: StageCore) => MoveableOptions);
54
+ canSelect: (el: HTMLElement) => boolean | Promise<boolean>;
55
+ updateDragEl: (el: HTMLDivElement) => void;
56
+ }
57
+
48
58
  export interface StoreState {
49
59
  root: MApp | null;
50
60
  page: MPage | null;
@@ -16,9 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { random } from 'lodash-es';
20
-
21
- import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
19
+ import type { MApp, MContainer, MNode, MPage } from '@tmagic/schema';
22
20
  import { NodeType } from '@tmagic/schema';
23
21
  import type StageCore from '@tmagic/stage';
24
22
  import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
@@ -27,8 +25,6 @@ import { Layout } from '@editor/type';
27
25
 
28
26
  export const COPY_STORAGE_KEY = '$MagicEditorCopyData';
29
27
 
30
- export const generateId = (type: string | number): string => `${type}_${random(10000, false)}`;
31
-
32
28
  /**
33
29
  * 获取所有页面配置
34
30
  * @param app DSL跟节点
@@ -74,51 +70,6 @@ export const generatePageName = (pageNameList: string[]): string => {
74
70
  */
75
71
  export const generatePageNameByApp = (app: MApp): string => generatePageName(getPageNameList(getPageList(app)));
76
72
 
77
- /**
78
- * 复制页面时,需要把组件下关联的弹窗id换测复制出来的弹窗的id
79
- * @param {number} oldId 复制的源弹窗id
80
- * @param {number} popId 新的弹窗id
81
- * @param {Object} pageConfig 页面配置
82
- */
83
- const updatePopId = (oldId: Id, popId: Id, pageConfig: MPage) => {
84
- pageConfig.items?.forEach((config) => {
85
- if (config.pop === oldId) {
86
- config.pop = popId;
87
- return;
88
- }
89
-
90
- if (config.popId === oldId) {
91
- config.popId = popId;
92
- return;
93
- }
94
-
95
- if (Array.isArray(config.items)) {
96
- updatePopId(oldId, popId, config as MPage);
97
- }
98
- });
99
- };
100
-
101
- /**
102
- * 将组件与组件的子元素配置中的id都设置成一个新的ID
103
- * @param {Object} config 组件配置
104
- */
105
- /* eslint no-param-reassign: ["error", { "props": false }] */
106
- export const setNewItemId = (config: MNode, parent?: MPage) => {
107
- const oldId = config.id;
108
-
109
- config.id = generateId(config.type || 'component');
110
- config.name = `${config.name?.replace(/_(\d+)$/, '')}_${config.id}`;
111
-
112
- // 只有弹窗在页面下的一级子元素才有效
113
- if (isPop(config) && parent?.type === NodeType.PAGE) {
114
- updatePopId(oldId, config.id, parent);
115
- }
116
-
117
- if (config.items && Array.isArray(config.items)) {
118
- config.items.forEach((item) => setNewItemId(item, config as MPage));
119
- }
120
- };
121
-
122
73
  /**
123
74
  * @param {Object} node
124
75
  * @returns {boolean}
@@ -20,7 +20,6 @@ import { FormConfig, FormState } from '@tmagic/form';
20
20
 
21
21
  import editorService from '@editor/services/editor';
22
22
  import eventsService from '@editor/services/events';
23
- import { generateId } from '@editor/utils/editor';
24
23
 
25
24
  /**
26
25
  * 统一为组件属性表单加上事件、高级、样式配置
@@ -161,6 +160,21 @@ export const fillConfig = (config: FormConfig = []) => [
161
160
  },
162
161
  ],
163
162
  },
163
+ {
164
+ type: 'fieldset',
165
+ legend: '变形',
166
+ name: 'transform',
167
+ items: [
168
+ {
169
+ name: 'rotate',
170
+ text: '旋转角度',
171
+ },
172
+ {
173
+ name: 'scale',
174
+ text: '缩放',
175
+ },
176
+ ],
177
+ },
164
178
  ],
165
179
  },
166
180
  ],
@@ -229,9 +243,18 @@ export const DEFAULT_CONFIG: FormConfig = fillConfig([]);
229
243
  * @param type 组件类型
230
244
  * @returns Object
231
245
  */
232
- export const getDefaultPropsValue = (type: string) => ({
233
- type,
234
- id: generateId(type),
235
- style: {},
236
- name: type,
237
- });
246
+ export const getDefaultPropsValue = (type: string, id: string) =>
247
+ ['page', 'container'].includes(type)
248
+ ? {
249
+ type,
250
+ id,
251
+ style: {},
252
+ name: type,
253
+ items: [],
254
+ }
255
+ : {
256
+ type,
257
+ id,
258
+ style: {},
259
+ name: type,
260
+ };