index.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { InputRule } from 'prosemirror-inputrules';
  2. import { PluginKey, Plugin, Transaction, Selection } from 'prosemirror-state';
  3. import { Attrs, MarkType, NodeType, Node, Schema, ResolvedPos } from 'prosemirror-model';
  4. import { EditorView } from 'prosemirror-view';
  5. declare const ie: boolean;
  6. declare const ie_version: unknown;
  7. declare const gecko: boolean;
  8. declare const gecko_version: number | false;
  9. declare const chrome: boolean;
  10. declare const chrome_version: number;
  11. declare const safari: boolean;
  12. declare const ios: boolean;
  13. declare const mac: boolean;
  14. declare const android: boolean;
  15. declare const webkit: boolean;
  16. declare const webkit_version: number;
  17. declare const browser_android: typeof android;
  18. declare const browser_chrome: typeof chrome;
  19. declare const browser_chrome_version: typeof chrome_version;
  20. declare const browser_gecko: typeof gecko;
  21. declare const browser_gecko_version: typeof gecko_version;
  22. declare const browser_ie: typeof ie;
  23. declare const browser_ie_version: typeof ie_version;
  24. declare const browser_ios: typeof ios;
  25. declare const browser_mac: typeof mac;
  26. declare const browser_safari: typeof safari;
  27. declare const browser_webkit: typeof webkit;
  28. declare const browser_webkit_version: typeof webkit_version;
  29. declare namespace browser {
  30. export { browser_android as android, browser_chrome as chrome, browser_chrome_version as chrome_version, browser_gecko as gecko, browser_gecko_version as gecko_version, browser_ie as ie, browser_ie_version as ie_version, browser_ios as ios, browser_mac as mac, browser_safari as safari, browser_webkit as webkit, browser_webkit_version as webkit_version };
  31. }
  32. declare const customInputRulesKey: PluginKey<any>;
  33. declare function customInputRules({ rules }: {
  34. rules: InputRule[];
  35. }): Plugin;
  36. interface Captured {
  37. group: string | undefined;
  38. fullMatch: string;
  39. start: number;
  40. end: number;
  41. }
  42. interface BeforeDispatch {
  43. match: string[];
  44. start: number;
  45. end: number;
  46. tr: Transaction;
  47. }
  48. interface Options {
  49. getAttr?: (match: RegExpMatchArray) => Attrs;
  50. updateCaptured?: (captured: Captured) => Partial<Captured>;
  51. beforeDispatch?: (options: BeforeDispatch) => void;
  52. }
  53. declare function markRule(regexp: RegExp, markType: MarkType, options?: Options): InputRule;
  54. declare function nodeRule(regexp: RegExp, nodeType: NodeType, options?: Options): InputRule;
  55. type Point = [top: number, left: number];
  56. declare function calculateNodePosition(view: EditorView, target: HTMLElement, handler: (selectedRect: DOMRect, targetRect: DOMRect, parentRect: DOMRect) => Point): void;
  57. interface Rect {
  58. left: number;
  59. right: number;
  60. top: number;
  61. bottom: number;
  62. }
  63. declare function calculateTextPosition(view: EditorView, target: HTMLElement, handler: (start: Rect, end: Rect, targetRect: DOMRect, parentRect: DOMRect) => Point): void;
  64. declare function posToDOMRect(view: EditorView, from: number, to: number): DOMRect;
  65. declare function cloneTr(tr: Transaction): Transaction;
  66. declare function equalNodeType(nodeType: NodeType | NodeType[], node: Node): boolean;
  67. type Predicate = (node: Node) => boolean;
  68. interface NodeWithPos {
  69. pos: number;
  70. node: Node;
  71. }
  72. declare function flatten(node: Node, descend?: boolean): NodeWithPos[];
  73. declare function findChildren(predicate: Predicate): (node: Node, descend?: boolean) => NodeWithPos[];
  74. declare function findChildrenByMark(node: Node, markType: MarkType, descend?: boolean): NodeWithPos[];
  75. declare function getNodeFromSchema(type: string, schema: Schema): NodeType;
  76. declare function getMarkFromSchema(type: string, schema: Schema): MarkType;
  77. interface ContentNodeWithPos {
  78. pos: number;
  79. start: number;
  80. depth: number;
  81. node: Node;
  82. }
  83. declare function findParentNodeClosestToPos(predicate: Predicate): ($pos: ResolvedPos) => ContentNodeWithPos | undefined;
  84. declare function findParentNode(predicate: Predicate): (selection: Selection) => ContentNodeWithPos | undefined;
  85. declare function findSelectedNodeOfType(selection: Selection, nodeType: NodeType): ContentNodeWithPos | undefined;
  86. export { type BeforeDispatch, type Captured, type ContentNodeWithPos, type NodeWithPos, type Options, browser, calculateNodePosition, calculateTextPosition, cloneTr, customInputRules, customInputRulesKey, equalNodeType, findChildren, findChildrenByMark, findParentNode, findParentNodeClosestToPos, findSelectedNodeOfType, flatten, getMarkFromSchema, getNodeFromSchema, markRule, nodeRule, posToDOMRect };
  87. //# sourceMappingURL=index.d.ts.map