TinyMCE 编辑器 (3.x) 从 Word 2015 粘贴时改变格式
TinyMCE Editor (3.x) altering format when pasting from Word 2015
当我复制一个格式正确的 word 文档的内容时,这意味着它有 H1 标签、3 个段落、一个 URL link 和一个电子邮件 link,一些粗体和一些斜体字 - 基本上是一个非常基本的文件,格式没有保留。下面是我的初始化文件。
tinyMCE.init({
// General options
mode : "exact",
elements : "content",
theme: "advanced",
//plugins : "safari,pagebreak,advhr,advimage,advlink,iespell,insertdatetime,preview,paste,fullscreen",
plugins : "pagebreak,style,advlink,iespell,insertdatetime,preview,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
plugin_preview_width : "500",
plugin_preview_height : "600",
// Theme options
theme_advanced_buttons1:"cut,copy,paste,pasteword,|,undo,redo,|,bold,italic,underline,|,forecolor,backcolor|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|fullscreen,code,iespell,imageButton,preview",
theme_advanced_disable : "help,removeformat,sub,sup,anchor,link,unlink,image,|,insertdate,inserttime,advhr,print",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
paste_auto_cleanup_on_paste: false,
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
valid_elements : "*[*]",
convert_urls:true,
cleanup : false
});
当我 运行 以下控制台命令时,我确实看到了 "html" 代码。此外,当我单击工具栏中的 HTML 图标时,我也在那里看到了 HTML 代码(尽管除第一个之外的所有 H1 标签都被删除了)。
// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());
// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});
// Get content of a specific editor:
tinyMCE.get('content').getContent()
当我点击提交按钮时,我的操作页面上只有一个简单的 cfdump,它只是纯文本和一个巨大的自段落。没有P标签,没有H1标签,只有纯文本。
<cfdump var="#form.content#">
<cfoutput>
#form.content#
<textarea>#form.content#</textarea>
</cfoutput>
只是为了笑,在操作页面上,我将 form.content 插入到我的 MSSQL 数据库中,数据类型为 nvarchar(2000) 只是为了查看浏览器是否正在玩游戏并且数据库只显示普通文字也是。这里还有一个异常就是当我运行我的测试页在Chrome时,只保存纯文本。当我在 FireFox 中 运行 测试页面时,Microsoft XML 数据被保存。
我只需要一个浏览器就可以工作。有人可以提供任何指导吗?
喜欢意大利面条代码。
我错过了一些逻辑,它正在检查我错过的浏览器,所以问题确实出在 fckeditor 而不是 tinymce。
/从以下位置开始代码段:http://ckeditor.com/forums/Support/FCK-Link-picker-errors-FF-3
我在 FCK 2.3.2 中遇到了同样的问题。最好的解决方案是更改 fckeditorcode_gecko.js 中的函数 CreateLink:
我的旧代码:
FCK.CreateLink=function(A){FCK.ExecuteNamedCommand('Unlink');if (A.length>0){var B='javascript:void(0);/*'+(new Date().getTime())+'*/';FCK.ExecuteNamedCommand('CreateLink',B);var C=document.evaluate("//a[@href='"+B+"']",this.EditorDocument.body,null,9,null).singleNodeValue;if (C){C.href=A;return C;}}};
新代码:
FCK.CreateLink=function(A){FCK.ExecuteNamedCommand('Unlink');if (A.length>0){var B='javascript:void(0);/*'+(new Date().getTime())+'*/';FCK.ExecuteNamedCommand('CreateLink',B);var C=this.EditorDocument.evaluate("//a[@href='"+B+"']",this.EditorDocument.body,null,9,null).singleNodeValue;if (C){C.href=A;return C;}}};
其实我只是把document.evaluate换成了this.EditorDocument.evaluate
/结束片段
当我复制一个格式正确的 word 文档的内容时,这意味着它有 H1 标签、3 个段落、一个 URL link 和一个电子邮件 link,一些粗体和一些斜体字 - 基本上是一个非常基本的文件,格式没有保留。下面是我的初始化文件。
tinyMCE.init({
// General options
mode : "exact",
elements : "content",
theme: "advanced",
//plugins : "safari,pagebreak,advhr,advimage,advlink,iespell,insertdatetime,preview,paste,fullscreen",
plugins : "pagebreak,style,advlink,iespell,insertdatetime,preview,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
plugin_preview_width : "500",
plugin_preview_height : "600",
// Theme options
theme_advanced_buttons1:"cut,copy,paste,pasteword,|,undo,redo,|,bold,italic,underline,|,forecolor,backcolor|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|fullscreen,code,iespell,imageButton,preview",
theme_advanced_disable : "help,removeformat,sub,sup,anchor,link,unlink,image,|,insertdate,inserttime,advhr,print",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
paste_auto_cleanup_on_paste: false,
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
valid_elements : "*[*]",
convert_urls:true,
cleanup : false
});
当我 运行 以下控制台命令时,我确实看到了 "html" 代码。此外,当我单击工具栏中的 HTML 图标时,我也在那里看到了 HTML 代码(尽管除第一个之外的所有 H1 标签都被删除了)。
// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());
// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});
// Get content of a specific editor:
tinyMCE.get('content').getContent()
当我点击提交按钮时,我的操作页面上只有一个简单的 cfdump,它只是纯文本和一个巨大的自段落。没有P标签,没有H1标签,只有纯文本。
<cfdump var="#form.content#">
<cfoutput>
#form.content#
<textarea>#form.content#</textarea>
</cfoutput>
只是为了笑,在操作页面上,我将 form.content 插入到我的 MSSQL 数据库中,数据类型为 nvarchar(2000) 只是为了查看浏览器是否正在玩游戏并且数据库只显示普通文字也是。这里还有一个异常就是当我运行我的测试页在Chrome时,只保存纯文本。当我在 FireFox 中 运行 测试页面时,Microsoft XML 数据被保存。
我只需要一个浏览器就可以工作。有人可以提供任何指导吗?
喜欢意大利面条代码。
我错过了一些逻辑,它正在检查我错过的浏览器,所以问题确实出在 fckeditor 而不是 tinymce。
/从以下位置开始代码段:http://ckeditor.com/forums/Support/FCK-Link-picker-errors-FF-3
我在 FCK 2.3.2 中遇到了同样的问题。最好的解决方案是更改 fckeditorcode_gecko.js 中的函数 CreateLink: 我的旧代码:
FCK.CreateLink=function(A){FCK.ExecuteNamedCommand('Unlink');if (A.length>0){var B='javascript:void(0);/*'+(new Date().getTime())+'*/';FCK.ExecuteNamedCommand('CreateLink',B);var C=document.evaluate("//a[@href='"+B+"']",this.EditorDocument.body,null,9,null).singleNodeValue;if (C){C.href=A;return C;}}};
新代码:
FCK.CreateLink=function(A){FCK.ExecuteNamedCommand('Unlink');if (A.length>0){var B='javascript:void(0);/*'+(new Date().getTime())+'*/';FCK.ExecuteNamedCommand('CreateLink',B);var C=this.EditorDocument.evaluate("//a[@href='"+B+"']",this.EditorDocument.body,null,9,null).singleNodeValue;if (C){C.href=A;return C;}}};
其实我只是把document.evaluate换成了this.EditorDocument.evaluate
/结束片段