Text
The Text node holds the actual character content in the editor. Every visible string you see is a Text node inside a block node like Paragraph or Heading. Text nodes carry marks (bold, italic, link, etc.), which is how inline formatting works.
Text is included in StarterKit. If you are building a custom setup without StarterKit, add it manually:
import { Editor, Document, Text, Paragraph } from '@domternal/core';
const editor = new Editor({ element: document.getElementById('editor')!, extensions: [Document, Text, Paragraph], content: '<p>Hello world</p>',});import { Component, signal } from '@angular/core';import { DomternalEditorComponent } from '@domternal/angular';import { Editor, Document, Text, Paragraph } from '@domternal/core';
@Component({ selector: 'app-editor', imports: [DomternalEditorComponent], template: ` <domternal-editor [extensions]="extensions" [content]="content" (editorCreated)="editor.set($event)" /> `,})export class EditorComponent { editor = signal<Editor | null>(null); extensions = [Document, Text, Paragraph]; content = '<p>Hello world</p>';}import { Domternal } from '@domternal/react';import { Document, Text, Paragraph } from '@domternal/core';
export default function Editor() { return ( <Domternal extensions={[Document, Text, Paragraph]} content="<p>Hello world</p>" > <Domternal.Content /> </Domternal> );}Text is a leaf node with no commands of its own. You interact with text content through the editor’s content methods:
// Insert text at the cursoreditor.commands.insertContent('Hello');
// Get all text contentconst text = editor.state.doc.textContent;
// Get text between positionsconst slice = editor.state.doc.textBetween(0, 10);Schema
Section titled “Schema”| Property | Value |
|---|---|
| ProseMirror name | text |
| Type | Node |
| Group | inline |
| Content | None (leaf node) |
| Rendered in DOM | As plain text (no wrapper element) |
Text nodes are leaf nodes: they contain characters but no child nodes. ProseMirror renders them directly as DOM text nodes without any wrapping HTML element.
How text and marks work together
Section titled “How text and marks work together”Text nodes carry marks. When you apply bold to a word, ProseMirror splits the text into separate Text nodes, each with its own set of marks:
<p>Hello <strong>world</strong></p>In the document model, this is two text nodes inside one paragraph:
{ "type": "paragraph", "content": [ { "type": "text", "text": "Hello " }, { "type": "text", "text": "world", "marks": [{ "type": "bold" }] } ]}Multiple marks can stack on the same text node:
{ "type": "text", "text": "important", "marks": [ { "type": "bold" }, { "type": "italic" }, { "type": "link", "attrs": { "href": "https://example.com" } } ]}Where text nodes can appear
Section titled “Where text nodes can appear”Text nodes belong to the inline group. They can appear inside any node whose content expression allows inline content:
| Node | Content expression |
|---|---|
| Paragraph | inline* |
| Heading | inline* |
| Code Block | text* (plain text only, no marks) |
| Details Summary | inline* |
Options
Section titled “Options”Text has no configurable options.
Commands
Section titled “Commands”Text adds no commands.
Keyboard shortcuts
Section titled “Keyboard shortcuts”Text adds no keyboard shortcuts.
Source
Section titled “Source”@domternal/core - Text.ts