@tmagic/editor 1.0.0-beta.4 → 1.0.0-beta.5
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/dist/style.css +4 -3
- package/dist/tmagic-editor.es.js +20 -30
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +18 -29
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/layouts/NavMenu.vue.d.ts +2 -1
- package/dist/types/src/utils/editor.d.ts +0 -1
- package/package.json +6 -6
- package/src/components/ScrollViewer.vue +1 -0
- package/src/layouts/NavMenu.vue +7 -3
- package/src/layouts/PropsPanel.vue +5 -10
- package/src/services/editor.ts +6 -3
- package/src/theme/nav-menu.scss +3 -3
- package/src/theme/stage.scss +1 -0
- package/src/utils/editor.ts +1 -20
- package/src/utils/scroll-viewer.ts +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DefineComponent, ComputedRef, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
import { MenuBarData } from '../type';
|
|
2
|
+
import { GetColumnWidth, MenuBarData } from '../type';
|
|
3
3
|
declare const _default: DefineComponent<{
|
|
4
4
|
data: {
|
|
5
5
|
type: PropType<MenuBarData>;
|
|
@@ -10,6 +10,7 @@ declare const _default: DefineComponent<{
|
|
|
10
10
|
};
|
|
11
11
|
}, {
|
|
12
12
|
keys: ComputedRef<(keyof MenuBarData)[]>;
|
|
13
|
+
columnWidth: ComputedRef<GetColumnWidth | undefined>;
|
|
13
14
|
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
14
15
|
data: {
|
|
15
16
|
type: PropType<MenuBarData>;
|
|
@@ -42,4 +42,3 @@ export declare const initPosition: (node: MNode, layout: Layout) => MNode;
|
|
|
42
42
|
export declare const setLayout: (node: MNode, layout: Layout) => MNode;
|
|
43
43
|
export declare const change2Fixed: (node: MNode, root: MApp) => MNode;
|
|
44
44
|
export declare const Fixed2Other: (node: MNode, root: MApp, getLayout: (node: MNode) => Promise<Layout>) => Promise<MNode>;
|
|
45
|
-
export declare const defaults: (object: any, source: any) => any;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-beta.
|
|
2
|
+
"version": "1.0.0-beta.5",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "dist/tmagic-editor.umd.js",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@element-plus/icons": "0.0.11",
|
|
31
|
-
"@tmagic/core": "^1.0.0-beta.
|
|
32
|
-
"@tmagic/form": "^1.0.0-beta.
|
|
33
|
-
"@tmagic/schema": "^1.0.0-beta.
|
|
34
|
-
"@tmagic/stage": "^1.0.0-beta.
|
|
35
|
-
"@tmagic/utils": "^1.0.0-beta.
|
|
31
|
+
"@tmagic/core": "^1.0.0-beta.5",
|
|
32
|
+
"@tmagic/form": "^1.0.0-beta.5",
|
|
33
|
+
"@tmagic/schema": "^1.0.0-beta.5",
|
|
34
|
+
"@tmagic/stage": "^1.0.0-beta.5",
|
|
35
|
+
"@tmagic/utils": "^1.0.0-beta.5",
|
|
36
36
|
"color": "^3.1.3",
|
|
37
37
|
"element-plus": "^2.0.2",
|
|
38
38
|
"events": "^3.3.0",
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-nav-menu" :style="{ height: `${height}px` }">
|
|
3
|
-
<div v-for="key in keys" :class="`menu-${key}`" :key="key">
|
|
3
|
+
<div v-for="key in keys" :class="`menu-${key}`" :key="key" :style="`width: ${columnWidth?.[key]}px`">
|
|
4
4
|
<tool-button :data="item" v-for="(item, index) in data[key]" :key="index"></tool-button>
|
|
5
5
|
</div>
|
|
6
6
|
</div>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script lang="ts">
|
|
10
|
-
import { computed, defineComponent, PropType } from 'vue';
|
|
10
|
+
import { computed, defineComponent, inject, PropType } from 'vue';
|
|
11
11
|
|
|
12
12
|
import ToolButton from '@editor/components/ToolButton.vue';
|
|
13
|
-
import { MenuBarData } from '@editor/type';
|
|
13
|
+
import { GetColumnWidth, MenuBarData, Services } from '@editor/type';
|
|
14
14
|
|
|
15
15
|
export default defineComponent({
|
|
16
16
|
name: 'nav-menu',
|
|
@@ -29,8 +29,12 @@ export default defineComponent({
|
|
|
29
29
|
},
|
|
30
30
|
|
|
31
31
|
setup(props) {
|
|
32
|
+
const services = inject<Services>('services');
|
|
33
|
+
|
|
32
34
|
return {
|
|
33
35
|
keys: computed(() => Object.keys(props.data) as Array<keyof MenuBarData>),
|
|
36
|
+
|
|
37
|
+
columnWidth: computed(() => services?.uiService.get<GetColumnWidth>('columnWidth')),
|
|
34
38
|
};
|
|
35
39
|
},
|
|
36
40
|
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script lang="ts">
|
|
13
|
-
import { defineComponent, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
|
|
13
|
+
import { computed, defineComponent, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
|
|
14
14
|
import { ElMessage } from 'element-plus';
|
|
15
15
|
|
|
16
16
|
import type { FormValue, MForm } from '@tmagic/form';
|
|
@@ -30,21 +30,16 @@ export default defineComponent({
|
|
|
30
30
|
// ts类型应该是FormConfig, 但是打包时会出错,所以暂时用any
|
|
31
31
|
const curFormConfig = ref<any>([]);
|
|
32
32
|
const services = inject<Services>('services');
|
|
33
|
+
const node = computed(() => services?.editorService.get<MNode | null>('node'));
|
|
33
34
|
|
|
34
35
|
const init = async () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!node) {
|
|
36
|
+
if (!node.value) {
|
|
38
37
|
curFormConfig.value = [];
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
values.value = node;
|
|
47
|
-
const type = node.type || (node.items ? 'container' : 'text');
|
|
41
|
+
values.value = node.value;
|
|
42
|
+
const type = node.value.type || (node.value.items ? 'container' : 'text');
|
|
48
43
|
curFormConfig.value = (await services?.propsService.getPropsConfig(type)) || [];
|
|
49
44
|
};
|
|
50
45
|
|
package/src/services/editor.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { reactive, toRaw } from 'vue';
|
|
20
|
-
import { cloneDeep } from 'lodash-es';
|
|
20
|
+
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
21
21
|
import serialize from 'serialize-javascript';
|
|
22
22
|
|
|
23
23
|
import type { Id, MApp, MComponent, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
@@ -31,7 +31,6 @@ import { LayerOffset, Layout } from '@editor/type';
|
|
|
31
31
|
import {
|
|
32
32
|
change2Fixed,
|
|
33
33
|
COPY_STORAGE_KEY,
|
|
34
|
-
defaults,
|
|
35
34
|
Fixed2Other,
|
|
36
35
|
getNodeIndex,
|
|
37
36
|
initPosition,
|
|
@@ -292,7 +291,11 @@ class Editor extends BaseService {
|
|
|
292
291
|
|
|
293
292
|
let newConfig = await this.toggleFixedPosition(toRaw(config), node, this.get<MApp>('root'));
|
|
294
293
|
|
|
295
|
-
|
|
294
|
+
newConfig = mergeWith(node, newConfig, (objValue, srcValue) => {
|
|
295
|
+
if (Array.isArray(srcValue)) {
|
|
296
|
+
return srcValue;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
296
299
|
|
|
297
300
|
if (!newConfig.type) throw new Error('配置缺少type值');
|
|
298
301
|
|
package/src/theme/nav-menu.scss
CHANGED
package/src/theme/stage.scss
CHANGED
package/src/utils/editor.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { random } from 'lodash-es';
|
|
20
20
|
|
|
21
21
|
import { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
22
22
|
import { getNodePath, isPop } from '@tmagic/utils';
|
|
@@ -223,22 +223,3 @@ export const Fixed2Other = async (node: MNode, root: MApp, getLayout: (node: MNo
|
|
|
223
223
|
|
|
224
224
|
return toRelative(node);
|
|
225
225
|
};
|
|
226
|
-
|
|
227
|
-
export const defaults = (object: any, source: any) => {
|
|
228
|
-
let o = source;
|
|
229
|
-
if (Array.isArray(object)) {
|
|
230
|
-
o = object;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
Object.entries(o).forEach(([key, value]: [string, any]) => {
|
|
234
|
-
if (typeof object[key] === 'undefined') {
|
|
235
|
-
object[key] = value;
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (value && typeof value !== 'string' && Object.keys(value).length) {
|
|
240
|
-
object[key] = defaults(cloneDeep(object[key]), value);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
return object;
|
|
244
|
-
};
|
|
@@ -25,7 +25,8 @@ export class ScrollViewer {
|
|
|
25
25
|
const { width, height } = contentRect;
|
|
26
26
|
const targetRect = this.target.getBoundingClientRect();
|
|
27
27
|
const targetWidth = targetRect.width * this.zoom;
|
|
28
|
-
const
|
|
28
|
+
const targetMarginTop = Number(this.target.style.marginTop) || 0;
|
|
29
|
+
const targetHeight = (targetRect.height + targetMarginTop) * this.zoom;
|
|
29
30
|
|
|
30
31
|
if (targetWidth < width) {
|
|
31
32
|
(this.target as any)._left = 0;
|