@tmagic/editor 1.2.0-beta.1 → 1.2.0-beta.3
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 +769 -768
- package/dist/tmagic-editor.mjs.map +1 -1
- package/dist/tmagic-editor.umd.js +773 -771
- package/dist/tmagic-editor.umd.js.map +1 -1
- package/package.json +9 -9
- package/src/Editor.vue +2 -2
- package/src/components/ContentMenu.vue +2 -2
- package/src/components/Icon.vue +6 -4
- package/src/components/ToolButton.vue +29 -14
- package/src/fields/Code.vue +4 -1
- package/src/fields/CodeLink.vue +19 -11
- package/src/fields/CodeSelect.vue +6 -6
- package/src/fields/UISelect.vue +8 -7
- package/src/index.ts +2 -1
- package/src/layouts/AddPageBox.vue +13 -20
- package/src/layouts/CodeEditor.vue +106 -120
- 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/LayerMenu.vue +86 -91
- package/src/layouts/sidebar/LayerPanel.vue +252 -162
- package/src/layouts/sidebar/Sidebar.vue +24 -28
- package/src/layouts/sidebar/TabPane.vue +43 -51
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +22 -18
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +21 -21
- package/src/layouts/workspace/PageBar.vue +11 -10
- package/src/services/codeBlock.ts +16 -10
- package/src/services/editor.ts +4 -4
- package/src/theme/index.scss +1 -15
- package/src/theme/theme.scss +15 -0
- package/src/type.ts +1 -1
- package/types/Editor.vue.d.ts +2 -2
- package/types/fields/Code.vue.d.ts +8 -0
- package/types/fields/CodeLink.vue.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +45 -3
- package/types/layouts/CodeEditor.vue.d.ts +160 -45
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +16 -64
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +16 -1071
- package/types/layouts/sidebar/Sidebar.vue.d.ts +114 -17
- package/types/layouts/sidebar/TabPane.vue.d.ts +80 -12
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +1 -0
- package/types/services/codeBlock.d.ts +1 -1
- package/types/services/editor.d.ts +2 -2
- package/types/type.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicTabPane v-if="config" :name="config.text">
|
|
3
3
|
<template #label>
|
|
4
4
|
<div :key="config.text">
|
|
5
5
|
<m-icon v-if="config.icon" :icon="config.icon"></m-icon>
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
<component v-else-if="config.slots?.codeBlockPanelHeader" :is="config.slots.codeBlockPanelHeader" />
|
|
36
36
|
</template>
|
|
37
37
|
|
|
38
|
-
<template #code-block-panel-tool="{ id }" v-if="data === 'code-block' || config.slots?.codeBlockPanelTool">
|
|
39
|
-
<slot v-if="data === 'code-block'" name="code-block-panel-tool" :id="id"></slot>
|
|
38
|
+
<template #code-block-panel-tool="{ id, data }" v-if="data === 'code-block' || config.slots?.codeBlockPanelTool">
|
|
39
|
+
<slot v-if="data === 'code-block'" name="code-block-panel-tool" :id="id" :data="data"></slot>
|
|
40
40
|
<component v-else-if="config.slots?.codeBlockPanelTool" :is="config.slots.codeBlockPanelTool" />
|
|
41
41
|
</template>
|
|
42
42
|
|
|
@@ -61,13 +61,15 @@
|
|
|
61
61
|
/>
|
|
62
62
|
</template>
|
|
63
63
|
</component>
|
|
64
|
-
</
|
|
64
|
+
</TMagicTabPane>
|
|
65
65
|
</template>
|
|
66
66
|
|
|
67
|
-
<script lang="ts">
|
|
68
|
-
import { computed
|
|
67
|
+
<script lang="ts" setup>
|
|
68
|
+
import { computed } from 'vue';
|
|
69
69
|
import { Coin, EditPen, Files } from '@element-plus/icons-vue';
|
|
70
70
|
|
|
71
|
+
import { TMagicTabPane } from '@tmagic/design';
|
|
72
|
+
|
|
71
73
|
import MIcon from '../../components/Icon.vue';
|
|
72
74
|
import { SideComponent, SideItem } from '../../type';
|
|
73
75
|
|
|
@@ -75,52 +77,42 @@ import CodeBlockList from './code-block/CodeBlockList.vue';
|
|
|
75
77
|
import ComponentListPanel from './ComponentListPanel.vue';
|
|
76
78
|
import LayerPanel from './LayerPanel.vue';
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
props: {
|
|
82
|
-
data: {
|
|
83
|
-
type: [Object, String] as PropType<SideItem>,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
80
|
+
const props = defineProps<{
|
|
81
|
+
data?: SideItem;
|
|
82
|
+
}>();
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return props.data;
|
|
92
|
-
}
|
|
84
|
+
const config = computed<SideComponent | undefined>(() => {
|
|
85
|
+
if (typeof props.data !== 'string') {
|
|
86
|
+
return props.data;
|
|
87
|
+
}
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}),
|
|
123
|
-
};
|
|
124
|
-
},
|
|
89
|
+
switch (props.data) {
|
|
90
|
+
case 'component-list':
|
|
91
|
+
return {
|
|
92
|
+
type: 'component',
|
|
93
|
+
icon: Coin,
|
|
94
|
+
text: '组件',
|
|
95
|
+
component: ComponentListPanel,
|
|
96
|
+
slots: {},
|
|
97
|
+
};
|
|
98
|
+
case 'layer':
|
|
99
|
+
return {
|
|
100
|
+
type: 'component',
|
|
101
|
+
icon: Files,
|
|
102
|
+
text: '已选组件',
|
|
103
|
+
component: LayerPanel,
|
|
104
|
+
slots: {},
|
|
105
|
+
};
|
|
106
|
+
case 'code-block':
|
|
107
|
+
return {
|
|
108
|
+
type: 'component',
|
|
109
|
+
icon: EditPen,
|
|
110
|
+
text: '代码编辑',
|
|
111
|
+
component: CodeBlockList,
|
|
112
|
+
slots: {},
|
|
113
|
+
};
|
|
114
|
+
default:
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
125
117
|
});
|
|
126
118
|
</script>
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<TMagicDialog
|
|
3
3
|
v-model="isShowCodeBlockEditor"
|
|
4
|
+
class="code-editor-dialog"
|
|
4
5
|
:title="currentTitle"
|
|
5
6
|
:fullscreen="true"
|
|
6
7
|
:before-close="saveAndClose"
|
|
7
8
|
:append-to-body="true"
|
|
8
|
-
custom-class="code-editor-dialog"
|
|
9
9
|
>
|
|
10
10
|
<layout v-model:left="left" :min-left="45" class="code-editor-layout">
|
|
11
11
|
<!-- 左侧列表 -->
|
|
12
12
|
<template #left v-if="mode === CodeEditorMode.LIST">
|
|
13
|
-
<
|
|
13
|
+
<TMagicTree
|
|
14
14
|
v-if="!isEmpty(state.codeList)"
|
|
15
|
-
|
|
15
|
+
class="side-tree"
|
|
16
16
|
node-key="id"
|
|
17
17
|
empty-text="暂无代码块"
|
|
18
18
|
:data="state.codeList"
|
|
19
19
|
:highlight-current="true"
|
|
20
|
-
@node-click="selectHandler"
|
|
21
20
|
:current-node-key="state.codeList[0].id"
|
|
22
|
-
|
|
21
|
+
@node-click="selectHandler"
|
|
23
22
|
>
|
|
24
23
|
<template #default="{ data }">
|
|
25
24
|
<div :id="data.id" class="list-container">
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
</div>
|
|
29
28
|
</div>
|
|
30
29
|
</template>
|
|
31
|
-
</
|
|
30
|
+
</TMagicTree>
|
|
32
31
|
</template>
|
|
33
32
|
<!-- 右侧区域 -->
|
|
34
33
|
<template #center>
|
|
@@ -41,11 +40,16 @@
|
|
|
41
40
|
]"
|
|
42
41
|
>
|
|
43
42
|
<slot name="code-block-edit-panel-header" :id="id"></slot>
|
|
44
|
-
<
|
|
43
|
+
<TMagicCard shadow="never">
|
|
45
44
|
<template #header>
|
|
46
45
|
<div class="code-name-wrapper">
|
|
47
46
|
<div class="code-name-label">代码块名称</div>
|
|
48
|
-
<
|
|
47
|
+
<TMagicInput
|
|
48
|
+
v-if="codeConfig"
|
|
49
|
+
class="code-name-input"
|
|
50
|
+
v-model="codeConfig.name"
|
|
51
|
+
:disabled="!editable"
|
|
52
|
+
/>
|
|
49
53
|
</div>
|
|
50
54
|
</template>
|
|
51
55
|
<div class="m-editor-wrapper">
|
|
@@ -63,26 +67,27 @@
|
|
|
63
67
|
}"
|
|
64
68
|
></magic-code-editor>
|
|
65
69
|
<div class="m-editor-content-bottom" v-if="editable">
|
|
66
|
-
<
|
|
67
|
-
<
|
|
70
|
+
<TMagicButton type="primary" class="button" @click="saveCode">保存</TMagicButton>
|
|
71
|
+
<TMagicButton type="primary" class="button" @click="saveAndClose">关闭</TMagicButton>
|
|
68
72
|
</div>
|
|
69
73
|
<div class="m-editor-content-bottom" v-else>
|
|
70
|
-
<
|
|
74
|
+
<TMagicButton type="primary" class="button" @click="saveAndClose">关闭</TMagicButton>
|
|
71
75
|
</div>
|
|
72
76
|
</div>
|
|
73
|
-
</
|
|
77
|
+
</TMagicCard>
|
|
74
78
|
</div>
|
|
75
79
|
</template>
|
|
76
80
|
</layout>
|
|
77
|
-
</
|
|
81
|
+
</TMagicDialog>
|
|
78
82
|
</template>
|
|
79
83
|
|
|
80
84
|
<script lang="ts" setup>
|
|
81
85
|
import { computed, inject, reactive, ref, watchEffect } from 'vue';
|
|
82
|
-
import { ElMessage } from 'element-plus';
|
|
83
86
|
import { forIn, isEmpty } from 'lodash-es';
|
|
84
87
|
import type * as monaco from 'monaco-editor';
|
|
85
88
|
|
|
89
|
+
import { TMagicButton, TMagicCard, TMagicDialog, TMagicInput, tMagicMessage, TMagicTree } from '@tmagic/design';
|
|
90
|
+
|
|
86
91
|
import type { CodeBlockContent, CodeDslList, ListState, Services } from '../../../type';
|
|
87
92
|
import { CodeEditorMode } from '../../../type';
|
|
88
93
|
import MagicCodeEditor from '../../CodeEditor.vue';
|
|
@@ -122,7 +127,6 @@ watchEffect(async () => {
|
|
|
122
127
|
state.codeList.push({
|
|
123
128
|
id: key,
|
|
124
129
|
name: value.name,
|
|
125
|
-
content: value.content,
|
|
126
130
|
});
|
|
127
131
|
});
|
|
128
132
|
currentTitle.value = state.codeList[0]?.name || '';
|
|
@@ -138,7 +142,7 @@ const saveCode = async (): Promise<boolean> => {
|
|
|
138
142
|
/* eslint no-eval: "off" */
|
|
139
143
|
codeConfig.value.content = eval(codeContent);
|
|
140
144
|
} catch (e: any) {
|
|
141
|
-
|
|
145
|
+
tMagicMessage.error(e.stack);
|
|
142
146
|
return false;
|
|
143
147
|
}
|
|
144
148
|
// 存入dsl
|
|
@@ -146,7 +150,7 @@ const saveCode = async (): Promise<boolean> => {
|
|
|
146
150
|
name: codeConfig.value.name,
|
|
147
151
|
content: codeConfig.value.content,
|
|
148
152
|
});
|
|
149
|
-
|
|
153
|
+
tMagicMessage.success('代码保存成功');
|
|
150
154
|
return true;
|
|
151
155
|
};
|
|
152
156
|
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
<div class="m-editor-code-block-list">
|
|
3
3
|
<slot name="code-block-panel-header">
|
|
4
4
|
<div class="code-header-wrapper">
|
|
5
|
-
<
|
|
5
|
+
<TMagicInput
|
|
6
6
|
:class="[editable ? 'code-filter-input' : 'code-filter-input-no-btn']"
|
|
7
7
|
size="small"
|
|
8
8
|
placeholder="输入关键字进行过滤"
|
|
9
9
|
clearable
|
|
10
10
|
v-model="filterText"
|
|
11
11
|
@input="filterTextChangeHandler"
|
|
12
|
-
></
|
|
13
|
-
<
|
|
14
|
-
>新增</
|
|
12
|
+
></TMagicInput>
|
|
13
|
+
<TMagicButton class="create-code-button" type="primary" size="small" @click="createCodeBlock" v-if="editable"
|
|
14
|
+
>新增</TMagicButton
|
|
15
15
|
>
|
|
16
16
|
</div>
|
|
17
17
|
</slot>
|
|
18
18
|
|
|
19
19
|
<!-- 代码块列表 -->
|
|
20
|
-
<
|
|
20
|
+
<TMagicTree
|
|
21
21
|
v-if="!isEmpty(state.codeList)"
|
|
22
22
|
ref="tree"
|
|
23
23
|
node-key="id"
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
<div class="code-name">{{ data.name }}({{ data.id }})</div>
|
|
34
34
|
<!-- 右侧工具栏 -->
|
|
35
35
|
<div class="right-tool">
|
|
36
|
-
<
|
|
36
|
+
<TMagicTooltip effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
|
|
37
37
|
<Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.id}`)"></Icon>
|
|
38
|
-
</
|
|
39
|
-
<
|
|
38
|
+
</TMagicTooltip>
|
|
39
|
+
<TMagicTooltip
|
|
40
40
|
effect="dark"
|
|
41
41
|
content="查看绑定关系"
|
|
42
42
|
placement="bottom"
|
|
43
43
|
v-if="state.bindComps[data.id] && state.bindComps[data.id].length > 0"
|
|
44
44
|
>
|
|
45
45
|
<Icon :icon="Link" class="edit-icon" @click.stop="toggleCombineRelation(data)"></Icon>
|
|
46
|
-
</
|
|
47
|
-
<
|
|
46
|
+
</TMagicTooltip>
|
|
47
|
+
<TMagicTooltip effect="dark" content="删除" placement="bottom" v-if="editable">
|
|
48
48
|
<Icon :icon="Close" class="edit-icon" @click.stop="deleteCode(`${data.id}`)"></Icon>
|
|
49
|
-
</
|
|
50
|
-
<slot name="code-block-panel-tool" :id="data.id"></slot>
|
|
49
|
+
</TMagicTooltip>
|
|
50
|
+
<slot name="code-block-panel-tool" :id="data.id" :data="data.codeBlockContent"></slot>
|
|
51
51
|
</div>
|
|
52
52
|
</div>
|
|
53
53
|
<!-- 展示代码块下绑定的组件 -->
|
|
@@ -62,27 +62,27 @@
|
|
|
62
62
|
></path>
|
|
63
63
|
</svg>
|
|
64
64
|
<!-- todo 功能暂时隐藏 -->
|
|
65
|
-
<!-- <
|
|
65
|
+
<!-- <TMagicButton
|
|
66
66
|
v-for="(comp, index) in state.bindComps[data.id]"
|
|
67
67
|
:key="index"
|
|
68
68
|
class="code-comp"
|
|
69
69
|
size="small"
|
|
70
70
|
:plain="true"
|
|
71
71
|
>{{ comp.name }}<Icon :icon="Close" class="comp-delete-icon" @click.stop="unbind(comp.id, data.id)"></Icon
|
|
72
|
-
></
|
|
73
|
-
<
|
|
72
|
+
></TMagicButton> -->
|
|
73
|
+
<TMagicButton
|
|
74
74
|
v-for="(comp, index) in state.bindComps[data.id]"
|
|
75
75
|
:key="index"
|
|
76
76
|
class="code-comp"
|
|
77
77
|
size="small"
|
|
78
78
|
:plain="true"
|
|
79
79
|
@click.stop="selectComp(comp.id)"
|
|
80
|
-
>{{ comp.name }}</
|
|
80
|
+
>{{ comp.name }}</TMagicButton
|
|
81
81
|
>
|
|
82
82
|
</div>
|
|
83
83
|
</div>
|
|
84
84
|
</template>
|
|
85
|
-
</
|
|
85
|
+
</TMagicTree>
|
|
86
86
|
|
|
87
87
|
<!-- 代码块编辑区 -->
|
|
88
88
|
<code-block-editor>
|
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
<script lang="ts" setup>
|
|
97
97
|
import { computed, inject, reactive, ref, watch } from 'vue';
|
|
98
98
|
import { Close, Edit, Link, View } from '@element-plus/icons-vue';
|
|
99
|
-
import { ElMessage } from 'element-plus';
|
|
100
99
|
import { forIn, isEmpty } from 'lodash-es';
|
|
101
100
|
|
|
101
|
+
import { TMagicButton, TMagicInput, tMagicMessage, TMagicTooltip, TMagicTree } from '@tmagic/design';
|
|
102
102
|
import { Id } from '@tmagic/schema';
|
|
103
103
|
import StageCore from '@tmagic/stage';
|
|
104
104
|
|
|
@@ -148,7 +148,7 @@ const initList = async () => {
|
|
|
148
148
|
state.codeList.push({
|
|
149
149
|
id: codeId,
|
|
150
150
|
name: value.name,
|
|
151
|
-
|
|
151
|
+
codeBlockContent: value,
|
|
152
152
|
showRelation: true,
|
|
153
153
|
});
|
|
154
154
|
});
|
|
@@ -184,7 +184,7 @@ watch(
|
|
|
184
184
|
const createCodeBlock = async () => {
|
|
185
185
|
const { codeBlockService } = services || {};
|
|
186
186
|
if (!codeBlockService) {
|
|
187
|
-
|
|
187
|
+
tMagicMessage.error('新增代码块失败');
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
const codeConfig: CodeBlockContent = {
|
|
@@ -214,7 +214,7 @@ const deleteCode = (key: string) => {
|
|
|
214
214
|
if (typeof props.customError === 'function') {
|
|
215
215
|
props.customError(key, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
216
216
|
} else {
|
|
217
|
-
|
|
217
|
+
tMagicMessage.error('代码块删除失败');
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
};
|
|
@@ -9,39 +9,39 @@
|
|
|
9
9
|
>
|
|
10
10
|
<div class="m-editor-page-bar-title">
|
|
11
11
|
<slot name="page-bar-title" :page="item">
|
|
12
|
-
<
|
|
12
|
+
<TMagicTooltip effect="dark" placement="top-start" :content="item.name">
|
|
13
13
|
<span>{{ item.name || item.id }}</span>
|
|
14
|
-
</
|
|
14
|
+
</TMagicTooltip>
|
|
15
15
|
</slot>
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
<
|
|
18
|
+
<TMagicPopover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
|
|
19
19
|
<div>
|
|
20
20
|
<slot name="page-bar-popover" :page="item">
|
|
21
|
-
<
|
|
21
|
+
<ToolButton
|
|
22
22
|
:data="{
|
|
23
23
|
type: 'button',
|
|
24
24
|
text: '复制',
|
|
25
25
|
icon: DocumentCopy,
|
|
26
26
|
handler: () => copy(item),
|
|
27
27
|
}"
|
|
28
|
-
></
|
|
29
|
-
<
|
|
28
|
+
></ToolButton>
|
|
29
|
+
<ToolButton
|
|
30
30
|
:data="{
|
|
31
31
|
type: 'button',
|
|
32
32
|
text: '删除',
|
|
33
33
|
icon: Delete,
|
|
34
34
|
handler: () => remove(item),
|
|
35
35
|
}"
|
|
36
|
-
></
|
|
36
|
+
></ToolButton>
|
|
37
37
|
</slot>
|
|
38
38
|
</div>
|
|
39
39
|
<template #reference>
|
|
40
|
-
<
|
|
40
|
+
<TMagicIcon class="m-editor-page-bar-menu-icon">
|
|
41
41
|
<CaretBottom></CaretBottom>
|
|
42
|
-
</
|
|
42
|
+
</TMagicIcon>
|
|
43
43
|
</template>
|
|
44
|
-
</
|
|
44
|
+
</TMagicPopover>
|
|
45
45
|
</div>
|
|
46
46
|
</PageBarScrollContainer>
|
|
47
47
|
</template>
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
import { computed, inject } from 'vue';
|
|
51
51
|
import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
52
52
|
|
|
53
|
+
import { TMagicIcon, TMagicPopover, TMagicTooltip } from '@tmagic/design';
|
|
53
54
|
import type { MApp, MPage } from '@tmagic/schema';
|
|
54
55
|
|
|
55
56
|
import ToolButton from '../../components/ToolButton.vue';
|
|
@@ -69,7 +69,7 @@ class CodeBlock extends BaseService {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* 获取活动的代码块dsl数据源(默认从dsl中的
|
|
72
|
+
* 获取活动的代码块dsl数据源(默认从dsl中的codeBlocks字段读取)
|
|
73
73
|
* @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
|
|
74
74
|
* @returns {CodeBlockDSL | null}
|
|
75
75
|
*/
|
|
@@ -100,15 +100,21 @@ class CodeBlock extends BaseService {
|
|
|
100
100
|
*/
|
|
101
101
|
public async setCodeDslById(id: string, codeConfig: CodeBlockContent): Promise<void> {
|
|
102
102
|
let codeDsl = await this.getCodeDsl();
|
|
103
|
-
if (!codeDsl)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
if (!codeDsl) {
|
|
104
|
+
// dsl中无代码块字段
|
|
105
|
+
codeDsl = {
|
|
106
|
+
[id]: codeConfig,
|
|
107
|
+
};
|
|
108
|
+
} else {
|
|
109
|
+
const existContent = codeDsl[id] || {};
|
|
110
|
+
codeDsl = {
|
|
111
|
+
...codeDsl,
|
|
112
|
+
[id]: {
|
|
113
|
+
...existContent,
|
|
114
|
+
...codeConfig,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
112
118
|
await this.setCodeDsl(codeDsl);
|
|
113
119
|
}
|
|
114
120
|
|
package/src/services/editor.ts
CHANGED
|
@@ -767,23 +767,23 @@ class Editor extends BaseService {
|
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
/**
|
|
770
|
-
* 从dsl中的
|
|
770
|
+
* 从dsl中的codeBlocks字段读取活动的代码块
|
|
771
771
|
* @returns {CodeBlockDSL | null}
|
|
772
772
|
*/
|
|
773
773
|
public async getCodeDsl(): Promise<CodeBlockDSL | null> {
|
|
774
774
|
const root = this.get<MApp | null>('root');
|
|
775
775
|
if (!root) return null;
|
|
776
|
-
return root.
|
|
776
|
+
return root.codeBlocks || null;
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
/**
|
|
780
|
-
* 设置代码块到dsl的
|
|
780
|
+
* 设置代码块到dsl的codeBlocks字段
|
|
781
781
|
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
782
782
|
* @returns {void}
|
|
783
783
|
*/
|
|
784
784
|
public async setCodeDsl(codeDsl: CodeBlockDSL): Promise<void> {
|
|
785
785
|
if (!this.state.root) return;
|
|
786
|
-
this.state.root.
|
|
786
|
+
this.state.root.codeBlocks = codeDsl;
|
|
787
787
|
}
|
|
788
788
|
|
|
789
789
|
private addModifiedNodeId(id: Id) {
|
package/src/theme/index.scss
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
1
|
@import "./common/var.scss";
|
|
2
|
-
@import "./
|
|
3
|
-
@import "./framework.scss";
|
|
4
|
-
@import "./sidebar.scss";
|
|
5
|
-
@import "./layer-panel.scss";
|
|
6
|
-
@import "./component-list-panel.scss";
|
|
7
|
-
@import "./resizer.scss";
|
|
8
|
-
@import "./workspace.scss";
|
|
9
|
-
@import "./page-bar.scss";
|
|
10
|
-
@import "./props-panel.scss";
|
|
11
|
-
@import "./content-menu.scss";
|
|
12
|
-
@import "./stage.scss";
|
|
13
|
-
@import "./code-editor.scss";
|
|
14
|
-
@import "./icon.scss";
|
|
15
|
-
@import "./code-block.scss";
|
|
16
|
-
@import "./layout.scss";
|
|
2
|
+
@import "./theme.scss";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@import "./nav-menu.scss";
|
|
2
|
+
@import "./framework.scss";
|
|
3
|
+
@import "./sidebar.scss";
|
|
4
|
+
@import "./layer-panel.scss";
|
|
5
|
+
@import "./component-list-panel.scss";
|
|
6
|
+
@import "./resizer.scss";
|
|
7
|
+
@import "./workspace.scss";
|
|
8
|
+
@import "./page-bar.scss";
|
|
9
|
+
@import "./props-panel.scss";
|
|
10
|
+
@import "./content-menu.scss";
|
|
11
|
+
@import "./stage.scss";
|
|
12
|
+
@import "./code-editor.scss";
|
|
13
|
+
@import "./icon.scss";
|
|
14
|
+
@import "./code-block.scss";
|
|
15
|
+
@import "./layout.scss";
|
package/src/type.ts
CHANGED
package/types/Editor.vue.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
97
|
updateDragEl: {
|
|
98
98
|
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
99
99
|
};
|
|
100
|
-
}, Services, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("props-panel-mounted"
|
|
100
|
+
}, Services, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "props-panel-mounted")[], "update:modelValue" | "props-panel-mounted", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
101
101
|
/** 页面初始值 */
|
|
102
102
|
modelValue: {
|
|
103
103
|
type: PropType<MApp>;
|
|
@@ -191,8 +191,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
191
191
|
type: PropType<(el: HTMLDivElement, target: HTMLElement) => void>;
|
|
192
192
|
};
|
|
193
193
|
}>> & {
|
|
194
|
-
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
195
194
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
195
|
+
"onProps-panel-mounted"?: ((...args: any[]) => any) | undefined;
|
|
196
196
|
}, {
|
|
197
197
|
menu: MenuBarData;
|
|
198
198
|
codeOptions: Record<string, any>;
|
|
@@ -7,6 +7,8 @@ declare const _default: {
|
|
|
7
7
|
name: string;
|
|
8
8
|
config: {
|
|
9
9
|
language?: string | undefined;
|
|
10
|
+
options?: Object | undefined;
|
|
11
|
+
height?: string | undefined;
|
|
10
12
|
};
|
|
11
13
|
prop: string;
|
|
12
14
|
}>>> & {
|
|
@@ -30,6 +32,8 @@ declare const _default: {
|
|
|
30
32
|
name: string;
|
|
31
33
|
config: {
|
|
32
34
|
language?: string | undefined;
|
|
35
|
+
options?: Object | undefined;
|
|
36
|
+
height?: string | undefined;
|
|
33
37
|
};
|
|
34
38
|
prop: string;
|
|
35
39
|
}>>> & {
|
|
@@ -59,6 +63,8 @@ declare const _default: {
|
|
|
59
63
|
name: string;
|
|
60
64
|
config: {
|
|
61
65
|
language?: string | undefined;
|
|
66
|
+
options?: Object | undefined;
|
|
67
|
+
height?: string | undefined;
|
|
62
68
|
};
|
|
63
69
|
prop: string;
|
|
64
70
|
}>>> & {
|
|
@@ -72,6 +78,8 @@ declare const _default: {
|
|
|
72
78
|
name: string;
|
|
73
79
|
config: {
|
|
74
80
|
language?: string | undefined;
|
|
81
|
+
options?: Object | undefined;
|
|
82
|
+
height?: string | undefined;
|
|
75
83
|
};
|
|
76
84
|
prop: string;
|
|
77
85
|
}>>> & {
|
|
@@ -8,6 +8,7 @@ declare const _default: {
|
|
|
8
8
|
name: string;
|
|
9
9
|
text?: string;
|
|
10
10
|
formTitle?: string;
|
|
11
|
+
codeOptions?: Object;
|
|
11
12
|
};
|
|
12
13
|
model: any;
|
|
13
14
|
name: string;
|
|
@@ -34,6 +35,7 @@ declare const _default: {
|
|
|
34
35
|
name: string;
|
|
35
36
|
text?: string;
|
|
36
37
|
formTitle?: string;
|
|
38
|
+
codeOptions?: Object;
|
|
37
39
|
};
|
|
38
40
|
model: any;
|
|
39
41
|
name: string;
|
|
@@ -66,6 +68,7 @@ declare const _default: {
|
|
|
66
68
|
name: string;
|
|
67
69
|
text?: string;
|
|
68
70
|
formTitle?: string;
|
|
71
|
+
codeOptions?: Object;
|
|
69
72
|
};
|
|
70
73
|
model: any;
|
|
71
74
|
name: string;
|
|
@@ -82,6 +85,7 @@ declare const _default: {
|
|
|
82
85
|
name: string;
|
|
83
86
|
text?: string;
|
|
84
87
|
formTitle?: string;
|
|
88
|
+
codeOptions?: Object;
|
|
85
89
|
};
|
|
86
90
|
model: any;
|
|
87
91
|
name: string;
|
package/types/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { default as uiService } from './services/ui';
|
|
|
15
15
|
export { default as codeBlockService } from './services/codeBlock';
|
|
16
16
|
export { default as ComponentListPanel } from './layouts/sidebar/ComponentListPanel.vue';
|
|
17
17
|
export { default as LayerPanel } from './layouts/sidebar/LayerPanel.vue';
|
|
18
|
+
export { default as CodeSelect } from './fields/CodeSelect.vue';
|
|
18
19
|
export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
|
|
19
20
|
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
20
21
|
export { default as ToolButton } from './components/ToolButton.vue';
|