forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.ts
More file actions
147 lines (120 loc) · 3.22 KB
/
editor.ts
File metadata and controls
147 lines (120 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { ReactNode, ComponentType } from 'react';
import { IPublicTypeNpmInfo, IPublicModelEditor } from './shell';
export interface EditorConfig {
skeleton?: SkeletonConfig;
theme?: ThemeConfig;
plugins?: PluginsConfig;
hooks?: HooksConfig;
shortCuts?: ShortCutsConfig;
utils?: UtilsConfig;
constants?: ConstantsConfig;
lifeCycles?: LifeCyclesConfig;
i18n?: I18nConfig;
}
export interface SkeletonConfig {
config: IPublicTypeNpmInfo;
props?: Record<string, unknown>;
handler?: (config: EditorConfig) => EditorConfig;
}
export interface FusionTheme {
package: string;
version: string;
}
export interface ThemeConfig {
fusion?: FusionTheme;
}
export interface PluginsConfig {
[key: string]: PluginConfig[];
}
export interface PluginConfig {
pluginKey: string;
type: string;
props: {
icon?: string;
title?: string;
width?: number;
height?: number;
visible?: boolean;
disabled?: boolean;
marked?: boolean;
align?: 'left' | 'right' | 'top' | 'bottom';
onClick?: () => void;
dialogProps?: Record<string, unknown>;
balloonProps?: Record<string, unknown>;
panelProps?: Record<string, unknown>;
linkProps?: Record<string, unknown>;
};
config?: IPublicTypeNpmInfo;
pluginProps?: Record<string, unknown>;
}
export type HooksConfig = HookConfig[];
export interface HookConfig {
message: string;
type: 'on' | 'once';
handler: (this: IPublicModelEditor, editor: IPublicModelEditor, ...args: any[]) => void;
}
export type ShortCutsConfig = ShortCutConfig[];
export interface ShortCutConfig {
keyboard: string;
handler: (editor: IPublicModelEditor, ev: Event, keymaster: any) => void;
}
export type UtilsConfig = UtilConfig[];
export interface UtilConfig {
name: string;
type: 'npm' | 'function';
content: IPublicTypeNpmInfo | ((...args: []) => any);
}
export type ConstantsConfig = Record<string, unknown>;
export interface LifeCyclesConfig {
init?: (editor: IPublicModelEditor) => any;
destroy?: (editor: IPublicModelEditor) => any;
}
export type LocaleType = 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP';
export interface I18nMessages {
[key: string]: string;
}
export interface I18nConfig {
'zh-CN'?: I18nMessages;
'zh-TW'?: I18nMessages;
'en-US'?: I18nMessages;
'ja-JP'?: I18nMessages;
}
export type I18nFunction = (key: string, params: any) => string;
export interface Utils {
[key: string]: (...args: any[]) => any;
}
export interface PluginProps {
editor?: IPublicModelEditor;
config: PluginConfig;
[key: string]: any;
}
export type Plugin = ReactNode & {
open?: () => boolean | undefined | Promise<any>;
close?: () => boolean | undefined | Promise<any>;
};
export type HOCPlugin = ReactNode & {
open: () => Promise<any>;
close: () => Promise<any>;
};
export interface PluginSet {
[key: string]: HOCPlugin;
}
export type PluginClass = ComponentType<PluginProps> & {
init?: (editor: IPublicModelEditor) => void;
defaultProps?: {
locale?: LocaleType;
messages?: I18nMessages;
};
};
export interface PluginClassSet {
[key: string]: PluginClass;
}
export interface PluginStatus {
disabled?: boolean;
visible?: boolean;
marked?: boolean;
locked?: boolean;
}
export interface PluginStatusSet {
[key: string]: PluginStatus;
}