Skip to content

Commit

Permalink
feat(editor): editorService.add 的addNode参数对象中加上inputEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen authored and jia000 committed Jul 26, 2022
1 parent 0450de4 commit c1fc6b8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/editor/src/layouts/workspace/Stage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ export default defineComponent({
left,
};
config.inputEvent = e;
services?.editorService.add(config, parent);
}
},
Expand Down
3 changes: 2 additions & 1 deletion packages/editor/src/services/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ class Editor extends BaseService {
* @returns 添加后的节点
*/
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');

let parentNode: MContainer | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/services/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Props extends BaseService {
* @param type 组件类型
* @returns 组件初始值
*/
public async getPropsValue(type: string, defaultValue: Record<string, any> = {}) {
public async getPropsValue(type: string, { inputEvent, ...defaultValue }: Record<string, any> = {}) {
if (type === 'area') {
const value = (await this.getPropsValue('button')) as MComponent;
value.className = 'action-area';
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export interface EditorNodeInfo {
export interface AddMNode {
type: string;
name?: string;
inputEvent?: DragEvent;
[key: string]: any;
}

Expand Down

0 comments on commit c1fc6b8

Please sign in to comment.