Skip to content

Commit 9bd8558

Browse files
author
Andrew L
committed
PoC for granual support
1 parent 2661306 commit 9bd8558

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/option-config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
export interface OptionConfig {
2-
pasteLinkAsPlainTextOverSelectedText?: boolean
2+
defaultPlainTextPaste?: PlainTextParams
3+
}
4+
5+
interface PlainTextParams {
6+
urlLinks?: boolean
7+
8+
// Not currently implemented behavior
9+
/*imageLinks?: boolean
10+
html?: boolean
11+
table?: boolean
12+
text?: boolean*/
313
}

src/paste-markdown-link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {shouldSkipFormatting} from './paste-keyboard-shortcut-helper'
55
const pasteLinkAsPlainTextOverSelectedTextMap = new WeakMap<HTMLElement, boolean>()
66

77
export function install(el: HTMLElement, optionConfig?: OptionConfig): void {
8-
pasteLinkAsPlainTextOverSelectedTextMap.set(el, optionConfig?.pasteLinkAsPlainTextOverSelectedText === true)
8+
pasteLinkAsPlainTextOverSelectedTextMap.set(el, optionConfig?.defaultPlainTextPaste?.urlLinks === true)
99
el.addEventListener('paste', onPaste)
1010
}
1111

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ function dispatchSkipFormattingKeyEvent(textarea) {
385385
)
386386
}
387387

388-
function subscribeWithOptionConfig(subscription, textarea, pasteLinkAsPlainTextOverSelectedText) {
388+
function subscribeWithOptionConfig(subscription, textarea, urlLinks) {
389389
// Clear the before test subscription with no config and re-subscribe with config
390390
subscription.unsubscribe()
391-
return subscribe(textarea, {pasteLinkAsPlainTextOverSelectedText})
391+
return subscribe(textarea, {defaultPlainTextPaste: {urlLinks}})
392392
}
393393

394394
function paste(textarea, data) {

0 commit comments

Comments
 (0)