feat(editor): editorService.add 的addNode参数对象中加上inputEvent

This commit is contained in:
roymondchen 2022-07-26 16:26:44 +08:00 committed by jia000
parent 0450de481f
commit c1fc6b8f94
4 changed files with 6 additions and 2 deletions

View File

@ -264,6 +264,8 @@ export default defineComponent({
left, left,
}; };
config.inputEvent = e;
services?.editorService.add(config, parent); services?.editorService.add(config, parent);
} }
}, },

View File

@ -271,7 +271,8 @@ class Editor extends BaseService {
* @returns * @returns
*/ */
public async add(addNode: AddMNode, parent?: MContainer | null): Promise<MNode> { public async add(addNode: AddMNode, parent?: MContainer | null): Promise<MNode> {
const { type, ...config } = addNode; // 加入inputEvent是为给业务扩展时可以获取到更多的信息只有在使用拖拽添加组件时才有改对象
const { type, inputEvent, ...config } = addNode;
const curNode = this.get<MContainer>('node'); const curNode = this.get<MContainer>('node');
let parentNode: MContainer | undefined; let parentNode: MContainer | undefined;

View File

@ -88,7 +88,7 @@ class Props extends BaseService {
* @param type * @param type
* @returns * @returns
*/ */
public async getPropsValue(type: string, defaultValue: Record<string, any> = {}) { public async getPropsValue(type: string, { inputEvent, ...defaultValue }: Record<string, any> = {}) {
if (type === 'area') { if (type === 'area') {
const value = (await this.getPropsValue('button')) as MComponent; const value = (await this.getPropsValue('button')) as MComponent;
value.className = 'action-area'; value.className = 'action-area';

View File

@ -125,6 +125,7 @@ export interface EditorNodeInfo {
export interface AddMNode { export interface AddMNode {
type: string; type: string;
name?: string; name?: string;
inputEvent?: DragEvent;
[key: string]: any; [key: string]: any;
} }