@@ -149,6 +149,144 @@ $scope.inputOptions = {
149149 angularIgnoreAttrs: [' class' , ' ng-model' , ' id' ]
150150};
151151 ```
152+ ## Use with Requirejs
153+
154+ Add require.js in js/lib folder.
155+
156+ _ app.js_
157+
158+ ``` javascript
159+ define ([" jquery" ," froala_editor" ," angular" ," angularroute" ," angular-froala" ," angularresource" ], function ($ ,a ,b ,c ,d ,e ) {
160+
161+ var myApp = angular .module (' myApp' , [' froala' ]).
162+ ` ` `
163+ _index.html_
164+
165+ ` ` ` html
166+ < script data- main= " js/app" src= " ../js/lib/require.js" >< / script>
167+ < script>
168+ var fe_plugins = [' align' , ' char_counter' , ' code_view' , ' colors' , ' draggable' , ' emoticons' ,
169+ ' entities' , ' file' , ' font_family' , ' font_size' , ' fullscreen' ,
170+ ' image_manager' , ' image' , ' inline_style' , ' line_breaker' ,
171+ ' link' , ' lists' , ' paragraph_format' , ' paragraph_style' , ' quote' ,
172+ ' save' , ' table' , ' url' , ' video' ]
173+ // Define paths.
174+ var paths = {
175+ ' app' : ' ../../app' ,
176+ ' jquery' : ' https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min' ,
177+ ' angular' : ' ../../../bower_components/angular/angular.min' ,
178+ ' froala_editor' : ' ../../../bower_components/froala-wysiwyg-editor/js/froala_editor.min' ,
179+ ' angular-froala' : ' ../../../src/angular-froala' ,
180+ ' angularroute' : ' ../../../bower_components/angular-route/angular-route' ,
181+ ' angularresource' : ' ../../../bower_components/angular-resource/angular-resource' ,
182+ ' angular-mocks' : ' ../../../bower_components/angular-mocks/angular-mocks'
183+ };
184+ // Add Froala Editor plugins to path.
185+ for (var i = 0 ; i < fe_plugins .length ; i++ ) {
186+ paths[' fe_' + fe_plugins[i]] = ' ../../../../../js/plugins/' + fe_plugins[i] + ' .min' ;
187+ }
188+ var shim = {
189+ ' froala_editor' : {deps: [' jquery' ]},
190+ ' angular-froala' : {deps: [' angular' ],exports: ' Backbone' },
191+ ' angularroute' : {deps: [' angular' ]},
192+ ' angularresource' : {deps: [' angular' ]},
193+ ' angular' : {exports: ' angular' },
194+ ' angularMocks' : {
195+ deps: [' angular' ],
196+ ' exports' : ' angular.mock'
197+ }
198+ };
199+ for (var i = 0 ; i < fe_plugins .length ; i++ ) {
200+ shim[' fe_' + fe_plugins[i]] = {
201+ deps: [' froala_editor' ]
202+ }
203+ }
204+ // Init RequireJS.
205+ requirejs .config ({
206+ ' baseUrl' : ' js/lib' ,
207+ ' paths' : paths,
208+ shim: shim
209+ });
210+ // Load the main app module to start the app
211+ requirejs ([" angular" ],function ()
212+ {
213+ requirejs ([" angular-froala" ],function (angular_froala )
214+ {
215+ requirejs ([" app" ]);
216+ })
217+ })
218+ < / script>
219+
220+ ` ` `
221+ _angular-froala.js_
222+
223+ ` ` ` javascript
224+
225+ define ([" jquery" ," froala_editor" ," angular" ," angularroute" ], function ($ ,a ,b ,c ) {
226+
227+ (function (window , angular , jQuery , undefined ) {
228+
229+ ` ` `
230+
231+ ## Use with Webpack
232+
233+ _webpack.config.js
234+
235+ ` ` ` javascript
236+
237+ module .exports = {
238+ optimization: {
239+ },
240+ entry: " ./index.js" ,
241+ output: {
242+ filename: " ./bundle.js"
243+ },
244+ module: {
245+ rules: [
246+ {
247+ test: / \. scss$ / ,
248+ loader: ' style!css!sass'
249+ },
250+ {
251+ test: / \. js$ / ,
252+ loader: ' babel-loader' ,
253+ exclude: / node_modules/
254+ }
255+ ]},
256+ resolve: {
257+ alias: {
258+ jQuery: " ./bower_components/jquery/dist/jquery.js" ,
259+ $: " ./bower_components/jquery/dist/jquery.js" ,
260+ froala_editor: " ./bower_components/froala-wysiwyg-editor/js/froala_editor.min.js" ,
261+ angularfroala: " ./angularfroala.js"
262+ }
263+ }
264+ }
265+
266+ ` ` `
267+
268+ _app.js_
269+
270+ ` ` ` javascript
271+
272+ let $ = require (' jquery' );
273+ window .$ = $;
274+ window .jQuery = $;
275+ require (' angular' )
276+ require (' froala-editor/js/froala_editor.min.js' );
277+ require (' ../src/angular-froala' )
278+ var myApp = angular .module (' myApp' , [' froala' ]).
279+ ... .
280+
281+ ` ` `
282+
283+ _index.html_
284+
285+ ` ` ` html
286+
287+ < script type= " text/javascript" src= " ../dist/bundle.js" >< / script>
288+
289+ ` ` `
152290
153291### Manual Instantiation
154292Sometimes you want to control when the Froala Editor will be instantiated. The directive includes a **froala-init** attributes which will provide you with the controls required to initialize and close the editor.
0 commit comments