surmon-china / ngx-quill-editor

🍡@quilljs editor component for @angular
https://github.surmon.me/ngx-quill-editor
MIT License
232 stars 54 forks source link

Compatibility with Angular Universal #62

Open suparnavg opened 6 years ago

suparnavg commented 6 years ago

@surmon-china I'm following the official Angular instructions to set up server side rendering using Angular Universal.

However, during the compilation process, an error is thrown:

elem.classList.toggle('test-class', false);
TypeError: Cannot read property 'toggle' of undefined
    at Object.DIFF_DELETE (

This is coming from the underlying quill.js module, specifically this part in the dist/quill.js file:

var elem = document.createElement('div');
elem.classList.toggle('test-class', false);
if (elem.classList.contains('test-class')) {
  var _toggle = DOMTokenList.prototype.toggle;
  DOMTokenList.prototype.toggle = function (token, force) {
    if (arguments.length > 1 && !this.contains(token) === !force) {
      return force;
    } else {
      return _toggle.call(this, token);
    }
  };
}

The document object is not available on the server - would it be possible to design a workaround for this scenario (as this will be an invaluable addition to the library). Happy to help in any way.

Some ideas here: https://github.com/KillerCodeMonkey/ngx-quill/issues/91, https://github.com/KillerCodeMonkey/ngx-quill/issues/57

KamilBanaszkiewicz commented 6 years ago

i stick to this request too.