Headless rich text editor built on ProseMirror with extensible architecture for building custom editors
94
Build a document import system that safely processes external documents by validating their structure and handling potential errors gracefully.
Create a system that:
Your system should provide:
createValidatedEditor(element, options) that initializes an editor with validation enabledimportDocument(editor, content, format) that safely imports content with validation
format can be "html" or "json"{ success: boolean, error?: string }<p>Hello <strong>world</strong></p>{ success: true }@test
{ "type": "doc", "content": [{ "type": "paragraph", "content": [{ "type": "text", "text": "Test" }] }] }{ success: true }@test
<p>Text <unknowntag>invalid</unknowntag></p>{ success: false, error: "..." }@test
{ success: false, error: "..." }@test
@generates
import { Editor } from '@tiptap/core';
/**
* Creates an editor instance with content validation enabled.
* Configures the editor to emit errors instead of throwing exceptions.
*/
export function createValidatedEditor(
element: HTMLElement | null,
options?: { onError?: (error: Error) => void }
): Editor;
/**
* Safely imports a document into the editor with validation.
* Returns success status and error message if validation fails.
*/
export function importDocument(
editor: Editor,
content: string,
format: 'html' | 'json'
): { success: boolean; error?: string };Provides the rich text editor framework with content validation capabilities.
Provides basic extensions for text editing (Document, Paragraph, Text, Bold, Italic).
Install with Tessl CLI
npx tessl i tessl/npm-tiptap--coredocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10