Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
knockout-froala
Advanced tools
Knockout.js binding for Froala WYSIWYG HTML Rich Text Editor ( Version 2 )
using Bower
bower install knockout-froala
using npm
npm install knockout-froala
to enable Froala binding on a textarea, you need to provide the following binding handlers
froala
: the model observable behind the editorfroalaOptions
: a plain object or an observable that will hold all the options to initalize the editorfroalaInstance
: [ optional ] if provided, froala instance will be stored in this observable once initialized ( should be observable )var viewModel = {
comments: ko.observable(),
options: {
// disable wrapping content with paragraphs
// instead <br> will be used
enter: $.FroalaEditor.ENTER_DIV,
// we like gray!
theme: 'gray',
toolbarButtons: [ 'bold', 'italic', 'underline' ]
}
}
ko.applyBindings( viewModel );
Using a <textarea>
<textarea data-bind="value: comments, froala: comments, froalaOptions: options"></textarea>
or a <div>
<div data-bind="froala: comments, froalaOptions: options"></div>
Changes in file index.html
<link rel="stylesheet" href="../bower_components/font-awesome/css/fontawesome.min.css" />
And
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
In order to use knockout-froala with require js, you require code snippet similar to following:
// Froala Editor plugins list. var fe_plugins = ['align', 'char_counter', 'code_view', 'colors', 'draggable', 'emoticons', 'entities', 'file', 'font_family', 'font_size', 'fullscreen', 'image_manager', 'image', 'inline_style', 'line_breaker', 'link', 'lists', 'paragraph_format', 'paragraph_style', 'quote', 'save', 'table', 'url', 'video'] // Define paths. var paths = { 'app': '../app', 'jquery': 'https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min', 'froala_editor': '../../../bower_components/froala-wysiwyg-editor/js/froala_editor.min', 'knockout':'../../../bower_components/knockout/dist/knockout.debug', 'knockout-froala':'../../../src/knockout-froala' }; // Add Froala Editor plugins to path. for (var i = 0; i < fe_plugins.length; i++) { paths['fe_' + fe_plugins[i]] = '../../../bower_components/froala-wysiwyg-editor/js/plugins/' + fe_plugins[i] + '.min'; } var shim = { 'froala_editor': {deps: ['jquery']} }; for (var i = 0; i < fe_plugins.length; i++) { shim['fe_' + fe_plugins[i]] = { deps: ['froala_editor'] } } // Init RequireJS. requirejs.config({ 'baseUrl': 'js/lib', 'paths': paths, shim: shim });
// Load the main app module to start the app
requirejs(["knockout"],function(ko)
{
window.ko=ko;
requirejs(["knockout-froala"],function(knockout_froala)
{
requirejs(["app"]);
})
})
Where: 1.fe_plugins denote list of froala plugins. 2.paths variable defines the path of all resources. 3.shim variable defines dependencies among js files. 4.knockout.debug.js is loaded first because it returns a object(ko) required for accessing knockout variables and methods. This variable is made global. 5.knockout-froala is loaded next because it defines the froala bindings required by main app. 6.Finally app.js is loaded which contains the logic of your app.
A Requirejs demo app is included in the repository. You can refer it for more details.
The knockout-froala
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.
FAQs
Knockout.js binding for Froala WYSIWYG HTML Rich Text Editor
The npm package knockout-froala receives a total of 57 weekly downloads. As such, knockout-froala popularity was classified as not popular.
We found that knockout-froala demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.