anchors.d.ts 964 B

123456789101112131415161718192021222324
  1. import type { Node } from '../nodes/Node.js';
  2. import type { Document } from './Document.js';
  3. /**
  4. * Verify that the input string is a valid anchor.
  5. *
  6. * Will throw on errors.
  7. */
  8. export declare function anchorIsValid(anchor: string): true;
  9. export declare function anchorNames(root: Document<Node, boolean> | Node): Set<string>;
  10. /** Find a new anchor name with the given `prefix` and a one-indexed suffix. */
  11. export declare function findNewAnchor(prefix: string, exclude: Set<string>): string;
  12. export declare function createNodeAnchors(doc: Document<Node, boolean>, prefix: string): {
  13. onAnchor: (source: unknown) => string;
  14. /**
  15. * With circular references, the source node is only resolved after all
  16. * of its child nodes are. This is why anchors are set only after all of
  17. * the nodes have been created.
  18. */
  19. setAnchors: () => void;
  20. sourceObjects: Map<unknown, {
  21. anchor: string | null;
  22. node: Node | null;
  23. }>;
  24. };