@tmagic/editor 1.5.20 → 1.5.22
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 +14 -2
- package/dist/tmagic-editor.js +1746 -2415
- package/dist/tmagic-editor.umd.cjs +1744 -2413
- package/package.json +12 -12
- package/src/Editor.vue +17 -1
- package/src/components/CodeBlockEditor.vue +3 -3
- package/src/editorProps.ts +6 -0
- package/src/fields/DataSourceFieldSelect/Index.vue +8 -3
- package/src/fields/DataSourceInput.vue +12 -3
- package/src/fields/EventSelect.vue +37 -22
- package/src/fields/StyleSetter/pro/Position.vue +10 -2
- package/src/index.ts +3 -0
- package/src/initService.ts +16 -0
- package/src/layouts/CodeEditor.vue +36 -10
- package/src/layouts/sidebar/Sidebar.vue +14 -2
- package/src/layouts/workspace/viewer/Stage.vue +17 -3
- package/src/services/events.ts +2 -2
- package/src/services/props.ts +25 -1
- package/src/theme/code-editor.scss +7 -2
- package/src/theme/props-panel.scss +10 -0
- package/src/type.ts +16 -0
- package/src/utils/props.ts +39 -18
- package/types/index.d.ts +367 -349
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.22",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -50,24 +50,24 @@
|
|
|
50
50
|
"buffer": "^6.0.3",
|
|
51
51
|
"color": "^3.1.3",
|
|
52
52
|
"deep-object-diff": "^1.1.9",
|
|
53
|
-
"emmet-monaco-es": "^5.
|
|
53
|
+
"emmet-monaco-es": "^5.5.0",
|
|
54
54
|
"events": "^3.3.0",
|
|
55
|
-
"gesto": "^1.19.
|
|
55
|
+
"gesto": "^1.19.4",
|
|
56
56
|
"keycon": "^1.4.0",
|
|
57
57
|
"lodash-es": "^4.17.21",
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
|
-
"serialize-javascript": "^6.0.
|
|
60
|
-
"sortablejs": "^1.15.
|
|
61
|
-
"@tmagic/design": "1.5.
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/
|
|
59
|
+
"serialize-javascript": "^6.0.2",
|
|
60
|
+
"sortablejs": "^1.15.6",
|
|
61
|
+
"@tmagic/design": "1.5.22",
|
|
62
|
+
"@tmagic/form": "1.5.22",
|
|
63
|
+
"@tmagic/table": "1.5.22",
|
|
64
|
+
"@tmagic/utils": "1.5.22",
|
|
65
|
+
"@tmagic/stage": "1.5.22"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.0",
|
|
69
69
|
"@types/lodash-es": "^4.17.4",
|
|
70
|
-
"@types/serialize-javascript": "^5.0.
|
|
70
|
+
"@types/serialize-javascript": "^5.0.4",
|
|
71
71
|
"@types/sortablejs": "^1.15.8",
|
|
72
72
|
"@vue/test-utils": "^2.4.6",
|
|
73
73
|
"type-fest": "^4.10.3"
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"monaco-editor": "^0.48.0",
|
|
77
77
|
"typescript": "*",
|
|
78
78
|
"vue": ">=3.5.0",
|
|
79
|
-
"@tmagic/core": "1.5.
|
|
79
|
+
"@tmagic/core": "1.5.22"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
package/src/Editor.vue
CHANGED
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
<script lang="ts" setup>
|
|
129
129
|
import { EventEmitter } from 'events';
|
|
130
130
|
|
|
131
|
-
import { provide } from 'vue';
|
|
131
|
+
import { provide, watch } from 'vue';
|
|
132
132
|
|
|
133
133
|
import type { MApp } from '@tmagic/core';
|
|
134
134
|
|
|
@@ -209,6 +209,22 @@ const stageOptions: StageOptions = {
|
|
|
209
209
|
|
|
210
210
|
stageOverlayService.set('stageOptions', stageOptions);
|
|
211
211
|
|
|
212
|
+
watch(
|
|
213
|
+
() => props.runtimeUrl,
|
|
214
|
+
(url) => {
|
|
215
|
+
if (!url) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const stage = editorService.get('stage');
|
|
220
|
+
if (!stage) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
stage.reloadIframe(url);
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
|
|
212
228
|
provide('services', services);
|
|
213
229
|
|
|
214
230
|
provide('codeOptions', props.codeOptions);
|
|
@@ -32,20 +32,20 @@
|
|
|
32
32
|
</FloatingBox>
|
|
33
33
|
|
|
34
34
|
<Teleport to="body">
|
|
35
|
-
<TMagicDialog title="查看修改" v-model="difVisible" fullscreen>
|
|
35
|
+
<TMagicDialog title="查看修改" v-model="difVisible" fullscreen destroy-on-close>
|
|
36
36
|
<div style="display: flex; margin-bottom: 10px">
|
|
37
37
|
<div style="flex: 1"><TMagicTag size="small" type="info">修改前</TMagicTag></div>
|
|
38
38
|
<div style="flex: 1"><TMagicTag size="small" type="success">修改后</TMagicTag></div>
|
|
39
39
|
</div>
|
|
40
40
|
|
|
41
41
|
<CodeEditor
|
|
42
|
-
v-if="difVisible"
|
|
43
42
|
ref="magicVsEditor"
|
|
44
43
|
type="diff"
|
|
45
44
|
language="json"
|
|
45
|
+
:disabled-full-screen="true"
|
|
46
46
|
:initValues="content.content"
|
|
47
47
|
:modifiedValues="formBox?.form?.values.content"
|
|
48
|
-
:
|
|
48
|
+
:height="`${windowRect.height - 150}px`"
|
|
49
49
|
></CodeEditor>
|
|
50
50
|
|
|
51
51
|
<template #footer>
|
package/src/editorProps.ts
CHANGED
|
@@ -81,6 +81,10 @@ export interface EditorProps {
|
|
|
81
81
|
disabledStageOverlay?: boolean;
|
|
82
82
|
/** 禁用属性配置面板右下角显示源码的按钮 */
|
|
83
83
|
disabledShowSrc?: boolean;
|
|
84
|
+
/** 禁用数据源 */
|
|
85
|
+
disabledDataSource?: boolean;
|
|
86
|
+
/** 禁用代码块 */
|
|
87
|
+
disabledCodeBlock?: boolean;
|
|
84
88
|
/** 已选组件、代码编辑、数据源缩进配置 */
|
|
85
89
|
treeIndent?: number;
|
|
86
90
|
/** 已选组件、代码编辑、数据源子节点缩进增量配置 */
|
|
@@ -111,6 +115,8 @@ export const defaultEditorProps = {
|
|
|
111
115
|
containerHighlightDuration: 800,
|
|
112
116
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
|
113
117
|
disabledShowSrc: false,
|
|
118
|
+
disabledDataSource: false,
|
|
119
|
+
disabledCodeBlock: false,
|
|
114
120
|
componentGroupList: () => [],
|
|
115
121
|
datasourceList: () => [],
|
|
116
122
|
menu: () => ({ left: [], right: [] }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-fields-data-source-field-select">
|
|
3
3
|
<FieldSelect
|
|
4
|
-
v-if="showDataSourceFieldSelect || !config.fieldConfig"
|
|
4
|
+
v-if="!disabledDataSource && (showDataSourceFieldSelect || !config.fieldConfig)"
|
|
5
5
|
:model-value="model[name]"
|
|
6
6
|
:disabled="disabled"
|
|
7
7
|
:size="size"
|
|
@@ -26,7 +26,11 @@
|
|
|
26
26
|
@change="onChangeHandler"
|
|
27
27
|
></component>
|
|
28
28
|
|
|
29
|
-
<TMagicTooltip
|
|
29
|
+
<TMagicTooltip
|
|
30
|
+
v-if="config.fieldConfig && !disabledDataSource"
|
|
31
|
+
:disabled="showDataSourceFieldSelect"
|
|
32
|
+
content="选择数据源"
|
|
33
|
+
>
|
|
30
34
|
<TMagicButton
|
|
31
35
|
style="margin-left: 5px"
|
|
32
36
|
:type="showDataSourceFieldSelect ? 'primary' : 'default'"
|
|
@@ -83,10 +87,11 @@ watch(
|
|
|
83
87
|
},
|
|
84
88
|
);
|
|
85
89
|
|
|
86
|
-
const { dataSourceService } = useServices();
|
|
90
|
+
const { dataSourceService, propsService } = useServices();
|
|
87
91
|
const mForm = inject<FormState | undefined>('mForm');
|
|
88
92
|
|
|
89
93
|
const dataSources = computed(() => dataSourceService.get('dataSources') || []);
|
|
94
|
+
const disabledDataSource = computed(() => propsService.getDisabledDataSource());
|
|
90
95
|
|
|
91
96
|
const type = computed((): string => {
|
|
92
97
|
let type = props.config.fieldConfig?.type;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<TMagicInput
|
|
3
|
+
v-if="disabledDataSource"
|
|
4
|
+
v-model="state"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
:size="size"
|
|
7
|
+
:clearable="true"
|
|
8
|
+
@change="changeHandler"
|
|
9
|
+
></TMagicInput>
|
|
2
10
|
<component
|
|
3
|
-
v-if="disabled || isFocused"
|
|
11
|
+
v-else-if="disabled || isFocused"
|
|
4
12
|
:is="getDesignConfig('components')?.autocomplete.component || 'el-autocomplete'"
|
|
5
13
|
class="tmagic-design-auto-complete"
|
|
6
14
|
ref="autocomplete"
|
|
@@ -52,7 +60,7 @@ import { computed, nextTick, ref, useTemplateRef, watch } from 'vue';
|
|
|
52
60
|
import { Coin } from '@element-plus/icons-vue';
|
|
53
61
|
|
|
54
62
|
import type { DataSchema, DataSourceSchema } from '@tmagic/core';
|
|
55
|
-
import { getDesignConfig, TMagicAutocomplete, TMagicTag } from '@tmagic/design';
|
|
63
|
+
import { getDesignConfig, TMagicAutocomplete, TMagicInput, TMagicTag } from '@tmagic/design';
|
|
56
64
|
import type { DataSourceInputConfig, FieldProps } from '@tmagic/form';
|
|
57
65
|
import { getKeysArray, isNumber } from '@tmagic/utils';
|
|
58
66
|
|
|
@@ -72,7 +80,7 @@ const emit = defineEmits<{
|
|
|
72
80
|
change: [value: string];
|
|
73
81
|
}>();
|
|
74
82
|
|
|
75
|
-
const { dataSourceService } = useServices();
|
|
83
|
+
const { dataSourceService, propsService } = useServices();
|
|
76
84
|
|
|
77
85
|
const autocompleteRef = useTemplateRef<InstanceType<typeof TMagicAutocomplete>>('autocomplete');
|
|
78
86
|
const isFocused = ref(false);
|
|
@@ -81,6 +89,7 @@ const displayState = ref<{ value: string; type: 'var' | 'text' }[]>([]);
|
|
|
81
89
|
|
|
82
90
|
const input = computed<HTMLInputElement>(() => autocompleteRef.value?.inputRef?.input);
|
|
83
91
|
const dataSources = computed(() => dataSourceService.get('dataSources'));
|
|
92
|
+
const disabledDataSource = computed(() => propsService.getDisabledDataSource());
|
|
84
93
|
|
|
85
94
|
const setDisplayState = () => {
|
|
86
95
|
displayState.value = getDisplayField(dataSources.value, state.value);
|
|
@@ -85,7 +85,7 @@ const emit = defineEmits<{
|
|
|
85
85
|
change: [v: any, eventData?: ContainerChangeEventData];
|
|
86
86
|
}>();
|
|
87
87
|
|
|
88
|
-
const { editorService, dataSourceService, eventsService, codeBlockService } = useServices();
|
|
88
|
+
const { editorService, dataSourceService, eventsService, codeBlockService, propsService } = useServices();
|
|
89
89
|
|
|
90
90
|
// 事件名称下拉框表单配置
|
|
91
91
|
const eventNameConfig = computed(() => {
|
|
@@ -173,24 +173,39 @@ const actionTypeConfig = computed(() => {
|
|
|
173
173
|
text: '联动类型',
|
|
174
174
|
type: 'select',
|
|
175
175
|
defaultValue: ActionType.COMP,
|
|
176
|
-
options: () =>
|
|
177
|
-
{
|
|
178
|
-
text:
|
|
179
|
-
label:
|
|
180
|
-
value:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
options: () => {
|
|
177
|
+
const o: {
|
|
178
|
+
text: string;
|
|
179
|
+
label: string;
|
|
180
|
+
value: string;
|
|
181
|
+
disabled?: boolean;
|
|
182
|
+
}[] = [
|
|
183
|
+
{
|
|
184
|
+
text: '组件',
|
|
185
|
+
label: '组件',
|
|
186
|
+
value: ActionType.COMP,
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
if (!propsService.getDisabledCodeBlock()) {
|
|
191
|
+
o.push({
|
|
192
|
+
text: '代码',
|
|
193
|
+
label: '代码',
|
|
194
|
+
disabled: !Object.keys(codeBlockService.getCodeDsl() || {}).length,
|
|
195
|
+
value: ActionType.CODE,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (!propsService.getDisabledDataSource()) {
|
|
200
|
+
o.push({
|
|
201
|
+
text: '数据源',
|
|
202
|
+
label: '数据源',
|
|
203
|
+
value: ActionType.DATA_SOURCE,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return o;
|
|
208
|
+
},
|
|
194
209
|
};
|
|
195
210
|
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
|
196
211
|
});
|
|
@@ -232,7 +247,7 @@ const compActionConfig = computed(() => {
|
|
|
232
247
|
|
|
233
248
|
let methods: EventOption[] | CascaderOption[] = [];
|
|
234
249
|
|
|
235
|
-
methods = eventsService.getMethod(node.type);
|
|
250
|
+
methods = eventsService.getMethod(node.type, model.to);
|
|
236
251
|
|
|
237
252
|
if (node.type === 'page-fragment-container' && node.pageFragmentId) {
|
|
238
253
|
const pageFragment = editorService.get('root')?.items?.find((page) => page.id === node.pageFragmentId);
|
|
@@ -240,7 +255,7 @@ const compActionConfig = computed(() => {
|
|
|
240
255
|
methods = [];
|
|
241
256
|
pageFragment.items.forEach((node: MComponent | MContainer) => {
|
|
242
257
|
traverseNode<MComponent | MContainer>(node, (node) => {
|
|
243
|
-
const nodeMethods = (node.type && eventsService.getMethod(node.type)) || [];
|
|
258
|
+
const nodeMethods = (node.type && eventsService.getMethod(node.type, node.id)) || [];
|
|
244
259
|
|
|
245
260
|
if (nodeMethods.length) {
|
|
246
261
|
methods.push({
|
|
@@ -317,7 +332,7 @@ const tableConfig = computed(() => ({
|
|
|
317
332
|
const node = editorService.getNodeById(model.to);
|
|
318
333
|
if (!node?.type) return [];
|
|
319
334
|
|
|
320
|
-
return eventsService.getMethod(node.type).map((option: any) => ({
|
|
335
|
+
return eventsService.getMethod(node.type, model.to).map((option: any) => ({
|
|
321
336
|
text: option.label,
|
|
322
337
|
value: option.value,
|
|
323
338
|
}));
|
|
@@ -12,6 +12,14 @@ const emit = defineEmits<{
|
|
|
12
12
|
change: [v: string | StyleSchema, eventData: ContainerChangeEventData];
|
|
13
13
|
}>();
|
|
14
14
|
|
|
15
|
+
const positionText: Record<string, string> = {
|
|
16
|
+
static: '不定位',
|
|
17
|
+
relative: '相对定位',
|
|
18
|
+
absolute: '绝对定位',
|
|
19
|
+
fixed: '固定定位',
|
|
20
|
+
sticky: '粘性定位',
|
|
21
|
+
};
|
|
22
|
+
|
|
15
23
|
const config = {
|
|
16
24
|
items: [
|
|
17
25
|
{
|
|
@@ -21,9 +29,9 @@ const config = {
|
|
|
21
29
|
type: 'data-source-field-select',
|
|
22
30
|
fieldConfig: {
|
|
23
31
|
type: 'select',
|
|
24
|
-
options:
|
|
32
|
+
options: Object.keys(positionText).map((item) => ({
|
|
25
33
|
value: item,
|
|
26
|
-
text: item
|
|
34
|
+
text: `${item}(${positionText[item]})`,
|
|
27
35
|
})),
|
|
28
36
|
},
|
|
29
37
|
},
|
package/src/index.ts
CHANGED
|
@@ -112,6 +112,9 @@ export { default as StyleSetter } from './fields/StyleSetter/Index.vue';
|
|
|
112
112
|
const defaultInstallOpt: EditorInstallOptions = {
|
|
113
113
|
// eslint-disable-next-line no-eval
|
|
114
114
|
parseDSL: (dsl: string) => eval(dsl),
|
|
115
|
+
customCreateMonacoEditor: (monaco, codeEditorEl, options) => monaco.editor.create(codeEditorEl, options),
|
|
116
|
+
customCreateMonacoDiffEditor: (monaco, codeEditorEl, options) =>
|
|
117
|
+
monaco.editor.createDiffEditor(codeEditorEl, options),
|
|
115
118
|
};
|
|
116
119
|
|
|
117
120
|
export default {
|
package/src/initService.ts
CHANGED
|
@@ -197,6 +197,22 @@ export const initServiceState = (
|
|
|
197
197
|
},
|
|
198
198
|
);
|
|
199
199
|
|
|
200
|
+
watch(
|
|
201
|
+
() => props.disabledCodeBlock,
|
|
202
|
+
(disabledCodeBlock) => propsService.setDisabledCodeBlock(disabledCodeBlock ?? false),
|
|
203
|
+
{
|
|
204
|
+
immediate: true,
|
|
205
|
+
},
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
watch(
|
|
209
|
+
() => props.disabledDataSource,
|
|
210
|
+
(disabledDataSource) => propsService.setDisabledDataSource(disabledDataSource ?? false),
|
|
211
|
+
{
|
|
212
|
+
immediate: true,
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
|
|
200
216
|
onBeforeUnmount(() => {
|
|
201
217
|
editorService.resetState();
|
|
202
218
|
historyService.resetState();
|
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
:class="`magic-code-editor-wrapper${fullScreen ? ' full-screen' : ''}`"
|
|
6
6
|
:style="!fullScreen && height ? `height: ${height}` : '100%'"
|
|
7
7
|
>
|
|
8
|
-
<TMagicButton
|
|
8
|
+
<TMagicButton
|
|
9
|
+
v-if="!disabledFullScreen"
|
|
10
|
+
class="magic-code-editor-full-screen-icon"
|
|
11
|
+
circle
|
|
12
|
+
size="small"
|
|
13
|
+
@click="fullScreenHandler"
|
|
9
14
|
><MIcon :icon="FullScreen"></MIcon
|
|
10
15
|
></TMagicButton>
|
|
11
16
|
<div ref="codeEditor" class="magic-code-editor-content"></div>
|
|
@@ -15,7 +20,7 @@
|
|
|
15
20
|
</template>
|
|
16
21
|
|
|
17
22
|
<script lang="ts" setup>
|
|
18
|
-
import { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
|
|
23
|
+
import { nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue';
|
|
19
24
|
import { FullScreen } from '@element-plus/icons-vue';
|
|
20
25
|
import { throttle } from 'lodash-es';
|
|
21
26
|
import serialize from 'serialize-javascript';
|
|
@@ -36,12 +41,11 @@ const props = withDefaults(
|
|
|
36
41
|
modifiedValues?: any;
|
|
37
42
|
type?: 'diff';
|
|
38
43
|
language?: string;
|
|
39
|
-
options?:
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
};
|
|
44
|
+
options?: monaco.editor.IStandaloneEditorConstructionOptions;
|
|
42
45
|
height?: string;
|
|
43
46
|
autoSave?: boolean;
|
|
44
47
|
parse?: boolean;
|
|
48
|
+
disabledFullScreen?: boolean;
|
|
45
49
|
}>(),
|
|
46
50
|
{
|
|
47
51
|
initValues: '',
|
|
@@ -51,6 +55,7 @@ const props = withDefaults(
|
|
|
51
55
|
tabSize: 2,
|
|
52
56
|
}),
|
|
53
57
|
parse: false,
|
|
58
|
+
disabledFullScreen: false,
|
|
54
59
|
},
|
|
55
60
|
);
|
|
56
61
|
|
|
@@ -124,6 +129,10 @@ const getEditorValue = () =>
|
|
|
124
129
|
const init = async () => {
|
|
125
130
|
if (!codeEditorEl.value) return;
|
|
126
131
|
|
|
132
|
+
if (codeEditorEl.value.clientHeight === 0) {
|
|
133
|
+
await nextTick();
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
const options = {
|
|
128
137
|
value: values.value,
|
|
129
138
|
language: props.language,
|
|
@@ -132,15 +141,13 @@ const init = async () => {
|
|
|
132
141
|
};
|
|
133
142
|
|
|
134
143
|
if (props.type === 'diff') {
|
|
135
|
-
vsDiffEditor = monaco
|
|
144
|
+
vsDiffEditor = getEditorConfig('customCreateMonacoDiffEditor')(monaco, codeEditorEl.value, options);
|
|
136
145
|
} else {
|
|
137
|
-
vsEditor = monaco
|
|
146
|
+
vsEditor = getEditorConfig('customCreateMonacoEditor')(monaco, codeEditorEl.value, options);
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
setEditorValue(props.initValues, props.modifiedValues);
|
|
141
150
|
|
|
142
|
-
loading.value = false;
|
|
143
|
-
|
|
144
151
|
emit('initd', vsEditor);
|
|
145
152
|
|
|
146
153
|
codeEditorEl.value.addEventListener('keydown', (e) => {
|
|
@@ -179,14 +186,33 @@ watch(
|
|
|
179
186
|
},
|
|
180
187
|
);
|
|
181
188
|
|
|
189
|
+
watch(
|
|
190
|
+
() => props.options,
|
|
191
|
+
(v) => {
|
|
192
|
+
vsEditor?.updateOptions(v);
|
|
193
|
+
vsDiffEditor?.updateOptions(v);
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
deep: true,
|
|
197
|
+
},
|
|
198
|
+
);
|
|
199
|
+
|
|
182
200
|
onMounted(async () => {
|
|
183
201
|
loading.value = true;
|
|
184
202
|
|
|
185
|
-
init();
|
|
203
|
+
await init();
|
|
204
|
+
|
|
205
|
+
loading.value = false;
|
|
186
206
|
});
|
|
187
207
|
|
|
188
208
|
onBeforeUnmount(() => {
|
|
189
209
|
resizeObserver.disconnect();
|
|
210
|
+
|
|
211
|
+
vsEditor?.dispose();
|
|
212
|
+
vsDiffEditor?.dispose();
|
|
213
|
+
|
|
214
|
+
vsEditor = null;
|
|
215
|
+
vsDiffEditor = null;
|
|
190
216
|
});
|
|
191
217
|
|
|
192
218
|
const fullScreen = ref(false);
|
|
@@ -201,7 +201,7 @@ const props = withDefaults(
|
|
|
201
201
|
},
|
|
202
202
|
);
|
|
203
203
|
|
|
204
|
-
const { depService, uiService } = useServices();
|
|
204
|
+
const { depService, uiService, propsService } = useServices();
|
|
205
205
|
|
|
206
206
|
const collecting = computed(() => depService.get('collecting'));
|
|
207
207
|
const taskLength = computed(() => depService.get('taskLength'));
|
|
@@ -283,7 +283,19 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
283
283
|
return typeof data === 'string' ? map[data] : data;
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
const sideBarItems = computed(() =>
|
|
286
|
+
const sideBarItems = computed(() =>
|
|
287
|
+
props.data.items
|
|
288
|
+
.map((item) => getItemConfig(item))
|
|
289
|
+
.filter((item) => {
|
|
290
|
+
if (item.$key === SideItemKey.DATA_SOURCE) {
|
|
291
|
+
return !propsService.getDisabledDataSource();
|
|
292
|
+
}
|
|
293
|
+
if (item.$key === SideItemKey.CODE_BLOCK) {
|
|
294
|
+
return !propsService.getDisabledCodeBlock();
|
|
295
|
+
}
|
|
296
|
+
return true;
|
|
297
|
+
}),
|
|
298
|
+
);
|
|
287
299
|
|
|
288
300
|
watch(
|
|
289
301
|
sideBarItems,
|
|
@@ -164,9 +164,23 @@ watch(page, (page) => {
|
|
|
164
164
|
}, 3000);
|
|
165
165
|
|
|
166
166
|
runtime.updatePageId?.(page.id);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
|
|
168
|
+
const unWatch = watch(
|
|
169
|
+
stageLoading,
|
|
170
|
+
() => {
|
|
171
|
+
if (stageLoading.value) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
nextTick(() => {
|
|
176
|
+
stage?.select(page.id);
|
|
177
|
+
unWatch();
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
immediate: true,
|
|
182
|
+
},
|
|
183
|
+
);
|
|
170
184
|
}
|
|
171
185
|
});
|
|
172
186
|
|
package/src/services/events.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { reactive } from 'vue';
|
|
|
20
20
|
import { cloneDeep } from 'lodash-es';
|
|
21
21
|
import type { Writable } from 'type-fest';
|
|
22
22
|
|
|
23
|
-
import { type EventOption } from '@tmagic/core';
|
|
23
|
+
import { type EventOption, type Id } from '@tmagic/core';
|
|
24
24
|
import { toLine } from '@tmagic/utils';
|
|
25
25
|
|
|
26
26
|
import type { AsyncHookPlugin, SyncHookPlugin } from '@editor/type';
|
|
@@ -70,7 +70,7 @@ class Events extends BaseService {
|
|
|
70
70
|
methodMap[toLine(type)] = [...method];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
public getMethod(type: string) {
|
|
73
|
+
public getMethod(type: string, _targetId: Id) {
|
|
74
74
|
return cloneDeep(methodMap[toLine(type)]) || [];
|
|
75
75
|
}
|
|
76
76
|
|
package/src/services/props.ts
CHANGED
|
@@ -57,6 +57,10 @@ class Props extends BaseService {
|
|
|
57
57
|
propsConfigMap: {},
|
|
58
58
|
propsValueMap: {},
|
|
59
59
|
relateIdMap: {},
|
|
60
|
+
/** 禁用数据源 */
|
|
61
|
+
disabledDataSource: false,
|
|
62
|
+
/** 禁用代码块 */
|
|
63
|
+
disabledCodeBlock: false,
|
|
60
64
|
});
|
|
61
65
|
|
|
62
66
|
constructor() {
|
|
@@ -66,6 +70,22 @@ class Props extends BaseService {
|
|
|
66
70
|
]);
|
|
67
71
|
}
|
|
68
72
|
|
|
73
|
+
public setDisabledDataSource(disabled: boolean) {
|
|
74
|
+
this.state.disabledDataSource = disabled;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public setDisabledCodeBlock(disabled: boolean) {
|
|
78
|
+
this.state.disabledCodeBlock = disabled;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public getDisabledDataSource(): boolean {
|
|
82
|
+
return this.state.disabledDataSource;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public getDisabledCodeBlock(): boolean {
|
|
86
|
+
return this.state.disabledCodeBlock;
|
|
87
|
+
}
|
|
88
|
+
|
|
69
89
|
public setPropsConfigs(configs: Record<string, FormConfig | PropsFormConfigFunction>) {
|
|
70
90
|
Object.keys(configs).forEach((type: string) => {
|
|
71
91
|
this.setPropsConfig(toLine(type), configs[type]);
|
|
@@ -74,7 +94,11 @@ class Props extends BaseService {
|
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
public async fillConfig(config: FormConfig, labelWidth?: string) {
|
|
77
|
-
return fillConfig(config,
|
|
97
|
+
return fillConfig(config, {
|
|
98
|
+
labelWidth: typeof labelWidth !== 'function' ? labelWidth : '80px',
|
|
99
|
+
disabledDataSource: this.getDisabledDataSource(),
|
|
100
|
+
disabledCodeBlock: this.getDisabledCodeBlock(),
|
|
101
|
+
});
|
|
78
102
|
}
|
|
79
103
|
|
|
80
104
|
public async setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction) {
|
|
@@ -84,6 +84,11 @@
|
|
|
84
84
|
right: 15px;
|
|
85
85
|
bottom: 15px;
|
|
86
86
|
z-index: 30;
|
|
87
|
+
opacity: 0.5;
|
|
88
|
+
|
|
89
|
+
&:hover {
|
|
90
|
+
opacity: 1;
|
|
91
|
+
}
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
.m-editor-props-panel-style-icon {
|
|
@@ -91,6 +96,11 @@
|
|
|
91
96
|
right: 15px;
|
|
92
97
|
bottom: 60px;
|
|
93
98
|
z-index: 30;
|
|
99
|
+
opacity: 0.5;
|
|
100
|
+
|
|
101
|
+
&:hover {
|
|
102
|
+
opacity: 1;
|
|
103
|
+
}
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
.m-editor-props-panel-src-code.magic-code-editor {
|
package/src/type.ts
CHANGED
|
@@ -33,6 +33,8 @@ import type {
|
|
|
33
33
|
UpdateDragEl,
|
|
34
34
|
} from '@tmagic/stage';
|
|
35
35
|
|
|
36
|
+
import Monaco from '@editor/utils/monaco-editor';
|
|
37
|
+
|
|
36
38
|
import type { CodeBlockService } from './services/codeBlock';
|
|
37
39
|
import type { ComponentListService } from './services/componentList';
|
|
38
40
|
import type { DataSourceService } from './services/dataSource';
|
|
@@ -119,6 +121,16 @@ export type GetConfig = (config: FormConfig) => Promise<FormConfig> | FormConfig
|
|
|
119
121
|
|
|
120
122
|
export interface EditorInstallOptions {
|
|
121
123
|
parseDSL: <T = any>(dsl: string) => T;
|
|
124
|
+
customCreateMonacoEditor: (
|
|
125
|
+
monaco: typeof Monaco,
|
|
126
|
+
codeEditorEl: HTMLElement,
|
|
127
|
+
options: Monaco.editor.IStandaloneEditorConstructionOptions,
|
|
128
|
+
) => Monaco.editor.IStandaloneCodeEditor;
|
|
129
|
+
customCreateMonacoDiffEditor: (
|
|
130
|
+
monaco: typeof Monaco,
|
|
131
|
+
codeEditorEl: HTMLElement,
|
|
132
|
+
options: Monaco.editor.IStandaloneEditorConstructionOptions,
|
|
133
|
+
) => Monaco.editor.IStandaloneDiffEditor;
|
|
122
134
|
[key: string]: any;
|
|
123
135
|
}
|
|
124
136
|
|
|
@@ -176,6 +188,10 @@ export interface PropsState {
|
|
|
176
188
|
propsConfigMap: Record<string, FormConfig>;
|
|
177
189
|
propsValueMap: Record<string, Partial<MNode>>;
|
|
178
190
|
relateIdMap: Record<Id, Id>;
|
|
191
|
+
/** 禁用数据源 */
|
|
192
|
+
disabledDataSource: boolean;
|
|
193
|
+
/** 禁用代码块 */
|
|
194
|
+
disabledCodeBlock: boolean;
|
|
179
195
|
}
|
|
180
196
|
|
|
181
197
|
export interface StageOverlayState {
|