PowerPaste plugin
This plugin is only available for paid TinyMCE subscriptions. |
The TinyMCE PowerPaste plugin automatically cleans up content from Microsoft Word, Microsoft Excel, and HTML sources to ensure clean, compliant content that matches the look and feel of the site.
Due to limitations in Microsoft Excel online (part of Office Live) PowerPaste does not support pasting from Microsoft Excel online. If you paste content using Microsoft Excel in Office Live you will get a plain text representation of the content. |
Usage
The PowerPaste plugin activates automatically when users paste content into the editor. For basic usage, users are not required to take any action. Simply copy and paste content normally using keyboard shortcuts, the browser’s "Paste" menu item (including from the context menu), or the TinyMCE "Paste" toolbar button.
To paste clipboard content as plain text, users can click the "Paste As Text" toolbar button or menu item, then paste the content normally. The TinyMCE PowerPaste plugin will convert the HTML on the clipboard into plain text.
If you configure PowerPaste to allow local images (see the powerpaste_allow_local_images
setting below), then images copied from Microsoft Word and other sources will appear in TinyMCE as Base64 encoded images. You can have TinyMCE automatically upload Base64 encoded images for reverting back to a standard image as described in the image upload documentation.
PowerPaste (when configured to allow local images) will import images from pasted Microsoft Word and Microsoft Excel content. When doing this, PowerPaste extracts Base64 encoded images from the clipboard. Images larger than approximately 8.5MB may fail to import based on technical limitations of web browsers. |
Cloud Installation
To enable the TinyMCE PowerPaste plugin with Tiny Cloud:
-
If you are currently using the
paste
plugin provided with TinyMCE, disable it by removing it from theplugins
list. -
Add
powerpaste
to theplugins
list.
Example TinyMCE configuration:
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'powerpaste'
});
Self-hosted Installation
To enable the TinyMCE PowerPaste plugin:
-
If you are currently using the
paste
plugin provided with TinyMCE, disable it by removing it from theplugins
list. -
Add
powerpaste
to theplugins
list in your TinyMCE configuration.
See the example TinyMCE configuration above.
Configuration Options
paste_as_text
This option controls the default state of the Paste as text menu item, which is added by the powerpaste
plugin under the Edit
menu drop-down.
The supported values are true
and false
. The default is false
.
paste_merge_formats
This option enables the merge format feature of the PowerPaste plugin. 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
paste_tab_spaces
This feature is only available for TinyMCE 5.4 and later. |
This option controls how many spaces are used to represent a tab character in HTML when pasting plain text content. By default, the Paste plugin will convert each tab character into 4 sequential space characters.
Type: Number
Default Value: 4
powerpaste_word_import
This option controls how content pasted from Microsoft Word is filtered.
Type: String
or Function
Default Value: prompt
The supported string-based values are:
-
clean
- Preserve the structure of the content such as headings, tables, and lists but remove inline styles and classes. This results in simple content that uses the site’s CSS stylesheet while retaining the semantic structure from the original document. -
merge
- Preserve the inline formatting and structure of the original document. Invalid and proprietary styles, tags and attributes are still removed ensuring that the HTML is valid while more closely matching the original document formatting. -
prompt
- Prompt the user to choose between the clean and merge options after attempting to paste HTML content.
Alternatively, this option can take an asynchronous function that returns a Promise which will resolve with the string clean
or merge
. This allows the paste mode to be dynamically set each time a user pastes relevant content. It can be used, for example, to replicate the prompt
dialog with a custom dialog.
When using the Windows operating system, copying and pasting content from Microsoft Word 2013 (or later) in "Protected View" will result in plain, unformatted text. This is due to how Protected View interacts with the clipboard. |
Example: powerpaste_word_import
using an asynchronous function
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'powerpaste',
powerpaste_word_import: function() {
// use a native confirm dialog to prompt the user to choose between clean and merge
return new Promise(function (resolve) {
if (confirm('Would you like to keep formatting?')) {
resolve('merge');
} else {
resolve('clean');
}
});
}
});
powerpaste_googledocs_import
This feature is only available for TinyMCE 5.8 and later. |
This option controls how content pasted from Google Docs is filtered.
Type: String
or Function
Default Value: prompt
The supported string-based values are:
-
clean
- Preserve the structure of the content such as headings, tables, and lists but remove inline styles and classes. This results in simple content that uses the site’s CSS stylesheet while retaining the semantic structure from the original document. -
merge
- Preserve the inline formatting and structure of the original document. Invalid and proprietary styles, tags and attributes are still removed ensuring that the HTML is valid while more closely matching the original document formatting. -
prompt
- Prompt the user to choose between the clean and merge options after attempting to paste HTML content.
Alternatively, this option can take an asynchronous function that returns a Promise which will resolve with the string clean
or merge
. This allows the paste mode to be dynamically set each time a user pastes relevant content. It can be used, for example, to replicate the prompt
dialog with a custom dialog.
Example: powerpaste_googledocs_import
using an asynchronous function
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'powerpaste',
powerpaste_googledocs_imports: function() {
// use a native confirm dialog to prompt the user to choose between clean and merge
return new Promise(function (resolve) {
if (confirm('Would you like to keep formatting?')) {
resolve('merge');
} else {
resolve('clean');
}
});
}
});
powerpaste_html_import
This option controls how content pasted from sources other than Microsoft Word and Google Docs are filtered. Note that this includes content copied from TinyMCE itself.
Type: String
Default Value: clean
The supported values are:
-
clean
- Preserve the structure of the content such as headings, tables, and lists but remove inline styles and classes. This results in simple content that uses the site’s CSS stylesheet while retaining the semantic structure from the original document. -
merge
- Preserve the inline formatting and structure of the original document. Invalid and proprietary styles, tags and attributes are still removed ensuring that the HTML is valid while more closely matching the original document formatting. -
prompt
- Prompt the user to choose between the clean and merge options after attempting to paste HTML content.
powerpaste_allow_local_images
When set to true
, Base64 encoded images using a data URI in the copied content will not be removed after pasting.
Default value: true
Possible values: true
, false
If you configure PowerPaste to allow local images, you can have TinyMCE automatically upload Base64 encoded images for conversion back to a standard image as described on the image upload documentation. |
powerpaste_block_drop
Due to browser limitations, it is not possible to filter content that is dragged and dropped into the editor. When powerpaste_block_drop
is set to true the plugin will disable drag and dropping content into the editor. This prevents the unfiltered content from being introduced. Copy and paste is still enabled.
Default value: false
Possible values: true
, false
powerpaste_clean_filtered_inline_elements
This option allows for configuration of PowerPaste’s "clean" paste filters for inline elements. These filters are run when powerpaste_word_import
or powerpaste_html_import
are set to "clean"
; or when a user clicks the "Remove formatting" button on the paste prompt dialog.
The list of inline elements that should be removed on paste can be specified by setting powerpaste_clean_filtered_inline_elements
to a comma-separated string of inline element tag names.
Possible Values: A comma-separated string.
Example: powerpaste_clean_filtered_inline_elements
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'powerpaste',
powerpaste_word_import: 'clean', // optional
powerpaste_html_import: 'clean', // optional
powerpaste_clean_filtered_inline_elements: 'strong, em, b, i, u, strike, sup, sub, font'
});
powerpaste_keep_unsupported_src
Due to browser limitations, PowerPaste is not able to support all image types supported by Microsoft Word and Microsoft Excel. When powerpaste_keep_unsupported_src
is set to true
, PowerPaste will store the original src
of unsupported images in a data-image-src
attribute on the pasted image element. This enables developers to add further image support via post-processing.
For example, browsers do not allow PowerPaste to access the file system. If your application has access to the file system, setting powerpaste_keep_unsupported_src
to true
may allow you to replace unsupported images during post-processing using the original file paths.
Default Value: false
Possible Values: true
, false
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
image_file_types
This option configures which image file formats will be recognized and placed in an img
element by the smart_paste
functionality when content is pasted into the editor.
Type: String
Default Value: 'jpeg,jpg,jpe,jfi,jfif,png,gif,bmp,webp'
Possible Values: A list of valid web image file extensions. For a list of possible values see: MDN Web Docs - Image file type and format guide.