@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
33 lines (32 loc) • 1.45 kB
TypeScript
import type { LengthGuide } from './types';
/**
* This creates a collection of points relative to the center line of each supplied length. For example; a length of
* 100 centered to 0 would result in the left position of -50 and a right position of +50.
*
* Length values should be unique, as duplicates will be trimmed from the result.
*
* @example
* createGuidelinesFromLengths([100, 200, 200, -200, 201]) => [
* {left: -50, right: 50, length: 100},
* {left: -100, right: 100, length: 200},
* {left: 100, right: -100, length: -200},
* {left: -100.5, right: 100.5, length: 201},
* ]
* When length is 0, return {left: 0, right: 0, length: 0}
*
* @param lengths A colection of length values which will be split into a left & right guides.
* @returns A collection of LengthGuide objects which can be used to draw left & right guides
*/
export declare const createGuidesFromLengths: (lengths: number[], isMaxLengthFullWidth?: boolean) => LengthGuide[];
/**
* This creates a Guideline configuration generating a collection of guideline pairs from each supplied length value.
* Each length value generates a guideline config for both the left and right side of the length.
* When length is 0, generate a guideline at position: {x: 0}
*
*/
export declare const createFixedGuidelinesFromLengths: (lengths: number[], key?: string, isMaxLengthFullWidth?: boolean) => {
key: string;
position: {
x: number;
};
}[];