@tmagic/editor 1.0.0-beta.10 → 1.0.0-beta.13

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 (88) hide show
  1. package/README.md +1 -0
  2. package/coverage/clover.xml +1444 -0
  3. package/coverage/coverage-final.json +34 -0
  4. package/coverage/lcov-report/Icon.vue.html +172 -0
  5. package/coverage/lcov-report/ToolButton.vue.html +655 -0
  6. package/coverage/lcov-report/base.css +224 -0
  7. package/coverage/lcov-report/block-navigation.js +87 -0
  8. package/coverage/lcov-report/favicon.png +0 -0
  9. package/coverage/lcov-report/index.html +206 -0
  10. package/coverage/lcov-report/layouts/sidebar/LayerMenu.vue.html +364 -0
  11. package/coverage/lcov-report/layouts/sidebar/index.html +116 -0
  12. package/coverage/lcov-report/prettify.css +1 -0
  13. package/coverage/lcov-report/prettify.js +2 -0
  14. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  15. package/coverage/lcov-report/sorter.js +196 -0
  16. package/coverage/lcov-report/src/Editor.vue.html +787 -0
  17. package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
  18. package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
  19. package/coverage/lcov-report/src/components/ToolButton.vue.html +655 -0
  20. package/coverage/lcov-report/src/components/index.html +146 -0
  21. package/coverage/lcov-report/src/index.html +131 -0
  22. package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
  23. package/coverage/lcov-report/src/layouts/Framework.vue.html +304 -0
  24. package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
  25. package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +316 -0
  26. package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
  27. package/coverage/lcov-report/src/layouts/index.html +176 -0
  28. package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +292 -0
  29. package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +364 -0
  30. package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +853 -0
  31. package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +343 -0
  32. package/coverage/lcov-report/src/layouts/sidebar/index.html +161 -0
  33. package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +631 -0
  34. package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +766 -0
  35. package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +421 -0
  36. package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +586 -0
  37. package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
  38. package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
  39. package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
  40. package/coverage/lcov-report/src/services/editor.ts.html +1984 -0
  41. package/coverage/lcov-report/src/services/events.ts.html +331 -0
  42. package/coverage/lcov-report/src/services/history.ts.html +457 -0
  43. package/coverage/lcov-report/src/services/index.html +206 -0
  44. package/coverage/lcov-report/src/services/props.ts.html +418 -0
  45. package/coverage/lcov-report/src/services/ui.ts.html +514 -0
  46. package/coverage/lcov-report/src/type.ts.html +850 -0
  47. package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
  48. package/coverage/lcov-report/src/utils/config.ts.html +172 -0
  49. package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
  50. package/coverage/lcov-report/src/utils/index.html +221 -0
  51. package/coverage/lcov-report/src/utils/index.ts.html +151 -0
  52. package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
  53. package/coverage/lcov-report/src/utils/props.ts.html +739 -0
  54. package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
  55. package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
  56. package/coverage/lcov-report/utils/index.html +116 -0
  57. package/coverage/lcov-report/utils/undo-redo.ts.html +313 -0
  58. package/coverage/lcov.info +3407 -0
  59. package/dist/style.css +3 -2
  60. package/dist/tmagic-editor.es.js +388 -196
  61. package/dist/tmagic-editor.es.js.map +1 -1
  62. package/dist/tmagic-editor.umd.js +393 -202
  63. package/dist/tmagic-editor.umd.js.map +1 -1
  64. package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -1
  65. package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +1 -1
  66. package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +2 -1
  67. package/dist/types/src/services/editor.d.ts +5 -2
  68. package/dist/types/src/services/props.d.ts +1 -1
  69. package/dist/types/src/services/ui.d.ts +1 -0
  70. package/dist/types/src/type.d.ts +3 -1
  71. package/dist/types/src/utils/editor.d.ts +4 -3
  72. package/package.json +28 -9
  73. package/src/components/ScrollViewer.vue +1 -1
  74. package/src/components/ToolButton.vue +3 -3
  75. package/src/layouts/PropsPanel.vue +1 -1
  76. package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
  77. package/src/layouts/sidebar/LayerMenu.vue +1 -0
  78. package/src/layouts/workspace/Workspace.vue +106 -3
  79. package/src/services/BaseService.ts +1 -1
  80. package/src/services/editor.ts +79 -13
  81. package/src/services/props.ts +2 -1
  82. package/src/services/ui.ts +5 -0
  83. package/src/theme/layer-panel.scss +1 -0
  84. package/src/type.ts +3 -1
  85. package/src/utils/editor.ts +31 -6
  86. package/src/utils/props.ts +1 -1
  87. package/tsconfig.json +0 -9
  88. package/vite.config.ts +0 -30
@@ -20,7 +20,8 @@ import { random } from 'lodash-es';
20
20
 
21
21
  import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
22
22
  import { NodeType } from '@tmagic/schema';
23
- import { getNodePath, isPop } from '@tmagic/utils';
23
+ import type StageCore from '@tmagic/stage';
24
+ import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
24
25
 
25
26
  import { Layout } from '@editor/type';
26
27
 
@@ -105,7 +106,7 @@ const updatePopId = (oldId: Id, popId: Id, pageConfig: MPage) => {
105
106
  export const setNewItemId = (config: MNode, parent?: MPage) => {
106
107
  const oldId = config.id;
107
108
 
108
- config.id = generateId(config.type);
109
+ config.id = generateId(config.type || 'component');
109
110
  config.name = `${config.name?.replace(/_(\d+)$/, '')}_${config.id}`;
110
111
 
111
112
  // 只有弹窗在页面下的一级子元素才有效
@@ -124,7 +125,7 @@ export const setNewItemId = (config: MNode, parent?: MPage) => {
124
125
  */
125
126
  export const isFixed = (node: MNode): boolean => node.style?.position === 'fixed';
126
127
 
127
- export const getNodeIndex = (node: MNode, parent: MContainer): number => {
128
+ export const getNodeIndex = (node: MNode, parent: MContainer | MApp): number => {
128
129
  const items = parent?.items || [];
129
130
  return items.findIndex((item: MNode) => `${item.id}` === `${node.id}`);
130
131
  };
@@ -139,11 +140,29 @@ export const toRelative = (node: MNode) => {
139
140
  return node;
140
141
  };
141
142
 
142
- export const initPosition = (node: MNode, layout: Layout) => {
143
+ const setTop2Middle = (node: MNode, parentNode: MNode, stage: StageCore) => {
144
+ const style = node.style || {};
145
+ const height = style.height || 0;
146
+
147
+ if (!stage || style.top || !parentNode.style || !isNumber(height)) return style;
148
+
149
+ const { height: parentHeight } = parentNode.style;
150
+
151
+ if (isPage(parentNode)) {
152
+ const { scrollTop = 0, wrapperHeight } = stage.mask;
153
+ style.top = (wrapperHeight - height) / 2 + scrollTop;
154
+ } else {
155
+ style.top = (parentHeight - height) / 2;
156
+ }
157
+
158
+ return style;
159
+ };
160
+
161
+ export const initPosition = (node: MNode, layout: Layout, parentNode: MNode, stage: StageCore) => {
143
162
  if (layout === Layout.ABSOLUTE) {
144
163
  node.style = {
145
164
  position: 'absolute',
146
- ...(node.style || {}),
165
+ ...setTop2Middle(node, parentNode, stage),
147
166
  };
148
167
  return node;
149
168
  }
@@ -194,12 +213,18 @@ export const change2Fixed = (node: MNode, root: MApp) => {
194
213
  return node;
195
214
  };
196
215
 
197
- export const Fixed2Other = async (node: MNode, root: MApp, getLayout: (node: MNode) => Promise<Layout>) => {
216
+ export const Fixed2Other = async (
217
+ node: MNode,
218
+ root: MApp,
219
+ getLayout: (parent: MNode, node?: MNode) => Promise<Layout>,
220
+ ) => {
198
221
  const path = getNodePath(node.id, root.items);
199
222
  const cur = path.pop();
200
223
  const offset = {
201
224
  left: cur?.style?.left || 0,
202
225
  top: cur?.style?.top || 0,
226
+ right: '',
227
+ bottom: '',
203
228
  };
204
229
 
205
230
  path.forEach((value) => {
@@ -174,7 +174,7 @@ export const fillConfig = (config: FormConfig = []) => [
174
174
  type: 'select',
175
175
  options: (mForm: FormState, { model }: any) => {
176
176
  const node = editorService.getNodeById(model.to);
177
- if (!node) return [];
177
+ if (!node?.type) return [];
178
178
 
179
179
  return eventsService.getMethod(node.type).map((option) => ({
180
180
  text: option.label,
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": "../..",
5
- },
6
- "exclude": [
7
- "**/dist/**/*"
8
- ],
9
- }
package/vite.config.ts DELETED
@@ -1,30 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making TMagicEditor available.
3
- *
4
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import path from 'path';
20
-
21
- import { defineConfig } from 'vite';
22
-
23
- import { getBaseConfig } from '../vite-config';
24
-
25
- import pkg from './package.json';
26
-
27
- const deps = Object.keys(pkg.dependencies);
28
- const alias = [{ find: /@editor/, replacement: path.join(__dirname, './src') }];
29
-
30
- export default defineConfig(getBaseConfig(deps, 'TMagicEditor', alias));