@tmagic/editor 1.3.0-alpha.9 → 1.3.0-beta.1
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 +106 -219
- package/dist/tmagic-editor.js +6253 -5042
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +6280 -5055
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +15 -15
- package/src/Editor.vue +4 -5
- package/src/components/CodeBlockEditor.vue +266 -0
- package/src/components/CodeParams.vue +60 -0
- package/src/components/ContentMenu.vue +97 -43
- package/src/components/Resizer.vue +8 -30
- package/src/components/SplitView.vue +3 -2
- package/src/editorProps.ts +30 -5
- package/src/fields/Code.vue +23 -19
- package/src/fields/CodeLink.vue +6 -7
- package/src/fields/CodeSelect.vue +12 -9
- package/src/fields/CodeSelectCol.vue +70 -81
- package/src/fields/DataSourceFieldSelect.vue +47 -0
- package/src/fields/DataSourceFields.vue +38 -22
- package/src/fields/DataSourceInput.vue +21 -58
- package/src/fields/DataSourceMethodSelect.vue +136 -0
- package/src/fields/DataSourceMethods.vue +104 -0
- package/src/fields/DataSourceSelect.vue +5 -12
- package/src/fields/EventSelect.vue +53 -19
- package/src/fields/KeyValue.vue +9 -11
- package/src/fields/UISelect.vue +54 -14
- package/src/hooks/index.ts +21 -0
- package/src/hooks/use-code-block-edit.ts +84 -0
- package/src/hooks/use-data-source-method.ts +100 -0
- package/src/hooks/use-getso.ts +35 -0
- package/src/{utils/stage.ts → hooks/use-stage.ts} +4 -7
- package/src/icons/CenterIcon.vue +13 -0
- package/src/icons/CodeIcon.vue +0 -2
- package/src/icons/FolderMinusIcon.vue +22 -0
- package/src/icons/PinIcon.vue +25 -0
- package/src/icons/PinnedIcon.vue +25 -0
- package/src/index.ts +14 -0
- package/src/initService.ts +69 -16
- package/src/layouts/CodeEditor.vue +35 -3
- package/src/layouts/Framework.vue +7 -3
- package/src/layouts/PropsPanel.vue +8 -3
- package/src/layouts/sidebar/ComponentListPanel.vue +4 -6
- package/src/layouts/sidebar/LayerMenu.vue +20 -21
- package/src/layouts/sidebar/LayerPanel.vue +12 -2
- package/src/layouts/sidebar/Sidebar.vue +22 -36
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +81 -119
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +64 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +27 -47
- package/src/layouts/sidebar/data-source/DataSourceList.vue +145 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +58 -85
- package/src/layouts/workspace/Workspace.vue +1 -1
- package/src/layouts/workspace/viewer/NodeListMenu.vue +159 -0
- package/src/layouts/workspace/viewer/NodeListMenuTitle.vue +68 -0
- package/src/layouts/workspace/{Stage.vue → viewer/Stage.vue} +5 -2
- package/src/layouts/workspace/{ViewerMenu.vue → viewer/ViewerMenu.vue} +10 -35
- package/src/services/codeBlock.ts +18 -71
- package/src/services/dataSource.ts +16 -1
- package/src/services/dep.ts +22 -20
- package/src/services/editor.ts +46 -18
- package/src/services/props.ts +2 -2
- package/src/theme/code-block.scss +5 -117
- package/src/theme/code-editor.scss +27 -2
- package/src/theme/content-menu.scss +26 -2
- package/src/theme/data-source-methods.scss +13 -0
- package/src/theme/data-source.scss +11 -0
- package/src/theme/event.scss +15 -12
- package/src/theme/framework.scss +0 -3
- package/src/theme/index.scss +8 -0
- package/src/theme/layout.scss +4 -0
- package/src/theme/sidebar.scss +18 -60
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +49 -7
- package/src/utils/content-menu.ts +92 -0
- package/src/utils/data-source/formConfigs/base.ts +28 -30
- package/src/utils/data-source/formConfigs/http.ts +9 -0
- package/src/utils/data-source/index.ts +65 -2
- package/src/utils/dep.ts +33 -7
- package/src/utils/index.ts +1 -1
- package/src/utils/props.ts +308 -189
- package/src/utils/undo-redo.ts +1 -1
- package/types/Editor.vue.d.ts +30 -6
- package/types/components/CodeBlockEditor.vue.d.ts +25 -0
- package/types/components/CodeParams.vue.d.ts +26 -0
- package/types/components/ContentMenu.vue.d.ts +27 -8
- package/types/components/Resizer.vue.d.ts +1 -3
- package/types/components/ToolButton.vue.d.ts +3 -3
- package/types/editorProps.d.ts +19 -5
- package/types/fields/Code.vue.d.ts +24 -19
- package/types/fields/CodeLink.vue.d.ts +12 -21
- package/types/fields/CodeSelect.vue.d.ts +6 -17
- package/types/fields/CodeSelectCol.vue.d.ts +10 -14
- package/types/fields/DataSourceFieldSelect.vue.d.ts +29 -0
- package/types/fields/DataSourceFields.vue.d.ts +7 -18
- package/types/fields/DataSourceInput.vue.d.ts +10 -30
- package/types/fields/DataSourceMethodSelect.vue.d.ts +29 -0
- package/types/fields/DataSourceMethods.vue.d.ts +32 -0
- package/types/fields/DataSourceSelect.vue.d.ts +13 -29
- package/types/fields/EventSelect.vue.d.ts +2 -13
- package/types/fields/KeyValue.vue.d.ts +9 -24
- package/types/fields/UISelect.vue.d.ts +2 -11
- package/types/hooks/index.d.ts +3 -0
- package/types/{components/FunctionEditor.vue.d.ts → hooks/use-code-block-edit.d.ts} +36 -119
- package/types/hooks/use-data-source-method.d.ts +130 -0
- package/types/hooks/use-getso.d.ts +5 -0
- package/types/icons/CenterIcon.vue.d.ts +2 -0
- package/types/icons/FolderMinusIcon.vue.d.ts +2 -0
- package/types/icons/PinIcon.vue.d.ts +2 -0
- package/types/icons/PinnedIcon.vue.d.ts +2 -0
- package/types/index.d.ts +7 -0
- package/types/initService.d.ts +2 -2
- package/types/layouts/CodeEditor.vue.d.ts +7 -4
- package/types/layouts/PropsPanel.vue.d.ts +274 -2
- package/types/layouts/sidebar/Sidebar.vue.d.ts +0 -3
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +4 -9
- package/types/layouts/sidebar/code-block/{CodeBlockEditor.vue.d.ts → CodeBlockListPanel.vue.d.ts} +9 -5
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -1
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +14 -0
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +1 -11
- package/types/layouts/workspace/viewer/NodeListMenu.vue.d.ts +15 -0
- package/types/layouts/workspace/viewer/NodeListMenuTitle.vue.d.ts +15 -0
- package/types/layouts/workspace/{Stage.vue.d.ts → viewer/Stage.vue.d.ts} +1 -1
- package/types/layouts/workspace/{ViewerMenu.vue.d.ts → viewer/ViewerMenu.vue.d.ts} +1 -1
- package/types/services/codeBlock.d.ts +6 -37
- package/types/services/dataSource.d.ts +7 -1
- package/types/services/dep.d.ts +12 -21
- package/types/services/editor.d.ts +1 -1
- package/types/services/props.d.ts +10 -115
- package/types/type.d.ts +44 -7
- package/types/utils/content-menu.d.ts +7 -0
- package/types/utils/data-source/formConfigs/base.d.ts +1 -2
- package/types/utils/data-source/index.d.ts +5 -0
- package/types/utils/dep.d.ts +4 -2
- package/types/utils/index.d.ts +1 -1
- package/types/utils/props.d.ts +13 -102
- package/src/components/CodeDraftEditor.vue +0 -148
- package/src/components/FunctionEditor.vue +0 -197
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +0 -100
- package/types/components/CodeDraftEditor.vue.d.ts +0 -61
- /package/types/{utils/stage.d.ts → hooks/use-stage.d.ts} +0 -0
package/src/fields/UISelect.vue
CHANGED
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-ui-select" v-if="uiSelectMode" @click="cancelHandler">
|
|
3
|
-
<TMagicButton type="danger" :icon="Delete" text style="padding: 0"
|
|
3
|
+
<TMagicButton type="danger" :icon="Delete" :disabled="disabled" :size="size" text style="padding: 0"
|
|
4
|
+
>取消</TMagicButton
|
|
5
|
+
>
|
|
4
6
|
</div>
|
|
5
|
-
<div class="m-fields-ui-select" v-else
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
<div class="m-fields-ui-select" v-else style="display: flex">
|
|
8
|
+
<template v-if="val">
|
|
9
|
+
<TMagicTooltip content="清除" placement="top">
|
|
10
|
+
<TMagicButton
|
|
11
|
+
style="padding: 0"
|
|
12
|
+
type="danger"
|
|
13
|
+
:icon="Close"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
:size="size"
|
|
16
|
+
text
|
|
17
|
+
@click.stop="deleteHandler"
|
|
18
|
+
></TMagicButton>
|
|
19
|
+
</TMagicTooltip>
|
|
20
|
+
|
|
21
|
+
<TMagicTooltip content="点击选中组件" placement="top">
|
|
22
|
+
<TMagicButton
|
|
23
|
+
text
|
|
24
|
+
style="padding: 0; margin: 0"
|
|
25
|
+
:disabled="disabled"
|
|
26
|
+
:size="size"
|
|
27
|
+
@click="selectNode(val)"
|
|
28
|
+
@mouseenter="highlight(val)"
|
|
29
|
+
@mouseleave="unhightlight"
|
|
30
|
+
>{{ `${toName}_${val}` }}</TMagicButton
|
|
31
|
+
>
|
|
32
|
+
</TMagicTooltip>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<TMagicTooltip v-else content="点击此处选择" placement="top">
|
|
36
|
+
<TMagicButton text style="padding: 0; margin: 0" :disabled="disabled" :size="size" @click="startSelect"
|
|
37
|
+
>点击此处选择</TMagicButton
|
|
38
|
+
>
|
|
11
39
|
</TMagicTooltip>
|
|
12
40
|
</div>
|
|
13
41
|
</template>
|
|
@@ -15,9 +43,11 @@
|
|
|
15
43
|
<script lang="ts" setup>
|
|
16
44
|
import { computed, inject, ref } from 'vue';
|
|
17
45
|
import { Close, Delete } from '@element-plus/icons-vue';
|
|
46
|
+
import { throttle } from 'lodash-es';
|
|
18
47
|
|
|
19
48
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
20
|
-
import { FormState } from '@tmagic/form';
|
|
49
|
+
import type { FieldProps, FormState } from '@tmagic/form';
|
|
50
|
+
import type { Id } from '@tmagic/schema';
|
|
21
51
|
|
|
22
52
|
import type { Services } from '@editor/type';
|
|
23
53
|
|
|
@@ -25,12 +55,7 @@ defineOptions({
|
|
|
25
55
|
name: 'MEditorUISelect',
|
|
26
56
|
});
|
|
27
57
|
|
|
28
|
-
const props = defineProps<
|
|
29
|
-
config: any;
|
|
30
|
-
model: any;
|
|
31
|
-
prop: string;
|
|
32
|
-
name: string;
|
|
33
|
-
}>();
|
|
58
|
+
const props = defineProps<FieldProps<any>>();
|
|
34
59
|
|
|
35
60
|
const emit = defineEmits(['change']);
|
|
36
61
|
|
|
@@ -77,6 +102,21 @@ const deleteHandler = () => {
|
|
|
77
102
|
mForm?.$emit('field-change', props.prop, '');
|
|
78
103
|
}
|
|
79
104
|
};
|
|
105
|
+
|
|
106
|
+
const selectNode = async (id: Id) => {
|
|
107
|
+
await services?.editorService.select(id);
|
|
108
|
+
services?.editorService.get('stage')?.select(id);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const highlight = throttle((id: Id) => {
|
|
112
|
+
services?.editorService.highlight(id);
|
|
113
|
+
services?.editorService.get('stage')?.highlight(id);
|
|
114
|
+
}, 150);
|
|
115
|
+
|
|
116
|
+
const unhightlight = () => {
|
|
117
|
+
services?.editorService.set('highlightNode', null);
|
|
118
|
+
services?.editorService.get('stage')?.clearHighlight();
|
|
119
|
+
};
|
|
80
120
|
</script>
|
|
81
121
|
|
|
82
122
|
<style lang="scss">
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 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
|
+
export * from './use-code-block-edit';
|
|
20
|
+
export * from './use-data-source-method';
|
|
21
|
+
export * from './use-stage';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { nextTick, ref } from 'vue';
|
|
2
|
+
import { cloneDeep } from 'lodash-es';
|
|
3
|
+
|
|
4
|
+
import { tMagicMessage } from '@tmagic/design';
|
|
5
|
+
import type { CodeBlockContent } from '@tmagic/schema';
|
|
6
|
+
|
|
7
|
+
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
|
8
|
+
import type { CodeBlockService } from '@editor/services/codeBlock';
|
|
9
|
+
|
|
10
|
+
export const useCodeBlockEdit = (codeBlockService?: CodeBlockService) => {
|
|
11
|
+
const codeConfig = ref<CodeBlockContent>();
|
|
12
|
+
const codeId = ref<string>();
|
|
13
|
+
const codeBlockEditor = ref<InstanceType<typeof CodeBlockEditor>>();
|
|
14
|
+
|
|
15
|
+
// 新增代码块
|
|
16
|
+
const createCodeBlock = async () => {
|
|
17
|
+
if (!codeBlockService) {
|
|
18
|
+
tMagicMessage.error('新增代码块失败');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
codeConfig.value = {
|
|
23
|
+
name: '代码块',
|
|
24
|
+
content: `({app, params}) => {\n // place your code here\n}`,
|
|
25
|
+
params: [],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
codeId.value = await codeBlockService.getUniqueId();
|
|
29
|
+
|
|
30
|
+
await nextTick();
|
|
31
|
+
|
|
32
|
+
codeBlockEditor.value?.show();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// 编辑代码块
|
|
36
|
+
const editCode = async (id: string) => {
|
|
37
|
+
const codeBlock = await codeBlockService?.getCodeContentById(id);
|
|
38
|
+
|
|
39
|
+
if (!codeBlock) {
|
|
40
|
+
tMagicMessage.error('获取代码块内容失败');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let codeContent = codeBlock.content;
|
|
45
|
+
|
|
46
|
+
if (typeof codeContent !== 'string') {
|
|
47
|
+
codeContent = codeContent.toString();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
codeConfig.value = {
|
|
51
|
+
...cloneDeep(codeBlock),
|
|
52
|
+
content: codeContent,
|
|
53
|
+
};
|
|
54
|
+
codeId.value = id;
|
|
55
|
+
|
|
56
|
+
await nextTick();
|
|
57
|
+
|
|
58
|
+
codeBlockEditor.value?.show();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// 删除代码块
|
|
62
|
+
const deleteCode = async (key: string) => {
|
|
63
|
+
codeBlockService?.deleteCodeDslByIds([key]);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const submitCodeBlockHandler = async (values: CodeBlockContent) => {
|
|
67
|
+
if (!codeId.value) return;
|
|
68
|
+
|
|
69
|
+
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
70
|
+
|
|
71
|
+
codeBlockEditor.value?.hide();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
codeId,
|
|
76
|
+
codeConfig,
|
|
77
|
+
codeBlockEditor,
|
|
78
|
+
|
|
79
|
+
createCodeBlock,
|
|
80
|
+
editCode,
|
|
81
|
+
deleteCode,
|
|
82
|
+
submitCodeBlockHandler,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { nextTick, ref } from 'vue';
|
|
2
|
+
import { cloneDeep } from 'lodash-es';
|
|
3
|
+
|
|
4
|
+
import { tMagicMessage } from '@tmagic/design';
|
|
5
|
+
import type { CodeBlockContent, DataSourceSchema } from '@tmagic/schema';
|
|
6
|
+
|
|
7
|
+
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
|
8
|
+
import { getConfig } from '@editor/utils/config';
|
|
9
|
+
|
|
10
|
+
export const useDataSourceMethod = () => {
|
|
11
|
+
const codeConfig = ref<CodeBlockContent>();
|
|
12
|
+
const codeBlockEditor = ref<InstanceType<typeof CodeBlockEditor>>();
|
|
13
|
+
|
|
14
|
+
const dataSource = ref<DataSourceSchema>();
|
|
15
|
+
const dataSourceMethod = ref('');
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
codeConfig,
|
|
19
|
+
codeBlockEditor,
|
|
20
|
+
|
|
21
|
+
createCode: async (model: DataSourceSchema) => {
|
|
22
|
+
codeConfig.value = {
|
|
23
|
+
name: '',
|
|
24
|
+
content: `({ params, dataSource, app }) => {\n // place your code here\n}`,
|
|
25
|
+
params: [],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
await nextTick();
|
|
29
|
+
|
|
30
|
+
dataSource.value = model;
|
|
31
|
+
dataSourceMethod.value = '';
|
|
32
|
+
|
|
33
|
+
codeBlockEditor.value?.show();
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
editCode: async (model: DataSourceSchema, methodName: string) => {
|
|
37
|
+
const method = model.methods?.find((method) => method.name === methodName);
|
|
38
|
+
|
|
39
|
+
if (!method) {
|
|
40
|
+
tMagicMessage.error('获取数据源方法失败');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let codeContent = method.content;
|
|
45
|
+
|
|
46
|
+
if (typeof codeContent !== 'string') {
|
|
47
|
+
codeContent = codeContent.toString();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
codeConfig.value = {
|
|
51
|
+
...cloneDeep(method),
|
|
52
|
+
content: codeContent,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
await nextTick();
|
|
56
|
+
|
|
57
|
+
dataSource.value = model;
|
|
58
|
+
dataSourceMethod.value = methodName;
|
|
59
|
+
|
|
60
|
+
codeBlockEditor.value?.show();
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
deleteCode: async (model: DataSourceSchema, methodName: string) => {
|
|
64
|
+
if (!model.methods) return;
|
|
65
|
+
|
|
66
|
+
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
67
|
+
|
|
68
|
+
if (index === -1) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
model.methods.splice(index, 1);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
submitCode: (values: CodeBlockContent) => {
|
|
76
|
+
if (!dataSource.value) return;
|
|
77
|
+
|
|
78
|
+
if (!dataSource.value.methods) {
|
|
79
|
+
dataSource.value.methods = [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (values.content) {
|
|
83
|
+
// 在保存的时候转换代码内容
|
|
84
|
+
const parseDSL = getConfig('parseDSL');
|
|
85
|
+
if (typeof values.content === 'string') {
|
|
86
|
+
values.content = parseDSL<(...args: any[]) => any>(values.content);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (dataSourceMethod.value) {
|
|
91
|
+
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
92
|
+
dataSource.value.methods.splice(index, 1, values);
|
|
93
|
+
} else {
|
|
94
|
+
dataSource.value.methods.push(values);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
codeBlockEditor.value?.hide();
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, type Ref, ref } from 'vue';
|
|
2
|
+
import Gesto, { type OnDrag } from 'gesto';
|
|
3
|
+
|
|
4
|
+
export const useGetSo = (target: Ref<HTMLElement | undefined>, emit: (evt: 'change', e: OnDrag<Gesto>) => void) => {
|
|
5
|
+
let getso: Gesto;
|
|
6
|
+
const isDraging = ref(false);
|
|
7
|
+
|
|
8
|
+
onMounted(() => {
|
|
9
|
+
if (!target.value) return;
|
|
10
|
+
getso = new Gesto(target.value, {
|
|
11
|
+
container: window,
|
|
12
|
+
pinchOutside: true,
|
|
13
|
+
})
|
|
14
|
+
.on('drag', (e) => {
|
|
15
|
+
if (!target.value) return;
|
|
16
|
+
|
|
17
|
+
emit('change', e);
|
|
18
|
+
})
|
|
19
|
+
.on('dragStart', () => {
|
|
20
|
+
isDraging.value = true;
|
|
21
|
+
})
|
|
22
|
+
.on('dragEnd', () => {
|
|
23
|
+
isDraging.value = false;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
onUnmounted(() => {
|
|
28
|
+
getso?.unset();
|
|
29
|
+
isDraging.value = false;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
isDraging,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
2
|
|
|
3
|
+
import type { MNode } from '@tmagic/schema';
|
|
3
4
|
import StageCore, { GuidesType, RemoveEventData, SortEventData, UpdateEventData } from '@tmagic/stage';
|
|
4
5
|
|
|
5
6
|
import editorService from '@editor/services/editor';
|
|
6
7
|
import uiService from '@editor/services/ui';
|
|
7
8
|
import { H_GUIDE_LINE_STORAGE_KEY, StageOptions, V_GUIDE_LINE_STORAGE_KEY } from '@editor/type';
|
|
8
|
-
|
|
9
|
-
import { getGuideLineFromCache } from './editor';
|
|
9
|
+
import { getGuideLineFromCache } from '@editor/utils/editor';
|
|
10
10
|
|
|
11
11
|
const root = computed(() => editorService.get('root'));
|
|
12
12
|
const page = computed(() => editorService.get('page'));
|
|
@@ -74,11 +74,8 @@ export const useStage = (stageOptions: StageOptions) => {
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
stage.on('remove', (ev: RemoveEventData) => {
|
|
77
|
-
editorService.
|
|
78
|
-
|
|
79
|
-
id: el.id,
|
|
80
|
-
})),
|
|
81
|
-
);
|
|
77
|
+
const nodes = ev.data.map(({ el }) => editorService.getNodeById(el.id));
|
|
78
|
+
editorService.remove(nodes.filter((node) => Boolean(node)) as MNode[]);
|
|
82
79
|
});
|
|
83
80
|
|
|
84
81
|
stage.on('select-parent', () => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 4H21V6H2V4Z" fill="black" fill-opacity="0.9" />
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 11H18V13H5V11Z" fill="black" fill-opacity="0.9" />
|
|
5
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 18H21V20H2V18Z" fill="black" fill-opacity="0.9" />
|
|
6
|
+
</svg>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: 'MEditorCenterIcon',
|
|
12
|
+
});
|
|
13
|
+
</script>
|
package/src/icons/CodeIcon.vue
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- 代码icon,cdn链接:https://cloudcache.tencent-cloud.com/qcloud/ui/static/government/0d463ed5-6407-4498-8865-3d05b5e70115.svg -->
|
|
3
2
|
<svg viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
4
|
-
<!-- Generator: Sketch 60.1 (88133) - https://sketch.com -->
|
|
5
3
|
<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs>
|
|
6
4
|
<g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
7
5
|
<g id="03图标" transform="translate(-561.000000, -2356.000000)">
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
width="1em"
|
|
4
|
+
height="1em"
|
|
5
|
+
viewBox="0 0 16 16"
|
|
6
|
+
class="bi bi-folder-minus"
|
|
7
|
+
fill="currentColor"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
fill-rule="evenodd"
|
|
12
|
+
d="M9.828 4H2.19a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91H9v1H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181L15.546 8H14.54l.265-2.91A1 1 0 0 0 13.81 4H9.828zm-2.95-1.707L7.587 3H2.19c-.24 0-.47.042-.684.12L1.5 2.98a1 1 0 0 1 1-.98h3.672a1 1 0 0 1 .707.293z"
|
|
13
|
+
/>
|
|
14
|
+
<path fill-rule="evenodd" d="M11 11.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5z" />
|
|
15
|
+
</svg>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
defineOptions({
|
|
20
|
+
name: 'MEditorFolderMinusIcon',
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
class="icon icon-tabler icon-tabler-pin"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
stroke-width="2"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
15
|
+
<path d="M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4" />
|
|
16
|
+
<line x1="9" y1="15" x2="4.5" y2="19.5" />
|
|
17
|
+
<line x1="14.5" y1="4" x2="20" y2="9.5" />
|
|
18
|
+
</svg>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
defineOptions({
|
|
23
|
+
name: 'MEditorPinIcon',
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
class="icon icon-tabler icon-tabler-pinned"
|
|
5
|
+
width="24"
|
|
6
|
+
height="24"
|
|
7
|
+
viewBox="0 0 24 24"
|
|
8
|
+
stroke-width="2"
|
|
9
|
+
stroke="currentColor"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
>
|
|
14
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
15
|
+
<path d="M9 4v6l-2 4v2h10v-2l-2 -4v-6" />
|
|
16
|
+
<line x1="12" y1="16" x2="12" y2="21" />
|
|
17
|
+
<line x1="8" y1="4" x2="16" y2="4" />
|
|
18
|
+
</svg>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
defineOptions({
|
|
23
|
+
name: 'MEditorPinnedIcon',
|
|
24
|
+
});
|
|
25
|
+
</script>
|
package/src/index.ts
CHANGED
|
@@ -22,7 +22,10 @@ import CodeLink from './fields/CodeLink.vue';
|
|
|
22
22
|
import CodeSelect from './fields/CodeSelect.vue';
|
|
23
23
|
import CodeSelectCol from './fields/CodeSelectCol.vue';
|
|
24
24
|
import DataSourceFields from './fields/DataSourceFields.vue';
|
|
25
|
+
import DataSourceFieldSelect from './fields/DataSourceFieldSelect.vue';
|
|
25
26
|
import DataSourceInput from './fields/DataSourceInput.vue';
|
|
27
|
+
import DataSourceMethods from './fields/DataSourceMethods.vue';
|
|
28
|
+
import DataSourceMethodSelect from './fields/DataSourceMethodSelect.vue';
|
|
26
29
|
import DataSourceSelect from './fields/DataSourceSelect.vue';
|
|
27
30
|
import EventSelect from './fields/EventSelect.vue';
|
|
28
31
|
import KeyValue from './fields/KeyValue.vue';
|
|
@@ -34,8 +37,11 @@ import type { InstallOptions } from './type';
|
|
|
34
37
|
|
|
35
38
|
import './theme/index.scss';
|
|
36
39
|
|
|
40
|
+
export type { OnDrag } from 'gesto';
|
|
41
|
+
|
|
37
42
|
export type { MoveableOptions } from '@tmagic/stage';
|
|
38
43
|
export * from './type';
|
|
44
|
+
export * from './hooks';
|
|
39
45
|
export * from './utils';
|
|
40
46
|
export { default as TMagicEditor } from './Editor.vue';
|
|
41
47
|
export { default as TMagicCodeEditor } from './layouts/CodeEditor.vue';
|
|
@@ -53,11 +59,15 @@ export { default as LayerPanel } from './layouts/sidebar/LayerPanel.vue';
|
|
|
53
59
|
export { default as CodeSelect } from './fields/CodeSelect.vue';
|
|
54
60
|
export { default as CodeSelectCol } from './fields/CodeSelectCol.vue';
|
|
55
61
|
export { default as DataSourceFields } from './fields/DataSourceFields.vue';
|
|
62
|
+
export { default as DataSourceMethods } from './fields/DataSourceMethods.vue';
|
|
56
63
|
export { default as DataSourceInput } from './fields/DataSourceInput.vue';
|
|
57
64
|
export { default as DataSourceSelect } from './fields/DataSourceSelect.vue';
|
|
65
|
+
export { default as DataSourceMethodSelect } from './fields/DataSourceMethodSelect.vue';
|
|
66
|
+
export { default as DataSourceFieldSelect } from './fields/DataSourceFieldSelect.vue';
|
|
58
67
|
export { default as EventSelect } from './fields/EventSelect.vue';
|
|
59
68
|
export { default as KeyValue } from './fields/KeyValue.vue';
|
|
60
69
|
export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
|
|
70
|
+
export { default as CodeBlockListPanel } from './layouts/sidebar/code-block/CodeBlockListPanel.vue';
|
|
61
71
|
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
62
72
|
export { default as ToolButton } from './components/ToolButton.vue';
|
|
63
73
|
export { default as ContentMenu } from './components/ContentMenu.vue';
|
|
@@ -65,6 +75,7 @@ export { default as Icon } from './components/Icon.vue';
|
|
|
65
75
|
export { default as LayoutContainer } from './components/SplitView.vue';
|
|
66
76
|
export { default as SplitView } from './components/SplitView.vue';
|
|
67
77
|
export { default as Resizer } from './components/Resizer.vue';
|
|
78
|
+
export { default as CodeBlockEditor } from './components/CodeBlockEditor.vue';
|
|
68
79
|
|
|
69
80
|
const defaultInstallOpt: InstallOptions = {
|
|
70
81
|
// eslint-disable-next-line no-eval
|
|
@@ -90,5 +101,8 @@ export default {
|
|
|
90
101
|
app.component('m-fields-key-value', KeyValue);
|
|
91
102
|
app.component('m-fields-data-source-input', DataSourceInput);
|
|
92
103
|
app.component('m-fields-data-source-select', DataSourceSelect);
|
|
104
|
+
app.component('m-fields-data-source-methods', DataSourceMethods);
|
|
105
|
+
app.component('m-fields-data-source-method-select', DataSourceMethodSelect);
|
|
106
|
+
app.component('m-fields-data-source-field-select', DataSourceFieldSelect);
|
|
93
107
|
},
|
|
94
108
|
};
|