@tmagic/editor 1.5.0-beta.3 → 1.5.0-beta.5
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 +274 -2
- package/dist/tmagic-editor.js +103 -46
- package/dist/tmagic-editor.umd.cjs +325 -242
- package/package.json +7 -9
- package/src/Editor.vue +8 -2
- 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 +5 -2
- 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 +1 -1
- 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 +2 -2
- package/src/fields/PageFragmentSelect.vue +1 -1
- package/src/fields/UISelect.vue +1 -1
- 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 +1 -1
- package/src/hooks/use-node-status.ts +1 -1
- package/src/hooks/use-stage.ts +2 -6
- package/src/index.ts +27 -7
- package/src/initService.ts +11 -3
- 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 +1 -1
- package/src/layouts/page-bar/PageBarScrollContainer.vue +1 -1
- package/src/layouts/page-bar/PageList.vue +1 -1
- package/src/layouts/page-bar/SwitchTypeButton.vue +1 -1
- package/src/layouts/sidebar/Sidebar.vue +12 -0
- 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 +12 -1
- 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 +1 -1
- package/src/layouts/workspace/Breadcrumb.vue +1 -1
- package/src/layouts/workspace/viewer/NodeListMenu.vue +1 -1
- package/src/layouts/workspace/viewer/Stage.vue +7 -3
- package/src/layouts/workspace/viewer/StageOverlay.vue +6 -1
- 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 +7 -8
- package/src/services/history.ts +1 -1
- package/src/services/props.ts +3 -3
- package/src/services/storage.ts +2 -2
- package/src/theme/index.scss +3 -0
- package/src/type.ts +13 -10
- package/src/utils/config.ts +5 -5
- package/src/utils/content-menu.ts +1 -1
- package/src/utils/data-source/index.ts +1 -1
- package/src/utils/editor.ts +2 -8
- 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 +53 -29
|
@@ -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';
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
import { computed, inject, ref, watch } from 'vue';
|
|
67
67
|
import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
68
68
|
|
|
69
|
+
import { type Id, type MPage, type MPageFragment, NodeType } from '@tmagic/core';
|
|
69
70
|
import { TMagicIcon, TMagicPopover } from '@tmagic/design';
|
|
70
|
-
import { Id, type MPage, type MPageFragment, NodeType } from '@tmagic/schema';
|
|
71
71
|
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
72
72
|
|
|
73
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';
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
import { computed, inject } from 'vue';
|
|
38
38
|
import { Files } from '@element-plus/icons-vue';
|
|
39
39
|
|
|
40
|
+
import { Id, MPage, MPageFragment } from '@tmagic/core';
|
|
40
41
|
import { TMagicIcon, TMagicPopover } from '@tmagic/design';
|
|
41
|
-
import { Id, MPage, MPageFragment } from '@tmagic/schema';
|
|
42
42
|
|
|
43
43
|
import ToolButton from '@editor/components/ToolButton.vue';
|
|
44
44
|
import type { Services } from '@editor/type';
|
|
@@ -182,6 +182,8 @@ const props = withDefaults(
|
|
|
182
182
|
defineProps<{
|
|
183
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
|
{
|
|
@@ -234,6 +236,8 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
234
236
|
props: {
|
|
235
237
|
layerContentMenu: props.layerContentMenu,
|
|
236
238
|
customContentMenu: props.customContentMenu,
|
|
239
|
+
indent: props.indent,
|
|
240
|
+
nextLevelIndentIncrement: props.nextLevelIndentIncrement,
|
|
237
241
|
},
|
|
238
242
|
component: LayerPanel,
|
|
239
243
|
slots: {},
|
|
@@ -244,6 +248,10 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
244
248
|
icon: EditPen,
|
|
245
249
|
text: '代码编辑',
|
|
246
250
|
component: CodeBlockListPanel,
|
|
251
|
+
props: {
|
|
252
|
+
indent: props.indent,
|
|
253
|
+
nextLevelIndentIncrement: props.nextLevelIndentIncrement,
|
|
254
|
+
},
|
|
247
255
|
slots: {},
|
|
248
256
|
},
|
|
249
257
|
[SideItemKey.DATA_SOURCE]: {
|
|
@@ -252,6 +260,10 @@ const getItemConfig = (data: SideItem): SideComponent => {
|
|
|
252
260
|
icon: Coin,
|
|
253
261
|
text: '数据源',
|
|
254
262
|
component: DataSourceListPanel,
|
|
263
|
+
props: {
|
|
264
|
+
indent: props.indent,
|
|
265
|
+
nextLevelIndentIncrement: props.nextLevelIndentIncrement,
|
|
266
|
+
},
|
|
255
267
|
slots: {},
|
|
256
268
|
},
|
|
257
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];
|
|
@@ -29,7 +29,13 @@
|
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
<!-- 数据源列表 -->
|
|
32
|
-
<DataSourceList
|
|
32
|
+
<DataSourceList
|
|
33
|
+
ref="dataSourceList"
|
|
34
|
+
:indent="indent"
|
|
35
|
+
:next-level-indent-increment="nextLevelIndentIncrement"
|
|
36
|
+
@edit="editHandler"
|
|
37
|
+
@remove="removeHandler"
|
|
38
|
+
></DataSourceList>
|
|
33
39
|
</TMagicScrollbar>
|
|
34
40
|
|
|
35
41
|
<DataSourceConfigPanel
|
|
@@ -61,6 +67,11 @@ defineOptions({
|
|
|
61
67
|
name: 'MEditorDataSourceListPanel',
|
|
62
68
|
});
|
|
63
69
|
|
|
70
|
+
defineProps<{
|
|
71
|
+
indent?: number;
|
|
72
|
+
nextLevelIndentIncrement?: number;
|
|
73
|
+
}>();
|
|
74
|
+
|
|
64
75
|
const eventBus = inject<EventBus>('eventBus');
|
|
65
76
|
const { dataSourceService } = inject<Services>('services') || {};
|
|
66
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,6 +1,6 @@
|
|
|
1
1
|
import { computed, ref, watch } from 'vue';
|
|
2
2
|
|
|
3
|
-
import type { Id, MNode, MPage, MPageFragment } from '@tmagic/
|
|
3
|
+
import type { Id, MNode, MPage, MPageFragment } from '@tmagic/core';
|
|
4
4
|
import { getNodePath, isPage, isPageFragment } from '@tmagic/utils';
|
|
5
5
|
|
|
6
6
|
import { LayerNodeStatus, Services } from '@editor/type';
|
|
@@ -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';
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
import { computed, inject, markRaw, nextTick, onBeforeUnmount, onMounted, ref, toRaw, watch, watchEffect } from 'vue';
|
|
45
45
|
import { cloneDeep } from 'lodash-es';
|
|
46
46
|
|
|
47
|
-
import type { MApp, MContainer } from '@tmagic/
|
|
47
|
+
import type { MApp, MContainer } from '@tmagic/core';
|
|
48
48
|
import StageCore, { getOffset, Runtime } from '@tmagic/stage';
|
|
49
49
|
import { calcValueByFontsize, getIdFromEl } from '@tmagic/utils';
|
|
50
50
|
|
|
51
51
|
import ScrollViewer from '@editor/components/ScrollViewer.vue';
|
|
52
52
|
import { useStage } from '@editor/hooks/use-stage';
|
|
53
53
|
import { DragType, Layout, type MenuButton, type MenuComponent, type Services, type StageOptions } from '@editor/type';
|
|
54
|
-
import {
|
|
54
|
+
import { getEditorConfig } from '@editor/utils/config';
|
|
55
55
|
import { KeyBindingContainerKey } from '@editor/utils/keybinding-config';
|
|
56
56
|
|
|
57
57
|
import NodeListMenu from './NodeListMenu.vue';
|
|
@@ -123,6 +123,10 @@ watchEffect(() => {
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
onBeforeUnmount(() => {
|
|
127
|
+
stage?.destroy();
|
|
128
|
+
});
|
|
129
|
+
|
|
126
130
|
watch(zoom, (zoom) => {
|
|
127
131
|
if (!stage || !zoom) return;
|
|
128
132
|
stage.setZoom(zoom);
|
|
@@ -170,7 +174,7 @@ onBeforeUnmount(() => {
|
|
|
170
174
|
services?.editorService.off('root-change', rootChangeHandler);
|
|
171
175
|
});
|
|
172
176
|
|
|
173
|
-
const parseDSL =
|
|
177
|
+
const parseDSL = getEditorConfig('parseDSL');
|
|
174
178
|
|
|
175
179
|
const contextmenuHandler = (e: MouseEvent) => {
|
|
176
180
|
e.preventDefault();
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
|
-
import { computed, inject, ref, watch } from 'vue';
|
|
11
|
+
import { computed, inject, onBeforeUnmount, ref, watch } from 'vue';
|
|
12
12
|
import { CloseBold } from '@element-plus/icons-vue';
|
|
13
13
|
|
|
14
14
|
import { TMagicIcon } from '@tmagic/design';
|
|
@@ -62,6 +62,11 @@ watch(stageOverlay, (stageOverlay) => {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
onBeforeUnmount(() => {
|
|
66
|
+
services?.stageOverlayService.get('stage')?.destroy();
|
|
67
|
+
services?.stageOverlayService.set('stage', null);
|
|
68
|
+
});
|
|
69
|
+
|
|
65
70
|
const closeOverlayHandler = () => {
|
|
66
71
|
services?.stageOverlayService.closeOverlay();
|
|
67
72
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { computed, inject, markRaw, ref, watch } from 'vue';
|
|
7
7
|
import { Bottom, Top } from '@element-plus/icons-vue';
|
|
8
8
|
|
|
9
|
-
import { NodeType } from '@tmagic/
|
|
9
|
+
import { NodeType } from '@tmagic/core';
|
|
10
10
|
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
11
11
|
|
|
12
12
|
import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
@@ -20,15 +20,15 @@ import { reactive } from 'vue';
|
|
|
20
20
|
import { cloneDeep, get, keys, pick } from 'lodash-es';
|
|
21
21
|
import type { Writable } from 'type-fest';
|
|
22
22
|
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import type {
|
|
23
|
+
import type { CodeBlockContent, CodeBlockDSL, Id, MNode, TargetOptions } from '@tmagic/core';
|
|
24
|
+
import { Target, Watcher } from '@tmagic/core';
|
|
25
|
+
import type { TableColumnConfig } from '@tmagic/form';
|
|
26
26
|
|
|
27
27
|
import editorService from '@editor/services/editor';
|
|
28
28
|
import storageService, { Protocol } from '@editor/services/storage';
|
|
29
29
|
import type { AsyncHookPlugin, CodeState } from '@editor/type';
|
|
30
30
|
import { CODE_DRAFT_STORAGE_KEY } from '@editor/type';
|
|
31
|
-
import {
|
|
31
|
+
import { getEditorConfig } from '@editor/utils/config';
|
|
32
32
|
import { COPY_CODE_STORAGE_KEY } from '@editor/utils/editor';
|
|
33
33
|
|
|
34
34
|
import BaseService from './BaseService';
|
|
@@ -117,7 +117,7 @@ class CodeBlock extends BaseService {
|
|
|
117
117
|
const codeConfigProcessed = cloneDeep(codeConfig);
|
|
118
118
|
if (codeConfigProcessed.content) {
|
|
119
119
|
// 在保存的时候转换代码内容
|
|
120
|
-
const parseDSL =
|
|
120
|
+
const parseDSL = getEditorConfig('parseDSL');
|
|
121
121
|
if (typeof codeConfigProcessed.content === 'string') {
|
|
122
122
|
codeConfigProcessed.content = parseDSL<(...args: any[]) => any>(codeConfigProcessed.content);
|
|
123
123
|
}
|
|
@@ -231,11 +231,11 @@ class CodeBlock extends BaseService {
|
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
public setParamsColConfig(config:
|
|
234
|
+
public setParamsColConfig(config: TableColumnConfig): void {
|
|
235
235
|
this.state.paramsColConfig = config;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
public getParamsColConfig():
|
|
238
|
+
public getParamsColConfig(): TableColumnConfig | undefined {
|
|
239
239
|
return this.state.paramsColConfig;
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { reactive } from 'vue';
|
|
2
2
|
import { cloneDeep, get } from 'lodash-es';
|
|
3
|
-
import { Writable } from 'type-fest';
|
|
3
|
+
import type { Writable } from 'type-fest';
|
|
4
4
|
|
|
5
|
-
import type { EventOption } from '@tmagic/core';
|
|
6
|
-
import { Target,
|
|
5
|
+
import type { DataSourceSchema, EventOption, Id, MNode, TargetOptions } from '@tmagic/core';
|
|
6
|
+
import { Target, Watcher } from '@tmagic/core';
|
|
7
7
|
import type { FormConfig } from '@tmagic/form';
|
|
8
|
-
import type { DataSourceSchema, Id, MNode } from '@tmagic/schema';
|
|
9
8
|
import { guid, toLine } from '@tmagic/utils';
|
|
10
9
|
|
|
11
10
|
import editorService from '@editor/services/editor';
|
package/src/services/dep.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { reactive } from 'vue';
|
|
19
19
|
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
20
|
+
import type { DepExtendedData, Id, MNode, Target, TargetNode } from '@tmagic/core';
|
|
21
|
+
import { DepTargetType, Watcher } from '@tmagic/core';
|
|
22
22
|
import { isPage } from '@tmagic/utils';
|
|
23
23
|
|
|
24
24
|
import { IdleTask } from '@editor/utils/idle-task';
|
package/src/services/editor.ts
CHANGED
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
import { reactive, toRaw } from 'vue';
|
|
20
20
|
import { cloneDeep, get, isObject, mergeWith, uniq } from 'lodash-es';
|
|
21
|
-
import { Writable } from 'type-fest';
|
|
21
|
+
import type { Writable } from 'type-fest';
|
|
22
22
|
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
23
|
+
import type { Id, MApp, MComponent, MContainer, MNode, MPage, MPageFragment, TargetOptions } from '@tmagic/core';
|
|
24
|
+
import { NodeType, Target, Watcher } from '@tmagic/core';
|
|
25
|
+
import { isFixed } from '@tmagic/stage';
|
|
26
26
|
import { calcValueByFontsize, getElById, getNodePath, isNumber, isPage, isPageFragment, isPop } from '@tmagic/utils';
|
|
27
27
|
|
|
28
28
|
import BaseService from '@editor/services//BaseService';
|
|
@@ -48,7 +48,6 @@ import {
|
|
|
48
48
|
getNodeIndex,
|
|
49
49
|
getPageFragmentList,
|
|
50
50
|
getPageList,
|
|
51
|
-
isFixed,
|
|
52
51
|
moveItemsInContainer,
|
|
53
52
|
setChildrenLayout,
|
|
54
53
|
setLayout,
|
|
@@ -234,7 +233,7 @@ class Editor extends BaseService {
|
|
|
234
233
|
* 只有容器拥有布局
|
|
235
234
|
*/
|
|
236
235
|
public async getLayout(parent: MNode, node?: MNode | null): Promise<Layout> {
|
|
237
|
-
if (node && typeof node !== 'function' && isFixed(node)) return Layout.FIXED;
|
|
236
|
+
if (node && typeof node !== 'function' && isFixed(node.style || {})) return Layout.FIXED;
|
|
238
237
|
|
|
239
238
|
if (parent.layout) {
|
|
240
239
|
return parent.layout;
|
|
@@ -1106,9 +1105,9 @@ class Editor extends BaseService {
|
|
|
1106
1105
|
const newConfig = cloneDeep(dist);
|
|
1107
1106
|
|
|
1108
1107
|
if (!isPop(src) && newConfig.style?.position) {
|
|
1109
|
-
if (isFixed(newConfig) && !isFixed(src)) {
|
|
1108
|
+
if (isFixed(newConfig.style) && !isFixed(src.style || {})) {
|
|
1110
1109
|
newConfig.style = change2Fixed(newConfig, root);
|
|
1111
|
-
} else if (!isFixed(newConfig) && isFixed(src)) {
|
|
1110
|
+
} else if (!isFixed(newConfig.style) && isFixed(src.style || {})) {
|
|
1112
1111
|
newConfig.style = await Fixed2Other(newConfig, root, this.getLayout);
|
|
1113
1112
|
}
|
|
1114
1113
|
}
|
package/src/services/history.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
20
|
|
|
21
|
-
import type { MPage, MPageFragment } from '@tmagic/
|
|
21
|
+
import type { MPage, MPageFragment } from '@tmagic/core';
|
|
22
22
|
|
|
23
23
|
import type { HistoryState, StepValue } from '@editor/type';
|
|
24
24
|
import { UndoRedo } from '@editor/utils/undo-redo';
|
package/src/services/props.ts
CHANGED
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
import { reactive } from 'vue';
|
|
20
20
|
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
21
|
-
import { Writable } from 'type-fest';
|
|
21
|
+
import type { Writable } from 'type-fest';
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import type { Id, MComponent, MNode, TargetOptions } from '@tmagic/core';
|
|
24
|
+
import { Target, Watcher } from '@tmagic/core';
|
|
24
25
|
import type { FormConfig } from '@tmagic/form';
|
|
25
|
-
import type { Id, MComponent, MNode } from '@tmagic/schema';
|
|
26
26
|
import { getNodePath, getValueByKeyPath, guid, setValueByKeyPath, toLine } from '@tmagic/utils';
|
|
27
27
|
|
|
28
28
|
import editorService from '@editor/services/editor';
|
package/src/services/storage.ts
CHANGED
|
@@ -2,7 +2,7 @@ import serialize from 'serialize-javascript';
|
|
|
2
2
|
import type { Writable } from 'type-fest';
|
|
3
3
|
|
|
4
4
|
import type { SyncHookPlugin } from '@editor/type';
|
|
5
|
-
import {
|
|
5
|
+
import { getEditorConfig } from '@editor/utils/config';
|
|
6
6
|
|
|
7
7
|
import BaseService from './BaseService';
|
|
8
8
|
|
|
@@ -76,7 +76,7 @@ export class WebStorage extends BaseService {
|
|
|
76
76
|
|
|
77
77
|
switch (protocol) {
|
|
78
78
|
case Protocol.OBJECT:
|
|
79
|
-
return
|
|
79
|
+
return getEditorConfig('parseDSL')(`(${item})`);
|
|
80
80
|
case Protocol.JSON:
|
|
81
81
|
return JSON.parse(item);
|
|
82
82
|
case Protocol.NUMBER:
|