I have TinyMCE 3.x working on Drupal 5.10. I've been able to add several options for the Paste plugin that strip out annoying tags in text pasted from Word, by adding the following to tinymce.module"
$form['output']['paste_auto_cleanup_on_paste'] = array(
'#type' => 'select',
'#title' => t('Auto-Cleanup on Paste'),
'#default_value' => $edit->settings['paste_auto_cleanup_on_paste'],
'#options' => array('false' => t('false'), 'true' => t('true')),
'#description' => t('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.')
);
$form['output']['paste_remove_spans'] = array(
'#type' => 'select',
'#title' => t('Remove Span tags on Paste'),
'#default_value' => $edit->settings['paste_remove_spans'],
'#options' => array('false' => t('false'), 'true' => t('true')),
'#description' => t('This enables you to control if the word parse operation should remove or keep span elements, they will be removed by default.')
);
$form['output']['paste_remove_styles'] = array(
'#type' => 'select',
'#title' => t('Remove Styles on Paste'),
'#default_value' => $edit->settings['paste_remove_styles'],
'#options' => array('false' => t('false'), 'true' => t('true')),
'#description' => t('This enables you to control if the word parse operation should remove or keep style attributes, they will be removed by default.')
);
$form['output']['paste_strip_class_attributes'] = array(
'#type' => 'select',
'#title' => t('Strip Class Attributes on Paste'),
'#default_value' => $edit->settings['paste_strip_class_attributes'],
'#options' => array('none' => t('none'), 'all' => t('all'), 'mso' => t('mso')),
'#description' => t('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. ')
);
$form['output']['paste_create_paragraphs'] = array(
'#type' => 'select',
'#title' => t('Convert Double Linebreaks to Paragraph Elements'),
'#default_value' => $edit->settings['paste_create_paragraphs'],
'#options' => array('true' => t('true'), 'false' => t('false')),
'#description' => t('If enabled double linefeeds are converted to paragraph elements when using the plain text dialog. This is enabled by default.')
);
$form['output']['paste_create_linebreaks'] = array(
'#type' => 'select',
'#title' => t('Convert Linebreaks to Break Elements'),
'#default_value' => $edit->settings['paste_create_linebreaks'],
'#options' => array('true' => t('true'), 'false' => t('false')),
'#description' => t('If enabled single linefeeds are converted to hard line break elements when using the plain text dialog. This is enabled by default.')
);
These options have really helped in cleaning up pastes from Word in TinyMCE, and I hope others will find them useful as well, and they can be added to the Drupal TinyMCE module.
However, I need to take this one step farther to strip out comments that Word content generates when pasting into Firefox 3. I found a solution here: http://tinymce.moxiecode.com/punbb/viewtopic.php?id=12385 and I think I've added the appropriate code to configure the callback:
$form['output']['paste_insert_word_content_callback'] = array(
'#type' => 'select',
'#title' => t('Strip Word Comments'),
'#default_value' => $edit->settings['paste_insert_word_content_callback'],
'#options' => array('convertWord' => t('convertWord'), 'false' => t('false')),
'#description' => t('Strips excess comments out of Word Paste into FireFox 3. This is enabled by default.')
);
but I can't figure out where the callback function itself should go. I've tried converting the function to php and adding it to the bottom of tinymce.module, I've tried putting it as-is in the tinymce.module where $tinymce_invoke gets set (up near the tinymce initialization code), and I've tried adding it into a script tag in page.tpl.php, but I can't get the callback to execute. I could really use some help, and we're willing to pay for consulting time if need be.
Comments
Comment #1
mupsi