@tmagic/editor 1.2.0-beta.2 → 1.2.0-beta.21
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 +41 -28
- package/dist/{tmagic-editor.mjs → tmagic-editor.js} +1693 -1272
- package/dist/tmagic-editor.js.map +1 -0
- package/dist/{tmagic-editor.umd.js → tmagic-editor.umd.cjs} +1700 -1274
- package/dist/tmagic-editor.umd.cjs.map +1 -0
- package/package.json +16 -14
- package/src/Editor.vue +54 -37
- package/src/components/CodeDraftEditor.vue +145 -0
- package/src/components/ContentMenu.vue +4 -4
- package/src/components/FunctionEditor.vue +145 -0
- package/src/components/Icon.vue +7 -5
- package/src/components/Layout.vue +149 -0
- package/src/components/ScrollBar.vue +1 -1
- package/src/components/ScrollViewer.vue +10 -1
- package/src/components/ToolButton.vue +30 -15
- package/src/fields/Code.vue +1 -1
- package/src/fields/CodeLink.vue +1 -1
- package/src/fields/CodeSelect.vue +89 -110
- package/src/fields/UISelect.vue +9 -8
- package/src/index.ts +1 -0
- package/src/layouts/AddPageBox.vue +3 -2
- package/src/layouts/CodeEditor.vue +2 -3
- package/src/layouts/Framework.vue +62 -40
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +11 -13
- package/src/layouts/Resizer.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +15 -13
- package/src/layouts/sidebar/LayerMenu.vue +9 -7
- package/src/layouts/sidebar/LayerPanel.vue +277 -177
- package/src/layouts/sidebar/Sidebar.vue +113 -27
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +34 -85
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +55 -89
- package/src/layouts/workspace/Breadcrumb.vue +32 -0
- package/src/layouts/workspace/PageBar.vue +12 -11
- package/src/layouts/workspace/PageBarScrollContainer.vue +1 -1
- package/src/layouts/workspace/Stage.vue +26 -9
- package/src/layouts/workspace/ViewerMenu.vue +11 -9
- package/src/layouts/workspace/Workspace.vue +10 -3
- package/src/services/BaseService.ts +6 -1
- package/src/services/codeBlock.ts +124 -125
- package/src/services/componentList.ts +6 -1
- package/src/services/editor.ts +43 -19
- package/src/services/events.ts +6 -1
- package/src/services/history.ts +7 -16
- package/src/services/props.ts +7 -2
- package/src/services/storage.ts +1 -0
- package/src/services/ui.ts +12 -0
- package/src/theme/breadcrumb.scss +6 -0
- package/src/theme/code-block.scss +30 -21
- package/src/theme/component-list-panel.scss +3 -7
- package/src/theme/layer-panel.scss +7 -2
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +76 -50
- package/src/utils/editor.ts +9 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/props.ts +2 -2
- package/src/utils/scroll-viewer.ts +18 -2
- package/src/utils/stage.ts +9 -2
- package/types/Editor.vue.d.ts +42 -29
- package/types/components/CodeDraftEditor.vue.d.ts +148 -0
- package/types/components/ContentMenu.vue.d.ts +1 -3
- package/types/components/FunctionEditor.vue.d.ts +120 -0
- package/types/components/Icon.vue.d.ts +1 -3
- package/types/{layouts → components}/Layout.vue.d.ts +12 -1
- package/types/components/ScrollBar.vue.d.ts +1 -3
- package/types/components/ScrollViewer.vue.d.ts +45 -1
- package/types/components/ToolButton.vue.d.ts +1 -3
- package/types/fields/Code.vue.d.ts +1 -3
- package/types/fields/CodeLink.vue.d.ts +1 -3
- package/types/fields/CodeSelect.vue.d.ts +10 -12
- package/types/fields/UISelect.vue.d.ts +1 -3
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +1 -3
- package/types/layouts/CodeEditor.vue.d.ts +6 -15
- package/types/layouts/NavMenu.vue.d.ts +1 -3
- package/types/layouts/sidebar/LayerMenu.vue.d.ts +25 -9
- package/types/layouts/sidebar/LayerPanel.vue.d.ts +38 -886
- package/types/layouts/sidebar/Sidebar.vue.d.ts +10 -5
- package/types/layouts/sidebar/code-block/CodeBlockEditor.vue.d.ts +1 -1
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +6 -5
- package/types/layouts/{sidebar/TabPane.vue.d.ts → workspace/Breadcrumb.vue.d.ts} +5 -43
- package/types/layouts/workspace/Stage.vue.d.ts +25 -8
- package/types/layouts/workspace/ViewerMenu.vue.d.ts +6 -3
- package/types/layouts/workspace/Workspace.vue.d.ts +23 -5
- package/types/services/BaseService.d.ts +2 -1
- package/types/services/codeBlock.d.ts +57 -36
- package/types/services/componentList.d.ts +1 -0
- package/types/services/editor.d.ts +5 -6
- package/types/services/events.d.ts +1 -0
- package/types/services/history.d.ts +5 -15
- package/types/services/props.d.ts +3 -2
- package/types/services/ui.d.ts +2 -1
- package/types/type.d.ts +64 -48
- package/types/utils/editor.d.ts +1 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/props.d.ts +1 -1
- package/types/utils/scroll-viewer.d.ts +5 -0
- package/dist/tmagic-editor.mjs.map +0 -1
- package/dist/tmagic-editor.umd.js.map +0 -1
- package/src/layouts/Layout.vue +0 -100
- package/src/layouts/sidebar/TabPane.vue +0 -116
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="el" class="m-editor-layout">
|
|
3
|
+
<template v-if="hasLeft">
|
|
4
|
+
<div class="m-editor-layout-left" :class="leftClass" :style="`width: ${left}px`">
|
|
5
|
+
<slot name="left"></slot>
|
|
6
|
+
</div>
|
|
7
|
+
<Resizer @change="changeLeft"></Resizer>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<div class="m-editor-layout-center" :class="centerClass" :style="`width: ${center}px`">
|
|
11
|
+
<slot name="center"></slot>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<template v-if="hasRight">
|
|
15
|
+
<Resizer @change="changeRight"></Resizer>
|
|
16
|
+
<div class="m-editor-layout-right" :class="rightClass" :style="`width: ${right}px`">
|
|
17
|
+
<slot name="right"></slot>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script lang="ts" setup name="MEditorLayout">
|
|
24
|
+
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
25
|
+
|
|
26
|
+
import Resizer from '../layouts/Resizer.vue';
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits(['update:left', 'change', 'update:right']);
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(
|
|
31
|
+
defineProps<{
|
|
32
|
+
left?: number;
|
|
33
|
+
right?: number;
|
|
34
|
+
minLeft?: number;
|
|
35
|
+
minRight?: number;
|
|
36
|
+
minCenter?: number;
|
|
37
|
+
leftClass?: string;
|
|
38
|
+
rightClass?: string;
|
|
39
|
+
centerClass?: string;
|
|
40
|
+
}>(),
|
|
41
|
+
{
|
|
42
|
+
minLeft: 46,
|
|
43
|
+
minRight: 1,
|
|
44
|
+
minCenter: 1,
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const el = ref<HTMLElement>();
|
|
49
|
+
|
|
50
|
+
const hasLeft = computed(() => typeof props.left !== 'undefined');
|
|
51
|
+
const hasRight = computed(() => typeof props.right !== 'undefined');
|
|
52
|
+
|
|
53
|
+
const getCenterWidth = (clientWidth: number, left: number, right: number) => {
|
|
54
|
+
let center = clientWidth - left - right;
|
|
55
|
+
if (center < props.minCenter) {
|
|
56
|
+
center = props.minCenter;
|
|
57
|
+
if (left < right) {
|
|
58
|
+
right = clientWidth - left - props.minCenter;
|
|
59
|
+
} else {
|
|
60
|
+
left = clientWidth - right - props.minCenter;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
center,
|
|
65
|
+
left,
|
|
66
|
+
right,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
let clientWidth = 0;
|
|
71
|
+
const resizerObserver = new ResizeObserver((entries) => {
|
|
72
|
+
for (const { contentRect } of entries) {
|
|
73
|
+
clientWidth = contentRect.width;
|
|
74
|
+
|
|
75
|
+
let left = props.left || 0;
|
|
76
|
+
let right = props.right || 0;
|
|
77
|
+
|
|
78
|
+
if (left > clientWidth) {
|
|
79
|
+
left = clientWidth / 3;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (right > clientWidth) {
|
|
83
|
+
right = clientWidth / 3;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const columnWidth = getCenterWidth(clientWidth, left, right);
|
|
87
|
+
|
|
88
|
+
center.value = columnWidth.center;
|
|
89
|
+
|
|
90
|
+
emit('change', {
|
|
91
|
+
left: columnWidth.left,
|
|
92
|
+
center: center.value,
|
|
93
|
+
right: columnWidth.right,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
if (el.value) {
|
|
100
|
+
resizerObserver.observe(el.value);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
onUnmounted(() => {
|
|
105
|
+
resizerObserver.disconnect();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const center = ref(0);
|
|
109
|
+
|
|
110
|
+
const changeLeft = (deltaX: number) => {
|
|
111
|
+
if (typeof props.left === 'undefined') return;
|
|
112
|
+
let left = Math.max(props.left + deltaX, props.minLeft) || 0;
|
|
113
|
+
emit('update:left', left);
|
|
114
|
+
|
|
115
|
+
if (clientWidth - left - (props.right || 0) <= 0) {
|
|
116
|
+
left = props.left;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const columnWidth = getCenterWidth(clientWidth, left, props.right || 0);
|
|
120
|
+
|
|
121
|
+
center.value = columnWidth.center;
|
|
122
|
+
|
|
123
|
+
emit('change', {
|
|
124
|
+
left: columnWidth.left,
|
|
125
|
+
center: center.value,
|
|
126
|
+
right: columnWidth.right,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const changeRight = (deltaX: number) => {
|
|
131
|
+
if (typeof props.right === 'undefined') return;
|
|
132
|
+
let right = Math.max(props.right - deltaX, props.minRight) || 0;
|
|
133
|
+
emit('update:right', right);
|
|
134
|
+
|
|
135
|
+
if (clientWidth - (props.left || 0) - right <= 0) {
|
|
136
|
+
right = props.right;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const columnWidth = getCenterWidth(clientWidth, props.left || 0, right);
|
|
140
|
+
|
|
141
|
+
center.value = columnWidth.center;
|
|
142
|
+
|
|
143
|
+
emit('change', {
|
|
144
|
+
left: columnWidth.left,
|
|
145
|
+
center: center.value,
|
|
146
|
+
right: columnWidth.right,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
</script>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<script lang="ts" setup>
|
|
25
|
+
<script lang="ts" setup name="MEditorScrollViewer">
|
|
26
26
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
27
27
|
|
|
28
28
|
import { ScrollViewerEvent } from '../type';
|
|
@@ -37,6 +37,10 @@ const props = withDefaults(
|
|
|
37
37
|
wrapWidth?: number;
|
|
38
38
|
wrapHeight?: number;
|
|
39
39
|
zoom?: number;
|
|
40
|
+
correctionScrollSize?: {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
40
44
|
}>(),
|
|
41
45
|
{
|
|
42
46
|
width: 0,
|
|
@@ -44,6 +48,10 @@ const props = withDefaults(
|
|
|
44
48
|
wrapWidth: 0,
|
|
45
49
|
wrapHeight: 0,
|
|
46
50
|
zoom: 1,
|
|
51
|
+
correctionScrollSize: () => ({
|
|
52
|
+
width: 0,
|
|
53
|
+
height: 0,
|
|
54
|
+
}),
|
|
47
55
|
},
|
|
48
56
|
);
|
|
49
57
|
|
|
@@ -69,6 +77,7 @@ onMounted(() => {
|
|
|
69
77
|
container: container.value,
|
|
70
78
|
target: el.value,
|
|
71
79
|
zoom: props.zoom,
|
|
80
|
+
correctionScrollSize: props.correctionScrollSize,
|
|
72
81
|
});
|
|
73
82
|
|
|
74
83
|
scrollViewer.on('scroll', (data: ScrollViewerEvent) => {
|
|
@@ -7,41 +7,56 @@
|
|
|
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>
|
|
39
44
|
</template>
|
|
40
45
|
|
|
41
|
-
<script lang="ts" setup>
|
|
46
|
+
<script lang="ts" setup name="MEditorToolButton">
|
|
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
|
|
package/src/fields/Code.vue
CHANGED
package/src/fields/CodeLink.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<m-fields-link :config="formConfig" :model="modelValue" name="form" @change="changeHandler"></m-fields-link>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script lang="ts" setup>
|
|
5
|
+
<script lang="ts" setup name="MEditorCodeLink">
|
|
6
6
|
import { computed, reactive, watch } from 'vue';
|
|
7
7
|
import serialize from 'serialize-javascript';
|
|
8
8
|
|
|
@@ -1,139 +1,118 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="m-fields-code-select"
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</template>
|
|
14
|
-
<div class="tool-bar">
|
|
15
|
-
<el-tooltip class="tool-item" effect="dark" content="查看代码块" placement="top">
|
|
16
|
-
<svg
|
|
17
|
-
@click="viewHandler"
|
|
18
|
-
preserveAspectRatio="xMidYMid meet"
|
|
19
|
-
viewBox="0 0 24 24"
|
|
20
|
-
width="15px"
|
|
21
|
-
height="15px"
|
|
22
|
-
data-v-65a7fb6c=""
|
|
23
|
-
>
|
|
24
|
-
<path
|
|
25
|
-
fill="currentColor"
|
|
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
|
-
></path>
|
|
28
|
-
</svg>
|
|
29
|
-
</el-tooltip>
|
|
30
|
-
</div>
|
|
31
|
-
</el-card>
|
|
2
|
+
<div class="m-fields-code-select">
|
|
3
|
+
<m-form-table
|
|
4
|
+
:config="tableConfig"
|
|
5
|
+
:model="model[name]"
|
|
6
|
+
name="hookData"
|
|
7
|
+
:enableToggleMode="false"
|
|
8
|
+
:prop="prop"
|
|
9
|
+
:size="size"
|
|
10
|
+
@change="changeHandler"
|
|
11
|
+
>
|
|
12
|
+
</m-form-table>
|
|
32
13
|
</div>
|
|
33
14
|
</template>
|
|
34
15
|
|
|
35
|
-
<script lang="ts" setup>
|
|
36
|
-
import { computed, defineEmits, defineProps, inject,
|
|
37
|
-
import {
|
|
38
|
-
import { cloneDeep, map, xor } from 'lodash-es';
|
|
16
|
+
<script lang="ts" setup name="MEditorCodeSelect">
|
|
17
|
+
import { computed, defineEmits, defineProps, inject, watch } from 'vue';
|
|
18
|
+
import { isEmpty, map } from 'lodash-es';
|
|
39
19
|
|
|
40
|
-
import {
|
|
20
|
+
import { createValues, FormItem, FormState, TableConfig } from '@tmagic/form';
|
|
21
|
+
import { HookType, Id } from '@tmagic/schema';
|
|
41
22
|
|
|
42
|
-
import
|
|
43
|
-
import { CodeEditorMode, CodeSelectOp } from '../type';
|
|
23
|
+
import { CodeParamStatement, HookData, Services } from '../type';
|
|
44
24
|
const services = inject<Services>('services');
|
|
45
|
-
|
|
25
|
+
const mForm = inject<FormState>('mForm');
|
|
46
26
|
const emit = defineEmits(['change']);
|
|
47
27
|
|
|
48
28
|
const props = defineProps<{
|
|
49
29
|
config: {
|
|
50
|
-
|
|
30
|
+
tableConfig?: TableConfig;
|
|
51
31
|
};
|
|
52
32
|
model: any;
|
|
53
33
|
prop: string;
|
|
54
34
|
name: string;
|
|
55
|
-
size:
|
|
35
|
+
size: 'mini' | 'small' | 'medium';
|
|
56
36
|
}>();
|
|
37
|
+
const codeDsl = computed(() => services?.codeBlockService.getCodeDslSync());
|
|
57
38
|
|
|
58
|
-
const
|
|
39
|
+
const tableConfig = computed<FormItem>(() => {
|
|
59
40
|
const defaultConfig = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
dropSort: true,
|
|
42
|
+
enableFullscreen: false,
|
|
43
|
+
border: true,
|
|
44
|
+
items: [
|
|
45
|
+
{
|
|
46
|
+
type: 'select',
|
|
47
|
+
label: '代码块',
|
|
48
|
+
name: 'codeId',
|
|
49
|
+
width: '200px',
|
|
50
|
+
options: () => {
|
|
51
|
+
if (codeDsl.value) {
|
|
52
|
+
return map(codeDsl.value, (value, key) => ({
|
|
53
|
+
text: `${value.name}(${key})`,
|
|
54
|
+
label: `${value.name}(${key})`,
|
|
55
|
+
value: key,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
return [];
|
|
59
|
+
},
|
|
60
|
+
onChange: (formState: any, codeId: Id, { model }: any) => {
|
|
61
|
+
// 参数的items是根据函数生成的,当codeId变化后修正model的值,避免写入其他codeId的params
|
|
62
|
+
model.params = {};
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'params',
|
|
67
|
+
label: '参数',
|
|
68
|
+
defaultValue: {},
|
|
69
|
+
itemsFunction: (row: HookData) => {
|
|
70
|
+
const paramsConfig = getParamsConfig(row.codeId);
|
|
71
|
+
if (!row.params) row.params = {};
|
|
72
|
+
if (isEmpty(row.params)) {
|
|
73
|
+
createValues(mForm, paramsConfig, {}, row.params);
|
|
74
|
+
}
|
|
75
|
+
return paramsConfig;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
72
79
|
};
|
|
73
80
|
return {
|
|
74
81
|
...defaultConfig,
|
|
75
|
-
...props.config.
|
|
82
|
+
...props.config.tableConfig,
|
|
76
83
|
};
|
|
77
84
|
});
|
|
78
|
-
const fieldKey = ref('');
|
|
79
|
-
const multiple = ref(true);
|
|
80
|
-
const combineIds = ref<string[]>([]);
|
|
81
|
-
let lastTagSnapshot = cloneDeep(props.model[props.name]) || [];
|
|
82
|
-
|
|
83
|
-
watchEffect(async () => {
|
|
84
|
-
const combineNames = await Promise.all(
|
|
85
|
-
combineIds.value.map(async (id) => {
|
|
86
|
-
const { name = '' } = (await services?.codeBlockService.getCodeContentById(id)) || {};
|
|
87
|
-
return name;
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
fieldKey.value = combineNames.join('-');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const changeHandler = async (value: any) => {
|
|
94
|
-
let codeIds = value;
|
|
95
|
-
if (typeof value === 'string') {
|
|
96
|
-
multiple.value = false;
|
|
97
|
-
lastTagSnapshot = [lastTagSnapshot];
|
|
98
|
-
codeIds = value ? [value] : [];
|
|
99
|
-
}
|
|
100
|
-
await setCombineRelation(codeIds);
|
|
101
|
-
emit('change', value);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// 同步绑定关系
|
|
105
|
-
const setCombineRelation = async (codeIds: string[]) => {
|
|
106
|
-
// 组件id
|
|
107
|
-
const { id = '' } = services?.editorService.get('node') || {};
|
|
108
85
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
86
|
+
watch(
|
|
87
|
+
() => props.model[props.name],
|
|
88
|
+
(value) => {
|
|
89
|
+
// 兼容旧的数据结构
|
|
90
|
+
if (isEmpty(value)) {
|
|
91
|
+
// 空值或者空数组
|
|
92
|
+
props.model[props.name] = {
|
|
93
|
+
hookType: HookType.CODE,
|
|
94
|
+
hookData: [],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
immediate: true,
|
|
100
|
+
},
|
|
101
|
+
);
|
|
122
102
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
combineIds.value = codeIds;
|
|
126
|
-
await services?.codeBlockService.setCombineIds(codeIds);
|
|
103
|
+
const changeHandler = async () => {
|
|
104
|
+
emit('change', props.model[props.name]);
|
|
127
105
|
};
|
|
128
106
|
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
107
|
+
const getParamsConfig = (codeId: Id) => {
|
|
108
|
+
if (!codeDsl.value) return [];
|
|
109
|
+
const paramStatements = codeDsl.value[codeId]?.params;
|
|
110
|
+
if (isEmpty(paramStatements)) return [];
|
|
111
|
+
return paramStatements.map((paramState: CodeParamStatement) => ({
|
|
112
|
+
name: paramState.name,
|
|
113
|
+
text: paramState.name,
|
|
114
|
+
labelWidth: '100px',
|
|
115
|
+
type: 'text',
|
|
116
|
+
}));
|
|
138
117
|
};
|
|
139
118
|
</script>
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
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
|
|
|
15
|
-
<script lang="ts" setup>
|
|
15
|
+
<script lang="ts" setup name="MEditorUISelect">
|
|
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';
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
|
48
48
|
export { default as ToolButton } from './components/ToolButton.vue';
|
|
49
49
|
export { default as ContentMenu } from './components/ContentMenu.vue';
|
|
50
50
|
export { default as Icon } from './components/Icon.vue';
|
|
51
|
+
export { default as LayoutContainer } from './components/Layout.vue';
|
|
51
52
|
|
|
52
53
|
const defaultInstallOpt: InstallOptions = {
|
|
53
54
|
// @todo, 自定义图片上传方法等编辑器依赖的外部选项
|
|
@@ -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>
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script lang="ts" setup>
|
|
14
|
+
<script lang="ts" setup name="MEditorAddPageBox">
|
|
15
15
|
import { inject, toRaw } from 'vue';
|
|
16
16
|
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
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div ref="codeEditor" class="magic-code-editor"></div>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script lang="ts" setup>
|
|
5
|
+
<script lang="ts" setup name="MEditorCodeEditor">
|
|
6
6
|
import { onMounted, onUnmounted, ref, watch } from 'vue';
|
|
7
7
|
import { throttle } from 'lodash-es';
|
|
8
8
|
import * as monaco from 'monaco-editor';
|
|
@@ -12,7 +12,7 @@ const props = withDefaults(
|
|
|
12
12
|
defineProps<{
|
|
13
13
|
initValues?: string | Object;
|
|
14
14
|
modifiedValues?: string | Object;
|
|
15
|
-
type?:
|
|
15
|
+
type?: 'diff';
|
|
16
16
|
language?: string;
|
|
17
17
|
options?: {
|
|
18
18
|
[key: string]: any;
|
|
@@ -20,7 +20,6 @@ const props = withDefaults(
|
|
|
20
20
|
autoSave?: boolean;
|
|
21
21
|
}>(),
|
|
22
22
|
{
|
|
23
|
-
type: '',
|
|
24
23
|
autoSave: true,
|
|
25
24
|
language: 'javascript',
|
|
26
25
|
options: () => ({
|