<!-- Froala 5.5.0 — Headless mode demo (paste into the JSFiddle HTML pane) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/froala-editor@5.5.0/css/froala_editor.pkgd.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/froala-editor@5.5.0/css/froala_style.min.css">
<main class="demo">
<header class="demo-head">
<h1>Froala headless mode</h1>
<p>Froala runs with <code>headless: true</code>: no built-in toolbar, popups or styling.
Everything below is <strong>our own UI</strong>, calling the editor's API.</p>
</header>
<!-- Our custom toolbar is built from JavaScript into this element -->
<div id="my-toolbar" class="my-toolbar" aria-label="Custom editor toolbar"></div>
<!-- The editor itself: just an editable area -->
<div id="editor">
<h2>Welcome to a headless editor</h2>
<p>Select some text, then use the custom buttons above. This editor has
<em>no toolbar of its own</em>. Every button is plain HTML that calls a Froala API method.</p>
<ul><li>Lists work</li><li>Undo and redo work</li></ul>
<table style="width:100%"><tbody>
<tr><td>Cell A1</td><td>Cell B1</td></tr>
<tr><td>Cell A2</td><td>Cell B2</td></tr>
</tbody></table>
<p>Last paragraph.</p>
</div>
<section class="panel">
<h3>Live HTML output</h3>
<pre id="output" class="output"></pre>
</section>
</main>
<script src="https://cdn.jsdelivr.net/npm/froala-editor@5.5.0/js/froala_editor.pkgd.min.js"></script>
// Froala 5.5.0 — headless mode demo.
// The editor runs with no built-in UI. The toolbar below is our own HTML,
// and every button simply calls a Froala API method.
const outputEl = document.getElementById('output');
function showHTML(ed) {
outputEl.textContent = ed.html.get();
}
// Ask the user for a URL. Returns the trimmed URL, or null if they cancel.
// (A browser prompt keeps this demo short. In your app, use your own input or dialog.)
function askForURL(message, example) {
const url = window.prompt(message, example);
return url && url.trim() ? url.trim() : null;
}
// ---------------------------------------------------------------------------
// 1. Create the editor in headless mode
// ---------------------------------------------------------------------------
const editor = new FroalaEditor('#editor', {
// key: 'YOUR_LICENSE_KEY', // add your license key here if you have one
headless: true, // no toolbar, popups or default styling
htmlExecuteScripts: false, // treat pasted scripts as plain content
placeholderText: 'Start typing…',
events: {
initialized: function () {
showHTML(this);
buildToolbar(this);
},
contentChanged: function () {
showHTML(this);
},
// Images and videos land asynchronously, so record the undo step once they arrive.
'image.inserted': function () { this.undo.saveStep(); },
'video.inserted': function () { this.undo.saveStep(); },
// Froala's own error popups are off in headless mode, so report errors yourself.
'image.error': function () { window.alert('That image could not be loaded.'); },
'video.linkError': function () { window.alert('That link is not a supported YouTube or Vimeo URL.'); }
}
});
// ---------------------------------------------------------------------------
// 2. Our own buttons. Each one calls a Froala API method.
// inline: tag to check with format.is() for the pressed...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.