Editor API
初始化
interface EditorConfig {
// Configuration for the editor items
items: Array<Record<string, any>>;
// Automatically apply changes to the data object
autoSave?: boolean;
// Define the current active batch for the editor
activeBatch?: string;
// Configuration for the top toolbar
topBar?: {
// Array of items for the toolbar
items: Array<Record<string, any>>;
};
// Configuration for the bottom toolbar
bottomBar?: {
// Array of items for the toolbar
items: Array<Record<string, any>>;
};
// Additional CSS class for the editor's box
css?: string;
// Initial values for the editor fields
values?: Record<string, any>;
// Placement of the editor (inline, modal, sidebar)
placement?: "inline" | "modal" | "sidebar";
// Set the editor to readonly mode
readonly?: boolean;
// Define layout for the editor
layout?: "columns" | "default";
// Function to handle action events
onaction?: (ev: OnActionResult) => void;
// Function to handle change events
onchange?: (ev: OnChangeResult) => void;
// Function to handle save events
onsave?: (ev: OnSaveResult) => void;
// Function to handle validation events
onvalidation?: (ev: OnValidationResult) => void;
}
属性
| activeBatch | 可选。控制编辑器中当前激活的输入批次 |
| autoSave | 可选。控制编辑器中数据的自动保存 |
| bottomBar | 可选。控制编辑器底部工具栏的配置 |
| css | 可选。为编辑器的容器框定义 CSS 类 |
| focus | 可选。控制编辑器 widget 在渲染时是否自动获得焦点 |
| hotkeys | 可选。允许为编辑器操作指定自定义快捷键 |
| items | 可选。定义在 Editor 中渲染的组件 |
| layout | 可选。控制编辑器组件的布局 |
| placement | 可选。控制编辑器组件的显示位置 |
| readonly | 可选。控制编辑器是否处于只读模式 |
| topBar | 可选。控制编辑器顶部工具栏的配置 |
| values | 可选。定义编辑器字段的初始值 |
Events
| action | 当编辑器中任意字段发生变更时触发 |
| change | 当编辑器中任意字段发生变更时触发 |
| save | 当用户请求保存编辑器中的数据时触发 |
| validation | 在验证过程完成时触发 |
辅 助工具
registerEditorItem- 将外部控件注册为 editor items