@tmagic/editor 1.2.12 → 1.2.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/dist/style.css +61 -39
- package/dist/tmagic-editor.js +890 -518
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +909 -544
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +14 -13
- package/src/components/CodeDraftEditor.vue +20 -17
- package/src/components/ContentMenu.vue +1 -1
- package/src/components/FunctionEditor.vue +10 -10
- package/src/components/Layout.vue +1 -1
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/SearchInput.vue +26 -0
- package/src/fields/CodeSelect.vue +18 -101
- package/src/fields/CodeSelectCol.vue +21 -3
- package/src/fields/EventSelect.vue +5 -3
- package/src/fields/UISelect.vue +1 -1
- package/src/icons/AppManageIcon.vue +11 -0
- package/src/icons/CodeIcon.vue +35 -0
- package/src/layouts/AddPageBox.vue +3 -3
- package/src/layouts/Framework.vue +4 -4
- package/src/layouts/NavMenu.vue +2 -2
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +11 -12
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +6 -15
- package/src/layouts/sidebar/Sidebar.vue +3 -3
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +22 -10
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +56 -51
- package/src/layouts/workspace/Breadcrumb.vue +1 -1
- package/src/layouts/workspace/PageBar.vue +2 -2
- package/src/layouts/workspace/PageBarScrollContainer.vue +3 -3
- package/src/layouts/workspace/Stage.vue +3 -3
- package/src/layouts/workspace/ViewerMenu.vue +4 -4
- package/src/layouts/workspace/Workspace.vue +1 -1
- package/src/services/BaseService.ts +1 -1
- package/src/services/codeBlock.ts +10 -13
- package/src/services/componentList.ts +1 -1
- package/src/services/editor.ts +6 -6
- package/src/services/events.ts +1 -1
- package/src/services/history.ts +2 -2
- package/src/services/props.ts +2 -2
- package/src/services/ui.ts +2 -2
- package/src/theme/code-block.scss +42 -11
- package/src/theme/component-list-panel.scss +0 -15
- package/src/theme/event.scss +12 -0
- package/src/theme/layer-panel.scss +0 -14
- package/src/theme/search-input.scss +14 -0
- package/src/theme/theme.scss +1 -0
- package/src/utils/config.ts +1 -1
- package/src/utils/dep.ts +2 -2
- package/src/utils/editor.ts +1 -1
- package/src/utils/operator.ts +4 -4
- package/src/utils/stage.ts +3 -3
- package/tsconfig.build.json +4 -1
- package/types/components/CodeDraftEditor.vue.d.ts +7 -4
- package/types/components/ContentMenu.vue.d.ts +3 -3
- package/types/components/FunctionEditor.vue.d.ts +140 -8
- package/types/components/Icon.vue.d.ts +2 -2
- package/types/components/Layout.vue.d.ts +28 -113
- package/types/components/ScrollBar.vue.d.ts +2 -2
- package/types/components/ScrollViewer.vue.d.ts +32 -135
- package/types/components/SearchInput.vue.d.ts +4 -0
- package/types/components/ToolButton.vue.d.ts +3 -3
- package/types/fields/Code.vue.d.ts +2 -2
- package/types/fields/CodeLink.vue.d.ts +2 -2
- package/types/fields/CodeSelect.vue.d.ts +8 -27
- package/types/fields/CodeSelectCol.vue.d.ts +3 -3
- package/types/fields/EventSelect.vue.d.ts +3 -3
- package/types/fields/UISelect.vue.d.ts +2 -2
- package/types/icons/AppManageIcon.vue.d.ts +2 -0
- package/types/icons/CodeIcon.vue.d.ts +2 -0
- package/types/layouts/CodeEditor.vue.d.ts +4 -4
- package/types/layouts/Framework.vue.d.ts +23 -74
- package/types/layouts/NavMenu.vue.d.ts +3 -3
- package/types/layouts/PropsPanel.vue.d.ts +11 -60
- package/types/layouts/Resizer.vue.d.ts +9 -54
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +11 -50
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +2 -2
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +17 -60
- package/types/layouts/sidebar/Sidebar.vue.d.ts +39 -104
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +15 -58
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +21 -66
- package/types/layouts/workspace/PageBar.vue.d.ts +13 -52
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +8 -48
- package/types/layouts/workspace/Stage.vue.d.ts +2 -2
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +3 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +20 -63
- package/types/services/codeBlock.d.ts +4 -4
- package/types/services/componentList.d.ts +1 -1
- package/types/services/dep.d.ts +2 -2
- package/types/services/editor.d.ts +1 -1
- package/types/services/events.d.ts +1 -1
- package/types/services/history.d.ts +2 -2
- package/types/services/props.d.ts +78 -1
- package/types/services/storage.d.ts +1 -1
- package/types/services/ui.d.ts +2 -2
- package/types/type.d.ts +8 -8
- package/types/utils/operator.d.ts +1 -1
- package/types/utils/props.d.ts +78 -1
|
@@ -2,15 +2,7 @@
|
|
|
2
2
|
<TMagicScrollbar class="magic-editor-layer-panel">
|
|
3
3
|
<slot name="layer-panel-header"></slot>
|
|
4
4
|
|
|
5
|
-
<
|
|
6
|
-
v-model="filterText"
|
|
7
|
-
class="search-input"
|
|
8
|
-
size="small"
|
|
9
|
-
placeholder="输入关键字进行过滤"
|
|
10
|
-
clearable
|
|
11
|
-
:prefix-icon="Search"
|
|
12
|
-
@change="filterTextChangeHandler"
|
|
13
|
-
></TMagicInput>
|
|
5
|
+
<SearchInput @search="filterTextChangeHandler"></SearchInput>
|
|
14
6
|
|
|
15
7
|
<TMagicTree
|
|
16
8
|
v-if="values.length"
|
|
@@ -58,17 +50,17 @@
|
|
|
58
50
|
|
|
59
51
|
<script lang="ts" setup name="MEditorLayerPanel">
|
|
60
52
|
import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
61
|
-
import { Search } from '@element-plus/icons-vue';
|
|
62
53
|
import KeyController from 'keycon';
|
|
63
54
|
import { difference, throttle, union } from 'lodash-es';
|
|
64
55
|
|
|
65
|
-
import {
|
|
56
|
+
import { TMagicScrollbar, TMagicTree } from '@tmagic/design';
|
|
66
57
|
import type { Id, MNode, MPage } from '@tmagic/schema';
|
|
67
58
|
import { MContainer, NodeType } from '@tmagic/schema';
|
|
68
59
|
import { getNodePath, isPage } from '@tmagic/utils';
|
|
69
60
|
|
|
70
|
-
import
|
|
71
|
-
import {
|
|
61
|
+
import SearchInput from '@editor/components/SearchInput.vue';
|
|
62
|
+
import type { MenuButton, MenuComponent, Services } from '@editor/type';
|
|
63
|
+
import { Layout } from '@editor/type';
|
|
72
64
|
|
|
73
65
|
import LayerMenu from './LayerMenu.vue';
|
|
74
66
|
|
|
@@ -87,7 +79,6 @@ const menu = ref<InstanceType<typeof LayerMenu>>();
|
|
|
87
79
|
const checkedKeys = ref<Id[]>([]);
|
|
88
80
|
// 是否多选
|
|
89
81
|
const isCtrlKeyDown = ref(false);
|
|
90
|
-
const filterText = ref('');
|
|
91
82
|
// 默认展开节点
|
|
92
83
|
const expandedKeys = ref<Id[]>([]);
|
|
93
84
|
const currentNodeKey = ref<Id>();
|
|
@@ -147,7 +138,7 @@ const allowDrop = (draggingNode: any, dropNode: any, type: string): boolean => {
|
|
|
147
138
|
|
|
148
139
|
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE) return false;
|
|
149
140
|
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE) return false;
|
|
150
|
-
if (!data
|
|
141
|
+
if (!data?.type) return false;
|
|
151
142
|
if (['prev', 'next'].includes(type)) return true;
|
|
152
143
|
if (data.items || data.type === 'container') return true;
|
|
153
144
|
|
|
@@ -89,9 +89,9 @@ import { Coin, EditPen, Files } from '@element-plus/icons-vue';
|
|
|
89
89
|
|
|
90
90
|
import { getConfig, TMagicTabs } from '@tmagic/design';
|
|
91
91
|
|
|
92
|
-
import MIcon from '
|
|
93
|
-
import type { MenuButton, MenuComponent, SideComponent, SideItem } from '
|
|
94
|
-
import { SideBarData } from '
|
|
92
|
+
import MIcon from '@editor/components/Icon.vue';
|
|
93
|
+
import type { MenuButton, MenuComponent, SideComponent, SideItem } from '@editor/type';
|
|
94
|
+
import { SideBarData } from '@editor/type';
|
|
95
95
|
|
|
96
96
|
import CodeBlockList from './code-block/CodeBlockList.vue';
|
|
97
97
|
import ComponentListPanel from './ComponentListPanel.vue';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
:model-value="true"
|
|
2
|
+
<TMagicDrawer
|
|
4
3
|
class="code-editor-dialog"
|
|
4
|
+
:model-value="true"
|
|
5
5
|
:title="currentTitle"
|
|
6
|
-
:
|
|
7
|
-
:close-on-press-escape="false"
|
|
6
|
+
:close-on-press-escape="true"
|
|
8
7
|
:append-to-body="true"
|
|
9
8
|
:show-close="false"
|
|
9
|
+
:close-on-click-modal="true"
|
|
10
|
+
:size="size"
|
|
11
|
+
:before-close="handleClose"
|
|
10
12
|
>
|
|
11
13
|
<Layout v-model:left="left" :min-left="45" class="code-editor-layout">
|
|
12
14
|
<!-- 右侧区域 -->
|
|
@@ -14,6 +16,7 @@
|
|
|
14
16
|
<div v-if="!isEmpty(codeConfig)" class="m-editor-code-block-editor-panel">
|
|
15
17
|
<slot name="code-block-edit-panel-header" :id="id"></slot>
|
|
16
18
|
<FunctionEditor
|
|
19
|
+
ref="functionEditor"
|
|
17
20
|
v-if="codeConfig"
|
|
18
21
|
:id="id"
|
|
19
22
|
:name="codeConfig.name"
|
|
@@ -26,21 +29,21 @@
|
|
|
26
29
|
</div>
|
|
27
30
|
</template>
|
|
28
31
|
</Layout>
|
|
29
|
-
</
|
|
32
|
+
</TMagicDrawer>
|
|
30
33
|
</template>
|
|
31
34
|
|
|
32
35
|
<script lang="ts" setup name="MEditorCodeBlockEditor">
|
|
33
36
|
import { computed, inject, reactive, ref, watchEffect } from 'vue';
|
|
34
37
|
import { cloneDeep, forIn, isEmpty } from 'lodash-es';
|
|
35
38
|
|
|
36
|
-
import {
|
|
39
|
+
import { TMagicDrawer } from '@tmagic/design';
|
|
37
40
|
import { ColumnConfig } from '@tmagic/form';
|
|
38
41
|
import { CodeBlockContent } from '@tmagic/schema';
|
|
39
42
|
|
|
40
|
-
import FunctionEditor from '
|
|
41
|
-
import Layout from '
|
|
42
|
-
import type { ListState, Services } from '
|
|
43
|
-
import { serializeConfig } from '
|
|
43
|
+
import FunctionEditor from '@editor/components/FunctionEditor.vue';
|
|
44
|
+
import Layout from '@editor/components/Layout.vue';
|
|
45
|
+
import type { ListState, Services } from '@editor/type';
|
|
46
|
+
import { serializeConfig } from '@editor/utils/editor';
|
|
44
47
|
|
|
45
48
|
const services = inject<Services>('services');
|
|
46
49
|
const codeOptions = inject('codeOptions', {});
|
|
@@ -49,6 +52,8 @@ defineProps<{
|
|
|
49
52
|
paramsColConfig?: ColumnConfig;
|
|
50
53
|
}>();
|
|
51
54
|
|
|
55
|
+
const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get('columnWidth').left || 0));
|
|
56
|
+
|
|
52
57
|
const left = ref(200);
|
|
53
58
|
const currentTitle = ref('');
|
|
54
59
|
// 编辑器当前需展示的代码块内容
|
|
@@ -81,4 +86,11 @@ watchEffect(async () => {
|
|
|
81
86
|
});
|
|
82
87
|
currentTitle.value = state.codeList[0]?.name || '';
|
|
83
88
|
});
|
|
89
|
+
|
|
90
|
+
const functionEditor = ref<InstanceType<typeof FunctionEditor>>();
|
|
91
|
+
|
|
92
|
+
const handleClose = async () => {
|
|
93
|
+
// 触发codeDraftEditor组件关闭事件
|
|
94
|
+
await functionEditor.value?.codeDraftEditor?.close();
|
|
95
|
+
};
|
|
84
96
|
</script>
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicScrollbar class="m-editor-code-block-list">
|
|
3
3
|
<slot name="code-block-panel-header">
|
|
4
4
|
<div class="code-header-wrapper">
|
|
5
|
-
<
|
|
6
|
-
:class="[editable ? 'code-filter-input' : 'code-filter-input-no-btn']"
|
|
7
|
-
size="small"
|
|
8
|
-
placeholder="输入关键字进行过滤"
|
|
9
|
-
clearable
|
|
10
|
-
v-model="filterText"
|
|
11
|
-
@input="filterTextChangeHandler"
|
|
12
|
-
></TMagicInput>
|
|
5
|
+
<SearchInput @search="filterTextChangeHandler"></SearchInput>
|
|
13
6
|
<TMagicButton class="create-code-button" type="primary" size="small" @click="createCodeBlock" v-if="editable"
|
|
14
7
|
>新增</TMagicButton
|
|
15
8
|
>
|
|
@@ -17,38 +10,40 @@
|
|
|
17
10
|
</slot>
|
|
18
11
|
|
|
19
12
|
<!-- 代码块列表 -->
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
>
|
|
33
|
-
<
|
|
34
|
-
<div
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
13
|
+
<TMagicTree
|
|
14
|
+
ref="tree"
|
|
15
|
+
class="magic-editor-layer-tree"
|
|
16
|
+
node-key="id"
|
|
17
|
+
empty-text="暂无代码块"
|
|
18
|
+
:default-expanded-keys="expandedKeys"
|
|
19
|
+
:expand-on-click-node="false"
|
|
20
|
+
:data="codeList"
|
|
21
|
+
:highlight-current="true"
|
|
22
|
+
:filter-node-method="filterNode"
|
|
23
|
+
@node-click="clickHandler"
|
|
24
|
+
>
|
|
25
|
+
<template #default="{ data }">
|
|
26
|
+
<div :id="data.id" class="list-container">
|
|
27
|
+
<div class="list-item">
|
|
28
|
+
<CodeIcon v-if="data.type === 'code'" class="codeIcon"></CodeIcon>
|
|
29
|
+
<AppManageIcon v-if="data.type === 'node'" class="compIcon"></AppManageIcon>
|
|
30
|
+
<span class="code-name" :class="{ code: data.type === 'code', hook: data.type === 'key' }"
|
|
31
|
+
>{{ data.name }}({{ data.id }})</span
|
|
32
|
+
>
|
|
33
|
+
<!-- 右侧工具栏 -->
|
|
34
|
+
<div class="right-tool" v-if="data.type === 'code'">
|
|
35
|
+
<TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
|
|
36
|
+
<Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.id}`)"></Icon>
|
|
37
|
+
</TMagicTooltip>
|
|
38
|
+
<TMagicTooltip effect="dark" content="删除" placement="bottom" v-if="editable">
|
|
39
|
+
<Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
|
|
40
|
+
</TMagicTooltip>
|
|
41
|
+
<slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
|
|
47
42
|
</div>
|
|
48
43
|
</div>
|
|
49
|
-
</
|
|
50
|
-
</
|
|
51
|
-
</
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
</TMagicTree>
|
|
52
47
|
|
|
53
48
|
<!-- 代码块编辑区 -->
|
|
54
49
|
<CodeBlockEditor v-if="isShowCodeBlockEditor" :paramsColConfig="paramsColConfig">
|
|
@@ -56,19 +51,22 @@
|
|
|
56
51
|
<slot name="code-block-edit-panel-header" :id="id"></slot>
|
|
57
52
|
</template>
|
|
58
53
|
</CodeBlockEditor>
|
|
59
|
-
</
|
|
54
|
+
</TMagicScrollbar>
|
|
60
55
|
</template>
|
|
61
56
|
|
|
62
57
|
<script setup lang="ts" name="MEditorCodeBlockList">
|
|
63
58
|
import { computed, inject, ref } from 'vue';
|
|
64
59
|
import { Close, Edit, View } from '@element-plus/icons-vue';
|
|
65
60
|
|
|
66
|
-
import { TMagicButton,
|
|
61
|
+
import { TMagicButton, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design';
|
|
67
62
|
import { ColumnConfig } from '@tmagic/form';
|
|
68
63
|
import { CodeBlockContent, Id } from '@tmagic/schema';
|
|
69
64
|
|
|
70
|
-
import Icon from '
|
|
71
|
-
import
|
|
65
|
+
import Icon from '@editor/components/Icon.vue';
|
|
66
|
+
import SearchInput from '@editor/components/SearchInput.vue';
|
|
67
|
+
import AppManageIcon from '@editor/icons/AppManageIcon.vue';
|
|
68
|
+
import CodeIcon from '@editor/icons/CodeIcon.vue';
|
|
69
|
+
import { CodeDeleteErrorType, CodeDslItem, Services } from '@editor/type';
|
|
72
70
|
|
|
73
71
|
import CodeBlockEditor from './CodeBlockEditor.vue';
|
|
74
72
|
|
|
@@ -81,19 +79,27 @@ const { codeBlockService, depService, editorService } = inject<Services>('servic
|
|
|
81
79
|
|
|
82
80
|
// 代码块列表
|
|
83
81
|
const codeList = computed(() =>
|
|
84
|
-
Object.values(depService?.targets['code-block'] || {}).map((target) =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
type: 'code',
|
|
88
|
-
children: Object.entries(target.deps).map(([id, dep]) => ({
|
|
82
|
+
Object.values(depService?.targets['code-block'] || {}).map((target) => {
|
|
83
|
+
// 组件节点
|
|
84
|
+
const compNodes = Object.entries(target.deps).map(([id, dep]) => ({
|
|
89
85
|
name: dep.name,
|
|
90
86
|
type: 'node',
|
|
91
87
|
id,
|
|
92
88
|
children: dep.keys.map((key) => ({ name: key, id: key, type: 'key' })),
|
|
93
|
-
}))
|
|
94
|
-
|
|
89
|
+
}));
|
|
90
|
+
return {
|
|
91
|
+
id: target.id,
|
|
92
|
+
name: target.name,
|
|
93
|
+
type: 'code',
|
|
94
|
+
codeBlockContent: codeBlockService?.getCodeContentById(target.id),
|
|
95
|
+
children: compNodes,
|
|
96
|
+
};
|
|
97
|
+
}),
|
|
95
98
|
);
|
|
96
99
|
|
|
100
|
+
// 默认展开组件层级的节点
|
|
101
|
+
const expandedKeys = computed(() => codeList.value.map((item) => item.id));
|
|
102
|
+
|
|
97
103
|
const editable = computed(() => codeBlockService?.getEditStatus());
|
|
98
104
|
|
|
99
105
|
// 是否展示代码编辑区
|
|
@@ -140,7 +146,6 @@ const deleteCode = (key: Id) => {
|
|
|
140
146
|
}
|
|
141
147
|
};
|
|
142
148
|
|
|
143
|
-
const filterText = ref('');
|
|
144
149
|
const tree = ref<InstanceType<typeof TMagicTree>>();
|
|
145
150
|
|
|
146
151
|
const filterNode = (value: string, data: CodeDslItem): boolean => {
|
|
@@ -14,7 +14,7 @@ import { TMagicButton } from '@tmagic/design';
|
|
|
14
14
|
import type { MNode } from '@tmagic/schema';
|
|
15
15
|
import { getNodePath } from '@tmagic/utils';
|
|
16
16
|
|
|
17
|
-
import type { Services } from '
|
|
17
|
+
import type { Services } from '@editor/type';
|
|
18
18
|
|
|
19
19
|
const services = inject<Services>('services');
|
|
20
20
|
const editorService = services?.editorService;
|
|
@@ -53,8 +53,8 @@ import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
|
53
53
|
import { TMagicIcon, TMagicPopover, TMagicTooltip } from '@tmagic/design';
|
|
54
54
|
import type { MPage } from '@tmagic/schema';
|
|
55
55
|
|
|
56
|
-
import ToolButton from '
|
|
57
|
-
import type { Services } from '
|
|
56
|
+
import ToolButton from '@editor/components/ToolButton.vue';
|
|
57
|
+
import type { Services } from '@editor/type';
|
|
58
58
|
|
|
59
59
|
import PageBarScrollContainer from './PageBarScrollContainer.vue';
|
|
60
60
|
|
|
@@ -32,9 +32,9 @@ import { ArrowLeftBold, ArrowRightBold, Plus } from '@element-plus/icons-vue';
|
|
|
32
32
|
|
|
33
33
|
import { NodeType } from '@tmagic/schema';
|
|
34
34
|
|
|
35
|
-
import Icon from '
|
|
36
|
-
import type { Services } from '
|
|
37
|
-
import { generatePageNameByApp } from '
|
|
35
|
+
import Icon from '@editor/components/Icon.vue';
|
|
36
|
+
import type { Services } from '@editor/type';
|
|
37
|
+
import { generatePageNameByApp } from '@editor/utils/editor';
|
|
38
38
|
|
|
39
39
|
const services = inject<Services>('services');
|
|
40
40
|
const editorService = services?.editorService;
|
|
@@ -33,9 +33,9 @@ import { cloneDeep } from 'lodash-es';
|
|
|
33
33
|
import type { MContainer } from '@tmagic/schema';
|
|
34
34
|
import StageCore, { calcValueByFontsize, getOffset, Runtime } from '@tmagic/stage';
|
|
35
35
|
|
|
36
|
-
import ScrollViewer from '
|
|
37
|
-
import { Layout, MenuButton, MenuComponent, Services, StageOptions } from '
|
|
38
|
-
import { useStage } from '
|
|
36
|
+
import ScrollViewer from '@editor/components/ScrollViewer.vue';
|
|
37
|
+
import { Layout, MenuButton, MenuComponent, Services, StageOptions } from '@editor/type';
|
|
38
|
+
import { useStage } from '@editor/utils/stage';
|
|
39
39
|
|
|
40
40
|
import ViewerMenu from './ViewerMenu.vue';
|
|
41
41
|
|
|
@@ -9,10 +9,10 @@ import { Bottom, CopyDocument, Delete, DocumentCopy, Top } from '@element-plus/i
|
|
|
9
9
|
import { NodeType } from '@tmagic/schema';
|
|
10
10
|
import { isPage } from '@tmagic/utils';
|
|
11
11
|
|
|
12
|
-
import ContentMenu from '
|
|
13
|
-
import storageService from '
|
|
14
|
-
import { LayerOffset, Layout, MenuButton, MenuComponent, Services } from '
|
|
15
|
-
import { COPY_STORAGE_KEY } from '
|
|
12
|
+
import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
13
|
+
import storageService from '@editor/services/storage';
|
|
14
|
+
import { LayerOffset, Layout, MenuButton, MenuComponent, Services } from '@editor/type';
|
|
15
|
+
import { COPY_STORAGE_KEY } from '@editor/utils/editor';
|
|
16
16
|
|
|
17
17
|
const props = withDefaults(
|
|
18
18
|
defineProps<{ isMultiSelect?: boolean; stageContentMenu: (MenuButton | MenuComponent)[] }>(),
|
|
@@ -21,7 +21,7 @@ import KeyController from 'keycon';
|
|
|
21
21
|
|
|
22
22
|
import { isPage } from '@tmagic/utils';
|
|
23
23
|
|
|
24
|
-
import type { MenuButton, MenuComponent, Services } from '
|
|
24
|
+
import type { MenuButton, MenuComponent, Services } from '@editor/type';
|
|
25
25
|
|
|
26
26
|
import Breadcrumb from './Breadcrumb.vue';
|
|
27
27
|
import PageBar from './PageBar.vue';
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { EventEmitter } from 'events';
|
|
20
20
|
|
|
21
|
-
import { compose } from '
|
|
21
|
+
import { compose } from '@editor/utils/compose';
|
|
22
22
|
|
|
23
23
|
const methodName = (prefix: string, name: string) => `${prefix}${name[0].toUpperCase()}${name.substring(1)}`;
|
|
24
24
|
|
|
@@ -21,9 +21,9 @@ import { keys, pick } from 'lodash-es';
|
|
|
21
21
|
|
|
22
22
|
import { CodeBlockContent, CodeBlockDSL, Id } from '@tmagic/schema';
|
|
23
23
|
|
|
24
|
-
import type { CodeState } from '
|
|
25
|
-
import { CODE_DRAFT_STORAGE_KEY } from '
|
|
26
|
-
import { info } from '
|
|
24
|
+
import type { CodeState } from '@editor/type';
|
|
25
|
+
import { CODE_DRAFT_STORAGE_KEY } from '@editor/type';
|
|
26
|
+
import { info } from '@editor/utils/logger';
|
|
27
27
|
|
|
28
28
|
import BaseService from './BaseService';
|
|
29
29
|
|
|
@@ -39,9 +39,6 @@ class CodeBlock extends BaseService {
|
|
|
39
39
|
|
|
40
40
|
constructor() {
|
|
41
41
|
super([
|
|
42
|
-
'getCodeContentById',
|
|
43
|
-
'getCodeDslByIds',
|
|
44
|
-
'getCurrentDsl',
|
|
45
42
|
'setCodeDslById',
|
|
46
43
|
'setCodeEditorShowStatus',
|
|
47
44
|
'setEditStatus',
|
|
@@ -77,9 +74,9 @@ class CodeBlock extends BaseService {
|
|
|
77
74
|
* @param {Id} id 代码块id
|
|
78
75
|
* @returns {CodeBlockContent | null}
|
|
79
76
|
*/
|
|
80
|
-
public
|
|
77
|
+
public getCodeContentById(id: Id): CodeBlockContent | null {
|
|
81
78
|
if (!id) return null;
|
|
82
|
-
const totalCodeDsl =
|
|
79
|
+
const totalCodeDsl = this.getCodeDsl();
|
|
83
80
|
if (!totalCodeDsl) return null;
|
|
84
81
|
return totalCodeDsl[id] ?? null;
|
|
85
82
|
}
|
|
@@ -91,7 +88,7 @@ class CodeBlock extends BaseService {
|
|
|
91
88
|
* @returns {void}
|
|
92
89
|
*/
|
|
93
90
|
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
|
94
|
-
const codeDsl =
|
|
91
|
+
const codeDsl = this.getCodeDsl();
|
|
95
92
|
|
|
96
93
|
if (!codeDsl) {
|
|
97
94
|
throw new Error('dsl中没有codeBlocks');
|
|
@@ -119,8 +116,8 @@ class CodeBlock extends BaseService {
|
|
|
119
116
|
* @param {string[]} ids 代码块id数组
|
|
120
117
|
* @returns {CodeBlockDSL}
|
|
121
118
|
*/
|
|
122
|
-
public
|
|
123
|
-
const codeDsl =
|
|
119
|
+
public getCodeDslByIds(ids: string[]): CodeBlockDSL {
|
|
120
|
+
const codeDsl = this.getCodeDsl();
|
|
124
121
|
return pick(codeDsl, ids) as CodeBlockDSL;
|
|
125
122
|
}
|
|
126
123
|
|
|
@@ -157,8 +154,8 @@ class CodeBlock extends BaseService {
|
|
|
157
154
|
* 获取当前选中的代码块内容
|
|
158
155
|
* @returns {CodeBlockContent | null}
|
|
159
156
|
*/
|
|
160
|
-
public
|
|
161
|
-
return
|
|
157
|
+
public getCurrentDsl(): CodeBlockContent | null {
|
|
158
|
+
return this.getCodeContentById(this.state.id);
|
|
162
159
|
}
|
|
163
160
|
|
|
164
161
|
/**
|
package/src/services/editor.ts
CHANGED
|
@@ -24,10 +24,10 @@ import { NodeType } from '@tmagic/schema';
|
|
|
24
24
|
import StageCore from '@tmagic/stage';
|
|
25
25
|
import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
|
26
26
|
|
|
27
|
-
import historyService from '
|
|
28
|
-
import storageService, { Protocol } from '
|
|
29
|
-
import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '
|
|
30
|
-
import { LayerOffset, Layout } from '
|
|
27
|
+
import historyService from '@editor/services/history';
|
|
28
|
+
import storageService, { Protocol } from '@editor/services/storage';
|
|
29
|
+
import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '@editor/type';
|
|
30
|
+
import { LayerOffset, Layout } from '@editor/type';
|
|
31
31
|
import {
|
|
32
32
|
change2Fixed,
|
|
33
33
|
COPY_STORAGE_KEY,
|
|
@@ -37,8 +37,8 @@ import {
|
|
|
37
37
|
getNodeIndex,
|
|
38
38
|
isFixed,
|
|
39
39
|
setLayout,
|
|
40
|
-
} from '
|
|
41
|
-
import { beforePaste, getAddParent } from '
|
|
40
|
+
} from '@editor/utils/editor';
|
|
41
|
+
import { beforePaste, getAddParent } from '@editor/utils/operator';
|
|
42
42
|
|
|
43
43
|
import BaseService from './BaseService';
|
|
44
44
|
import propsService from './props';
|
package/src/services/events.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { cloneDeep } from 'lodash-es';
|
|
|
22
22
|
import { DEFAULT_EVENTS, DEFAULT_METHODS, EventOption } from '@tmagic/core';
|
|
23
23
|
import { toLine } from '@tmagic/utils';
|
|
24
24
|
|
|
25
|
-
import type { ComponentGroup } from '
|
|
25
|
+
import type { ComponentGroup } from '@editor/type';
|
|
26
26
|
|
|
27
27
|
import BaseService from './BaseService';
|
|
28
28
|
|
package/src/services/history.ts
CHANGED
|
@@ -20,8 +20,8 @@ import { reactive } from 'vue';
|
|
|
20
20
|
|
|
21
21
|
import type { MPage } from '@tmagic/schema';
|
|
22
22
|
|
|
23
|
-
import { HistoryState, StepValue } from '
|
|
24
|
-
import { UndoRedo } from '
|
|
23
|
+
import type { HistoryState, StepValue } from '@editor/type';
|
|
24
|
+
import { UndoRedo } from '@editor/utils/undo-redo';
|
|
25
25
|
|
|
26
26
|
import BaseService from './BaseService';
|
|
27
27
|
|
package/src/services/props.ts
CHANGED
|
@@ -23,8 +23,8 @@ import type { FormConfig } from '@tmagic/form';
|
|
|
23
23
|
import type { MComponent, MNode } from '@tmagic/schema';
|
|
24
24
|
import { toLine } from '@tmagic/utils';
|
|
25
25
|
|
|
26
|
-
import type { PropsState } from '
|
|
27
|
-
import { fillConfig } from '
|
|
26
|
+
import type { PropsState } from '@editor/type';
|
|
27
|
+
import { fillConfig } from '@editor/utils/props';
|
|
28
28
|
|
|
29
29
|
import BaseService from './BaseService';
|
|
30
30
|
|
package/src/services/ui.ts
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
20
|
|
|
21
|
-
import editorService from '
|
|
22
|
-
import type { StageRect, UiState } from '
|
|
21
|
+
import editorService from '@editor/services/editor';
|
|
22
|
+
import type { StageRect, UiState } from '@editor/type';
|
|
23
23
|
|
|
24
24
|
import BaseService from './BaseService';
|
|
25
25
|
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
.m-editor-code-block-list {
|
|
2
2
|
height: 100%;
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
.magic-editor-layer-tree {
|
|
5
|
+
padding-top: 48px;
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
.code-header-wrapper {
|
|
5
9
|
display: flex;
|
|
6
10
|
align-items: center;
|
|
7
11
|
justify-content: center;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
|
|
17
|
+
.search-input {
|
|
18
|
+
flex: 1;
|
|
19
|
+
position: relative;
|
|
14
20
|
}
|
|
21
|
+
|
|
15
22
|
.create-code-button {
|
|
16
23
|
margin-left: 2px;
|
|
17
24
|
margin-right: 10px;
|
|
@@ -27,22 +34,47 @@
|
|
|
27
34
|
overflow: hidden;
|
|
28
35
|
.list-item {
|
|
29
36
|
display: flex;
|
|
37
|
+
align-items: center;
|
|
30
38
|
width: 100%;
|
|
39
|
+
align-items: center;
|
|
31
40
|
|
|
32
41
|
.right-tool {
|
|
33
42
|
display: flex;
|
|
34
43
|
width: fit-content !important;
|
|
44
|
+
align-items: center;
|
|
45
|
+
margin-right: 10px;
|
|
35
46
|
.edit-icon {
|
|
36
47
|
margin: 0 5px;
|
|
37
48
|
}
|
|
38
49
|
}
|
|
50
|
+
|
|
51
|
+
.codeIcon {
|
|
52
|
+
width: 20px;
|
|
53
|
+
height: 20px;
|
|
54
|
+
margin-right: 5px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.compIcon {
|
|
58
|
+
width: 15px;
|
|
59
|
+
height: 15px;
|
|
60
|
+
margin-right: 5px;
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
.code-name {
|
|
40
64
|
white-space: nowrap;
|
|
41
65
|
overflow: hidden;
|
|
42
66
|
text-overflow: ellipsis;
|
|
43
67
|
width: 0 !important;
|
|
44
68
|
flex: 1;
|
|
45
|
-
line-height:
|
|
69
|
+
line-height: 22px;
|
|
70
|
+
|
|
71
|
+
&.code {
|
|
72
|
+
color: #000;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&.hook {
|
|
76
|
+
color: #909399;
|
|
77
|
+
}
|
|
46
78
|
}
|
|
47
79
|
}
|
|
48
80
|
}
|
|
@@ -50,9 +82,8 @@
|
|
|
50
82
|
|
|
51
83
|
.m-fields-code-select {
|
|
52
84
|
width: 100%;
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
margin-right: 5px;
|
|
85
|
+
.el-card__header {
|
|
86
|
+
display: none;
|
|
56
87
|
}
|
|
57
88
|
}
|
|
58
89
|
|
|
@@ -4,21 +4,6 @@
|
|
|
4
4
|
margin-top: 48px;
|
|
5
5
|
background-color: $--sidebar-content-background-color;
|
|
6
6
|
|
|
7
|
-
.search-input {
|
|
8
|
-
background: #fff;
|
|
9
|
-
color: #bbbbbb;
|
|
10
|
-
padding: 10px;
|
|
11
|
-
position: absolute;
|
|
12
|
-
top: 0;
|
|
13
|
-
left: 0;
|
|
14
|
-
box-sizing: border-box;
|
|
15
|
-
z-index: 1;
|
|
16
|
-
|
|
17
|
-
.el-input__prefix {
|
|
18
|
-
padding: 7px;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
7
|
.tmagic-design-collapse-item {
|
|
23
8
|
> div:first-of-type {
|
|
24
9
|
border-bottom: 1px solid $--border-color;
|