amis-editor-core 6.9.0 → 6.10.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/esm/component/Editor.d.ts +5 -1
- package/esm/component/ModalForm.d.ts +25 -0
- package/esm/deepSplice.d.ts +12 -0
- package/esm/index.d.ts +4 -1
- package/esm/index.js +2 -2
- package/esm/manager.d.ts +13 -2
- package/esm/plugin.d.ts +13 -0
- package/esm/store/editor.d.ts +25 -36
- package/lib/component/Editor.d.ts +5 -1
- package/lib/component/ModalForm.d.ts +25 -0
- package/lib/component/base/BackTop.d.ts +1 -1
- package/lib/deepSplice.d.ts +12 -0
- package/lib/editor.js +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +2 -2
- package/lib/layout/flex.d.ts +0 -1
- package/lib/manager.d.ts +13 -2
- package/lib/plugin.d.ts +13 -0
- package/lib/store/editor.d.ts +25 -36
- package/lib/style.css +1 -1
- package/package.json +4 -4
package/esm/manager.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { EditorDNDManager } from './dnd';
|
|
|
10
10
|
import { VariableManager } from './variable';
|
|
11
11
|
import type { IScopedContext } from 'amis';
|
|
12
12
|
import type { SchemaObject, SchemaCollection } from 'amis';
|
|
13
|
-
import type { RendererConfig } from 'amis-core';
|
|
13
|
+
import type { Api, Payload, RendererConfig } from 'amis-core';
|
|
14
14
|
export interface EditorManagerConfig extends Omit<EditorProps, 'value' | 'onChange'> {
|
|
15
15
|
}
|
|
16
16
|
export interface PluginClass {
|
|
@@ -61,6 +61,7 @@ export declare class EditorManager {
|
|
|
61
61
|
dataSchema: DataSchema;
|
|
62
62
|
/** 变量管理 */
|
|
63
63
|
readonly variableManager: VariableManager;
|
|
64
|
+
fetch?: (api: Api, data?: any, options?: object) => Promise<Payload>;
|
|
64
65
|
constructor(config: EditorManagerConfig, store: EditorStoreType, parent?: EditorManager | undefined);
|
|
65
66
|
normalizeScene(plugins?: Array<PluginClass | [PluginClass, Record<string, any> | (() => Record<string, any>)]>): (PluginClass | [PluginClass, Record<string, any> | (() => Record<string, any>)])[];
|
|
66
67
|
dynamicAddPlugin(pluginName: string): void;
|
|
@@ -440,6 +441,11 @@ export declare class EditorManager {
|
|
|
440
441
|
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
441
442
|
calculateHighlightBox(root?: any): void;
|
|
442
443
|
resetHighlightBox(root: any): void;
|
|
444
|
+
/**
|
|
445
|
+
* 显示插入面板
|
|
446
|
+
* @param region
|
|
447
|
+
* @param preferTag
|
|
448
|
+
*/
|
|
443
449
|
updateState(state: any, replace?: boolean): void;
|
|
444
450
|
setWidthMutable(value: any): void;
|
|
445
451
|
setHeightMutable(value: any): void;
|
|
@@ -817,6 +823,11 @@ export declare class EditorManager {
|
|
|
817
823
|
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
818
824
|
calculateHighlightBox(root?: any): void;
|
|
819
825
|
resetHighlightBox(root: any): void;
|
|
826
|
+
/**
|
|
827
|
+
* 显示插入面板
|
|
828
|
+
* @param region
|
|
829
|
+
* @param preferTag
|
|
830
|
+
*/
|
|
820
831
|
updateState(state: any, replace?: boolean): void;
|
|
821
832
|
setWidthMutable(value: any): void;
|
|
822
833
|
setHeightMutable(value: any): void;
|
|
@@ -1039,7 +1050,7 @@ export declare class EditorManager {
|
|
|
1039
1050
|
toggleSelection(id: string): void;
|
|
1040
1051
|
setSelection(selections: Array<string>, id?: string): void;
|
|
1041
1052
|
startDrag(id: string, e: React.DragEvent): void;
|
|
1042
|
-
scaffold(form:
|
|
1053
|
+
scaffold(form: ScaffoldForm, value: any): Promise<SchemaObject>;
|
|
1043
1054
|
reScaffold(id: string, form: ScaffoldForm, value: any): Promise<void>;
|
|
1044
1055
|
reScaffoldV2(id: string): Promise<void>;
|
|
1045
1056
|
lazyPatchSchema: import("lodash").DebouncedFunc<any>;
|
package/esm/plugin.d.ts
CHANGED
|
@@ -243,11 +243,14 @@ export interface PopOverForm {
|
|
|
243
243
|
* @deprecated 改用 body 代替
|
|
244
244
|
*/
|
|
245
245
|
controls?: Array<any>;
|
|
246
|
+
initApi?: any;
|
|
247
|
+
api?: any;
|
|
246
248
|
}
|
|
247
249
|
export interface ScaffoldForm extends PopOverForm {
|
|
248
250
|
stepsBody?: boolean;
|
|
249
251
|
/** 是否可跳过创建向导直接创建 */
|
|
250
252
|
canSkip?: boolean;
|
|
253
|
+
getSchema?: (value: any) => PopOverForm | Promise<PopOverForm>;
|
|
251
254
|
mode?: 'normal' | 'horizontal' | 'inline' | {
|
|
252
255
|
mode: string;
|
|
253
256
|
horizontal: any;
|
|
@@ -336,6 +339,7 @@ export interface PanelProps {
|
|
|
336
339
|
manager: EditorManager;
|
|
337
340
|
popOverContainer?: () => HTMLElement | void;
|
|
338
341
|
readonly?: boolean;
|
|
342
|
+
children?: React.ReactNode | ((props: PanelProps) => React.ReactNode);
|
|
339
343
|
}
|
|
340
344
|
/**
|
|
341
345
|
* 面板信息定义
|
|
@@ -379,6 +383,15 @@ export interface RendererInfoResolveEventContext extends EventContext {
|
|
|
379
383
|
export interface RendererJSONSchemaResolveEventContext extends BaseEventContext {
|
|
380
384
|
data: string;
|
|
381
385
|
}
|
|
386
|
+
export interface IGlobalEvent {
|
|
387
|
+
label: string;
|
|
388
|
+
name: string;
|
|
389
|
+
description: string;
|
|
390
|
+
mapping: Array<{
|
|
391
|
+
key: string;
|
|
392
|
+
type: string;
|
|
393
|
+
}>;
|
|
394
|
+
}
|
|
382
395
|
/**
|
|
383
396
|
* 右键菜单事件的上下文。
|
|
384
397
|
*/
|
package/esm/store/editor.d.ts
CHANGED
|
@@ -51,6 +51,13 @@ export interface PopOverFormContext extends PopOverForm {
|
|
|
51
51
|
callback: (value: any, diff: any) => void;
|
|
52
52
|
node?: EditorNodeType;
|
|
53
53
|
}
|
|
54
|
+
export interface ModalFormContext extends PopOverForm {
|
|
55
|
+
mode?: 'dialog' | 'drawer';
|
|
56
|
+
size?: string;
|
|
57
|
+
postion?: string;
|
|
58
|
+
value: any;
|
|
59
|
+
callback: (value: any, diff: any) => void;
|
|
60
|
+
}
|
|
54
61
|
/**
|
|
55
62
|
* 搜集的 name 信息
|
|
56
63
|
*/
|
|
@@ -441,10 +448,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
441
448
|
updateSchemaStyle(value: any): void;
|
|
442
449
|
setComponent(value: any): void;
|
|
443
450
|
getComponent(): any;
|
|
444
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
445
|
-
* 根据当前分类和关键字获取预置组件
|
|
446
|
-
* 备注:组件面板展示需要
|
|
447
|
-
*/
|
|
451
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
448
452
|
calculateHighlightBox(root?: any): void;
|
|
449
453
|
resetHighlightBox(root: any): void;
|
|
450
454
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -503,6 +507,10 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
503
507
|
scaffoldFormBuzy: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
504
508
|
scaffoldError: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
505
509
|
popOverForm: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<PopOverFormContext, PopOverFormContext, PopOverFormContext>>;
|
|
510
|
+
modalForm: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<ModalFormContext, ModalFormContext, ModalFormContext>>;
|
|
511
|
+
modalMode: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
512
|
+
modalFormBuzy: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
513
|
+
modalFormError: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
506
514
|
subEditorContext: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<SubEditorContext, SubEditorContext, SubEditorContext>>;
|
|
507
515
|
superEditorData: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<any, any, any>>;
|
|
508
516
|
calculateStarted: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -516,6 +524,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
516
524
|
readonly filteredSchema: any;
|
|
517
525
|
readonly filteredSchemaForPreview: any;
|
|
518
526
|
isRootSchema(id: string): boolean;
|
|
527
|
+
readonly rootId: any;
|
|
519
528
|
getRootId(): any;
|
|
520
529
|
isHoved(id: string): boolean | "";
|
|
521
530
|
isActive(id: string): boolean | "";
|
|
@@ -896,10 +905,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
896
905
|
updateSchemaStyle(value: any): void;
|
|
897
906
|
setComponent(value: any): void;
|
|
898
907
|
getComponent(): any;
|
|
899
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
900
|
-
* 根据当前分类和关键字获取预置组件
|
|
901
|
-
* 备注:组件面板展示需要
|
|
902
|
-
*/
|
|
908
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
903
909
|
calculateHighlightBox(root?: any): void;
|
|
904
910
|
resetHighlightBox(root: any): void;
|
|
905
911
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -1276,10 +1282,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
1276
1282
|
updateSchemaStyle(value: any): void;
|
|
1277
1283
|
setComponent(value: any): void;
|
|
1278
1284
|
getComponent(): any;
|
|
1279
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
1280
|
-
* 根据当前分类和关键字获取预置组件
|
|
1281
|
-
* 备注:组件面板展示需要
|
|
1282
|
-
*/
|
|
1285
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
1283
1286
|
calculateHighlightBox(root?: any): void;
|
|
1284
1287
|
resetHighlightBox(root: any): void;
|
|
1285
1288
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -1679,10 +1682,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
1679
1682
|
updateSchemaStyle(value: any): void;
|
|
1680
1683
|
setComponent(value: any): void;
|
|
1681
1684
|
getComponent(): any;
|
|
1682
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
1683
|
-
* 根据当前分类和关键字获取预置组件
|
|
1684
|
-
* 备注:组件面板展示需要
|
|
1685
|
-
*/
|
|
1685
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
1686
1686
|
calculateHighlightBox(root?: any): void;
|
|
1687
1687
|
resetHighlightBox(root: any): void;
|
|
1688
1688
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -2059,10 +2059,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
2059
2059
|
updateSchemaStyle(value: any): void;
|
|
2060
2060
|
setComponent(value: any): void;
|
|
2061
2061
|
getComponent(): any;
|
|
2062
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
2063
|
-
* 根据当前分类和关键字获取预置组件
|
|
2064
|
-
* 备注:组件面板展示需要
|
|
2065
|
-
*/
|
|
2062
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
2066
2063
|
calculateHighlightBox(root?: any): void;
|
|
2067
2064
|
resetHighlightBox(root: any): void;
|
|
2068
2065
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -2440,10 +2437,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
2440
2437
|
updateSchemaStyle(value: any): void;
|
|
2441
2438
|
setComponent(value: any): void;
|
|
2442
2439
|
getComponent(): any;
|
|
2443
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
2444
|
-
* 根据当前分类和关键字获取预置组件
|
|
2445
|
-
* 备注:组件面板展示需要
|
|
2446
|
-
*/
|
|
2440
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
2447
2441
|
calculateHighlightBox(root?: any): void;
|
|
2448
2442
|
resetHighlightBox(root: any): void;
|
|
2449
2443
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -2820,10 +2814,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
2820
2814
|
updateSchemaStyle(value: any): void;
|
|
2821
2815
|
setComponent(value: any): void;
|
|
2822
2816
|
getComponent(): any;
|
|
2823
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
2824
|
-
* 根据当前分类和关键字获取预置组件
|
|
2825
|
-
* 备注:组件面板展示需要
|
|
2826
|
-
*/
|
|
2817
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
2827
2818
|
calculateHighlightBox(root?: any): void;
|
|
2828
2819
|
resetHighlightBox(root: any): void;
|
|
2829
2820
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -3201,10 +3192,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
3201
3192
|
updateSchemaStyle(value: any): void;
|
|
3202
3193
|
setComponent(value: any): void;
|
|
3203
3194
|
getComponent(): any;
|
|
3204
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
3205
|
-
* 根据当前分类和关键字获取预置组件
|
|
3206
|
-
* 备注:组件面板展示需要
|
|
3207
|
-
*/
|
|
3195
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
3208
3196
|
calculateHighlightBox(root?: any): void;
|
|
3209
3197
|
resetHighlightBox(root: any): void;
|
|
3210
3198
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -3581,10 +3569,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
3581
3569
|
updateSchemaStyle(value: any): void;
|
|
3582
3570
|
setComponent(value: any): void;
|
|
3583
3571
|
getComponent(): any;
|
|
3584
|
-
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
3585
|
-
* 根据当前分类和关键字获取预置组件
|
|
3586
|
-
* 备注:组件面板展示需要
|
|
3587
|
-
*/
|
|
3572
|
+
getTarget(): HTMLElement | HTMLElement[] | null;
|
|
3588
3573
|
calculateHighlightBox(root?: any): void;
|
|
3589
3574
|
resetHighlightBox(root: any): void;
|
|
3590
3575
|
updateState(state: any, replace?: boolean): void;
|
|
@@ -3751,6 +3736,10 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
|
|
|
3751
3736
|
updateScaffoldData(value: any, replace?: boolean): void;
|
|
3752
3737
|
openPopOverForm(context: PopOverFormContext): void;
|
|
3753
3738
|
closePopOverForm(): void;
|
|
3739
|
+
openModalForm(context: ModalFormContext): void;
|
|
3740
|
+
closeModalForm(): void;
|
|
3741
|
+
markModalFormBuzy(value: any): void;
|
|
3742
|
+
setModalFormError(msg?: string): void;
|
|
3754
3743
|
activeHighlightNodes(ids: Array<string>): void;
|
|
3755
3744
|
deActiveHighlightNodes(ids: Array<string>): void;
|
|
3756
3745
|
calculateHighlightBox(ids?: Array<string>): void;
|
|
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|
|
2
2
|
import { EditorStoreType } from '../store/editor';
|
|
3
3
|
import { EditorManager, PluginClass } from '../manager';
|
|
4
4
|
import { RenderOptions } from 'amis';
|
|
5
|
-
import { PluginEventListener, RendererPluginAction } from '../plugin';
|
|
5
|
+
import { PluginEventListener, RendererPluginAction, IGlobalEvent } from '../plugin';
|
|
6
6
|
import type { SchemaObject } from 'amis';
|
|
7
7
|
import type { VariableGroup, VariableOptions } from '../variable';
|
|
8
8
|
import type { EditorNodeType } from '../store/node';
|
|
@@ -74,6 +74,7 @@ export interface EditorProps extends PluginEventListener {
|
|
|
74
74
|
customActionGetter?: (manager: EditorManager) => {
|
|
75
75
|
[propName: string]: RendererPluginAction;
|
|
76
76
|
};
|
|
77
|
+
globalEventGetter?: (manager: EditorManager) => IGlobalEvent[];
|
|
77
78
|
};
|
|
78
79
|
/** 上下文变量 */
|
|
79
80
|
variables?: VariableGroup[];
|
|
@@ -91,6 +92,9 @@ export interface EditorProps extends PluginEventListener {
|
|
|
91
92
|
getHostNodeDataSchema?: () => Promise<any>;
|
|
92
93
|
getAvaiableContextFields?: (node: EditorNodeType) => Promise<any>;
|
|
93
94
|
readonly?: boolean;
|
|
95
|
+
onEditorMount?: (manager: EditorManager) => void;
|
|
96
|
+
onEditorUnmount?: (manager: EditorManager) => void;
|
|
97
|
+
children?: React.ReactNode | ((manager: EditorManager) => React.ReactNode);
|
|
94
98
|
}
|
|
95
99
|
export default class Editor extends Component<EditorProps> {
|
|
96
100
|
readonly store: EditorStoreType;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditorManager } from '../manager';
|
|
3
|
+
import { EditorStoreType } from '../store/editor';
|
|
4
|
+
export interface ModalFormProps {
|
|
5
|
+
store: EditorStoreType;
|
|
6
|
+
manager: EditorManager;
|
|
7
|
+
theme?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class ModalForm extends React.Component<ModalFormProps> {
|
|
10
|
+
handleConfirmClick(): Promise<void>;
|
|
11
|
+
amisScope: any;
|
|
12
|
+
scopeRef(scoped: any): void;
|
|
13
|
+
buildSchema(): {
|
|
14
|
+
type: string;
|
|
15
|
+
wrapWithPanel: boolean;
|
|
16
|
+
mode: string;
|
|
17
|
+
wrapperComponent: string;
|
|
18
|
+
initApi: any;
|
|
19
|
+
api: any;
|
|
20
|
+
body: any[];
|
|
21
|
+
submitOnChange: boolean;
|
|
22
|
+
autoFocus: boolean;
|
|
23
|
+
};
|
|
24
|
+
render(): React.JSX.Element;
|
|
25
|
+
}
|
|
@@ -16,7 +16,7 @@ export default class BackTop extends React.Component<BackTopProps, BackTopStates
|
|
|
16
16
|
constructor(props: any);
|
|
17
17
|
componentDidMount(): void;
|
|
18
18
|
componentWillUnmount(): void;
|
|
19
|
-
getDefaultTarget():
|
|
19
|
+
getDefaultTarget(): (Window & typeof globalThis) | Document;
|
|
20
20
|
handleScroll(e: React.UIEvent<HTMLElement> | {
|
|
21
21
|
target: any;
|
|
22
22
|
}): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 深度 splice 数组,同时返回新的对象,按需拷贝,没有副作用
|
|
3
|
+
*
|
|
4
|
+
* 第二个参数可以是一个函数,函数的返回值不为 false 时,表示找到了目标,函数的返回值为 number 时,表示偏移量
|
|
5
|
+
*
|
|
6
|
+
* @param target
|
|
7
|
+
* @param path
|
|
8
|
+
* @param numberToDelete
|
|
9
|
+
* @param items
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function deepSplice(target: any, path: string | ((value: any, index: number | string, stack: Array<any>) => any), numberToDelete: number, provider?: ((origin: any) => any) | any, ...items: any[]): any;
|
package/lib/editor.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ import { UnknownRendererPlugin } from './plugin/Unknown';
|
|
|
39
39
|
import ShortcutKey from './component/base/ShortcutKey';
|
|
40
40
|
import WidthDraggableContainer from './component/base/WidthDraggableContainer';
|
|
41
41
|
import { SchemaFrom } from './component/base/SchemaForm';
|
|
42
|
+
import { RendererThumb } from './component/RendererThumb';
|
|
43
|
+
import { AvailableRenderersPanel } from './component/Panel/AvailableRenderersPanel';
|
|
44
|
+
import { deepSplice } from './deepSplice';
|
|
42
45
|
export declare const version = "__buildVersion";
|
|
43
46
|
export default Editor;
|
|
44
|
-
export { Editor, MiniEditor, utils, mapReactElement, RendererEditor, BasicEditor, CodeEditor, VRenderer, RegionWrapper, IFramePreview as IFrameEditor, SearchPanel, EditorNodeType, EditorNodeSnapshot, EditorStoreType, ContainerWrapper, AvailableRenderersPlugin, BasicToolbarPlugin, CodePlugin, ErrorRendererPlugin, OutlinePlugin, UnknownRendererPlugin, ShortcutKey, SchemaFrom, WidthDraggableContainer };
|
|
47
|
+
export { Editor, MiniEditor, utils, deepSplice, mapReactElement, RendererEditor, BasicEditor, CodeEditor, VRenderer, RegionWrapper, IFramePreview as IFrameEditor, SearchPanel, EditorNodeType, EditorNodeSnapshot, EditorStoreType, ContainerWrapper, AvailableRenderersPlugin, AvailableRenderersPanel, BasicToolbarPlugin, CodePlugin, ErrorRendererPlugin, OutlinePlugin, UnknownRendererPlugin, ShortcutKey, SchemaFrom, WidthDraggableContainer, RendererThumb };
|