mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-06 23:59:37 +02:00
3358 Adding types for blockArrowHelper
This commit is contained in:
@@ -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') &&
|
@@ -64,3 +64,5 @@ export interface ClassDef {
|
|||||||
textStyles: string[];
|
textStyles: string[];
|
||||||
styles: string[];
|
styles: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Direction = 'up' | 'down' | 'left' | 'right' | 'x' | 'y';
|
||||||
|
Reference in New Issue
Block a user