@tmagic/editor 1.3.6 → 1.3.8
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 +34 -11
- package/dist/tmagic-editor.js +1360 -957
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +1382 -977
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +17 -17
- package/src/Editor.vue +15 -7
- package/src/components/CodeBlockEditor.vue +2 -2
- package/src/components/ContentMenu.vue +5 -5
- 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 +1 -1
- package/src/components/TreeNode.vue +3 -3
- package/src/editorProps.ts +14 -4
- package/src/fields/PageFragmentSelect.vue +63 -0
- package/src/hooks/use-getso.ts +2 -2
- package/src/hooks/use-stage.ts +18 -1
- package/src/index.ts +3 -0
- package/src/initService.ts +15 -5
- package/src/layouts/AddPageBox.vue +16 -4
- package/src/layouts/CodeEditor.vue +2 -2
- package/src/layouts/Framework.vue +19 -3
- package/src/layouts/PropsPanel.vue +9 -7
- 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 +2 -0
- package/src/layouts/sidebar/layer/LayerMenu.vue +39 -27
- package/src/layouts/sidebar/layer/LayerPanel.vue +7 -1
- 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 +3 -3
- package/src/layouts/workspace/Workspace.vue +6 -7
- package/src/layouts/workspace/viewer/NodeListMenu.vue +2 -2
- package/src/layouts/workspace/viewer/Stage.vue +12 -5
- package/src/layouts/workspace/viewer/ViewerMenu.vue +93 -80
- package/src/services/dataSource.ts +17 -0
- package/src/services/dep.ts +4 -0
- package/src/services/editor.ts +66 -35
- package/src/services/history.ts +6 -2
- package/src/services/keybinding.ts +48 -13
- package/src/theme/code-block.scss +0 -16
- package/src/theme/page-bar.scss +18 -1
- package/src/theme/page-fragment-select.scss +14 -0
- package/src/theme/theme.scss +1 -0
- package/src/theme/tree.scss +6 -0
- package/src/type.ts +23 -7
- package/src/utils/content-menu.ts +2 -2
- package/src/utils/editor.ts +22 -15
- package/src/utils/operator.ts +4 -4
- package/types/components/ToolButton.vue.d.ts +2 -2
- package/types/editorProps.d.ts +11 -2
- package/types/fields/PageFragmentSelect.vue.d.ts +31 -0
- package/types/index.d.ts +1 -0
- package/types/layouts/AddPageBox.vue.d.ts +14 -1
- package/types/layouts/Framework.vue.d.ts +14 -1
- package/types/layouts/PropsPanel.vue.d.ts +19 -10
- package/types/layouts/page-bar/AddButton.vue.d.ts +16 -0
- 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/Sidebar.vue.d.ts +2 -0
- package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +22 -3
- package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +2 -0
- package/types/layouts/sidebar/layer/use-click.d.ts +25 -3
- package/types/layouts/sidebar/layer/use-keybinding.d.ts +1 -1
- package/types/layouts/workspace/Workspace.vue.d.ts +2 -0
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +2 -0
- package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +8 -0
- package/types/services/dataSource.d.ts +2 -0
- package/types/services/dep.d.ts +1 -0
- package/types/services/editor.d.ts +3 -2
- package/types/services/history.d.ts +3 -2
- package/types/services/keybinding.d.ts +21 -1
- package/types/type.d.ts +26 -12
- package/types/utils/editor.d.ts +9 -7
- package/src/layouts/workspace/PageBar.vue +0 -87
- package/types/layouts/workspace/PageBar.vue.d.ts +0 -15
- package/types/layouts/workspace/PageBarScrollContainer.vue.d.ts +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import KeyController, { KeyControllerEvent } from 'keycon';
|
|
2
2
|
|
|
3
|
-
import { isPage } from '@tmagic/utils';
|
|
3
|
+
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
4
4
|
|
|
5
5
|
import { KeyBindingCacheItem, KeyBindingCommand, KeyBindingItem } from '@editor/type';
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ class Keybinding extends BaseService {
|
|
|
19
19
|
[KeyBindingCommand.DELETE_NODE]: () => {
|
|
20
20
|
const nodes = editorService.get('nodes');
|
|
21
21
|
|
|
22
|
-
if (!nodes || isPage(nodes[0])) return;
|
|
22
|
+
if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0])) return;
|
|
23
23
|
editorService.remove(nodes);
|
|
24
24
|
},
|
|
25
25
|
[KeyBindingCommand.COPY_NODE]: () => {
|
|
@@ -29,7 +29,7 @@ class Keybinding extends BaseService {
|
|
|
29
29
|
[KeyBindingCommand.CUT_NODE]: () => {
|
|
30
30
|
const nodes = editorService.get('nodes');
|
|
31
31
|
|
|
32
|
-
if (!nodes || isPage(nodes[0])) return;
|
|
32
|
+
if (!nodes || isPage(nodes[0]) || isPageFragment(nodes[0])) return;
|
|
33
33
|
editorService.copy(nodes);
|
|
34
34
|
editorService.remove(nodes);
|
|
35
35
|
},
|
|
@@ -84,15 +84,29 @@ class Keybinding extends BaseService {
|
|
|
84
84
|
},
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
public
|
|
87
|
+
public registerCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>) {
|
|
88
88
|
this.commands[command] = handler;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated
|
|
93
|
+
*/
|
|
94
|
+
public registeCommand(command: string, handler: (e: KeyboardEvent) => void | Promise<void>) {
|
|
95
|
+
this.registerCommand(command, handler);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public unregisterCommand(command: string) {
|
|
92
99
|
delete this.commands[command];
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated
|
|
104
|
+
*/
|
|
105
|
+
public unregisteCommand(command: string) {
|
|
106
|
+
this.unregisterCommand(command);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public registerEl(name: string, el?: HTMLElement) {
|
|
96
110
|
if (name !== 'global' && !el) {
|
|
97
111
|
throw new Error('只有name为global可以不传el');
|
|
98
112
|
}
|
|
@@ -102,20 +116,34 @@ class Keybinding extends BaseService {
|
|
|
102
116
|
this.bind(name);
|
|
103
117
|
}
|
|
104
118
|
|
|
105
|
-
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated
|
|
121
|
+
*/
|
|
122
|
+
public registeEl(name: string, el?: HTMLElement) {
|
|
123
|
+
this.registerEl(name, el);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public unregisterEl(name: string) {
|
|
106
127
|
this.controllers.get(name)?.destroy();
|
|
107
128
|
this.controllers.delete(name);
|
|
108
129
|
this.bindingList.forEach((item) => {
|
|
109
|
-
item.
|
|
130
|
+
item.bound = false;
|
|
110
131
|
});
|
|
111
132
|
}
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated
|
|
136
|
+
*/
|
|
137
|
+
public unregisteEl(name: string) {
|
|
138
|
+
this.unregisterEl(name);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public register(maps: KeyBindingItem[]) {
|
|
114
142
|
for (const keybindingItem of maps) {
|
|
115
143
|
const { command, keybinding, when } = keybindingItem;
|
|
116
144
|
|
|
117
145
|
for (const [type = '', eventType = 'keydown'] of when) {
|
|
118
|
-
const cacheItem: KeyBindingCacheItem = { type, command, keybinding, eventType,
|
|
146
|
+
const cacheItem: KeyBindingCacheItem = { type, command, keybinding, eventType, bound: false };
|
|
119
147
|
|
|
120
148
|
this.bindingList.push(cacheItem);
|
|
121
149
|
}
|
|
@@ -124,6 +152,13 @@ class Keybinding extends BaseService {
|
|
|
124
152
|
this.bind();
|
|
125
153
|
}
|
|
126
154
|
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated
|
|
157
|
+
*/
|
|
158
|
+
public registe(map: KeyBindingItem[]) {
|
|
159
|
+
this.register(map);
|
|
160
|
+
}
|
|
161
|
+
|
|
127
162
|
public reset() {
|
|
128
163
|
this.controllers.forEach((keycon) => {
|
|
129
164
|
keycon.destroy();
|
|
@@ -138,13 +173,13 @@ class Keybinding extends BaseService {
|
|
|
138
173
|
|
|
139
174
|
private bind(name?: string) {
|
|
140
175
|
for (const item of this.bindingList) {
|
|
141
|
-
const { type, eventType, command, keybinding,
|
|
176
|
+
const { type, eventType, command, keybinding, bound } = item;
|
|
142
177
|
|
|
143
178
|
if (name && name !== type) {
|
|
144
179
|
continue;
|
|
145
180
|
}
|
|
146
181
|
|
|
147
|
-
if (
|
|
182
|
+
if (bound) {
|
|
148
183
|
continue;
|
|
149
184
|
}
|
|
150
185
|
|
|
@@ -166,7 +201,7 @@ class Keybinding extends BaseService {
|
|
|
166
201
|
}
|
|
167
202
|
});
|
|
168
203
|
|
|
169
|
-
item.
|
|
204
|
+
item.bound = true;
|
|
170
205
|
}
|
|
171
206
|
}
|
|
172
207
|
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
.m-editor-code-block-list {
|
|
2
2
|
height: 100%;
|
|
3
|
-
|
|
4
|
-
.list-container {
|
|
5
|
-
.list-item {
|
|
6
|
-
.codeIcon {
|
|
7
|
-
width: 22px;
|
|
8
|
-
height: 22px;
|
|
9
|
-
margin-right: 5px;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.compIcon {
|
|
13
|
-
width: 22px;
|
|
14
|
-
height: 22px;
|
|
15
|
-
margin-right: 5px;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
3
|
}
|
|
20
4
|
|
|
21
5
|
.m-fields-code-select {
|
package/src/theme/page-bar.scss
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
.m-editor-page-bar {
|
|
1
|
+
.m-editor-page-bar-tabs {
|
|
2
2
|
position: fixed;
|
|
3
3
|
bottom: 0;
|
|
4
4
|
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
|
|
7
|
+
.tmagic-design-button.m-editor-page-bar-switch-type-button {
|
|
8
|
+
margin-left: 7px;
|
|
9
|
+
position: relative;
|
|
10
|
+
top: 1px;
|
|
11
|
+
border-radius: 3px 3px 0 0;
|
|
12
|
+
border: 1px solid $--border-color;
|
|
13
|
+
border-bottom: 1px solid transparent;
|
|
14
|
+
|
|
15
|
+
&.active {
|
|
16
|
+
background-color: #f3f3f3;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.m-editor-page-bar {
|
|
5
22
|
display: flex;
|
|
6
23
|
width: 100%;
|
|
7
24
|
height: $--page-bar-height;
|
package/src/theme/theme.scss
CHANGED
package/src/theme/tree.scss
CHANGED
package/src/type.ts
CHANGED
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
import type { Component } from 'vue';
|
|
20
20
|
|
|
21
21
|
import type { ColumnConfig, FilterFunction, FormConfig, FormItem } from '@tmagic/form';
|
|
22
|
-
import type { CodeBlockContent, CodeBlockDSL, Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
22
|
+
import type { CodeBlockContent, CodeBlockDSL, Id, MApp, MContainer, MNode, MPage, MPageFragment } from '@tmagic/schema';
|
|
23
23
|
import type StageCore from '@tmagic/stage';
|
|
24
24
|
import type {
|
|
25
25
|
ContainerHighlightType,
|
|
26
26
|
CustomizeMoveableOptionsCallbackConfig,
|
|
27
|
+
GuidesOptions,
|
|
27
28
|
MoveableOptions,
|
|
28
29
|
RenderType,
|
|
29
30
|
UpdateDragEl,
|
|
@@ -53,13 +54,14 @@ export interface FrameworkSlots {
|
|
|
53
54
|
workspace(props: {}): any;
|
|
54
55
|
'props-panel'(props: {}): any;
|
|
55
56
|
'footer'(props: {}): any;
|
|
57
|
+
'page-bar'(props: {}): any;
|
|
58
|
+
'page-bar-title'(props: { page: MPage | MPageFragment }): any;
|
|
59
|
+
'page-bar-popover'(props: { page: MPage | MPageFragment }): any;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
export interface WorkspaceSlots {
|
|
59
63
|
stage(props: {}): any;
|
|
60
64
|
'workspace-content'(props: {}): any;
|
|
61
|
-
'page-bar-title'(props: { page: MPage }): any;
|
|
62
|
-
'page-bar-popover'(props: { page: MPage }): any;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
export interface ComponentListPanelSlots {
|
|
@@ -131,18 +133,23 @@ export interface StageOptions {
|
|
|
131
133
|
isContainer: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
132
134
|
updateDragEl: UpdateDragEl;
|
|
133
135
|
renderType: RenderType;
|
|
136
|
+
guidesOptions: Partial<GuidesOptions>;
|
|
137
|
+
disabledMultiSelect?: boolean;
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
export interface StoreState {
|
|
137
141
|
root: MApp | null;
|
|
138
|
-
page: MPage | null;
|
|
142
|
+
page: MPage | MPageFragment | null;
|
|
139
143
|
parent: MContainer | null;
|
|
140
144
|
node: MNode | null;
|
|
141
145
|
highlightNode: MNode | null;
|
|
142
146
|
nodes: MNode[];
|
|
143
147
|
stage: StageCore | null;
|
|
148
|
+
stageLoading: boolean;
|
|
144
149
|
modifiedNodeIds: Map<Id, Id>;
|
|
145
150
|
pageLength: number;
|
|
151
|
+
pageFragmentLength: number;
|
|
152
|
+
disabledMultiSelect: boolean;
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
export type StoreStateKey = keyof StoreState;
|
|
@@ -223,7 +230,7 @@ export interface UiState {
|
|
|
223
230
|
export interface EditorNodeInfo {
|
|
224
231
|
node: MNode | null;
|
|
225
232
|
parent: MContainer | null;
|
|
226
|
-
page: MPage | null;
|
|
233
|
+
page: MPage | MPageFragment | null;
|
|
227
234
|
}
|
|
228
235
|
|
|
229
236
|
export interface AddMNode {
|
|
@@ -488,7 +495,7 @@ export interface CodeParamStatement {
|
|
|
488
495
|
}
|
|
489
496
|
|
|
490
497
|
export interface StepValue {
|
|
491
|
-
data: MPage;
|
|
498
|
+
data: MPage | MPageFragment;
|
|
492
499
|
modifiedNodeIds: Map<Id, Id>;
|
|
493
500
|
nodeId: Id;
|
|
494
501
|
}
|
|
@@ -571,7 +578,7 @@ export interface KeyBindingCacheItem {
|
|
|
571
578
|
command: KeyBindingCommand | string;
|
|
572
579
|
keybinding?: string | string[];
|
|
573
580
|
eventType: 'keyup' | 'keydown';
|
|
574
|
-
|
|
581
|
+
bound: boolean;
|
|
575
582
|
}
|
|
576
583
|
|
|
577
584
|
export interface CodeSelectColConfig {
|
|
@@ -583,6 +590,15 @@ export interface CodeSelectColConfig {
|
|
|
583
590
|
display?: boolean | FilterFunction;
|
|
584
591
|
}
|
|
585
592
|
|
|
593
|
+
export interface PageFragmentSelectConfig {
|
|
594
|
+
type: 'page-fragment-select';
|
|
595
|
+
name: string;
|
|
596
|
+
text: string;
|
|
597
|
+
labelWidth?: number | string;
|
|
598
|
+
disabled?: boolean | FilterFunction;
|
|
599
|
+
display?: boolean | FilterFunction;
|
|
600
|
+
}
|
|
601
|
+
|
|
586
602
|
export interface DataSourceMethodSelectConfig {
|
|
587
603
|
type: 'data-source-method-select';
|
|
588
604
|
name: string;
|
|
@@ -2,7 +2,7 @@ import { computed, markRaw, Ref } from 'vue';
|
|
|
2
2
|
import { CopyDocument, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
|
3
3
|
|
|
4
4
|
import { Id, MContainer, NodeType } from '@tmagic/schema';
|
|
5
|
-
import { isPage } from '@tmagic/utils';
|
|
5
|
+
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
6
6
|
|
|
7
7
|
import ContentMenu from '@editor/components/ContentMenu.vue';
|
|
8
8
|
import type { MenuButton, Services } from '@editor/type';
|
|
@@ -15,7 +15,7 @@ export const useDeleteMenu = (): MenuButton => ({
|
|
|
15
15
|
icon: Delete,
|
|
16
16
|
display: (services) => {
|
|
17
17
|
const node = services?.editorService?.get('node');
|
|
18
|
-
return node?.type !== NodeType.ROOT && !isPage(node);
|
|
18
|
+
return node?.type !== NodeType.ROOT && !isPage(node) && !isPageFragment(node);
|
|
19
19
|
},
|
|
20
20
|
handler: (services) => {
|
|
21
21
|
const nodes = services?.editorService?.get('nodes');
|
package/src/utils/editor.ts
CHANGED
|
@@ -18,24 +18,29 @@
|
|
|
18
18
|
|
|
19
19
|
import serialize from 'serialize-javascript';
|
|
20
20
|
|
|
21
|
-
import type { Id, MApp, MContainer, MNode, MPage } from '@tmagic/schema';
|
|
21
|
+
import type { Id, MApp, MContainer, MNode, MPage, MPageFragment } from '@tmagic/schema';
|
|
22
22
|
import { NodeType } from '@tmagic/schema';
|
|
23
23
|
import type StageCore from '@tmagic/stage';
|
|
24
|
-
import { getNodePath, isNumber, isPage, isPop } from '@tmagic/utils';
|
|
24
|
+
import { getNodePath, isNumber, isPage, isPageFragment, isPop } from '@tmagic/utils';
|
|
25
25
|
|
|
26
26
|
import { Layout } from '@editor/type';
|
|
27
27
|
export const COPY_STORAGE_KEY = '$MagicEditorCopyData';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* 获取所有页面配置
|
|
31
|
-
* @param
|
|
31
|
+
* @param root DSL跟节点
|
|
32
32
|
* @returns 所有页面配置
|
|
33
33
|
*/
|
|
34
|
-
export const getPageList = (
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
export const getPageList = (root?: MApp | null): MPage[] => {
|
|
35
|
+
if (!root) return [];
|
|
36
|
+
if (!Array.isArray(root.items)) return [];
|
|
37
|
+
return root.items.filter((item) => isPage(item)) as MPage[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const getPageFragmentList = (root?: MApp | null): MPageFragment[] => {
|
|
41
|
+
if (!root) return [];
|
|
42
|
+
if (!Array.isArray(root.items)) return [];
|
|
43
|
+
return root.items.filter((item) => isPageFragment(item)) as MPageFragment[];
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
/**
|
|
@@ -43,22 +48,23 @@ export const getPageList = (app: MApp): MPage[] => {
|
|
|
43
48
|
* @param pages 所有页面配置
|
|
44
49
|
* @returns 所有页面名称
|
|
45
50
|
*/
|
|
46
|
-
export const getPageNameList = (pages: MPage[]): string[] =>
|
|
51
|
+
export const getPageNameList = (pages: (MPage | MPageFragment)[]): string[] =>
|
|
52
|
+
pages.map((page) => page.name || 'index');
|
|
47
53
|
|
|
48
54
|
/**
|
|
49
55
|
* 新增页面时,生成页面名称
|
|
50
56
|
* @param {Object} pageNameList 所有页面名称
|
|
51
57
|
* @returns {string}
|
|
52
58
|
*/
|
|
53
|
-
export const generatePageName = (pageNameList: string[]): string => {
|
|
59
|
+
export const generatePageName = (pageNameList: string[], type: NodeType.PAGE | NodeType.PAGE_FRAGMENT): string => {
|
|
54
60
|
let pageLength = pageNameList.length;
|
|
55
61
|
|
|
56
|
-
if (!pageLength) return
|
|
62
|
+
if (!pageLength) return `${type}_index`;
|
|
57
63
|
|
|
58
|
-
let pageName =
|
|
64
|
+
let pageName = `${type}_${pageLength}`;
|
|
59
65
|
while (pageNameList.includes(pageName)) {
|
|
60
66
|
pageLength += 1;
|
|
61
|
-
pageName =
|
|
67
|
+
pageName = `${type}_${pageLength}`;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
return pageName;
|
|
@@ -69,7 +75,8 @@ export const generatePageName = (pageNameList: string[]): string => {
|
|
|
69
75
|
* @param {Object} app 所有页面配置
|
|
70
76
|
* @returns {string}
|
|
71
77
|
*/
|
|
72
|
-
export const generatePageNameByApp = (app: MApp): string =>
|
|
78
|
+
export const generatePageNameByApp = (app: MApp, type: NodeType.PAGE | NodeType.PAGE_FRAGMENT): string =>
|
|
79
|
+
generatePageName(getPageNameList(type === 'page' ? getPageList(app) : getPageFragmentList(app)), type);
|
|
73
80
|
|
|
74
81
|
/**
|
|
75
82
|
* @param {Object} node
|
|
@@ -129,7 +136,7 @@ export const getInitPositionStyle = (style: Record<string, any> = {}, layout: La
|
|
|
129
136
|
return style;
|
|
130
137
|
};
|
|
131
138
|
|
|
132
|
-
export const
|
|
139
|
+
export const setChildrenLayout = (node: MContainer, layout: Layout) => {
|
|
133
140
|
node.items?.forEach((child: MNode) => {
|
|
134
141
|
setLayout(child, layout);
|
|
135
142
|
});
|
package/src/utils/operator.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { toRaw } from 'vue';
|
|
2
2
|
import { isEmpty } from 'lodash-es';
|
|
3
3
|
|
|
4
|
-
import { Id, MContainer, MNode } from '@tmagic/schema';
|
|
5
|
-
import { isPage } from '@tmagic/utils';
|
|
4
|
+
import { Id, MContainer, MNode, NodeType } from '@tmagic/schema';
|
|
5
|
+
import { isPage, isPageFragment } from '@tmagic/utils';
|
|
6
6
|
|
|
7
7
|
import editorService from '@editor/services/editor';
|
|
8
8
|
import propsService from '@editor/services/props';
|
|
@@ -58,8 +58,8 @@ export const beforePaste = async (position: PastePosition, config: MNode[]): Pro
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
const root = editorService.get('root');
|
|
61
|
-
if (isPage(pasteConfig) && root) {
|
|
62
|
-
pasteConfig.name = generatePageNameByApp(root);
|
|
61
|
+
if ((isPage(pasteConfig) || isPageFragment(pasteConfig)) && root) {
|
|
62
|
+
pasteConfig.name = generatePageNameByApp(root, isPage(pasteConfig) ? NodeType.PAGE : NodeType.PAGE_FRAGMENT);
|
|
63
63
|
}
|
|
64
64
|
return pasteConfig as MNode;
|
|
65
65
|
}),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MenuButton, MenuComponent } from '../type';
|
|
2
2
|
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
3
3
|
data?: MenuButton | MenuComponent | undefined;
|
|
4
|
-
eventType?: "
|
|
4
|
+
eventType?: "mousedown" | "mouseup" | "click" | undefined;
|
|
5
5
|
}>, {
|
|
6
6
|
data: () => {
|
|
7
7
|
type: string;
|
|
@@ -10,7 +10,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
10
10
|
eventType: string;
|
|
11
11
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
12
12
|
data?: MenuButton | MenuComponent | undefined;
|
|
13
|
-
eventType?: "
|
|
13
|
+
eventType?: "mousedown" | "mouseup" | "click" | undefined;
|
|
14
14
|
}>, {
|
|
15
15
|
data: () => {
|
|
16
16
|
type: string;
|
package/types/editorProps.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EventOption } from '@tmagic/core';
|
|
2
|
-
import { CustomTargetOptions } from '@tmagic/dep';
|
|
2
|
+
import type { CustomTargetOptions } from '@tmagic/dep';
|
|
3
3
|
import type { FormConfig, FormState } from '@tmagic/form';
|
|
4
4
|
import type { DataSourceSchema, Id, MApp, MNode } from '@tmagic/schema';
|
|
5
|
-
import StageCore, { ContainerHighlightType, CustomizeMoveableOptionsCallbackConfig, MoveableOptions, RenderType, UpdateDragEl } from '@tmagic/stage';
|
|
5
|
+
import StageCore, { ContainerHighlightType, type CustomizeMoveableOptionsCallbackConfig, type GuidesOptions, type MoveableOptions, RenderType, type UpdateDragEl } from '@tmagic/stage';
|
|
6
6
|
import type { ComponentGroup, DatasourceTypeOption, MenuBarData, MenuButton, MenuComponent, SideBarData, StageRect } from './type';
|
|
7
7
|
export interface EditorProps {
|
|
8
8
|
/** 页面初始值 */
|
|
@@ -62,6 +62,13 @@ export interface EditorProps {
|
|
|
62
62
|
extendFormState?: (state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
63
63
|
/** 自定义依赖收集器,复制组件时会将关联依赖一并复制 */
|
|
64
64
|
collectorOptions?: CustomTargetOptions;
|
|
65
|
+
/** 标尺配置 */
|
|
66
|
+
guidesOptions?: Partial<GuidesOptions>;
|
|
67
|
+
/** 禁止多选 */
|
|
68
|
+
disabledMultiSelect?: boolean;
|
|
69
|
+
/** 禁用页面片 */
|
|
70
|
+
disabledPageFragment?: boolean;
|
|
71
|
+
customContentMenu?: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
|
|
65
72
|
}
|
|
66
73
|
export declare const defaultEditorProps: {
|
|
67
74
|
componentGroupList: () => never[];
|
|
@@ -84,4 +91,6 @@ export declare const defaultEditorProps: {
|
|
|
84
91
|
containerHighlightType: ContainerHighlightType;
|
|
85
92
|
codeOptions: () => {};
|
|
86
93
|
renderType: RenderType;
|
|
94
|
+
disabledMultiSelect: boolean;
|
|
95
|
+
disabledPageFragment: boolean;
|
|
87
96
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FieldProps } from '@tmagic/form';
|
|
2
|
+
import type { PageFragmentSelectConfig } from '../type';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FieldProps<PageFragmentSelectConfig>>, {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
change: (...args: any[]) => void;
|
|
7
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<FieldProps<PageFragmentSelectConfig>>, {
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}>>> & {
|
|
10
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
}, {}>;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
16
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
17
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
18
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
19
|
+
} : {
|
|
20
|
+
type: import('vue').PropType<T[K]>;
|
|
21
|
+
required: true;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type __VLS_WithDefaults<P, D> = {
|
|
25
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
26
|
+
default: D[K];
|
|
27
|
+
}> : P[K];
|
|
28
|
+
};
|
|
29
|
+
type __VLS_Prettify<T> = {
|
|
30
|
+
[K in keyof T]: T[K];
|
|
31
|
+
} & {};
|
package/types/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export { default as LayoutContainer } from './components/SplitView.vue';
|
|
|
41
41
|
export { default as SplitView } from './components/SplitView.vue';
|
|
42
42
|
export { default as Resizer } from './components/Resizer.vue';
|
|
43
43
|
export { default as CodeBlockEditor } from './components/CodeBlockEditor.vue';
|
|
44
|
+
export { default as PageFragmentSelect } from './fields/PageFragmentSelect.vue';
|
|
44
45
|
declare const _default: {
|
|
45
46
|
install: (app: App, opt?: Partial<InstallOptions>) => void;
|
|
46
47
|
};
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
disabledPageFragment: boolean;
|
|
3
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
disabledPageFragment: boolean;
|
|
5
|
+
}>>>, {}, {}>;
|
|
2
6
|
export default _default;
|
|
7
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
8
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
9
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
10
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
11
|
+
} : {
|
|
12
|
+
type: import('vue').PropType<T[K]>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { FrameworkSlots } from '../type';
|
|
2
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
3
|
+
disabledPageFragment: boolean;
|
|
4
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
5
|
+
disabledPageFragment: boolean;
|
|
6
|
+
}>>>, {}, {}>, Readonly<FrameworkSlots>>;
|
|
3
7
|
export default _default;
|
|
8
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
9
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
10
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
11
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
12
|
+
} : {
|
|
13
|
+
type: import('vue').PropType<T[K]>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
4
17
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
5
18
|
new (): {
|
|
6
19
|
$slots: S;
|