From a895853b6449c8c0076710942d2645170ca4a2b6 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Tue, 19 Oct 2021 19:23:30 +0200 Subject: [PATCH] update: Add injection keys --- examples/EdgeTypes/utils.ts | 42 ++++------------ .../ConnectionLine/ConnectionLine.vue | 8 +-- src/components/Edges/Edge.vue | 8 +-- src/components/Handle/Handle.vue | 8 +-- src/components/Nodes/Node.vue | 8 +-- .../NodesSelection/NodesSelection.vue | 8 +-- .../UserSelection/UserSelection.vue | 4 +- src/composables/useZoom.ts | 6 +-- src/container/EdgeRenderer/EdgeRenderer.vue | 13 ++--- src/container/Flow/Flow.vue | 14 +++--- src/container/NodeRenderer/NodeRenderer.vue | 5 +- src/container/SelectionPane/SelectionPane.vue | 8 +-- src/container/ZoomPane/ZoomPane.vue | 5 +- src/context/symbols.ts | 5 ++ src/hooks/RevueFlowHooks.ts | 49 ++----------------- src/hooks/useGlobalKeyHandler.ts | 5 +- src/types/hooks.ts | 45 +++++++++++++++++ src/types/index.ts | 1 + src/types/store.ts | 4 +- 19 files changed, 113 insertions(+), 133 deletions(-) create mode 100644 src/context/symbols.ts create mode 100644 src/types/hooks.ts diff --git a/examples/EdgeTypes/utils.ts b/examples/EdgeTypes/utils.ts index 12a5ea01..0d7c7c63 100644 --- a/examples/EdgeTypes/utils.ts +++ b/examples/EdgeTypes/utils.ts @@ -2,50 +2,26 @@ import { ElementId, Elements, Position } from '../../src' const nodeWidth = 80 const nodeGapWidth = nodeWidth * 2 -const nodeStyle = { width: nodeWidth + 'px', fontSize: '11px', color: 'white' } +const nodeStyle = { width: `${nodeWidth}px`, fontSize: '11px', color: 'white' } const sourceTargetPositions = [ { source: Position.Bottom, target: Position.Top }, - { source: Position.Right, target: Position.Left } + { source: Position.Right, target: Position.Left }, ] const nodeColors = [ ['#1e9e99', '#4cb3ac', '#6ec9c0', '#8ddfd4'], - ['#0f4c75', '#1b5d8b', '#276fa1', '#3282b8'] + ['#0f4c75', '#1b5d8b', '#276fa1', '#3282b8'], ] const edgeTypes = ['default', 'step', 'smoothstep', 'straight'] const offsets = [ { x: 0, - y: -nodeGapWidth + y: -nodeGapWidth, }, { x: nodeGapWidth, - y: -nodeGapWidth + y: -nodeGapWidth, }, - { - x: nodeGapWidth, - y: 0 - }, - { - x: nodeGapWidth, - y: nodeGapWidth - }, - { - x: 0, - y: nodeGapWidth - }, - { - x: -nodeGapWidth, - y: nodeGapWidth - }, - { - x: -nodeGapWidth, - y: 0 - }, - { - x: -nodeGapWidth, - y: -nodeGapWidth - } ] let id = 0 @@ -66,7 +42,7 @@ export function getElements(): Elements { const style = { ...nodeStyle, background: nodeColors[sourceTargetIndex][edgeTypeIndex] } const sourcePosition = { x: offsetIndex * nodeWidth * 4, - y: edgeTypeIndex * 300 + sourceTargetIndex * edgeTypes.length * 300 + y: edgeTypeIndex * 300 + sourceTargetIndex * edgeTypes.length * 300, } const sourceId = getNodeId() const sourceData = { label: `Source ${sourceId}` } @@ -76,14 +52,14 @@ export function getElements(): Elements { data: sourceData, position: sourcePosition, sourcePosition: currSourceTargetPos.source, - targetPosition: currSourceTargetPos.target + targetPosition: currSourceTargetPos.target, } const targetId = getNodeId() const targetData = { label: `Target ${targetId}` } const targetPosition = { x: sourcePosition.x + currOffset.x, - y: sourcePosition.y + currOffset.y + y: sourcePosition.y + currOffset.y, } const targetNode = { id: targetId, @@ -91,7 +67,7 @@ export function getElements(): Elements { data: targetData, position: targetPosition, sourcePosition: currSourceTargetPos.source, - targetPosition: currSourceTargetPos.target + targetPosition: currSourceTargetPos.target, } initialElements.push(sourceNode) diff --git a/src/components/ConnectionLine/ConnectionLine.vue b/src/components/ConnectionLine/ConnectionLine.vue index 62f13140..fe3819a8 100644 --- a/src/components/ConnectionLine/ConnectionLine.vue +++ b/src/components/ConnectionLine/ConnectionLine.vue @@ -1,8 +1,8 @@