Link extension for tiptap rich text editor providing automatic link detection, paste handling, click behavior, and XSS protection.
88
Build a custom Tiptap editor command that programmatically inserts formatted links at specific positions while preventing automatic link detection from interfering with your transaction.
Your solution should create a custom command called insertFormattedLink that:
text (string), url (string), position (number)The command must handle:
@generates
Given an empty editor, insertFormattedLink("Click here", "https://example.com", 0) inserts "Click here" as a link at position 0, and the autolink plugin does not modify the transaction @test
Given an editor with existing text "Hello world", insertFormattedLink("test link", "https://test.com", 6) inserts "test link" as a link at position 6 (after "Hello "), resulting in "Hello test linkworld" with "test link" being a clickable link @test
Given an editor, calling insertFormattedLink("link", "https://example.com", 9999) with an out-of-bounds position returns false and does not modify the document @test
import { Editor } from '@tiptap/core';
/**
* Inserts formatted text as a link at a specific position while preventing
* automatic link detection from interfering.
*
* @param editor - The Tiptap editor instance
* @param text - The text to insert
* @param url - The URL for the link
* @param position - The position in the document to insert at
* @returns true if successful, false otherwise
*/
export function insertFormattedLink(
editor: Editor,
text: string,
url: string,
position: number
): boolean;Provides the core Tiptap editor functionality and transaction system.
Provides link mark functionality and automatic link detection that must be coordinated with.
Install with Tessl CLI
npx tessl i tessl/npm-tiptap--extension-linkdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10