diff --git a/src/index.ts b/src/index.ts index c3c37fa..d81ed91 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,12 +8,12 @@ interface Subscription { unsubscribe: () => void } -function subscribe(el: HTMLElement): Subscription { - installTable(el) - installImageLink(el) - installLink(el) - installText(el) - installHTML(el) +function subscribe(el: HTMLElement, {signal}: {signal?: AbortSignal} = {}): Subscription { + installTable(el, {signal}) + installImageLink(el, {signal}) + installLink(el, {signal}) + installText(el, {signal}) + installHTML(el, {signal}) return { unsubscribe: () => { diff --git a/src/paste-markdown-image-link.ts b/src/paste-markdown-image-link.ts index defdcb2..cf33f5d 100644 --- a/src/paste-markdown-image-link.ts +++ b/src/paste-markdown-image-link.ts @@ -2,10 +2,10 @@ import {insertText} from './text' -export function install(el: HTMLElement): void { - el.addEventListener('dragover', onDragover) - el.addEventListener('drop', onDrop) - el.addEventListener('paste', onPaste) +export function install(el: HTMLElement, {signal}: {signal?: AbortSignal} = {}): void { + el.addEventListener('dragover', onDragover, {signal}) + el.addEventListener('drop', onDrop, {signal}) + el.addEventListener('paste', onPaste, {signal}) } export function uninstall(el: HTMLElement): void { diff --git a/src/paste-markdown-link.ts b/src/paste-markdown-link.ts index 1bbf17c..9682d19 100644 --- a/src/paste-markdown-link.ts +++ b/src/paste-markdown-link.ts @@ -1,7 +1,7 @@ import {insertText} from './text' -export function install(el: HTMLElement): void { - el.addEventListener('paste', onPaste) +export function install(el: HTMLElement, {signal}: {signal?: AbortSignal} = {}): void { + el.addEventListener('paste', onPaste, {signal}) } export function uninstall(el: HTMLElement): void { diff --git a/src/paste-markdown-table.ts b/src/paste-markdown-table.ts index e2784b7..6ecbdc1 100644 --- a/src/paste-markdown-table.ts +++ b/src/paste-markdown-table.ts @@ -1,9 +1,9 @@ import {insertText} from './text' -export function install(el: HTMLElement): void { - el.addEventListener('dragover', onDragover) - el.addEventListener('drop', onDrop) - el.addEventListener('paste', onPaste) +export function install(el: HTMLElement, {signal}: {signal?: AbortSignal} = {}): void { + el.addEventListener('dragover', onDragover, {signal}) + el.addEventListener('drop', onDrop, {signal}) + el.addEventListener('paste', onPaste, {signal}) } export function uninstall(el: HTMLElement): void { diff --git a/src/paste-markdown-text.ts b/src/paste-markdown-text.ts index b02fa6d..bc5fba8 100644 --- a/src/paste-markdown-text.ts +++ b/src/paste-markdown-text.ts @@ -1,7 +1,7 @@ import {insertText} from './text' -export function install(el: HTMLElement): void { - el.addEventListener('paste', onPaste) +export function install(el: HTMLElement, {signal}: {signal?: AbortSignal} = {}): void { + el.addEventListener('paste', onPaste, {signal}) } export function uninstall(el: HTMLElement): void {