# Plugin: paste

This plugin adds paste as plain text and paste from Word icons to TinyMCE. This plugin was developed by Ryan Demmer and modified by the TinyMCE crew to be more general and some extra features where added.

On 25 May 2005, this plugin was modified by speednet: IE now pastes directly into the editor, bypassing the extra steps of opening the Insert box, selecting options, and clicking Insert. Speednet also added the Select All command, which highlights all the content in the editor when the user clicks the toolbar button (Other miscellaneous cleanup also).

On 28 October 2005, this plugin was modified by monkeybrain: Added the paste_strip_class_attributes option.

### Installation Instructions

- Copy the paste directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins).
- Add plugin to TinyMCE plugin option list example: plugins : "paste".
- Add the button names to button list, example: theme_advanced_buttons3_add : "pastetext,pasteword,selectall".

### Initialization Example

    tinyMCE.init({
    	theme : "advanced",
    	mode : "textareas",
    	plugins : "paste",
    	theme_advanced_buttons3_add : "pastetext,pasteword,selectall",
    	paste_create_paragraphs : false,
    	paste_create_linebreaks : false,
    	paste_use_dialog : true,
    	paste_auto_cleanup_on_paste : true,
    	paste_convert_middot_lists : false,
    	paste_unindented_list_class : "unindentedList",
    	paste_convert_headers_to_strong : true,
    	paste_insert_word_content_callback : "convertWord"
    });

    function convertWord(type, content) {
    	switch (type) {
    		// Gets executed before the built in logic performes it's cleanups
    		case "before":
    			content = content.toLowerCase(); // Some dummy logic
    			break;

    		// Gets executed after the built in logic performes it's cleanups
    		case "after":
    			content = content.toLowerCase(); // Some dummy logic
    			break;
    	}

    	return content;
    }

### Options

[paste_create_paragraphs] | If enabled double linefeeds are converted to paragraph elements when using the plain text dialog. This is enabled by default.
[paste_create_linebreaks] | If enabled single linefeeds are converted to hard line break elements when using the plain text dialog. This is enabled by default.
[paste_use_dialog] | MSIE specific option, if you set this to true both Mozilla and MSIE will present a paste dialog. If you set it to false pasting in MSIE will be done directly. This option is set to false by default.
[paste_auto_cleanup_on_paste] | MSIE specific option. If you enable this feature, a word paste will be executed when the user copy/paste content to the editor. This feature is disabled by default.
[paste_convert_middot_lists] | If this feature is enabled middot lists are converted into UL lists, these will be assign a special class.
[paste_unindented_list_class] | This option enables you to specify what class to assign to the UL list of middot converted lists. Middot lists are unindented in MS Office. This option defaults to "unIndentedList".
[paste_convert_headers_to_strong] | This feature converts H1-6 elements to strong elements on paste, this is feature is disabled by default.
[paste_remove_spans] | This enables you to control if the word parse operation should remove or keep span elements, they will be removed by default.
[paste_remove_styles] | This enables you to control if the word parse operation should remove or keep style attributes, they will be removed by default.
[paste_replace_list] | Comma separated list of search/replace chunks. Where even items is the regexp that is to be used for the search and odd values are the contents that are to be replaced. This option defaults to: "\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-" this list replaces some custom MS 1250 characters. The \uXXXX values is the hex values of the Unicode characters. Trick use javascript:alert('<unicode char>'.charCodeAt(0).toString(16)); to retive these numbers.

[paste_strip_class_attributes]

This feature allows you to control whether or not class attributes are stripped when using pasteword. Valid values are:

- all - will strip all class attributes from the pasted content. This is the default value.
- none - will not strip any class attributes from the pasted content.
- mso - will strip out all of the class attribute values that start with "Mso", but retain all others.

[paste_insert_word_content_callback] | This option enables you to specify a callback function. This callback is executed when the user pastes word content, the return value of this function will be the new content string. Check the example above for more details.