@tmagic/editor 1.5.0-beta.0 → 1.5.0-beta.10
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 +285 -8
- package/dist/tmagic-editor.js +396 -332
- package/dist/tmagic-editor.umd.cjs +628 -533
- package/package.json +13 -14
- package/src/Editor.vue +18 -4
- package/src/components/CodeBlockEditor.vue +5 -5
- package/src/components/SearchInput.vue +1 -0
- package/src/components/Tree.vue +10 -2
- package/src/components/TreeNode.vue +4 -2
- package/src/editorProps.ts +6 -3
- package/src/fields/CodeLink.vue +2 -2
- package/src/fields/CodeSelect.vue +1 -1
- package/src/fields/CodeSelectCol.vue +1 -1
- package/src/fields/CondOpSelect.vue +1 -1
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +2 -8
- package/src/fields/DataSourceFieldSelect/Index.vue +2 -2
- package/src/fields/DataSourceFields.vue +1 -1
- package/src/fields/DataSourceInput.vue +4 -4
- package/src/fields/DataSourceMethodSelect.vue +1 -1
- package/src/fields/DataSourceMethods.vue +1 -1
- package/src/fields/DataSourceMocks.vue +1 -1
- package/src/fields/DisplayConds.vue +1 -1
- package/src/fields/EventSelect.vue +4 -4
- package/src/fields/PageFragmentSelect.vue +1 -1
- package/src/fields/UISelect.vue +1 -1
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/hooks/use-data-source-edit.ts +1 -1
- package/src/hooks/use-data-source-method.ts +3 -3
- package/src/hooks/use-filter.ts +2 -2
- package/src/hooks/use-node-status.ts +3 -3
- package/src/hooks/use-stage.ts +2 -2
- package/src/index.ts +30 -8
- package/src/initService.ts +17 -10
- package/src/layouts/AddPageBox.vue +1 -1
- package/src/layouts/CodeEditor.vue +5 -5
- package/src/layouts/Framework.vue +2 -2
- package/src/layouts/NavMenu.vue +1 -1
- package/src/layouts/PropsPanel.vue +1 -1
- package/src/layouts/page-bar/AddButton.vue +1 -1
- package/src/layouts/page-bar/PageBar.vue +8 -2
- package/src/layouts/page-bar/PageBarScrollContainer.vue +1 -1
- package/src/layouts/page-bar/PageList.vue +8 -2
- package/src/layouts/page-bar/SwitchTypeButton.vue +1 -1
- package/src/layouts/sidebar/ComponentListPanel.vue +1 -1
- package/src/layouts/sidebar/Sidebar.vue +31 -3
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +11 -3
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +11 -2
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +1 -1
- package/src/layouts/sidebar/data-source/DataSourceList.vue +13 -3
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +30 -15
- package/src/layouts/sidebar/layer/LayerNodeTool.vue +1 -1
- package/src/layouts/sidebar/layer/LayerPanel.vue +5 -1
- package/src/layouts/sidebar/layer/use-click.ts +1 -1
- package/src/layouts/sidebar/layer/use-drag.ts +1 -1
- package/src/layouts/sidebar/layer/use-node-status.ts +3 -4
- package/src/layouts/workspace/Breadcrumb.vue +1 -1
- package/src/layouts/workspace/viewer/NodeListMenu.vue +2 -2
- package/src/layouts/workspace/viewer/Stage.vue +9 -5
- package/src/layouts/workspace/viewer/StageOverlay.vue +9 -4
- package/src/layouts/workspace/viewer/ViewerMenu.vue +1 -1
- package/src/services/codeBlock.ts +7 -7
- package/src/services/dataSource.ts +3 -4
- package/src/services/dep.ts +2 -2
- package/src/services/editor.ts +10 -11
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +3 -3
- package/src/services/stageOverlay.ts +15 -7
- package/src/services/storage.ts +2 -2
- package/src/theme/data-source.scss +8 -5
- package/src/theme/index.scss +3 -0
- package/src/theme/page-bar.scss +2 -1
- package/src/type.ts +14 -11
- package/src/utils/config.ts +5 -5
- package/src/utils/content-menu.ts +3 -3
- package/src/utils/data-source/index.ts +1 -1
- package/src/utils/editor.ts +13 -35
- package/src/utils/operator.ts +2 -1
- package/src/utils/props.ts +1 -1
- package/src/utils/tree.ts +1 -1
- package/types/index.d.ts +1664 -3039
package/src/initService.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { onBeforeUnmount, reactive, toRaw, watch } from 'vue';
|
|
2
|
-
import { cloneDeep } from 'lodash-es';
|
|
3
|
-
|
|
4
|
-
import type {
|
|
2
|
+
import { cloneDeep, debounce } from 'lodash-es';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
CodeBlockContent,
|
|
6
|
+
DataSourceSchema,
|
|
7
|
+
EventOption,
|
|
8
|
+
Id,
|
|
9
|
+
MApp,
|
|
10
|
+
MNode,
|
|
11
|
+
MPage,
|
|
12
|
+
MPageFragment,
|
|
13
|
+
} from '@tmagic/core';
|
|
5
14
|
import {
|
|
6
15
|
createCodeBlockTarget,
|
|
7
16
|
createDataSourceCondTarget,
|
|
@@ -9,14 +18,12 @@ import {
|
|
|
9
18
|
createDataSourceTarget,
|
|
10
19
|
DepTargetType,
|
|
11
20
|
Target,
|
|
12
|
-
} from '@tmagic/
|
|
13
|
-
import
|
|
14
|
-
import { isPage } from '@tmagic/utils';
|
|
21
|
+
} from '@tmagic/core';
|
|
22
|
+
import { isPage, traverseNode } from '@tmagic/utils';
|
|
15
23
|
|
|
16
24
|
import PropsPanel from './layouts/PropsPanel.vue';
|
|
17
25
|
import { EditorProps } from './editorProps';
|
|
18
26
|
import { Services } from './type';
|
|
19
|
-
import { traverseNode } from './utils';
|
|
20
27
|
|
|
21
28
|
export declare type LooseRequired<T> = {
|
|
22
29
|
[P in string & keyof T]: T[P];
|
|
@@ -242,7 +249,7 @@ export const initServiceEvents = (
|
|
|
242
249
|
|
|
243
250
|
const getApp = () => {
|
|
244
251
|
const stage = editorService.get('stage');
|
|
245
|
-
return stage?.renderer
|
|
252
|
+
return stage?.renderer?.runtime?.getApp?.();
|
|
246
253
|
};
|
|
247
254
|
|
|
248
255
|
const updateDataSourceSchema = () => {
|
|
@@ -284,7 +291,7 @@ export const initServiceEvents = (
|
|
|
284
291
|
}
|
|
285
292
|
};
|
|
286
293
|
|
|
287
|
-
const collectedHandler = (nodes: MNode[], deep: boolean) => {
|
|
294
|
+
const collectedHandler = debounce((nodes: MNode[], deep: boolean) => {
|
|
288
295
|
const root = editorService.get('root');
|
|
289
296
|
const stage = editorService.get('stage');
|
|
290
297
|
|
|
@@ -328,7 +335,7 @@ export const initServiceEvents = (
|
|
|
328
335
|
});
|
|
329
336
|
});
|
|
330
337
|
});
|
|
331
|
-
};
|
|
338
|
+
}, 300);
|
|
332
339
|
|
|
333
340
|
depService.on('add-target', targetAddHandler);
|
|
334
341
|
depService.on('remove-target', targetRemoveHandler);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import { inject, toRaw } from 'vue';
|
|
23
23
|
import { Plus } from '@element-plus/icons-vue';
|
|
24
24
|
|
|
25
|
-
import { NodeType } from '@tmagic/
|
|
25
|
+
import { NodeType } from '@tmagic/core';
|
|
26
26
|
|
|
27
27
|
import MIcon from '@editor/components/Icon.vue';
|
|
28
28
|
import type { Services } from '@editor/type';
|
|
@@ -23,7 +23,7 @@ import serialize from 'serialize-javascript';
|
|
|
23
23
|
import { TMagicButton } from '@tmagic/design';
|
|
24
24
|
|
|
25
25
|
import MIcon from '@editor/components/Icon.vue';
|
|
26
|
-
import {
|
|
26
|
+
import { getEditorConfig } from '@editor/utils/config';
|
|
27
27
|
import monaco from '@editor/utils/monaco-editor';
|
|
28
28
|
|
|
29
29
|
defineOptions({
|
|
@@ -76,7 +76,7 @@ const toString = (v: string | any, language: string): string => {
|
|
|
76
76
|
return value;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const
|
|
79
|
+
const parseCode = (v: string | any, language: string): any => {
|
|
80
80
|
if (typeof v !== 'string') {
|
|
81
81
|
return v;
|
|
82
82
|
}
|
|
@@ -85,7 +85,7 @@ const parse = (v: string | any, language: string): any => {
|
|
|
85
85
|
return JSON.parse(v);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
return
|
|
88
|
+
return getEditorConfig('parseDSL')(v);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
let vsEditor: monaco.editor.IStandaloneCodeEditor | null = null;
|
|
@@ -149,7 +149,7 @@ const init = async () => {
|
|
|
149
149
|
e.stopPropagation();
|
|
150
150
|
const newValue = getEditorValue();
|
|
151
151
|
values.value = newValue;
|
|
152
|
-
emit('save', props.parse ?
|
|
152
|
+
emit('save', props.parse ? parseCode(newValue, props.language) : newValue);
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
|
|
@@ -158,7 +158,7 @@ const init = async () => {
|
|
|
158
158
|
const newValue = getEditorValue();
|
|
159
159
|
if (values.value !== newValue) {
|
|
160
160
|
values.value = newValue;
|
|
161
|
-
emit('save', props.parse ?
|
|
161
|
+
emit('save', props.parse ? parseCode(newValue, props.language) : newValue);
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
@@ -65,7 +65,7 @@ import { TMagicScrollbar } from '@tmagic/design';
|
|
|
65
65
|
|
|
66
66
|
import SplitView from '@editor/components/SplitView.vue';
|
|
67
67
|
import type { FrameworkSlots, GetColumnWidth, PageBarSortOptions, Services } from '@editor/type';
|
|
68
|
-
import {
|
|
68
|
+
import { getEditorConfig } from '@editor/utils/config';
|
|
69
69
|
|
|
70
70
|
import PageBar from './page-bar/PageBar.vue';
|
|
71
71
|
import AddPageBox from './AddPageBox.vue';
|
|
@@ -156,7 +156,7 @@ onBeforeUnmount(() => {
|
|
|
156
156
|
|
|
157
157
|
const saveCode = (value: string) => {
|
|
158
158
|
try {
|
|
159
|
-
const parseDSL =
|
|
159
|
+
const parseDSL = getEditorConfig('parseDSL');
|
|
160
160
|
editorService?.set('root', parseDSL(value));
|
|
161
161
|
} catch (e: any) {
|
|
162
162
|
console.error(e);
|
package/src/layouts/NavMenu.vue
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { computed, inject, markRaw, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
11
11
|
import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, ZoomOut } from '@element-plus/icons-vue';
|
|
12
12
|
|
|
13
|
-
import { NodeType } from '@tmagic/
|
|
13
|
+
import { NodeType } from '@tmagic/core';
|
|
14
14
|
|
|
15
15
|
import ToolButton from '@editor/components/ToolButton.vue';
|
|
16
16
|
import { ColumnLayout, MenuBarData, MenuButton, MenuComponent, MenuItem, Services } from '@editor/type';
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, ref, watchEffect } from 'vue';
|
|
42
42
|
import { Document as DocumentIcon } from '@element-plus/icons-vue';
|
|
43
43
|
|
|
44
|
+
import type { MNode } from '@tmagic/core';
|
|
44
45
|
import { TMagicButton } from '@tmagic/design';
|
|
45
46
|
import type { FormState, FormValue } from '@tmagic/form';
|
|
46
47
|
import { MForm } from '@tmagic/form';
|
|
47
|
-
import type { MNode } from '@tmagic/schema';
|
|
48
48
|
|
|
49
49
|
import MIcon from '@editor/components/Icon.vue';
|
|
50
50
|
import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { computed, inject, toRaw } from 'vue';
|
|
15
15
|
import { Plus } from '@element-plus/icons-vue';
|
|
16
16
|
|
|
17
|
-
import { NodeType } from '@tmagic/
|
|
17
|
+
import { NodeType } from '@tmagic/core';
|
|
18
18
|
|
|
19
19
|
import Icon from '@editor/components/Icon.vue';
|
|
20
20
|
import type { Services } from '@editor/type';
|
|
@@ -24,7 +24,13 @@
|
|
|
24
24
|
</slot>
|
|
25
25
|
</div>
|
|
26
26
|
|
|
27
|
-
<TMagicPopover
|
|
27
|
+
<TMagicPopover
|
|
28
|
+
popper-class="page-bar-popover"
|
|
29
|
+
placement="top"
|
|
30
|
+
trigger="hover"
|
|
31
|
+
:width="160"
|
|
32
|
+
:destroy-on-close="true"
|
|
33
|
+
>
|
|
28
34
|
<div>
|
|
29
35
|
<slot name="page-bar-popover" :page="item">
|
|
30
36
|
<ToolButton
|
|
@@ -60,8 +66,8 @@
|
|
|
60
66
|
import { computed, inject, ref, watch } from 'vue';
|
|
61
67
|
import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
62
68
|
|
|
69
|
+
import { type Id, type MPage, type MPageFragment, NodeType } from '@tmagic/core';
|
|
63
70
|
import { TMagicIcon, TMagicPopover } from '@tmagic/design';
|
|
64
|
-
import { Id, type MPage, type MPageFragment, NodeType } from '@tmagic/schema';
|
|
65
71
|
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
66
72
|
|
|
67
73
|
import ToolButton from '@editor/components/ToolButton.vue';
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
|
37
37
|
import Sortable, { SortableEvent } from 'sortablejs';
|
|
38
38
|
|
|
39
|
-
import { Id, NodeType } from '@tmagic/
|
|
39
|
+
import { Id, NodeType } from '@tmagic/core';
|
|
40
40
|
|
|
41
41
|
import Icon from '@editor/components/Icon.vue';
|
|
42
42
|
import type { PageBarSortOptions, Services } from '@editor/type';
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
id="m-editor-page-bar-list-icon"
|
|
5
5
|
class="m-editor-page-bar-item m-editor-page-bar-item-icon"
|
|
6
6
|
>
|
|
7
|
-
<TMagicPopover
|
|
7
|
+
<TMagicPopover
|
|
8
|
+
popper-class="page-bar-popover"
|
|
9
|
+
placement="top"
|
|
10
|
+
trigger="hover"
|
|
11
|
+
:width="160"
|
|
12
|
+
:destroy-on-close="true"
|
|
13
|
+
>
|
|
8
14
|
<div>
|
|
9
15
|
<slot name="page-list-popover" :list="list">
|
|
10
16
|
<ToolButton
|
|
@@ -31,8 +37,8 @@
|
|
|
31
37
|
import { computed, inject } from 'vue';
|
|
32
38
|
import { Files } from '@element-plus/icons-vue';
|
|
33
39
|
|
|
40
|
+
import { Id, MPage, MPageFragment } from '@tmagic/core';
|
|
34
41
|
import { TMagicIcon, TMagicPopover } from '@tmagic/design';
|
|
35
|
-
import { Id, MPage, MPageFragment } from '@tmagic/schema';
|
|
36
42
|
|
|
37
43
|
import ToolButton from '@editor/components/ToolButton.vue';
|
|
38
44
|
import type { Services } from '@editor/type';
|
|
@@ -111,7 +111,7 @@ const dragendHandler = () => {
|
|
|
111
111
|
globalThis.clearTimeout(timeout);
|
|
112
112
|
timeout = undefined;
|
|
113
113
|
}
|
|
114
|
-
const doc = stage.value?.renderer
|
|
114
|
+
const doc = stage.value?.renderer?.getDocument();
|
|
115
115
|
if (doc && stageOptions?.containerHighlightClassName) {
|
|
116
116
|
removeClassNameByClassName(doc, stageOptions.containerHighlightClassName);
|
|
117
117
|
}
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
</template>
|
|
149
149
|
|
|
150
150
|
<script setup lang="ts">
|
|
151
|
-
import { computed, inject, ref, watch } from 'vue';
|
|
151
|
+
import { computed, inject, nextTick, ref, watch } from 'vue';
|
|
152
152
|
import { Coin, EditPen, Goods, List } from '@element-plus/icons-vue';
|
|
153
153
|
|
|
154
154
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
@@ -180,8 +180,10 @@ defineOptions({
|
|
|
180
180
|
|
|
181
181
|
const props = withDefaults(
|
|
182
182
|
defineProps<{
|
|
183
|
-
data
|
|
183
|
+
data?: SideBarData;
|
|
184
184
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
185
|
+
indent?: number;
|
|
186
|
+
nextLevelIndentIncrement?: number;
|
|
185
187
|
customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
|
|
186
188
|
}>(),
|
|
187
189
|
{
|
|
@@ -196,7 +198,23 @@ const props = withDefaults(
|
|
|
196
198
|
const services = inject<Services>('services');
|
|
197
199
|
|
|
198
200
|
const columnLeftWidth = computed(() => services?.uiService.get('columnWidth')[ColumnLayout.LEFT] || 0);
|
|
199
|
-
const { height:
|
|
201
|
+
const { height: editorContentHeight } = useEditorContentHeight();
|
|
202
|
+
const columnLeftHeight = ref(0);
|
|
203
|
+
|
|
204
|
+
const unWatchEditorContentHeight = watch(
|
|
205
|
+
editorContentHeight,
|
|
206
|
+
(height) => {
|
|
207
|
+
if (height) {
|
|
208
|
+
columnLeftHeight.value = height * 0.5;
|
|
209
|
+
nextTick().then(() => {
|
|
210
|
+
unWatchEditorContentHeight();
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
immediate: true,
|
|
216
|
+
},
|
|
217
|
+
);
|
|
200
218
|
|
|
201
219
|
const activeTabName = ref(props.data?.status);
|
|
202
220
|
|
|
@@ -218,6 +236,8 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
218
236
|
props: {
|
|
219
237
|
layerContentMenu: props.layerContentMenu,
|
|
220
238
|
customContentMenu: props.customContentMenu,
|
|
239
|
+
indent: props.indent,
|
|
240
|
+
nextLevelIndentIncrement: props.nextLevelIndentIncrement,
|
|
221
241
|
},
|
|
222
242
|
component: LayerPanel,
|
|
223
243
|
slots: {},
|
|
@@ -228,6 +248,10 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
228
248
|
icon: EditPen,
|
|
229
249
|
text: '代码编辑',
|
|
230
250
|
component: CodeBlockListPanel,
|
|
251
|
+
props: {
|
|
252
|
+
indent: props.indent,
|
|
253
|
+
nextLevelIndentIncrement: props.nextLevelIndentIncrement,
|
|
254
|
+
},
|
|
231
255
|
slots: {},
|
|
232
256
|
},
|
|
233
257
|
[SideItemKey.DATA_SOURCE]: {
|
|
@@ -236,6 +260,10 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
236
260
|
icon: Coin,
|
|
237
261
|
text: '数据源',
|
|
238
262
|
component: DataSourceListPanel,
|
|
263
|
+
props: {
|
|
264
|
+
indent: props.indent,
|
|
265
|
+
nextLevelIndentIncrement: props.nextLevelIndentIncrement,
|
|
266
|
+
},
|
|
239
267
|
slots: {},
|
|
240
268
|
},
|
|
241
269
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Tree
|
|
2
|
+
<Tree
|
|
3
|
+
:data="codeList"
|
|
4
|
+
:node-status-map="nodeStatusMap"
|
|
5
|
+
:indent="indent"
|
|
6
|
+
:next-level-indent-increment="nextLevelIndentIncrement"
|
|
7
|
+
@node-click="clickHandler"
|
|
8
|
+
>
|
|
3
9
|
<template #tree-node-label="{ data }">
|
|
4
10
|
<div
|
|
5
11
|
:class="{
|
|
@@ -28,9 +34,9 @@
|
|
|
28
34
|
import { computed, inject } from 'vue';
|
|
29
35
|
import { Close, Edit, View } from '@element-plus/icons-vue';
|
|
30
36
|
|
|
31
|
-
import {
|
|
37
|
+
import type { Id, MNode } from '@tmagic/core';
|
|
38
|
+
import { DepTargetType } from '@tmagic/core';
|
|
32
39
|
import { tMagicMessage, tMagicMessageBox, TMagicTooltip } from '@tmagic/design';
|
|
33
|
-
import type { Id, MNode } from '@tmagic/schema';
|
|
34
40
|
|
|
35
41
|
import Icon from '@editor/components/Icon.vue';
|
|
36
42
|
import Tree from '@editor/components/Tree.vue';
|
|
@@ -45,6 +51,8 @@ defineOptions({
|
|
|
45
51
|
});
|
|
46
52
|
|
|
47
53
|
const props = defineProps<{
|
|
54
|
+
indent?: number;
|
|
55
|
+
nextLevelIndentIncrement?: number;
|
|
48
56
|
customError?: (id: Id, errorType: CodeDeleteErrorType) => any;
|
|
49
57
|
}>();
|
|
50
58
|
|
|
@@ -11,7 +11,14 @@
|
|
|
11
11
|
</slot>
|
|
12
12
|
|
|
13
13
|
<!-- 代码块列表 -->
|
|
14
|
-
<CodeBlockList
|
|
14
|
+
<CodeBlockList
|
|
15
|
+
ref="codeBlockList"
|
|
16
|
+
:custom-error="customError"
|
|
17
|
+
:indent="indent"
|
|
18
|
+
:next-level-indent-increment="nextLevelIndentIncrement"
|
|
19
|
+
@edit="editCode"
|
|
20
|
+
@remove="deleteCode"
|
|
21
|
+
>
|
|
15
22
|
<template #code-block-panel-tool="{ id, data }">
|
|
16
23
|
<slot name="code-block-panel-tool" :id="id" :data="data"></slot>
|
|
17
24
|
</template>
|
|
@@ -30,8 +37,8 @@
|
|
|
30
37
|
<script setup lang="ts">
|
|
31
38
|
import { computed, inject, ref } from 'vue';
|
|
32
39
|
|
|
40
|
+
import type { Id } from '@tmagic/core';
|
|
33
41
|
import { TMagicButton, TMagicScrollbar } from '@tmagic/design';
|
|
34
|
-
import type { Id } from '@tmagic/schema';
|
|
35
42
|
|
|
36
43
|
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
|
37
44
|
import SearchInput from '@editor/components/SearchInput.vue';
|
|
@@ -47,6 +54,8 @@ defineOptions({
|
|
|
47
54
|
});
|
|
48
55
|
|
|
49
56
|
defineProps<{
|
|
57
|
+
indent?: number;
|
|
58
|
+
nextLevelIndentIncrement?: number;
|
|
50
59
|
customError?: (id: Id, errorType: CodeDeleteErrorType) => any;
|
|
51
60
|
}>();
|
|
52
61
|
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
<script setup lang="ts">
|
|
25
25
|
import { inject, Ref, ref, watchEffect } from 'vue';
|
|
26
26
|
|
|
27
|
+
import { DataSourceSchema } from '@tmagic/core';
|
|
27
28
|
import { tMagicMessage } from '@tmagic/design';
|
|
28
29
|
import { FormConfig, MFormBox } from '@tmagic/form';
|
|
29
|
-
import { DataSourceSchema } from '@tmagic/schema';
|
|
30
30
|
|
|
31
31
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
32
32
|
import { useEditorContentHeight } from '@editor/hooks';
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Tree
|
|
2
|
+
<Tree
|
|
3
|
+
:data="list"
|
|
4
|
+
:node-status-map="nodeStatusMap"
|
|
5
|
+
:indent="indent"
|
|
6
|
+
:next-level-indent-increment="nextLevelIndentIncrement"
|
|
7
|
+
@node-click="clickHandler"
|
|
8
|
+
>
|
|
3
9
|
<template #tree-node-label="{ data }">
|
|
4
10
|
<div
|
|
5
11
|
:class="{
|
|
@@ -27,9 +33,8 @@
|
|
|
27
33
|
import { computed, inject } from 'vue';
|
|
28
34
|
import { Close, Edit, View } from '@element-plus/icons-vue';
|
|
29
35
|
|
|
30
|
-
import { DepTargetType } from '@tmagic/
|
|
36
|
+
import { DepData, DepTargetType, Id, MNode } from '@tmagic/core';
|
|
31
37
|
import { tMagicMessageBox, TMagicTooltip } from '@tmagic/design';
|
|
32
|
-
import { DepData, Id, MNode } from '@tmagic/schema';
|
|
33
38
|
|
|
34
39
|
import Icon from '@editor/components/Icon.vue';
|
|
35
40
|
import Tree from '@editor/components/Tree.vue';
|
|
@@ -43,6 +48,11 @@ defineOptions({
|
|
|
43
48
|
name: 'MEditorDataSourceList',
|
|
44
49
|
});
|
|
45
50
|
|
|
51
|
+
defineProps<{
|
|
52
|
+
indent?: number;
|
|
53
|
+
nextLevelIndentIncrement?: number;
|
|
54
|
+
}>();
|
|
55
|
+
|
|
46
56
|
const emit = defineEmits<{
|
|
47
57
|
edit: [id: string];
|
|
48
58
|
remove: [id: string];
|
|
@@ -2,30 +2,40 @@
|
|
|
2
2
|
<TMagicScrollbar class="data-source-list-panel m-editor-layer-panel">
|
|
3
3
|
<div class="search-wrapper">
|
|
4
4
|
<SearchInput @search="filterTextChangeHandler"></SearchInput>
|
|
5
|
-
<TMagicPopover
|
|
5
|
+
<TMagicPopover
|
|
6
|
+
v-if="editable"
|
|
7
|
+
placement="right"
|
|
8
|
+
trigger="hover"
|
|
9
|
+
popper-class="data-source-list-panel-add-menu"
|
|
10
|
+
:destroy-on-close="true"
|
|
11
|
+
>
|
|
6
12
|
<template #reference>
|
|
7
13
|
<TMagicButton type="primary" size="small">新增</TMagicButton>
|
|
8
14
|
</template>
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
></ToolButton>
|
|
21
|
-
</div>
|
|
15
|
+
<ToolButton
|
|
16
|
+
v-for="(item, index) in datasourceTypeList"
|
|
17
|
+
:data="{
|
|
18
|
+
type: 'button',
|
|
19
|
+
text: item.text,
|
|
20
|
+
handler: () => {
|
|
21
|
+
addHandler(item.type);
|
|
22
|
+
},
|
|
23
|
+
}"
|
|
24
|
+
:key="index"
|
|
25
|
+
></ToolButton>
|
|
22
26
|
</TMagicPopover>
|
|
23
27
|
|
|
24
28
|
<slot name="data-source-panel-search"></slot>
|
|
25
29
|
</div>
|
|
26
30
|
|
|
27
31
|
<!-- 数据源列表 -->
|
|
28
|
-
<DataSourceList
|
|
32
|
+
<DataSourceList
|
|
33
|
+
ref="dataSourceList"
|
|
34
|
+
:indent="indent"
|
|
35
|
+
:next-level-indent-increment="nextLevelIndentIncrement"
|
|
36
|
+
@edit="editHandler"
|
|
37
|
+
@remove="removeHandler"
|
|
38
|
+
></DataSourceList>
|
|
29
39
|
</TMagicScrollbar>
|
|
30
40
|
|
|
31
41
|
<DataSourceConfigPanel
|
|
@@ -57,6 +67,11 @@ defineOptions({
|
|
|
57
67
|
name: 'MEditorDataSourceListPanel',
|
|
58
68
|
});
|
|
59
69
|
|
|
70
|
+
defineProps<{
|
|
71
|
+
indent?: number;
|
|
72
|
+
nextLevelIndentIncrement?: number;
|
|
73
|
+
}>();
|
|
74
|
+
|
|
60
75
|
const eventBus = inject<EventBus>('eventBus');
|
|
61
76
|
const { dataSourceService } = inject<Services>('services') || {};
|
|
62
77
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { inject } from 'vue';
|
|
10
10
|
import { Hide, View } from '@element-plus/icons-vue';
|
|
11
11
|
|
|
12
|
-
import type { MNode } from '@tmagic/
|
|
12
|
+
import type { MNode } from '@tmagic/core';
|
|
13
13
|
|
|
14
14
|
import MIcon from '@editor/components/Icon.vue';
|
|
15
15
|
import { Services } from '@editor/type';
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
ref="tree"
|
|
11
11
|
:data="nodeData"
|
|
12
12
|
:node-status-map="nodeStatusMap"
|
|
13
|
+
:indent="indent"
|
|
14
|
+
:next-level-indent-increment="nextLevelIndentIncrement"
|
|
13
15
|
@node-dragover="handleDragOver"
|
|
14
16
|
@node-dragstart="handleDragStart"
|
|
15
17
|
@node-dragleave="handleDragLeave"
|
|
@@ -47,8 +49,8 @@
|
|
|
47
49
|
<script setup lang="ts">
|
|
48
50
|
import { computed, inject, ref } from 'vue';
|
|
49
51
|
|
|
52
|
+
import type { MNode } from '@tmagic/core';
|
|
50
53
|
import { TMagicScrollbar } from '@tmagic/design';
|
|
51
|
-
import type { MNode } from '@tmagic/schema';
|
|
52
54
|
|
|
53
55
|
import SearchInput from '@editor/components/SearchInput.vue';
|
|
54
56
|
import Tree from '@editor/components/Tree.vue';
|
|
@@ -70,6 +72,8 @@ defineOptions({
|
|
|
70
72
|
|
|
71
73
|
defineProps<{
|
|
72
74
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
75
|
+
indent?: number;
|
|
76
|
+
nextLevelIndentIncrement?: number;
|
|
73
77
|
customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
|
|
74
78
|
}>();
|
|
75
79
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, type ComputedRef, nextTick, type Ref, ref } from 'vue';
|
|
2
2
|
import { throttle } from 'lodash-es';
|
|
3
3
|
|
|
4
|
-
import { Id, MNode } from '@tmagic/
|
|
4
|
+
import { Id, MNode } from '@tmagic/core';
|
|
5
5
|
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
6
6
|
|
|
7
7
|
import { LayerNodeStatus, Services, TreeNodeData, UI_SELECT_MODE_EVENT_NAME } from '@editor/type';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { computed, ref, watch } from 'vue';
|
|
2
2
|
|
|
3
|
-
import type { Id, MNode, MPage, MPageFragment } from '@tmagic/
|
|
4
|
-
import { getNodePath, isPage, isPageFragment } from '@tmagic/utils';
|
|
3
|
+
import type { Id, MNode, MPage, MPageFragment } from '@tmagic/core';
|
|
4
|
+
import { getNodePath, isPage, isPageFragment, traverseNode } from '@tmagic/utils';
|
|
5
5
|
|
|
6
|
-
import { LayerNodeStatus, Services } from '@editor/type';
|
|
7
|
-
import { traverseNode } from '@editor/utils';
|
|
6
|
+
import type { LayerNodeStatus, Services } from '@editor/type';
|
|
8
7
|
import { updateStatus } from '@editor/utils/tree';
|
|
9
8
|
|
|
10
9
|
const createPageNodeStatus = (page: MPage | MPageFragment, initialLayerNodeStatus?: Map<Id, LayerNodeStatus>) => {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
11
|
import { computed, inject } from 'vue';
|
|
12
12
|
|
|
13
|
+
import type { MNode } from '@tmagic/core';
|
|
13
14
|
import { TMagicButton } from '@tmagic/design';
|
|
14
|
-
import type { MNode } from '@tmagic/schema';
|
|
15
15
|
import { getNodePath } from '@tmagic/utils';
|
|
16
16
|
|
|
17
17
|
import type { Services } from '@editor/type';
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
<script lang="ts" setup>
|
|
25
25
|
import { computed, inject, nextTick, ref, watch } from 'vue';
|
|
26
26
|
|
|
27
|
+
import type { MNode } from '@tmagic/core';
|
|
27
28
|
import { TMagicTooltip } from '@tmagic/design';
|
|
28
|
-
import type { MNode } from '@tmagic/schema';
|
|
29
29
|
import { getIdFromEl } from '@tmagic/utils';
|
|
30
30
|
|
|
31
31
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
@@ -61,7 +61,7 @@ const unWatch = watch(
|
|
|
61
61
|
nextTick(() => unWatch());
|
|
62
62
|
|
|
63
63
|
stage.on('select', (el: HTMLElement, event: MouseEvent) => {
|
|
64
|
-
const els = stage.renderer
|
|
64
|
+
const els = stage.renderer?.getElementsFromPoint(event) || [];
|
|
65
65
|
const ids = els.map((el) => getIdFromEl()(el)).filter((id) => Boolean(id)) as string[];
|
|
66
66
|
|
|
67
67
|
buttonVisible.value = ids.length > 3;
|