-
Notifications
You must be signed in to change notification settings - Fork 1.4k
5.6~5.9 issue fix round 1 #2143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import LogicFlow, { BaseNodeModel } from '@logicflow/core' | ||
| import { concat } from 'lodash-es' | ||
| import LogicFlow, { BaseEdgeModel, BaseNodeModel } from '@logicflow/core' | ||
| import { uniqBy, concat } from 'lodash-es' | ||
|
|
||
| // 后续并入FlowPath | ||
| const getPath = (id: string, lf: LogicFlow) => { | ||
|
|
@@ -99,7 +99,8 @@ export class Highlight { | |
| this.enable = enable | ||
| } | ||
|
|
||
| setMode(mode: IMode) { | ||
| public setMode(mode: IMode) { | ||
| console.log('setMode', mode) | ||
| this.mode = mode | ||
| } | ||
|
|
||
|
|
@@ -119,11 +120,14 @@ export class Highlight { | |
| model.sourceNode.updateStyles(this.tempStyles[model.sourceNode.id]) | ||
| model.targetNode.updateStyles(this.tempStyles[model.targetNode.id]) | ||
| } | ||
| this.lf.emit('highlight:single', { | ||
| data: model, | ||
| }) | ||
| } | ||
|
|
||
| private highlightNeighbours(id: string) { | ||
| const model = this.lf.getModelById(id) | ||
|
|
||
| let relateElements: (BaseNodeModel | BaseEdgeModel)[] = [] | ||
| if (model?.BaseType === 'node') { | ||
| // 高亮节点 | ||
| model.updateStyles(this.tempStyles[id]) | ||
|
|
@@ -135,23 +139,46 @@ export class Highlight { | |
| concat(incomingEdges, outgoingEdges).forEach((edge) => { | ||
| edge.updateStyles(this.tempStyles[edge.id]) | ||
| }) | ||
| relateElements = uniqBy( | ||
| concat( | ||
| relateElements, | ||
| incomingNodes, | ||
| outgoingNodes, | ||
| incomingEdges, | ||
| outgoingEdges, | ||
| ), | ||
| 'id', | ||
| ) | ||
| } else if (model?.BaseType === 'edge') { | ||
| // 高亮边及对应的节点 | ||
| model.updateStyles(this.tempStyles[id]) | ||
| model.sourceNode.updateStyles(this.tempStyles[model.sourceNode.id]) | ||
| model.targetNode.updateStyles(this.tempStyles[model.targetNode.id]) | ||
| relateElements = [model.sourceNode, model.targetNode] | ||
| } | ||
| this.lf.emit('highlight:neighbours', { | ||
| data: model, | ||
| relateElements, | ||
| }) | ||
| } | ||
|
|
||
| private highlightPath(id: string) { | ||
| const path = getPath(id, this.lf) | ||
| const relateElements: any[] = [] | ||
| path.forEach((_id) => { | ||
| const elementModel = this.lf.getModelById(_id) | ||
| // 高亮路径上所有的边和节点 | ||
| this.lf.getModelById(_id)?.updateStyles(this.tempStyles[_id]) | ||
| elementModel?.updateStyles(this.tempStyles[_id]) | ||
| relateElements.push(elementModel) | ||
| }) | ||
| this.lf.emit('highlight:path', { | ||
| data: this.lf.getModelById(id), | ||
| relateElements, | ||
| }) | ||
| } | ||
|
|
||
| highlight(id: string, mode: IMode = this.mode) { | ||
| console.log('highlight', id, mode) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another one |
||
| if (!this.enable) return | ||
| if (Object.keys(this.tempStyles).length) { | ||
| this.restoreHighlight() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,10 +78,37 @@ export class ProximityConnect { | |
| }, | ||
| ) | ||
| // 节点、锚点拖拽结束事件 | ||
| this.lf.graphModel.eventCenter.on('node:drop,anchor:dragend', () => { | ||
| this.lf.graphModel.eventCenter.on('node:drop', () => { | ||
| if (!this.enable) return | ||
| this.handleDrop() | ||
| }) | ||
| // 锚点拖拽需要单独判断一下当前拖拽终点是否在某个锚点上,如果是,就不触发插件的连线,以免出现创建了两条连线的问题,表现见 issue 2140 | ||
| this.lf.graphModel.eventCenter.on('anchor:dragend', ({ e, edgeModel }) => { | ||
| if (!this.enable) return | ||
| const { | ||
| canvasOverlayPosition: { x: eventX, y: eventY }, | ||
| } = this.lf.graphModel.getPointByClient({ | ||
| x: e.clientX, | ||
| y: e.clientY, | ||
| }) | ||
|
|
||
| if (edgeModel && this.virtualEdge) { | ||
| const { id: virtualEdgeId } = this.virtualEdge as BaseEdgeModel | ||
| const { targetNodeId } = edgeModel as BaseEdgeModel | ||
| const targetNodeModel = | ||
| this.lf.graphModel.getNodeModelById(targetNodeId) | ||
| const dropPointIsAnchor = targetNodeModel?.anchors.some((anchor) => { | ||
| const { x, y } = anchor | ||
| return Math.abs(eventX - x) <= 10 && Math.abs(eventY - y) <= 10 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 确认下如果锚点大小调整了,会不会 dropPointIsAnchor 判断与实际不符 现在是判断 Math.abs(evtX - x) <= 10,相当于默认锚点大小为 10 |
||
| }) | ||
| if (dropPointIsAnchor) { | ||
| this.lf.deleteEdge(virtualEdgeId) | ||
| return | ||
| } | ||
| } | ||
|
|
||
| this.handleDrop() | ||
| }) | ||
| } | ||
|
|
||
| // 节点拖拽动作 | ||
|
|
@@ -335,6 +362,7 @@ export class ProximityConnect { | |
|
|
||
| // 增加实体边 | ||
| addActualEdge() { | ||
| console.log('addActualEdge') | ||
| if (isNil(this.virtualEdge)) return | ||
| const { | ||
| type, | ||
|
|
@@ -346,6 +374,7 @@ export class ProximityConnect { | |
| endPoint, | ||
| pointsList, | ||
| } = this.virtualEdge | ||
| this.lf.deleteEdge(this.virtualEdge.id) | ||
| this.lf.addEdge({ | ||
| type, | ||
| sourceNodeId, | ||
|
|
@@ -356,7 +385,6 @@ export class ProximityConnect { | |
| endPoint, | ||
| pointsList, | ||
| }) | ||
| this.lf.deleteEdge(this.virtualEdge.id) | ||
| } | ||
|
|
||
| // 设置虚拟边样式 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
干掉它