grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

GrapesJS does not work in IE11

Open altalker opened this issue 9 years ago • 48 comments

GrapesJS does not work in IE11 as many of the JS function are not supported (e.g. remove().. , "`", blob.map..

altalker avatar Aug 06 '17 23:08 altalker

Can you show me exactly what kind of errors do you have?

artf avatar Aug 08 '17 11:08 artf

  1. image content: `<di

image 3. image

altalker avatar Aug 08 '17 16:08 altalker

This is when I use IE 11 when items are dragged into the Canvas or using filestack. MS Edge it is ok. (JavaScript ECMA compatibility differences)

altalker avatar Aug 08 '17 18:08 altalker

thanks @altalker unfortunately, I'm not able to check those issues right now but hope to do so soon

artf avatar Aug 08 '17 19:08 artf

Actually have dnd broken on Edge as well. Just doesn't work

nicksav avatar Sep 01 '17 03:09 nicksav

hey @nicksav can you post please your errors

artf avatar Sep 04 '17 21:09 artf

I am facing the same problem when using GrapesJs on IE11. Even http://grapesjs.com/demo.html is not working fine. I am getting these errors:

image when I drag the components/blocks to the canvas(even before I drop them).

umangpasricha avatar Sep 26 '17 12:09 umangpasricha

I think it's clear that we have to add some polyfill for those methods, but at the moment, it's just not my priority (can't even test them properly), so... PRs are welcome

artf avatar Sep 26 '17 13:09 artf

@altalker wich Windows version are you using?

arthuralmeidap avatar Sep 29 '17 13:09 arthuralmeidap

I added polyfill for these methods and now it is working fine on IE too. Here is the code I added for 'assign' method in the .js file I am using:

if (typeof Object.assign != 'function') { Object.defineProperty(Object, "assign", { value: function assign(target, varArgs) { 'use strict'; if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } var to = Object(target); for (var index = 1; index < arguments.length; index++) { var nextSource = arguments[index]; if (nextSource != null) { for (var nextKey in nextSource) { if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { to[nextKey] = nextSource[nextKey]; } } } } return to; }, writable: true, configurable: true }); }

and here is the code I added before the use of 'matches' function in grapes.min.js:

if (!object.matches) object.matches = object.msMatchesSelector || object.webkitMatchesSelector;

As IE does not support these methods so before using matches function in grapes.min.js, we are going to check if any object.matches method exists. If not then define object.matches with object.msMatchesSelector(this is supported by IE instead of matches).

umangpasricha avatar Oct 05 '17 05:10 umangpasricha

@artf I can change babel presets with env preset. It should work with appropriate configuration. Or we can add babel-polyfill to this configuration

ateshuseyin avatar Oct 19 '17 12:10 ateshuseyin

Can anybody try the latest version (the demo is updated too) and report if you get errors in console?

artf avatar Oct 20 '17 13:10 artf

@artf Can you please help me out. It is not working for me also. I have tried the demo , it is not working as well. @umangpasricha if you have working copy of js which works in IE11 can you please send me?

vishal5033 avatar Nov 07 '17 10:11 vishal5033

Yes, GrapesJS editor is working fine on Firefox, Chrome. IE11 and safari at my end. The changes I made in my code are: In index file, I added the following code:

if (typeof Object.assign != 'function') { Object.defineProperty(Object, "assign", { value: function assign(target, varArgs) { 'use strict'; if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } var to = Object(target); for (var index = 1; index < arguments.length; index++) { var nextSource = arguments[index]; if (nextSource != null) { for (var nextKey in nextSource) { if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { to[nextKey] = nextSource[nextKey]; } } } } return to; }, writable: true, configurable: true }); }

Then I made some changes in the grapes.min.js file. Here I am attaching this file as .txt: grapesminjs.txt

umangpasricha avatar Nov 07 '17 12:11 umangpasricha

@vishal5033 do you see any error in console? @umangpasricha what about the current demo (v0.12.25) in IE11? Can you tell me if you see any error

artf avatar Nov 07 '17 12:11 artf

@artf Yes I am getting the same error:

Object doesn't support property or method 'assign'

To resolve this I added the same code(mentioned above) in index.php file at my end.

umangpasricha avatar Nov 07 '17 12:11 umangpasricha

@ateshuseyin seems like babel-preset-env doesn't work as expected 🤔 or I'm missing something?

artf avatar Nov 07 '17 12:11 artf

@artf I'm busy next 2 days but I will be look at as soon as possible

ateshuseyin avatar Nov 07 '17 12:11 ateshuseyin

I m getting this error when I am running grapesjs with MJML in IE11 SCRIPT5007: Unable to get property 'plugins' of undefined or null reference File: grapesjs-mjml.min.js, Line: 61790, Column: 1 I made the changes given by umangpasricha mentioned above. but still not working. I am using the grapesJS latest version 0.12.30 and latest grapesmjml version 0.0.26 Please help me out to resolve this issue asap. Thanks.

NorthstarTech avatar Nov 11 '17 10:11 NorthstarTech

I fond the problem. I forgot to add babel-polyfill into project. So new js features was undefined in old browsers like Object.assign. fixed and sended a pull request #515.

So, are there any one who will test with IE. I am a mac user also. You can test by http://grapesjs-ie-polyfill.surge.sh/

ateshuseyin avatar Nov 13 '17 13:11 ateshuseyin