这个插件为 TinyMCE 增加"纯文本粘贴"和"从WORD粘贴"按钮。插件由 Ryan Demmer 开发,由 TinyMCE 工作人员修改使之更加通用,并附加了额外的特性。
2005年5月25日,插件被 speednet 修改。目前在IE里直接粘贴到编辑器里,主要步骤有打开插入BOX,选择选项,点击插入。Speednet 也增加了全选按钮,用户点击时会高亮显示编辑器中的所有内容。
2005年10月28日,插件被 monkeybrain 修改。增加了 paste_strip_class_attributes 选项。
安装说明
- paste 目录复制到 TinyMCE 的插件目录(/jscripts/tiny_mce/plugins)。
- 在 TinyMCE 插件选项列表中加入插件,例如: plugins : "paste"。
- 在按钮列表中加入按钮名,例如:theme_advanced_buttons3_add : "pastetext,pasteword,selectall"。
初始化示例
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;
}
选项
| [paste_create_paragraphs] | 如果选项打开,使用纯文本对话框时,双换行符会被转换为段落元素。默认打开。 |
| [paste_create_linebreaks] | 如果选项打开,使用纯文本对话框时,单换行会被转换成硬回车。默认打开。 |
| [paste_use_dialog] | MSIE 专用选项,如果设为 true ,Mozilla 和 MSIE 中会出现一个粘贴对话框。如果设为 false ,MSIE 中会直接粘贴。默认为 false 。 |
| [paste_auto_cleanup_on_paste] | MSIE 专用选项,如果打开这个特性,当用户在编辑器中复制或粘贴时,word paste会被执行。默认为 false。 |
| [paste_convert_middot_lists] | 如果这个特性被打开,"·"列表将被转换成无序列表,这里制定特定 class 来完成。 |
| [paste_unindented_list_class] | 这个选项让你指定用哪个 class 进行无序列表与"·"列表的转换。在MS Office中"·"列表是不缩进的。选项默认为"unIndentedList"。 |
| [paste_convert_headers_to_strong] | 这个特性将在粘贴中将 H1-6 元素转换成粗体元素。默认为false。 |
| [paste_replace_list] | 以逗号分隔的查找/替换块列表。偶数项目是用来查找的正则表达式,而技术值是要被替换的内容。
选项默认为: "\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-"这个列表替换一些微软 1250 字符。 \uXXXX 是 Unicode 字符的16进制值。 使用javascript:alert('<unicode char>'.charCodeAt(0).toString(16));得到数字。 |
| [paste_strip_class_attributes] | 这个特性可以使你控制当使用 pastework 时是否去除 class 属性。有效值是:
|
| [paste_insert_word_content_callback] | 这个选项使你可以指定一个回调函数。当用户粘贴 word 内容时回调函数会被调用,函数的返回值时新的内容字符串。看看的例子以得知更多细节。 |