Skip to content

Commit

Permalink
Fix clipboard typing
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored and jhchen committed Nov 15, 2022
1 parent 875a0a9 commit 4098cbb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions modules/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import { deleteRange } from './keyboard';

const debug = logger('quill:clipboard');

const CLIPBOARD_CONFIG = [
type Selector = string | Node['TEXT_NODE'] | Node['ELEMENT_NODE'];
type Matcher = (node: Node, delta: Delta, scroll: ScrollBlot) => Delta;

const CLIPBOARD_CONFIG: [Selector, Matcher][] = [
[Node.TEXT_NODE, matchText],
[Node.TEXT_NODE, matchNewline],
['br', matchBreak],
Expand Down Expand Up @@ -63,11 +66,8 @@ const STYLE_ATTRIBUTORS = [
return memo;
}, {});

type Matcher = (node: Node, delta: Delta, scroll: ScrollBlot) => Delta;
type Selector = string | Node['TEXT_NODE'] | Node['ELEMENT_NODE'];

interface ClipboardOptions {
matchers: Matcher[];
matchers: [Selector, Matcher][];
}

class Clipboard extends Module<ClipboardOptions> {
Expand Down Expand Up @@ -155,7 +155,6 @@ class Clipboard extends Module<ClipboardOptions> {
e.preventDefault();
const [range] = this.quill.selection.getRange();
if (range == null) return;
// @ts-expect-error
const { html, text } = this.onCopy(range, isCut);
e.clipboardData.setData('text/plain', text);
e.clipboardData.setData('text/html', html);
Expand Down Expand Up @@ -189,6 +188,7 @@ class Clipboard extends Module<ClipboardOptions> {
this.onPaste(range, { html, text });
}

onCopy(range: Range, isCut: boolean): { html: string; text: string };
onCopy(range: Range) {
const text = this.quill.getText(range);
const html = this.quill.getSemanticHTML(range);
Expand Down

0 comments on commit 4098cbb

Please sign in to comment.