text-fragments-ts/lib/ index.d.ts
51 lines
3.4 KiB

  1. import { nonEmptyString, integer, locale } from './common.js';
  2. import { BoundaryPoint } from './whatwg-dom.js';
  3. import { origin } from './whatwg-html.js';
  4. export declare const fragmentDirectiveDelimiter = ":~:";
  5. export declare function initializeDocumentFragmentDirective(document: Document): {
  6. documentUrl: string;
  7. documentFragmentDirective: string | null;
  8. };
  9. export declare function parseTextDirective(textDirectiveInput: TextDirective): ParsedTextDirective | null;
  10. export interface ParsedTextDirective {
  11. textStart: nonEmptyString;
  12. textEnd: nonEmptyString | null;
  13. prefix: nonEmptyString | null;
  14. suffix: nonEmptyString | null;
  15. }
  16. export declare type ValidFragmentDirective = string;
  17. export declare function isValidFragmentDirective(input: string | null): input is ValidFragmentDirective;
  18. export declare type TextDirective = string;
  19. export declare function isTextFragmentDirective(input: string): input is TextDirective;
  20. export declare function shouldAllowTextFragment(isUserTriggered: boolean, incumbentNavigationOrigin: origin | null, document: Document): boolean;
  21. export declare function scrollToTheFragment(indicatedPart: [Element, Range | null]): void;
  22. export declare function indicatedPartOfTheDocument_beginning({ document, documentFragmentDirective, documentAllowTextFragmentDirective }: {
  23. document: Document;
  24. documentFragmentDirective: string | null;
  25. documentAllowTextFragmentDirective: boolean;
  26. }): {
  27. documentIndicatedPart: [Element, Range] | undefined;
  28. ranges?: Range[];
  29. };
  30. export declare function firstCommonAncestor(nodeA: Node, nodeB: Node): Node | never;
  31. export declare function shadowIncludingParent(node: Node): Node | null;
  32. export declare function scrollDomRectIntoView(boundingBox: DOMRect, options: ScrollIntoViewOptions, startingElement: Element): void;
  33. export declare function scrollElementIntoView(element: Element, behavior: ScrollBehavior, block: ScrollLogicalPosition, inline: ScrollLogicalPosition): void;
  34. export declare function scrollRangeIntoView(range: Range, containingElement: Element, options: ScrollIntoViewOptions): void;
  35. export declare function processFragmentDirective(fragmentDirectiveInput: string | null, document: Document): Range[];
  36. export declare function findRangeFromTextDirective(parsedValues: ParsedTextDirective, document: Document): Range | null;
  37. export declare function advanceRangeStartToNextNonWhitespacePosition(range: Range): void;
  38. export declare function findStringInRange(query: string, searchRange: Range): Range | null;
  39. export declare function isSearchInvisible(node: Node): boolean;
  40. export declare function partOfNonSearchableSubtree(node: Node): boolean;
  41. export declare type VisibleTextNode = Text;
  42. export declare function isVisibleTextNode(node: Node): node is VisibleTextNode;
  43. export declare function hasBlockLevelDisplay(node: Node): boolean;
  44. export declare function nearestBlockAncestorOf(node: Node): Node;
  45. export declare function findARangeFromANodeList(queryString: string, searchRange: Range, nodes: Text[]): Range | null;
  46. export declare function getBoundaryPointAtIndex(index: integer, nodes: Text[], isEnd: boolean): BoundaryPoint | null;
  47. export declare function isWordBounded(text: string, startPosition: integer, count: number, startLocale: locale, endLocale: locale): boolean;
  48. export interface FragmentDirective {
  49. }
  50. export declare function browserSupportsTextFragments(): boolean;
  51. //# sourceMappingURL=index.d.ts.map