@tmagic/editor 1.3.0-alpha.22 → 1.3.0-alpha.24
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 +21 -103
- package/dist/tmagic-editor.js +177 -145
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +177 -145
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/fields/CodeSelectCol.vue +10 -1
- package/src/layouts/sidebar/Sidebar.vue +20 -26
- package/src/services/editor.ts +43 -15
- package/src/theme/sidebar.scss +18 -60
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.24",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "^7.18.0",
|
|
48
48
|
"@element-plus/icons-vue": "^2.0.9",
|
|
49
|
-
"@tmagic/core": "1.3.0-alpha.
|
|
50
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
51
|
-
"@tmagic/form": "1.3.0-alpha.
|
|
52
|
-
"@tmagic/schema": "1.3.0-alpha.
|
|
53
|
-
"@tmagic/stage": "1.3.0-alpha.
|
|
54
|
-
"@tmagic/table": "1.3.0-alpha.
|
|
55
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
49
|
+
"@tmagic/core": "1.3.0-alpha.24",
|
|
50
|
+
"@tmagic/design": "1.3.0-alpha.24",
|
|
51
|
+
"@tmagic/form": "1.3.0-alpha.24",
|
|
52
|
+
"@tmagic/schema": "1.3.0-alpha.24",
|
|
53
|
+
"@tmagic/stage": "1.3.0-alpha.24",
|
|
54
|
+
"@tmagic/table": "1.3.0-alpha.24",
|
|
55
|
+
"@tmagic/utils": "1.3.0-alpha.24",
|
|
56
56
|
"buffer": "^6.0.3",
|
|
57
57
|
"color": "^3.1.3",
|
|
58
58
|
"events": "^3.3.0",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"vue": "^3.3.4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@tmagic/design": "1.3.0-alpha.
|
|
68
|
-
"@tmagic/form": "1.3.0-alpha.
|
|
67
|
+
"@tmagic/design": "1.3.0-alpha.24",
|
|
68
|
+
"@tmagic/form": "1.3.0-alpha.24",
|
|
69
69
|
"monaco-editor": "^0.41.0",
|
|
70
70
|
"vue": "^3.3.4"
|
|
71
71
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
35
|
<script lang="ts" setup name="">
|
|
36
|
-
import { computed, inject, ref } from 'vue';
|
|
36
|
+
import { computed, inject, ref, watch } from 'vue';
|
|
37
37
|
import { Edit, View } from '@element-plus/icons-vue';
|
|
38
38
|
import { isEmpty, map } from 'lodash-es';
|
|
39
39
|
|
|
@@ -78,6 +78,15 @@ const getParamItemsConfig = (codeId?: Id): CodeParamStatement[] => {
|
|
|
78
78
|
const codeDsl = computed(() => services?.codeBlockService.getCodeDsl());
|
|
79
79
|
const paramsConfig = ref<CodeParamStatement[]>(getParamItemsConfig(props.model[props.name]));
|
|
80
80
|
|
|
81
|
+
watch(
|
|
82
|
+
() => props.model[props.name],
|
|
83
|
+
(v, preV) => {
|
|
84
|
+
if (v !== preV) {
|
|
85
|
+
paramsConfig.value = getParamItemsConfig(v);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
|
|
81
90
|
const selectConfig = {
|
|
82
91
|
type: 'select',
|
|
83
92
|
text: '代码块',
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<div class="m-editor-sidebar" v-if="data.type === 'tabs' && data.items.length">
|
|
3
|
+
<div class="m-editor-sidebar-header">
|
|
4
|
+
<div
|
|
5
|
+
class="m-editor-sidebar-header-item"
|
|
6
|
+
v-for="(config, index) in sideBarItems"
|
|
7
|
+
:key="config.$key ?? index"
|
|
8
|
+
:class="{ 'is-active': activeTabName === config.text }"
|
|
9
|
+
@click="activeTabName = config.text || `${index}`"
|
|
10
|
+
>
|
|
11
|
+
<MIcon v-if="config.icon" :icon="config.icon"></MIcon>
|
|
12
|
+
<div v-if="config.text" class="magic-editor-tab-panel-title">{{ config.text }}</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
class="m-editor-sidebar-content"
|
|
10
17
|
v-for="(config, index) in sideBarItems"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
:key="config.$key || index"
|
|
18
|
+
:key="config.$key ?? index"
|
|
19
|
+
v-show="activeTabName === config.text"
|
|
14
20
|
>
|
|
15
|
-
<template #label>
|
|
16
|
-
<div :key="config.text">
|
|
17
|
-
<MIcon v-if="config.icon" :icon="config.icon"></MIcon>
|
|
18
|
-
<div v-if="config.text" class="magic-editor-tab-panel-title">{{ config.text }}</div>
|
|
19
|
-
</div>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
21
|
<component v-if="config" :is="config.component" v-bind="config.props || {}" v-on="config?.listeners || {}">
|
|
23
22
|
<template
|
|
24
23
|
#component-list-panel-header
|
|
@@ -71,16 +70,14 @@
|
|
|
71
70
|
/>
|
|
72
71
|
</template>
|
|
73
72
|
</component>
|
|
74
|
-
</
|
|
75
|
-
</
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
76
75
|
</template>
|
|
77
76
|
|
|
78
|
-
<script lang="ts"
|
|
77
|
+
<script setup lang="ts">
|
|
79
78
|
import { computed, ref, watch } from 'vue';
|
|
80
79
|
import { Coin, EditPen, Goods, List } from '@element-plus/icons-vue';
|
|
81
80
|
|
|
82
|
-
import { getConfig } from '@tmagic/design';
|
|
83
|
-
|
|
84
81
|
import MIcon from '@editor/components/Icon.vue';
|
|
85
82
|
import type { MenuButton, MenuComponent, SideComponent, SideItem } from '@editor/type';
|
|
86
83
|
import { SideBarData } from '@editor/type';
|
|
@@ -104,9 +101,6 @@ const props = withDefaults(
|
|
|
104
101
|
},
|
|
105
102
|
);
|
|
106
103
|
|
|
107
|
-
const tabPaneComponent = getConfig('components')?.tabPane;
|
|
108
|
-
const tabsComponent = getConfig('components')?.tabs;
|
|
109
|
-
|
|
110
104
|
const activeTabName = ref(props.data?.status);
|
|
111
105
|
|
|
112
106
|
const getItemConfig = (data: SideItem): SideComponent => {
|
package/src/services/editor.ts
CHANGED
|
@@ -648,12 +648,14 @@ class Editor extends BaseService {
|
|
|
648
648
|
|
|
649
649
|
if (doc) {
|
|
650
650
|
const el = doc.getElementById(`${node.id}`);
|
|
651
|
-
const parentEl = el?.offsetParent;
|
|
651
|
+
const parentEl = layout === Layout.FIXED ? doc.body : el?.offsetParent;
|
|
652
652
|
if (parentEl && el) {
|
|
653
653
|
node.style.left = (parentEl.clientWidth - el.clientWidth) / 2;
|
|
654
|
+
node.style.right = '';
|
|
654
655
|
}
|
|
655
656
|
} else if (parent.style && isNumber(parent.style?.width) && isNumber(node.style?.width)) {
|
|
656
657
|
node.style.left = (parent.style.width - node.style.width) / 2;
|
|
658
|
+
node.style.right = '';
|
|
657
659
|
}
|
|
658
660
|
|
|
659
661
|
return node;
|
|
@@ -792,20 +794,46 @@ class Editor extends BaseService {
|
|
|
792
794
|
if (!node || isPage(node)) return;
|
|
793
795
|
|
|
794
796
|
const { style, id, type } = node;
|
|
795
|
-
if (!style || style.position
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
797
|
+
if (!style || !['absolute', 'fixed'].includes(style.position)) return;
|
|
798
|
+
|
|
799
|
+
const update = (style: { [key: string]: any }) =>
|
|
800
|
+
this.update({
|
|
801
|
+
id,
|
|
802
|
+
type,
|
|
803
|
+
style,
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
if (top) {
|
|
807
|
+
if (isNumber(style.top)) {
|
|
808
|
+
update({
|
|
809
|
+
...style,
|
|
810
|
+
top: Number(style.top) + Number(top),
|
|
811
|
+
bottom: '',
|
|
812
|
+
});
|
|
813
|
+
} else if (isNumber(style.bottom)) {
|
|
814
|
+
update({
|
|
815
|
+
...style,
|
|
816
|
+
bottom: Number(style.bottom) - Number(top),
|
|
817
|
+
top: '',
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (left) {
|
|
823
|
+
if (isNumber(style.left)) {
|
|
824
|
+
update({
|
|
825
|
+
...style,
|
|
826
|
+
left: Number(style.left) + Number(left),
|
|
827
|
+
right: '',
|
|
828
|
+
});
|
|
829
|
+
} else if (isNumber(style.right)) {
|
|
830
|
+
update({
|
|
831
|
+
...style,
|
|
832
|
+
right: Number(style.right) - Number(left),
|
|
833
|
+
left: '',
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
}
|
|
809
837
|
}
|
|
810
838
|
|
|
811
839
|
public resetState() {
|
package/src/theme/sidebar.scss
CHANGED
|
@@ -1,76 +1,33 @@
|
|
|
1
|
-
.m-editor-sidebar
|
|
1
|
+
.m-editor-sidebar {
|
|
2
|
+
display: flex;
|
|
2
3
|
height: 100%;
|
|
3
4
|
|
|
4
|
-
.
|
|
5
|
-
.t-tabs__header {
|
|
5
|
+
.m-editor-sidebar-header {
|
|
6
6
|
background: $--sidebar-heder-background-color;
|
|
7
|
-
border: 0;
|
|
8
7
|
height: 100%;
|
|
8
|
+
width: 40px;
|
|
9
9
|
|
|
10
|
-
.
|
|
11
|
-
background-color: transparent;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.t-tabs__nav--card.t-tabs__nav-item:not(.t-is-disabled):not(
|
|
15
|
-
.t-is-active
|
|
16
|
-
):hover {
|
|
17
|
-
background-color: transparent;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&.is-left,
|
|
21
|
-
&.t-is-left {
|
|
22
|
-
width: 40px;
|
|
23
|
-
margin-right: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.el-tabs__nav-wrap {
|
|
27
|
-
margin: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.el-tabs__nav {
|
|
31
|
-
border: 0;
|
|
32
|
-
border-radius: 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.tab-label {
|
|
36
|
-
margin-left: 2px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.el-tabs__item.is-left,
|
|
40
|
-
.t-tabs__nav-item {
|
|
10
|
+
.m-editor-sidebar-header-item {
|
|
41
11
|
line-height: 15px;
|
|
42
|
-
border: 0;
|
|
43
12
|
height: auto;
|
|
44
13
|
padding: 8px;
|
|
45
14
|
color: rgb(255, 255, 255);
|
|
46
15
|
box-sizing: border-box;
|
|
16
|
+
cursor: pointer;
|
|
47
17
|
|
|
48
|
-
&.is-
|
|
49
|
-
|
|
50
|
-
&.is-active,
|
|
51
|
-
&.t-is-active {
|
|
52
|
-
background: $--sidebar-content-background-color;
|
|
53
|
-
border: 0;
|
|
54
|
-
|
|
55
|
-
i {
|
|
56
|
-
color: #353140;
|
|
57
|
-
}
|
|
18
|
+
&.is-active {
|
|
19
|
+
background: $--sidebar-content-background-color;
|
|
58
20
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
21
|
+
i {
|
|
22
|
+
color: #353140;
|
|
62
23
|
}
|
|
63
24
|
|
|
64
|
-
|
|
65
|
-
|
|
25
|
+
.magic-editor-tab-panel-title {
|
|
26
|
+
color: #353140;
|
|
66
27
|
}
|
|
67
28
|
}
|
|
68
29
|
}
|
|
69
30
|
|
|
70
|
-
.t-tabs__nav-item {
|
|
71
|
-
padding: 7px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
31
|
i {
|
|
75
32
|
font-size: 25px;
|
|
76
33
|
color: rgba(255, 255, 255, 0.6);
|
|
@@ -86,6 +43,12 @@
|
|
|
86
43
|
}
|
|
87
44
|
}
|
|
88
45
|
|
|
46
|
+
.m-editor-sidebar-content {
|
|
47
|
+
height: 100%;
|
|
48
|
+
width: calc(100% - 40px);
|
|
49
|
+
overflow: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
89
52
|
.el-scrollbar {
|
|
90
53
|
height: 100%;
|
|
91
54
|
}
|
|
@@ -109,9 +72,4 @@
|
|
|
109
72
|
background: rgba(0, 0, 0, 0.2);
|
|
110
73
|
}
|
|
111
74
|
}
|
|
112
|
-
|
|
113
|
-
.el-tabs__content,
|
|
114
|
-
.el-tab-pane {
|
|
115
|
-
height: 100%;
|
|
116
|
-
}
|
|
117
75
|
}
|