Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

74
Views
Get current selection info from Froala editor

I am using Froala WYSIWYG editor in my project. I would like to create my own font-family select component which will display the current font-family. So I need to listen to changes of an editor's selection, each time get current font-family and update my custom component.

import "froala-editor/js/plugins/font_family.min.js";
import Froala from "froala-editor";

const editor = new Froala("#container", {
    events: {
        onSelectionChange: function() { // I need something like this.
            console.log(this.selection.get().fontFamily); // Eg. "Arial" or "Verdana". 
        }
    }
});

I only found fontFamilySelection option in the docs, however, it will show the current font family in a native editor's component. One way is to read the current font family from the native component, but it's not a very clean solution.

Is there any way to do something like this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try these three additional event hooks

input - on user input

click - after clicking somewhere in the editor, perhaps into a different tag and font

commands.after - after any menu command, like the native font picker

These hooks allow you to query the font-family style on the current tag.

const editor = new Froala("#container", {
    events: {
        onSelectionChange: function() { // I need something like this.
            console.log(this.selection.get().fontFamily); // Eg. "Arial" or "Verdana". 
        },
        'input': function (inputEvent) {
            // after a user input
            console.log(this.selection.element().style.fontFamily);
        },'click': function (clickEvent) {
            // after a user click
            console.log(this.selection.element().style.fontFamily);
        },
        'commands.after': function (cmd, param1, param2) {
            // after a command, e.g. the user used the inbuilt font chooser
            console.log(this.selection.element().style.fontFamily);
        }
    }
});

Others might be useful too, from the list at https://froala.com/wysiwyg-editor/docs/events/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!