@tmagic/editor 1.2.13 → 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 +37 -6
- package/dist/tmagic-editor.js +770 -394
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +789 -420
- 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/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 +3 -3
- package/src/layouts/sidebar/LayerMenu.vue +2 -2
- package/src/layouts/sidebar/LayerPanel.vue +4 -4
- package/src/layouts/sidebar/Sidebar.vue +3 -3
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +15 -6
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +26 -13
- 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 +3 -3
- 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 +28 -4
- package/src/theme/event.scss +12 -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/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 +1 -1
- 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
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.14",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "npm run build:type && vite build",
|
|
27
|
-
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
|
|
27
|
+
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
28
28
|
"clear:type": "rimraf ./types"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "^7.18.0",
|
|
48
48
|
"@element-plus/icons-vue": "^2.0.9",
|
|
49
|
-
"@tmagic/core": "1.2.
|
|
50
|
-
"@tmagic/design": "1.2.
|
|
51
|
-
"@tmagic/form": "1.2.
|
|
52
|
-
"@tmagic/schema": "1.2.
|
|
53
|
-
"@tmagic/stage": "1.2.
|
|
54
|
-
"@tmagic/utils": "1.2.
|
|
49
|
+
"@tmagic/core": "1.2.14",
|
|
50
|
+
"@tmagic/design": "1.2.14",
|
|
51
|
+
"@tmagic/form": "1.2.14",
|
|
52
|
+
"@tmagic/schema": "1.2.14",
|
|
53
|
+
"@tmagic/stage": "1.2.14",
|
|
54
|
+
"@tmagic/utils": "1.2.14",
|
|
55
55
|
"buffer": "^6.0.3",
|
|
56
56
|
"color": "^3.1.3",
|
|
57
57
|
"events": "^3.3.0",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"vue": "^3.2.37"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@tmagic/design": "1.2.
|
|
67
|
-
"@tmagic/form": "1.2.
|
|
66
|
+
"@tmagic/design": "1.2.14",
|
|
67
|
+
"@tmagic/form": "1.2.14",
|
|
68
68
|
"monaco-editor": "^0.34.0",
|
|
69
69
|
"vue": "^3.2.37"
|
|
70
70
|
},
|
|
@@ -73,13 +73,14 @@
|
|
|
73
73
|
"@types/lodash-es": "^4.17.4",
|
|
74
74
|
"@types/node": "^15.12.4",
|
|
75
75
|
"@types/serialize-javascript": "^5.0.1",
|
|
76
|
-
"@vitejs/plugin-vue": "^
|
|
76
|
+
"@vitejs/plugin-vue": "^4.1.0",
|
|
77
77
|
"@vue/compiler-sfc": "^3.2.37",
|
|
78
78
|
"@vue/test-utils": "^2.0.0",
|
|
79
79
|
"rimraf": "^3.0.2",
|
|
80
80
|
"sass": "^1.35.1",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
81
|
+
"tsc-alias": "^1.8.5",
|
|
82
|
+
"typescript": "^5.0.4",
|
|
83
|
+
"vite": "^4.2.1",
|
|
83
84
|
"vite-plugin-vue-setup-extend": "^0.4.0",
|
|
84
85
|
"vue-tsc": "^1.0.11"
|
|
85
86
|
}
|
|
@@ -25,15 +25,14 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
<script lang="ts" setup name="MEditorCodeDraftEditor">
|
|
27
27
|
import { computed, inject, ref, watchEffect } from 'vue';
|
|
28
|
-
import type { Action } from 'element-plus';
|
|
29
28
|
import type * as monaco from 'monaco-editor';
|
|
30
29
|
|
|
31
30
|
import { TMagicButton, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
|
|
32
31
|
import { Id } from '@tmagic/schema';
|
|
33
32
|
import { datetimeFormatter } from '@tmagic/utils';
|
|
34
33
|
|
|
35
|
-
import MagicCodeEditor from '
|
|
36
|
-
import type { Services } from '
|
|
34
|
+
import MagicCodeEditor from '@editor/layouts/CodeEditor.vue';
|
|
35
|
+
import type { Services } from '@editor/type';
|
|
37
36
|
|
|
38
37
|
const props = withDefaults(
|
|
39
38
|
defineProps<{
|
|
@@ -93,7 +92,7 @@ const saveCodeDraft = async (codeValue: string) => {
|
|
|
93
92
|
return;
|
|
94
93
|
}
|
|
95
94
|
services?.codeBlockService.setCodeDraft(props.id, codeValue);
|
|
96
|
-
tMagicMessage.success(
|
|
95
|
+
tMagicMessage.success(`代码草稿成功保存到本地 ${datetimeFormatter(new Date())}`);
|
|
97
96
|
};
|
|
98
97
|
|
|
99
98
|
// 保存并关闭
|
|
@@ -108,24 +107,23 @@ const saveAndClose = (): void => {
|
|
|
108
107
|
const close = async (): Promise<void> => {
|
|
109
108
|
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
110
109
|
if (codeDraft) {
|
|
111
|
-
|
|
112
|
-
.confirm('您有代码修改未保存,是否保存后再关闭?', '提示', {
|
|
110
|
+
try {
|
|
111
|
+
await tMagicMessageBox.confirm('您有代码修改未保存,是否保存后再关闭?', '提示', {
|
|
113
112
|
confirmButtonText: '保存并关闭',
|
|
114
113
|
cancelButtonText: '直接关闭',
|
|
115
114
|
type: 'warning',
|
|
116
115
|
distinguishCancelAndClose: true,
|
|
117
|
-
})
|
|
118
|
-
.then(async () => {
|
|
119
|
-
// 保存之后再关闭
|
|
120
|
-
saveAndClose();
|
|
121
|
-
})
|
|
122
|
-
.catch((action: Action) => {
|
|
123
|
-
if (action === 'cancel') {
|
|
124
|
-
// 删除草稿 直接关闭
|
|
125
|
-
services?.codeBlockService.removeCodeDraft(props.id);
|
|
126
|
-
emit('close');
|
|
127
|
-
}
|
|
128
116
|
});
|
|
117
|
+
|
|
118
|
+
// 保存之后再关闭
|
|
119
|
+
saveAndClose();
|
|
120
|
+
} catch (action: any) {
|
|
121
|
+
if (action === 'cancel') {
|
|
122
|
+
// 删除草稿 直接关闭
|
|
123
|
+
services?.codeBlockService.removeCodeDraft(props.id);
|
|
124
|
+
emit('close');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
129
127
|
} else {
|
|
130
128
|
emit('close');
|
|
131
129
|
}
|
|
@@ -138,4 +136,9 @@ const toggleFullScreen = (): void => {
|
|
|
138
136
|
codeEditor.value.focus();
|
|
139
137
|
}
|
|
140
138
|
};
|
|
139
|
+
|
|
140
|
+
defineExpose({
|
|
141
|
+
saveAndClose,
|
|
142
|
+
close,
|
|
143
|
+
});
|
|
141
144
|
</script>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<script lang="ts" setup name="MEditorContentMenu">
|
|
26
26
|
import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
|
27
27
|
|
|
28
|
-
import { MenuButton, MenuComponent } from '
|
|
28
|
+
import { MenuButton, MenuComponent } from '@editor/type';
|
|
29
29
|
|
|
30
30
|
import ToolButton from './ToolButton.vue';
|
|
31
31
|
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
</template>
|
|
22
22
|
<CodeDraftEditor
|
|
23
|
+
ref="codeDraftEditor"
|
|
23
24
|
:id="id"
|
|
24
25
|
:content="codeContent"
|
|
25
26
|
:editable="editable"
|
|
@@ -32,14 +33,14 @@
|
|
|
32
33
|
</TMagicCard>
|
|
33
34
|
</template>
|
|
34
35
|
<script lang="ts" setup name="MEditorFunctionEditor">
|
|
35
|
-
import { inject,
|
|
36
|
+
import { inject, ref, watchEffect } from 'vue';
|
|
36
37
|
import { cloneDeep } from 'lodash-es';
|
|
37
38
|
|
|
38
39
|
import { TMagicCard, TMagicInput, tMagicMessage } from '@tmagic/design';
|
|
39
40
|
import { ColumnConfig, TableConfig } from '@tmagic/form';
|
|
40
41
|
import { CodeParam, Id } from '@tmagic/schema';
|
|
41
42
|
|
|
42
|
-
import type { Services } from '
|
|
43
|
+
import type { Services } from '@editor/type';
|
|
43
44
|
|
|
44
45
|
import CodeDraftEditor from './CodeDraftEditor.vue';
|
|
45
46
|
const defaultParamColConfig: ColumnConfig = {
|
|
@@ -116,19 +117,12 @@ const tableConfig: TableConfig = {
|
|
|
116
117
|
],
|
|
117
118
|
};
|
|
118
119
|
|
|
119
|
-
const emit = defineEmits(['change', 'field-input']);
|
|
120
|
-
|
|
121
120
|
const services = inject<Services>('services');
|
|
122
121
|
|
|
123
122
|
const codeName = ref<string>('');
|
|
124
123
|
const codeContent = ref<string>('');
|
|
125
124
|
const evalRes = ref(true);
|
|
126
125
|
|
|
127
|
-
provide('mForm', {
|
|
128
|
-
$emit: emit,
|
|
129
|
-
setField: () => {},
|
|
130
|
-
});
|
|
131
|
-
|
|
132
126
|
const tableModel = ref<{ params: CodeParam[] }>();
|
|
133
127
|
watchEffect(() => {
|
|
134
128
|
codeName.value = props.name;
|
|
@@ -169,7 +163,7 @@ const saveCode = async (codeValue: string): Promise<void> => {
|
|
|
169
163
|
content: codeValue,
|
|
170
164
|
params: tableModel.value?.params || [],
|
|
171
165
|
});
|
|
172
|
-
tMagicMessage.success('
|
|
166
|
+
tMagicMessage.success('代码成功保存到本地');
|
|
173
167
|
// 删除草稿
|
|
174
168
|
services?.codeBlockService.removeCodeDraft(props.id);
|
|
175
169
|
}
|
|
@@ -187,4 +181,10 @@ const saveAndClose = async (codeValue: string): Promise<void> => {
|
|
|
187
181
|
const close = (): void => {
|
|
188
182
|
services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
189
183
|
};
|
|
184
|
+
|
|
185
|
+
const codeDraftEditor = ref<InstanceType<typeof CodeDraftEditor>>();
|
|
186
|
+
|
|
187
|
+
defineExpose({
|
|
188
|
+
codeDraftEditor,
|
|
189
|
+
});
|
|
190
190
|
</script>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<script lang="ts" setup name="MEditorLayout">
|
|
24
24
|
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
25
25
|
|
|
26
|
-
import Resizer from '
|
|
26
|
+
import Resizer from '@editor/layouts/Resizer.vue';
|
|
27
27
|
|
|
28
28
|
const emit = defineEmits(['update:left', 'change', 'update:right']);
|
|
29
29
|
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
<script lang="ts" setup name="MEditorScrollViewer">
|
|
26
26
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
27
27
|
|
|
28
|
-
import { ScrollViewerEvent } from '
|
|
29
|
-
import { ScrollViewer } from '
|
|
28
|
+
import type { ScrollViewerEvent } from '@editor/type';
|
|
29
|
+
import { ScrollViewer } from '@editor/utils/scroll-viewer';
|
|
30
30
|
|
|
31
31
|
import ScrollBar from './ScrollBar.vue';
|
|
32
32
|
|
|
@@ -1,110 +1,43 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-code-select" :class="config.className">
|
|
3
|
-
<
|
|
4
|
-
:config="
|
|
5
|
-
|
|
6
|
-
name="hookData"
|
|
7
|
-
:enableToggleMode="false"
|
|
8
|
-
:prop="prop"
|
|
9
|
-
:size="size"
|
|
10
|
-
@change="changeHandler"
|
|
11
|
-
>
|
|
12
|
-
<template #operateCol="{ scope }">
|
|
13
|
-
<Icon
|
|
14
|
-
v-if="scope.row.codeId && config.editable"
|
|
15
|
-
:icon="editable ? Edit : View"
|
|
16
|
-
class="edit-icon"
|
|
17
|
-
@click="editCode(scope.row.codeId)"
|
|
18
|
-
></Icon>
|
|
19
|
-
</template>
|
|
20
|
-
</m-form-table>
|
|
3
|
+
<TMagicCard>
|
|
4
|
+
<m-form-container :config="codeConfig" :model="model[name]" @change="changeHandler"> </m-form-container>
|
|
5
|
+
</TMagicCard>
|
|
21
6
|
</div>
|
|
22
7
|
</template>
|
|
23
8
|
|
|
24
9
|
<script lang="ts" setup name="MEditorCodeSelect">
|
|
25
|
-
import { computed, defineEmits, defineProps,
|
|
26
|
-
import {
|
|
27
|
-
import { isEmpty, map } from 'lodash-es';
|
|
10
|
+
import { computed, defineEmits, defineProps, watch } from 'vue';
|
|
11
|
+
import { isEmpty } from 'lodash-es';
|
|
28
12
|
|
|
29
|
-
import {
|
|
30
|
-
import { HookType
|
|
13
|
+
import { TMagicCard } from '@tmagic/design';
|
|
14
|
+
import { HookType } from '@tmagic/schema';
|
|
31
15
|
|
|
32
|
-
import Icon from '../components/Icon.vue';
|
|
33
|
-
import { CodeParamStatement, HookData, Services } from '../type';
|
|
34
|
-
const services = inject<Services>('services');
|
|
35
|
-
const mForm = inject<FormState>('mForm');
|
|
36
16
|
const emit = defineEmits(['change']);
|
|
37
17
|
|
|
38
18
|
const props = withDefaults(
|
|
39
19
|
defineProps<{
|
|
40
20
|
config: {
|
|
41
|
-
tableConfig?: TableConfig;
|
|
42
21
|
className?: string;
|
|
43
|
-
editable?: boolean;
|
|
44
22
|
};
|
|
45
23
|
model: any;
|
|
46
24
|
prop: string;
|
|
47
25
|
name: string;
|
|
48
26
|
size: 'small' | 'default' | 'large';
|
|
49
27
|
}>(),
|
|
50
|
-
{
|
|
51
|
-
config: () => ({
|
|
52
|
-
editable: true,
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
28
|
+
{},
|
|
55
29
|
);
|
|
56
30
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type: 'select',
|
|
68
|
-
label: '代码块',
|
|
69
|
-
name: 'codeId',
|
|
70
|
-
width: '200px',
|
|
71
|
-
options: () => {
|
|
72
|
-
if (codeDsl.value) {
|
|
73
|
-
return map(codeDsl.value, (value, key) => ({
|
|
74
|
-
text: `${value.name}(${key})`,
|
|
75
|
-
label: `${value.name}(${key})`,
|
|
76
|
-
value: key,
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
return [];
|
|
80
|
-
},
|
|
81
|
-
onChange: (formState: any, codeId: Id, { model }: any) => {
|
|
82
|
-
// 参数的items是根据函数生成的,当codeId变化后修正model的值,避免写入其他codeId的params
|
|
83
|
-
model.params = {};
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: 'params',
|
|
88
|
-
label: '参数',
|
|
89
|
-
defaultValue: {},
|
|
90
|
-
itemsFunction: (row: HookData) => {
|
|
91
|
-
const paramsConfig = getParamsConfig(row.codeId);
|
|
92
|
-
// 如果参数没有填值,则使用createValues补全空值
|
|
93
|
-
if (!row.params || isEmpty(row.params)) {
|
|
94
|
-
createValues(mForm, paramsConfig, {}, row.params);
|
|
95
|
-
}
|
|
96
|
-
return paramsConfig;
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
...defaultConfig,
|
|
103
|
-
...props.config.tableConfig,
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
31
|
+
const codeConfig = computed(() => ({
|
|
32
|
+
type: 'group-list',
|
|
33
|
+
name: 'hookData',
|
|
34
|
+
enableToggleMode: false,
|
|
35
|
+
items: [
|
|
36
|
+
{
|
|
37
|
+
type: 'code-select-col',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}));
|
|
108
41
|
|
|
109
42
|
watch(
|
|
110
43
|
() => props.model[props.name],
|
|
@@ -126,20 +59,4 @@ watch(
|
|
|
126
59
|
const changeHandler = async () => {
|
|
127
60
|
emit('change', props.model[props.name]);
|
|
128
61
|
};
|
|
129
|
-
|
|
130
|
-
const getParamsConfig = (codeId: Id): CodeParamStatement[] => {
|
|
131
|
-
if (!codeDsl.value) return [];
|
|
132
|
-
const paramStatements = codeDsl.value[codeId]?.params;
|
|
133
|
-
if (isEmpty(paramStatements)) return [];
|
|
134
|
-
return paramStatements.map((paramState: CodeParamStatement) => ({
|
|
135
|
-
labelWidth: '100px',
|
|
136
|
-
text: paramState.name,
|
|
137
|
-
inline: true,
|
|
138
|
-
...paramState,
|
|
139
|
-
}));
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const editCode = (codeId: Id) => {
|
|
143
|
-
services?.codeBlockService.setCodeEditorContent(true, codeId);
|
|
144
|
-
};
|
|
145
62
|
</script>
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-code-select-col">
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
<div class="code-select-container">
|
|
4
|
+
<!-- 代码块下拉框 -->
|
|
5
|
+
<m-form-container
|
|
6
|
+
class="select"
|
|
7
|
+
:config="selectConfig"
|
|
8
|
+
:model="model"
|
|
9
|
+
@change="onParamsChangeHandler"
|
|
10
|
+
></m-form-container>
|
|
11
|
+
<!-- 查看/编辑按钮 -->
|
|
12
|
+
<Icon class="icon" :icon="editable ? Edit : View" @click="editCode"></Icon>
|
|
13
|
+
</div>
|
|
5
14
|
<!-- 参数填写框 -->
|
|
6
15
|
<m-form-container :config="codeParamsConfig" :model="model" @change="onParamsChangeHandler"></m-form-container>
|
|
7
16
|
</div>
|
|
@@ -9,12 +18,15 @@
|
|
|
9
18
|
|
|
10
19
|
<script lang="ts" setup name="MEditorCodeSelectCol">
|
|
11
20
|
import { computed, defineEmits, defineProps, inject, ref, watch } from 'vue';
|
|
21
|
+
import { Edit, View } from '@element-plus/icons-vue';
|
|
12
22
|
import { isEmpty, map } from 'lodash-es';
|
|
13
23
|
|
|
14
24
|
import { createValues, FieldsetConfig, FormState } from '@tmagic/form';
|
|
15
25
|
import { Id } from '@tmagic/schema';
|
|
16
26
|
|
|
17
|
-
import
|
|
27
|
+
import Icon from '@editor/components/Icon.vue';
|
|
28
|
+
import type { CodeParamStatement, Services } from '@editor/type';
|
|
29
|
+
|
|
18
30
|
const services = inject<Services>('services');
|
|
19
31
|
const mForm = inject<FormState>('mForm');
|
|
20
32
|
const emit = defineEmits(['change']);
|
|
@@ -30,6 +42,7 @@ const props = withDefaults(
|
|
|
30
42
|
{},
|
|
31
43
|
);
|
|
32
44
|
const codeDsl = computed(() => services?.codeBlockService.getCodeDsl());
|
|
45
|
+
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
33
46
|
const codeParamsConfig = ref<FieldsetConfig>({
|
|
34
47
|
type: 'fieldset',
|
|
35
48
|
items: [],
|
|
@@ -114,4 +127,9 @@ watch(
|
|
|
114
127
|
immediate: true,
|
|
115
128
|
},
|
|
116
129
|
);
|
|
130
|
+
|
|
131
|
+
// 打开代码编辑框
|
|
132
|
+
const editCode = () => {
|
|
133
|
+
services?.codeBlockService.setCodeEditorContent(true, props.model.codeId);
|
|
134
|
+
};
|
|
117
135
|
</script>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-event-select">
|
|
3
|
-
<m-form-
|
|
3
|
+
<m-form-table
|
|
4
4
|
v-if="isOldVersion"
|
|
5
5
|
ref="eventForm"
|
|
6
6
|
:size="props.size"
|
|
7
7
|
:model="model"
|
|
8
|
+
name="events"
|
|
8
9
|
:config="tableConfig"
|
|
9
10
|
@change="onChangeHandler"
|
|
10
|
-
></m-form-
|
|
11
|
+
></m-form-table>
|
|
11
12
|
|
|
12
13
|
<div v-else class="fullWidth">
|
|
13
14
|
<TMagicButton class="create-button" type="primary" size="small" @click="addEvent()">添加事件</TMagicButton>
|
|
@@ -41,7 +42,8 @@ import { TMagicButton } from '@tmagic/design';
|
|
|
41
42
|
import { FormState } from '@tmagic/form';
|
|
42
43
|
import { ActionType } from '@tmagic/schema';
|
|
43
44
|
|
|
44
|
-
import { EventSelectConfig, Services } from '
|
|
45
|
+
import type { EventSelectConfig, Services } from '@editor/type';
|
|
46
|
+
|
|
45
47
|
const services = inject<Services>('services');
|
|
46
48
|
|
|
47
49
|
const props = defineProps<{
|
package/src/fields/UISelect.vue
CHANGED
|
@@ -19,7 +19,7 @@ import { Close, Delete } from '@element-plus/icons-vue';
|
|
|
19
19
|
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
20
20
|
import { FormState } from '@tmagic/form';
|
|
21
21
|
|
|
22
|
-
import { Services } from '
|
|
22
|
+
import type { Services } from '@editor/type';
|
|
23
23
|
|
|
24
24
|
const props = defineProps<{
|
|
25
25
|
config: any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- app-manage cdn链接:https://cloudcache.tencent-cloud.com/qcloud/ui/static/console_aside_v4/6638c8a5-2e7f-477a-83b1-a413a0e4ba39.svg -->
|
|
3
|
+
<svg width="16px" height="16px" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<g fill="#7C878E" fill-rule="evenodd">
|
|
5
|
+
<path d="M15.3,5.5 L8,0 L0.7,5.5 L8,11 L15.3,5.5 Z M8,2.5 L12,5.5 L8,8.5 L4,5.5 L8,2.5 Z" fill-rule="nonzero" />
|
|
6
|
+
<path d="M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" />
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts" setup name="MEditorAppManageIcon"></script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 代码icon,cdn链接:https://cloudcache.tencent-cloud.com/qcloud/ui/static/government/0d463ed5-6407-4498-8865-3d05b5e70115.svg -->
|
|
3
|
+
<svg
|
|
4
|
+
width="32px"
|
|
5
|
+
height="32px"
|
|
6
|
+
viewBox="0 0 32 32"
|
|
7
|
+
version="1.1"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
10
|
+
>
|
|
11
|
+
<!-- Generator: Sketch 60.1 (88133) - https://sketch.com -->
|
|
12
|
+
<title>gsd-icon-line-Universal-code</title>
|
|
13
|
+
<desc>Created with Sketch.</desc>
|
|
14
|
+
<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs>
|
|
15
|
+
<g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
16
|
+
<g id="03图标" transform="translate(-561.000000, -2356.000000)">
|
|
17
|
+
<g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)">
|
|
18
|
+
<g id="路径">
|
|
19
|
+
<mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask>
|
|
20
|
+
<use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use>
|
|
21
|
+
<path
|
|
22
|
+
d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z"
|
|
23
|
+
id="形状"
|
|
24
|
+
fill="#1D1F24"
|
|
25
|
+
mask="url(#mask-2)"
|
|
26
|
+
></path>
|
|
27
|
+
</g>
|
|
28
|
+
</g>
|
|
29
|
+
<g id="icon切图" transform="translate(226.000000, 1782.000000)"></g>
|
|
30
|
+
</g>
|
|
31
|
+
</g>
|
|
32
|
+
</svg>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts" setup name="MEditorCodeIcon"></script>
|
|
@@ -17,9 +17,9 @@ import { Plus } from '@element-plus/icons-vue';
|
|
|
17
17
|
|
|
18
18
|
import { NodeType } from '@tmagic/schema';
|
|
19
19
|
|
|
20
|
-
import MIcon from '
|
|
21
|
-
import type { Services } from '
|
|
22
|
-
import { generatePageNameByApp } from '
|
|
20
|
+
import MIcon from '@editor/components/Icon.vue';
|
|
21
|
+
import type { Services } from '@editor/type';
|
|
22
|
+
import { generatePageNameByApp } from '@editor/utils';
|
|
23
23
|
|
|
24
24
|
const services = inject<Services>('services');
|
|
25
25
|
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
right-class="m-editor-framework-right"
|
|
19
19
|
v-model:left="columnWidth.left"
|
|
20
20
|
v-model:right="columnWidth.right"
|
|
21
|
-
:min-left="
|
|
22
|
-
:min-right="
|
|
21
|
+
:min-left="65"
|
|
22
|
+
:min-right="20"
|
|
23
23
|
@change="columnWidthChange"
|
|
24
24
|
>
|
|
25
25
|
<template #left>
|
|
@@ -47,8 +47,8 @@ import { computed, inject, ref, watch } from 'vue';
|
|
|
47
47
|
|
|
48
48
|
import { TMagicScrollbar } from '@tmagic/design';
|
|
49
49
|
|
|
50
|
-
import Layout from '
|
|
51
|
-
import { GetColumnWidth, Services } from '
|
|
50
|
+
import Layout from '@editor/components/Layout.vue';
|
|
51
|
+
import type { GetColumnWidth, Services } from '@editor/type';
|
|
52
52
|
|
|
53
53
|
import AddPageBox from './AddPageBox.vue';
|
|
54
54
|
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -12,8 +12,8 @@ import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, Z
|
|
|
12
12
|
|
|
13
13
|
import { NodeType } from '@tmagic/schema';
|
|
14
14
|
|
|
15
|
-
import ToolButton from '
|
|
16
|
-
import { ColumnLayout, MenuBarData, MenuButton, MenuComponent, MenuItem, Services } from '
|
|
15
|
+
import ToolButton from '@editor/components/ToolButton.vue';
|
|
16
|
+
import { ColumnLayout, MenuBarData, MenuButton, MenuComponent, MenuItem, Services } from '@editor/type';
|
|
17
17
|
|
|
18
18
|
const props = withDefaults(
|
|
19
19
|
defineProps<{
|
|
@@ -20,7 +20,7 @@ import { tMagicMessage } from '@tmagic/design';
|
|
|
20
20
|
import type { FormValue } from '@tmagic/form';
|
|
21
21
|
import { MForm } from '@tmagic/form';
|
|
22
22
|
|
|
23
|
-
import type { Services } from '
|
|
23
|
+
import type { Services } from '@editor/type';
|
|
24
24
|
|
|
25
25
|
const emit = defineEmits(['mounted']);
|
|
26
26
|
|
|
@@ -39,9 +39,9 @@ import serialize from 'serialize-javascript';
|
|
|
39
39
|
import { TMagicCollapse, TMagicCollapseItem, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
|
|
40
40
|
import { removeClassNameByClassName } from '@tmagic/utils';
|
|
41
41
|
|
|
42
|
-
import MIcon from '
|
|
43
|
-
import SearchInput from '
|
|
44
|
-
import type { ComponentGroup, ComponentItem, Services, StageOptions } from '
|
|
42
|
+
import MIcon from '@editor/components/Icon.vue';
|
|
43
|
+
import SearchInput from '@editor/components/SearchInput.vue';
|
|
44
|
+
import type { ComponentGroup, ComponentItem, Services, StageOptions } from '@editor/type';
|
|
45
45
|
|
|
46
46
|
const searchText = ref('');
|
|
47
47
|
|
|
@@ -8,8 +8,8 @@ import { CopyDocument, Delete, Files, Plus } from '@element-plus/icons-vue';
|
|
|
8
8
|
|
|
9
9
|
import { NodeType } from '@tmagic/schema';
|
|
10
10
|
|
|
11
|
-
import ContentMenu from '
|
|
12
|
-
import type { ComponentGroup, MenuButton, MenuComponent, Services } from '
|
|
11
|
+
import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
12
|
+
import type { ComponentGroup, MenuButton, MenuComponent, Services } from '@editor/type';
|
|
13
13
|
|
|
14
14
|
const props = defineProps<{
|
|
15
15
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
@@ -58,9 +58,9 @@ import type { Id, MNode, MPage } from '@tmagic/schema';
|
|
|
58
58
|
import { MContainer, NodeType } from '@tmagic/schema';
|
|
59
59
|
import { getNodePath, isPage } from '@tmagic/utils';
|
|
60
60
|
|
|
61
|
-
import SearchInput from '
|
|
62
|
-
import type { MenuButton, MenuComponent, Services } from '
|
|
63
|
-
import { Layout } from '
|
|
61
|
+
import SearchInput from '@editor/components/SearchInput.vue';
|
|
62
|
+
import type { MenuButton, MenuComponent, Services } from '@editor/type';
|
|
63
|
+
import { Layout } from '@editor/type';
|
|
64
64
|
|
|
65
65
|
import LayerMenu from './LayerMenu.vue';
|
|
66
66
|
|
|
@@ -138,7 +138,7 @@ const allowDrop = (draggingNode: any, dropNode: any, type: string): boolean => {
|
|
|
138
138
|
|
|
139
139
|
if (ingType !== NodeType.PAGE && data.type === NodeType.PAGE) return false;
|
|
140
140
|
if (ingType === NodeType.PAGE && data.type !== NodeType.PAGE) return false;
|
|
141
|
-
if (!data
|
|
141
|
+
if (!data?.type) return false;
|
|
142
142
|
if (['prev', 'next'].includes(type)) return true;
|
|
143
143
|
if (data.items || data.type === 'container') return true;
|
|
144
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';
|