@tmagic/editor 1.3.5 → 1.3.7
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/LICENSE +5432 -0
- package/dist/style.css +88 -62
- package/dist/tmagic-editor.js +2448 -2016
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +2453 -2019
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +23 -23
- package/src/Editor.vue +15 -7
- package/src/components/CodeBlockEditor.vue +2 -2
- package/src/components/ContentMenu.vue +5 -5
- package/src/components/FloatingBox.vue +117 -0
- package/src/components/ScrollBar.vue +2 -2
- package/src/components/ScrollViewer.vue +2 -2
- package/src/components/SplitView.vue +2 -2
- package/src/components/Tree.vue +5 -0
- package/src/components/TreeNode.vue +10 -4
- package/src/editorProps.ts +20 -3
- package/src/fields/PageFragmentSelect.vue +55 -0
- package/src/hooks/use-filter.ts +55 -0
- package/src/hooks/use-getso.ts +2 -2
- package/src/hooks/use-node-status.ts +48 -0
- package/src/hooks/use-stage.ts +19 -1
- package/src/index.ts +3 -0
- package/src/initService.ts +43 -17
- package/src/layouts/AddPageBox.vue +16 -4
- package/src/layouts/CodeEditor.vue +2 -2
- package/src/layouts/Framework.vue +17 -3
- package/src/layouts/PropsPanel.vue +2 -2
- package/src/layouts/page-bar/AddButton.vue +48 -0
- package/src/layouts/page-bar/PageBar.vue +158 -0
- package/src/layouts/{workspace → page-bar}/PageBarScrollContainer.vue +61 -35
- package/src/layouts/page-bar/SwitchTypeButton.vue +45 -0
- package/src/layouts/sidebar/Sidebar.vue +9 -2
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +55 -65
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +2 -1
- package/src/layouts/sidebar/data-source/DataSourceList.vue +63 -59
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +1 -1
- package/src/layouts/sidebar/layer/LayerMenu.vue +39 -27
- package/src/layouts/sidebar/layer/LayerPanel.vue +31 -8
- package/src/layouts/sidebar/layer/use-click.ts +5 -3
- package/src/layouts/sidebar/layer/use-keybinding.ts +8 -8
- package/src/layouts/sidebar/layer/use-node-status.ts +10 -13
- package/src/layouts/workspace/Workspace.vue +6 -7
- package/src/layouts/workspace/viewer/NodeListMenu.vue +68 -129
- package/src/layouts/workspace/viewer/Stage.vue +14 -6
- package/src/layouts/workspace/viewer/ViewerMenu.vue +94 -86
- package/src/services/BaseService.ts +63 -26
- package/src/services/codeBlock.ts +7 -1
- package/src/services/dep.ts +12 -8
- package/src/services/editor.ts +131 -64
- package/src/services/history.ts +6 -2
- package/src/services/keybinding.ts +48 -13
- package/src/services/props.ts +70 -12
- package/src/services/storage.ts +23 -13
- package/src/services/ui.ts +4 -1
- package/src/theme/code-block.scss +0 -16
- package/src/theme/floating-box.scss +30 -0
- package/src/theme/layer-panel.scss +19 -0
- package/src/theme/page-bar.scss +18 -1
- package/src/theme/stage.scss +24 -0
- package/src/theme/theme.scss +1 -1
- package/src/theme/tree.scss +12 -1
- package/src/type.ts +28 -10
- package/src/utils/compose.ts +25 -6
- package/src/utils/content-menu.ts +6 -7
- package/src/utils/editor.ts +34 -18
- package/src/utils/operator.ts +5 -6
- package/types/components/CodeBlockEditor.vue.d.ts +6 -2
- package/types/components/CodeParams.vue.d.ts +3 -1
- package/types/components/ContentMenu.vue.d.ts +13 -5
- package/types/components/FloatingBox.vue.d.ts +78 -0
- package/types/components/Resizer.vue.d.ts +6 -1
- package/types/components/ScrollBar.vue.d.ts +3 -1
- package/types/components/ScrollViewer.vue.d.ts +3 -3
- package/types/components/SearchInput.vue.d.ts +3 -1
- package/types/components/SplitView.vue.d.ts +8 -4
- package/types/components/ToolButton.vue.d.ts +3 -3
- package/types/components/Tree.vue.d.ts +27 -8
- package/types/components/TreeNode.vue.d.ts +24 -7
- package/types/editorProps.d.ts +16 -1
- package/types/fields/Code.vue.d.ts +6 -2
- package/types/fields/CodeLink.vue.d.ts +5 -3
- package/types/fields/CodeSelect.vue.d.ts +3 -1
- package/types/fields/CodeSelectCol.vue.d.ts +3 -1
- package/types/fields/DataSourceFieldSelect.vue.d.ts +3 -1
- package/types/fields/DataSourceFields.vue.d.ts +5 -3
- package/types/fields/DataSourceInput.vue.d.ts +8 -4
- package/types/fields/DataSourceMethodSelect.vue.d.ts +3 -1
- package/types/fields/DataSourceMethods.vue.d.ts +5 -3
- package/types/fields/DataSourceMocks.vue.d.ts +5 -3
- package/types/fields/DataSourceSelect.vue.d.ts +5 -3
- package/types/fields/EventSelect.vue.d.ts +3 -1
- package/types/fields/KeyValue.vue.d.ts +2 -2
- package/types/fields/PageFragmentSelect.vue.d.ts +31 -0
- package/types/fields/UISelect.vue.d.ts +3 -1
- package/types/hooks/use-code-block-edit.d.ts +14 -5
- package/types/hooks/use-data-source-method.d.ts +14 -5
- package/types/hooks/use-filter.d.ts +7 -0
- package/types/hooks/use-node-status.d.ts +6 -0
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +14 -1
- package/types/layouts/CodeEditor.vue.d.ts +4 -1
- package/types/layouts/Framework.vue.d.ts +14 -1
- package/types/layouts/PropsPanel.vue.d.ts +19 -13
- package/types/layouts/{workspace/viewer/NodeListMenuTitle.vue.d.ts → page-bar/AddButton.vue.d.ts} +3 -2
- package/types/layouts/page-bar/PageBar.vue.d.ts +28 -0
- package/types/layouts/page-bar/PageBarScrollContainer.vue.d.ts +24 -0
- package/types/layouts/page-bar/SwitchTypeButton.vue.d.ts +20 -0
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -1
- package/types/layouts/sidebar/Sidebar.vue.d.ts +7 -5
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +9 -3
- package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +1 -1
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -1
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +8 -2
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +1 -1
- package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +26 -3
- package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +3 -1
- package/types/layouts/sidebar/layer/use-click.d.ts +37 -6
- package/types/layouts/sidebar/layer/use-keybinding.d.ts +1 -1
- package/types/layouts/sidebar/layer/use-node-status.d.ts +3 -4
- package/types/layouts/workspace/Workspace.vue.d.ts +3 -1
- package/types/layouts/workspace/viewer/NodeListMenu.vue.d.ts +1 -14
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +2 -0
- package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +9 -1
- package/types/services/BaseService.d.ts +4 -1
- package/types/services/dataSource.d.ts +1 -0
- package/types/services/dep.d.ts +6 -5
- package/types/services/editor.d.ts +12 -5
- package/types/services/history.d.ts +3 -2
- package/types/services/keybinding.d.ts +21 -1
- package/types/services/props.d.ts +25 -1
- package/types/services/storage.d.ts +7 -7
- package/types/type.d.ts +32 -17
- package/types/utils/compose.d.ts +1 -1
- package/types/utils/editor.d.ts +14 -8
- package/src/layouts/sidebar/layer/use-filter.ts +0 -59
- package/src/layouts/workspace/PageBar.vue +0 -87
- package/src/layouts/workspace/viewer/NodeListMenuTitle.vue +0 -68
- package/src/theme/dep-list.scss +0 -59
- package/types/layouts/sidebar/layer/use-filter.d.ts +0 -7
- package/types/layouts/workspace/PageBar.vue.d.ts +0 -15
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +0 -9
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type ComputedRef, ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
import { Id, MNode, MPage } from '@tmagic/schema';
|
|
4
|
-
|
|
5
|
-
import { LayerNodeStatus } from '@editor/type';
|
|
6
|
-
import { traverseNode } from '@editor/utils';
|
|
7
|
-
import { updateStatus } from '@editor/utils/tree';
|
|
8
|
-
|
|
9
|
-
export const useFilter = (
|
|
10
|
-
nodeStatusMap: ComputedRef<Map<Id, LayerNodeStatus> | undefined>,
|
|
11
|
-
page: ComputedRef<MPage | null | undefined>,
|
|
12
|
-
) => {
|
|
13
|
-
// tree方法:对树节点进行筛选时执行的方法
|
|
14
|
-
const filterIsMatch = (value: string, data: MNode): boolean => {
|
|
15
|
-
if (!value) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
let name = '';
|
|
19
|
-
if (data.name) {
|
|
20
|
-
name = data.name;
|
|
21
|
-
} else if (data.items) {
|
|
22
|
-
name = 'container';
|
|
23
|
-
}
|
|
24
|
-
return `${data.id}${name}${data.type}`.includes(value);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const filterNode = (text: string) => (node: MNode, parents: MNode[]) => {
|
|
28
|
-
if (!nodeStatusMap.value) return;
|
|
29
|
-
|
|
30
|
-
const visible = filterIsMatch(text, node);
|
|
31
|
-
if (visible && parents.length) {
|
|
32
|
-
parents.forEach((parent) => {
|
|
33
|
-
updateStatus(nodeStatusMap.value!, parent.id, {
|
|
34
|
-
visible,
|
|
35
|
-
expand: true,
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
updateStatus(nodeStatusMap.value, node.id, {
|
|
41
|
-
visible,
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const filter = (text: string) => {
|
|
46
|
-
if (!page.value?.items?.length) return;
|
|
47
|
-
|
|
48
|
-
page.value.items.forEach((node) => {
|
|
49
|
-
traverseNode(node, filterNode(text));
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
filterText: ref(''),
|
|
55
|
-
filterTextChangeHandler(text: string) {
|
|
56
|
-
filter(text);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<PageBarScrollContainer>
|
|
3
|
-
<div
|
|
4
|
-
v-for="item in (root && root.items) || []"
|
|
5
|
-
class="m-editor-page-bar-item"
|
|
6
|
-
:key="item.key"
|
|
7
|
-
:class="{ active: page?.id === item.id }"
|
|
8
|
-
@click="switchPage(item)"
|
|
9
|
-
>
|
|
10
|
-
<div class="m-editor-page-bar-title">
|
|
11
|
-
<slot name="page-bar-title" :page="item">
|
|
12
|
-
<TMagicTooltip effect="dark" placement="top-start" :content="item.name">
|
|
13
|
-
<span>{{ item.name || item.id }}</span>
|
|
14
|
-
</TMagicTooltip>
|
|
15
|
-
</slot>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<TMagicPopover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
|
|
19
|
-
<div>
|
|
20
|
-
<slot name="page-bar-popover" :page="item">
|
|
21
|
-
<ToolButton
|
|
22
|
-
:data="{
|
|
23
|
-
type: 'button',
|
|
24
|
-
text: '复制',
|
|
25
|
-
icon: DocumentCopy,
|
|
26
|
-
handler: () => copy(item),
|
|
27
|
-
}"
|
|
28
|
-
></ToolButton>
|
|
29
|
-
<ToolButton
|
|
30
|
-
:data="{
|
|
31
|
-
type: 'button',
|
|
32
|
-
text: '删除',
|
|
33
|
-
icon: Delete,
|
|
34
|
-
handler: () => remove(item),
|
|
35
|
-
}"
|
|
36
|
-
></ToolButton>
|
|
37
|
-
</slot>
|
|
38
|
-
</div>
|
|
39
|
-
<template #reference>
|
|
40
|
-
<TMagicIcon class="m-editor-page-bar-menu-icon">
|
|
41
|
-
<CaretBottom></CaretBottom>
|
|
42
|
-
</TMagicIcon>
|
|
43
|
-
</template>
|
|
44
|
-
</TMagicPopover>
|
|
45
|
-
</div>
|
|
46
|
-
</PageBarScrollContainer>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script lang="ts" setup>
|
|
50
|
-
import { computed, inject } from 'vue';
|
|
51
|
-
import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
52
|
-
|
|
53
|
-
import { TMagicIcon, TMagicPopover, TMagicTooltip } from '@tmagic/design';
|
|
54
|
-
import type { MPage } from '@tmagic/schema';
|
|
55
|
-
|
|
56
|
-
import ToolButton from '@editor/components/ToolButton.vue';
|
|
57
|
-
import type { Services } from '@editor/type';
|
|
58
|
-
|
|
59
|
-
import PageBarScrollContainer from './PageBarScrollContainer.vue';
|
|
60
|
-
|
|
61
|
-
defineOptions({
|
|
62
|
-
name: 'MEditorPageBar',
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const services = inject<Services>('services');
|
|
66
|
-
const editorService = services?.editorService;
|
|
67
|
-
|
|
68
|
-
const root = computed(() => editorService?.get('root'));
|
|
69
|
-
|
|
70
|
-
const page = computed(() => editorService?.get('page'));
|
|
71
|
-
|
|
72
|
-
const switchPage = (page: MPage) => {
|
|
73
|
-
editorService?.select(page);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const copy = (node: MPage) => {
|
|
77
|
-
node && editorService?.copy(node);
|
|
78
|
-
editorService?.paste({
|
|
79
|
-
left: 0,
|
|
80
|
-
top: 0,
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const remove = (node: MPage) => {
|
|
85
|
-
editorService?.remove(node);
|
|
86
|
-
};
|
|
87
|
-
</script>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
style="
|
|
4
|
-
text-align: center;
|
|
5
|
-
padding: 5px 0;
|
|
6
|
-
font-size: 14px;
|
|
7
|
-
cursor: move;
|
|
8
|
-
display: flex;
|
|
9
|
-
justify-content: space-between;
|
|
10
|
-
align-items: center;
|
|
11
|
-
"
|
|
12
|
-
ref="target"
|
|
13
|
-
>
|
|
14
|
-
<TMagicTooltip placement="top" :content="pinned ? '取消置于顶层自动隐藏' : '置于顶层不消失'">
|
|
15
|
-
<MIcon
|
|
16
|
-
style="margin-left: 10px; cursor: pointer"
|
|
17
|
-
:icon="pinned ? PinnedIcon : PinIcon"
|
|
18
|
-
@click="pinHandler"
|
|
19
|
-
></MIcon>
|
|
20
|
-
</TMagicTooltip>
|
|
21
|
-
|
|
22
|
-
<span>可选组件</span>
|
|
23
|
-
|
|
24
|
-
<div style="margin-right: 10px">
|
|
25
|
-
<TMagicButton text size="small" @click="closeHandler">
|
|
26
|
-
<MIcon :icon="Close"></MIcon>
|
|
27
|
-
</TMagicButton>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<script lang="ts" setup>
|
|
33
|
-
import { ref } from 'vue';
|
|
34
|
-
import { Close } from '@element-plus/icons-vue';
|
|
35
|
-
import type { OnDrag } from 'gesto';
|
|
36
|
-
|
|
37
|
-
import { TMagicButton, TMagicTooltip } from '@tmagic/design';
|
|
38
|
-
|
|
39
|
-
import MIcon from '@editor/components/Icon.vue';
|
|
40
|
-
import { useGetSo } from '@editor/hooks/use-getso';
|
|
41
|
-
import PinIcon from '@editor/icons/PinIcon.vue';
|
|
42
|
-
import PinnedIcon from '@editor/icons/PinnedIcon.vue';
|
|
43
|
-
|
|
44
|
-
defineOptions({
|
|
45
|
-
name: 'MEditorNodeListMenuTitle',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const props = defineProps<{
|
|
49
|
-
pinned: boolean;
|
|
50
|
-
}>();
|
|
51
|
-
|
|
52
|
-
const emit = defineEmits<{
|
|
53
|
-
close: [];
|
|
54
|
-
'update:pinned': [pinned: boolean];
|
|
55
|
-
change: [e: OnDrag];
|
|
56
|
-
}>();
|
|
57
|
-
|
|
58
|
-
const pinHandler = () => {
|
|
59
|
-
emit('update:pinned', !props.pinned);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const closeHandler = () => {
|
|
63
|
-
emit('close');
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const target = ref<HTMLDivElement>();
|
|
67
|
-
useGetSo(target, emit);
|
|
68
|
-
</script>
|
package/src/theme/dep-list.scss
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
.m-editor-dep-list-panel {
|
|
2
|
-
.magic-editor-layer-tree {
|
|
3
|
-
padding-top: 48px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.search-wrapper {
|
|
7
|
-
display: flex;
|
|
8
|
-
align-items: center;
|
|
9
|
-
justify-content: center;
|
|
10
|
-
position: absolute;
|
|
11
|
-
top: 0;
|
|
12
|
-
width: 100%;
|
|
13
|
-
z-index: 1;
|
|
14
|
-
|
|
15
|
-
.search-input {
|
|
16
|
-
flex: 1;
|
|
17
|
-
position: relative;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.tmagic-design-button {
|
|
21
|
-
margin-right: 10px;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.list-container {
|
|
26
|
-
width: 100%;
|
|
27
|
-
overflow: hidden;
|
|
28
|
-
.list-item {
|
|
29
|
-
display: flex;
|
|
30
|
-
width: 100%;
|
|
31
|
-
align-items: center;
|
|
32
|
-
|
|
33
|
-
.right-tool {
|
|
34
|
-
display: flex;
|
|
35
|
-
width: fit-content !important;
|
|
36
|
-
align-items: center;
|
|
37
|
-
.edit-icon {
|
|
38
|
-
margin: 0 5px;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
.name {
|
|
42
|
-
white-space: nowrap;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
text-overflow: ellipsis;
|
|
45
|
-
width: 0 !important;
|
|
46
|
-
flex: 1;
|
|
47
|
-
line-height: 22px;
|
|
48
|
-
|
|
49
|
-
&.code {
|
|
50
|
-
color: #000;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&.hook {
|
|
54
|
-
color: #909399;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ComputedRef } from 'vue';
|
|
2
|
-
import { Id, MPage } from '@tmagic/schema';
|
|
3
|
-
import { LayerNodeStatus } from '../../../type';
|
|
4
|
-
export declare const useFilter: (nodeStatusMap: ComputedRef<Map<Id, LayerNodeStatus> | undefined>, page: ComputedRef<MPage | null | undefined>) => {
|
|
5
|
-
filterText: import("vue").Ref<string>;
|
|
6
|
-
filterTextChangeHandler(text: string): void;
|
|
7
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { MPage } from '@tmagic/schema';
|
|
2
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
|
|
3
|
-
"page-bar-title"?(_: {
|
|
4
|
-
page: MPage;
|
|
5
|
-
}): any;
|
|
6
|
-
"page-bar-popover"?(_: {
|
|
7
|
-
page: MPage;
|
|
8
|
-
}): any;
|
|
9
|
-
}>;
|
|
10
|
-
export default _default;
|
|
11
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
12
|
-
new (): {
|
|
13
|
-
$slots: S;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
|
|
2
|
-
default?(_: {}): any;
|
|
3
|
-
}>;
|
|
4
|
-
export default _default;
|
|
5
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
6
|
-
new (): {
|
|
7
|
-
$slots: S;
|
|
8
|
-
};
|
|
9
|
-
};
|