1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 21:51:51 +02:00

Initial fixes for IE compat of cloneFragment (#1943)

* Initial fixes for IE compat of cloneFragment

* Used prettier to fix styling

* Removed solutions that can be polyfilled; added COMPAT comment

* Updated FAQ to reflect ideology towards IE

* Update faq.md

* Update faq.md

* Update faq.md
This commit is contained in:
Dylan Phelan
2018-07-19 15:53:38 -04:00
committed by Ian Storm Taylor
parent c4471a5f37
commit 09c93a6cd4
2 changed files with 9 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import TRANSFER_TYPES from '../constants/transfer-types'
import getWindow from 'get-window'
import findDOMNode from './find-dom-node'
import removeAllRanges from './remove-all-ranges'
import { IS_IE } from 'slate-dev-environment'
import { ZERO_WIDTH_SELECTOR, ZERO_WIDTH_ATTRIBUTE } from './find-point'
const { FRAGMENT, HTML, TEXT } = TRANSFER_TYPES
@@ -88,7 +89,11 @@ function cloneFragment(event, value, fragment = value.fragment) {
// For browsers supporting it, we set the clipboard registers manually,
// since the result is more predictable.
if (event.clipboardData && event.clipboardData.setData) {
// COMPAT: IE supports the setData method, but only in restricted sense.
// IE doesn't support arbitrary MIME types or common ones like 'text/plain';
// it only accepts "Text" (which gets mapped to 'text/plain') and "Url"
// (mapped to 'text/url-list'); so, we should only enter block if !IS_IE
if (event.clipboardData && event.clipboardData.setData && !IS_IE) {
event.preventDefault()
event.clipboardData.setData(TEXT, div.textContent)
event.clipboardData.setData(FRAGMENT, encoded)