CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tiptap--extension-link

Link extension for tiptap rich text editor providing automatic link detection, paste handling, click behavior, and XSS protection.

88

1.23x
Overview
Eval results
Files

task.mdevals/scenario-9/

Customizable Link Editor

Build a rich text editor with configurable link behavior. The editor should allow customization of how links behave when created, clicked, and pasted.

Requirements

Create a function that initializes a text editor with customizable link handling. The editor configuration should support:

  1. Automatic link detection control: Allow enabling or disabling automatic conversion of typed URLs into clickable links
  2. Click behavior configuration: Control whether links can be opened by clicking them in the editor
  3. Paste behavior configuration: Control whether pasted URLs are automatically converted to links
  4. Default link attributes: Set default HTML attributes for all created links (such as target window and security attributes)
  5. Protocol handling: Specify a default protocol to use when URLs are entered without one (e.g., "example.com" should be treated as a valid URL)

Implementation

@generates

API

interface EditorConfig {
  enableAutolink: boolean;
  enableClickOpen: boolean;
  enablePasteLink: boolean;
  defaultLinkAttributes: {
    target?: string;
    rel?: string;
    class?: string;
  };
  defaultProtocol: string;
}

/**
 * Initializes a rich text editor with configured link behavior
 * @param config - Configuration options for link behavior
 * @returns An initialized editor instance
 */
export function createEditor(config: EditorConfig): any;

Test Cases

  • Creating an editor with autolink disabled prevents automatic link detection @test
  • Creating an editor with click-to-open disabled prevents links from opening on click @test
  • Creating an editor with paste linking disabled prevents URLs from becoming links when pasted @test
  • Default link attributes are applied to all created links in the editor @test
  • The default protocol is used for URLs without a protocol @test

Dependencies { .dependencies }

@tiptap/core { .dependency }

Provides the base editor functionality for rich text editing.

@satisfied-by

@tiptap/extension-link { .dependency }

Provides link functionality with configurable behavior for the editor.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tiptap--extension-link

tile.json