@tmagic/editor 1.2.0-beta.2 → 1.2.0-beta.4
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/tmagic-editor.mjs +415 -400
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +417 -402
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/components/ContentMenu.vue +2 -2
- package/src/components/Icon.vue +6 -4
- package/src/components/ToolButton.vue +29 -14
- package/src/fields/CodeSelect.vue +6 -6
- package/src/fields/UISelect.vue +8 -7
- package/src/layouts/AddPageBox.vue +2 -1
- package/src/layouts/Framework.vue +3 -2
- package/src/layouts/PropsPanel.vue +3 -8
- package/src/layouts/sidebar/ComponentListPanel.vue +13 -11
- package/src/layouts/sidebar/LayerPanel.vue +252 -162
- package/src/layouts/sidebar/Sidebar.vue +4 -2
- package/src/layouts/sidebar/TabPane.vue +4 -2
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +21 -16
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +19 -19
- package/src/layouts/workspace/PageBar.vue +11 -10
- package/types/Editor.vue.d.ts +2 -2
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +16 -883
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.0-beta.
|
|
2
|
+
"version": "1.2.0-beta.4",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/core": "^7.18.0",
|
|
47
47
|
"@element-plus/icons-vue": "^2.0.9",
|
|
48
|
-
"@tmagic/core": "1.2.0-beta.
|
|
49
|
-
"@tmagic/
|
|
50
|
-
"@tmagic/
|
|
51
|
-
"@tmagic/
|
|
52
|
-
"@tmagic/
|
|
48
|
+
"@tmagic/core": "1.2.0-beta.4",
|
|
49
|
+
"@tmagic/design": "1.2.0-beta.4",
|
|
50
|
+
"@tmagic/form": "1.2.0-beta.4",
|
|
51
|
+
"@tmagic/schema": "1.2.0-beta.4",
|
|
52
|
+
"@tmagic/stage": "1.2.0-beta.4",
|
|
53
|
+
"@tmagic/utils": "1.2.0-beta.4",
|
|
53
54
|
"buffer": "^6.0.3",
|
|
54
55
|
"color": "^3.1.3",
|
|
55
|
-
"element-plus": "^2.2.17",
|
|
56
56
|
"events": "^3.3.0",
|
|
57
57
|
"gesto": "^1.7.0",
|
|
58
58
|
"keycon": "^1.1.2",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"vue": "^3.2.37"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@tmagic/
|
|
66
|
-
"
|
|
65
|
+
"@tmagic/design": "1.2.0-beta.4",
|
|
66
|
+
"@tmagic/form": "1.2.0-beta.4",
|
|
67
67
|
"monaco-editor": "^0.34.0",
|
|
68
68
|
"vue": "^3.2.37"
|
|
69
69
|
},
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-if="menuData.length && visible" class="magic-editor-content-menu" ref="menu" :style="menuStyle">
|
|
3
3
|
<div>
|
|
4
|
-
<
|
|
4
|
+
<ToolButton
|
|
5
5
|
v-for="(item, index) in menuData"
|
|
6
6
|
event-type="mouseup"
|
|
7
7
|
:data="item"
|
|
8
8
|
:key="index"
|
|
9
9
|
@mouseup="hide"
|
|
10
10
|
@mouseenter="showSubMenu(item)"
|
|
11
|
-
></
|
|
11
|
+
></ToolButton>
|
|
12
12
|
</div>
|
|
13
13
|
<teleport to="body">
|
|
14
14
|
<content-menu
|
package/src/components/Icon.vue
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
2
|
+
<TMagicIcon v-if="!icon" class="magic-editor-icon"><Edit></Edit></TMagicIcon>
|
|
3
|
+
<TMagicIcon v-else-if="typeof icon === 'string' && icon.startsWith('http')" class="magic-editor-icon"
|
|
4
4
|
><img :src="icon"
|
|
5
|
-
/></
|
|
5
|
+
/></TMagicIcon>
|
|
6
6
|
<i v-else-if="typeof icon === 'string'" class="magic-editor-icon" :class="icon"></i>
|
|
7
|
-
<
|
|
7
|
+
<TMagicIcon v-else class="magic-editor-icon"><component :is="toRaw(icon)"></component></TMagicIcon>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
11
|
import { toRaw } from 'vue';
|
|
12
12
|
import { Edit } from '@element-plus/icons-vue';
|
|
13
13
|
|
|
14
|
+
import { TMagicIcon } from '@tmagic/design';
|
|
15
|
+
|
|
14
16
|
defineProps<{
|
|
15
17
|
icon?: any;
|
|
16
18
|
}>();
|
|
@@ -7,32 +7,37 @@
|
|
|
7
7
|
@mousedown="mousedownHandler(data, $event)"
|
|
8
8
|
@mouseup="mouseupHandler(data, $event)"
|
|
9
9
|
>
|
|
10
|
-
<
|
|
10
|
+
<TMagicDivider v-if="data.type === 'divider'" :direction="data.direction || 'vertical'"></TMagicDivider>
|
|
11
11
|
<div v-else-if="data.type === 'text'" class="menu-item-text">{{ data.text }}</div>
|
|
12
12
|
|
|
13
13
|
<template v-else-if="data.type === 'button'">
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></
|
|
14
|
+
<TMagicTooltip v-if="data.tooltip" effect="dark" placement="bottom-start" :content="data.tooltip">
|
|
15
|
+
<TMagicButton size="small" text :disabled="disabled"
|
|
16
|
+
><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton
|
|
17
17
|
>
|
|
18
|
-
</
|
|
19
|
-
<
|
|
20
|
-
><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></
|
|
18
|
+
</TMagicTooltip>
|
|
19
|
+
<TMagicButton v-else size="small" text :disabled="disabled"
|
|
20
|
+
><MIcon v-if="data.icon" :icon="data.icon"></MIcon><span>{{ data.text }}</span></TMagicButton
|
|
21
21
|
>
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
|
-
<
|
|
24
|
+
<TMagicDropdown
|
|
25
|
+
v-else-if="data.type === 'dropdown'"
|
|
26
|
+
trigger="click"
|
|
27
|
+
:disabled="disabled"
|
|
28
|
+
@command="dropdownHandler"
|
|
29
|
+
>
|
|
25
30
|
<span class="el-dropdown-link menubar-menu-button">
|
|
26
|
-
{{ data.text }}<
|
|
31
|
+
{{ data.text }}<TMagicIcon class="el-icon--right"><ArrowDown></ArrowDown></TMagicIcon>
|
|
27
32
|
</span>
|
|
28
33
|
<template #dropdown>
|
|
29
|
-
<
|
|
30
|
-
<
|
|
34
|
+
<TMagicDropdownMenu v-if="data.items && data.items.length">
|
|
35
|
+
<TMagicDropdownItem v-for="(subItem, index) in data.items" :key="index" :command="{ data, subItem }">{{
|
|
31
36
|
subItem.text
|
|
32
|
-
}}</
|
|
33
|
-
</
|
|
37
|
+
}}</TMagicDropdownItem>
|
|
38
|
+
</TMagicDropdownMenu>
|
|
34
39
|
</template>
|
|
35
|
-
</
|
|
40
|
+
</TMagicDropdown>
|
|
36
41
|
|
|
37
42
|
<component v-else-if="data.type === 'component'" v-bind="data.props || {}" :is="data.component"></component>
|
|
38
43
|
</div>
|
|
@@ -42,6 +47,16 @@
|
|
|
42
47
|
import { computed, inject } from 'vue';
|
|
43
48
|
import { ArrowDown } from '@element-plus/icons-vue';
|
|
44
49
|
|
|
50
|
+
import {
|
|
51
|
+
TMagicButton,
|
|
52
|
+
TMagicDivider,
|
|
53
|
+
TMagicDropdown,
|
|
54
|
+
TMagicDropdownItem,
|
|
55
|
+
TMagicDropdownMenu,
|
|
56
|
+
TMagicIcon,
|
|
57
|
+
TMagicTooltip,
|
|
58
|
+
} from '@tmagic/design';
|
|
59
|
+
|
|
45
60
|
import MIcon from '../components/Icon.vue';
|
|
46
61
|
import type { MenuButton, MenuComponent, Services } from '../type';
|
|
47
62
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-code-select" :key="fieldKey">
|
|
3
|
-
<
|
|
3
|
+
<TMagicCard shadow="never">
|
|
4
4
|
<template #header>
|
|
5
5
|
<m-fields-select
|
|
6
6
|
:config="selectConfig"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
></m-fields-select>
|
|
13
13
|
</template>
|
|
14
14
|
<div class="tool-bar">
|
|
15
|
-
<
|
|
15
|
+
<TMagicTooltip class="tool-item" effect="dark" content="查看代码块" placement="top">
|
|
16
16
|
<svg
|
|
17
17
|
@click="viewHandler"
|
|
18
18
|
preserveAspectRatio="xMidYMid meet"
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
d="m23 12l-7.071 7.071l-1.414-1.414L20.172 12l-5.657-5.657l1.414-1.414L23 12zM3.828 12l5.657 5.657l-1.414 1.414L1 12l7.071-7.071l1.414 1.414L3.828 12z"
|
|
27
27
|
></path>
|
|
28
28
|
</svg>
|
|
29
|
-
</
|
|
29
|
+
</TMagicTooltip>
|
|
30
30
|
</div>
|
|
31
|
-
</
|
|
31
|
+
</TMagicCard>
|
|
32
32
|
</div>
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
35
|
<script lang="ts" setup>
|
|
36
36
|
import { computed, defineEmits, defineProps, inject, ref, watchEffect } from 'vue';
|
|
37
|
-
import { ElMessage } from 'element-plus';
|
|
38
37
|
import { cloneDeep, map, xor } from 'lodash-es';
|
|
39
38
|
|
|
39
|
+
import { TMagicCard, tMagicMessage, TMagicTooltip } from '@tmagic/design';
|
|
40
40
|
import { SelectConfig } from '@tmagic/form';
|
|
41
41
|
|
|
42
42
|
import type { Services } from '../type';
|
|
@@ -128,7 +128,7 @@ const setCombineIds = async (codeIds: string[]) => {
|
|
|
128
128
|
|
|
129
129
|
const viewHandler = async () => {
|
|
130
130
|
if (props.model[props.name].length === 0) {
|
|
131
|
-
|
|
131
|
+
tMagicMessage.error('请先绑定代码块');
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
// 记录当前已被绑定的代码块,为查看弹窗的展示内容
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler">
|
|
3
|
-
<
|
|
3
|
+
<TMagicButton type="danger" :icon="Delete" text style="padding: 0">取消</TMagicButton>
|
|
4
4
|
</div>
|
|
5
5
|
<div class="m-fields-ui-select" v-else @click="startSelect" style="display: flex">
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
</
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
</
|
|
6
|
+
<TMagicTooltip v-if="val" content="清除">
|
|
7
|
+
<TMagicButton style="padding: 0" type="danger" :icon="Close" text @click.stop="deleteHandler"></TMagicButton>
|
|
8
|
+
</TMagicTooltip>
|
|
9
|
+
<TMagicTooltip :content="val ? toName + '_' + val : '点击此处选择'">
|
|
10
|
+
<TMagicButton text style="padding: 0; margin: 0">{{ val ? toName + '_' + val : '点击此处选择' }}</TMagicButton>
|
|
11
|
+
</TMagicTooltip>
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { computed, inject, ref } from 'vue';
|
|
17
17
|
import { Close, Delete } from '@element-plus/icons-vue';
|
|
18
18
|
|
|
19
|
+
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
19
20
|
import { FormState } from '@tmagic/form';
|
|
20
21
|
|
|
21
22
|
import { Services } from '../type';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="m-editor-empty-content">
|
|
4
4
|
<div class="m-editor-empty-button" @click="clickHandler">
|
|
5
5
|
<div>
|
|
6
|
-
<
|
|
6
|
+
<MIcon :icon="Plus"></MIcon>
|
|
7
7
|
</div>
|
|
8
8
|
<p>新增页面</p>
|
|
9
9
|
</div>
|
|
@@ -17,6 +17,7 @@ import { Plus } from '@element-plus/icons-vue';
|
|
|
17
17
|
|
|
18
18
|
import { NodeType } from '@tmagic/schema';
|
|
19
19
|
|
|
20
|
+
import MIcon from '../components/Icon.vue';
|
|
20
21
|
import type { Services } from '../type';
|
|
21
22
|
import { generatePageNameByApp } from '../utils';
|
|
22
23
|
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<template v-if="pageLength > 0" #right>
|
|
37
|
-
<
|
|
37
|
+
<TMagicScrollbar>
|
|
38
38
|
<slot name="props-panel"></slot>
|
|
39
|
-
</
|
|
39
|
+
</TMagicScrollbar>
|
|
40
40
|
</template>
|
|
41
41
|
</layout>
|
|
42
42
|
</div>
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
<script lang="ts" setup>
|
|
46
46
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
47
47
|
|
|
48
|
+
import { TMagicScrollbar } from '@tmagic/design';
|
|
48
49
|
import type { MApp } from '@tmagic/schema';
|
|
49
50
|
|
|
50
51
|
import { GetColumnWidth, Services } from '../type';
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
<script lang="ts" setup>
|
|
17
17
|
import { computed, getCurrentInstance, inject, onMounted, ref, watchEffect } from 'vue';
|
|
18
|
-
import { ElMessage } from 'element-plus';
|
|
19
18
|
|
|
19
|
+
import { tMagicMessage } from '@tmagic/design';
|
|
20
20
|
import type { FormValue, MForm } from '@tmagic/form';
|
|
21
21
|
import type { MNode } from '@tmagic/schema';
|
|
22
22
|
import type StageCore from '@tmagic/stage';
|
|
@@ -65,13 +65,8 @@ const submit = async () => {
|
|
|
65
65
|
services?.editorService.update(values);
|
|
66
66
|
} catch (e: any) {
|
|
67
67
|
console.error(e);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
duration: 10000,
|
|
71
|
-
showClose: true,
|
|
72
|
-
message: e.message,
|
|
73
|
-
dangerouslyUseHTMLString: true,
|
|
74
|
-
});
|
|
68
|
+
tMagicMessage.closeAll();
|
|
69
|
+
tMagicMessage.error(e.message);
|
|
75
70
|
}
|
|
76
71
|
};
|
|
77
72
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicScrollbar>
|
|
3
3
|
<slot name="component-list-panel-header"></slot>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
<
|
|
5
|
+
<TMagicCollapse class="ui-component-panel" :model-value="collapseValue">
|
|
6
|
+
<TMagicInput
|
|
7
7
|
prefix-icon="el-icon-search"
|
|
8
8
|
placeholder="输入关键字进行过滤"
|
|
9
9
|
class="search-input"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
v-model="searchText"
|
|
13
13
|
/>
|
|
14
14
|
<template v-for="(group, index) in list">
|
|
15
|
-
<
|
|
16
|
-
<template #title><
|
|
15
|
+
<TMagicCollapseItem v-if="group.items && group.items.length" :key="index" :name="`${index}`">
|
|
16
|
+
<template #title><MIcon :icon="Grid"></MIcon>{{ group.title }}</template>
|
|
17
17
|
<div
|
|
18
18
|
v-for="item in group.items"
|
|
19
19
|
class="component-item"
|
|
@@ -27,21 +27,23 @@
|
|
|
27
27
|
<slot name="component-list-item" :component="item">
|
|
28
28
|
<MIcon :icon="item.icon"></MIcon>
|
|
29
29
|
|
|
30
|
-
<
|
|
30
|
+
<TMagicTooltip effect="dark" placement="bottom" :content="item.text">
|
|
31
31
|
<span>{{ item.text }}</span>
|
|
32
|
-
</
|
|
32
|
+
</TMagicTooltip>
|
|
33
33
|
</slot>
|
|
34
34
|
</div>
|
|
35
|
-
</
|
|
35
|
+
</TMagicCollapseItem>
|
|
36
36
|
</template>
|
|
37
|
-
</
|
|
38
|
-
</
|
|
37
|
+
</TMagicCollapse>
|
|
38
|
+
</TMagicScrollbar>
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
41
|
<script lang="ts" setup>
|
|
42
42
|
import { computed, inject, ref } from 'vue';
|
|
43
|
+
import { Grid } from '@element-plus/icons-vue';
|
|
43
44
|
import serialize from 'serialize-javascript';
|
|
44
45
|
|
|
46
|
+
import { TMagicCollapse, TMagicCollapseItem, TMagicInput, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
|
|
45
47
|
import type StageCore from '@tmagic/stage';
|
|
46
48
|
import { removeClassNameByClassName } from '@tmagic/utils';
|
|
47
49
|
|
|
@@ -62,7 +64,7 @@ const list = computed(() =>
|
|
|
62
64
|
const collapseValue = computed(() =>
|
|
63
65
|
Array(list.value?.length)
|
|
64
66
|
.fill(1)
|
|
65
|
-
.map((x, i) => i),
|
|
67
|
+
.map((x, i) => `${i}`),
|
|
66
68
|
);
|
|
67
69
|
|
|
68
70
|
let timeout: NodeJS.Timeout | undefined;
|