UNPKG

hi-mention

Version:

纯JS聊天框,兼容原生HTML/React/Vue等各种框架;支持@提及功能、插入富文本等多功能编辑器;内置H5和PC的交互样式

58 lines (57 loc) 1.51 kB
export interface UserInfo { id?: string | number; name?: string; avatar?: string; pingyin?: string; element?: HTMLElement; [key: string]: any; } export type MediaType = "H5" | "PC"; export interface UserSelectorOptions { users: UserInfo[]; idKey: string; nameKey: string; avatarKey: string; pingyinKey: string; media: MediaType; usersWdith: string; usersHeight: string; } export interface MentionOptions extends UserSelectorOptions { trigger: string; placeholder: string; placeholderColor: string; mentionColor: string; } export interface ViewUser extends UserInfo { element: HTMLElement; } export interface EventsType { focus?: (e?: FocusEvent) => void; blur?: (e?: FocusEvent) => void; keydown?: (e?: KeyboardEvent) => void; keyup?: (e?: KeyboardEvent) => void; input?: (e?: Event) => void; change?: (data?: { text: string; html: string; }) => void; "mention-user"?: (user?: UserInfo) => void; } export interface OnEvents { inputs: ((e?: Event) => void)[]; focuses: ((e?: FocusEvent) => void)[]; blurs: ((e?: FocusEvent) => void)[]; keydowns: ((e?: KeyboardEvent) => void)[]; keyups: ((e?: KeyboardEvent) => void)[]; changes: ((data?: { text: string; html: string; }) => void)[]; "mention-users": ((user?: UserInfo) => void)[]; } export interface RangeElsType { editorEl: HTMLElement; rowEl: HTMLElement; textEl: HTMLElement; }