npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

knockout-froala

v4.2.0

Published

Knockout.js binding for Froala WYSIWYG HTML Rich Text Editor

Downloads

468

Readme

Knockout Froala WYSIWYG HTML Editor (with events registration)

npm npm npm

Knockout.js binding for Froala WYSIWYG HTML Rich Text Editor ( Version 2 )

Install

using Bower

bower install knockout-froala

using npm

npm install knockout-froala

Usage

to enable Froala binding on a textarea, you need to provide the following binding handlers

  • froala: the model observable behind the editor
  • froalaOptions: a plain object or an observable that will hold all the options to initalize the editor
  • 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
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' ]
  },
  events: {
    'initialized': function (e, editor) {
      console.log('INITIALIZED');
    }
  }
}

ko.applyBindings( viewModel );

Using a <textarea>

<textarea data-bind="value: comments, froala: comments, froalaOptions: options, froalaEvents: events"></textarea>

or a <div>

<div data-bind="froala: comments, froalaOptions: options, froalaEvents: events"></div>

You can also pass events

Inside knockout-froala.js-

'focus': function () {
   // this is the editor instance.
   console.log(this);
 }

Including All Plugins

Use froala_editor.pkgd.legacy.min file to include all plugins

How to use with require js

In order to use knockout-froala with require js, you require code snippet similar to following:

  1. // 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', 'FroalaEditor': '../../../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 = {

    }; for (var i = 0; i < fe_plugins.length; i++) { shim['fe_' + fe_plugins[i]] = { deps: ['FroalaEditor']

    } } // Init RequireJS. requirejs.config({ 'baseUrl': 'js/lib', 'paths': paths, shim: shim });

    // Load the main app module to start the app

    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.app.js contains the logic of your app.

  1. Here is app.js code:

requirejs(["knockout"],function(ko) { window.ko=ko; requirejs(["FroalaEditor"],function(FroalaEditor) { window.FroalaEditor = FroalaEditor; requirejs(["knockout-froala"],function() {

requirejs(["fe_image","fe_char_counter"], function() {

(function(){ var viewModel = { html: ko.observable( '' ), options: { enter: FroalaEditor.ENTER_DIV, theme: 'gray', charCounterMax:150 } }

ko.applyBindings( viewModel, document.getElementById( 'app' ) );

})();

}) }) }) })

A Requirejs demo app is included in the repository. You can refer it for more details.

License

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.