paste-plaintext.md 3.3 KB


menu-title: Paste plain text category: features-pasting

order: 30

{@snippet features/build-paste-source}

Pasting plain text

The plain text pasting feature is implemented by the {@link module:clipboard/clipboard~PastePlainText} plugin which is a part of the {@link module:clipboard/clipboard~Clipboard} plugin.

It detects the Ctrl/Cmd + Shift + V keystroke during the paste and causes the pasted text to inherit the styles of the content it was pasted into. In this sense, the feature can also be described as "pasting without formatting" — the source formatting of the pasted text gets replaced with the target formatting of the text it was pasted into.

Pasting plain text with a double line break will turn the break into a paragraph. A single line break will instead be turned into a soft break upon pasting.

Demo

Paste plain text between the styled paragraphs below using the Ctrl/Cmd + Shift + V to test the style inheritance. Paste without the Shift modifier to retain unstyled text. You can copy this very paragraph or one from the demo for convenience.

{@snippet features/paste-plain-text}

Related features

CKEditor 5 supports a wider range of paste features, including:

  • {@link features/paste-from-word Paste from Word} – Paste content from Microsoft Word and maintain the original structure and formatting.
  • {@link features/paste-from-google-docs Paste from Google Docs} – Paste content from Google Docs, maintaining the original formatting and structure.
  • {@link features/html-embed Raw HTML embedding} – Embed an HTML snippet in the editor. For advanced users

Installation

This feature is required by the Clipboard plugin and is enabled by default in all official builds. The installation instructions are for developers interested in building their own custom rich-text editor.

To add this feature to your rich-text editor, install the @ckeditor/ckeditor5-clipboard package:

npm install --save @ckeditor/ckeditor5-clipboard

Then add the {@link module:clipboard/clipboard~Clipboard Clipboard} plugin to your plugin list:

import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';

ClassicEditor
	.create( document.querySelector( '#editor' ), {
		plugins: [ Clipboard, Bold, ... ]
	} )
	.then( ... )
	.catch( ... );

{@link module:clipboard/clipboard~PastePlainText PastePlainText} plugin will activate along with the Clipboard plugin.

Support for other applications

You can find more information regarding compatibility with other applications in this ticket.

If you think that support for any of the applications needs improvements, please add 👍 and comments in the following issues:

Feel free to open a new feature request for other similar applications, too!