Giter Site home page Giter Site logo

ng-quill's Introduction

ng-quill Build Status

NPM

ng-quill is an Angular.js component for Quill rich text editor. You can get an ugly as hell demo here: ngQuill in action or with AMD (RequireJS) ngQuill requirejs

The new version is complete rewritten and is using QuillJS 1.x. For the latest old version (0.20.1) checkout the special branch for it.

Installation

Contribution

I am using GitFlow --> All Changes and Pull-Requests have to be on develop-branch! Changes directly in the master branch are not longer allowed and will be rejected.

Usage

  • load angular, quill, ngquill scripts in your index.html
  • original sources are in src-folder, build files are in dist-folder
  • add dependency to your app module var myAppModule = angular.module('quillTest', ['ngQuill']);
  • use ngQuillConfigProvider to overwrite global settings in your config-Block
  • use ngquill directive in your html <ng-quill-editor ng-model="message"></ng-quill-editor>
  • add this line to your css [ng-quill-editor] { display: block; }
  • if you use it in a form and you are resetting it via $setPristine() -> you have to set editor.setHTML('') -> it will add the error class only, if the model has ng-dirty class
  • add a custom toolbar using ng-quill-toolbar - it uses transclusion to add toolbar, avoids flickering and sets the modules toolbar config to the custom toolbar automatically:
<ng-quill-editor
    ng-model="title"
>
    <ng-quill-toolbar>
        <div>
            <span class="ql-formats">
                <button class="ql-bold" ng-attr-title="{{'Bold'}}"></button>
            </span>
            <span class="ql-formats">
                <select class="ql-align" ng-attr-title="{{'Aligment'}}">
                    <option selected></option>
                    <option value="center"></option>
                    <option value="right"></option>
                    <option value="justify"></option>
                </select>
                <select class="ql-align">
                    <option selected></option>
                    <option value="center"></option>
                    <option value="right"></option>
                    <option value="justify"></option>
                </select>
            </span>
        </div>
    </ng-quill-toolbar>
</ng-quill-editor>

Configuration

  • use ngQuillConfigProvider.set({modules: { ... }, theme: 'snow', placeholder: 'placeholder', formats: { ... }, bounds: document.body, readyOnly: false) to config toolbar module, other modules, default theme, allowed formats, ...
  • set theme name: theme="snow" (default: 'snow')
  • set readOnly: read-only="" (default: false) - requires true or false
  • overwrite global config for each editor: modules="modulesConfig"
  • set placeholder: placeholder="Inser your text here" or placeholder=" " for empty string
  • set bounds: bounds="...", change the default boundary element of the editor (document.body) - set it to 'self' and the editor element is used
  • override formats: formats="formatsArray", per default all quill formats are allowed
  • set max-length: max-length="5", adds validation for maxlength (sets model state to invalid and adds ng-invalid-maxlength class)
  • set min-length: min-length="5", adds validation for minlength (sets model state to invalid and adds ng-invalid-minlength class), only works for values > 1, if you only want to check if there is a value --> use required/ng-required
  • set strict: activate/deactivate strict editor mode (default: true)
  • set scrollingContainer: set html element or css selector that gets the scrollbars
  • use custom-options for adding for example custom font sizes (see example in demo.html) --> this overwrites this options globally !!!

Callback/Outputs

  • onEditorCreated: triggered after editor is created and provides editor-object on-editor-created="myCallback(editor)"
  • onContentChanged: triggered after changes in the editor. Provides editor-object, html representation and text representation on-content-changed="myCallback(editor, html, text, delta, oldDelta, source)"
  • onSelectionChanged: triggered after text selection changed on-selection-changed="myCallback(editor, range, oldRange, source)"

Advanced Usage and Configuration

After editor creation you can use everything from the ordinary quill editor -> listen to editorCreated and work with the editor instance in your controller like you want ;). Add modules, use the quill API or listen to Events. Keep in mind to use $timeout if you are listening / working with quill-Events and updating some $scope stuff to notify angular about it ;). Quill Documentation

ng-quill's People

Contributors

killercodemonkey avatar bengtweisse avatar matikun86 avatar megawebmaster avatar victordidenko avatar wojtek-oledzki avatar cordobo avatar bitdeli-chef avatar carloshpds avatar jziggas avatar khashayar avatar loicknuchel avatar mattbeattie avatar fracmak avatar nargonath avatar acao avatar sdsanders avatar freitash avatar iz80 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.