diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 6e3391c420..44de57336f 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -132,7 +132,7 @@ import NodeCreator from '@/components/NodeCreator/NodeCreator.vue'; import NodeSettings from '@/components/NodeSettings.vue'; import RunData from '@/components/RunData.vue'; -import { getLeftmostTopNode, getWorkflowCorners, scaleSmaller, scaleBigger, scaleReset, addOrRemoveMidpointArrow, addEndpointArrow, getDefaultOverlays } from './helpers'; +import { getLeftmostTopNode, getWorkflowCorners, scaleSmaller, scaleBigger, scaleReset, addOrRemoveMidpointArrow, addEndpointArrow, getDefaultOverlays, getIcon } from './helpers'; import mixins from 'vue-typed-mixins'; import { v4 as uuidv4} from 'uuid'; @@ -1342,7 +1342,7 @@ export default mixins( }); this.instance.bind('connection', (info: OnConnectionBindInfo) => { - info.connection.setConnector(['Flowchart', { cornerRadius: 8, stub: JSPLUMB_FLOWCHART_STUB, gap: 5, alwaysRespectStubs: true}]); + info.connection.setConnector(['Flowchart', { cornerRadius: 8, stub: JSPLUMB_FLOWCHART_STUB, gap: 5, alwaysRespectStubs: false}]); addEndpointArrow(info.connection); addOrRemoveMidpointArrow(info.connection); @@ -1368,14 +1368,24 @@ export default mixins( if (timer !== undefined) { clearTimeout(timer); } - const overlay = info.connection.getOverlay('remove-connection'); + const overlay = info.connection.getOverlay('connection-actions'); overlay.setVisible(true); + + const arrow = info.connection.getOverlay('midpoint-arrow'); + if (arrow) { + arrow.setVisible(false); + } }); info.connection.bind('mouseout', (connection: IConnection) => { timer = setTimeout(() => { - const overlay = info.connection.getOverlay('remove-connection'); + const overlay = info.connection.getOverlay('connection-actions'); overlay.setVisible(false); timer = undefined; + + const arrow = info.connection.getOverlay('midpoint-arrow'); + if (arrow) { + arrow.setVisible(true); + } }, 500); }); @@ -1383,13 +1393,13 @@ export default mixins( info.connection.addOverlay([ 'Label', { - id: 'remove-connection', - label: 'x', - cssClass: 'remove-connection-label', - visible: false, + id: 'connection-actions', + label: `
${getIcon('plus')}
${getIcon('trash')}
`, + cssClass: 'connection-actions', + visible: true, events: { mousedown: () => { - this.__removeConnectionByConnectionInfo(info, true); + // this.__removeConnectionByConnectionInfo(info, true); }, }, }, @@ -2421,4 +2431,28 @@ export default mixins( } } +.connection-actions { + > div { + border: 2px solid var(--color-text-base); + background-color: var(--color-background-xlight); + font-size: var(--font-size-2xs); + border-radius: var(--border-radius-base); + height: var(--spacing-l); + width: var(--spacing-l); + display: inline-flex; + align-items: center; + justify-content: center; + cursor: pointer; + + &:first-child { + margin-right: var(--spacing-xs); + } + + &:hover { + border-color: var(--color-primary); + color: var(--color-primary); + } + } +} + diff --git a/packages/editor-ui/src/views/helpers.ts b/packages/editor-ui/src/views/helpers.ts index 607ce5197d..7d4fefe4a5 100644 --- a/packages/editor-ui/src/views/helpers.ts +++ b/packages/editor-ui/src/views/helpers.ts @@ -127,7 +127,7 @@ export const addEndpointArrow = (connection: Connection) => { export const addOrRemoveMidpointArrow = (connection: Connection) => { const sourceEndpoint = connection.endpoints[0]; const targetEndpoint = connection.endpoints[1]; - const requiresArrow = sourceEndpoint.anchor.lastReturnValue[0] >= (targetEndpoint.anchor.lastReturnValue[0] - JSPLUMB_FLOWCHART_STUB); + const requiresArrow = sourceEndpoint.anchor.lastReturnValue[0] >= targetEndpoint.anchor.lastReturnValue[0]; const hasArrow = !!connection.getOverlay('midpoint-arrow'); @@ -154,3 +154,15 @@ export const addOrRemoveMidpointArrow = (connection: Connection) => { }, ]); }; + +export const getIcon = (name: string): string => { + if (name === 'trash') { + return ``; + } + + if (name === 'plus') { + return ``; + } + + return ''; +};