@lobehub/editor
Version:
A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.
40 lines (39 loc) • 1.47 kB
TypeScript
import { DropdownMenuItemType } from '@lobehub/ui';
import Fuse from 'fuse.js';
import type { IEditor, IEditorKernel, IServiceID } from "../../../types";
import { getBasicTypeaheadTriggerMatch } from '../utils/utils';
export type ISlashDividerOption = {
type: 'divider';
};
export interface ISlashMenuOption extends DropdownMenuItemType {
onSelect?: (editor: IEditor, matchingString: string) => void;
}
export type ISlashOption = ISlashMenuOption | ISlashDividerOption;
export interface SlashOptions {
allowWhitespace?: boolean;
items: Array<ISlashOption> | ((search: {
leadOffset: number;
matchingString: string;
replaceableString: string;
} | null) => Promise<Array<ISlashOption>>);
maxLength?: number;
minLength?: number;
punctuation?: string;
trigger: string;
}
export interface ISlashService {
registerSlash(options: SlashOptions): void;
}
export declare const ISlashService: IServiceID<ISlashService>;
export declare class SlashService implements ISlashService {
private kernel;
private triggerMap;
private triggerFnMap;
private triggerFuseMap;
private logger;
constructor(kernel: IEditorKernel);
registerSlash(options: SlashOptions): void;
getSlashOptions(trigger: string): SlashOptions | undefined;
getSlashTriggerFn(trigger: string): ReturnType<typeof getBasicTypeaheadTriggerMatch> | undefined;
getSlashFuse(trigger: string): Fuse<ISlashOption> | undefined;
}