Copy & paste options

TinyMCE PowerPaste plugin

TinyMCE has built-in paste functionality, however PowerPaste is a premium plugin that provides improved paste support, including support for Microsoft Word, Microsoft Excel and Google Docs content. It also includes the option to clean or merge the styles when pasting content into the editor.

For information, see the PowerPaste plugin.

The core paste functionality and PowerPaste share many options, although some have minor differences. The following options apply specifically to the core paste functionality. For example, the paste_block_drop, paste_data_images, paste_remove_styles_if_webkit, and paste_webkit_styles options are specific to the core functionality and do not apply to the PowerPaste plugin.

Controlling how content is pasted

These options affect the way HTML content is processed when pasted in to the editor.

paste_as_text

This option enables you to set the default state of the Paste as text menu item under the Edit menu dropdown. It’s disabled by default.

Type: Boolean

Default value: false

Possible values: true, false

Example: Using paste_as_text

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_as_text: true
});

paste_block_drop

Due to browser limitations, it is not possible to filter content that is dragged and dropped into the editor. When paste_block_drop is set to true dragging and dropping content into the editor will be disabled. This prevents the unfiltered content from being introduced. Copy and paste is still enabled.

Type: Boolean

Default value: false

Possible values: true, false

Example: Using paste_block_drop

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  paste_block_drop: false
});

paste_merge_formats

This option enables the merge format feature when pasting content. This merges identical text format elements to reduce the number of HTML elements produced. For example: <b>abc <b>bold</b> 123</b> becomes <b>abc bold 123</b> since the inner format is redundant. This option is enabled by default but can be disabled if retaining nested or identical format elements is important.

Type: Boolean

Default value: true

Possible values: true, false

Example: Using paste_merge_formats

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_merge_formats: false
});

paste_tab_spaces

This option controls how many spaces are used to represent a tab character in HTML when pasting plain text content. By default, when tab characters are pasted they will be converted into 4 sequential space characters.

Type: Number

Default value: 4

Example: Using paste_tab_spaces

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_tab_spaces: 2
});

smart_paste

The smart_paste function will:

  • Detect text that resembles a URL and change the text to a hyperlink.

  • Detect text that resembles the URL for an image and will try to replace the text with the image.

To disable the smart_paste functionality, set smart_paste to false. To configure which image file types are recognised, see Image & file options - images_file_types.

Type: Boolean

Default value: true

Possible values: true, false

Example: Using smart_paste

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  smart_paste: false
});

Filtering pasted content

These options control how the HTML content is filtered such that the content is eliminated or preserved when pasted into the editor.

paste_data_images

This option specifies whether data:url images (inline images) should be removed or not from the pasted contents.

Setting paste_data_images to true will allow the pasted images, while setting it to false will disallow pasted images.

Type: Boolean

Default value: true

Possible values: true, false

Example: Using paste_data_images

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_data_images: false
});

paste_preprocess

This option enables you to modify the pasted content before it gets inserted into the editor.

Type: Function

Example: Using paste_preprocess

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_preprocess: (editor, args) => {
    console.log(args.content);
    args.content += ' preprocess';
  }
});

paste_postprocess

This option enables you to modify the pasted content before it gets inserted into the editor, but after it’s been parsed into a DOM structure.

Type: Function

Example: Using paste_postprocess

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_postprocess: (editor, args) => {
    console.log(args.node);
    args.node.setAttribute('id', '42');
  }
});

paste_remove_styles_if_webkit

This option allows you to disable TinyMCE’s default paste filters for webkit styles.

Type: Boolean

Default value: true

Possible values: true, false

Example: Using paste_remove_styles_if_webkit

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_remove_styles_if_webkit: false
});

paste_webkit_styles

This option allows you to specify styles you want to keep when pasting in WebKit. WebKit has a quirk where it will take all the computed CSS properties for an element and add them to spans within the editor. Since most users don’t want random spans added all over their document, we need to manually clean that up until the bug is fixed. This option defaults to 'none' but can be set to 'all' or a specific list of styles to retain.

Type: String

Default value: 'none'

Possible values: 'none', 'all' or a space separated list of styles

Example: Using paste_webkit_styles

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  toolbar: 'paste',
  paste_webkit_styles: 'color font-size'
});