hi-mention
Version:
纯JS聊天框,兼容原生HTML/React/Vue等各种框架;支持@提及功能、插入富文本等多功能编辑器;内置H5和PC的交互样式
38 lines (37 loc) • 1.22 kB
TypeScript
import { UserInfo, UserSelectorOptions } from "./types";
export default class UserSelector {
element: HTMLDivElement;
get status(): "open" | "close";
set status(status: "open" | "close");
options: UserSelectorOptions;
constructor(el: Element | HTMLElement, options: Partial<UserSelectorOptions>);
/**
* 创建用户选项元素
* @param user 用户信息
* @returns 用户列表中的选项元素
*/
protected createUserItem(user: UserInfo): HTMLElement;
protected getCursorPosition(): {
left: number;
top: number;
right: number;
bottom: number;
positionY: "top" | "bottom";
positionX: "left" | "right";
} | null;
protected getH5Position(): "top" | "bottom";
/**
* 根据查询字符串显示用户列表项
* @param query
* @returns
*/
protected viewUserItems(query: string): boolean;
/**
* 设置用户选择器的位置
*/
protected setPosition(): void;
setOptions(options: Partial<UserSelectorOptions>): this;
open(query: string): void;
close(): void;
onSelectUser(fn: (user: UserInfo) => void): void;
}