Skip to content

Latest commit

 

History

History
230 lines (196 loc) · 6.67 KB

README.md

File metadata and controls

230 lines (196 loc) · 6.67 KB

ngx-jodit-pro v3.x (beta)

Angular wrapper for Jodit PRO WYSIWYG editor. It supports Angular >= 16 and jodit-pro v2 beta. You need a license key in order to use this wrapper. Buy here.

License

This package does not contain the source code of Jodit Pro. You have to install it as described here (scroll down). This wrapper is licensed under MIT License, Jodit Pro is licensed seperately (see license).

Compatibility table

Ngx-jodit-proJodit ProAngularTypeDemoReadme
npmv1.x>= v12ModuleDemoReadme
npmv2.x>= v12ModuleDemoReadme
npmv2.x>= v16StandaloneDemoReadme

Demo

You can find a demo of ngx-jodit-pro 3.x here.

Installation

  1. Make sure that jodit-pro@beta AND jodit@beta is installed:

    npm install jodit-pro@beta jodit@beta --save
    
  2. npm install ngx-jodit-pro@3x --save
    
  3. Add the following path to your app's styles in angular.json (or project.json for Nx):

    ...
     ,
     "styles": [
       "node_modules/jodit-pro/es2021/jodit.fat.min.css",
       ...
     ],
    ...
    
  4. Add NgxJoditProComponent (standalone) to the imports array in your app.module.ts:

    @NgModule({
     ...
     imports: [
       ...,
       NgxJoditProComponent
     ],
     ...
     })
    
  5. Now you can use the component

      <ngx-jodit-pro [(value)]="value" [options]="options" #joditComponent></ngx-jodit-pro>
    

Usage

Using Jodit Pro API

Use (Pro) plugins

You can install plugins from Jodit and Jodit Pro. For more information about Jodit Pro plugins see Jodit Pro Docs.

  1. Open folder "node_modules/jodit-pro" or "node_modules/jodit" depending on if you want to add jodit oder jodit-pro plugins.
  2. Open the plugin folder in "esm/plugins", e.g. "tune-block" in "jodit-pro".
  3. Look for the main file named like the plugin e.g. "tune-block.js".
  4. Import "jodit" and the path to this file in a Typescript file of your application. E.g. the Angular component that includes ngx-jodit-pro. For example:
import "jodit";
import "node_modules/jodit-pro/esm/plugins/tune-block/tune-block.js";

Now you can apply the plugin options to ngx-jodit-pro options property. For example:

import {JoditProConfig} from 'ngx-jodit-pro';

options:JoditProConfig = {
  tuneBlock: {
    popup: {
      p: Jodit.atom(['align', 'tune.up', 'tune.remove', 'tune.down'])
    }
  }
}

Add custom plugins

You can access the initialized Jodit from the attribute "jodit" of the NgxJoditProComponent to use the Pro API:

Any component.ts:

import {ViewChild} from '@angular/core';

//...
@ViewChild("joditComponent")
joditComponent ? : NgxJoditProComponent;

// in ngAfterViewInit
if (this.joditComponent) {
  // example:
  this.joditComponent.jodit.plugins.add("hello", () => {
    alert("hello!");
  });
}

Any component.html:

<ngx-jodit-pro #joditComponent ...></ngx-jodit-pro>

Options

All options from Jodit AND JoditPro are supported. Use type "JoditProConfig" for options.

Options for ngx-jodit

Name Type Description
value two-way data-binding Updates as soon as HTML value of the editor changed. You can set your value, too.
options one-way data-binding Sets options for Jodit

Events for ngx-jodit

You can bind events using the Angular way, e.g.:
<ngx-jodit (joditChange)="onChange($event)"></ngx-jodit>

Name Description
joditChange Triggers as soon as something of the HTML value changes.
joditKeyDown Triggers as soon as a key is pressed down.
joditKeyUp Triggers as soon as a key is released.
joditMousedown Triggers as soon as the left mouse button is pressed.
joditMouseup Triggers as soon as the left mouse button is released.
joditClick Triggers as soon as the user clicks on the editor.
joditFocus Triggers as soon as Jodit gets focus.
joditPaste Triggers as soon as something is pasted.
joditResize Triggers as soon as the editor resizes.
joditBeforeEnter Triggers as soon as enter key is pressed.
joditBeforeCommand Triggers before a command is executed.
joditAfterExec Triggers after a command is executed.
joditAfterPaste Triggers after something pasted.
joditChangeSelection Triggers as soon as selection is changed.