@editora/template
v1.0.3
Published
Template plugin for Rich Text Editor - Insert predefined document templates
Readme
@editora/template
[!IMPORTANT] Live Website: https://editora-ecosystem.netlify.app/
Storybook: https://editora-ecosystem-storybook.netlify.app/
Template plugin for Editora rich text editor.
What It Does
- Opens a template picker dialog from the toolbar.
- Supports category and search filtering.
- Supports insert mode and replace mode.
- Sanitizes template HTML with
dompurifybefore insertion. - Records DOM transactions for undo/redo integration.
Installation
npm install @editora/templateIf you are installing plugins as a bundle:
npm install @editora/pluginsUsage
import { TemplatePlugin } from "@editora/template";
const plugins = [TemplatePlugin()];Exports
TemplatePlugin()PREDEFINED_TEMPLATESaddCustomTemplate(template)getAllTemplates()getTemplatesByCategory(category)getTemplateCategories()searchTemplates(query)sanitizeTemplate(html)validateTemplate(template)Templatetype
Add Custom Templates
import { addCustomTemplate, type Template } from "@editora/template";
const invoiceTemplate: Template = {
id: "invoice-basic",
name: "Invoice",
category: "Business",
description: "Basic invoice document",
html: "<h2>Invoice</h2><p>Bill To: {{ customer_name }}</p>",
};
addCustomTemplate(invoiceTemplate);Toolbar Command
- Command:
insertTemplate - Toolbar label:
Template
Notes
- HTML is sanitized before insertion.
- Script tags and unsafe attributes are stripped.
- Template insertion works in both React wrapper and web component editors.
