Skip to content

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>',
});
PropertyValue
ProseMirror nametext
TypeNode
Groupinline
ContentNone (leaf node)
Rendered in DOMAs 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.

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" } }
]
}

Text nodes belong to the inline group. They can appear inside any node whose content expression allows inline content:

NodeContent expression
Paragraphinline*
Headinginline*
Code Blocktext* (plain text only, no marks)
Details Summaryinline*

Text has no configurable options.

Text adds no commands.

Text adds no keyboard shortcuts.

@domternal/core - Text.ts