The Tiptap Clean Paste Extension is a plugin for Tiptap that provides a clean paste functionality for your editor. It allows you to strip unwanted content from pasted text, such as formatting, styles, or non-printable characters.
You can install the Tiptap Clean Paste Extension via npm:
npm install tiptap-clean-paste
To use the tiptap-clean-paste Extension in your Tiptap editor, import it and add it to your extensions list:
import { CleanPaste } from "tiptap-clean-paste";
// or
import CleanPaste from "tiptap-clean-paste";
// Using the default regex pattern
const extensions = [CleanPaste];
// Or define your custom regex pattern
const customRegex = /[^\x20-\x7E\s]/g;
const extensions = [
CleanPaste.configure({
regexPattern: customRegex, // customize the regex pattern used for cleaning pasted text
}),
];
const TiptapEditor = () => {
const editor = useEditor({
extensions,
content: "<p>Hello World!</p>",
});
};