Headings feature for CKEditor 5 that provides structured heading levels (H1-H6) and paragraph formatting with configurable UI components.
npx @tessl/cli install tessl/npm-ckeditor--ckeditor5-heading@46.0.0CKEditor 5 Heading is a comprehensive headings feature plugin that provides structured heading levels (H1-H6) and paragraph formatting for CKEditor 5. It offers configurable heading options, multiple UI components (dropdown and individual buttons), and advanced document structuring capabilities with title/body separation.
npm install @ckeditor/ckeditor5-headingimport { Heading, HeadingEditing, HeadingUI } from '@ckeditor/ckeditor5-heading';For configuration types:
import type { HeadingConfig, HeadingOption } from '@ckeditor/ckeditor5-heading';For individual button components:
import { HeadingButtonsUI } from '@ckeditor/ckeditor5-heading';For document structuring:
import { Title } from '@ckeditor/ckeditor5-heading';import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic';
import { Heading } from '@ckeditor/ckeditor5-heading';
ClassicEditor.create(document.querySelector('#editor'), {
plugins: [Heading, /* other plugins */],
toolbar: ['heading', /* other tools */],
heading: {
options: [
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
{ model: 'heading1', view: 'h2', title: 'Heading 1', class: 'ck-heading_heading1' },
{ model: 'heading2', view: 'h3', title: 'Heading 2', class: 'ck-heading_heading2' },
{ model: 'heading3', view: 'h4', title: 'Heading 3', class: 'ck-heading_heading3' }
]
}
});CKEditor 5 Heading is built around several key components:
Heading combines editing and UI functionality as a single pluginHeadingEditing handles model-view conversion, commands, and Enter key behaviorHeadingUI provides dropdown interface, HeadingButtonsUI provides individual buttonsHeadingCommand manages heading application and state trackingTitle plugin enables title/body document organizationMain plugin that combines editing and UI features for heading functionality. Provides the complete heading system with configurable options.
class Heading extends Plugin {
static readonly pluginName: 'Heading';
static readonly requires: [typeof HeadingEditing, typeof HeadingUI];
static readonly isOfficialPlugin: true;
}Engine functionality for heading conversion, commands, and model-view processing. Handles the core editing behavior for headings.
class HeadingEditing extends Plugin {
static readonly pluginName: 'HeadingEditing';
static readonly requires: [typeof Paragraph];
static readonly isOfficialPlugin: true;
constructor(editor: Editor);
init(): void;
afterInit(): void;
}User interface components including dropdown selectors and individual heading buttons for toolbar integration.
class HeadingUI extends Plugin {
static readonly pluginName: 'HeadingUI';
static readonly isOfficialPlugin: true;
init(): void;
}
class HeadingButtonsUI extends Plugin {
init(): void;
}Heading command for programmatic heading application and state management.
class HeadingCommand extends Command {
readonly value: false | string;
readonly modelElements: Array<string>;
constructor(editor: Editor, modelElements: Array<string>);
refresh(): void;
execute(options: { value: string }): void;
}Advanced document structuring with title and body sections for document organization.
class Title extends Plugin {
static readonly pluginName: 'Title';
static readonly requires: ['Paragraph'];
static readonly isOfficialPlugin: true;
init(): void;
getTitle(options?: Record<string, unknown>): string;
getBody(options?: Record<string, unknown>): string;
}Flexible configuration interfaces for customizing heading options, view mappings, and styling.
interface HeadingConfig {
options?: Array<HeadingOption>;
}
type HeadingOption = HeadingElementOption | HeadingParagraphOption;
interface HeadingElementOption {
model: 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | `heading${string}`;
view: ViewElementDefinition;
title: string;
class: string;
icon?: string;
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
converterPriority?: 'low' | 'normal' | 'high';
}
interface HeadingParagraphOption {
model: 'paragraph';
title: string;
class: string;
icon?: string;
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
}
interface HeadingTitleConfig {
placeholder?: string;
}// Re-exported from other CKEditor packages
import type { Plugin } from '@ckeditor/ckeditor5-core';
import type { Command } from '@ckeditor/ckeditor5-core';
import type { Editor } from '@ckeditor/ckeditor5-core';
import type { ViewElementDefinition } from '@ckeditor/ckeditor5-engine';
import type { MatcherPattern } from '@ckeditor/ckeditor5-engine';
import type { ArrayOrItem } from '@ckeditor/ckeditor5-utils';