Days
Hours
Minutes
Seconds
x

New Froala Editor v4.5.1 is here – Learn More

Skip to content

Why Froala 4.1.1 is Essential: A Quick Recap

Hello developers! A while back, we unveiled Froala V4.1.1, an iteration that succeeded our much-acclaimed V4.1 release. In case you missed out, this update came with a host of improvements designed to give you an unparalleled coding experience. Today, we’re revisiting the groundbreaking features of this update, paying special attention to TypeScript and Angular. Let’s dive in!

A Quick Flashback to Froala 4.1 and TypeScript

Froala 4.1 made a big move by supporting TypeScript. Why is that cool? TypeScript makes coding easier and faster. Here’s how:

  1. Smart Tips: TypeScript is like a smart buddy who helps you code. It gives you hints that can help you avoid mistakes.
  2. Error-Checking: TypeScript checks your code while you’re writing it, helping you catch errors before they become big problems.
  3. Better Auto-complete: This isn’t just regular auto-complete. TypeScript’s suggestions are really on point, which makes finding code easier.

But wait, not everything was perfect. People who used Froala with Angular had some issues. That’s where the new update, Froala 4.1.1, comes in to fix those problems.

What’s New in Froala 4.1.1?

TypeScript is Now Even Cooler

First, let’s talk about TypeScript again. In this new 4.1.1 update, TypeScript support is upgraded, and it’s extra helpful if you’re using Angular. Ever run into issues like wrong definitions or missing bits in the index.d.ts file? The 4.1.1 update fixes those problems. That means Froala and Angular’s TypeScript get along really well now. It’s a smooth ride!

More Goodies for Angular Coders

Moving on, if you’re an Angular developer, you’re in for a treat. The 4.1.1 update makes dealing with toolbar buttons a breeze. To get this new feature, all you need to do is add Froala’s plugin scripts to your app.module.ts file. So, it’s gotten a lot easier and more flexible to use.

 

import 'froala-editor/js/plugins/align.min.js';

You can activate additional buttons like align right, align left, center, and justify. If you want the full package, use this import statement:

import 'froala-editor/js/plugins.pkgd.min.js';

With 4.1.1, you now have the power to tweak the editor’s toolbar using the toolbarButtons API option. By setting this option, you can specify which toolbar buttons appear and where. Here’s an example:

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

 

Fixing TypeScript Definitions

One of the most underappreciated but vital updates in 4.1.1 was the refinement of TypeScript definitions. For example, numerous properties were added or edited:

FE.DEFAULTS

FE.DefineIcon

FE.DefineIconTemplate

FE.END_MARKER

FE.KEYCODE

FE.MARKERS

FE.PLUGINS

FE.POPUP_TEMPLATES

FE.RegisterCommand

FE.RegisterQuickInsertButton

FE.RegisterShortcut

FE.START_MARKER

If you were experiencing errors while creating custom buttons or plugins, 4.1.1 is your go-to solution.

Extra Content: Why this is a big deal

Easy-to-Add Features with Modular Design

First off, Froala 4.1.1 has a modular design. What’s that mean? It means you can pick and choose just the features you need. This is great for working with modern JavaScript frameworks like Angular, which also love modularity. For example, you can add just the pieces you need for your Froala editor, making your app quicker to load. Plus, TypeScript makes this process safer and more predictable.

Handle Tasks that Take Time Smoothly with Asynchronous Support

Next up, Froala 4.1.1 is ready for tasks that take some time to complete, like pulling in data from a website. It uses something called JavaScript Promises to make these tasks go smoothly. TypeScript adds another layer of safety here, helping you avoid mistakes when you’re handling these tasks. For example, you can set up rules for what kind of data you’re expecting, making it less likely you’ll run into errors later on.

Keep Up with Real-Time Changes Using Observables

Lastly, if you’re an Angular developer, you’ll be happy to hear about the Observables feature. Observables help you manage changes in your app in real-time. Froala 4.1.1 works really well with Angular’s Observables. You can tie them into Froala’s events, making your app more interactive and dynamic. Picture this: you can auto-save content or update your app’s look in real-time. And again, TypeScript makes this all easier and safer to manage.

Why You Should Update Now

First things first, updating to Froala Editor 4.1.1 is super important. It’s not just another regular update. Think of it as adding a turbo boost to your coding tools, especially if you’re using TypeScript or Angular. We’ve even got a step-by-step guide at the end of our original post to help you with the update.

Time to Wrap It Up

In conclusion, the 4.1.1 version isn’t just a small tweak. It’s like redoing the whole thing to make your coding life better. So if you haven’t updated yet, you really should. You’ll get to see all the cool stuff Froala Editor has to offer.

Happy coding!

Download Froala Editor

Document Ready Mode on a Froala Component in Your React App

Document Ready React editor

Rich text editors are indispensable tools for creating, editing, and formatting content.

These editors empower users to craft appealing and structured text without needing in-depth knowledge of HTML and CSS.

Froala is a tool that provides a powerful and customizable rich text editing experience, and it integrates with React applications.

One of its features is the Document Ready mode, which simplifies document view.

In this article, we’ll explore how to use the Document Ready mode of Froala in your React project app.

What is Document Ready Mode?

Document Ready React editor

Froala’s Document Ready mode is a feature that simplifies the initialization of the editor and allows you to focus on creating content rather than wrestling with configuration settings.

It streamlines the setup process, making it more straightforward and user-friendly.

Prerequisites

Before we dive into using Document Ready mode, let’s ensure you have everything in place:

React Project: You should have a React project set up. If not, you can create one using create-react-app or your preferred method.

Installation: Install Froala Editor in your React project using npm or yarn:

npm install react-froala-wysiwyg --save

Import Styles: Import Froala’s CSS styles in your project. You can do this by adding the following line no App.js file:

import "froala-editor/css/froala_style.min.css";

import "froala-editor/css/froala_editor.pkgd.min.css";

Initializing Froala Editor Component

Now that we’ve got the prerequisites out of the way, let’s initialize Froala Editor in Document Ready mode within your React project. Follow these steps:

1. Import Froala Editor

In your React component where you want to use Froala Editor, start by importing the necessary dependencies:

import FroalaEditorComponent from "react-froala-wysiwyg";

2. Create the Component

Next, create your React component with this code:

function App() {

  let model = '<p><a href="https://froala.com">Froala WYSIWYG Editor</a></p>';

  return (

    <div id="froala-editor">

          <h1>Froala WYSIWYG Editor </h1>

          <h2>Tutorial about Document Ready</h2>

      <FroalaEditorComponent

        tag="textarea"

        model={model}

        config={{

          quickInsertTags: [""],

        }}

      />

    </div>
  );
}

export default App;

In the above code, we’ve created a simple React component.

Froala rich text editor

3. Configure Froala Editor

To make the most of Froala Editor, you can configure it according to your needs.

Inside the initialization code block, you can pass configuration options as an object. Here’s an example of some common options you might want to use:

toolbarButtons: ['bold', 'italic', 'underline'],

Customized WYSIWYG Editor

In this example, we’ve customized the toolbar buttons. You can explore more configuration options in Froala’s official documentation.

Include Document Ready mode

Use this line to change your component for the Document Ready mode.

 documentReady: true

The “document ready mode” feature in the Froala WYSIWYG HTML Editor is designed to enhance the editing experience when creating online documents, making it more akin to using traditional word processors like Microsoft Word or Google Docs.

Document Ready Editor

Enabling Document Ready Mode: When you enable the document mode in the Froala editor, it automatically configures the editor with optimized settings for creating documents.

These settings are tailored to make the editor behave more like a traditional word processor, making it easier to work with documents.

In summary, the Froala WYSIWYG HTML Editor’s “document ready mode” feature simplifies creating online documents by providing a set of optimized settings and essential tools for document editing.

It bridges the gap between traditional word processors and web-based editing, ensuring that your documents can be printed or exported as PDFs with ease, just like you would in a typical word processing software.

This feature can be particularly advantageous for web applications or websites that require users to generate and manage documents online.

The component will have this code:

import "froala-editor/css/froala_style.min.css";

import "froala-editor/css/froala_editor.pkgd.min.css";

import FroalaEditorComponent from "react-froala-wysiwyg";

function App() {

  let model = '<p><a href="https://froala.com">Froala WYSIWYG Editor</a></p>';

  return (

    <div id="froala-editor">

          <h1>Froala WYSIWYG Editor </h1>

          <h2>Tutorial about Document Ready</h2>

      <FroalaEditorComponent

        tag="textarea"

        model={model}

        config={{

          documentReady: true

        }}
      />

    </div>
  );
}
export default App;

Conclusion

By following the steps outlined in this article, you can easily integrate Froala Editor into your React project app using Document Ready mode.

This approach simplifies the setup process, allowing you to focus on creating and editing rich content while taking advantage of Froala’s extensive customization options.

Remember to refer to Froala’s official documentation for a comprehensive list of configuration options, events, and advanced features.

With Froala Editor and React, you can provide your users with a seamless and intuitive rich text editing experience in your web applications. Happy editing!

Froala with Grammarly Text Editor SDK Alternative

Integrating Froala with Grammarly Text Editor SDK Alternative

Grammarly announced that it would be discontinuing the Text Editor SDK, the developer tool that puts the company’s automated editing functionality into any app. The tool will be shut down on January 10th, 2024, after which the functionality will cease to work in any applications where it’s in use.

If you use Grammarly Text Editor SDK and your business will be affected by this change. You don’t need to worry. We’ve got you covered.

A WYSIWYG Editor that can integrate with Different JavaScript tools

Froala is a powerful WYSIWYG editor that can be easily integrated with different JavaScript tools on the web. Fortunately, there are a lot of JavaScript tools that provide similar Grammarly features. Incorporating a Grammarly alternative with Froala will maintain the same user experience in your application.

For instance, if you are looking for a grammar check and spelling correction suite, you can use WProofreader, the AI-powered component of WebSpellChecker. WProofreader works with the Froala editor seamlessly, providing real-time grammar, spelling, and punctuation checks. Check out how this integration works and see a working demo on our WProofreader integration page.

Another good Grammarly alternative is Sapling. In addition to grammar checking, Sapling also offers deep learning-powered autocomplete suggestions across all messaging platforms.

How to Integrate Sapling with Froala

Integrating Froala with Sapling

Integrating Sapling with Froala is a straightforward process that requires minimal coding. Sapling offers an extensive API as well as SDKs that assist in grammar-checking text for Python and JavaScript, and an HTTP API that is language-agnostic. In this post, we will use the grammar-checking SDK for quick integration with Froala. Here are the steps required.

Prerequisites:

  • Registering for an API key:

    Sapling offers a free plan with limited capabilities but it comes with a free 30-day trial of Sapling Pro. To allow you to try Sapling capabilities. Sign up for Sapling, and get your API key, to get started.

  • Prepare your environment:

    Sapling and Froala are versatile tools that support popular JavaScript frameworks like React, Angular, and Vue. Both offer guidance on how to integrate within these frameworks. However, for the sake of clarity, this article will focus on a straightforward integration using basic HTML and JavaScript. You can then adapt these principles to your favorite framework.

Get started

At the beginning, create an HTML document with a single element where the editor will be initialized.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Froala & Sapling</title>

</head>

<body>

    <div id="editor-element">Lets get started!</div>

</body>

</html>

Start with initializing Froala:

  • Include Froala Stylesheet on the page header
    <!-- include the latest Froala version stylesheet -->
    <link href='https://cdn.jsdelivr.net/npm/froala-editor@latest/css/froala_editor.pkgd.min.css' rel='stylesheet' type='text/css' />
  • Include the Froala script before the closing </body> tag
    <!-- include the latest Froala version script -->
    <script type='text/javascript' src='https://cdn.jsdelivr.net/npm/froala-editor@latest/js/froala_editor.pkgd.min.js'></script>
  • Initialize the Froala editor by calling the Forala constructor function and passing the element selector as the first parameter
    <script> 

        new FroalaEditor('#editor-element');

    </script>

Now, if you open your HTML page on your browser, you should see the Froala editor opened

Froala editor initialized

Initializing Sapling:

  • Include the Sapling JavaScript file:
<script src="https://sapling.ai/static/js/sapling-sdk-v1.0.5.min.js"></script>
  •  We need to initialize Sapling after the editor loads. In this case, we can initialize it inside the Froala initialized event or in the callback function which is passed as the third parameter to the Froala constructor function. Basically, it is the same as doing it like this
    <script> 

        let editor = new FroalaEditor('#editor-element',{},function(){

            Sapling.init({

              key: '***',

              mode: 'dev',

            });          

        });

    </script>
  • Or doing it like this
    <script> 

        new FroalaEditor('#editor-element',{

            events: {

                'initialized': function () {                   

                Sapling.init({

                        key: '***',

                        mode: 'dev',

                        });

                }
            }

        });

   </script>

The Sapling init method takes an object that includes the following properties:

  • `key`: This is the API key you received when you signed up for Sapling.
  • `mode`: This can be either `’dev’ for development mode, or ‘prod’ for production mode. It determines what API endpoints Sapling will use.

Note:

  • During development, you can pass in the API key and use Sapling’s endpoints by setting mode: ‘dev’ in the init function.
  • For production, do not pass the API key in JavaScript. Instead, include the API key in your backend and call Sapling’s endpoints from the backend. This is the default setting with mode: ‘prod’.
  • Remember to replace ‘***’ with your Sapling API Key.

Once Sapling is initialized, we can call any of the methods mentioned in the Sapling docs.

We will use Sapling.observe to observe the editor for changes and provide grammar corrections and suggestions every time we add content.

  <script> 

    new FroalaEditor('#editor-element',{},function(){

        Sapling.init({
            key: '***',
            mode: 'dev',
        });

        // `this` is the editor instance

        const contentEditable = this.$el[0];

        Sapling.observe(contentEditable);
    });

 </script>

 The observe method’s first parameter should be the contenteditable or textarea element that needs to be observed. In our example we used the this keyword, which contains the editor instance, to get the editing area element.

Open the HTML file in your browser to test integration. Grammar checks should automatically be applied as you type in the editor. After clicking on the incorrect text, a popup displays suggested corrections. Select the desired correction to apply it to the text.

Grammar checking and correction with Froala and Sapling

The full example code is

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Froala & Sapling</title>
    <!-- include the latest Froala version stylesheet -->
    <link href='https://cdn.jsdelivr.net/npm/froala-editor@latest/css/froala_editor.pkgd.min.css' rel='stylesheet' type='text/css' />
</head>
<body>

    <div id="editor-element" sapling-ignore="true">Lets get started!</div>

    <!-- include the latest Froala version script -->
    <script type='text/javascript' src='https://cdn.jsdelivr.net/npm/froala-editor@latest/js/froala_editor.pkgd.min.js'></script>
       
    <!-- include the Sapling SDK script -->
    <script src="https://sapling.ai/static/js/sapling-sdk-v1.0.5.min.js"></script>

    <script> 
    new FroalaEditor('#editor-element',{},function(){
       
        Sapling.init({
            key: '***',
            mode: 'dev',
        });

        // `this` is the editor instance
        const contentEditable = this.$el[0];
        Sapling.observe(contentEditable);
        
    });
    </script>
</body>
</html>

The example provided showcases only a glimpse of Sapling and Froala’s potential. We employed Sapling for live grammar and spelling checks within the editor. This can be further enhanced by tailoring Sapling to various editor events, leveraging different Sapling API methods, and even creating a custom Froala  plugin for implementing more Sapling features. 

Conclusion

The rolldown of Grammarly Text Editor SDK does not mark the end of automated writing assistant tools in your app. Explore the other options and choose the one that best fits your application’s needs.

Sapling offers a range of features such as grammar checking, writing suggestions, autocompletion, and more. You can easily integrate Sapling with the Froala WYSIWYG editor and provide users with a seamless writing experience. Using Sapling with Froala supports multiple languages, including, but not limited to English, German, and Spanish. 

Let’s start integrating Froala with Sapling and enjoy cleaner and free from grammatical errors writing experience. It is an essential add-on for writers, bloggers, marketers, or any users who frequently engage in content creation.

Leave a comment if you need help with the integration process or if you run into any issues.

Froala V4.1.1 release: Enhancing Typescript Support

Typescript Support

Today, we are delighted to introduce Froala V4.1.1, an update that builds upon the successes of our best release ever with Froala v4.1 which introduced updated LTS support for React, Vue, and Angular among other important improvements.

In response to our users’ feedback, We have introduced, in V4.1.1, significant changes to ensure a smoother and more compatible experience with TypeScript in Froala.

Froala 4.1 & TypeScript

Froala 4.1 has introduced TypeScript definitions support. This addition is a game-changer for developers as it offers a range of benefits that enhance productivity and code reliability. It provides developers with helpful hints, type-checking at compile-time, and more robust auto-completion.

  1. Better Intelligence:
    Software development teams can now enjoy contextual granularity while coding, thus reducing the chances of making errors..
  2. Compile-time Type Checking:
    Allowing developers to catch potential bugs in their code that may have been missed. This significantly enhances build-time code reliability.
  3. Definitive Auto-completion:
    This feature is a boon for quick coding. Suggestions based on TypeScript definitions provide accurate find-and-replace functionality, making coding a breeze. With accurate types, your editor gains a clear insight into the values and functionalities available, eliminating the need to search through the entire code base.

However, there were some incorrect definitions and missing properties in the index.d.ts file. As a result, using these properties could lead to TypeScript errors. Especially, when using the Angular SDK. Release 4.1.1 came to resolve these issues.

What’s new in Froala 4.1.1?

Enhanced TypeScript Support
Froala 4.1.1 boasts enhanced typescript definition support, successfully addressing any issues encountered in 4.1, and guaranteeing seamless compatibility with Angular TypeScript.
To fully benefit from these enhancements and avoid coding complications, we encourage all users to promptly update to the latest release. For instructions on how to update, please refer to our handy “how-to-update” section located at the bottom of this post.

let’s dig deeper into the 4.1.1 release

Displaying toolbar buttons correctly on Angular

Now that Froala supports the latest Angular release, you can enhance your users editing capabilities with the Froala editor. Follow this comprehensive step-by-step tutorial to integrate Froala into your Angular app.

The basic integration process will only display the editor’s default toolbar buttons. However, by importing Froala’s plugin scripts into the app.module.ts file, users can now have access to additional buttons related to those plugins.

For instance, by importing the align plugin

import 'froala-editor/js/plugins/align.min.js';

The editor toolbar will display the following buttons:

  • Align right
  • Align left
  • Center
  • Justify

To enjoy the full range of features, you can import all the editor plugins with a single statement thereby displaying all plugin toolbar buttons

import 'froala-editor/js/plugins.pkgd.min.js';

Furthermore, You have the flexibility to customize the editor toolbar to your liking by utilizing the toolbarButtons API option. Simply set this option with the desired toolbar buttons and pass it within the Froala Angular component options tag.

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

Fix TypeScript Definitions

As we mentioned above, in V4.1.1, we added properties that were missed in v4.1, we’ve also fine-tuned some definitions to ensure everything works smoothly.

Many properties have been added or edited. Such as:

  • FE.DEFAULTS
  • FE.DefineIcon
  • FE.DefineIconTemplate
  • FE.END_MARKER
  • FE.KEYCODE
  • FE.MARKERS
  • FE.PLUGINS
  • FE.POPUP_TEMPLATES
  • FE.RegisterCommand
  • FE.RegisterQuickInsertButton
  • FE.RegisterShortcut
  • FE.START_MARKER

If you’ve been encountering errors while creating custom buttons, plugins, or icons, don’t worry! Simply update your editor and it will now work without these errors.

How Can I Update?

We’ve streamlined the process to make it hassle-free. Just head over to our dedicated page for each framework SDK, where you’ll find detailed instructions on installing or updating to the latest version. Follow the links below to get started.

If you are using a plain JavaScript library or other framework, check the get started page to know the proper way of downloading the latest Froala Editor release and how to include it in your project based on your preferred method.

If you are using a plain JavaScript library or other framework, follow the table below to know the proper way of downloading the latest Froala Editor release and how to include it in your project based on your preferred method.

Method How to download Include in your project
CDN
<!-- Include Editor stylesheet-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />

<!-- Include Editor JavaScript file-->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/js/froala_editor.pkgd.min.js"></script>
CDN (Always the latest version)
<!-- Include Editor stylesheet-->
<link href="https://cdn.jsdelivr.net/npm/froala-editor@latest/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />

<!-- Include Editor JavaScript file-->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@latest/js/froala_editor.pkgd.min.js"></script>
NPM
npm install froala-editor
<!--

Replace the {download-folder-path} in the following example with the path to the folder containing the stylesheet file e.g.

../css/froala_editor.pkgd.min.js

-->

<link href="{download-folder-path}/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />

<!--

Replace the {download-folder-path} with the path to the folder containing the JS file e.g.

../js/froala_editor.pkgd.min.js

-->

<script type="text/javascript" src="{download-folder-path}/froala_editor.pkgd.min.js"></script>
bower
bower install froala-wysiwyg-editor
NO Package Manager Download Froala WYSIWYG Editor files using the download form here.
Integrated with a Framework Select your preferred framework from 17 different popular frameworks.
Other options Check here for other options to use Froala WYSIWYG Editor in your project.

For Froala Editor Version 2 Users:

Follow this migration guide to get step-by-step instructions on how to upgrade from version 2.

Try The Latest Froala Editor

Explore a variety of examples that demonstrate the functionality of the Froala HTML Editor.

Support and Feedback

We are dedicated to always offering the best possible experience for all our users. We believe this release, meant to enhance Typescript support, is a stepping stone towards that commitment. We encourage you to try this improved Typescript support and give us your valuable feedback. Your input is crucial for delivering continuous enhancement in meeting your evolving needs. Thank you for being a valuable part of our vibrant and growing community.
We would like to hear what you think of the latest release! Join us on our GitHub Community to chat with our product manager, developers, and other members of the Froala team.

Change Log

Get Started

  • You can download and start using Froala in less than five minutes following our get started guide.

Technical Questions

Get Froala Editor Now

 

Custom Buttons with Froala in an Angular Application

Froala Angular CUstom Buttons

In web development, Froala and Angular are well-known for being efficient and flexible. Froala is a WYSIWYG Editor with lots of features. Angular is a popular tool for building apps and works well with Froala. Together, they help developers save time and make better apps. For example, you can create custom buttons in the Froala editor, making apps more interactive.

 

In this guide, we’ll dig into custom buttons: why they’re awesome, how they simplify app building, and real-world uses.

The Power of Froala and Angular

But first, let’s chat about why mixing Froala with Angular makes such a big difference in web development.

Why Froala and Angular?

Froala’s Strengths:

Simple Setup: You can easily add Froala to different settings, including Angular.

Make It Yours: With Froala, you can customize a lot, like making your own buttons.

Lots to Offer: Froala lets you format text, add media, and more.

Angular’s Strengths:

Neat & Tidy: Angular is built in parts, so it’s easier to work with and keep clean.

Instant Updates: Changes you make in Angular show up in real-time.

More to Add: With tools like angular-froala-wysiwyg, Angular lets you do even more.

Tutorial: Creating Custom Buttons with Froala in Angular

Step 1: Installation

This step includes installing the necessary packages and including the required styles.

Install angular-froala-wysiwyg:

npm install angular-froala-wysiwyg

Add CSS styles to your index. file:

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

Optionally, install font-awesome for additional icons (either via npm or using the CDN in index.):

npm install font-awesome

Or

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-

Step 2: Integration with Angular

This step integrates the Froala WYSIWYG editor with your Angular application.

Generate a New Angular Application (skip if you already have one):

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

Install angular-froala-wysiwyg:

npm install angular-froala-wysiwyg --save

Modify src/app/app.module.ts by Importing Froala Modules and Adding Them to the Imports Array:

 

import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
@NgModule({

   ...

   imports: [FroalaEditorModule.forRoot(), FroalaViewModule.forRoot(), ... ],

   ...

})

Insert the Necessary Styles in angular.json within 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",
]

Update src/app/app.component. to Include the Froala Editor Directive:

<div [froalaEditor]>Hello, Froala!</div>

Run Your Angular Application:

ng serve

Setting Up Froala Editor in Your Angular App

  1. Install Froala: This step is all about getting Froala into your app.
  2. Integrate with Angular: Once installed, make sure Froala works well with your Angular project.
  3. Ready for Customization: With Froala now part of your Angular app, you can start adding special features. For example, you can create your own buttons like we mentioned.

By completing these steps, your Froala editor will be all set and ready for any custom touches you want to add.

Step 3: Adding Custom Buttons

Go to Your Component File

  • Find the Angular component where you want to add the new button in Froala.
  • This could be in a special editor component or somewhere broader like a form page.

Make Your Custom Button

  • Within the component, find the FroalaEditor object.
  • Use it to create and list your custom button.
  • Put this step in the ngOnInit section. This makes sure your button is ready when the page starts up.

Here’s the updated code snippet:

 

import { Component, OnInit } from '@angular/core';
import FroalaEditor from 'froala-editor';

@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 {
  public content: string = '<p>Your initial content here...</p>';
  ngOnInit() {
    FroalaEditor.DefineIcon('alert', { NAME: 'info' });
    FroalaEditor.RegisterCommand('alert', {
      title: 'Hello',
      callback: () => {
        alert('Hello!', this);
      },
    });
  }

  public options: Object = {
    toolbarButtons: ['bold', 'italic', 'underline', 'paragraphFormat', 'alert'],
    // ...
  };
}

 

Setting Up Custom Buttons in Froala with Angular

  1. Add to Toolbar: Put your custom button, like ‘alert’, on the Froala editor’s toolbar list. This makes it show up there.
  2. Include in Template: Add the component with your custom button to the right Angular templates, so the Froala editor pops up where you want.

By setting it up this way inside the Angular component from the start, your custom button fits right into your app’s flow and looks like a built-in part of your design.

Now, run the application:

ng serve

You can view the whole demo here:

How Custom Buttons in Froala Impact the Real World

With custom buttons in Froala, you can do so much more than just regular tasks. They boost user experience and bring fresh features to life. Check out these practical uses:

Easy Content Checks: In systems that manage content, a button can send work straight to a boss for a quick check.

Quick Email Templates: For email marketing, a button can add ready-to-use templates instantly.

Help for Special Needs: You can make buttons that read out text, helping users who need it.

Work with Other Tools: Add buttons that link to calendars, calculators, or other tools to make the editor even better.

Share on Social Media: A button can post content directly to sites like Facebook or Twitter, perfect for bloggers.

Unpacking the Power of Custom Buttons in Development

Better User Experience: With buttons made just for them, users will find your apps more enjoyable.

Faster App Building: With tools like Froala and Angular, developers can make detailed features faster.

Easy Updates: Custom buttons mean you can add new things to your app without redoing everything.”

Conclusion

Froala and Angular help make app-building simpler and better. One fun feature is adding custom buttons, as shown in our guide. These buttons can speed up tasks and make apps user-friendly. They let developers add creative touches. New or seasoned at building apps? Using these buttons in Froala and Angular offers cool features to try out.

 

Get Froala Editor Now

Crafting a Custom Button for the Froala Editor in Vue.js

vue js custom button

Creating a custom button for the Froala Editor within a Vue.js application allows developers to extend the editor’s capabilities to match their project’s specific needs. This comprehensive guide will walk you through the process step by step.

vue js custom button main image

Prerequisites:

Basic understanding of and Vue.js.

Node.js and NPM are installed on your machine.

A fresh Vue.js project. If you don’t have one, set it up using the Vue CLI.

Step-by-Step Integration:

1. Setting up a New Vue Project (if needed):

If you don’t already have a Vue project,

npm install -g @vue/cli

vue create froala-vue-project

cd froala-vue-project

2. Install the vue-froala-wysiwyg package:

npm install vue-froala-wysiwyg --save

3. Setting up Froala in the project

Open the src/main.js file:

import 'froala-editor/js/plugins.pkgd.min.js';

import 'froala-editor/css/froala_editor.pkgd.min.css';

import { createApp } from 'vue';
import App from './App.vue';
import VueFroala from 'vue-froala-wysiwyg';

const app = createApp(App);
app.use(VueFroala);
app.mount('#app');

4. Set up the Froala component in your Vue template:

In src/App.vue:

 

<template>
  <div id="app">
    <froala :tag="'textarea'" :config="config" v-model:value="content"></froala>
  </div>
</template>

<script>
import FroalaEditor from 'froala-editor';

export default {
  name: 'App',
  data() {
    return {
      content: 'Your initial content here!',
      config: {}
    };
  }
};
</script>

5. Creating Your Custom Button:

  1. Define the Icon: Choose an SVG icon or use a predefined one. Here, we’ll use the ‘star’ icon:
  2. Register the Custom Button: Define your button’s functionality. In this example, the button will insert custom text:
    1. FroalaEditor.DefineIcon('myButton', {NAME: 'star', SVG_KEY: 'star'});
  3. Integrate the Button into the Froala Toolbar: Update the config object in your App.vue:
    1. config: {
        toolbarButtons: [['bold', 'italic', 'underline', 'myButton']]
        // ... any other configurations
      }
      

Here’s the final look of your App.Vue file

<template>
  <div id="app">
    <froala :tag="'textarea'" :config="config" v-model:value="content"></froala>
  </div>
</template>

<script>
import FroalaEditor from 'froala-editor';

export default {
  name: 'App',
  data() {
    return {
      content: 'Your initial content here!',
      config: {
        //... (you can add your initial configuration here)
        toolbarButtons: [['bold', 'italic', 'underline', 'myButton']]
      }
    };
  },
  created() {
    // Define the Icon for the Custom Button
    FroalaEditor.DefineIcon('myButton', {NAME: 'star', SVG_KEY: 'star'});

    // Register the Custom Button's action
    FroalaEditor.RegisterCommand('myButton', {
      title: 'Insert Custom Text',
      focus: true,
      undo: true,
      refreshAfterCallback: true,
      callback: function() {
        this.html.insert('Watch the magic happen🌠');
      }
    });
  }
};
</script>

6. Run and Test:

Launch your Vue.js application:

 

npm run serve

Open your browser to view the application. You should spot the Froala Editor with your custom button integrated. Clicking it will insert the pre-set text.

 

Here’s a demo of the working code:

 

Extra Content: The Seamless Integration of Froala with Vue.js 3 LTS Version

With the long-term support (LTS) version of Vue.js 3 now available, the benefits of using Froala with Vue.js have become even more pronounced. Here’s why:

1. Flexibility Meets Stability

The LTS version of Vue.js 3 offers a stable platform that receives regular maintenance and security updates. When you combine this stability with Froala’s adaptability, developers get a blend of reliability and flexibility that few combinations can offer.

2. Enhanced Performance:

Vue.js 3 has brought numerous performance improvements. One notable change is the async setup, which allows you to handle asynchronous operations directly within the setup function. Combined with Froala’s efficient rendering, this results in a smoother user experience.

 

<template>
  <froala :tag="'textarea'" :config="config" v-model:value="content"></froala>
</template>

<script>
import { ref } from 'vue';
import FroalaEditor from 'froala-editor';

export default {
  async setup() {
    const content = ref('Your initial content here!');
    const config = ref({
      //... (your initial configuration here)
    });

    // Let's say you fetch some content asynchronously for the editor.
    const fetchedContent = await fetchContentFromServer();
    content.value = fetchedContent;

    return {
      content,
      config
    };
  }
};
</script>

3. Better Composition API:

Vue.js 3 introduces the Composition API, which allows a more flexible code organization. Combined with Froala’s modular design, this results in cleaner and more maintainable code.

 

import { ref, computed } from 'vue';
import FroalaEditor from 'froala-editor';

export default {
  setup() {
    const content = ref('Your initial content here!');
    
    // Using the Composition API to create a computed property
    const wordCount = computed(() => {
      return content.value.split(' ').length;
    });

    // Define and register a custom button using Froala's methods within the Composition API
    FroalaEditor.DefineIcon('wordCountButton', {NAME: 'counter', SVG_KEY: 'counter'});
    FroalaEditor.RegisterCommand('wordCountButton', {
      title: 'Word Count',
      focus: false,
      undo: false,
      refreshAfterCallback: false,
      callback: function() {
        alert(`Current word count: ${wordCount.value}`);
      }
    });

    return {
      content,
      wordCount
    };
  }
};

4. Improved Customizability:

Vue.js 3 LTS comes with enhanced support for TypeScript. This means developers can now easily define types for their custom buttons or other editor extensions.

 

import { Ref, ref } from 'vue';
import FroalaEditor from 'froala-editor';

interface EditorConfig {
  toolbarButtons?: string[][];
  //... other configuration options
}

export default {
  setup(): { content: Ref<string>; config: Ref<EditorConfig> } {
    const content: Ref<string> = ref('Your initial content here!');
    const config: Ref<EditorConfig> = ref({
      toolbarButtons: [['bold', 'italic', 'underline', 'wordCountButton']]
      // ... other configurations
    });

    return {
      content,
      config
    };
  }
};

The code snippets provided demonstrate how effortlessly Vue.js 3 LTS and Froala Editor can integrate. Together, they offer a robust platform for developers aiming to create top-notch digital solutions.

 

Conclusion

Successfully adding a custom button for the Froala Editor within a Vue.js app enhances the user experience and demonstrates the flexibility of both Vue.js and Froala. This tutorial aimed to deliver a clear roadmap from the beginning to the end of the process, and we urge readers to explore further customizations to meet their unique demands. With tools like Vue.js and Froala, the possibilities are vast. Happy coding!

Do checkout our Vue.js documentation to learn more.

 

Download Froala Editor

Creating Custom Buttons with React and Froala Editor

React editor custom buttons

The Froala Editor is a powerful WYSIWYG (What You See Is What You Get) HTML editor that offers a wide range of features for creating and editing content. One of its standout features is the ability to enhance its functionality by creating custom buttons. In this article, we will explore how to create custom toolbar buttons using React and Froala Editor to enhance your experience in creating content. React editor custom buttons

Understanding the Integration of Froala Editor and React

Before delving into the creation of custom buttons, let’s briefly examine the integration of Froala Editor with React. Froala Editor is a text editor that offers a seamless and user-friendly interface for editing content. Integrating Froala with React involves wrapping the editor inside a React component, thereby combining the capabilities of both technologies. You can learn more about the integration between React and Froala in the documentation on our website. To get started, you need to install the necessary dependencies for your React project.

npm install react-froala-wysiwyg --save

Once installed, you can import the Froala Editor styles and the React component:

import React from 'react'; import FroalaEditorComponent from 'react-froala-wysiwyg'; import 'froala-editor/css/froala_style.min.css'; import 'froala-editor/css/froala_editor.pkgd.min.css';

Now, you can use the FroalaEditorComponent in your React component’s method:

const App = () => {   return (     <div >       <FroalaEditorComponent         tag="textarea"       />     </div>   ); }; export default App;

With this integration, you can have a basic Froala Editor running in your React application. However, the true power lies in creating customized buttons to enhance the capabilities of the editor.

Extending the Froala Editor with Custom Buttons

The toolbar of the Froala Editor is where users can find options for formatting text, adding images, links, and other elements. Creating custom toolbar buttons using React allows you to enhance this functionality and offer users additional features that are specifically designed for your application’s requirements. Froala Editor allows you to seamlessly integrate custom buttons into its toolbar, providing users with additional functionality tailored to their specific needs. To accomplish this, we will utilize the combination of React and the Froala Editor’s API. On the component file, import Froalaeditor component so we can use it to create the custom buttons

import Froalaeditor from 'froala-editor';

Then add the following code to create ‘Alert’, ‘Clear’, and ‘Insert’ buttons.

Froalaeditor.DefineIcon('alert', {NAME: 'info', SVG_KEY: 'help'});   Froalaeditor.RegisterCommand('alert', {     title: 'Hello',     focus: false,     undo: false,     refreshAfterCallback: false,     callback: function () {       alert('Hello!');     }   });   Froalaeditor.DefineIcon('clear', {NAME: 'remove', SVG_KEY: 'remove'});   Froalaeditor.RegisterCommand('clear', {     title: 'Clear HTML',     focus: false,     undo: true,     refreshAfterCallback: true,     callback: function () {       this.html.set('');       this.events.focus();     }   });   Froalaeditor.DefineIcon('insert', {NAME: 'plus', SVG_KEY: 'add'});   Froalaeditor.RegisterCommand('insert', {     title: 'Insert HTML',     focus: true,     undo: true,     refreshAfterCallback: true,     callback: function () {       this.html.insert('My New HTML');     }   });

Witnessing the Magic of Custom Buttons

With these custom buttons seamlessly integrated into the Froala Editor, users are empowered to utilize their extended functionalities. Each custom button reveals a unique aspect of improvement. Alert Button: The ‘alert’ button transforms into a messenger, delivering a JavaScript alert that displays the message “Hello!” when summoned with a click. Clear Button: The ‘clear’ button assumes the role of a content guardian, allowing users to remove the editor’s content while maintaining its focus, providing a blank canvas for new creations. Insert Button: The ‘Insert’ button emerges as a vessel of ingenuity, allowing users to infuse the editor’s canvas with the inscription “My New HTML,” enabling rapid creation. These custom buttons embody the essence of a personalized experience, guiding users towards a world of streamlined actions, driven by these customized functionalities.

The Flourish: Integrating Custom Buttons

The culmination of this customization journey occurs when these custom buttons are seamlessly integrated into the Froala Editor’s toolbar, enhancing the process of creating content. React takes center stage here, serving as the conduit for this integration.

import React from 'react'; import FroalaEditorComponent from 'react-froala-wysiwyg'; import 'froala-editor/css/froala_style.min.css'; import 'froala-editor/css/froala_editor.pkgd.min.css'; const App = () => {   return (     <div >       <FroalaEditorComponent         tag="textarea"         config={{           toolbarButtons: [['undo', 'redo' , 'bold'], ['alert', 'clear', 'insert']],         }}       />     </div>   ); }; export default App;

In the React component snippet above, the FroalaEditor component is imported and configured with the toolbarButtons prop. The toolbar is meticulously organized into two rows. The first row comprises standard buttons such as ‘undo,’ ‘redo,’ and ‘bold.’ The second row showcases the culmination of our endeavor – the custom buttons: ‘alert,’ ‘clear,’ and ‘insert.’ Below we can see images of the result of the component with the buttons that we saw in the React application. React editor custom buttons Froala editor React editor custom buttons editor custom buttons custom buttons By following these steps, you can seamlessly integrate custom toolbar buttons into the Froala Editor using React. This approach empowers you to enhance the editor’s capabilities beyond its default features and create a more customized editing experience for your users.

Conclusion

Customizing rich text editors such as Froala using React opens up a world of possibilities for creating dynamic and feature-rich content creation experiences. By integrating custom toolbar buttons, you can provide users with specialized functionality that aligns with your application’s requirements. This not only enhances user satisfaction but also showcases your development skills in delivering a seamless and intuitive editing environment. So, go ahead and explore the combination of React and Froala Editor to create the ideal content creation tool for your web application. We have included a working example below that shows the complete code we have discussed.

 

Building Interactive Web Apps with React and Froala Editor

React rich text editor

Web applications have become a part of our lives by facilitating seamless communication and collaboration.

Rich text-editing capabilities are a crucial aspect of web app development. Users expect a user-friendly and easy-to-use interface to compose and present text.

Froala Editor is a feature-rich and customizable WYSIWYG (What You See Is What You Get) editor that enables users to easily create and format content. It supports various text styles, images, videos, and tables. This article explains how to use Froala Editor in a React app for better text editing.

Building Interactive Web Apps with React and Froala Editor

Why Choose The Froala Editor

Before diving into the integration process, let’s briefly discuss why the Froala Editor stands out among other text editors. Froala Editor offers a comprehensive set of features that make it an excellent choice for developers and content creators.

  • Rich Text Editing Capabilities: The Froala Editor provides a user-friendly interface that allows users to format and style text similar to a word processor.
  • Responsive Design: The editor is designed to work seamlessly across different devices, ensuring a consistent experience for all users.
  • Cross-browser Compatibility: Froala Editor supports all major web browsers, including Chrome, Firefox, Safari, and Edge.
  • Customizable: Developers can customize the editor’s appearance and behavior to match the application’s theme and requirements.
  • Media Support: The editor supports various media types, such as images and videos, making content creation more engaging.
  • Undo/Redo Functionality: Users can easily undo or redo their actions. This provides a safety net for accidental changes.
  • Easy Integration: The Froala Editor offers straightforward integration with popular frameworks, such as React, making it an ideal choice for developers.

With these features in mind, let’s move on to the steps required to integrate Froala Editor into a React application.

Installation and Setup

Prerequisites

Before integrating Froala Editor into your React application, make sure you have Node.js and npm (Node Package Manager) installed on your system. This allows one to create a new React project and effectively manage its dependencies.

Creating a React Application

To start, open your terminal and use the following command to create a new React application:

npx create-react-app froala-editor-demo

cd froala-editor-demo

This will set up a new React project in a directory called froala-editor-demo. Next, navigate to the project directory and install Froala Editor SDK:

npm install react-froala-wysiwyg --save

Importing and Initializing Froala Editor

After installing Froala Editor SDK, you need to import it and initialize it within your React application. To do this, follow these steps:

Open App.js, and import the necessary modules:

Import the Froala Editor CSS

Import the Froala Editor CSS to ensure that the editor’s styles are applied correctly.

import 'froala-editor/css/froala_editor.pkgd.min.css';

import 'froala-editor/css/froala_style.min.css';

Import the Froala Editor Component

import FroalaEditorComponent from 'react-froala-wysiwyg';

Usage Examples

Now that we have the basic integration set up, let’s explore some usage examples of the Froala Editor within our React application.

Example 1: Basic Usage

Using the FroalaEditorComponent is as simple as rendering it in your desired location within your React application.

Inside the App Function remove everything and add the following return statement

  return (
    <div>

      <h1>Froala Editor App</h1>
      <FroalaEditorComponent tag='textarea'/>
    </div>
  );

The App.js code now looks like

// Require Editor CSS files.
import 'froala-editor/css/froala_style.min.css';
import 'froala-editor/css/froala_editor.pkgd.min.css';

import FroalaEditorComponent from 'react-froala-wysiwyg';

function App() {

  return (
    <div>

      <h1>Froala Editor App</h1>
      <FroalaEditorComponent tag='textarea'/>
    </div>
  );
  
}

export default App;

Run the application and you will see the Froala editor rendered on the screen

React rich text editor

Example 2: Customizing the Editor

Froala Editor allows you to customize various aspects of the editor. You can add custom configurations by passing an options object during initialization.

<FroalaEditorComponent tag='textarea' config={{

        toolbarButtons: ['bold', 'italic', 'underline'],

        quickInsertTags: [''],

}}/>

In this example, we modified the toolbar buttons to include only basic formatting options.

Customized rich text editor

Conclusion

Rich text editing functionality can be easily added by creating interactive web applications with React and Froala Editor. In this article, we covered the installation, configuration, and fundamental usage examples for integrating Froala Editor into a React application. 

You can quickly enable Froala Editor’s extensive capabilities in your web application by following the installation and configuration instructions provided in this article.

Additionally, you can customize the editor to meet your individual needs thanks to its flexibility and customization options, which makes it a valuable tool for content creation, blog platforms, online editors, and many other web applications.

As you delve deeper into both technologies, you’ll discover a myriad of possibilities for building sophisticated web applications that cater to diverse user needs. So, go ahead, experiment, and create amazing interactive web apps with React and Froala Editor.

For more information, explore our React SDK documentation.

How to integrate Froala With Vue 3

Froala-Vue integration

We are pleased to announce that Froala version 4.1 has been released. This new version of Froala also provides users with an improved experience, better performance and accessibility. It also includes new features such as support for Vue.js 3.x.

Vue.js 3.0 is a popular JavaScript framework for developing highly reactive user interfaces. Froala improves application user interfaces by offering an intuitive, feature-rich WYSIWYG editor that comes with numerous styling options, image management features, in-built support for rich text editing, video embedding, SEO-friendly, and many other features. That’s why I’m excited to show you how easy it is to integrate the Froala WYSIWYG editor with a Vue 3 application.

Vue WYSIWYG Editor

Before diving in, we assume you have a working knowledge of:

  • JavaScript (including some of the newer, es2015 features)
  • Vue 3
  • How to use the terminal/command line
  • Node and npm

We will create a simple application and guide you step-by-step through this tutorial. There will be a working demo at the end of the article.

Step 1: Create a simple Vue project

Skip this step if you already have a Vue 3 project setup. If not, head over to your terminal/console.

Using your terminal, you can create a new Vue.js project with vue-create:

1.1 Install the Vue CLI

npm install -g @vue/cli

1.2 Inside the folder where you want to create your new Vue project run the Vue create command for a basic Vue project

vue create my-froala-vue-app

1.3 The terminal will prompt some configuration questions. Carefully answer them with your preferred set-up settings. I selected `Default ([Vue 3] babel, eslint)` for a simple Vue 3 project. I also picked ‘NPM‘ as the package manager to use when installing dependencies.

Create Vue APP.

Step 2: Install Vue WYSIWYG editor (the Froala Editor Package)

Step inside the project directory:

cd my-froala-vue-app

Once inside, install Froala’s Vue WYSIWYG editor by running the following command:

npm install vue-froala-wysiwyg --save
Note: 
This installs the latest Froala Vue SDK which supports Vue 3. If you are using an earlier Vue version, use the following command instead

npm install [email protected] --save

Unfortunately, this command will not install the latest version of Froala. Therefore, we recommend updating Vue and installing Froala using the first command.

Congratulations, you have successfully installed Froala in your Vue application. This means you can now use the VueFroala component in your project. To use the editor component in your application, you need to import it into main.js. Let’s see how to do that!

Step 3: Integration

3.1 Import Froala Editor in main.js

Open your main.js file and import the imperative bits for Froala Editor. Here’s what your file should include:

import { createApp } from 'vue'
import App from './App.vue'

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


// Import Froala Editor css files.
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/froala_style.min.css';


// Import Froala Editor component
import VueFroala from 'vue-froala-wysiwyg';

const app = createApp(App);          

app.use(VueFroala);
app.mount('#app');

3.2 Initializing the Editor

From within your project directory, open the src/App.vue file. By default, it makes use of a HelloWorld component:

<template>

  <img alt="Vue logo" src="./assets/logo.png">

  <HelloWorld msg="Welcome to Your Vue.js App"/>

</template>




<script>

import HelloWorld from './components/HelloWorld.vue'




export default {

  name: 'App',

  components: {

    HelloWorld

  }

}

</script>




<style>

#app {

  font-family: Avenir, Helvetica, Arial, sans-serif;

  -webkit-font-smoothing: antialiased;

  -moz-osx-font-smoothing: grayscale;

  text-align: center;

  color: #2c3e50;

  margin-top: 60px;

}

</style>

Remove the importing and declaring the HelloWorld component within the <script> tags since we will use the Froala editor component instead.

In the App component definition, add the data function that defines the component’s data properties. Inside the data function, add the following properties:

  • config: is an object that contains the editor API options
  • model: a string containing the editor’s default HTML content displayed by the editor.
<script>

export default {

  name: 'App',

  data () {

    return {

      config: {

        //documentReady: true,

        //direction: 'rtl',

        heightMin: 300,

        events: {

          initialized: function () {

            console.log('initialized')

          }

        }

      },

      model: '<i>Edit Your Content Here!</i>'

    }

  }

}

</script>

Finally, replace the HelloWorld component within the <template> tags with the editor component :

<template>

  <img alt="Vue logo" src="./assets/logo.png">

  <froala id="edit" :tag="'textarea'" :config="config" v-model:value="model"></froala>

</template>
  • :tag attribute is used to tell on which tag the editor is initialized.
  • :config attribute is used to configure the editor options
  • v-model:value Used to load editor content. This value is affected by editor HTML changes.

:config and v-model:value are using the config and model data properties we defined previously.
Note: There will be changes to the model value if you want to initialize the editor based on a, button, img, or input tags. We will cover these special tags in detail in another article since they change the editor’s interface.

Step 4: Run the project

After the integration is complete, it’s time to run your project to see the editor in action.

To start your local development server and see your application, run the following command in your terminal:

npm run serve

This command will start the development server and mounts your application at `http://localhost:8080`

You can always stop the server by using the `CTRl + C` command.

That should reveal your new Froala editor within your Vue 3 Project.

Step 5 Displaying HTML

To display content created with the Froala editor use the froalaView component.

<froalaView v-model:value="content"></froalaView>

Step 6: Customizing Your Froala’s Vue WYSIWYG editor

Customizing the Froala editor is distinctively easy. The powerful Froala Editor API allows customizations by adjusting our config object. Refer to the API options, events, and methods docs to see what it offers. For instance, you can edit toolbar buttons using the toolbarButtons API option. Here is an example

<template>

  <img alt="Vue logo" src="./assets/logo.png">

  <froala id="edit" :tag="'textarea'" :config="config" v-model:value="model"></froala>

</template>

<script>

export default {

  name: 'App',

  data () {

    return {

      config: {

          toolbarButtons: {

            'moreText': {

              'buttons': [ 'italic', 'underline', 'bold', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', 'textColor', 'backgroundColor', 'inlineClass', 'inlineStyle', 'clearFormatting']

            },

            'moreParagraph': {

              'buttons': ['alignLeft', 'alignCenter', 'formatOLSimple']

            },

            'moreRich': {

              'buttons': ['insertLink', 'insertImage', 'insertVideo', 'insertTable', 'emoticons', 'fontAwesome', 'specialCharacters', 'embedly', 'insertFile', 'insertHR']

            },

            'moreMisc': {

              'buttons': ['undo', 'redo', 'fullscreen', 'print', 'getPDF', 'spellChecker', 'selectAll', 'html', 'help'],

              'align': 'right',

              'buttonsVisible': 2
            }

          },

        events: {

          initialized: function () {

            console.log('initialized')

          }

        }

      },

      model: '<i>Edit Your Content Here!</i>'

    }

  }

}

</script>

<style>

#app {

  font-family: Avenir, Helvetica, Arial, sans-serif;

  -webkit-font-smoothing: antialiased;

  -moz-osx-font-smoothing: grayscale;

  text-align: center;

  color: #2c3e50;

  margin-top: 60px;

}

</style>

Options

You can pass any existing Froala option within the config attribute. Vue SDK users will also be able to utilize a specific Froala option:

  • immediateVueModelUpdate: (default: false) This option updates the Vue model as soon as a key is released in the editor. Note that it may affect performance.

Events

As you can see in the previous example, API Events can be passed in with the options. Events are passed as an object named “events” in which you can define all the different events you want to use. Each defined event is an object where the key is the event name and the value is the callback function.

Methods

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

Custom Buttons

Furthermore, you can extend editor functionality by defining custom buttons. Froala allows us to define and add new buttons to the toolbar very conveniently and we will describe how to do this in a separate article.

Ready to build more with Froala and its Vue WYSIWYG Editor?

Froala doesn’t just provide a WYSIWYG editor but a powerful tool that enhances the user experience and makes content creation a breeze. With support for Vue, you can integrate Froala into various Vue projects ensuring a consistent user experience.

From the way you configure it, to the way you handle events or even create custom functionality, Froala’s Vue WYSIWYG Editor is remarkably simple and efficient.

Remember that an effective user interface yields better user engagement. Use Froala’s Vue WYSIWYG Editor for your content creation and enjoy the difference it makes.

Test Froala’s Vue Wysiwyg Editor

We built a Vue demo application showcasing the editor’s capabilities. You can use this as a starting point to test and understand how it works and fits your project requirements. Play with our demo and share your feedback in the comments.

 

TypeScript and Froala: The Basics

Typescript featured image

Froala Editor, renowned for its user-friendly interface and powerful features, just upped its game by introducing TypeScript support. If you’re a developer, TypeScript integration makes your life easier when working with Froala. How? Read on.

The Power of TypeScript

TypeScript, a statically typed superset of JavaScript, offers robust type-checking during development. This means errors are caught at compile-time rather than at runtime, resulting in fewer bugs and a more predictable development process. With the Froala Editor integrating TypeScript support, developers can harness these benefits when crafting rich text editing experiences.

typescript blog main image

An Illustrative Example with Froala’s tableEditButtons Option

Consider you want to initiate the Froala Editor with the tableEditButtons option. Using the newly provided TypeScript definitions, we can define our options like this:

 

export class AppComponent {
  title = 'my-app';
  public options: Partial<FroalaEditor.FroalaOptions> = {
    tableEditButtons: ['tableRows', 'tableColumns', 'tableCells', 'tableCellVerticalAlign', 'tableRemove']
  };
}

This simple code showcases two of TypeScript’s powerful features:

Autocomplete: As you start typing “tableEdit…“, your IDE will suggest available options from FroalaOptions, ensuring you pick the correct option without constantly referring to the documentation.

tableedit autocomplete

Type Checking: If you accidentally set tableEditButtons to a non-array or a boolean, TypeScript will raise a compile-time error. This immediate feedback loop is invaluable, ensuring you’re always working with valid configurations.

TypeScript error

Here’s the exact same configuration via JavaScript:

Javascript/TypeScript example

You’ll see that there’s no runtime error whatsoever. This is just a surface level explanation of the power of TypeScript with Froala.

Correct type:

TypeScript correct example

 

Going Technical: Understanding the Partial Utility Type

The use of Partial<FroalaEditor.FroalaOptions> might raise eyebrows if you’re new to TypeScript. Let’s dissect it:

Partial: A built-in TypeScript utility type, it creates a type where all properties are optional. This is immensely helpful when working with large option objects like FroalaOptions, where you might only want to specify a few settings.

FroalaEditor.FroalaOptions: This refers to the type definition provided by Froala for all available editor options. By combining it with Partial, we’re signaling that our options object will only use a subset of all available Froala options.

 

TypeScript vs JavaScript

TypeScript vs. JavaScript: Advancing with Froala

When you choose to implement a rich-text editor like Froala in your application, every decision you make can impact development velocity, bug frequency, and maintainability. One such pivotal decision is whether to use TypeScript or stick with plain JavaScript. Here’s a detailed comparison:

1. Type Safety

JavaScript: 

Being a dynamically typed language, JavaScript doesn’t allow you to define the type of a variable, leading to potential runtime errors. When working with a comprehensive library like Froala, this can cause unexpected behavior if you mistakenly assign incorrect types to editor options or misinterpret returned types.

TypeScript:

Statically Typed: At its core, TypeScript is a statically typed superset of JavaScript. This means you declare the type of variables, function parameters, and return types.

let myOption: boolean = true;

With Froala, this ensures that you’re assigning the correct types to each editor option and correctly interpreting returned values.

Compile-Time Checks: Before the code even runs, TypeScript will identify and flag type-related errors. This means if you’ve wrongly assigned a string to an option that expects a boolean, the error is caught during development rather than at runtime.

2. Autocomplete and Intellisense

JavaScript: While modern IDEs provide some level of autocomplete for JavaScript, the lack of type information can make suggestions less accurate, especially for large libraries like Froala.

TypeScript:

The enhanced type system in TypeScript allows IDEs to offer precise and context-aware autocomplete suggestions. When you’re working with Froala, as you start typing an option, the IDE will display a list of valid properties, complete with type information and even brief documentation.

This leads to faster development, less reliance on constantly referencing the official docs, and fewer mistakes.

For example, if you want to use Codox.io options you can just type “codox…” and it will show the relevant options.

codox options

3. Interface Implementation

JavaScript: Without formal interfaces, ensuring an object conforms to a specific shape or requirement in JavaScript requires manual checks and can be error-prone.

TypeScript:

Interfaces: TypeScript allows you to define interfaces, ensuring an object matches a specific structure.

 

interface FroalaCustomOption {

  theme: string;

  plugins: string[];

}

 

When using Froala, if the library offers a predefined interface for its configuration options, you can guarantee that your configuration object adheres to this structure, preventing potential errors. To learn more about TypeScript interfaces, you can check out their official guide.

4. Scalability and Maintenance

JavaScript: Larger projects can become hard to manage and maintain due to JavaScript’s dynamic nature.

TypeScript:

Offers enhanced readability and self-documenting features via its type system. In the context of Froala, as your application grows and you incorporate more features of the editor, TypeScript ensures that older integrations remain consistent and bug-free.

Refactoring becomes safer, as changes can be made with the confidence that any breaking alterations will be flagged by the compiler.

Froala, TypeScript, and Angular: Your Superpower

Angular, one of the most widely-used frameworks for building web applications, has championed TypeScript since its second version. When we intertwine the benefits of TypeScript with Froala within an Angular environment, the synergies elevate web development to new heights. Here’s why:

Native Support for TypeScript

Angular’s Foundation: Angular is built with TypeScript. This means that all of its core libraries, modules, and tooling are optimized for TypeScript. When you use Froala with TypeScript in an Angular project, you’re aligning with the natural rhythm of the framework.

Consistency: Incorporating Froala’s TypeScript features within an Angular application ensures a seamless development experience. Your Froala configurations and interactions will follow the same type patterns as the rest of your Angular components and services.

Enhanced Dependency Injection

Angular’s robust dependency injection system, combined with TypeScript’s type system, allows for more precise token retrieval. When integrating services or utilities related to Froala, TypeScript ensures you’re injecting the right dependencies.

Support for LTS version of Angular

Froala supports the latest version of Angular’s SDK. You can read more about it here.

Conclusion

TypeScript’s integration into the Froala Editor ecosystem isn’t just a flashy addition; it’s a game-changer. With powerful features like autocomplete and compile-time type checking, developers can work faster, smarter, and with greater confidence.

Are you ready to supercharge your Froala Editor experience with TypeScript? Dive in today and experience the difference!

Download Froala Editor