util.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { MentionsProps } from './Mentions';
  2. import type { OptionProps } from './Option';
  3. /**
  4. * Cut input selection into 2 part and return text before selection start
  5. */
  6. export declare function getBeforeSelectionText(input: HTMLTextAreaElement): string;
  7. interface MeasureIndex {
  8. location: number;
  9. prefix: string;
  10. }
  11. /**
  12. * Find the last match prefix index
  13. */
  14. export declare function getLastMeasureIndex(text: string, prefix: string[]): MeasureIndex;
  15. interface MeasureConfig {
  16. measureLocation: number;
  17. prefix: string;
  18. targetText: string;
  19. selectionStart: number;
  20. split: string;
  21. }
  22. /**
  23. * Paint targetText into current text:
  24. * text: little@litest
  25. * targetText: light
  26. * => little @light test
  27. */
  28. export declare function replaceWithMeasure(text: string, measureConfig: MeasureConfig): {
  29. text: string;
  30. selectionLocation: number;
  31. };
  32. export declare function setInputSelection(input: HTMLTextAreaElement, location: number): void;
  33. export declare function validateSearch(text: string, split: MentionsProps['split']): boolean;
  34. export declare function filterOption(input: string, { value }: OptionProps): boolean;
  35. export {};