froala / angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
MIT License
306 stars 123 forks source link

element.froalaEditor not defined in link function #156

Closed kavare closed 6 years ago

kavare commented 7 years ago

Description

When includes angular-froala in a tool-agnostic build process, it fails to be initiated.

TypeError: s.froalaEditor is not a function
    at Object.u.createEditor (chrome-extension://dijaojadlplcedapabbjgpoleiikldhd/js/iframe.js:122914:1661)
    at Object.u.init (chrome-extension://dijaojadlplcedapabbjgpoleiikldhd/js/iframe.js:122914:748)
    at Object.link (chrome-extension://dijaojadlplcedapabbjgpoleiikldhd/js/iframe.js:122914:2848)

Background

We built a uikit which include froala-editor as a component. It works fine when serve locally, but failed when we used webpack to build it and import from other projects.

The main reason behind is that in the source file, the link function of froala directive assume the element will have element.froalaEditor bind to the element, but this is only true if jquery has been included before angular. In the build version, regardless the build tool one may use (grunt, gulp, webpack), this might not be the case.

One way to by-pass this issue is to manually wrap the element in link function with jQuery, if jQuery exists.

ahmadassaf commented 7 years ago

I've been having this as well .. i have not tried your PR yet .. but will see if this can fix it for me

stefanneculai commented 7 years ago

@ahmadassaf it would be amazing to get your feedback about this.

ahmadassaf commented 7 years ago

@stefanneculai i confirm @kavare PR fixed the issue for me 👍

kavare commented 7 years ago

@stefanneculai Thank you for approving the PR. Please let me know when it is published in NPM as well. :)

stefanneculai commented 6 years ago

@kavare it will be published during this week.

kavare commented 6 years ago

@stefanneculai I can see the version update on github but still not being published on npm yet. It's currently blocking us so would really appreciate it if we can facilitate this.