refactor(core): cleanup edge and node renderer
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
import { NodeWrapper } from '../../components'
|
||||
import type { GraphNode, HandleConnectable, NodeComponent } from '../../types'
|
||||
import type { GraphNode, NodeComponent } from '../../types'
|
||||
|
||||
const slots = inject(Slots)
|
||||
|
||||
const {
|
||||
nodesDraggable,
|
||||
nodesFocusable,
|
||||
elementsSelectable,
|
||||
nodesConnectable,
|
||||
nodes,
|
||||
getNodes,
|
||||
getNodesInitialized,
|
||||
getNodeTypes,
|
||||
updateNodeDimensions,
|
||||
emits,
|
||||
} = $(useVueFlow())
|
||||
const { nodes, getNodes, getNodesInitialized, getNodeTypes, updateNodeDimensions, emits } = $(useVueFlow())
|
||||
|
||||
let resizeObserver = $ref<ResizeObserver>()
|
||||
|
||||
@@ -44,12 +33,6 @@ onMounted(() => {
|
||||
|
||||
onBeforeUnmount(() => resizeObserver?.disconnect())
|
||||
|
||||
const draggable = (nodeDraggable?: boolean) => (typeof nodeDraggable === 'undefined' ? nodesDraggable : nodeDraggable)
|
||||
const selectable = (nodeSelectable?: boolean) => (typeof nodeSelectable === 'undefined' ? elementsSelectable : nodeSelectable)
|
||||
const connectable = (nodeConnectable?: HandleConnectable) =>
|
||||
typeof nodeConnectable === 'undefined' ? nodesConnectable : nodeConnectable
|
||||
const focusable = (nodeFocusable?: boolean) => (typeof nodeFocusable === 'undefined' ? nodesFocusable : nodeFocusable)
|
||||
|
||||
function getType(type?: string, template?: GraphNode['template']) {
|
||||
const name = type || 'default'
|
||||
let nodeType = template ?? getNodeTypes[name]
|
||||
@@ -92,10 +75,6 @@ export default {
|
||||
:resize-observer="resizeObserver"
|
||||
:type="getType(node.type, node.template)"
|
||||
:name="node.type || 'default'"
|
||||
:draggable="draggable(node.draggable)"
|
||||
:selectable="selectable(node.selectable)"
|
||||
:connectable="connectable(node.connectable)"
|
||||
:focusable="focusable(node.focusable)"
|
||||
:node="node"
|
||||
/>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user