Advanced Integrations for an AI Content Analyzer

In the last post, we introduced our internal content analyzer. That tool is great for a high-level score, but its โ€œinput-process-outputโ€ model is just the beginning. The real opportunity is to build a more dynamic and integrated experience.

This article is for developers who saw that analyzer and thought, โ€œWhatโ€™s next?โ€ Weโ€™ll explore three practical ways to evolve a content analysis tool using the Froala editorโ€™s deeper API features.

Key Takeaways

  • Embed AI suggestions directly into the editor text using html.set().
  • Use the official Froala Filestack plugin to handle direct .docx file uploads.
  • Leverage the pluginโ€™s events to create a custom document-to-HTML workflow.
  • Use the editorโ€™s contentChanged event to create a โ€œlive lintingโ€ experience.
  • Debounce editor events to ensure optimal application performance.

Embed Feedback Directly into the Text

A common limitation of analyzer tools is the separation of feedback from the content itself. We can fix this by putting the AIโ€™s suggestions right where they belong, transforming static text into interactive annotations.

The API Implementation

After your application gets a response from the AI, it can parse the suggestions and programmatically rewrite the editorโ€™s content. By wrapping the targeted text in a custom <span> tag using html.set(), you can highlight the area and use a title attribute to show the AIโ€™s note on hover.

 

/**
 * A hypothetical function after receiving AI feedback.
 * Applies suggestions to the Froala Editor's content,
 * highlighting the original text with feedback as a tooltip.
 */
function applySuggestions(suggestions) {
  let modifiedContent = froalaEditor.html.get();

  // Your logic to find and replace text would go here
  suggestions.forEach(suggestion => {
    modifiedContent = modifiedContent.replace(
      suggestion.originalText,
      `<span class="suggestion" title="${suggestion.feedback}">${suggestion.originalText}</span>`
    );
  });

  froalaEditor.html.set(modifiedContent);
}

 

Integrate a Document Upload Workflow

Writers work in document editors. A professional tool should handle .docx files directly, not force a copy-paste workflow. Instead of building a custom uploader, we can use the official Froala Filestack plugin to handle this.

The goal is to use the plugin to upload a .docx file, but instead of inserting a link to that file, we will intercept the upload, convert the document to HTML on our backend, and then load that HTML into the editor.

The API Implementation

This approach relies on using the pluginโ€™s built-in filestack.uploadedToFilestack event. We configure the plugin with our API key and then use the event to trigger our custom conversion logic.

  • The user clicks the โ€˜Insert Fileโ€™ button, which is now powered by Filestack.
  • They upload a .docx file using the Filestack picker.
  • The filestack.uploadedToFilestack event fires, providing the URL of the uploaded file.
  • Our custom logic sends this URL to a backend service for conversion.
  • The editorโ€™s html.set() method is called to insert the final, converted HTML.

 

/**
 * Initializes the Froala Editor with the Filestack plugin,
 * configured for a custom DOCX workflow.
 */
new FroalaEditor('#editor', {
  // Ensure the 'insertFile' button is available in the toolbar.
  toolbarButtons: ['bold', 'italic', '|', 'insertFile'],

  // Basic Filestack plugin configuration.
  filestackOptions: {
    filestackAPI: 'YOUR_FILESTACK_API_KEY', // Replace with your actual Filestack API key.
    pickerOptions: {
      accept: ['.docx', '.doc'] // Only allow .docx and .doc files to be picked.
    }
  },

  events: {
    // This plugin event is crucial for our custom workflow.
    // It triggers after a file has been successfully uploaded to Filestack.
    'filestack.uploadedToFilestack': function (response) {
      // The plugin has handled the file upload; now we take over.
      const fileUrl = response.filesUploaded[0].url; // Get the URL of the uploaded file.
      const editorInstance = this; // 'this' refers to the Froala editor instance.

      // This would be your function that calls a backend service
      // to convert the document at the given URL into HTML.
      convertDocxToHtml(fileUrl).then(html => {
        // Once the HTML is received, set it as the editor's content.
        editorInstance.html.set(html);
      });

      // Return 'false' to prevent the default behavior of the Filestack plugin,
      // which would typically insert a link to the uploaded file.
      return false;
    }
  }
});

 

 

Build Real-Time Analysis with Editor Events

A manual โ€œAnalyzeโ€ button is useful, but we can provide more immediate value with real-time feedback. The goal is to create a โ€œlive lintingโ€ experience that offers suggestions as the user writes.

The Froala Events API is the foundation for this feature.

The API Implementation

You can listen for the contentChanged event to trigger actions whenever the user types. To avoid performance issues, you must โ€œdebounceโ€ this event so your analysis function only runs after the user has paused typing for a moment.

 

// Assumes you have a debounce utility function from a library like Lodash.
// This function delays the execution of 'updateRealtimeFeedback'
// until 1.5 seconds after the user stops typing or making changes.
const debouncedAnalysis = debounce(() => {
  let currentContent = froalaEditor.html.get();
  // Run your lightweight, real-time content analysis here.
  updateRealtimeFeedback(currentContent);
}, 1500); // 1.5 second delay

// Attach the debounced analysis function to the 'contentChanged' event of the editor.
froalaEditor.events.on('contentChanged', debouncedAnalysis);

 

Wrapping up the improvements

A basic content analyzer is a great start, but itโ€™s just one possibility. These examples show how a rich editor with a deep API is not just an input field but a platform for building integrated and powerful applications. By using the API to handle content manipulation, custom UI, and events, you can move beyond simple analysis and create tools that actively improve a writerโ€™s workflow.

Posted on July 9, 2025

Carl Cruz

Product Marketing Manager for Froala. With four years of experience and a background in development, they specialize in translating complex technical features into clear value for a developer-focused audience.

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *