@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
70 lines (69 loc) • 1.74 kB
TypeScript
import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import type { CSSToken } from '@atlaskit/tokens';
export type WidthTypes = 'percentage' | 'pixel';
export type LengthGuide = {
left: number;
right: number;
length: number;
isFullWidth?: boolean;
};
export type Range = {
start: number;
end: number;
};
export type VerticalPosition = {
x: number;
y?: Range;
};
export type HorizontalPosition = {
x?: Range;
y: number;
};
export type Position = VerticalPosition | HorizontalPosition;
export type GuidelineStyles = {
active?: boolean;
show?: boolean;
styles?: {
capStyle?: 'line';
lineStyle?: 'dashed' | 'solid';
color?: CSSToken;
};
};
export type GuidelineConfig = {
key: string;
position: Position;
isFullWidth?: boolean;
} & GuidelineStyles;
export type GuidelineContainerRect = {
top: number;
left: number;
};
export type GuidelinePluginState = {
guidelines: GuidelineConfig[];
rect?: GuidelineContainerRect;
};
export interface GuidelinePluginOptions {
}
export type DisplayGrid = (props: GuidelinePluginState) => boolean;
export type DisplayGuideline = (view: EditorView) => DisplayGrid;
export type GuidelineSnap = {
guidelineKey: string;
width: number;
};
export type GuidelineSnapsReference = {
snaps: {
x?: number[];
y?: number[];
};
guidelineReference: GuidelineSnap[];
};
export type GuidelineTypes = 'default' | 'temporary' | 'relative' | 'none';
export type RelativeGuides = {
width?: {
[key: number]: NodeWithPos[];
};
height?: {
[key: number]: NodeWithPos[];
};
};