3358 Adding types for blockArrowHelper

This commit is contained in:
Knut Sveidqvist
2024-01-30 17:48:46 +01:00
parent 7bcdea9bd1
commit 6fce617284
2 changed files with 11 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
const expandAndDeduplicateDirections = (directions) => { import type { Direction } from '../../src/diagrams/block/blockTypes.js';
const expandAndDeduplicateDirections = (directions: Direction[]) => {
const uniqueDirections = new Set(); const uniqueDirections = new Set();
for (const direction of directions) { for (const direction of directions) {
@@ -19,7 +21,11 @@ const expandAndDeduplicateDirections = (directions) => {
return uniqueDirections; return uniqueDirections;
}; };
export const getArrowPoints = (duplicatedDirections, bbox, node) => { export const getArrowPoints = (
duplicatedDirections: Direction[],
bbox: { width: number; height: number },
node: any
) => {
// Expand and deduplicate the provided directions. // Expand and deduplicate the provided directions.
// for instance: x, right => right, left // for instance: x, right => right, left
const directions = expandAndDeduplicateDirections(duplicatedDirections); const directions = expandAndDeduplicateDirections(duplicatedDirections);
@@ -37,7 +43,7 @@ export const getArrowPoints = (duplicatedDirections, bbox, node) => {
const padding = node.padding / 2; const padding = node.padding / 2;
// Initialize an empty array to store points for the arrow. // Initialize an empty array to store points for the arrow.
let points = []; const points = [];
if ( if (
directions.has('right') && directions.has('right') &&

View File

@@ -64,3 +64,5 @@ export interface ClassDef {
textStyles: string[]; textStyles: string[];
styles: string[]; styles: string[];
} }
export type Direction = 'up' | 'down' | 'left' | 'right' | 'x' | 'y';