Read the document
Read content in multiple formats. Chunked reads help with large documents.
getText 
Return the entire document as plain text.
Returns
string: The entire document as plain text
Example
// Read the whole document as text
const text = toolkit.getText()getHtml 
Return the entire document as HTML.
Returns
string: The entire document as HTML
Example
// Read the whole document as HTML
const html = toolkit.getHtml()getJson 
Return the entire document as Tiptap JSON.
Returns
any: The entire document as Tiptap JSON
Example
// Read the whole document as Tiptap JSON
const json = toolkit.getJson()getTextSelection 
Return the current selection as text.
Returns
string: The selected text content as a plain string
Example
// Read the selected text
const selection = toolkit.getTextSelection()getHtmlSelection 
Return the current selection as HTML.
Returns
string: The selected HTML content
Example
// Read the selected HTML content
const selection = toolkit.getHtmlSelection()getJsonSelection 
Return the current selection as Tiptap JSON.
Returns
any: The selected Tiptap JSON content
Example
// Read the selected Tiptap JSON content
const selection = toolkit.getJsonSelection()getTextRange 
Return text content from a specific range.
Parameters
range(Range): The range to get content fromfrom(number): Start positionto(number): End position
options?(GetTextRangeOptions): Options for thegetTextRangemethoddoc?(Node): Optional document node to use instead of the current editor document
Returns
string: The text content as a plain string
Example
// Read a text slice
const snippet = toolkit.getTextRange({ from: 0, to: 100 })getHtmlRange 
Return HTML content from a specific range.
Parameters
range(Range): The range to get content fromfrom(number): Start positionto(number): End position
options?(GetHtmlRangeOptions): Options for thegetHtmlRangemethoddoc?(Node): Optional document node to use instead of the current editor document
Returns
string: The HTML content as a string
Example
// Read the HTML of the content from position 0 to 100
const snippet = toolkit.getHtmlRange({ from: 0, to: 100 })getJsonRange 
Return Tiptap JSON content from a specific range.
Parameters
range(Range): The range to get content fromfrom(number): Start positionto(number): End position
options?(GetJsonRangeOptions): Options for thegetJsonRangemethoddoc?(Node): Optional document node to use instead of the current editor document
Returns
any: The Tiptap JSON content
Example
// Read a Tiptap JSON slice
const snippet = toolkit.getJsonRange({ from: 0, to: 100 })getTextChunks 
Split the document into text chunks for large-content processing.
Parameters
options?(GetTextChunksOptions): Options for thegetTextChunksmethodchunkSize?(number): Max characters per chunk. Defaults to 32,000 characters (8000 tokens * 4 characters per token)
Returns
TextChunk[]: Array of text chunks, where each chunk contains:
content(string): The text content of the chunkrange(Range): The range in the document where the chunk starts and endsfrom(number): Start position in the documentto(number): End position in the document
nodeRange(NodeRange): The node range where the chunk starts and endsfrom(number): Start node position in the documentto(number): End node position in the document
Example
// Split the document into chunks of the default size
const chunks = toolkit.getTextChunks()
// Split the document into chunks of 1000 characters maximum
const smallerChunks = toolkit.getTextChunks({ chunkSize: 1000 })getHtmlChunks 
Split the document into HTML chunks for large-content processing.
Parameters
options?(GetHtmlChunksOptions): Options for thegetHtmlChunksmethodchunkSize?(number): Max characters per chunk. Defaults to 32,000 characters (8000 tokens * 4 characters per token)
Returns
HtmlChunk[]: Array of HTML chunks, where each chunk contains:
content(string): The HTML content of the chunkrange(Range): The range in the document where the chunk starts and endsfrom(number): Start position in the documentto(number): End position in the document
nodeRange(NodeRange): The node range where the chunk starts and endsfrom(number): Start node position in the documentto(number): End node position in the document
Example
// Split the document into chunks of the default size
const chunks = toolkit.getHtmlChunks()
// Split the document into chunks of 1000 characters maximum
const smallerChunks = toolkit.getHtmlChunks({ chunkSize: 1000 })getJsonChunks 
Split the document into Tiptap JSON chunks for large-content processing.
Parameters
options?(GetJsonChunksOptions): Options for thegetJsonChunksmethodchunkSize?(number): Max characters per chunk. Defaults to 32,000 characters (8000 tokens * 4 characters per token)
Returns
JsonChunk[]: Array of Tiptap JSON chunks, where each chunk contains:
content(any): The Tiptap JSON content of the chunk. It is the JSON of a Fragment of the document.range(Range): The range in the document where the chunk starts and endsfrom(number): Start position in the documentto(number): End position in the document
nodeRange(NodeRange): The node range where the chunk starts and endsfrom(number): Start node position in the documentto(number): End node position in the document
Example
// Split the document into chunks of the default size
const chunks = toolkit.getJsonChunks()
// Split the document into chunks of 1000 characters maximum
const smallerChunks = toolkit.getJsonChunks({ chunkSize: 1000 })