refactor(core): cleanup edge and node renderer

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-03-02 08:47:38 +01:00
committed by Braks
parent e5a2a79605
commit 4d535ed34c
4 changed files with 42 additions and 54 deletions
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import EdgeWrapper from '../../components/Edges/EdgeWrapper'
import ConnectionLine from '../../components/ConnectionLine/ConnectionLine.vue'
import type { EdgeComponent, EdgeUpdatable, GraphEdge } from '../../types'
import type { EdgeComponent, GraphEdge } from '../../types'
import MarkerDefinitions from './MarkerDefinitions.vue'
const slots = inject(Slots)
@@ -9,9 +9,6 @@ const slots = inject(Slots)
const {
connectionStartHandle,
nodesConnectable,
edgesUpdatable,
edgesFocusable,
elementsSelectable,
getSelectedNodes,
findNode,
getEdges,
@@ -53,10 +50,6 @@ onBeforeUnmount(() => {
stop?.()
})
const selectable = (edgeSelectable?: boolean) => (typeof edgeSelectable === 'undefined' ? elementsSelectable : edgeSelectable)
const updatable = (edgeUpdatable?: EdgeUpdatable) => (typeof edgeUpdatable === 'undefined' ? edgesUpdatable : edgeUpdatable)
const focusable = (edgeFocusable?: boolean) => (typeof edgeFocusable === 'undefined' ? edgesFocusable : edgeFocusable)
function getType(type?: string, template?: GraphEdge['template']) {
const name = type || 'default'
let edgeType = template ?? getEdgeTypes[name]
@@ -100,9 +93,6 @@ export default {
:edge="edge"
:type="getType(edge.type, edge.template)"
:name="edge.type || 'default'"
:selectable="selectable(edge.selectable)"
:updatable="updatable(edge.updatable)"
:focusable="focusable(edge.focusable)"
/>
</g>
</svg>