Code Monkey home page Code Monkey logo

ionicrichtext's Introduction

Ionic 3 Rich Text

npm

A simple rich text editor (or HTML editor) for Ionic 3 applications. I took the idea of judgewest2000 and adapted it to my needs.

Installing

npm i ionic-rich-text

Import it into your app.module

import { RichTextModule } from 'ionic-rich-text/dist/rich-text-module';

.
.
.

  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    RichTextModule
  ],

If you are using lazy loading, you might have to import the module into the page's module as well.

Usage

You can just use the editor with the tag

<rich-text [formControlItem]="item"></rich-text>

and in your .ts file:

constructor(public navCtrl: NavController, public navParams: NavParams, private fb: FormBuilder) {
    this.item = this.fb.control('');
  }

Options

You can pass an object to the component to enable/disable some of its functionalities (disabled ones will not be visible)

Option Description
bold If the bold option is enabled
italic If the italic option is enabled
underline If the underline option is enabled
strikethrough If the strikethrough option is enabled
largeText If the large text option is enabled
smallText If the small text option is enabled
alignLeft If the align left option is enabled
alignCenter If the align center option is enabled
alignRight If the align right option is enabled
justify If the justify option is enabled
lineJump If the line jump option is enabled
orderedList If the ordered list option is enabled
unorderedList If the unordered list option is enabled
canClose If the editor can be opened/closed on demand

There is a type for this object definition:

export interface RichTextOptions {
  undo?: boolean;
  redo?: boolean;
  bold?: boolean;
  italic?: boolean;
  underline?: boolean;
  largeText?: boolean;
  smallText?: boolean;
  alignLeft?: boolean;
  alignCenter?: boolean;
  alignRight?: boolean;
  justify?: boolean;
  lineJump?: boolean;
  orderedList?: boolean;
  unorderedList?: boolean;
  strikethrough?: boolean;
  canClose?: boolean;
}

So you can do

<rich-text [formControlItem]="item" [options]="{canClose: true, lineJump: false}"></rich-text>

Authors

  • Ismael Funes - Initial work

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Let me know if you have any issue or improvement!

ionicrichtext's People

Contributors

ismafunes avatar

Watchers

 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.