Skip to content

Commit

Permalink
fix(core): 类型定义 properties:change 改为 node:properties-change
Browse files Browse the repository at this point in the history
  • Loading branch information
HeatonZ authored and boyongjiong committed Oct 30, 2024
1 parent ac1726f commit 88e7a54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
48 changes: 21 additions & 27 deletions packages/core/src/event/eventArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,27 @@ interface NodeEventArgs {
'node:resize': NodeEventArgsPick<
'preData' | 'data' | 'model' | 'deltaX' | 'deltaY' | 'index'
>
/**
* 元素的 properties 发生改变
*/
'node:properties-change': {
/**
* 元素的 id
*/
id: string
/**
* 改变的 properties 的 key
*/
keys: string[]
/**
* 改变前的 properties
*/
preProperties: Record<string, any>
/**
* 改变后的 properties
*/
properties: Record<string, any>
}
}

type EdgeEventArgsPick<T extends 'data' | 'e' | 'position'> = Pick<
Expand Down Expand Up @@ -356,33 +377,6 @@ interface CommonEventArgs {
*/
position: ClientPosition
}
/**
* 元素的 properties 发生改变
*/
'properties:change': {
data: {
/**
* 元素的 id
*/
id: string
/**
* 元素的类型
*/
type: string
/**
* 改变的 properties 的 key
*/
keys: string[]
/**
* 改变前的 properties
*/
preProperties: Record<string, any>
/**
* 改变后的 properties
*/
properties: Record<string, any>
}
}
/**
* 进行画布平移或缩放等变化操作时触发
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/model/node/BaseNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ export class BaseNodeModel<P extends PropertiesType = PropertiesType>
this.properties = nextProperties
this.setAttributes()

// 触发更新节点 properties:change 的事件
// 触发更新节点 node:properties-change 的事件
this.graphModel.eventCenter.emit(EventType.NODE_PROPERTIES_CHANGE, {
id: this.id,
keys: updateKeys,
Expand Down

0 comments on commit 88e7a54

Please sign in to comment.