Hi Cara
Thanks for the reply.
With the error even if preformatted was selected prior to pasting, the formatting was lost.
I added the following to my functions.php file and it solved the issues. It also gives me more options on the editor controls.
add_filter('tiny_mce_before_init', 'custom_tinymce_settings');
function custom_tinymce_settings($initArray) {
? ? $initArray['toolbar1'] = 'bold italic underline strikethrough superscript ?subscript | bullist numlist | outdent indent ?| link unlink | alignleft aligncenter alignright alignjustify | removeformat ';
? ? $initArray['toolbar2'] = 'formatselect fontselect fontsizeselect';
? ? $initArray['toolbar3'] = 'cut copy paste | undo redo | forecolor backcolor';
? ? $initArray['content_css'] = get_template_directory_uri() . '/css/custom-editor-styles.css'; // Custom styles for the editor
? ? // Preserve line breaks
? ? $initArray['wpautop'] = false; // Prevents automatic paragraph tags around content
? ? $initArray['forced_root_block'] = ''; // Prevents wrapping content in <p> tags by default
? ? // Enable and configure paste plugin
? ? $initArray['plugins'] = 'paste'; // Ensure paste plugin is enabled
? ? $initArray['paste_as_text'] = false; // Allows rich text to be pasted with formatting
? ?// $initArray['paste_enable_default_filters'] = false; // Disable TinyMCE's default paste filters
? ? // Configure TinyMCE to allow preformatted text
? ? $initArray['preformatted'] = true; // Allows preformatted text, keeping spaces and tabs intact
? ? $initArray['force_p_newlines'] = true; // Forces new lines to be preserved as paragraphs
? ? $initArray['remove_linebreaks'] = false; // Prevents TinyMCE from removing line breaks
? ? // Clean up symbols and formatting from Word
? ? $initArray['paste_word_valid_elements'] = "b,strong,i,em,ul,ol,li,p,br,h1,h2,h3,h4,h5,h6";
? ? $initArray['paste_remove_styles'] = true; // Strip inline Word styles that may include special symbols
? ? $initArray['paste_retain_style_properties'] = ''; // Remove any unwanted style properties on paste
? ? // Allow all HTML tags (optional)
? ? //$initArray['valid_elements'] = '*[*]'; // Allows all HTML tags and attributes
? ? $initArray['extended_valid_elements'] = 'pre[class|style],p,br,b,strong,i,em'; // Extend to specific inline tags if needed
? ? return $initArray;
}