从 word 粘贴到 extjs 编辑器
Posted
技术标签:
【中文标题】从 word 粘贴到 extjs 编辑器【英文标题】:Paste from word to extjs editor 【发布时间】:2016-08-09 12:22:09 【问题描述】:我发现 extjs 编辑器还有一个问题。
当我复制时
<ol type="A" style="margin-top: 0pt; margin-bottom: 0pt;">
<li style="line-height: 115%; font-size: 11pt; margin-top: 0pt; margin-bottom: 10pt;"><span style="font-family: Calibri; font-size: 11pt;">Main Heading 1</span></li>
</ol>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">1.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 1</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">2.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 2</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">3.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 3</span></p>
<ol type="A" style="margin-top: 0pt; margin-bottom: 0pt;" start="2">
<li style="line-height: 115%; font-size: 11pt; margin-top: 0pt; margin-bottom: 10pt;"><span style="font-family: Calibri; font-size: 11pt;">Main Heading 2</span></li>
</ol>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">1.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 1</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">2.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 2</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">3.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 3</span></p>
并粘贴到extjs htmleditor中,转换为
<ol style="list-style-type: upper-alpha; direction: ltr;">
<li style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal;">
<p style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l2 level1 lfo1;">Main
Heading 1
</p>
</li>
</ol>
<p><font face="Times New Roman" size="3">
<br></font>
</p>
<ol style="list-style-type: decimal; direction: ltr;">
<li style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal;">
<p style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l5 level1 lfo2; mso-add-space: auto;">Item
1
</p>
</li>
<li style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal;'>
<p style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l5 level1 lfo2; mso-add-space: auto;'>Item
2
</p>
</li>
<li style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal;'>
<p style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l5 level1 lfo2; mso-add-space: auto;'>Item
3
</p>
</li>
</ol>
<p><font face="Times New Roman" size="3">
<br></font>
</p>
<ol style="list-style-type: upper-alpha; direction: ltr;">
<li style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal;">
<p style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l2 level1 lfo1;">Main
Heading 2
</p>
</li>
</ol>
<p><font face="Times New Roman" size="3">
<br></font>
</p>
<ol style="list-style-type: decimal; direction: ltr;">
<li style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal;">
<p style="color: rgb(0, 0, 0); font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l7 level1 lfo3; mso-add-space: auto;">Item
1
</p>
</li>
<li style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal;'>
<p style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l7 level1 lfo3; mso-add-space: auto;'>Item
2
</p>
</li>
<li style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal;'>
<p style='color: rgb(0, 0, 0); font-family: "Calibri","sans-serif"; font-size: 11pt; font-style: normal; font-weight: normal; margin-top: 0in; margin-bottom: 0pt; mso-list: l7 level1 lfo3; mso-add-space: auto;'>Item
3
</p>
</li>
</ol>
也请建议我这样做,以消除从 word 复制粘贴到编辑器时的格式问题
【问题讨论】:
【参考方案1】:将word文档保存为html,在“Source Edit”中复制/粘贴html代码。
<ol type="A" style="margin-top: 0pt; margin-bottom: 0pt;">
<li style="line-height: 115%; font-size: 11pt; margin-top: 0pt; margin-bottom: 10pt;"><span style="font-family: Calibri; font-size: 11pt;">Main Heading 1</span></li>
</ol>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">1.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 1</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">2.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 2</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">3.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 3</span></p>
<ol type="A" style="margin-top: 0pt; margin-bottom: 0pt;" start="2">
<li style="line-height: 115%; font-size: 11pt; margin-top: 0pt; margin-bottom: 10pt;"><span style="font-family: Calibri; font-size: 11pt;">Main Heading 2</span></li>
</ol>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">1.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 1</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">2.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 2</span></p>
<p style="margin: 0pt 0pt 10pt 72pt; line-height: 115%; text-indent: -18pt; font-size: 11pt;"><span style="font-family: Calibri; font-size: 11pt;">3.</span><span style='font: 7pt/normal "Times New Roman"; font-size-adjust: none; font-stretch: normal;'> </span><span style="font-family: Calibri; font-size: 11pt;">Item 3</span></p>
【讨论】:
您好,请在 IE11 中进行,而不是在 chrome 浏览器中进行 我不使用 chrome。我用的是 IE11。 在word中创建相同的公告并将相同的公告复制到htmleditor中看看会发生什么,请IE11做【参考方案2】:当我与 IE 支持团队聊天时,我知道这不是 ExtJs 编辑器的问题,而是 IE11 引擎的问题。如果我将其保持在 IE8 兼容模式下,它将起作用。 请参考链接 https://social.msdn.microsoft.com/Forums/ie/en-US/7225fe68-5afb-4aa9-a77d-5c4eef366921/copy-paste-issue-in-ie-11?forum=iewebdevelopment
【讨论】:
以上是关于从 word 粘贴到 extjs 编辑器的主要内容,如果未能解决你的问题,请参考以下文章
富文本编辑器xheditor支持从word复制粘贴保留格式和图片的插件