Skip to content

Commit 553fc78

Browse files
Added square path route type
1 parent 9d70654 commit 553fc78

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

src/@types/Canvas.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export interface CanvasEdgeData {
246246
toSide: Side
247247

248248
edgeStyle?: 'long-dashed' | 'short-dashed' | 'dotted'
249-
edgePathRoute?: 'direct' | 'a-star'
249+
edgePathRoute?: 'direct' | 'square' | 'a-star'
250250

251251
portalId?: string
252252
isUnsaved?: boolean

src/canvas-extensions/edges-style-canvas-extension.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ const ROUTES_MENU_OPTIONS: CanvasHelper.MenuOption[] = [
4040
label: 'Direct',
4141
icon: 'minus'
4242
},
43+
{
44+
id: 'square',
45+
label: 'Square',
46+
icon: 'corner-down-right'
47+
},
4348
{
4449
id: 'a-star',
4550
label: 'A*',
@@ -175,6 +180,29 @@ export default class EdgesStyleCanvasExtension {
175180
x: (fromPos.x + toPos.x) / 2,
176181
y: (fromPos.y + toPos.y) / 2
177182
}
183+
} else if (pathRouteType === 'square') {
184+
let pathArray: Position[] = []
185+
if (edge.from.side === 'bottom' || edge.from.side === 'top') {
186+
pathArray = [
187+
fromPos,
188+
{ x: fromPos.x, y: fromPos.y + (toPos.y - fromPos.y) / 2 },
189+
{ x: toPos.x, y: fromPos.y + (toPos.y - fromPos.y) / 2 },
190+
toPos
191+
]
192+
} else {
193+
pathArray = [
194+
fromPos,
195+
{ x: fromPos.x + (toPos.x - fromPos.x) / 2, y: fromPos.y },
196+
{ x: fromPos.x + (toPos.x - fromPos.x) / 2, y: toPos.y },
197+
toPos
198+
]
199+
}
200+
201+
newPath = SvgPathHelper.pathArrayToSvgPath(pathArray, false)
202+
edge.center = {
203+
x: (fromPos.x + toPos.x) / 2,
204+
y: (fromPos.y + toPos.y) / 2
205+
}
178206
} else if (pathRouteType === 'a-star') {
179207
if (canvas.isDragging && !this.plugin.settings.getSetting('edgeStylePathfinderPathLiveUpdate')) return
180208

src/settings.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ const NODE_TYPES_ON_DOUBLE_CLICK = {
66
'file': 'File'
77
}
88

9-
/*const SLIDE_SIZE_OPTIONS = {
10-
'1200x675': '16:9',
11-
'1350x900': '3:2',
12-
}*/
13-
149
export interface AdvancedCanvasPluginSettings {
1510
nodeTypeOnDoubleClick: string
1611
defaultTextNodeWidth: number
@@ -67,7 +62,7 @@ export const DEFAULT_SETTINGS: Partial<AdvancedCanvasPluginSettings> = {
6762
edgesStylingFeatureEnabled: true,
6863
edgeStylePathfinderGridResolution: 10,
6964
edgeStylePathfinderPathLiveUpdate: true,
70-
edgeStylePathfinderPathRounded: false,
65+
edgeStylePathfinderPathRounded: true,
7166

7267
commandsFeatureEnabled: true,
7368
zoomToClonedNode: true,

0 commit comments

Comments
 (0)