@@ -8,6 +8,10 @@ import EdgePathfindingDirect from "./edge-pathfinding-methods/pathfinding-direct
88import EdgePathfindingSquare from "./edge-pathfinding-methods/pathfinding-square"
99import { BUILTIN_EDGE_STYLE_ATTRIBUTES , StyleAttribute , styleAttributeValidator } from "./style-config"
1010import CssStylesConfigManager from "src/managers/css-styles-config-manager"
11+ import AdvancedCanvasPlugin from "src/main"
12+
13+ export const GET_EDGE_CSS_STYLES_MANAGER = ( plugin : AdvancedCanvasPlugin ) =>
14+ new CssStylesConfigManager ( plugin , 'advanced-canvas-edge-style' , styleAttributeValidator )
1115
1216const EDGE_PATHFINDING_METHODS : { [ key : string ] : typeof EdgePathfindingMethod } = {
1317 'direct' : EdgePathfindingDirect ,
@@ -22,7 +26,7 @@ export default class EdgeStylesExtension extends CanvasExtension {
2226 isEnabled ( ) { return 'edgesStylingFeatureEnabled' as const }
2327
2428 init ( ) {
25- this . cssStylesManager = new CssStylesConfigManager ( this . plugin , 'advanced-canvas-edge-style' , styleAttributeValidator )
29+ this . cssStylesManager = GET_EDGE_CSS_STYLES_MANAGER ( this . plugin )
2630
2731 this . plugin . registerEvent ( this . plugin . app . workspace . on (
2832 'advanced-canvas:popup-menu-created' ,
@@ -43,7 +47,7 @@ export default class EdgeStylesExtension extends CanvasExtension {
4347 'advanced-canvas:node-added' ,
4448 ( canvas : Canvas , node : CanvasNode ) => {
4549 if ( canvas . dirty . size > 1 && ! canvas . isPasting ) return // Skip if multiple nodes are added at once (e.g. on initial load)
46-
50+
4751 this . updateAllEdgesInArea ( canvas , node . getBBox ( ) )
4852 }
4953 ) )
@@ -106,7 +110,7 @@ export default class EdgeStylesExtension extends CanvasExtension {
106110 }
107111 } )
108112 }
109-
113+
110114 canvas . pushHistory ( canvas . getData ( ) )
111115 }
112116
@@ -133,7 +137,7 @@ export default class EdgeStylesExtension extends CanvasExtension {
133137 }
134138
135139 const edgeData = edge . getData ( )
136-
140+
137141 // Reset path to default
138142 if ( ! edge . bezier ) return
139143 edge . center = undefined
@@ -144,20 +148,20 @@ export default class EdgeStylesExtension extends CanvasExtension {
144148 if ( pathfindingMethod && pathfindingMethod in EDGE_PATHFINDING_METHODS ) {
145149 const fromNodeBBox = edge . from . node . getBBox ( )
146150 const fromBBoxSidePos = BBoxHelper . getCenterOfBBoxSide ( fromNodeBBox , edge . from . side )
147- const fromPos = edge . from . end === 'none' ?
151+ const fromPos = edge . from . end === 'none' ?
148152 fromBBoxSidePos :
149153 edge . bezier . from
150-
154+
151155 const toNodeBBox = edge . to . node . getBBox ( )
152156 const toBBoxSidePos = BBoxHelper . getCenterOfBBoxSide ( toNodeBBox , edge . to . side )
153- const toPos = edge . to . end === 'none' ?
157+ const toPos = edge . to . end === 'none' ?
154158 toBBoxSidePos :
155159 edge . bezier . to
156160
157161 const path = new ( EDGE_PATHFINDING_METHODS [ pathfindingMethod ] as any ) (
158- this . plugin ,
159- canvas ,
160- fromNodeBBox , fromPos , fromBBoxSidePos , edge . from . side ,
162+ this . plugin ,
163+ canvas ,
164+ fromNodeBBox , fromPos , fromBBoxSidePos , edge . from . side ,
161165 toNodeBBox , toPos , toBBoxSidePos , edge . to . side
162166 ) . getPath ( )
163167 if ( ! path ) return
@@ -195,4 +199,4 @@ export default class EdgeStylesExtension extends CanvasExtension {
195199 else // Default triangle
196200 return `0,0 6.5,10.4 -6.5,10.4`
197201 }
198- }
202+ }
0 commit comments