@textbus/platform-browser
Version:
Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.
83 lines (82 loc) • 2.43 kB
TypeScript
/**
* 选区焦点可视位置
*/
export interface Rect {
left: number;
top: number;
width: number;
height: number;
}
export interface OverflowClipAncestor {
element: Element;
clipX: boolean;
clipY: boolean;
}
export interface OverflowClipContext {
/** 自内而外 */
clipAncestors: OverflowClipAncestor[];
scrollContainers: Element[];
/** 嵌套滚动时最近的 overflow 容器 */
firstScrollContainer: Element;
}
/**
* 一次遍历祖先链:缓存 overflow 轴信息,并收集滚动监听目标。
*/
export declare function getOverflowClipContext(anchor: Node, extraRoot?: Element): OverflowClipContext;
export interface CaretBoxLayout {
boxHeight: number;
rectTop: number;
}
/** 根据行高与内容矩形计算光标盒高度与顶部(视口坐标) */
export declare function measureCaretBoxLayout(contentRect: Rect, style: CSSStyleDeclaration): CaretBoxLayout;
/** 测量行内旋转角度(writing-mode 继承) */
export declare function measureInlineCaretRotate(node: HTMLElement, initialRotate: number, writingMode: string): number;
export interface CaretPresentation {
outOfView: boolean;
clipPath: string;
layoutElRect: Rect;
position: {
left: number;
top: number;
height: number;
};
caretColor: string;
style: {
height: string;
lineHeight: string;
fontSize: string;
};
}
export interface ComputeCaretPresentationOptions {
anchor: HTMLElement;
maskRect: Rect;
clipAncestors: OverflowClipAncestor[];
maskLeft: number;
maskTop: number;
boxHeight: number;
rectTop: number;
contentRect: Rect;
fontSize: string;
color: string;
measureElementRect: () => Rect;
}
/**
* 在 element 样式已写入后调用:计算裁剪、是否移出视口及对外事件数据。
*/
export declare function computeCaretPresentation(options: ComputeCaretPresentationOptions): CaretPresentation;
export interface UIElementParams {
classes?: string[];
attrs?: {
[key: string]: any;
};
props?: {
[key: string]: any;
};
styles?: {
[key: string]: any;
};
children?: (Node | null)[];
on?: Record<string, (ev: Event) => void>;
}
export declare function createElement(tagName: string, options?: UIElementParams): HTMLElement;
export declare function getLayoutRectByRange(range: Range): Rect;