angular2-froala-wyswiyg
angular2-froala-wyswiyg provides Angular2 bindings to the froala WYSIWYG editor VERSION 2.
Installation
-
Clone this repo or download the zip.
-
Run
bower install
or Download the editor from https://www.froala.com/wysiwyg-editor/ and jQuery -
Load Froala WYSIWYG editor (and all desired plugins), jQuery and the angular2 directives file into your project.
- lib/froala.directives.ts
NB: You must ensure jQuery is included before angular2.
Usage
1. Import froala directives:
;
2. Use them in your component:
You can check src/app.component.ts file for a more detailed usage example.
-
'src' directory contains a working example that will need a server to run. To run them:
npm start
. -
'demo' directory contains a minified working example that can run without a server. To build demo/app.js in case you've modified the sources(src dir):
npm run build
. To run: open demo/index.html directly into browser.
Options
You can pass editor options as Input (optional).
[froalaEditor]='options'
You can pass any existing Froala option. Consult the Froala documentation to view the list of all the available options:
public options: Object =
Aditional option is used:
- immediateAngularModelUpdate: (default: false) This option synchronizes the angular model as soon as a key is released in the editor. Note that it may affect performances.
Events and Methods
Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function.
public options: Object =
Using the editor instance from the arguments of the callback you can call editor methods as described in the method docs.
Froala events are described in the events docs.
Model
The WYSIWYG HTML editor content model.
[(froalaModel)]="editorContent"
Pass initial content:
public editorContent: string = 'My Document\'s Title'
Use the content in other places:
Manual Instantiation
Gets the functionality to operate on the editor: create, destroy and get editor instance. Use it if you want to manually initialize the editor.
(froalaInit)="initialize($event)"
Where initialize
is the name of a function in your component which will receive an object with different methods to control the editor initialization process.
public initializeinitControls
The object received by the function will contain the following methods:
- initialize: Call this method to initialize the Froala Editor
- destroy: Call this method to destroy the Froala Editor
- getEditor: Call this method to retrieve the editor that was created. This method will return null if the editor was not yet created
Displaying HTML
To display content created with the froala editor use the froalaView directive.
[froalaView]="editorContent"
License
The angular2-froala-wyswiyg
project is under MIT license. However, in order to use Froala WYSIWYG HTML Editor plugin you should purchase a license for it.
Froala Editor has 3 different licenses for commercial use. For details please see License Agreement.
Development environment setup
If you want to contribute to angular2-froala-wyswiyg, you will first need to install the required tools to get the project going.
Prerequisites
- Node Package Manager (NPM)
- Git
Dependencies
- Bower (package management)
1. Install Bower
$ npm install -g grunt-cli bower
2. Install project dependencies
$ npm install
$ bower install
3. Run in development mode. Is loads the src files that make use of lib/froala.directives
$ npm start