@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.
- package/README.md +1 -0
- package/coverage/clover.xml +1444 -0
- package/coverage/coverage-final.json +34 -0
- package/coverage/lcov-report/Icon.vue.html +172 -0
- package/coverage/lcov-report/ToolButton.vue.html +655 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/layouts/sidebar/LayerMenu.vue.html +364 -0
- package/coverage/lcov-report/layouts/sidebar/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/Editor.vue.html +787 -0
- package/coverage/lcov-report/src/components/Icon.vue.html +172 -0
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +283 -0
- package/coverage/lcov-report/src/components/ToolButton.vue.html +655 -0
- package/coverage/lcov-report/src/components/index.html +146 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +214 -0
- package/coverage/lcov-report/src/layouts/Framework.vue.html +304 -0
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +208 -0
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +316 -0
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +268 -0
- package/coverage/lcov-report/src/layouts/index.html +176 -0
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +292 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +364 -0
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +853 -0
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +343 -0
- package/coverage/lcov-report/src/layouts/sidebar/index.html +161 -0
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +631 -0
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +766 -0
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +421 -0
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +586 -0
- package/coverage/lcov-report/src/layouts/workspace/index.html +161 -0
- package/coverage/lcov-report/src/services/BaseService.ts.html +643 -0
- package/coverage/lcov-report/src/services/componentList.ts.html +229 -0
- package/coverage/lcov-report/src/services/editor.ts.html +1984 -0
- package/coverage/lcov-report/src/services/events.ts.html +331 -0
- package/coverage/lcov-report/src/services/history.ts.html +457 -0
- package/coverage/lcov-report/src/services/index.html +206 -0
- package/coverage/lcov-report/src/services/props.ts.html +418 -0
- package/coverage/lcov-report/src/services/ui.ts.html +514 -0
- package/coverage/lcov-report/src/type.ts.html +850 -0
- package/coverage/lcov-report/src/utils/compose.ts.html +184 -0
- package/coverage/lcov-report/src/utils/config.ts.html +172 -0
- package/coverage/lcov-report/src/utils/editor.ts.html +838 -0
- package/coverage/lcov-report/src/utils/index.html +221 -0
- package/coverage/lcov-report/src/utils/index.ts.html +151 -0
- package/coverage/lcov-report/src/utils/logger.ts.html +226 -0
- package/coverage/lcov-report/src/utils/props.ts.html +739 -0
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +733 -0
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov-report/utils/index.html +116 -0
- package/coverage/lcov-report/utils/undo-redo.ts.html +313 -0
- package/coverage/lcov.info +3407 -0
- package/dist/style.css +3 -2
- package/dist/tmagic-editor.es.js +388 -196
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +393 -202
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -1
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +1 -1
- package/dist/types/src/layouts/workspace/Workspace.vue.d.ts +2 -1
- package/dist/types/src/services/editor.d.ts +5 -2
- package/dist/types/src/services/props.d.ts +1 -1
- package/dist/types/src/services/ui.d.ts +1 -0
- package/dist/types/src/type.d.ts +3 -1
- package/dist/types/src/utils/editor.d.ts +4 -3
- package/package.json +28 -9
- package/src/components/ScrollViewer.vue +1 -1
- package/src/components/ToolButton.vue +3 -3
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +2 -2
- package/src/layouts/sidebar/LayerMenu.vue +1 -0
- package/src/layouts/workspace/Workspace.vue +106 -3
- package/src/services/BaseService.ts +1 -1
- package/src/services/editor.ts +79 -13
- package/src/services/props.ts +2 -1
- package/src/services/ui.ts +5 -0
- package/src/theme/layer-panel.scss +1 -0
- package/src/type.ts +3 -1
- package/src/utils/editor.ts +31 -6
- package/src/utils/props.ts +1 -1
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -30
package/src/utils/editor.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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 (
|
|
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) => {
|
package/src/utils/props.ts
CHANGED
|
@@ -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
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));
|