knockout-froala
Advanced tools
Comparing version 3.1.0 to 3.1.1
{ | ||
"name": "knockout-froala", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
@@ -41,3 +41,3 @@ "homepage": "https://github.com/froala/knockout-froala", | ||
"froala-wysiwyg-editor": "3.1.0", | ||
"froala-wysiwyg-editor": "3.1.1", | ||
"font-awesome": "^4.7.0", | ||
@@ -44,0 +44,0 @@ |
{ | ||
"name": "knockout-froala", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Knockout.js binding for Froala WYSIWYG HTML Rich Text Editor", | ||
@@ -5,0 +5,0 @@ "main": "src/knockout-froala.js", |
@@ -1,2 +0,2 @@ | ||
# Knockout Froala WYSIWYG HTML Editor | ||
# Knockout Froala WYSIWYG HTML Editor (with events registration) | ||
@@ -30,2 +30,3 @@ [![npm](https://img.shields.io/npm/v/knockout-froala.svg)](https://www.npmjs.com/package/knockout-froala) | ||
* `froalaInstance`: [ optional ] if provided, froala instance will be stored in this observable once initialized ( should be observable ) | ||
* `froalaEvents`: [ optional ] if provided, specified events will be registered to the froala instance | ||
@@ -43,2 +44,7 @@ ```js | ||
toolbarButtons: [ 'bold', 'italic', 'underline' ] | ||
}, | ||
events: { | ||
'initialized': function (e, editor) { | ||
console.log('INITIALIZED'); | ||
} | ||
} | ||
@@ -53,3 +59,3 @@ } | ||
```html | ||
<textarea data-bind="value: comments, froala: comments, froalaOptions: options"></textarea> | ||
<textarea data-bind="value: comments, froala: comments, froalaOptions: options, froalaEvents: events"></textarea> | ||
``` | ||
@@ -60,5 +66,14 @@ | ||
```html | ||
<div data-bind="froala: comments, froalaOptions: options"></div> | ||
<div data-bind="froala: comments, froalaOptions: options, froalaEvents: events"></div> | ||
``` | ||
#### You can also pass [events](https://www.froala.com/wysiwyg-editor/docs/events) | ||
Inside `knockout-froala.js`- | ||
``` | ||
'focus': function () { | ||
// this is the editor instance. | ||
console.log(this); | ||
} | ||
``` | ||
## Including All Plugins | ||
@@ -65,0 +80,0 @@ Use froala_editor.pkgd.legacy.min file to include all plugins |
@@ -26,3 +26,15 @@ /** | ||
// register events before initializing the editor | ||
for( var eventName in allBindings.froalaEvents ) { | ||
$el.on( 'froalaEditor.' + eventName, allBindings.froalaEvents[eventName] ); | ||
} | ||
// initialize the editor | ||
$el.froalaEditor( options || {} ); | ||
// provide froala editor instance for flexibility | ||
if( allBindings.froalaInstance && ko.isWriteableObservable( allBindings.froalaInstance ) ) { | ||
allBindings.froalaInstance( $el.data( 'froala.editor' ) ); | ||
// update underlying model whenever editor content changed | ||
@@ -29,0 +41,0 @@ var processUpdateEvent = function (e) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39886
193
172