I have been working on getting our platform compatible in IE11 and Slate is really close. In fact with just a couple polyfills, it mostly works. I know there isn't official support for IE with Slate, but I figured I would document my findings here seeing as I don't believe it would take too much work to get it working in IE.
Element.closest(). This is used through out the Slate codebase. Easy to polyfill, I used the one here: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill. This might be good to replace with a built in closest utility instead of relying on the browser seeing as Edge also lacks support for it.Selection.extend(). I know this is used a few times in components/leaf.js, possibly elsewhere as well. Unfortunately I couldn't find a solid polyfill for this. If someone finds one I'd love to get my hands on it. Instead I wrote my own: https://gist.github.com/tyler-johnson/0a3e8818de3f115b2a2dc47468ac0099. It works for Slate, but I'm not sure how compatible it is with the native version.DataTransfer.setData() only supports a type value of 'text'. This affects all of the drag-n-drop support, but more specifically these lines: utils/get-transfer-data.js#L21-L25. Judging by that code, I think its possible to fix this by making an exception for IE where only text types are allowed and everything else is ignored or interpreted as text. Not the most elegant, but at least some forms of drag-n-drop would be possible.window.scrollX or window.scrollY. This is used in utils/scroll-to-selection.js. MDN says to use pageXOffset and pageYOffset and my local tests show that these replacements do work.Let me know if I can help to get Slate working in IE; I can definitely open pull-requests. Thanks.
Hey @tyler-johnson thanks for posting this!
I'm definitely down to accept PRs that help make it work in more browsers. The only difficulty is that I probably won't be routinely testing in those browsers, so there might be a few regressions over time. But if the utilities are nicely abstracted out and placed in ./utils this shouldn't be a problem.
Did some investigation about Selection.extend:
Here it is said that
it is not possible to implement
Selection.extendin Internet Explorer up to and including version 11
And Draft.js as well seems to be doing something differently for IE instead of polyfilling .extend: link
Not sure if I'm capable of delivering some code for this issue, but hope this info will help someone who can.
I submitted a fairly simple PR for a Selection.extend shim in #730, as well as a shim for the Element.closest in #728. The scrollX/Y changes were merged in #664, too!
After these get merged it should make Slate usable in both IE11 and Edge, at least in the core functionality! ๐
Thanks so much @Craga89 for the PRs! I'll leave this issue open until we can verify that it actually works in IE11 and Edge.
@Craga89 thanks for getting those in there! I will try to do some more testing in IE this week.
I am concerned about Selection.extend as mentioned by @optimistiks. Hopefully, though, my code is a good enough replacement for extend in Slate. I put that together fairly quickly and I know it doesn't do exactly the same thing as the native extend.
Also I have uncovered some additional issues with IE and Slate, which were exposed when I ran Slate in an iframe.
I had Slate fully* functional in IE on a project with a few somewhat hackish fills and updates, so I need to dig those out and compare. I leave that asterisk because pasting HTML content was not working, only plain text, but I do not recall any remaining bugs with typing or simple selection.
FYI slatejs.org is working great on Edge now, though IE11 does have some minor quirks here and there.
getData/setData with anything other than regular old text types. We can probably detect this and account for it; I'll look into a pull request for it shortly.
display: inline-block or similar.Are there any updates on the Pasting HTML in IE11 issue? @Craga89
@Chropez I just submitted a PR that should fix the Pasting HTML in IE11 issue.
Thank you so much @mahlero, great job!
Closing this issue since it seems like much of it is handled. If certain specific things crop up, feel free to open them in new targeted issues.
Most helpful comment
FYI slatejs.org is working great on Edge now, though IE11 does have some minor quirks here and there.
getData/setDatawith anything other than regular oldtexttypes. We can probably detect this and account for it; I'll look into a pull request for it shortly.Looks like there's a known issue with this that has been addressed in CKEditor, but I'm unsure if this is applicable here, as it appears to disable drag/drop of the content entirely ๐ Sad times... though interestingly, it only happens to appear for elements that have
display: inline-blockor similar.