@tmagic/editor 1.5.0-beta.8 → 1.5.0
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 +75 -16
- package/dist/tmagic-editor.js +797 -518
- package/dist/tmagic-editor.umd.cjs +802 -525
- package/package.json +13 -10
- package/src/Editor.vue +6 -1
- package/src/components/CodeBlockEditor.vue +11 -5
- package/src/components/CodeParams.vue +3 -3
- package/src/editorProps.ts +3 -1
- package/src/fields/Code.vue +1 -2
- package/src/fields/CodeSelect.vue +13 -11
- package/src/fields/CodeSelectCol.vue +32 -5
- package/src/fields/CondOpSelect.vue +5 -2
- package/src/fields/DataSourceFields.vue +31 -12
- package/src/fields/DataSourceMethods.vue +72 -14
- package/src/fields/DisplayConds.vue +8 -3
- package/src/fields/EventSelect.vue +28 -11
- package/src/fields/KeyValue.vue +15 -10
- package/src/fields/UISelect.vue +6 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/hooks/use-data-source-edit.ts +3 -2
- package/src/hooks/use-filter.ts +1 -1
- package/src/hooks/use-node-status.ts +2 -2
- package/src/initService.ts +177 -74
- package/src/layouts/Framework.vue +8 -4
- package/src/layouts/PropsPanel.vue +3 -3
- package/src/layouts/page-bar/AddButton.vue +29 -9
- package/src/layouts/page-bar/PageBar.vue +78 -65
- package/src/layouts/page-bar/PageBarScrollContainer.vue +82 -96
- package/src/layouts/page-bar/PageList.vue +5 -3
- package/src/layouts/page-bar/Search.vue +67 -0
- package/src/layouts/sidebar/Sidebar.vue +3 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +6 -1
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +7 -5
- package/src/layouts/sidebar/data-source/DataSourceList.vue +6 -1
- package/src/layouts/sidebar/layer/use-node-status.ts +2 -3
- package/src/layouts/workspace/Workspace.vue +5 -2
- package/src/layouts/workspace/viewer/Stage.vue +23 -5
- package/src/services/dataSource.ts +12 -5
- package/src/services/dep.ts +61 -13
- package/src/services/editor.ts +46 -51
- package/src/theme/page-bar.scss +38 -16
- package/src/theme/search-input.scss +1 -0
- package/src/type.ts +2 -1
- package/src/utils/data-source/formConfigs/http.ts +2 -0
- package/src/utils/data-source/index.ts +2 -2
- package/src/utils/editor.ts +78 -22
- package/src/utils/idle-task.ts +36 -4
- package/src/utils/props.ts +3 -3
- package/types/index.d.ts +835 -1169
- package/src/hooks/use-data-source-method.ts +0 -100
- package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-page-bar-tabs">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
<PageBarScrollContainer
|
|
4
|
+
ref="pageBarScrollContainer"
|
|
5
|
+
:page-bar-sort-options="pageBarSortOptions"
|
|
6
|
+
:length="list.length"
|
|
7
|
+
>
|
|
6
8
|
<template #prepend>
|
|
7
|
-
<
|
|
9
|
+
<slot name="page-bar-add-button"><AddButton></AddButton></slot>
|
|
10
|
+
|
|
11
|
+
<Search v-model:query="query"></Search>
|
|
8
12
|
<PageList :list="list">
|
|
9
13
|
<template #page-list-popover="{ list }"><slot name="page-list-popover" :list="list"></slot></template>
|
|
10
14
|
</PageList>
|
|
@@ -13,8 +17,9 @@
|
|
|
13
17
|
<div
|
|
14
18
|
v-for="item in list"
|
|
15
19
|
class="m-editor-page-bar-item"
|
|
20
|
+
ref="pageBarItems"
|
|
16
21
|
:key="item.id"
|
|
17
|
-
:page-id="item.id"
|
|
22
|
+
:data-page-id="item.id"
|
|
18
23
|
:class="{ active: page?.id === item.id }"
|
|
19
24
|
@click="switchPage(item.id)"
|
|
20
25
|
>
|
|
@@ -68,89 +73,59 @@ import { CaretBottom, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
|
68
73
|
|
|
69
74
|
import { type Id, type MPage, type MPageFragment, NodeType } from '@tmagic/core';
|
|
70
75
|
import { TMagicIcon, TMagicPopover } from '@tmagic/design';
|
|
71
|
-
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
72
76
|
|
|
73
77
|
import ToolButton from '@editor/components/ToolButton.vue';
|
|
74
78
|
import type { PageBarSortOptions, Services } from '@editor/type';
|
|
75
|
-
import { getPageFragmentList, getPageList } from '@editor/utils';
|
|
76
79
|
|
|
77
80
|
import AddButton from './AddButton.vue';
|
|
78
81
|
import PageBarScrollContainer from './PageBarScrollContainer.vue';
|
|
79
82
|
import PageList from './PageList.vue';
|
|
80
|
-
import
|
|
83
|
+
import Search from './Search.vue';
|
|
81
84
|
|
|
82
85
|
defineOptions({
|
|
83
86
|
name: 'MEditorPageBar',
|
|
84
87
|
});
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const props = withDefaults(
|
|
90
|
+
defineProps<{
|
|
91
|
+
disabledPageFragment: boolean;
|
|
92
|
+
pageBarSortOptions?: PageBarSortOptions;
|
|
93
|
+
filterFunction?: (page: MPage | MPageFragment, keyword: string) => boolean;
|
|
94
|
+
}>(),
|
|
95
|
+
{
|
|
96
|
+
filterFunction: (page, keyword) => page.name?.includes(keyword) || `${page.id}`.includes(keyword),
|
|
97
|
+
},
|
|
98
|
+
);
|
|
92
99
|
|
|
93
100
|
const services = inject<Services>('services');
|
|
94
101
|
const editorService = services?.editorService;
|
|
95
102
|
|
|
96
103
|
const root = computed(() => editorService?.get('root'));
|
|
97
104
|
const page = computed(() => editorService?.get('page'));
|
|
98
|
-
const pageList = computed(() => getPageList(root.value));
|
|
99
|
-
const pageFragmentList = computed(() => getPageFragmentList(root.value));
|
|
100
105
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(page) => {
|
|
109
|
-
if (!page) {
|
|
110
|
-
if (active.value === NodeType.PAGE) {
|
|
111
|
-
activePage.value = '';
|
|
112
|
-
}
|
|
113
|
-
if (active.value === NodeType.PAGE_FRAGMENT) {
|
|
114
|
-
activePageFragment.value = '';
|
|
115
|
-
}
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (isPage(page)) {
|
|
120
|
-
activePage.value = page?.id;
|
|
121
|
-
if (active.value !== NodeType.PAGE) {
|
|
122
|
-
active.value = NodeType.PAGE;
|
|
123
|
-
}
|
|
124
|
-
} else if (isPageFragment(page)) {
|
|
125
|
-
activePageFragment.value = page?.id;
|
|
126
|
-
if (active.value !== NodeType.PAGE_FRAGMENT) {
|
|
127
|
-
active.value = NodeType.PAGE_FRAGMENT;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
immediate: true,
|
|
133
|
-
},
|
|
134
|
-
);
|
|
106
|
+
const query = ref<{
|
|
107
|
+
pageType: NodeType[];
|
|
108
|
+
keyword: string;
|
|
109
|
+
}>({
|
|
110
|
+
pageType: [NodeType.PAGE, NodeType.PAGE_FRAGMENT],
|
|
111
|
+
keyword: '',
|
|
112
|
+
});
|
|
135
113
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
switchPage(activePage.value);
|
|
143
|
-
return;
|
|
114
|
+
const list = computed(() => {
|
|
115
|
+
const { pageType, keyword } = query.value;
|
|
116
|
+
if (pageType.length === 0) {
|
|
117
|
+
return [];
|
|
144
118
|
}
|
|
145
119
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
120
|
+
return (root.value?.items || []).filter((item) => {
|
|
121
|
+
if (pageType.includes(item.type)) {
|
|
122
|
+
if (keyword) {
|
|
123
|
+
return props.filterFunction(item, keyword);
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
151
126
|
}
|
|
152
|
-
|
|
153
|
-
}
|
|
127
|
+
return false;
|
|
128
|
+
});
|
|
154
129
|
});
|
|
155
130
|
|
|
156
131
|
const switchPage = (id: Id) => {
|
|
@@ -168,4 +143,42 @@ const copy = (node: MPage | MPageFragment) => {
|
|
|
168
143
|
const remove = (node: MPage | MPageFragment) => {
|
|
169
144
|
editorService?.remove(node);
|
|
170
145
|
};
|
|
146
|
+
|
|
147
|
+
const pageBarScrollContainer = ref<InstanceType<typeof PageBarScrollContainer>>();
|
|
148
|
+
const pageBarItems = ref<HTMLDivElement[]>();
|
|
149
|
+
watch(page, (page) => {
|
|
150
|
+
if (
|
|
151
|
+
!page ||
|
|
152
|
+
!pageBarScrollContainer.value?.itemsContainerWidth ||
|
|
153
|
+
!pageBarItems.value ||
|
|
154
|
+
pageBarItems.value.length < 2
|
|
155
|
+
) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const firstItem = pageBarItems.value[0];
|
|
160
|
+
const lastItem = pageBarItems.value[pageBarItems.value.length - 1];
|
|
161
|
+
|
|
162
|
+
if (page.id === firstItem.dataset.pageId) {
|
|
163
|
+
pageBarScrollContainer.value.scroll('start');
|
|
164
|
+
} else if (page.id === lastItem.dataset.pageId) {
|
|
165
|
+
pageBarScrollContainer.value.scroll('end');
|
|
166
|
+
} else {
|
|
167
|
+
const pageItem = pageBarItems.value.find((item) => item.dataset.pageId === page.id);
|
|
168
|
+
if (!pageItem) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const pageItemRect = pageItem.getBoundingClientRect();
|
|
173
|
+
const offsetLeft = pageItemRect.left - firstItem.getBoundingClientRect().left;
|
|
174
|
+
const { itemsContainerWidth } = pageBarScrollContainer.value;
|
|
175
|
+
|
|
176
|
+
const left = itemsContainerWidth - offsetLeft - pageItemRect.width;
|
|
177
|
+
|
|
178
|
+
const translateLeft = pageBarScrollContainer.value.getTranslateLeft();
|
|
179
|
+
if (offsetLeft + translateLeft < 0 || offsetLeft + pageItemRect.width > itemsContainerWidth - translateLeft) {
|
|
180
|
+
pageBarScrollContainer.value.scrollTo(left);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
171
184
|
</script>
|
|
@@ -1,42 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-page-bar" ref="pageBar">
|
|
3
3
|
<slot name="prepend"></slot>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<Icon :icon="ArrowLeftBold"></Icon>
|
|
4
|
+
<div v-if="length" class="m-editor-page-bar-items" ref="itemsContainer">
|
|
5
|
+
<slot></slot>
|
|
7
6
|
</div>
|
|
8
7
|
|
|
9
8
|
<div
|
|
10
|
-
v-if="
|
|
11
|
-
class="m-editor-page-bar-
|
|
12
|
-
|
|
13
|
-
:style="`width: ${itemsContainerWidth}px`"
|
|
9
|
+
v-if="canScroll"
|
|
10
|
+
class="m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-item-left-icon"
|
|
11
|
+
@click="scroll('left')"
|
|
14
12
|
>
|
|
15
|
-
<
|
|
13
|
+
<Icon :icon="ArrowLeftBold"></Icon>
|
|
16
14
|
</div>
|
|
17
15
|
|
|
18
|
-
<div
|
|
16
|
+
<div
|
|
17
|
+
v-if="canScroll"
|
|
18
|
+
class="m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-item-right-icon"
|
|
19
|
+
@click="scroll('right')"
|
|
20
|
+
>
|
|
19
21
|
<Icon :icon="ArrowRightBold"></Icon>
|
|
20
22
|
</div>
|
|
21
23
|
</div>
|
|
22
24
|
</template>
|
|
23
25
|
|
|
24
26
|
<script setup lang="ts">
|
|
25
|
-
import {
|
|
26
|
-
computed,
|
|
27
|
-
type ComputedRef,
|
|
28
|
-
inject,
|
|
29
|
-
nextTick,
|
|
30
|
-
onBeforeUnmount,
|
|
31
|
-
onMounted,
|
|
32
|
-
ref,
|
|
33
|
-
watch,
|
|
34
|
-
type WatchStopHandle,
|
|
35
|
-
} from 'vue';
|
|
27
|
+
import { computed, inject, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
|
36
28
|
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
|
37
|
-
import Sortable, { SortableEvent } from 'sortablejs';
|
|
29
|
+
import Sortable, { type SortableEvent } from 'sortablejs';
|
|
38
30
|
|
|
39
|
-
import { Id
|
|
31
|
+
import type { Id } from '@tmagic/core';
|
|
40
32
|
|
|
41
33
|
import Icon from '@editor/components/Icon.vue';
|
|
42
34
|
import type { PageBarSortOptions, Services } from '@editor/type';
|
|
@@ -46,8 +38,8 @@ defineOptions({
|
|
|
46
38
|
});
|
|
47
39
|
|
|
48
40
|
const props = defineProps<{
|
|
49
|
-
type: NodeType.PAGE | NodeType.PAGE_FRAGMENT;
|
|
50
41
|
pageBarSortOptions?: PageBarSortOptions;
|
|
42
|
+
length: number;
|
|
51
43
|
}>();
|
|
52
44
|
|
|
53
45
|
const services = inject<Services>('services');
|
|
@@ -63,11 +55,12 @@ const showPageListButton = computed(() => uiService?.get('showPageListButton'));
|
|
|
63
55
|
const itemsContainerWidth = ref(0);
|
|
64
56
|
|
|
65
57
|
const setCanScroll = () => {
|
|
66
|
-
//
|
|
58
|
+
// 减去新增、搜索、页面列表、左移、右移5个按钮的宽度
|
|
67
59
|
// 37 = icon width 16 + padding 10 * 2 + border-right 1
|
|
68
60
|
itemsContainerWidth.value =
|
|
69
61
|
(pageBar.value?.clientWidth || 0) -
|
|
70
62
|
37 * 2 -
|
|
63
|
+
37 -
|
|
71
64
|
(showAddPageButton.value ? 37 : 21) -
|
|
72
65
|
(showPageListButton.value ? 37 : 0);
|
|
73
66
|
|
|
@@ -94,99 +87,92 @@ onBeforeUnmount(() => {
|
|
|
94
87
|
let translateLeft = 0;
|
|
95
88
|
|
|
96
89
|
const scroll = (type: 'left' | 'right' | 'start' | 'end') => {
|
|
97
|
-
if (!itemsContainer.value) return;
|
|
90
|
+
if (!itemsContainer.value || !canScroll.value) return;
|
|
98
91
|
|
|
99
92
|
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
100
93
|
|
|
101
94
|
if (type === 'left') {
|
|
102
|
-
translateLeft
|
|
103
|
-
|
|
104
|
-
if (translateLeft > 0) {
|
|
105
|
-
translateLeft = 0;
|
|
106
|
-
}
|
|
95
|
+
scrollTo(translateLeft + 200);
|
|
107
96
|
} else if (type === 'right') {
|
|
108
|
-
translateLeft
|
|
109
|
-
|
|
110
|
-
if (-translateLeft > maxScrollLeft) {
|
|
111
|
-
translateLeft = -maxScrollLeft;
|
|
112
|
-
}
|
|
97
|
+
scrollTo(translateLeft - 200);
|
|
113
98
|
} else if (type === 'start') {
|
|
114
|
-
|
|
99
|
+
scrollTo(0);
|
|
115
100
|
} else if (type === 'end') {
|
|
116
|
-
|
|
101
|
+
scrollTo(-maxScrollLeft);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const scrollTo = (value: number) => {
|
|
106
|
+
if (!itemsContainer.value || !canScroll.value) return;
|
|
107
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
108
|
+
|
|
109
|
+
if (value >= 0) {
|
|
110
|
+
value = 0;
|
|
117
111
|
}
|
|
118
112
|
|
|
113
|
+
if (-value > maxScrollLeft) {
|
|
114
|
+
value = -maxScrollLeft;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
translateLeft = value;
|
|
118
|
+
|
|
119
119
|
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
setTimeout(() => {
|
|
130
|
-
setCanScroll();
|
|
131
|
-
if (length < preLength) {
|
|
122
|
+
watch(
|
|
123
|
+
() => props.length,
|
|
124
|
+
(length = 0, preLength = 0) => {
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
setCanScroll();
|
|
127
|
+
nextTick(() => {
|
|
128
|
+
if (length < preLength || preLength === 0) {
|
|
132
129
|
scroll('start');
|
|
133
130
|
} else {
|
|
134
131
|
scroll('end');
|
|
135
132
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
onUpdate: async (event: SortableEvent) => {
|
|
149
|
-
await editorService?.sort(
|
|
150
|
-
beforeDragList[event.oldIndex as number],
|
|
151
|
-
beforeDragList[event.newIndex as number],
|
|
152
|
-
);
|
|
153
|
-
if (typeof props.pageBarSortOptions?.afterUpdate === 'function') {
|
|
154
|
-
await props.pageBarSortOptions.afterUpdate(event, sortable);
|
|
155
|
-
}
|
|
156
|
-
},
|
|
133
|
+
});
|
|
134
|
+
if (length > 1) {
|
|
135
|
+
const el = document.querySelector('.m-editor-page-bar-items') as HTMLElement;
|
|
136
|
+
let beforeDragList: Id[] = [];
|
|
137
|
+
const options = {
|
|
138
|
+
...{
|
|
139
|
+
dataIdAttr: 'page-id', // 获取排序后的数据
|
|
140
|
+
onStart: async (event: SortableEvent) => {
|
|
141
|
+
if (typeof props.pageBarSortOptions?.beforeStart === 'function') {
|
|
142
|
+
await props.pageBarSortOptions.beforeStart(event, sortable);
|
|
143
|
+
}
|
|
144
|
+
beforeDragList = sortable.toArray();
|
|
157
145
|
},
|
|
158
|
-
|
|
159
|
-
|
|
146
|
+
onUpdate: async (event: SortableEvent) => {
|
|
147
|
+
await editorService?.sort(
|
|
148
|
+
beforeDragList[event.oldIndex as number],
|
|
149
|
+
beforeDragList[event.newIndex as number],
|
|
150
|
+
);
|
|
151
|
+
if (typeof props.pageBarSortOptions?.afterUpdate === 'function') {
|
|
152
|
+
await props.pageBarSortOptions.afterUpdate(event, sortable);
|
|
153
|
+
}
|
|
160
154
|
},
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
let unWatchPageLength: WatchStopHandle | null;
|
|
173
|
-
let unWatchPageFragmentLength: WatchStopHandle | null;
|
|
174
|
-
|
|
175
|
-
watch(
|
|
176
|
-
() => props.type,
|
|
177
|
-
(type) => {
|
|
178
|
-
if (type === NodeType.PAGE) {
|
|
179
|
-
unWatchPageFragmentLength?.();
|
|
180
|
-
unWatchPageFragmentLength = null;
|
|
181
|
-
unWatchPageLength = crateWatchLength(pageLength);
|
|
182
|
-
} else {
|
|
183
|
-
unWatchPageLength?.();
|
|
184
|
-
unWatchPageLength = null;
|
|
185
|
-
unWatchPageFragmentLength = crateWatchLength(pageFragmentLength);
|
|
186
|
-
}
|
|
155
|
+
},
|
|
156
|
+
...{
|
|
157
|
+
...(props.pageBarSortOptions ? props.pageBarSortOptions : {}),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
if (!el) return;
|
|
161
|
+
const sortable = new Sortable(el, options);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
187
164
|
},
|
|
188
165
|
{
|
|
189
166
|
immediate: true,
|
|
190
167
|
},
|
|
191
168
|
);
|
|
169
|
+
|
|
170
|
+
defineExpose({
|
|
171
|
+
itemsContainerWidth,
|
|
172
|
+
scroll,
|
|
173
|
+
scrollTo,
|
|
174
|
+
getTranslateLeft() {
|
|
175
|
+
return translateLeft;
|
|
176
|
+
},
|
|
177
|
+
});
|
|
192
178
|
</script>
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
:data="{
|
|
19
19
|
type: 'button',
|
|
20
20
|
text: item.devconfig?.tabName || item.name || item.id,
|
|
21
|
+
className: item.id === page?.id ? 'active' : '',
|
|
21
22
|
handler: () => switchPage(item.id),
|
|
22
23
|
}"
|
|
23
24
|
:key="index"
|
|
@@ -47,7 +48,7 @@ defineOptions({
|
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
defineProps<{
|
|
50
|
-
list: MPage
|
|
51
|
+
list: (MPage | MPageFragment)[];
|
|
51
52
|
}>();
|
|
52
53
|
|
|
53
54
|
const services = inject<Services>('services');
|
|
@@ -55,7 +56,8 @@ const uiService = services?.uiService;
|
|
|
55
56
|
const editorService = services?.editorService;
|
|
56
57
|
|
|
57
58
|
const showPageListButton = computed(() => uiService?.get('showPageListButton'));
|
|
58
|
-
const
|
|
59
|
-
|
|
59
|
+
const page = computed(() => editorService?.get('page'));
|
|
60
|
+
const switchPage = async (id: Id) => {
|
|
61
|
+
await editorService?.select(id);
|
|
60
62
|
};
|
|
61
63
|
</script>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-search">
|
|
3
|
+
<Icon :icon="Search" @click="visible = !visible" :class="{ 'icon-active': visible }"></Icon>
|
|
4
|
+
<Teleport to=".m-editor-page-bar-tabs" v-if="visible">
|
|
5
|
+
<MForm
|
|
6
|
+
v-if="query"
|
|
7
|
+
class="m-editor-page-bar-search-panel"
|
|
8
|
+
:inline="true"
|
|
9
|
+
:config="formConfig"
|
|
10
|
+
:init-values="query"
|
|
11
|
+
:prevent-submit-default="true"
|
|
12
|
+
@change="onFormChange"
|
|
13
|
+
></MForm>
|
|
14
|
+
</Teleport>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { ref } from 'vue';
|
|
20
|
+
import { Search } from '@element-plus/icons-vue';
|
|
21
|
+
|
|
22
|
+
import { NodeType } from '@tmagic/core';
|
|
23
|
+
import { createForm, MForm } from '@tmagic/form';
|
|
24
|
+
|
|
25
|
+
import Icon from '@editor/components/Icon.vue';
|
|
26
|
+
|
|
27
|
+
interface Query {
|
|
28
|
+
pageType: NodeType[];
|
|
29
|
+
keyword: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits<{
|
|
33
|
+
search: [value: Query];
|
|
34
|
+
}>();
|
|
35
|
+
|
|
36
|
+
const query = defineModel<Query>('query');
|
|
37
|
+
|
|
38
|
+
const formConfig = createForm([
|
|
39
|
+
{
|
|
40
|
+
type: 'checkbox-group',
|
|
41
|
+
name: 'pageType',
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
value: NodeType.PAGE,
|
|
45
|
+
text: '页面',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: NodeType.PAGE_FRAGMENT,
|
|
49
|
+
text: '页面片段',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'keyword',
|
|
55
|
+
type: 'text',
|
|
56
|
+
placeholder: '请输入关键字',
|
|
57
|
+
clearable: true,
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
const visible = ref(false);
|
|
62
|
+
|
|
63
|
+
const onFormChange = (values: Query) => {
|
|
64
|
+
query.value = values;
|
|
65
|
+
emit('search', values);
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
<div
|
|
21
21
|
class="m-editor-sidebar-content"
|
|
22
|
+
:class="{ 'm-editor-dep-collecting': collecting }"
|
|
22
23
|
v-for="(config, index) in sideBarItems"
|
|
23
24
|
:key="config.$key ?? index"
|
|
24
25
|
v-show="[config.text, config.$key, `${index}`].includes(activeTabName)"
|
|
@@ -197,6 +198,8 @@ const props = withDefaults(
|
|
|
197
198
|
|
|
198
199
|
const services = inject<Services>('services');
|
|
199
200
|
|
|
201
|
+
const collecting = computed(() => services?.depService.get('collecting'));
|
|
202
|
+
|
|
200
203
|
const columnLeftWidth = computed(() => services?.uiService.get('columnWidth')[ColumnLayout.LEFT] || 0);
|
|
201
204
|
const { height: editorContentHeight } = useEditorContentHeight();
|
|
202
205
|
const columnLeftHeight = ref(0);
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<template #tree-node-tool="{ data }">
|
|
22
|
+
<TMagicTag v-if="collecting && data.type === 'code'" type="info" size="small" style="margin-right: 5px"
|
|
23
|
+
>依赖收集中</TMagicTag
|
|
24
|
+
>
|
|
22
25
|
<TMagicTooltip v-if="data.type === 'code'" effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
|
|
23
26
|
<Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editCode(`${data.key}`)"></Icon>
|
|
24
27
|
</TMagicTooltip>
|
|
@@ -36,7 +39,7 @@ import { Close, Edit, View } from '@element-plus/icons-vue';
|
|
|
36
39
|
|
|
37
40
|
import type { Id, MNode } from '@tmagic/core';
|
|
38
41
|
import { DepTargetType } from '@tmagic/core';
|
|
39
|
-
import { tMagicMessage, tMagicMessageBox, TMagicTooltip } from '@tmagic/design';
|
|
42
|
+
import { tMagicMessage, tMagicMessageBox, TMagicTag, TMagicTooltip } from '@tmagic/design';
|
|
40
43
|
|
|
41
44
|
import Icon from '@editor/components/Icon.vue';
|
|
42
45
|
import Tree from '@editor/components/Tree.vue';
|
|
@@ -64,6 +67,8 @@ const emit = defineEmits<{
|
|
|
64
67
|
const services = inject<Services>('services');
|
|
65
68
|
const { codeBlockService, depService, editorService } = services || {};
|
|
66
69
|
|
|
70
|
+
const collecting = computed(() => depService?.get('collecting'));
|
|
71
|
+
|
|
67
72
|
// 代码块列表
|
|
68
73
|
const codeList = computed<TreeNodeData[]>(() =>
|
|
69
74
|
Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
|
|
@@ -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
|
+
import type { DataSourceSchema } from '@tmagic/core';
|
|
28
28
|
import { tMagicMessage } from '@tmagic/design';
|
|
29
|
-
import { FormConfig, MFormBox } from '@tmagic/form';
|
|
29
|
+
import { type ContainerChangeEventData, type FormConfig, MFormBox } from '@tmagic/form';
|
|
30
30
|
|
|
31
31
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
32
32
|
import { useEditorContentHeight } from '@editor/hooks';
|
|
@@ -46,7 +46,9 @@ const props = defineProps<{
|
|
|
46
46
|
const boxVisible = defineModel<boolean>('visible', { default: false });
|
|
47
47
|
const width = defineModel<number>('width', { default: 670 });
|
|
48
48
|
|
|
49
|
-
const emit = defineEmits
|
|
49
|
+
const emit = defineEmits<{
|
|
50
|
+
submit: [v: any, eventData: ContainerChangeEventData];
|
|
51
|
+
}>();
|
|
50
52
|
|
|
51
53
|
const services = inject<Services>('services');
|
|
52
54
|
|
|
@@ -63,8 +65,8 @@ watchEffect(() => {
|
|
|
63
65
|
dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
|
|
64
66
|
});
|
|
65
67
|
|
|
66
|
-
const submitHandler = (values: any) => {
|
|
67
|
-
emit('submit', values);
|
|
68
|
+
const submitHandler = (values: any, data: ContainerChangeEventData) => {
|
|
69
|
+
emit('submit', values, data);
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
const errorHandler = (error: any) => {
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
</template>
|
|
20
20
|
<template #tree-node-tool="{ data }">
|
|
21
|
+
<TMagicTag v-if="collecting && data.type === 'ds'" type="info" size="small" style="margin-right: 5px"
|
|
22
|
+
>依赖收集中</TMagicTag
|
|
23
|
+
>
|
|
21
24
|
<TMagicTooltip v-if="data.type === 'ds'" effect="dark" :content="editable ? '编辑' : '查看'" placement="bottom">
|
|
22
25
|
<Icon :icon="editable ? Edit : View" class="edit-icon" @click.stop="editHandler(`${data.key}`)"></Icon>
|
|
23
26
|
</TMagicTooltip>
|
|
@@ -34,7 +37,7 @@ import { computed, inject } from 'vue';
|
|
|
34
37
|
import { Close, Edit, View } from '@element-plus/icons-vue';
|
|
35
38
|
|
|
36
39
|
import { DepData, DepTargetType, Id, MNode } from '@tmagic/core';
|
|
37
|
-
import { tMagicMessageBox, TMagicTooltip } from '@tmagic/design';
|
|
40
|
+
import { tMagicMessageBox, TMagicTag, TMagicTooltip } from '@tmagic/design';
|
|
38
41
|
|
|
39
42
|
import Icon from '@editor/components/Icon.vue';
|
|
40
43
|
import Tree from '@editor/components/Tree.vue';
|
|
@@ -60,6 +63,8 @@ const emit = defineEmits<{
|
|
|
60
63
|
|
|
61
64
|
const { depService, editorService, dataSourceService } = inject<Services>('services') || {};
|
|
62
65
|
|
|
66
|
+
const collecting = computed(() => depService?.get('collecting'));
|
|
67
|
+
|
|
63
68
|
const editable = computed(() => dataSourceService?.get('editable') ?? true);
|
|
64
69
|
|
|
65
70
|
const dataSources = computed(() => dataSourceService?.get('dataSources') || []);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { computed, ref, watch } from 'vue';
|
|
2
2
|
|
|
3
3
|
import type { Id, MNode, MPage, MPageFragment } from '@tmagic/core';
|
|
4
|
-
import { getNodePath, isPage, isPageFragment } from '@tmagic/utils';
|
|
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>) => {
|