@tmagic/editor 1.3.16 → 1.4.0-beta.1
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 +11 -3
- package/dist/tmagic-editor.js +847 -523
- package/dist/tmagic-editor.umd.cjs +862 -538
- package/package.json +23 -21
- package/src/components/CodeBlockEditor.vue +50 -24
- package/src/components/FloatingBox.vue +53 -12
- package/src/fields/Code.vue +12 -10
- package/src/fields/CodeLink.vue +9 -9
- package/src/fields/CodeSelect.vue +7 -5
- package/src/fields/CodeSelectCol.vue +1 -1
- package/src/fields/DataSourceFieldSelect.vue +118 -27
- package/src/fields/DataSourceFields.vue +10 -3
- package/src/fields/DataSourceInput.vue +7 -7
- package/src/fields/DataSourceMethodSelect.vue +1 -1
- package/src/fields/DataSourceMethods.vue +3 -3
- package/src/fields/DataSourceMocks.vue +3 -3
- package/src/fields/DataSourceSelect.vue +6 -18
- package/src/fields/EventSelect.vue +1 -1
- package/src/fields/KeyValue.vue +8 -8
- package/src/fields/PageFragmentSelect.vue +1 -1
- package/src/fields/UISelect.vue +5 -5
- package/src/hooks/use-code-block-edit.ts +0 -1
- package/src/index.ts +2 -2
- package/src/layouts/NavMenu.vue +21 -2
- package/src/layouts/sidebar/Sidebar.vue +5 -0
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +0 -1
- package/src/services/BaseService.ts +5 -2
- package/src/services/codeBlock.ts +14 -8
- package/src/services/dataSource.ts +39 -26
- package/src/services/editor.ts +46 -25
- package/src/services/events.ts +4 -4
- package/src/services/props.ts +44 -35
- package/src/services/stageOverlay.ts +14 -7
- package/src/services/storage.ts +14 -8
- package/src/services/ui.ts +20 -19
- package/src/theme/code-editor.scss +6 -0
- package/src/theme/floating-box.scss +2 -0
- package/src/theme/sidebar.scss +6 -3
- package/src/type.ts +81 -37
- package/src/utils/operator.ts +37 -39
- package/src/utils/props.ts +174 -37
- package/types/components/CodeBlockEditor.vue.d.ts +4 -4
- package/types/components/CodeParams.vue.d.ts +5 -5
- package/types/components/ContentMenu.vue.d.ts +12 -12
- package/types/components/FloatingBox.vue.d.ts +14 -12
- package/types/components/Icon.vue.d.ts +3 -3
- package/types/components/Resizer.vue.d.ts +3 -3
- package/types/components/ScrollBar.vue.d.ts +3 -3
- package/types/components/ScrollViewer.vue.d.ts +12 -12
- package/types/components/SearchInput.vue.d.ts +1 -1
- package/types/components/SplitView.vue.d.ts +11 -11
- package/types/components/ToolButton.vue.d.ts +13 -13
- package/types/components/Tree.vue.d.ts +24 -14
- package/types/components/TreeNode.vue.d.ts +22 -12
- package/types/fields/Code.vue.d.ts +14 -14
- package/types/fields/CodeLink.vue.d.ts +6 -10
- package/types/fields/CodeSelect.vue.d.ts +14 -14
- package/types/fields/CodeSelectCol.vue.d.ts +11 -11
- package/types/fields/DataSourceFieldSelect.vue.d.ts +11 -11
- package/types/fields/DataSourceFields.vue.d.ts +11 -11
- package/types/fields/DataSourceInput.vue.d.ts +14 -18
- package/types/fields/DataSourceMethodSelect.vue.d.ts +11 -11
- package/types/fields/DataSourceMethods.vue.d.ts +11 -11
- package/types/fields/DataSourceMocks.vue.d.ts +11 -11
- package/types/fields/DataSourceSelect.vue.d.ts +13 -26
- package/types/fields/EventSelect.vue.d.ts +3 -3
- package/types/fields/KeyValue.vue.d.ts +14 -18
- package/types/fields/PageFragmentSelect.vue.d.ts +11 -11
- package/types/fields/UISelect.vue.d.ts +8 -4
- package/types/hooks/use-code-block-edit.d.ts +51 -89
- package/types/hooks/use-data-source-method.d.ts +51 -89
- package/types/hooks/use-node-status.d.ts +6 -1
- package/types/icons/AppManageIcon.vue.d.ts +1 -1
- package/types/icons/CenterIcon.vue.d.ts +1 -1
- package/types/icons/CodeIcon.vue.d.ts +1 -1
- package/types/icons/FolderMinusIcon.vue.d.ts +1 -1
- package/types/icons/PinIcon.vue.d.ts +1 -1
- package/types/icons/PinnedIcon.vue.d.ts +1 -1
- package/types/layouts/AddPageBox.vue.d.ts +3 -3
- package/types/layouts/CodeEditor.vue.d.ts +12 -12
- package/types/layouts/Framework.vue.d.ts +9 -9
- package/types/layouts/NavMenu.vue.d.ts +11 -11
- package/types/layouts/PropsPanel.vue.d.ts +193 -243
- package/types/layouts/page-bar/AddButton.vue.d.ts +3 -3
- package/types/layouts/page-bar/PageBar.vue.d.ts +8 -8
- package/types/layouts/page-bar/PageBarScrollContainer.vue.d.ts +8 -8
- package/types/layouts/page-bar/SwitchTypeButton.vue.d.ts +3 -3
- package/types/layouts/sidebar/ComponentListPanel.vue.d.ts +1 -1
- package/types/layouts/sidebar/Sidebar.vue.d.ts +12 -12
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +10 -10
- package/types/layouts/sidebar/code-block/CodeBlockListPanel.vue.d.ts +9 -9
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -3
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +3 -3
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +9 -9
- package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +11 -11
- package/types/layouts/sidebar/layer/LayerNodeTool.vue.d.ts +3 -3
- package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +9 -9
- package/types/layouts/sidebar/layer/use-click.d.ts +42 -76
- package/types/layouts/sidebar/layer/use-node-status.d.ts +6 -1
- package/types/layouts/workspace/Breadcrumb.vue.d.ts +1 -1
- package/types/layouts/workspace/Workspace.vue.d.ts +12 -12
- package/types/layouts/workspace/viewer/NodeListMenu.vue.d.ts +1 -1
- package/types/layouts/workspace/viewer/Stage.vue.d.ts +11 -11
- package/types/layouts/workspace/viewer/StageOverlay.vue.d.ts +1 -1
- package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +12 -12
- package/types/services/BaseService.d.ts +5 -2
- package/types/services/codeBlock.d.ts +8 -0
- package/types/services/dataSource.d.ts +9 -2
- package/types/services/editor.d.ts +8 -1
- package/types/services/props.d.ts +15 -22
- package/types/services/stageOverlay.d.ts +8 -1
- package/types/services/storage.d.ts +8 -0
- package/types/services/ui.d.ts +15 -9
- package/types/type.d.ts +50 -32
- package/types/utils/operator.d.ts +1 -1
- package/types/utils/props.d.ts +2 -13
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type MenuButton, type MenuComponent } from '../../../type';
|
|
2
|
-
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
3
3
|
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
4
4
|
disabledStageOverlay?: boolean | undefined;
|
|
5
5
|
customContentMenu?: ((menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[]) | undefined;
|
|
6
6
|
}>, {
|
|
7
7
|
disabledStageOverlay: boolean;
|
|
8
|
-
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
8
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
9
9
|
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
10
10
|
disabledStageOverlay?: boolean | undefined;
|
|
11
11
|
customContentMenu?: ((menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[]) | undefined;
|
|
@@ -15,15 +15,6 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
15
15
|
disabledStageOverlay: boolean;
|
|
16
16
|
}, {}>;
|
|
17
17
|
export default _default;
|
|
18
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
19
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
20
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
21
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
22
|
-
} : {
|
|
23
|
-
type: import('vue').PropType<T[K]>;
|
|
24
|
-
required: true;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
18
|
type __VLS_WithDefaults<P, D> = {
|
|
28
19
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
29
20
|
default: D[K];
|
|
@@ -32,3 +23,12 @@ type __VLS_WithDefaults<P, D> = {
|
|
|
32
23
|
type __VLS_Prettify<T> = {
|
|
33
24
|
[K in keyof T]: T[K];
|
|
34
25
|
} & {};
|
|
26
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
27
|
+
type __VLS_TypePropsToOption<T> = {
|
|
28
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
29
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
30
|
+
} : {
|
|
31
|
+
type: import('vue').PropType<T[K]>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuButton, MenuComponent } from '../../../type';
|
|
2
|
-
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
3
3
|
isMultiSelect?: boolean | undefined;
|
|
4
4
|
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
5
5
|
customContentMenu?: ((menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[]) | undefined;
|
|
@@ -9,7 +9,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
9
9
|
customContentMenu: (menus: (MenuButton | MenuComponent)[]) => (MenuButton | MenuComponent)[];
|
|
10
10
|
}>, {
|
|
11
11
|
show: (e: MouseEvent) => void;
|
|
12
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").
|
|
12
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
13
13
|
isMultiSelect?: boolean | undefined;
|
|
14
14
|
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
15
15
|
customContentMenu?: ((menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[]) | undefined;
|
|
@@ -18,20 +18,11 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
18
18
|
stageContentMenu: () => never[];
|
|
19
19
|
customContentMenu: (menus: (MenuButton | MenuComponent)[]) => (MenuButton | MenuComponent)[];
|
|
20
20
|
}>>>, {
|
|
21
|
+
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
21
22
|
customContentMenu: (menus: (MenuButton | MenuComponent)[], type: string) => (MenuButton | MenuComponent)[];
|
|
22
23
|
isMultiSelect: boolean;
|
|
23
|
-
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
24
24
|
}, {}>;
|
|
25
25
|
export default _default;
|
|
26
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
27
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
28
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
29
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
30
|
-
} : {
|
|
31
|
-
type: import('vue').PropType<T[K]>;
|
|
32
|
-
required: true;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
26
|
type __VLS_WithDefaults<P, D> = {
|
|
36
27
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
37
28
|
default: D[K];
|
|
@@ -40,3 +31,12 @@ type __VLS_WithDefaults<P, D> = {
|
|
|
40
31
|
type __VLS_Prettify<T> = {
|
|
41
32
|
[K in keyof T]: T[K];
|
|
42
33
|
} & {};
|
|
34
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
35
|
+
type __VLS_TypePropsToOption<T> = {
|
|
36
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
37
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
38
|
+
} : {
|
|
39
|
+
type: import('vue').PropType<T[K]>;
|
|
40
|
+
required: true;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -9,7 +9,7 @@ import { EventEmitter } from 'events';
|
|
|
9
9
|
* 例如:
|
|
10
10
|
* Class EditorService extends BaseService {
|
|
11
11
|
* constructor() {
|
|
12
|
-
* super(['add']);
|
|
12
|
+
* super([ { name: 'add', isAsync: true },]);
|
|
13
13
|
* }
|
|
14
14
|
* add(value) { return result; }
|
|
15
15
|
* };
|
|
@@ -37,7 +37,7 @@ import { EventEmitter } from 'events';
|
|
|
37
37
|
* 例如:
|
|
38
38
|
* Class EditorService extends BaseService {
|
|
39
39
|
* constructor() {
|
|
40
|
-
* super(['add']);
|
|
40
|
+
* super([ { name: 'add', isAsync: true },]);
|
|
41
41
|
* }
|
|
42
42
|
* add(value) { return result; }
|
|
43
43
|
* };
|
|
@@ -56,6 +56,9 @@ export default class extends EventEmitter {
|
|
|
56
56
|
name: string;
|
|
57
57
|
isAsync: boolean;
|
|
58
58
|
}[], serialMethods?: string[]);
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated 请使用usePlugin代替
|
|
61
|
+
*/
|
|
59
62
|
use(options: Record<string, Function>): void;
|
|
60
63
|
usePlugin(options: Record<string, Function>): void;
|
|
61
64
|
removeAllPlugins(): void;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { Writable } from 'type-fest';
|
|
1
2
|
import type { ColumnConfig } from '@tmagic/form';
|
|
2
3
|
import type { CodeBlockContent, CodeBlockDSL, Id } from '@tmagic/schema';
|
|
4
|
+
import type { AsyncHookPlugin } from '../type';
|
|
3
5
|
import BaseService from './BaseService';
|
|
6
|
+
declare const canUsePluginMethods: {
|
|
7
|
+
async: readonly ["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"];
|
|
8
|
+
sync: never[];
|
|
9
|
+
};
|
|
10
|
+
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
4
11
|
declare class CodeBlock extends BaseService {
|
|
5
12
|
private state;
|
|
6
13
|
constructor();
|
|
@@ -95,6 +102,7 @@ declare class CodeBlock extends BaseService {
|
|
|
95
102
|
getUniqueId(): Promise<string>;
|
|
96
103
|
resetState(): void;
|
|
97
104
|
destroy(): void;
|
|
105
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName, CodeBlock>): void;
|
|
98
106
|
}
|
|
99
107
|
export type CodeBlockService = CodeBlock;
|
|
100
108
|
declare const _default: CodeBlock;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Writable } from 'type-fest';
|
|
1
2
|
import type { EventOption } from '@tmagic/core';
|
|
2
3
|
import type { FormConfig } from '@tmagic/form';
|
|
3
4
|
import type { DataSourceSchema } from '@tmagic/schema';
|
|
4
|
-
import type { DatasourceTypeOption } from '../type';
|
|
5
|
+
import type { DatasourceTypeOption, SyncHookPlugin } from '../type';
|
|
5
6
|
import BaseService from './BaseService';
|
|
6
7
|
interface State {
|
|
7
8
|
datasourceTypeList: DatasourceTypeOption[];
|
|
@@ -13,6 +14,11 @@ interface State {
|
|
|
13
14
|
methods: Record<string, EventOption[]>;
|
|
14
15
|
}
|
|
15
16
|
type StateKey = keyof State;
|
|
17
|
+
declare const canUsePluginMethods: {
|
|
18
|
+
async: never[];
|
|
19
|
+
sync: readonly ["getFormConfig", "setFormConfig", "getFormValue", "setFormValue", "getFormEvent", "setFormEvent", "getFormMethod", "setFormMethod", "add", "update", "remove", "createId"];
|
|
20
|
+
};
|
|
21
|
+
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
16
22
|
declare class DataSource extends BaseService {
|
|
17
23
|
private state;
|
|
18
24
|
constructor();
|
|
@@ -38,10 +44,11 @@ declare class DataSource extends BaseService {
|
|
|
38
44
|
};
|
|
39
45
|
update(config: DataSourceSchema): DataSourceSchema;
|
|
40
46
|
remove(id: string): void;
|
|
47
|
+
createId(): string;
|
|
41
48
|
getDataSourceById(id: string): DataSourceSchema | undefined;
|
|
42
49
|
resetState(): void;
|
|
43
50
|
destroy(): void;
|
|
44
|
-
|
|
51
|
+
usePlugin(options: SyncHookPlugin<SyncMethodName, DataSource>): void;
|
|
45
52
|
}
|
|
46
53
|
export type DataSourceService = DataSource;
|
|
47
54
|
declare const _default: DataSource;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { Writable } from 'type-fest';
|
|
1
2
|
import type { Id, MContainer, MNode } from '@tmagic/schema';
|
|
2
3
|
import BaseService from '../services/BaseService';
|
|
3
|
-
import type { AddMNode, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '../type';
|
|
4
|
+
import type { AddMNode, AsyncHookPlugin, EditorNodeInfo, PastePosition, StepValue, StoreState, StoreStateKey } from '../type';
|
|
4
5
|
import { LayerOffset, Layout } from '../type';
|
|
6
|
+
declare const canUsePluginMethods: {
|
|
7
|
+
async: readonly ["getLayout", "highlight", "select", "multiSelect", "doAdd", "add", "doRemove", "remove", "doUpdate", "update", "sort", "copy", "paste", "doPaste", "doAlignCenter", "alignCenter", "moveLayer", "moveToContainer", "dragTo", "undo", "redo", "move"];
|
|
8
|
+
sync: never[];
|
|
9
|
+
};
|
|
10
|
+
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
5
11
|
declare class Editor extends BaseService {
|
|
6
12
|
state: StoreState;
|
|
7
13
|
private isHistoryStateChange;
|
|
@@ -144,6 +150,7 @@ declare class Editor extends BaseService {
|
|
|
144
150
|
resetState(): void;
|
|
145
151
|
destroy(): void;
|
|
146
152
|
resetModifiedNodeId(): void;
|
|
153
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName, Editor>): void;
|
|
147
154
|
private addModifiedNodeId;
|
|
148
155
|
private pushHistoryState;
|
|
149
156
|
private changeHistoryState;
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
+
import { Writable } from 'type-fest';
|
|
1
2
|
import type { FormConfig } from '@tmagic/form';
|
|
2
3
|
import type { MNode } from '@tmagic/schema';
|
|
4
|
+
import type { AsyncHookPlugin, SyncHookPlugin } from '../type';
|
|
3
5
|
import BaseService from './BaseService';
|
|
6
|
+
declare const canUsePluginMethods: {
|
|
7
|
+
async: readonly ["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "fillConfig", "getDefaultPropsValue"];
|
|
8
|
+
sync: readonly ["createId", "setNewItemId"];
|
|
9
|
+
};
|
|
10
|
+
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
11
|
+
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
4
12
|
declare class Props extends BaseService {
|
|
5
13
|
private state;
|
|
6
14
|
constructor();
|
|
7
15
|
setPropsConfigs(configs: Record<string, FormConfig>): void;
|
|
8
|
-
fillConfig(config: FormConfig): Promise<
|
|
9
|
-
type: string;
|
|
10
|
-
items: {
|
|
11
|
-
[x: string]: any;
|
|
12
|
-
status?: string | undefined;
|
|
13
|
-
title: string;
|
|
14
|
-
lazy?: boolean | undefined;
|
|
15
|
-
labelWidth?: string | undefined;
|
|
16
|
-
items: FormConfig;
|
|
17
|
-
onTabClick?: ((mForm: import("@tmagic/form").FormState | undefined, tab: any, data: any) => void) | undefined;
|
|
18
|
-
}[];
|
|
19
|
-
}[]>;
|
|
20
|
-
/**
|
|
21
|
-
* 为指定类型组件设置组件属性表单配置
|
|
22
|
-
* @param type 组件类型
|
|
23
|
-
* @param config 组件属性表单配置
|
|
24
|
-
*/
|
|
16
|
+
fillConfig(config: FormConfig, labelWidth?: string): Promise<FormConfig>;
|
|
25
17
|
setPropsConfig(type: string, config: FormConfig): Promise<void>;
|
|
26
18
|
/**
|
|
27
19
|
* 获取指点类型的组件属性表单配置
|
|
@@ -41,21 +33,21 @@ declare class Props extends BaseService {
|
|
|
41
33
|
* @param type 组件类型
|
|
42
34
|
* @returns 组件初始值
|
|
43
35
|
*/
|
|
44
|
-
getPropsValue(
|
|
45
|
-
createId(type: string | number):
|
|
36
|
+
getPropsValue(componentType: string, { inputEvent, ...defaultValue }?: Record<string, any>): Promise<any>;
|
|
37
|
+
createId(type: string | number): string;
|
|
46
38
|
/**
|
|
47
39
|
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
48
40
|
* 如果没有相同ID并且force为false则保持不变
|
|
49
41
|
* @param {Object} config 组件配置
|
|
50
42
|
* @param {Boolean} force 是否强制设置新的ID
|
|
51
43
|
*/
|
|
52
|
-
setNewItemId(config: MNode, force?: boolean):
|
|
44
|
+
setNewItemId(config: MNode, force?: boolean): MNode;
|
|
53
45
|
/**
|
|
54
46
|
* 获取默认属性配置
|
|
55
47
|
* @param type 组件类型
|
|
56
48
|
* @returns Object
|
|
57
49
|
*/
|
|
58
|
-
getDefaultPropsValue(type: string):
|
|
50
|
+
getDefaultPropsValue(type: string): {
|
|
59
51
|
type: string;
|
|
60
52
|
layout: string;
|
|
61
53
|
style: {};
|
|
@@ -67,7 +59,7 @@ declare class Props extends BaseService {
|
|
|
67
59
|
name: string;
|
|
68
60
|
layout?: undefined;
|
|
69
61
|
items?: undefined;
|
|
70
|
-
}
|
|
62
|
+
};
|
|
71
63
|
resetState(): void;
|
|
72
64
|
/**
|
|
73
65
|
* 替换关联ID
|
|
@@ -80,6 +72,7 @@ declare class Props extends BaseService {
|
|
|
80
72
|
*/
|
|
81
73
|
clearRelateId(): void;
|
|
82
74
|
destroy(): void;
|
|
75
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName, Props> & SyncHookPlugin<SyncMethodName, Props>): void;
|
|
83
76
|
/**
|
|
84
77
|
* 获取setNewItemId前后映射关系
|
|
85
78
|
* @param oldId 原组件ID
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import type { Writable } from 'type-fest';
|
|
1
2
|
import StageCore from '@tmagic/stage';
|
|
2
3
|
import BaseService from '../services/BaseService';
|
|
3
|
-
import type { StageOptions, StageOverlayState } from '../type';
|
|
4
|
+
import type { StageOptions, StageOverlayState, SyncHookPlugin } from '../type';
|
|
5
|
+
declare const canUsePluginMethods: {
|
|
6
|
+
async: never[];
|
|
7
|
+
sync: readonly ["openOverlay", "closeOverlay", "updateOverlay", "createStage"];
|
|
8
|
+
};
|
|
9
|
+
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
4
10
|
declare class StageOverlay extends BaseService {
|
|
5
11
|
private state;
|
|
6
12
|
constructor();
|
|
@@ -10,6 +16,7 @@ declare class StageOverlay extends BaseService {
|
|
|
10
16
|
closeOverlay(): void;
|
|
11
17
|
updateOverlay(): void;
|
|
12
18
|
createStage(stageOptions?: StageOptions): StageCore;
|
|
19
|
+
usePlugin(options: SyncHookPlugin<SyncMethodName, StageOverlay>): void;
|
|
13
20
|
private createContentEl;
|
|
14
21
|
private copyDocumentElement;
|
|
15
22
|
private render;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Writable } from 'type-fest';
|
|
2
|
+
import type { SyncHookPlugin } from '../type';
|
|
1
3
|
import BaseService from './BaseService';
|
|
2
4
|
interface Options {
|
|
3
5
|
namespace?: string;
|
|
@@ -10,6 +12,11 @@ export declare enum Protocol {
|
|
|
10
12
|
NUMBER = "number",
|
|
11
13
|
BOOLEAN = "boolean"
|
|
12
14
|
}
|
|
15
|
+
declare const canUsePluginMethods: {
|
|
16
|
+
async: never[];
|
|
17
|
+
sync: readonly ["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"];
|
|
18
|
+
};
|
|
19
|
+
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;
|
|
13
20
|
/**
|
|
14
21
|
* 数据存储服务
|
|
15
22
|
*/
|
|
@@ -50,6 +57,7 @@ export declare class WebStorage extends BaseService {
|
|
|
50
57
|
*/
|
|
51
58
|
setItem(key: string, value: any, options?: Options): void;
|
|
52
59
|
destroy(): void;
|
|
60
|
+
usePlugin(options: SyncHookPlugin<SyncMethodName, WebStorage>): void;
|
|
53
61
|
private getValueAndProtocol;
|
|
54
62
|
}
|
|
55
63
|
export type StorageService = WebStorage;
|
package/types/services/ui.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Writable } from 'type-fest';
|
|
2
|
+
import type { AsyncHookPlugin, UiState } from '../type';
|
|
2
3
|
import BaseService from './BaseService';
|
|
4
|
+
declare const canUsePluginMethods: {
|
|
5
|
+
async: readonly ["zoom", "calcZoom"];
|
|
6
|
+
sync: readonly [];
|
|
7
|
+
};
|
|
8
|
+
type AsyncMethodName = Writable<(typeof canUsePluginMethods)['async']>;
|
|
3
9
|
declare class Ui extends BaseService {
|
|
4
10
|
constructor();
|
|
5
11
|
set<K extends keyof UiState, T extends UiState[K]>(name: K, value: T): void;
|
|
@@ -22,21 +28,21 @@ declare class Ui extends BaseService {
|
|
|
22
28
|
};
|
|
23
29
|
showGuides: boolean;
|
|
24
30
|
showRule: boolean;
|
|
25
|
-
propsPanelSize: "
|
|
31
|
+
propsPanelSize: "small" | "large" | "default";
|
|
26
32
|
showAddPageButton: boolean;
|
|
27
|
-
floatBox: Map<string, {
|
|
28
|
-
status: boolean;
|
|
29
|
-
zIndex: number;
|
|
30
|
-
top: number;
|
|
31
|
-
left: number;
|
|
32
|
-
}>;
|
|
33
33
|
hideSlideBar: boolean;
|
|
34
|
+
navMenuRect: {
|
|
35
|
+
left: number;
|
|
36
|
+
top: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
34
40
|
}[K];
|
|
35
41
|
zoom(zoom: number): Promise<void>;
|
|
36
42
|
calcZoom(): Promise<number>;
|
|
37
|
-
setFloatBox(keys: string[]): Promise<void>;
|
|
38
43
|
resetState(): void;
|
|
39
44
|
destroy(): void;
|
|
45
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName, Ui>): void;
|
|
40
46
|
private setStageRect;
|
|
41
47
|
}
|
|
42
48
|
export type UiService = Ui;
|
package/types/type.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { PascalCasedProperties } from 'type-fest';
|
|
3
|
+
import type { ChildConfig, ColumnConfig, FilterFunction, FormConfig, FormItem, Input } from '@tmagic/form';
|
|
4
|
+
import type { CodeBlockContent, CodeBlockDSL, DataSourceFieldType, Id, MApp, MContainer, MNode, MPage, MPageFragment } from '@tmagic/schema';
|
|
4
5
|
import type StageCore from '@tmagic/stage';
|
|
5
6
|
import type { ContainerHighlightType, CustomizeMoveableOptionsCallbackConfig, GuidesOptions, MoveableOptions, RenderType, UpdateDragEl } from '@tmagic/stage';
|
|
6
7
|
import type { CodeBlockService } from './services/codeBlock';
|
|
@@ -191,15 +192,14 @@ export interface UiState {
|
|
|
191
192
|
propsPanelSize: 'large' | 'default' | 'small';
|
|
192
193
|
/** 是否显示新增页面按钮 */
|
|
193
194
|
showAddPageButton: boolean;
|
|
194
|
-
/** slide 拖拽悬浮窗 state */
|
|
195
|
-
floatBox: Map<string, {
|
|
196
|
-
status: boolean;
|
|
197
|
-
zIndex: number;
|
|
198
|
-
top: number;
|
|
199
|
-
left: number;
|
|
200
|
-
}>;
|
|
201
195
|
/** 是否隐藏侧边栏 */
|
|
202
196
|
hideSlideBar: boolean;
|
|
197
|
+
navMenuRect: {
|
|
198
|
+
left: number;
|
|
199
|
+
top: number;
|
|
200
|
+
width: number;
|
|
201
|
+
height: number;
|
|
202
|
+
};
|
|
203
203
|
}
|
|
204
204
|
export interface EditorNodeInfo {
|
|
205
205
|
node: MNode | null;
|
|
@@ -506,39 +506,40 @@ export interface KeyBindingCacheItem {
|
|
|
506
506
|
eventType: 'keyup' | 'keydown';
|
|
507
507
|
bound: boolean;
|
|
508
508
|
}
|
|
509
|
-
export interface CodeSelectColConfig {
|
|
509
|
+
export interface CodeSelectColConfig extends FormItem {
|
|
510
510
|
type: 'code-select-col';
|
|
511
|
-
|
|
512
|
-
text: string;
|
|
513
|
-
labelWidth?: number | string;
|
|
514
|
-
disabled?: boolean | FilterFunction;
|
|
511
|
+
/** 是否可以编辑代码块,disable表示的是是否可以选择代码块 */
|
|
515
512
|
notEditable?: boolean | FilterFunction;
|
|
516
|
-
display?: boolean | FilterFunction;
|
|
517
513
|
}
|
|
518
|
-
export interface PageFragmentSelectConfig {
|
|
514
|
+
export interface PageFragmentSelectConfig extends FormItem {
|
|
519
515
|
type: 'page-fragment-select';
|
|
520
|
-
name: string;
|
|
521
|
-
text: string;
|
|
522
|
-
labelWidth?: number | string;
|
|
523
|
-
disabled?: boolean | FilterFunction;
|
|
524
|
-
display?: boolean | FilterFunction;
|
|
525
516
|
}
|
|
526
|
-
export interface
|
|
517
|
+
export interface DataSourceSelect extends FormItem, Input {
|
|
518
|
+
type: 'data-source-select';
|
|
519
|
+
/** 数据源类型: base、http... */
|
|
520
|
+
dataSourceType?: string;
|
|
521
|
+
/** 是否要编译成数据源的data。
|
|
522
|
+
* id: 不编译,就是要数据源id;
|
|
523
|
+
* value: 要编译(数据源data)
|
|
524
|
+
* */
|
|
525
|
+
value?: 'id' | 'value';
|
|
526
|
+
}
|
|
527
|
+
export interface DataSourceMethodSelectConfig extends FormItem {
|
|
527
528
|
type: 'data-source-method-select';
|
|
528
|
-
|
|
529
|
-
text: string;
|
|
530
|
-
labelWidth?: number | string;
|
|
531
|
-
disabled?: boolean | FilterFunction;
|
|
529
|
+
/** 是否可以编辑数据源,disable表示的是是否可以选择数据源 */
|
|
532
530
|
notEditable?: boolean | FilterFunction;
|
|
533
|
-
display?: boolean | FilterFunction;
|
|
534
531
|
}
|
|
535
|
-
export interface DataSourceFieldSelectConfig {
|
|
532
|
+
export interface DataSourceFieldSelectConfig extends FormItem {
|
|
536
533
|
type: 'data-source-field-select';
|
|
537
|
-
|
|
534
|
+
/** 是否要编译成数据源的data。
|
|
535
|
+
* key: 不编译,就是要数据源id和field name;
|
|
536
|
+
* value: 要编译(数据源data[`${filed}`])
|
|
537
|
+
* */
|
|
538
538
|
value?: 'key' | 'value';
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
539
|
+
/** 是否严格的遵守父子节点不互相关联 */
|
|
540
|
+
checkStrictly?: boolean;
|
|
541
|
+
dataSourceFieldType?: DataSourceFieldType[];
|
|
542
|
+
fieldConfig?: ChildConfig;
|
|
542
543
|
}
|
|
543
544
|
/** 可新增的数据源类型选项 */
|
|
544
545
|
export interface DatasourceTypeOption {
|
|
@@ -573,3 +574,20 @@ export interface TreeNodeData {
|
|
|
573
574
|
items?: TreeNodeData[];
|
|
574
575
|
[key: string]: any;
|
|
575
576
|
}
|
|
577
|
+
export type AsyncBeforeHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = {
|
|
578
|
+
[K in Value[number]]?: (...args: Parameters<C[K]>) => Promise<Parameters<C[K]>> | Parameters<C[K]>;
|
|
579
|
+
};
|
|
580
|
+
export type AsyncAfterHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = {
|
|
581
|
+
[K in Value[number]]?: (result: Awaited<ReturnType<C[K]>>, ...args: Parameters<C[K]>) => ReturnType<C[K]> | Awaited<ReturnType<C[K]>>;
|
|
582
|
+
};
|
|
583
|
+
export type SyncBeforeHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = {
|
|
584
|
+
[K in Value[number]]?: (...args: Parameters<C[K]>) => Parameters<C[K]>;
|
|
585
|
+
};
|
|
586
|
+
export type SyncAfterHook<Value extends Array<string>, C extends Record<Value[number], (...args: any) => any>> = {
|
|
587
|
+
[K in Value[number]]?: (result: ReturnType<C[K]>, ...args: Parameters<C[K]>) => ReturnType<C[K]>;
|
|
588
|
+
};
|
|
589
|
+
export type AddPrefixToObject<T, P extends string> = {
|
|
590
|
+
[K in keyof T as K extends string ? `${P}${K}` : never]: T[K];
|
|
591
|
+
};
|
|
592
|
+
export type AsyncHookPlugin<T extends Array<string>, C extends Record<T[number], (...args: any) => any>> = AddPrefixToObject<PascalCasedProperties<AsyncBeforeHook<T, C>>, 'before'> & AddPrefixToObject<PascalCasedProperties<AsyncAfterHook<T, C>>, 'after'>;
|
|
593
|
+
export type SyncHookPlugin<T extends Array<string>, C extends Record<T[number], (...args: any) => any>> = AddPrefixToObject<PascalCasedProperties<SyncBeforeHook<T, C>>, 'before'> & AddPrefixToObject<PascalCasedProperties<SyncAfterHook<T, C>>, 'after'>;
|
|
@@ -6,7 +6,7 @@ import type { AddMNode, PastePosition } from '../type';
|
|
|
6
6
|
* @param config 待粘贴的元素配置(复制时保存的那份配置)
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare const beforePaste: (position: PastePosition, config: MNode[]) =>
|
|
9
|
+
export declare const beforePaste: (position: PastePosition, config: MNode[]) => MNode[];
|
|
10
10
|
/**
|
|
11
11
|
* 将元素粘贴到容器内时,将相对于画布坐标转换为相对于容器的坐标
|
|
12
12
|
* @param position PastePosition 粘贴时相对于画布的坐标
|
package/types/utils/props.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormConfig,
|
|
1
|
+
import type { FormConfig, TabPaneConfig } from '@tmagic/form';
|
|
2
2
|
export declare const styleTabConfig: TabPaneConfig;
|
|
3
3
|
export declare const eventTabConfig: TabPaneConfig;
|
|
4
4
|
export declare const advancedTabConfig: TabPaneConfig;
|
|
@@ -8,15 +8,4 @@ export declare const displayTabConfig: TabPaneConfig;
|
|
|
8
8
|
* @param config 组件属性配置
|
|
9
9
|
* @returns Object
|
|
10
10
|
*/
|
|
11
|
-
export declare const fillConfig: (config?: FormConfig) =>
|
|
12
|
-
type: string;
|
|
13
|
-
items: {
|
|
14
|
-
[x: string]: any;
|
|
15
|
-
status?: string | undefined;
|
|
16
|
-
title: string;
|
|
17
|
-
lazy?: boolean | undefined;
|
|
18
|
-
labelWidth?: string | undefined;
|
|
19
|
-
items: FormConfig;
|
|
20
|
-
onTabClick?: ((mForm: FormState | undefined, tab: any, data: any) => void) | undefined;
|
|
21
|
-
}[];
|
|
22
|
-
}[];
|
|
11
|
+
export declare const fillConfig: (config?: FormConfig, labelWidth?: string) => FormConfig;
|