lexical-vue
Version:
An extensible Vue 3 web text-editor based on Lexical.
71 lines (70 loc) • 3.13 kB
TypeScript
import * as __VLS_VINE from 'vue-vine/internals';
import type { CommandListenerPriority, LexicalCommand, LexicalEditor, TextNode } from 'lexical';
import type { Component, ComponentPublicInstance, Ref } from 'vue';
export type MenuRenderFn<TOption extends MenuOption> = (anchorElementRef: Ref<HTMLElement | null>, itemProps: {
selectedIndex: number | null;
selectOptionAndCleanUp: (option: TOption) => void;
setHighlightedIndex: (index: number) => void;
options: Array<TOption>;
}, matchingString: string | null) => Component | null;
export interface MenuTextMatch {
leadOffset: number;
matchingString: string;
replaceableString: string;
}
export interface MenuResolution {
match?: MenuTextMatch;
getRect: () => DOMRect;
}
export declare const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
export declare class MenuOption {
key: string;
ref: HTMLElement | null;
constructor(key: string);
setRefElement(el: Element | ComponentPublicInstance | null): void;
}
export interface MenuRenderProps<TOption extends MenuOption> {
anchorElementRef: HTMLElement | null;
itemProps: {
selectedIndex: number | null;
selectOptionAndCleanUp: (option: TOption) => void;
setHighlightedIndex: (index: number) => void;
options: Array<TOption>;
};
matchingString: string | null;
}
export declare function getScrollParent(element: HTMLElement, includeHidden: boolean): HTMLElement | HTMLBodyElement;
export declare function useDynamicPositioning(resolution: Ref<MenuResolution | null>, targetElement: Ref<HTMLElement | null>, onReposition: () => void, onVisibilityChange?: (isInView: boolean) => void): void;
export declare const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{
index: number;
option: MenuOption;
}>;
export declare function useMenuAnchorRef(resolution: Ref<MenuResolution | null>, setResolution: (r: MenuResolution | null) => void, className?: string, parent?: HTMLElement | undefined, shouldIncludePageYOffset__EXPERIMENTAL?: boolean): Ref<HTMLElement | null>;
export type TriggerFn = (text: string, editor: LexicalEditor) => MenuTextMatch | null;
interface LexicalMenuProps<TOption extends MenuOption> {
close: () => void;
editor: LexicalEditor;
anchorElementRef: HTMLElement;
resolution: MenuResolution;
options: Array<TOption>;
shouldSplitNodeWithQuery?: boolean;
commandPriority?: CommandListenerPriority;
}
type __VLS_VINE_LexicalMenu_emits__ = __VLS_NormalizeEmits<__VLS_VINE.VueDefineEmits<{
selectOption: [
payload: {
option: TOption;
textNodeContainingQuery: TextNode | null;
closeMenu: () => void;
matchingString: string;
}
];
}>>;
export declare function LexicalMenu<TOption extends MenuOption>(props: __VLS_VINE.VineComponentCommonProps & LexicalMenuProps<TOption> & {
onSelectOption: __VLS_VINE_LexicalMenu_emits__['selectOption'];
}, context: {
slots: {
default: (props: MenuRenderProps<TOption>) => any;
};
}): __VLS_VINE.VueVineComponent;
export {};