Skip to main content
Version: Next

Code Sample Plugin

Immutable code blocks with language metadata and dialog-based editing.

Installation and Import

import { CodeSamplePlugin } from "@editora/plugins";
// or: import { CodeSamplePlugin } from "@editora/plugins/code-sample";

Usage

const plugins = [CodeSamplePlugin()];

Command Matrix

ActionCommandShortcutToolbar
Insert code blockinsertCodeBlockMod-Shift-CInsert Code

Config Options

This plugin does not expose plugin-level runtime config. Syntax highlighting is optional via host-provided Prism integration.

Behavior

  • Inserts code blocks with language metadata (data-lang)
  • Supports edit/update workflow through a code dialog
  • Supports copy action for code block contents
  • Preserves whitespace and line structure

Validation Checklist

  • Insert/edit cycles preserve exact code text
  • Language metadata updates on edit
  • Copy action works for long snippets
  • Undo/redo restores code block changes