Giter Site home page Giter Site logo

froala / angular-froala-wysiwyg Goto Github PK

View Code? Open in Web Editor NEW
726.0 32.0 200.0 1.54 MB

Angular 4, 5, 6, 7, 8 and 9 plugin for Froala WYSIWYG HTML Rich Text Editor.

Home Page: https://froala.com/wysiwyg-editor

TypeScript 62.15% HTML 0.99% Dockerfile 1.76% Shell 35.09%
angular2 froala wysiwyg wysiwyg-editor html-editor angular4 angular5 angular6 rich-text-editor text-editor

angular-froala-wysiwyg's Introduction

Angular Froala WYSIWYG Editor - Demo

npm npm npm

Angular 15+ versions bindings for Froala WYSIWYG Editor.

WYSIWYG HTML Editor

Table of contents

  1. Installation instructions
  2. Update editor instructions
  3. Integration
  4. Usage
  5. Manual Initialization
  6. Displaying HTML
  7. License
  8. Development environment setup

Installation instructions

Install angular-froala-wysiwyg from npm

npm install angular-froala-wysiwyg

You will need CSS styles

<!-- index.html -->
<link href="node_modules/froala-editor/css/froala_editor.pkgd.min.css" rel="stylesheet">

Note : In case you want to use font-awesome icons , you can use them by installing it.

  • Run npm install font-awesome
  • Or in index.hml add given cdn
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

Update editor instructions

npm update froala-editor --save

Integration

Use with Angular CLI

Installing @angular/cli

Note: you can skip this part if you already have application generated.

npm install -g @angular/cli
ng new my-app
cd my-app

Add angular-froala-wysiwyg

  • install angular-froala-wysiwyg
npm install angular-froala-wysiwyg --save
  • open src/app/app.module.ts and add
// Import all Froala Editor plugins.
// import 'froala-editor/js/plugins.pkgd.min.js';

// Import a single Froala Editor plugin.
// import 'froala-editor/js/plugins/align.min.js';

// Import a Froala Editor language file.
// import 'froala-editor/js/languages/de.js';

// Import a third-party plugin.
// import 'froala-editor/js/third_party/font_awesome.min';
// import 'froala-editor/js/third_party/image_tui.min';
// import 'froala-editor/js/third_party/spell_checker.min';
// import 'froala-editor/js/third_party/embedly.min';

// Import Angular plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
...

@NgModule({
   ...
   imports: [FroalaEditorModule.forRoot(), FroalaViewModule.forRoot() ... ],
   ...
})
  • open angular.json file and insert a new entry into the styles array
"styles": [
  "styles.css",
  "./node_modules/froala-editor/css/froala_editor.pkgd.min.css",
  "./node_modules/froala-editor/css/froala_style.min.css",
]
  • open src/app/app.component.html and add
<div [froalaEditor]>Hello, Froala!</div>

Run angular-cli

ng serve

Use with ionic v2 or v3

Create Ionic app

Note: you can skip this part if you already have application generated.

npm install -g cordova ionic
ionic start sample blank
cd sample

Add angular-froala-wysiwyg

For v3 make sure that you use the latest version of ionic and also the latest version of angular.

Installing Froala Wysiwyg Editor in Ionic is fairly easy, it can be done using npm:

npm install angular-froala-wysiwyg --save
  • Inside src/app/app.component.html add
<ion-app>
<ion-router-outlet></ion-router-outlet>
<div [froalaEditor]>Hello, Froala!</div>
</ion-app>
  • open src/app/app.module.ts and add
// Import all Froala Editor plugins.
// import 'froala-editor/js/plugins.pkgd.min.js';

// Import a single Froala Editor plugin.
// import 'froala-editor/js/plugins/align.min.js';

// Import a Froala Editor language file.
// import 'froala-editor/js/languages/de.js';

// Import a third-party plugin.
// import 'froala-editor/js/third_party/font_awesome.min';
// import 'froala-editor/js/third_party/image_tui.min';
// import 'froala-editor/js/third_party/spell_checker.min';
// import 'froala-editor/js/third_party/embedly.min';

// Import Angular2 plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
...

Replace

imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule]

with

imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,FroalaEditorModule.forRoot(), FroalaViewModule.forRoot()]
  • Inside src/app/app-routing.module.ts remove the line
{ path: '', redirectTo: 'home', pathMatch: 'full' }  
  • Inside src/index.html
<link rel="stylesheet" href="assets/css/font-awesome.min.css">  
<link rel="stylesheet" href="assets/css/froala_editor.pkgd.min.css">
<link rel="stylesheet" href="assets/css/froala_style.min.css">
  • In angular.json change outpath of build to "outputPath": "src/assets" and insert following inside assetsarray of build:
"assets":[
 ...,
 
  {
    "glob": "**/*",
    "input": "node_modules/froala-editor/css",
    "output": "css"
  },
  {
    "glob": "**/*",
    "input": "node_modules/font-awesome/css",
    "output": "css"
  },
  {
    "glob": "**/*",
    "input": "node_modules/font-awesome/fonts",
    "output": "fonts"
  },
  {
    "glob": "**/*",
    "input": "node_modules/froala-editor/js",
    "output": "js"
  }
 ]

Run your App

ionic build
ionic serve

Use with webpack/starter

Create webpack app

Note: you can skip this part if you already have application generated.

git clone --depth 1 https://github.com/AngularClass/angular-starter.git
cd angular-starter
npm install
npm install [email protected] --save
npm install @types/[email protected]

Add angular-froala-wysiwyg

  • install angular-froala-wysiwyg
npm install angular-froala-wysiwyg --save
  • open src/app/app.module.ts and add
// Import all Froala Editor plugins.
// import 'froala-editor/js/plugins.pkgd.min.js';

// Import a single Froala Editor plugin.
// import 'froala-editor/js/plugins/align.min.js';

// Import a Froala Editor language file.
// import 'froala-editor/js/languages/de.js';

// Import a third-party plugin.
// import 'froala-editor/js/third_party/font_awesome.min';
// import 'froala-editor/js/third_party/image_tui.min';
// import 'froala-editor/js/third_party/spell_checker.min';
// import 'froala-editor/js/third_party/embedly.min';

// Import Angular plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
...

@NgModule({
   ...
   imports: [FroalaEditorModule.forRoot(), FroalaViewModule.forRoot(), ... ],
   ...
})
  • open src/app/app.component.ts and add to the template
<div [froalaEditor]>Hello, Froala!</div>
  • open config/webpack.common.js
var webpack = require('webpack');
  • open config/webpack.common.js and add the following to CopyWebpackPlugin
{
  from: 'node_modules/froala-editor/css/',
  to: 'assets/froala-editor/css/',
},
  • open config/head-config.common.js and add a new entry to link
{ rel: 'stylesheet', href: '/assets/froala-editor/css/froala_editor.pkgd.min.css' },
{ rel: 'stylesheet', href: '/assets/froala-editor/css/froala_style.min.css' }

Run webpack app

npm run start

Use with system.js and JIT

Create Angular app

Note: you can skip this part if you already have application generated.

git clone https://github.com/froala/angular-froala-systemjs-demo
cd angular-froala-systemjs-demo
npm install

Add angular-froala-wysiwyg

  • install angular-froala-wysiwyg
npm install angular-froala-wysiwyg --save
  • open src/index.html and add
<link rel="stylesheet" href="node_modules/froala-editor/css/froala_editor.pkgd.min.css">
<link rel="stylesheet" href="node_modules/froala-editor/css/froala_style.min.css">
  • open src/app/app.module.ts and add
// Import all Froala Editor plugins.
// import 'froala-editor/js/plugins.pkgd.min.js';

// Import a single Froala Editor plugin.
// import 'froala-editor/js/plugins/align.min.js';

// Import a Froala Editor language file.
// import 'froala-editor/js/languages/de.js';

// Import a third-party plugin.
// import 'froala-editor/js/third_party/font_awesome.min';
// import 'froala-editor/js/third_party/image_tui.min';
// import 'froala-editor/js/third_party/spell_checker.min';
// import 'froala-editor/js/third_party/embedly.min';

// Import Angular2 plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
...

@NgModule({
   ...
   imports: [FroalaEditorModule.forRoot(), FroalaViewModule.forRoot(), ... ],
   ...
})
  • open src/app/app.component.ts file and add to the template
<div [froalaEditor]>Hello, Froala!</div>

Run app

npm run start

Use with aot

Create Angular app

  1. ng new froala-aot
{
  "glob": "**/*",
  "input": "./node_modules/froala-editor",
  "output": "assets/froala-editor/"
},
{
  "glob": "**/*",
  "input": "./node_modules/font-awesome",
  "output": "assets/font-awesome/"
},
{
  "glob": "**/*",
  "input": "./node_modules/jquery",
  "output": "assets/jquery/"
}
  • Go to package.json and update scripts.build to ng build --aot and scripts.start to ng serve --aot

Add angular-froala-wysiwyg

  • install angular-froala-wysiwyg

In case you want to use font-awesome icons , you can use them by installing it.

  • Run npm install font-awesome and add in app.module.ts
import 'froala-editor/js/third_party/font_awesome.min';
  • Go to angular.json and change architect.build.options.outputPath to src/dist and add following json to architect.build.options.assets array
npm install angular-froala-wysiwyg --save
  • open src/index.html and add
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/froala-editor/css/froala_editor.pkgd.min.css">
  • open src/app/app.module.ts and add
// Import all Froala Editor plugins.
// import 'froala-editor/js/plugins.pkgd.min.js';

// Import a single Froala Editor plugin.
// import 'froala-editor/js/plugins/align.min.js';

// Import a Froala Editor language file.
// import 'froala-editor/js/languages/de.js';

// Import a third-party plugin.
// import 'froala-editor/js/third_party/image_tui.min';
// import 'froala-editor/js/third_party/spell_checker.min';
// import 'froala-editor/js/third_party/embedly.min';

// Import Angular2 plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
...

@NgModule({
   ...
   imports: [FroalaEditorModule.forRoot(), FroalaViewModule.forRoot(), ... ],
   ...
})
  • open src/app/app.component.ts file and add to the template
<div [froalaEditor]>Hello, Froala!</div>

Run app

npm run build
npm run start

Usage

Options

You can pass editor options as Input (optional).

[froalaEditor]='options'

You can pass any existing Froala option. Consult the Froala documentation to view the list of all the available options:

public options: Object = {
  placeholderText: 'Edit Your Content Here!',
  charCounterCount: false
}

Aditional option is used:

  • immediateAngularModelUpdate: (default: false) This option synchronizes the angular model as soon as a key is released in the editor. Note that it may affect performances.

Events and Methods

Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function.

public options: Object = {
  placeholder: "Edit Me",
  events : {
    'focus' : function(e, editor) {
      console.log(editor.selection.get());
    }
  }
}

Using the editor instance from the arguments of the callback you can call editor methods as described in the method docs.

Froala events are described in the events docs.

Model

The WYSIWYG HTML editor content model.

[(froalaModel)]="editorContent"

Pass initial content:

public editorContent: string = 'My Document\'s Title'

Use the content in other places:

<input [ngModel]="editorContent"/>
<input [(ngModel)]="editorContent"/> <!-- For two way binding -->

Other two way binding example:

<div [froalaEditor] [(froalaModel)]="editorContent"></div>
<div [froalaEditor] [(froalaModel)]="editorContent"></div>

Use it with reactive forms:

<form [formGroup]="form" (ngSubmit)="onSubmit()">
  <textarea [froalaEditor] formControlName="formModel"></textarea>
  <button type="submit">Submit</button>
</form>

If you want to use two-way binding to display the form model in other places you must include [(froalaModel)]:

<form [formGroup]="form" (ngSubmit)="onSubmit()">
  <textarea [froalaEditor] formControlName="formModel" [(froalaModel)]="form.formModel"></textarea>
  <div [froalaView]="form.formModel"></div>
  <button type="submit">Submit</button>
</form>

If you want to wrap froalaEditor directive into a component that supports reactive forms please see froala.component.ts from demo.

Extend functionality

You can extend the functionality by adding a custom button like bellow:

// Import Froala Editor.
import FroalaEditor from 'froala-editor';

// We will make usage of the Init hook and make the implementation there.
import { Component, OnInit  } from '@angular/core';

@Component({
  selector: 'app-demo',
  template: `<div class="sample">
               <h2>Sample 11: Add Custom Button</h2>
               <div [froalaEditor]="options" [(froalaModel)]="content" ></div>
             </div>`,


export class AppComponent implements OnInit{

  ngOnInit () {
    FroalaEditor.DefineIcon('alert', {NAME: 'info'});
    FroalaEditor.RegisterCommand('alert', {
      title: 'Hello',
      focus: false,
      undo: false,
      refreshAfterCallback: false,

      callback: () => {
        alert('Hello!', this);
      }
    });
  }

  public options: Object = {
    charCounterCount: true,
    toolbarButtons: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
    toolbarButtonsXS: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
    toolbarButtonsSM: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
    toolbarButtonsMD: ['bold', 'italic', 'underline', 'paragraphFormat','alert'],
  };
}

Special tags

Note: In order to use special tags in app.module.ts add

// Import all Froala Editor plugins.
 import 'froala-editor/js/plugins.pkgd.min.js';

You may also use the editor on img, button, input and a tags:

<img [froalaEditor] [(froalaModel)]="imgObj"/>

The model must be an object containing the attributes for your special tags. Example:

public imgObj: Object = {
  src: 'path/to/image.jpg'
};

The froalaModel will change as the attributes change during usage.

  • froalaModel can contain a special attribute named innerHTML which inserts innerHTML in the element: If you are using 'button' tag, you can specify the button text like this:
public buttonModel: Object = {
  innerHTML: 'Click Me'
};

As the button text is modified by the editor, the innerHTML attribute from buttonModel model will be modified too.

Specific option for special tags

  • angularIgnoreAttrs: (default: null) This option is an array of attributes that you want to ignore when the editor updates the froalaModel:
public inputOptions: Object = {
  angularIgnoreAttrs: ['class', 'id']
};

Manual Initialization

Gets the functionality to operate on the editor: create, destroy and get editor instance. Use it if you want to manually initialize the editor.

(froalaInit)="initialize($event)"

Where initialize is the name of a function in your component which will receive an object with different methods to control the editor initialization process.

public initialize(initControls) {
  this.initControls = initControls;
  this.deleteAll = function() {
  	this.initControls.getEditor()('html.set', '');
  };
}

The object received by the function will contain the following methods:

  • initialize: Call this method to initialize the Froala Editor
  • destroy: Call this method to destroy the Froala Editor
  • getEditor: Call this method to retrieve the editor that was created. This method will return null if the editor was not yet created

Displaying HTML

To display content created with the froala editor use the froalaView directive.

[froalaView]="editorContent"

<div [froalaEditor] [(froalaModel)]="editorContent"></div>
<div [froalaView]="editorContent"></div>

License

The angular-froala-wyswiyg 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.

Development environment setup

If you want to contribute to angular-froala-wyswiyg, you will first need to install the required tools to get the project going.

Prerequisites

Install dependencies

$ npm install

Build

$ npm run demo.build

Run Demo

$ npm run start

angular-froala-wysiwyg's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-froala-wysiwyg's Issues

[Help] How to listen to changes in Editor instance

How to listen to changes in the Editor instance?

After every keyUp event I want to log the editor content to the console. What is the best way to do this? Using (ngModelChange)="onChange($event) is not working for me.

<div [froalaEditor]='options' [(froalaModel)]="editorContent"
(ngModelChange)="onChange($event)"
></div>
onChange(content) {
    console.log('content', content);
  }

[question/not-sure-if-bug-or-not] Tooltips aren't being set

I use these options after I've included "../node_modules/froala-editor/js/languages/sv.js" file in angular-cli.json's scripts array:

  public options: any = {
    language: 'se',
    tooltips: true
  };

And then I pass it to the editor:

<div [froalaEditor]="options" [(froalaModel)]="model"></div>

However The language is still english as no tooltips are showing when I hover the buttons.

Am I missing something or is there a bug here?

Problem when using my API to Upload Image in Froala Editor

I'm use project Angular 2 and project Express JS. But I when I change options like this:
public options: Object = {
imageUploadURL: 'http://localhost:5000/post/image'
}
and my server side I have function from call POST/IMAGE:
saveImage: function (req, res) {
console.log('=======>>>>>')
FroalaEditor.Image.upload(req, '/uploads/', function (err, data) {
// Return data.
if (err) {
return res.send(JSON.stringify(err));
}
res.send(data);
console.log(data)
});
}
My problem is can't load image in Froala edtior normally but Image was added in server.

respository name changed - Release 2.4.1 not npm installable

release 2.4.1 is not installable through npm in reason of the original package having an typo which was changed with the latest version. Consider releasing an version 2.3.4 with a deprecated warning?

angular2-froala-wyswiyg now is angular2-froala-wysiwyg

npm ERR! notarget No compatible version found: angular2-froala-wyswiyg@^2.4.1
npm ERR! notarget Valid install targets:
npm ERR! notarget 2.3.4-rc.1

Draggable "fr-dragging" when initializing.

We were experiencing really weird behavior when initilizing dynamic html in the editor. Some DOM elements still had the .fr-dragging class for some reason so the drop behavior was really weird and wasn't responding properly.

Needed to remove all .fr-dragging classes in the html when initializing any html in the editor resolved the problem. Maybe it should be done in the froalaEditor.initialized default event ?

Databinding stops working

I have the following:

<textarea [froalaEditor] id="details" class="k-textbox gt-textbox" [readonly]="(pageMode=='Display')" [(ngModel)]="Requirement.Details"></textarea>

However, if I save the item, the data is not saved to that fields (non-Froala fields work fine).

Strict Mode Error

Hi,

I got this error in by project:

ERROR in [default] lib/froala.directives.ts:193:17
Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode

Can anyone help me?

Working with angular universal

Hi,
I try to use this directives with angular universal starter but it didn't work. Here is the repo:
[(https://github.com/angular/universal-starter)]

and my error is

$ is not defined

Is it a bug or did I use it in wrong way?

Unexpected value 'FroalaEditorDirective'

Following the sample implementation the following snippet causes
Uncaught Error: Unexpected value 'FroalaEditorDirective' declared by the module 'AppModule'(…):

app.module.ts:
import { FroalaEditorDirective, FroalaViewDirective } from '../../node_modules/angular2-froala-wysiwyg/lib/froala.directives';

@NgModule({ imports: [ ... ], declarations: [ AppComponent, HomeComponent, ..., FroalaEditorDirective, FroalaViewDirective ], providers: [ ApiService, XmlService, LoggingService, WebSocketService ], bootstrap: [AppComponent] })

Special-tags img bug - froala_editor.min.js is throwing an error c.replace is not a function

I just tried to use froala editor on an image with angular 2 as described in the readme.md

However I'm getting the error on console c.replace is not a function:

TypeError: c.replace is not a function
    at Object.p [as html] (froala_editor.min.js:8)
    at b.z (froala_editor.min.js:8)
    at HTMLImageElement.<anonymous> (froala_editor.min.js:7)
    at Function.each (jquery.js:365)
    at jQuery.fn.init.each (jquery.js:137)
    at jQuery.fn.init.a.fn.froalaEditor (froala_editor.min.js:7)
    at HTMLImageElement.<anonymous> (froala.directives.ts:115)
    at HTMLImageElement.dispatch (jquery.js:4737)
    at HTMLImageElement.elemData.handle (jquery.js:4549)
    at Object.trigger (jquery.js:7807)

component.html

<img [froalaEditor] [(froalaModel)]="imgObj"/>

component.ts

public imgObj: Object = {
  src: 'path/to/image.jpg'
};

using through npm "froala-editor": "^2.4.0", "angular2-froala-wyswiyg": "^2.3.4-rc.1" which both are latest.

ngModel support

It would be great if this component supported ngModel directly. I want to have a form which includes a Froala editor, and a "submit" button which is only enabled if the form is dirty. This currently doesn't seem possible, even if you use the <input [ngModel]="froalaContent"> hack.

Typing in that input will cause the submit button to become enabled, but typing in Froala will not.

Make froala editor a real npm installable ngModule #featureRequest #improvement

Wouldn't it make sense to make this a real npm installable ngModule for Angular 2 to simplify usage.

app.module.ts

import { FroalaEditorModule } from froala-editor;

@NgModule({
  imports: [
    FroalaEditor.forRoot()
  ]
})

And than be able to use directives as described.

Not yet sure if forRoot is required.

I also would appreciate if the froala editor is included into the module and js files must not be included into index.html. I have too ideas for this:

  • integrate through import
  • import lazy load the the editor from cdn

I think it is really inconvenient adding the editor at several points

Custom Image Button JQueryStatic error

I want to create a custom image button, but I use this:

$.FroalaEditor.DefineIcon('imageInfo', {NAME: 'info'});

get an error:

Property 'FroalaEditor' does not exist on type 'JQueryStatic'.

Thanks for your help.

$ is not a function

Hi,

I'm trying to use your wysiwyg, I used your tutorial for angular-cli but I'getting this error :
$ is not defined

When I type in the browser's console $('xx') it works while I have :
declare var $:any;
else $ is undefined

angular-cli.json :

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "admin"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
	"assets/fonts/roboto.css",
	"../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.css",
	  "../node_modules/font-awesome/css/font-awesome.css",
	  "../node_modules/froala-editor/css/froala_editor.pkgd.min.css"
      ],
      "scripts": [
	"../node_modules/jquery/dist/jquery.min.js",
  	"../node_modules/froala-editor/js/froala_editor.pkgd.min.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [
	"../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2)"
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

In template :
<div [froalaEditor]>Hello, Froala!</div>

And in the bootstreap module I made the import with forRoot()

I used @angular/cli 1.0.0-rc.2 and rc.4

Have you some ideas?

Thanks

I closed it whithout solution, sorry but I used another WYSIWYG

Systematic options (in directive?)

I'd like to systematically apply a config to my froala editor. Imagine that you have a lot of inputs with forala editor and you don't want to apply the same configuration to each input separately.

In angular, you can create a directive and simply apply the configuration there. However, when I create a directive called froalaConfig as follow:

textarea(froalaEditor='', froalaConfig='', [formControlName]='lang.key')

And in the froalaConfig directive:

ngAfterViewInit(): void{
        this.element.nativeElement.froalaEditor({
            charCounterCount: false
        });
}

Unfortunately, this.element.nativeElement returns .froalaEditor is not a function.

How can I systematically apply a config to the editor?

Editor is losing focus after froalaModel update

The editor is losing his focus after each update of the froalaModel. The insert pipe/cursor is disappearing and you have to click inside the editor to continue editing.

Version: angular2-froala-wysiwyg - 2.4.2-2

I'm using the contentChanged event to update the froalaModel.

editor return

how to get the all return value of editor,the function that"editor.selection.get()"only get the value of one selected row of editor

Working with SystemJS

I'm using SystemJS, when run the application I got error:

(SystemJS) Unexpected token <↵ SyntaxError: Unexpected token <↵ at eval ()↵ at Object.eval (http://localhost:3000/src/tmp/app/app.module.js:10:33)↵ at eval (http://localhost:3000/src/tmp/app/app.module.js:44:4)↵ at eval (http://localhost:3000/src/tmp/app/app.module.js:45:3)↵ at eval ()↵ Evaluating http://localhost:3000/jquery↵ Evaluating http://localhost:3000/src/tmp/app/app.module.js↵ Evaluating http://localhost:3000/src/tmp/app/main.js↵ Error loading http://localhost:3000/src/tmp/app/main.js"

I'm using Angular 2.4.3

Where do I configure custom buttons (Angular4 using angular-cli)?

Where do I configure custom buttons and dropdowns? I have tried define them in the component but they need to be created before load. I noticed in another issue you said that they need to be loaded before the froala files, but how would I use my components' functions if that is the case?

Character Counting doesn't work when using suggestive text in mobile devices : Andrioid/IOS

Expected behavior.

Characters should be counted correctly on suggestive text of Andriod/IOS keyboards

Actual behavior.

Character count is not counted with the suggestive text until a key is pressed from the keyboard(Andriod/IOS mobile devices), along with accepting the input even the maximum characters exceeded.

Steps to reproduce the problem.

1.Launch the app
2.Go to the Froal Editor page
3.Use the suggestive text on top of the keyboard(Andriod/IOS) to type.

Note : This issue is already fixed as an enhancement for wysiwyg-editior, and hence haven't released , can I have the same some Angular2, with a release .

Can't select text or put cursor in inline-editor using IE Edge / IE11 and FF in Angular2 app

Expected behavior.

Being able to select text and set the cursor where clicked in the editor box.

Actual behavior.

Can't select any text, besides using CTRL+A, can't put the cursor where I want to. It will always be place at the start of the text

Steps to reproduce the problem.

(Describe the steps to reproduce the problem here)

OS.

Windows 8.1

Browser.

(Browser name an version here)
, IE Edge, IE11, FF 50.1.0

I'm using Froala with jQuery in an Angular 2 project, in Chrome everything works perfectly fine, but in IE and FF that isn't the case. I don't know if it has anything to do with ShadowDom or so.

But what I did is, I created a directive, that create the editor when clicked on an element that uses that directive. This is the init code of Froala, I'm using.

jQuery(this.wysiwyg.element).froalaEditor({
        key: key,
        useClasses: true,
        toolbarContainer: '#toolbarContainer',
        toolbarButtons: toolbar,
        toolbarButtonsMD: toolbar,
        toolbarButtonsSM: toolbar,
        toolbarButtonsXS: toolbar,
        htmlRemoveTags: ['script', 'base'],
        toolbarSticky: false,
        linkEditButtons: ['linkEdit', 'linkRemove'],
        linkInsertButtons: ['linkBack'],
        linkMultipleStyles: false,
        linkText: true,
        linkAlwaysBlank: true,
        keepFormatOnDelete: true,
        placeholderText: ''
});

When the editor isn't used anymore, i just do jQuery(this.wysiwyg.element).froalaEditor('destroy');

It's kinda strange that this all works without any problem in Chrome, but not in FF and IE Edge / IE11, could you guys maybe have some suggestions?

Question: Custom color picker / input

Thanks for your help! Our team loves the Froala editor but we need to add our own color picker with input so the user can specify the hex code. Other that popping a new modal up, do you guys have a way to call into a new toolbar with custom HTML inside of it? Just like how you're doing the color picker now?

Thanks again.

editor does not update when froalaModel changes

This seems to be because of this code, which only permits one-time setup:

   // froalaModel directive as input: store initial editor content                                                                                                                                                                                                                                                                                                                                                                     
    @Input() set froalaModel(content: string) {                                                                                                                                                                                                                                                                                                                                                                                         

      if (!this._gotContent) {                                                                                                                                                                                                                                                                                                                                                                                                          
        this._initContent = content;                                                                                                                                                                                                                                                                                                                                                                                                    
        this._gotContent = true;                                                                                                                                                                                                                                                                                                                                                                                                        
      }                                                                                                                                                                                                                                                                                                                                                                                                                            
    }      

I changed it to this, which seems to work:

   // froalaModel directive as input: store initial editor content                                                                                                                                                                                                                                                                                                                                                                     
    @Input() set froalaModel(content: string) {                                                                                                                                                                                                                                                                                                                                                                                         

      if (!this._gotContent) {                                                                                                                                                                                                                                                                                                                                                                                                          
        this._initContent = content;                                                                                                                                                                                                                                                                                                                                                                                                    
        this._gotContent = true;                                                                                                                                                                                                                                                                                                                                                                                                        
      } else {                                                                                                                                                                                                                                                                                                                                                                                                                          
          this._$element.froalaEditor('html.set', content || '', true);        // HERE                                                                                                                                                                                                                                                                                                                                                         
      }                                                                                                                                                                                                                                                                                                                                                                                                                                 
    }      

Custom DropDown integration using AngularJS2

Could anyone help me how to integrate the plugin using AngularJS2. I tried, defining the plugin when the view is entered and declared the dropdown in froalaEditor options.

Something looks like this 👍

public options: any = { 
    placeholderText: 'You can enter only 2048 characters !!',
    charCounterCount: true,
    charCounterMax: 2048,
    imagePaste:false,
    imagePasteProcess: false,
    toolbarButtons: ['bold', 'italic', 'formatBlock', 'my_dropdown']
}

ionViewDidEnter(){
  
    $.FroalaEditor.DefineIcon('my_dropdown', {NAME: 'cog'});
    $.FroalaEditor.RegisterCommand('my_dropdown', {
      title: 'Advanced options',
      type: 'dropdown',
      focus: false,
      undo: false,
      refreshAfterCallback: true,
      options: {
        'v1': 'Option 1',
        'v2': 'Option 2'
      },
      callback: function (cmd, val) {
        console.log (val);
      },
      // Callback on refresh.
      refresh: function ($btn) {
        console.log ('do refresh');
      },
      // Callback on dropdown show.
      refreshOnShow: function ($btn, $dropdown) {
        console.log ('do refresh when show');
      }
    });
    

}

It doesnt help me out. Please suggest if any ways.

Uncaught TypeError: Cannot read property 'pageX' of undefined

I am seeing the following error when running the froala editor within a SharePoint (SPFx) context:

core.umd.js:3064 EXCEPTION: Cannot read property 'pageX' of undefined
ErrorHandler.handleError @ core.umd.js:3064
next @ core.umd.js:8041
schedulerFn @ core.umd.js:3689
SafeSubscriber.__tryOrUnsub @ Subscriber.ts:250
SafeSubscriber.next @ Subscriber.ts:202
Subscriber._next @ Subscriber.ts:135
Subscriber.next @ Subscriber.ts:95
Subject.next @ Subject.ts:61
EventEmitter.emit @ core.umd.js:3675
NgZone.triggerError @ core.umd.js:4040
onHandleError @ core.umd.js:4001
ZoneDelegate.handleError @ zone.js:334
Zone.runTask @ zone.js:169
ZoneTask.invoke @ zone.js:416
data.args.(anonymous function) @ zone.js:1527
arguments.(anonymous function) @ init.js:1

core.umd.js:3069 ORIGINAL STACKTRACE:
ErrorHandler.handleError @ core.umd.js:3069
next @ core.umd.js:8041
schedulerFn @ core.umd.js:3689
SafeSubscriber.__tryOrUnsub @ Subscriber.ts:250
SafeSubscriber.next @ Subscriber.ts:202
Subscriber._next @ Subscriber.ts:135
Subscriber.next @ Subscriber.ts:95
Subject.next @ Subject.ts:61
EventEmitter.emit @ core.umd.js:3675
NgZone.triggerError @ core.umd.js:4040
onHandleError @ core.umd.js:4001
ZoneDelegate.handleError @ zone.js:334
Zone.runTask @ zone.js:169
ZoneTask.invoke @ zone.js:416
data.args.(anonymous function) @ zone.js:1527
arguments.(anonymous function) @ init.js:1

core.umd.js:3070 TypeError: Cannot read property 'pageX' of undefined
at i (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:149:3933), :17:5549)
at ZoneDelegate.invokeTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :363:31)
at Object.onInvokeTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:18:48), :3971:41)
at ZoneDelegate.invokeTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :362:36)
at Zone.runTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :166:47)
at ZoneTask.invoke (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :416:38)
at data.args.(anonymous function) (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :1527:25)
at arguments.(anonymous function) (https://static.sharepointonline.com/bld/_layouts/15/16.0.6309.1206/init.js:1:95300)
ErrorHandler.handleError @ core.umd.js:3070
next @ core.umd.js:8041
schedulerFn @ core.umd.js:3689
SafeSubscriber.__tryOrUnsub @ Subscriber.ts:250
SafeSubscriber.next @ Subscriber.ts:202
Subscriber._next @ Subscriber.ts:135
Subscriber.next @ Subscriber.ts:95
Subject.next @ Subject.ts:61
EventEmitter.emit @ core.umd.js:3675
NgZone.triggerError @ core.umd.js:4040
onHandleError @ core.umd.js:4001
ZoneDelegate.handleError @ zone.js:334
Zone.runTask @ zone.js:169
ZoneTask.invoke @ zone.js:416
data.args.(anonymous function) @ zone.js:1527
arguments.(anonymous function) @ init.js:1

Subscriber.ts:253 Uncaught TypeError: Cannot read property 'pageX' of undefined
at i (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:149:3933), :17:5549)
at ZoneDelegate.invokeTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :363:31)
at Object.onInvokeTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:18:48), :3971:41)
at ZoneDelegate.invokeTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :362:36)
at Zone.runTask (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :166:47)
at ZoneTask.invoke (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :416:38)
at data.args.(anonymous function) (eval at (https://????.sharepoint.com/sites/Development/SiteAssets/????/requirements-form.bundle_849135b793670aa75ed843f6802f94d7.js:2:14506), :1527:25)
at arguments.(anonymous function) (https://static.sharepointonline.com/bld/_layouts/15/16.0.6309.1206/init.js:1:95300)
> i @ froala_editor.pkgd.min.js:17
ZoneDelegate.invokeTask @ zone.js:363
onInvokeTask @ core.umd.js:3971
ZoneDelegate.invokeTask @ zone.js:362
Zone.runTask @ zone.js:166
ZoneTask.invoke @ zone.js:416
data.args.(anonymous function) @ zone.js:1527
arguments.(anonymous function) @ init.js:1

Styling in SharePoint context

The buttons in the Froala editor are too wide when loaded into a SharePoint context (as all buttons have a min-width of 6em set by SP styles). Therefore, would suggest adding the following:

.fr-toolbar .fr-command.fr-btn, .fr-popup .fr-command.fr-btn {
  min-width: initial;
}

Protractor E2E tests timing out

I keep getting the following error when trying to test a page containing the Froala wysiwyg editor:

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

I have increased the default timeout to 35000 but this has made no difference. If I remove the editor reference from my HTML my tests will work as normal (after I remove parts of tests that interact with the editor).

I have also noticed that the actions specified in the test are carried out in bursts, i.e, it will carry out some of the steps, wait several seconds, then carry out some more etc.

Is the Froala editor compatible with Protractor testing?

froala editor ng2 jit and aot support

I'd really appreciate if this repository would add support for both compile strategies

  • just in time (jit)
  • ahead of time (aot).

Later AOT is especially interesting since it reduces bundle size quiet a lot and is faster in execution. AOT requires a manifest.

Use on Ionic 2

Hi, I'm trying to use this package in Ionic 2

Do you have any idea or tips about how to do it ?

Thanks in advance

this._$element.froalaEditor is not a function in electron 1.4.15

I am currently trying to implement angular2-froala-wysiwyg in our angular2 electron application.
Unfortunately we got the error this._$element.froalaEditor is not a function as soon as I try to initialise the editor.

Before I was able to implement everything in our ionic2 app without any problems.

In my opinion, everthing should be defined correctly. Here you can see the console output for froala and jquery:

screen shot 2017-02-09 at 11 47 53

Those are the current dependencies of this project:

    "@angular/common": "^2.4.5",
    "@angular/compiler": "^2.4.5",
    "@angular/core": "^2.4.5",
    "@angular/flex-layout": "^2.0.0-beta.1",
    "@angular/forms": "^2.4.5",
    "@angular/http": "^2.4.5",
    "@angular/material": "^2.0.0-beta.1",
    "@angular/platform-browser": "^2.4.5",
    "@angular/platform-browser-dynamic": "^2.4.5",
    "@angular/router": "^3.4.5",
    "@angular/upgrade": "^2.4.5",
    "@bbit/ng2-bbit": "^1.1.0",
    "@bbit/ng2-bbit-electron": "^0.1.0",
    "angular2-froala-wysiwyg": "^2.4.2-2",
    "angular2-google-maps": "^0.17.0",
    "angular2-in-memory-web-api": "0.0.21",
    "basscss": "^8.0.3",
    "core-js": "^2.4.1",
    "es6-shim": "^0.35.3",
    "esprima": "^3.1.3",
    "font-awesome": "^4.7.0",
    "froala-editor": "^2.4.2",
    "google-libphonenumber": "^2.0.9",
    "homedir": "^0.6.0",
    "immutable": "^3.8.1",
    "jquery": "3.0.0",
    "jquery.scrollto": "^2.1.2",
    "jsoneditor": "^5.5.11",
    "lodash": "^4.17.4",
    "material-design-icons-iconfont": "^3.0.3",
    "material-design-lite": "^1.3.0",
    "mdi": "^1.8.36",
    "mkdirp": "^0.5.1",
    "moment": "^2.17.1",
    "mousetrap": "^1.6.0",
    "node-machine-id": "^1.1.4",
    "paho-client": "^1.0.1",
    "pouchdb": "^6.1.1",
    "qrious": "^2.2.0",
    "reflect-metadata": "^0.1.9",
    "request": "^2.78.0",
    "rxjs": "^5.1.0",
    "source-map": "^0.5.6",
    "static-eval": "^1.1.1",
    "systemjs": "^0.20.5",
    "systemjs-plugin-json": "^0.2.2",
    "webcomponents.js": "^0.7.23",
    "zone.js": "^0.7.6"

I tried to downgrade jQuery to >=1.11.0 because I saw that this was an issue in some React-projects without any success.

Does anyone have an idea how to fix this problem?

Thank you in advance!

Cannot find name 'JQueryStatic'

Upgraded to the latest version of froala editor (2.5.0). Giving me the following error i.c.m. the Angular-cli

node_modules/angular2-froala-wysiwyg/editor/editor.directive.ts (3,16): Cannot find name 'JQueryStatic'.)

Support for reactive forms

The documentation mentions only the use of model based form ([(froalaModel)]="editorContent"), what about formControlName?

Update to Angular 2.0.0

Hi Guys,

I see that you're latest version still runs on RC.4. When are you planning to update to Angular 2.0.0

Error while image loading

I have use your code,

took example how it should be use here
https://www.froala.com/wysiwyg-editor/docs/sdks/nodejs/image-server-upload#complete-example

But when i'm trying to use the editro and load the image there i receive next error

TypeError: Cannot read property 'on' of undefined
at new Multipart (/var/www/html/flexi/flexi-universal/node_modules/busboy/lib/types/multipart.js:106:5)
at Multipart (/var/www/html/flexi/flexi-universal/node_modules/busboy/lib/types/multipart.js:26:12)
at Busboy.parseHeaders (/var/www/html/flexi/flexi-universal/node_modules/busboy/lib/main.js:71:22)
at new Busboy (/var/www/html/flexi/flexi-universal/node_modules/busboy/lib/main.js:22:10)
at Object.upload (/var/www/html/flexi/flexi-universal/node_modules/wysiwyg-editor-node-sdk/lib/utils/disk.management.js:49:18)
at Object.upload (/var/www/html/flexi/flexi-universal/node_modules/wysiwyg-editor-node-sdk/lib/image.js:44:18)
at /var/www/html/flexi/flexi-universal/dist/server/index.js:45926:28
at Layer.handle [as handle_request] (/var/www/html/flexi/flexi-universal/node_modules/express/lib/router/layer.js:95:5)
at next (/var/www/html/flexi/flexi-universal/node_modules/express/lib/router/route.js:131:13)
at Form. (/var/www/html/flexi/flexi-universal/node_modules/connect-multiparty/index.js:103:9)
undefined

My code where i'm trying to use it (node_modules/wysiwyg-editor-node-sdk/lib/utils/disk.management.js)

try {
    var busboy = new Busboy({ headers: req.headers });
  } catch(e) {
    return callback(e);
  }

  function sendResponse() {
    callback(null, {link: link});
  }

  // Handle file arrival.
  busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
...

Missing 'bundles' on npm

Are there any reasons why the bundles-folder is missing from npm since 2.5.0?

If so, how do we have to use v2.5.0 and up with systemjs?

Cannot find name 'JQueryStatic'.

I have done 'bower install' and 'npm install' successfully. But when I run 'npm start' I am getting this error: error TS2304: Cannot find name 'JQueryStatic'. It's in the file: froala.directives.ts.
Am I missing a step somwehere?

images get rotated automatically

Hi,

Just tried adding images (drag and drop or quick insert) with the latest version of ng2 froala and particular images get auto-rotated 90 degrees. I confirmed that the affected images appear correctly angled in windows 10 icon preview, and other apps like paint, gimp, windows photo viewer, so I think it's safe to call this a bug with froala.

Note: my photo library has images that may have been previously rotated / saved using windows photo viewer's rotate button. I don't know if that rotate feature is storing some metadata that isn't being handled correctly. Just a thought. Not sure what else could cause this odd behavior in froala.

Any help appreciated. If you need sample files please provide a way to send privately.

Regards,

S. Arora

Remove jQuery as dependency

jQuery is bad enough as a standalone library and it's hugely frowned upon to use along with angular, you should really consider dropping it and go with vanilla JS. This would lead to a higher usage of the editor because people like me won't be put off by the jQuery dependency.

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.