6db2a3ec343dfabd99038c33cbe741ce3828f7cda27598f43821fd0842f4830116e7855250742032d9a84b76574107bcb5d210449f46103f2c6d40493bc343 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import type { ScrollBlot } from 'parchment';
  2. import Delta from 'quill-delta';
  3. import type { EmitterSource } from '../core/emitter.js';
  4. import Module from '../core/module.js';
  5. import Quill from '../core/quill.js';
  6. import type { Range } from '../core/selection.js';
  7. type Selector = string | Node['TEXT_NODE'] | Node['ELEMENT_NODE'];
  8. type Matcher = (node: Node, delta: Delta, scroll: ScrollBlot) => Delta;
  9. interface ClipboardOptions {
  10. matchers: [Selector, Matcher][];
  11. }
  12. declare class Clipboard extends Module<ClipboardOptions> {
  13. static DEFAULTS: ClipboardOptions;
  14. matchers: [Selector, Matcher][];
  15. constructor(quill: Quill, options: Partial<ClipboardOptions>);
  16. addMatcher(selector: Selector, matcher: Matcher): void;
  17. convert({ html, text }: {
  18. html?: string;
  19. text?: string;
  20. }, formats?: Record<string, unknown>): Delta;
  21. protected normalizeHTML(doc: Document): void;
  22. protected convertHTML(html: string): Delta;
  23. dangerouslyPasteHTML(html: string, source?: EmitterSource): void;
  24. dangerouslyPasteHTML(index: number, html: string, source?: EmitterSource): void;
  25. onCaptureCopy(e: ClipboardEvent, isCut?: boolean): void;
  26. private normalizeURIList;
  27. onCapturePaste(e: ClipboardEvent): void;
  28. onCopy(range: Range, isCut: boolean): {
  29. html: string;
  30. text: string;
  31. };
  32. onPaste(range: Range, { text, html }: {
  33. text?: string;
  34. html?: string;
  35. }): void;
  36. prepareMatching(container: Element, nodeMatches: WeakMap<Node, Matcher[]>): Matcher[][];
  37. }
  38. declare function traverse(scroll: ScrollBlot, node: ChildNode, elementMatchers: Matcher[], textMatchers: Matcher[], nodeMatches: WeakMap<Node, Matcher[]>): Delta;
  39. declare function matchAttributor(node: HTMLElement, delta: Delta, scroll: ScrollBlot): Delta;
  40. declare function matchBlot(node: Node, delta: Delta, scroll: ScrollBlot): Delta;
  41. declare function matchNewline(node: Node, delta: Delta, scroll: ScrollBlot): Delta;
  42. declare function matchText(node: HTMLElement, delta: Delta, scroll: ScrollBlot): Delta;
  43. export { Clipboard as default, matchAttributor, matchBlot, matchNewline, matchText, traverse, };