Skip to content

Commit eadb3cd

Browse files
committed
Disable Markdown quoting/copying for Microsoft Edge
Edge crashes around the time the document fragment prepared for Markdown syntax is inserted into the DOM to get its string representation. Until we figure out what exactly crashes Edge, this disables Markdown quoting and copying for that browser.
1 parent 9cb0c6e commit eadb3cd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

quote-selection.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import rangeToMarkdown from './markdown-parsing'
55
const containers = new WeakMap()
66
let installed = 0
77

8+
const edgeBrowser = /\bEdge\//.test(navigator.userAgent)
9+
810
type Subscription = {|
911
unsubscribe: () => void
1012
|}
@@ -22,7 +24,9 @@ export function install(container: Element) {
2224
installed += containers.has(container) ? 0 : 1
2325
containers.set(container, 1)
2426
document.addEventListener('keydown', quoteSelection)
25-
container.addEventListener('copy', onCopy)
27+
if (!edgeBrowser) {
28+
container.addEventListener('copy', onCopy)
29+
}
2630
}
2731

2832
export function uninstall(container: Element) {
@@ -31,7 +35,9 @@ export function uninstall(container: Element) {
3135
if (!installed) {
3236
document.removeEventListener('keydown', quoteSelection)
3337
}
34-
container.removeEventListener('copy', onCopy)
38+
if (!edgeBrowser) {
39+
container.removeEventListener('copy', onCopy)
40+
}
3541
}
3642

3743
function onCopy(event: ClipboardEvent) {
@@ -142,7 +148,7 @@ function extractQuote(text: string, range: Range, unwrap: boolean): ?Quote {
142148
if (!container) return
143149

144150
const markdownSelector = container.getAttribute('data-quote-markdown')
145-
if (markdownSelector != null) {
151+
if (markdownSelector != null && !edgeBrowser) {
146152
try {
147153
selectionText = selectFragment(rangeToMarkdown(range, markdownSelector, unwrap))
148154
.replace(/^\n+/, '')

0 commit comments

Comments
 (0)