Skip to content

Commit 550e43a

Browse files
committed
Remove markdown copy to clipboard
There are many cross-browser issues with undo and newline handling once we opt into managing the clipboard contents with custom behavior. So disable this feature for now.
1 parent f5bca33 commit 550e43a

1 file changed

Lines changed: 0 additions & 34 deletions

File tree

quote-selection.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ export function install(container: Element) {
2727
if (firstInstall) {
2828
document.addEventListener('keydown', quoteSelection)
2929
}
30-
if (!edgeBrowser) {
31-
container.addEventListener('copy', onCopy)
32-
}
3330
}
3431

3532
export function uninstall(container: Element) {
@@ -38,37 +35,6 @@ export function uninstall(container: Element) {
3835
if (!installed) {
3936
document.removeEventListener('keydown', quoteSelection)
4037
}
41-
if (!edgeBrowser) {
42-
container.removeEventListener('copy', onCopy)
43-
}
44-
}
45-
46-
function onCopy(event: ClipboardEvent) {
47-
const target = event.target
48-
if (!(target instanceof HTMLElement)) return
49-
if (isFormField(target)) return
50-
51-
const transfer = event.clipboardData
52-
if (!transfer) return
53-
54-
const selection = window.getSelection()
55-
let range
56-
try {
57-
range = selection.getRangeAt(0)
58-
} catch (err) {
59-
return
60-
}
61-
62-
const text = selection.toString()
63-
const quoted = extractQuote(text, range, true)
64-
if (!quoted) return
65-
66-
transfer.setData('text/plain', text)
67-
transfer.setData('text/x-gfm', quoted.selectionText)
68-
event.preventDefault()
69-
70-
selection.removeAllRanges()
71-
selection.addRange(range)
7238
}
7339

7440
function eventIsNotRelevant(event: KeyboardEvent): boolean {

0 commit comments

Comments
 (0)