Paste Handler

Available in Team plan

The PasteHandler extension intelligently transforms pasted HTML to ensure compatibility with content from external sources. It runs a series of transformations on pasted content to clean up source-specific formatting artifacts while preserving user intent.

Supported sources

SourcemacOS DesktopWindows DesktopWeb (Browser)
Microsoft Excel✓ (SharePoint)
Microsoft Word✓ (SharePoint)
Microsoft Outlook✓ (Outlook Web)
Google Docs
Google Sheets

Install

npm install @tiptap-pro/extension-paste-handler

Usage

The extension requires no configuration. Just add it to your editor and it works automatically.

import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'
import PasteHandler from '@tiptap-pro/extension-paste-handler'

const editor = new Editor({
  extensions: [
    StarterKit,
    PasteHandler,
  ],
})

What it handles

The extension applies a series of transformations to pasted HTML, executed in a specific order:

TransformationDescription
CSS class resolutionResolves class-based CSS formatting (e.g. from Excel) to inline styles
Office markup cleanupRemoves Microsoft Office-specific elements and properties like <o:p> tags and mso-* styles
Bookmark removalStrips Word bookmark markers and empty bookmark anchors
Table cell text stylesEnsures text formatting in table cells is properly recognized by the editor
Background color conversionConverts background-color styles to highlight marks for the Highlight extension
ARIA heading conversionTransforms ARIA heading elements (from SharePoint Word) to semantic HTML headings
Horizontal rule detectionDetects text-based horizontal rules (e.g. from Google Docs) and converts them to <hr> elements
Soft line break mergingMerges consecutive zero-margin paragraphs (from Google Docs) into proper line breaks
Nested list reconstructionRebuilds flat list structures (from SharePoint) into properly nested lists
Ordered list normalizationRemoves inline list-style-type to let your editor's CSS control list styling
Orphan break cleanupRemoves stray <br> tags between block elements that cause unwanted spacing

Error handling

If any transformation fails, the extension gracefully falls back to the original pasted HTML to ensure paste functionality is never broken.