And*_*raD 7 ms-word richtextbox rich-text-editor wysihtml5
将文本从单词复制到wysihtml5编辑器时,文本会混乱(无论是格式还是附加添加的字符).这有一个简单的解决方案吗?我正在寻找的正确行为将是Stack Overflow的富文本编辑器的工作方式 - 从单词复制和粘贴的文本看起来与word文档相同.
谢谢!
更新:
为了解决粘贴的文字格式的格式问题,我"p": {},在使用的wysihtml5-0.30_rc2.js文件中添加了这一行.该行已在defaultOptions [parserRules] [tags]的声明中添加(请参阅used resources).
不过,现在我可以在粘贴文本的开头看到"字体定义"段落:
<!-- /* Font Definitions */ @font-face {font-family:Arial; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; mso-hyphenate:none; font-size:11.0pt; font-family:Arial; mso-fareast-font-family:Arial; mso-bidi-font-family:Arial; color:black; mso-fareast-language:HI; mso-bidi-language:HI;} a:link, span.MsoHyperlink {mso-style-unhide:no; mso-style-parent:""; color:navy; mso-ansi-language:#00FF; mso-fareast-language:#00FF; mso-bidi-language:#00FF; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt
90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} -->
Run Code Online (Sandbox Code Playgroud)
这只发生在我使用Firefox时,而不是在Chrome中发生.关于如何摆脱这个问题的任何想法?
wysihtml5包含一个解析器,用于分析粘贴到其文本区域中的所有文本,并应用parserRules配置对象中定义的过滤规则。添加"style": { "remove": 1 }到你的parserRules应该就可以了。
要了解 Firefox 问题,您必须查看粘贴到文本区域的原始剪贴板 HTML 内容(源自 Word)。仅复制一些 Word 文本并将其粘贴到文本编辑器中不会有帮助,因为文本编辑器需要剪贴板内容的纯文本变体。
\n\n如果您在 Mac 上\xe2\x80\x99,您可以借助ClipboardViewer 工具查看原始剪贴板内容,您必须使用 XCode 自行编译该工具。所需的 HTML 内容应位于public.html或Apple HTML pasteboard type字段中。也许存在其他不需要编译和/或在其他操作系统上工作的工具。
现在您应该看到 Word 中的剪贴板内容实际上类似于
\n\n <span>\n <!--\n /* Font Definitions */\n ...\n div.WordSection1 {page:WordSection1;}\n ...\n -->\n </span>\nRun Code Online (Sandbox Code Playgroud)\n\n因此,通过删除style标签(及其所有内容),字体定义垃圾就会消失。
查看wysihtml5\xe2\x80\x99s parserRule 演示以了解一些更高级的配置选项。
\n| 归档时间: |
|
| 查看次数: |
3300 次 |
| 最近记录: |