Skip to main content
Version: 1.0.0

Template Plugin

TemplatePlugin inserts predefined/custom templates with sanitization and category/search workflows.

Install and import

import {
TemplatePlugin,
addCustomTemplate,
getAllTemplates,
getTemplateCategories,
getTemplatesByCategory,
searchTemplates,
sanitizeTemplate,
validateTemplate,
} from "@editora/plugins";
// or subpath: "@editora/plugins/template"

Usage

const plugins = [TemplatePlugin()];

Command Matrix

ActionCommandShortcutToolbar
Open template dialoginsertTemplateNoneTemplate

Config Options

This plugin does not expose plugin-level runtime config. Template data can be extended through helper APIs.

Template helper APIs

  • getAllTemplates()
  • getTemplatesByCategory(category)
  • getTemplateCategories()
  • searchTemplates(query)
  • addCustomTemplate(template)
  • validateTemplate(template)
  • sanitizeTemplate(html)

Behavior

  • Supports category and search filtering
  • Supports insert/replace style content flows
  • Applies sanitization before insertion

Security notes

  • Sanitization is DOMPurify-based
  • Script-like content is stripped
  • Keep sanitize flow enabled for untrusted template sources

Validation checklist

  • Custom template add/search/category flows are stable
  • Inserted template remains editable
  • Undo/redo captures template insertion correctly