refactor(editor): 支持doPaste插件 (#299)

* refactor(editor): 粘贴时添加粘贴选项,用于格式化粘贴对象数据。

* refactor(editor): 支持doPaste插件
This commit is contained in:
王明华 2022-08-22 17:36:02 +08:00 committed by GitHub
parent a7fa9f3a29
commit 56b8ed1d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,6 +71,7 @@ class Editor extends BaseService {
'sort',
'copy',
'paste',
'doPaste',
'duAlignCenter',
'alignCenter',
'moveLayer',
@ -556,11 +557,16 @@ class Editor extends BaseService {
if (!Array.isArray(config)) return;
const pasteConfigs = await beforePaste(position, config);
const pasteConfigs = await this.doPaste(config, position);
return this.add(pasteConfigs);
}
public async doPaste(config: MNode[], position: PastePosition = {}): Promise<MNode[]> {
const pasteConfigs = await beforePaste(position, cloneDeep(config));
return pasteConfigs;
}
public async doAlignCenter(config: MNode): Promise<MNode> {
const parent = this.getParentById(config.id);