GithubHelp home page GithubHelp logo

agorkovenko / angular-2-froala Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 2.7 MB

Module for using Froala WYSIWYG editor in Angular 2 APP

JavaScript 9.32% TypeScript 84.05% HTML 1.57% SCSS 5.06%
angular2 froala wysiwyg wysiwyg-editor html-editor angular8 angular9 angular

angular-2-froala's Introduction

Afe - Angular (current v.6.1.0) Froala Editor

Affe

What I developed?

Own module (afe-editor) with editor (Froala Editor) included and visual notification (Toastr) for error.

This module is the HTML editor for Angular 6 makes it easy to use and allows you to make preliminary settings that will be common to all the modules and components in which you will use Froala Editor.

How to use

Step 1

Download from gihub

https://github.com/AGorkovenko/angular-2-froala

and put in your project (exp. in folder ./app )

install editor

npm install froala-editor

install notification lib

npm install --save toastr

Step 2

Import module

import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {CommonModule} from "@angular/common";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {AppComponent} from "./app.component";

// Import to your main or other module
import {AfeEditorModule} from "./afe-editor/afe-editor.module";

@NgModule({
	declarations: [
		AppComponent
	],
	imports: [
		BrowserModule,
		CommonModule,
		FormsModule,
		ReactiveFormsModule,
		
		// Add module
		AfeEditorModule
	],
	providers: [],
	bootstrap: [AppComponent]
})
export class AppModule {
}

Step 3

Set some options in file /afe-editor/afe-editor-options-init.ts

...

AFE_EDITOR_OPTIONS = {
	...
		
	// Example: custom toolbar
	// more you can find here
	// https://www.froala.com/wysiwyg-editor/docs/options
	
	toolbarButtons: [
		"paragraphFormat",
		"bold",
		"italic",
		"|",
		"formatOL",
		"formatUL",
		"quote",
		"-",
		"insertLink",
		"insertImage"
	],
	imageUploadURL: this.editorService.UPLOAD_IMAGE_API,
	...
}

...

Step 4

Customize some variables and method in service /afe-editor/afe-editor.service.ts

...

// URL of api end-point for uploading image

UPLOAD_IMAGE_API: string = environment.serverAddress + "/image";

...

Step 5

Use in component

HTML template

<afe-editor formControlName="editorField"></afe-editor>

Angular 6 component

export class AppComponent implements OnInit {
	
	testForm: FormGroup;
	
	constructor(private fb: FormBuilder) {
	}
	
	ngOnInit(): void {
		this.testForm = this.fb.group({
			editorField: new FormControl("", Validators.required)
		});
	}
}

Step 6

Add all style and scripts to your angular.json

"styles": [
	...
	"node_modules/ngx-toastr/toastr.css",
	"node_modules/froala-editor/css/froala_editor.pkgd.min.css",
	"node_modules/froala-editor/css/froala_style.min.css",
	"node_modules/froala-editor/css/themes/dark.min.css",
	"node_modules/froala-editor/css/themes/gray.min.css",
	"node_modules/froala-editor/css/themes/red.min.css",
	"node_modules/froala-editor/css/themes/royal.min.css",
	"node_modules/font-awesome/css/font-awesome.min.css",
	...
],
"scripts": [
	...
	"node_modules/jquery/dist/jquery.min.js",
	"node_modules/froala-editor/js/froala_editor.pkgd.min.js",
	...
]

Screenshot editor

Using source for this module:

angular-2-froala's People

Contributors

agorkovenko avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  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.