Skip to content

Commit

Permalink
feat: add allowNodeInsertOnEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtengjin committed Dec 5, 2023
1 parent 1032c28 commit 7d8a1f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ http://localhost:3000
<td>false</td>
<td>是否显示小地图</td>
</tr>
<tr>
<td>allowNodeInsertOnEdge</td>
<td>boolean</td>
<td></td>
<td>是否开启拖拽节点到线中间进行节点插入</td>
</tr>
<tr>
<td>canConnectMultiLines</td>
<td>bool</td>
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/topology/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface ITopologyProps {
showDownload?: boolean; // 是否显示工具栏中的下载图片
showMinimap?: boolean; // 是否显示小地图
downloadImg?: (scopeType?: 'global' | 'selected', download?: boolean, name?: string) => void;
allowNodeInsertOnEdge?: boolean; // 是否开启拖拽节点到线中间进行节点插入
canConnectMultiLines?: boolean; // 控制一个锚点是否可以连接多条线
overlap?: boolean; // 是否允许节点覆盖,默认允许,设置 true 时不允许
overlapCallback?: () => void; // overlap 回调
Expand Down Expand Up @@ -1241,14 +1242,14 @@ class Topology extends React.Component<ITopologyProps, ITopologyState> {
* @returns
*/
generateLinesByInsertNodeInLine = (dragId, targetPos) => {
const { data, lineColor } = this.props;
const { data, lineColor, allowNodeInsertOnEdge = false } = this.props;
let insertLines = [];
let cloneLines = [...data.lines];

const linePointsMap = this.getCurvePointsAndLineOriginMap();
const isolated = dragId && isolatedNode(data, dragId);
// 拖动单个孤立节点,才会触发快捷插入逻辑
if (isolated) {
if (allowNodeInsertOnEdge && isolated) {
const nodeSize = getNodeSize(dragId);
const minX = targetPos.x;
const minY = targetPos.y;
Expand Down

0 comments on commit 7d8a1f6

Please sign in to comment.