Find answers to common questions about Light HTML Editor, how it works, and how it can benefit your project.
Your questions about Light HTML Editor, answered
Light HTML Editor is a lightweight, embeddable WYSIWYG (What You See Is What You Get) editor designed specifically for editing existing HTML pages. You can drop it into any container on your web page, and it allows users to edit text and styles directly within the context of the live page. When a user makes a change, you get the modified HTML back, ready to be saved or processed by your application.
Key takeaway: It edits existing HTML, not build pages from scratch. It's perfect for content management and inline editing.
Light HTML Editor is designed for developers and platforms that need to provide a visual editing experience for their users. It's an ideal fit for:
It is not a tool for building pages from scratch with drag-and-drop blocks (for that, consider GrapesJS) or for rich document editing like Google Docs (for that, consider TipTap or ProseMirror).
"Lightweight" refers to both its size and its dependencies:
This makes it incredibly easy to integrate into any project, regardless of its size or complexity.
Getting started is simple. There are two primary ways to include the editor in your project:
Just add this script tag to your HTML file. This method requires no build step.
<script src="https://cdn.jsdelivr.net/npm/light-html-editor/dist/light-html-editor.umd.js"></script>
If you're using a module bundler like Vite, Webpack, or Rollup, install it as a dependency:
npm install light-html-editor
Then, import it into your JavaScript/TypeScript file:
import { Editor } from 'light-html-editor'
Once included, you can initialize the editor with just a few lines of code.
Here is a complete, minimal example of how to set up the editor:
<!-- 1. Create a container for the editor -->
<div id="editor" style="height: 600px;"></div>
<!-- 2. Initialize the editor -->
<script type="module">
import { Editor } from 'light-html-editor'
const editor = Editor.create('#editor', {
html: `<!DOCTYPE html>
<html><body>
<h1>Hello world</h1>
<p>Edit me!</p>
</body></html>`,
onChange(html) {
// This function is called every time the user makes a change
console.log('Updated HTML:', html)
},
})
</script>
The editor will automatically fill the container you provide, so be sure to set its width and height in CSS to control the layout.
The editor provides two main ways for you to get the updated HTML content:
This is the most common method. You provide a function to the `onChange` option when you create the editor. This function is called (debounced by default) every time the content changes.
Editor.create('#editor', {
html: '...',
onChange(html) {
// Send the HTML to your server or update your application state
saveToServer(html)
},
})
You can get the current HTML at any time by calling the `getHtml()` method on the editor instance. This is useful for things like saving on a button click.
const editor = Editor.create('#editor', { ... })
// Later, for example, on a save button click:
const saveButton = document.getElementById('save-button')
saveButton.addEventListener('click', () => {
const currentHtml = editor.getHtml()
console.log('Saving this HTML:', currentHtml)
})
Light HTML Editor comes with a rich set of built-in tools for both text and style editing.
The style panel provides comprehensive CSS controls, organized into tabs:
Users can click on any element on the page to see and modify its styles in this panel.
The plugin system is a powerful feature that allows you to extend the editor's functionality with custom tools. A plugin is a simple JavaScript object with a name and an install function. The install function is called once when the editor is created, giving you access to the editor instance to add new buttons, sections, or logic.
Here's an example of a simple plugin that adds heading buttons:
const headingPlugin = {
name: 'headings',
install(editor) {
// Add buttons to the toolbar
for (const [tag, label] of [['H1','H1'], ['H2','H2'], ['H3','H3']]) {
editor.toolbar.addButton({
id: `heading-${tag}`,
label,
title: `Wrap in <${tag}>`,
onClick() {
// Use the browser's built-in command to format selection
document.execCommand('formatBlock', false, tag)
},
})
}
},
}
// Use the plugin when creating the editor
Editor.create('#editor', {
html: myHtml,
plugins: [headingPlugin],
})
This allows you to tailor the editor to your specific needs, adding anything from custom content blocks to specialized formatting tools.
Yes, you have full programmatic control over both the toolbar and the style panel.
You can add or remove buttons from the toolbar at any time using the editor instance:
// Add a custom button
editor.toolbar.addButton({
id: 'my-custom-btn',
label: 'Special',
title: 'Do something special',
onClick(editor) {
alert('Special button clicked!')
},
})
// Remove a button later
editor.toolbar.removeButton('my-custom-btn')
You can also add your own custom sections to the style panel, allowing you to build completely custom UIs for controlling your elements:
// Add a custom section to the style panel
editor.stylePanel.addSection({
id: 'my-controls',
title: 'My Custom Controls',
render(editor) {
// Create your custom HTML for the controls
const div = document.createElement('div')
div.innerHTML = '<label>My Setting:</input type="checkbox"></label>'
return div
},
onSelect(el, sectionEl) {
// This is called when a user clicks an element in the canvas
// You can update your custom controls here
const myCheckbox = sectionEl.querySelector('input')
myCheckbox.checked = el.getAttribute('data-my-setting') === 'true'
},
})
// Remove a section later
editor.stylePanel.removeSection('my-controls')
Light HTML Editor is offered with a simple, transparent pricing model to suit different needs:
Perfect for personal projects, small websites, and getting started.
Designed for growing businesses and professional applications.
For detailed pricing and to choose a plan, please visit our Pricing Page.
Yes! We offer a 14-day free trial for the Pro plan. No credit card is required to start the trial. You'll have full access to all Pro features during the trial period, allowing you to test the editor with your specific use case and ensure it meets your needs before committing to a subscription.
You can start your free trial directly from your account dashboard after signing up.
Data security and privacy are our top priorities. We handle your data with the utmost care:
Please refer to our Privacy Policy for a detailed overview of how we collect, use, and protect your information.
You retain full ownership of all content you create, upload, or edit using Light HTML Editor. We do not claim any ownership or rights to your data. The editor is simply a tool to help you build and manage your own content. Our service only processes and stores your data as necessary to provide the editing functionality, and you can export or delete your data at any time.
We offer different levels of support depending on your plan:
We have a dedicated documentation site that covers everything you need to know. You can find it at docs.light-html-editor.apposters.com.
The documentation includes:
Our documentation is constantly updated to reflect new features and improvements.
We encourage feedback from our users! The best way to report a bug or request a new feature is to use our feedback form, which you can find in your account dashboard or at light-html-editor.apposters.com/feedback.
When reporting a bug, please provide as much detail as possible, including:
For feature requests, tell us what you're trying to achieve, and we'll consider it for future versions of the product.