@tmagic/editor 1.0.0-beta.13 → 1.0.0-beta.14
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/coverage/clover.xml +646 -550
- package/coverage/coverage-final.json +19 -18
- package/coverage/lcov-report/index.html +55 -55
- package/coverage/lcov-report/src/Editor.vue.html +1 -1
- package/coverage/lcov-report/{layouts/sidebar/LayerMenu.vue.html → src/components/ContentMenu.vue.html} +137 -95
- package/coverage/lcov-report/src/components/Icon.vue.html +5 -5
- package/coverage/lcov-report/src/components/ScrollViewer.vue.html +1 -1
- package/coverage/lcov-report/src/components/ToolButton.vue.html +180 -63
- package/coverage/lcov-report/src/components/index.html +34 -19
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/layouts/AddPageBox.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Framework.vue.html +13 -13
- package/coverage/lcov-report/src/layouts/NavMenu.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/PropsPanel.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/Resizer.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/index.html +15 -15
- package/coverage/lcov-report/src/layouts/sidebar/ComponentListPanel.vue.html +78 -12
- package/coverage/lcov-report/src/layouts/sidebar/LayerMenu.vue.html +149 -92
- package/coverage/lcov-report/src/layouts/sidebar/LayerPanel.vue.html +43 -121
- package/coverage/lcov-report/src/layouts/sidebar/Sidebar.vue.html +1 -1
- package/coverage/lcov-report/src/layouts/sidebar/index.html +40 -40
- package/coverage/lcov-report/src/layouts/workspace/PageBar.vue.html +99 -12
- package/coverage/lcov-report/src/layouts/workspace/Stage.vue.html +86 -95
- package/coverage/lcov-report/src/layouts/workspace/ViewerMenu.vue.html +208 -97
- package/coverage/lcov-report/src/layouts/workspace/Workspace.vue.html +3 -3
- package/coverage/lcov-report/src/layouts/workspace/index.html +35 -35
- package/coverage/lcov-report/src/services/BaseService.ts.html +11 -11
- package/coverage/lcov-report/src/services/componentList.ts.html +1 -1
- package/coverage/lcov-report/src/services/editor.ts.html +102 -9
- package/coverage/lcov-report/src/services/events.ts.html +1 -1
- package/coverage/lcov-report/src/services/history.ts.html +29 -8
- package/coverage/lcov-report/src/services/index.html +25 -25
- package/coverage/lcov-report/src/services/props.ts.html +4 -7
- package/coverage/lcov-report/src/services/ui.ts.html +1 -1
- package/coverage/lcov-report/src/type.ts.html +8 -14
- package/coverage/lcov-report/src/utils/compose.ts.html +4 -4
- package/coverage/lcov-report/src/utils/config.ts.html +1 -1
- package/coverage/lcov-report/src/utils/editor.ts.html +2 -2
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/logger.ts.html +1 -1
- package/coverage/lcov-report/src/utils/props.ts.html +59 -2
- package/coverage/lcov-report/src/utils/scroll-viewer.ts.html +1 -1
- package/coverage/lcov-report/src/utils/undo-redo.ts.html +1 -1
- package/coverage/lcov.info +1623 -1354
- package/dist/style.css +39 -18
- package/dist/tmagic-editor.es.js +598 -412
- package/dist/tmagic-editor.es.js.map +1 -1
- package/dist/tmagic-editor.umd.js +595 -408
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/dist/types/src/Editor.vue.d.ts +1 -1
- package/dist/types/src/components/ToolButton.vue.d.ts +12 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -0
- package/dist/types/src/layouts/workspace/PageBar.vue.d.ts +2 -0
- package/dist/types/src/services/history.d.ts +1 -0
- package/dist/types/src/services/props.d.ts +2 -2
- package/dist/types/src/type.d.ts +6 -8
- package/dist/types/src/utils/polyfills.d.ts +0 -0
- package/package.json +8 -7
- package/src/components/ContentMenu.vue +107 -0
- package/src/components/ToolButton.vue +66 -27
- package/src/index.ts +2 -0
- package/src/layouts/Framework.vue +6 -6
- package/src/layouts/sidebar/ComponentListPanel.vue +23 -1
- package/src/layouts/sidebar/LayerMenu.vue +91 -72
- package/src/layouts/sidebar/LayerPanel.vue +23 -49
- package/src/layouts/workspace/PageBar.vue +35 -6
- package/src/layouts/workspace/Stage.vue +41 -44
- package/src/layouts/workspace/ViewerMenu.vue +104 -67
- package/src/layouts/workspace/Workspace.vue +2 -2
- package/src/services/editor.ts +32 -1
- package/src/services/history.ts +7 -0
- package/src/services/props.ts +2 -3
- package/src/theme/common/var.scss +1 -0
- package/src/theme/component-list-panel.scss +2 -0
- package/src/theme/content-menu.scss +33 -26
- package/src/theme/layer-panel.scss +1 -1
- package/src/theme/page-bar.scss +22 -1
- package/src/type.ts +6 -8
- package/src/utils/editor.ts +1 -1
- package/src/utils/polyfills.ts +22 -0
- package/src/utils/props.ts +19 -0
- package/coverage/lcov-report/Icon.vue.html +0 -172
- package/coverage/lcov-report/ToolButton.vue.html +0 -655
- package/coverage/lcov-report/layouts/sidebar/index.html +0 -116
- package/coverage/lcov-report/utils/index.html +0 -116
- package/coverage/lcov-report/utils/undo-redo.ts.html +0 -313
- package/dist/types/src/layouts/sidebar/LayerPanel.vue.d.ts +0 -980
- package/dist/types/src/layouts/workspace/Stage.vue.d.ts +0 -188
- package/dist/types/src/layouts/workspace/ViewerMenu.vue.d.ts +0 -18
|
@@ -1,47 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<div>
|
|
4
|
-
<div class="magic-editor-content-menu-item" @click="() => center()" v-if="canCenter">水平居中</div>
|
|
5
|
-
<div class="magic-editor-content-menu-item" @click="() => copy()">复制</div>
|
|
6
|
-
<div class="magic-editor-content-menu-item" @click="paste" v-if="canPaste">粘贴</div>
|
|
7
|
-
<template v-if="canMoveZPos">
|
|
8
|
-
<div class="separation"></div>
|
|
9
|
-
<div class="magic-editor-content-menu-item" @click="topItem">上移一层</div>
|
|
10
|
-
<div class="magic-editor-content-menu-item" @click="bottomItem">下移一层</div>
|
|
11
|
-
<div class="magic-editor-content-menu-item" @click="top">置顶</div>
|
|
12
|
-
<div class="magic-editor-content-menu-item" @click="bottom">置底</div>
|
|
13
|
-
</template>
|
|
14
|
-
<template v-if="canDelete">
|
|
15
|
-
<div class="separation"></div>
|
|
16
|
-
<div class="magic-editor-content-menu-item" @click="() => remove()">删除</div>
|
|
17
|
-
</template>
|
|
18
|
-
<div class="separation"></div>
|
|
19
|
-
<div class="magic-editor-content-menu-item" @click="clearGuides">清空参考线</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
2
|
+
<content-menu :menu-data="menuData" ref="menu"></content-menu>
|
|
22
3
|
</template>
|
|
23
4
|
|
|
24
5
|
<script lang="ts">
|
|
25
|
-
import { computed, defineComponent, inject, onMounted, ref, watch } from 'vue';
|
|
6
|
+
import { computed, defineComponent, inject, markRaw, onMounted, reactive, ref, watch } from 'vue';
|
|
7
|
+
import { Bottom, Delete, DocumentCopy, Top } from '@element-plus/icons';
|
|
26
8
|
|
|
27
9
|
import { NodeType } from '@tmagic/schema';
|
|
28
10
|
import type StageCore from '@tmagic/stage';
|
|
29
11
|
|
|
30
|
-
import
|
|
12
|
+
import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
13
|
+
import { LayerOffset, Layout, MenuItem, Services } from '@editor/type';
|
|
31
14
|
import { COPY_STORAGE_KEY } from '@editor/utils/editor';
|
|
32
15
|
|
|
33
16
|
export default defineComponent({
|
|
34
|
-
|
|
17
|
+
components: { ContentMenu },
|
|
35
18
|
|
|
36
19
|
setup() {
|
|
37
20
|
const services = inject<Services>('services');
|
|
38
21
|
const editorService = services?.editorService;
|
|
39
|
-
const menu = ref<
|
|
22
|
+
const menu = ref<InstanceType<typeof ContentMenu>>();
|
|
40
23
|
const canPaste = ref(false);
|
|
41
24
|
const canCenter = ref(false);
|
|
42
25
|
|
|
43
26
|
const node = computed(() => editorService?.get('node'));
|
|
44
27
|
const parent = computed(() => editorService?.get('parent'));
|
|
28
|
+
const isPage = computed(() => node.value?.type === NodeType.PAGE);
|
|
45
29
|
|
|
46
30
|
onMounted(() => {
|
|
47
31
|
const data = globalThis.localStorage.getItem(COPY_STORAGE_KEY);
|
|
@@ -62,49 +46,102 @@ export default defineComponent({
|
|
|
62
46
|
|
|
63
47
|
return {
|
|
64
48
|
menu,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
49
|
+
menuData: reactive<MenuItem[]>([
|
|
50
|
+
{
|
|
51
|
+
type: 'button',
|
|
52
|
+
text: '水平居中',
|
|
53
|
+
display: () => canCenter.value,
|
|
54
|
+
handler: () => {
|
|
55
|
+
node.value && editorService?.alignCenter(node.value);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'button',
|
|
60
|
+
text: '复制',
|
|
61
|
+
icon: markRaw(DocumentCopy),
|
|
62
|
+
handler: () => {
|
|
63
|
+
node.value && editorService?.copy(node.value);
|
|
64
|
+
canPaste.value = true;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'button',
|
|
69
|
+
text: '粘贴',
|
|
70
|
+
display: () => canPaste.value,
|
|
71
|
+
handler: () => {
|
|
72
|
+
const top = menu.value?.$el.offsetTop || 0;
|
|
73
|
+
const left = menu.value?.$el.offsetLeft || 0;
|
|
74
|
+
editorService?.paste({ left, top });
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'divider',
|
|
79
|
+
direction: 'horizontal',
|
|
80
|
+
display: () => !isPage.value,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'button',
|
|
84
|
+
text: '上移一层',
|
|
85
|
+
icon: markRaw(Top),
|
|
86
|
+
display: () => !isPage.value,
|
|
87
|
+
handler: () => {
|
|
88
|
+
editorService?.moveLayer(1);
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'button',
|
|
93
|
+
text: '下移一层',
|
|
94
|
+
icon: markRaw(Bottom),
|
|
95
|
+
display: () => !isPage.value,
|
|
96
|
+
handler: () => {
|
|
97
|
+
editorService?.moveLayer(-1);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'button',
|
|
102
|
+
text: '置顶',
|
|
103
|
+
display: () => !isPage.value,
|
|
104
|
+
handler: () => {
|
|
105
|
+
editorService?.moveLayer(LayerOffset.TOP);
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'button',
|
|
110
|
+
text: '置底',
|
|
111
|
+
display: () => !isPage.value,
|
|
112
|
+
handler: () => {
|
|
113
|
+
editorService?.moveLayer(LayerOffset.BOTTOM);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'divider',
|
|
118
|
+
direction: 'horizontal',
|
|
119
|
+
display: () => !isPage.value,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: 'button',
|
|
123
|
+
text: '删除',
|
|
124
|
+
icon: Delete,
|
|
125
|
+
display: () => !isPage.value,
|
|
126
|
+
handler: () => {
|
|
127
|
+
node.value && editorService?.remove(node.value);
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: 'divider',
|
|
132
|
+
direction: 'horizontal',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: 'button',
|
|
136
|
+
text: '清空参考线',
|
|
137
|
+
handler: () => {
|
|
138
|
+
editorService?.get<StageCore>('stage').clearGuides();
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
]),
|
|
142
|
+
|
|
143
|
+
show(e: MouseEvent) {
|
|
144
|
+
menu.value?.show(e);
|
|
108
145
|
},
|
|
109
146
|
};
|
|
110
147
|
},
|
|
@@ -84,11 +84,11 @@ export default defineComponent({
|
|
|
84
84
|
e.inputEvent.preventDefault();
|
|
85
85
|
node.value && services?.editorService.copy(node.value);
|
|
86
86
|
})
|
|
87
|
-
.
|
|
87
|
+
.keydown([ctrl, 'v'], (e) => {
|
|
88
88
|
e.inputEvent.preventDefault();
|
|
89
89
|
node.value && services?.editorService.paste();
|
|
90
90
|
})
|
|
91
|
-
.
|
|
91
|
+
.keydown([ctrl, 'x'], (e) => {
|
|
92
92
|
e.inputEvent.preventDefault();
|
|
93
93
|
if (!node.value || isPage(node.value)) return;
|
|
94
94
|
services?.editorService.copy(node.value);
|
package/src/services/editor.ts
CHANGED
|
@@ -54,6 +54,7 @@ class Editor extends BaseService {
|
|
|
54
54
|
stage: null,
|
|
55
55
|
highlightNode: null,
|
|
56
56
|
modifiedNodeIds: new Map(),
|
|
57
|
+
pageLength: 0,
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
constructor() {
|
|
@@ -69,6 +70,7 @@ class Editor extends BaseService {
|
|
|
69
70
|
'paste',
|
|
70
71
|
'alignCenter',
|
|
71
72
|
'moveLayer',
|
|
73
|
+
'move',
|
|
72
74
|
'undo',
|
|
73
75
|
'redo',
|
|
74
76
|
'highlight',
|
|
@@ -89,6 +91,7 @@ class Editor extends BaseService {
|
|
|
89
91
|
log('store set ', name, ' ', value);
|
|
90
92
|
|
|
91
93
|
if (name === 'root') {
|
|
94
|
+
this.state.pageLength = (value as unknown as MApp)?.items?.length || 0;
|
|
92
95
|
this.emit('root-change', value);
|
|
93
96
|
}
|
|
94
97
|
}
|
|
@@ -190,6 +193,9 @@ class Editor extends BaseService {
|
|
|
190
193
|
} else {
|
|
191
194
|
historyService.empty();
|
|
192
195
|
}
|
|
196
|
+
|
|
197
|
+
this.emit('select', node);
|
|
198
|
+
|
|
193
199
|
return node!;
|
|
194
200
|
}
|
|
195
201
|
|
|
@@ -249,8 +255,9 @@ class Editor extends BaseService {
|
|
|
249
255
|
const curNode = this.get<MContainer>('node');
|
|
250
256
|
|
|
251
257
|
let parentNode: MNode | undefined;
|
|
258
|
+
const isPage = type === NodeType.PAGE;
|
|
252
259
|
|
|
253
|
-
if (
|
|
260
|
+
if (isPage) {
|
|
254
261
|
parentNode = this.get<MApp>('root');
|
|
255
262
|
// 由于支持中间件扩展,在parent参数为undefined时,parent会变成next函数
|
|
256
263
|
} else if (parent && typeof parent !== 'function') {
|
|
@@ -290,6 +297,12 @@ class Editor extends BaseService {
|
|
|
290
297
|
|
|
291
298
|
stage?.select(newNode.id);
|
|
292
299
|
|
|
300
|
+
if (isPage) {
|
|
301
|
+
this.state.pageLength += 1;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
this.emit('add', newNode);
|
|
305
|
+
|
|
293
306
|
return newNode;
|
|
294
307
|
}
|
|
295
308
|
|
|
@@ -318,9 +331,23 @@ class Editor extends BaseService {
|
|
|
318
331
|
stage?.remove({ id: node.id, root: this.get('root') });
|
|
319
332
|
|
|
320
333
|
if (node.type === NodeType.PAGE) {
|
|
334
|
+
this.state.pageLength -= 1;
|
|
335
|
+
|
|
321
336
|
if (root.items[0]) {
|
|
322
337
|
await this.select(root.items[0]);
|
|
323
338
|
stage?.select(root.items[0].id);
|
|
339
|
+
} else {
|
|
340
|
+
this.set('node', null);
|
|
341
|
+
this.set('parent', null);
|
|
342
|
+
this.set('page', null);
|
|
343
|
+
this.set('stage', null);
|
|
344
|
+
this.set('highlightNode', null);
|
|
345
|
+
this.resetModifiedNodeId();
|
|
346
|
+
historyService.reset();
|
|
347
|
+
|
|
348
|
+
this.emit('remove', node);
|
|
349
|
+
|
|
350
|
+
return node;
|
|
324
351
|
}
|
|
325
352
|
} else {
|
|
326
353
|
await this.select(parent);
|
|
@@ -330,6 +357,8 @@ class Editor extends BaseService {
|
|
|
330
357
|
this.addModifiedNodeId(parent.id);
|
|
331
358
|
this.pushHistoryState();
|
|
332
359
|
|
|
360
|
+
this.emit('remove', node);
|
|
361
|
+
|
|
333
362
|
return node;
|
|
334
363
|
}
|
|
335
364
|
|
|
@@ -391,6 +420,8 @@ class Editor extends BaseService {
|
|
|
391
420
|
this.addModifiedNodeId(newConfig.id);
|
|
392
421
|
this.pushHistoryState();
|
|
393
422
|
|
|
423
|
+
this.emit('update', newConfig);
|
|
424
|
+
|
|
394
425
|
return newConfig;
|
|
395
426
|
}
|
|
396
427
|
|
package/src/services/history.ts
CHANGED
|
@@ -51,6 +51,13 @@ class History extends BaseService {
|
|
|
51
51
|
this.on('change', this.setCanUndoRedo);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
public reset() {
|
|
55
|
+
this.state.pageSteps = {};
|
|
56
|
+
this.state.pageId = undefined;
|
|
57
|
+
this.state.canRedo = false;
|
|
58
|
+
this.state.canUndo = false;
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
public changePage(page: MPage): void {
|
|
55
62
|
if (!page) return;
|
|
56
63
|
|
package/src/services/props.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
|
-
import { cloneDeep } from 'lodash-es';
|
|
20
|
+
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
21
21
|
|
|
22
22
|
import type { FormConfig } from '@tmagic/form';
|
|
23
23
|
import type { MComponent, MNode } from '@tmagic/schema';
|
|
@@ -100,8 +100,7 @@ class Props extends BaseService {
|
|
|
100
100
|
|
|
101
101
|
return cloneDeep({
|
|
102
102
|
...getDefaultPropsValue(type),
|
|
103
|
-
...defaultValue,
|
|
104
|
-
...(this.state.propsValueMap[type] || {}),
|
|
103
|
+
...mergeWith(this.state.propsValueMap[type] || {}, defaultValue),
|
|
105
104
|
});
|
|
106
105
|
}
|
|
107
106
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
top: 0;
|
|
13
13
|
left: 0;
|
|
14
14
|
box-sizing: border-box;
|
|
15
|
+
z-index: 1;
|
|
15
16
|
|
|
16
17
|
.el-input__prefix {
|
|
17
18
|
padding: 10px;
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
color: $--font-color;
|
|
63
64
|
flex-direction: column;
|
|
64
65
|
width: 42px;
|
|
66
|
+
cursor: pointer;
|
|
65
67
|
|
|
66
68
|
i {
|
|
67
69
|
font-size: 20px;
|
|
@@ -2,38 +2,45 @@
|
|
|
2
2
|
position: fixed;
|
|
3
3
|
font-size: 12px;
|
|
4
4
|
background: #fff;
|
|
5
|
-
color: #333;
|
|
6
5
|
box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);
|
|
7
6
|
z-index: 9999;
|
|
8
7
|
transform-origin: 0% 0%;
|
|
9
8
|
font-weight: 600;
|
|
10
9
|
padding: 4px 0px;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
max-height: 100%;
|
|
11
12
|
|
|
12
|
-
.
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 0;
|
|
15
|
-
border-color: rgba(155, 155, 155, 0.1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.subMenu {
|
|
19
|
-
position: absolute;
|
|
20
|
-
right: 0;
|
|
21
|
-
transform: translate(100%, 0);
|
|
22
|
-
background-color: #fff;
|
|
13
|
+
.menu-item {
|
|
23
14
|
color: #333;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
display: flex;
|
|
16
|
+
-webkit-box-align: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
min-width: 140px;
|
|
20
|
+
transition: all 0.2s ease 0s;
|
|
21
|
+
padding: 5px 14px;
|
|
22
|
+
border-left: 2px solid transparent;
|
|
23
|
+
|
|
24
|
+
.el-button {
|
|
25
|
+
width: 100%;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
29
28
|
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
.el-button--text,
|
|
30
|
+
i {
|
|
31
|
+
color: $--font-color;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.divider {
|
|
35
|
+
padding: 0 14px;
|
|
36
|
+
|
|
37
|
+
.el-divider {
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:hover {
|
|
43
|
+
background-color: $--hover-color;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
}
|
package/src/theme/page-bar.scss
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
z-index: 1;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
&-title {
|
|
44
44
|
max-width: 150px;
|
|
45
45
|
text-overflow: ellipsis;
|
|
46
46
|
white-space: nowrap;
|
|
@@ -48,3 +48,24 @@
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
.page-bar-popover {
|
|
53
|
+
&.el-popper.el-popover {
|
|
54
|
+
padding: 10px 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.menu-item {
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: all 0.2s ease 0s;
|
|
60
|
+
padding: 5px 14px;
|
|
61
|
+
|
|
62
|
+
.el-button--text,
|
|
63
|
+
i {
|
|
64
|
+
color: $--font-color;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
background-color: $--hover-color;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/type.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface StoreState {
|
|
|
53
53
|
highlightNode: MNode | null;
|
|
54
54
|
stage: StageCore | null;
|
|
55
55
|
modifiedNodeIds: Map<Id, Id>;
|
|
56
|
+
pageLength: number;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export interface PropsState {
|
|
@@ -125,6 +126,8 @@ export interface MenuButton {
|
|
|
125
126
|
* zoom: 放大缩小
|
|
126
127
|
*/
|
|
127
128
|
type: 'button' | 'dropdown' | 'text' | 'divider' | 'zoom';
|
|
129
|
+
/** 当type为divider时有效,分割线方向, 默认vertical */
|
|
130
|
+
direction?: 'horizontal' | 'vertical';
|
|
128
131
|
/** 展示的文案 */
|
|
129
132
|
text?: string;
|
|
130
133
|
/** 鼠标悬浮是显示的气泡中的文案 */
|
|
@@ -136,14 +139,9 @@ export interface MenuButton {
|
|
|
136
139
|
/** 是否显示,默认为true */
|
|
137
140
|
display?: boolean | ((data?: Services) => boolean);
|
|
138
141
|
/** type为button/dropdown时点击运行的方法 */
|
|
139
|
-
handler?: (data
|
|
140
|
-
/** type为dropdown
|
|
141
|
-
items?:
|
|
142
|
-
/** 展示的文案 */
|
|
143
|
-
text: string;
|
|
144
|
-
/** 点击运行的方法 */
|
|
145
|
-
handler(data: Services): any;
|
|
146
|
-
}[];
|
|
142
|
+
handler?: (data: Services, event: MouseEvent) => Promise<any> | any;
|
|
143
|
+
/** type为dropdown时,下拉的菜单列表, 或者有子菜单时 */
|
|
144
|
+
items?: MenuButton[];
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
export interface MenuComponent {
|
package/src/utils/editor.ts
CHANGED
|
@@ -144,7 +144,7 @@ const setTop2Middle = (node: MNode, parentNode: MNode, stage: StageCore) => {
|
|
|
144
144
|
const style = node.style || {};
|
|
145
145
|
const height = style.height || 0;
|
|
146
146
|
|
|
147
|
-
if (!stage || style.top || !parentNode.style || !isNumber(height)) return style;
|
|
147
|
+
if (!stage || typeof style.top !== 'undefined' || !parentNode.style || !isNumber(height)) return style;
|
|
148
148
|
|
|
149
149
|
const { height: parentHeight } = parentNode.style;
|
|
150
150
|
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
// serialize-javascript 依赖的 randombytes 依赖全局的 global 对象,因此此处需添加 global polyfill
|
|
20
|
+
if (typeof (window as any).global === 'undefined') {
|
|
21
|
+
(window as any).global = window;
|
|
22
|
+
}
|
package/src/utils/props.ts
CHANGED
|
@@ -142,6 +142,25 @@ export const fillConfig = (config: FormConfig = []) => [
|
|
|
142
142
|
},
|
|
143
143
|
],
|
|
144
144
|
},
|
|
145
|
+
{
|
|
146
|
+
type: 'fieldset',
|
|
147
|
+
legend: '字体',
|
|
148
|
+
items: [
|
|
149
|
+
{
|
|
150
|
+
name: 'color',
|
|
151
|
+
text: '颜色',
|
|
152
|
+
type: 'colorPicker',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'fontSize',
|
|
156
|
+
text: '大小',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'fontWeight',
|
|
160
|
+
text: '粗细',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
},
|
|
145
164
|
],
|
|
146
165
|
},
|
|
147
166
|
],
|