mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-03-05 13:39:04 +01: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:
parent
c4471a5f37
commit
09c93a6cd4
@ -24,4 +24,6 @@ If you have an element that is not going to be editable, you can choose between
|
||||
|
||||
Slate's goal is to support all the modern browsers on both desktop and mobile devices.
|
||||
|
||||
However, right now Slate is in beta, so its support is not as full as it will later be. It's currently tested against the latest few versions of Chrome, Firefox and Safari on desktops. It isn't currently tested against Internet Explorer or Edge, or against mobile devices. If you want to add more browser or device support, we'd love for you to submit a pull request!
|
||||
However, right now Slate is in beta and is community-driven, so its support is not as robust as it could be. It's currently tested against the latest few versions of Chrome, Firefox and Safari on desktops. It isn't currently tested against Internet Explorer or Edge, or against mobile devices. If you want to add more browser or device support, we'd love for you to submit a pull request!
|
||||
|
||||
For older browsers, such as IE11, a lot of the now standard native APIs aren't available. Slate's position on this is that it is up to the user to bring polyfills (like https://polyfill.io) when needed for things like `el.closest`, etc. Otherwise we'd have to bundle and maintain lots of polyfills that others may not even need in the first place.
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user