markup.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { KeyValue, Nilable } from '@antv/x6-common';
  2. import { Attr } from '../registry';
  3. export type Markup = string | Markup.JSONMarkup | Markup.JSONMarkup[];
  4. export declare namespace Markup {
  5. type Selectors = KeyValue<Element | Element[]>;
  6. interface JSONMarkup {
  7. /**
  8. * The namespace URI of the element. It defaults to SVG namespace
  9. * `"http://www.w3.org/2000/svg"`.
  10. */
  11. ns?: string | null;
  12. /**
  13. * The type of element to be created.
  14. */
  15. tagName: string;
  16. /**
  17. * A unique selector for targeting the element within the `attr`
  18. * cell attribute.
  19. */
  20. selector?: string | null;
  21. /**
  22. * A selector for targeting multiple elements within the `attr`
  23. * cell attribute. The group selector name must not be the same
  24. * as an existing selector name.
  25. */
  26. groupSelector?: string | string[] | null;
  27. attrs?: Attr.SimpleAttrs;
  28. style?: Record<string, string | number>;
  29. className?: string | string[];
  30. children?: JSONMarkup[];
  31. textContent?: string;
  32. }
  33. interface ParseResult {
  34. fragment: DocumentFragment;
  35. selectors: Selectors;
  36. groups: KeyValue<Element[]>;
  37. }
  38. }
  39. export declare namespace Markup {
  40. function isJSONMarkup(markup?: Nilable<Markup>): boolean;
  41. function isStringMarkup(markup?: Nilable<Markup>): markup is string;
  42. function clone(markup?: Nilable<Markup>): string | JSONMarkup | JSONMarkup[] | null | undefined;
  43. /**
  44. * Removes blank space in markup to prevent create empty text node.
  45. */
  46. function sanitize(markup: string): string;
  47. function parseJSONMarkup(markup: JSONMarkup | JSONMarkup[], options?: {
  48. ns?: string;
  49. }): ParseResult;
  50. function renderMarkup(markup: Markup): {
  51. elem?: Element;
  52. selectors?: Selectors;
  53. };
  54. function parseLabelStringMarkup(markup: string): {
  55. fragment: DocumentFragment;
  56. selectors: {};
  57. };
  58. }
  59. export declare namespace Markup {
  60. function getSelector(elem: Element, stop: Element, prev?: string): string | undefined;
  61. }
  62. export declare namespace Markup {
  63. function getPortContainerMarkup(): Markup;
  64. function getPortMarkup(): Markup;
  65. function getPortLabelMarkup(): Markup;
  66. }
  67. export declare namespace Markup {
  68. function getEdgeMarkup(): Markup;
  69. }
  70. export declare namespace Markup {
  71. function getForeignObjectMarkup(bare?: boolean): Markup.JSONMarkup;
  72. }