diff --git a/lib/components/content.js b/lib/components/content.js index d586fccc9..0de38ca8d 100644 --- a/lib/components/content.js +++ b/lib/components/content.js @@ -210,6 +210,7 @@ class Content extends React.Component { */ onCutCopy = (e) => { + // debugger const native = window.getSelection() if (!native.rangeCount) return @@ -244,7 +245,12 @@ class Content extends React.Component { // Set the `isCopying` flag, so our `onSelect` logic doesn't fire. this.tmp.isCopying = true - native.selectAllChildren(div) + const r = window.document.createRange() + // COMPAT: In Firefox, trying to use the terser `native.selectAllChildren` + // throws an error, so we use the older `range` equivalent. (2016/06/21) + r.selectNodeContents(div) + native.removeAllRanges() + native.addRange(r) // Revert to the previous selection right after copying. window.requestAnimationFrame(() => { @@ -302,7 +308,7 @@ class Content extends React.Component { const data = e.clipboardData const paste = {} - // COMPAT: In Firefox, `types` is array-like. + // COMPAT: In Firefox, `types` is array-like. (2016/06/21) const types = Array.from(data.types) // Handle files. @@ -410,8 +416,9 @@ class Content extends React.Component { whiteSpace: 'pre-wrap', // Allow words to break if they are too long. wordWrap: 'break-word', - // COMPAT: Prevent iOS from showing the BIU formatting menu, which causes - // the internal state to get out of sync in weird ways. + // COMPAT: In iOS, a formatting menu with bold, italic and underline + // buttons is shown which causes our internal state to get out of sync in + // weird ways. This hides that. (2016/06/21) ...(readOnly ? {} : { WebkitUserModify: 'read-write-plaintext-only' }), // Allow for passed-in styles to override anything. ...this.props.style,