还有其他建议吗?
使用CKEditor从一个实例复制到另一个实例(使用CTRL + C / V)。你总是得到一些改变的源代码。即使启用了高级内容过滤,也只允许一些插件和内容规则。
在此处查看此示例(代码1):
<p>nubosys GmbH ist ein
Infrastrukturanbieter und bietet für eine moderne Informations- und
Kommunikationstechnologie (ICT) das ideale Umfeld.<p>
另一个实例中的CTRL + C / V变为此(代码2):
<p><span>nubosys</span> GmbH ist ein Infrastrukturanbieter und bietet
für eine moderne <span>Informations</span>-
und Kommunikationstechnologie (ICT) das ideale Umfeld.</p>
所以你看到的是插入了不必要的 span 标签
当我监控剪贴板时,我看到了这个(代码3):
所以你看到CKEditor在过滤掉东西方面做得很好。但它与原始版本不是100%相同。
我的方法是实现基于源代码的复制模式。所以我想知道CKEditor是否还没有这样的东西。我的用例是从CMS中的一个实例复制到另一个编辑器实例。
我想要更多背景信息。这是我们开始的Orchard CMS的CKEditor插件:https://github.com/inteno/CustomCK/wiki/Introduction
如何强制用户只需单击一下或按CTRL + C / V即可将HTML代码从一个实例复制到另一个实例(无源更改)。
当我使用forcePasteAsPlainText:true时,问题不会发生,但格式化将丢失。我想要一种干净的方式来复制格式而不需要更改源。
更新
在这个小提琴http://jsfiddle.net/mjost/6rgo0udg/15/中,问题不会发生。 CKEditor设法过滤掉错误的代码:
Version:0.9
StartHTML:0000000165
EndHTML:0000000886
StartFragment:0000000201
EndFragment:0000000850
SourceURL:http://fiddle.jshell.net/mjost/6rgo0udg/15/show/
<html>
<body>
<!--StartFragment--><p style="box-sizing: border-box; border-radius: 0px !important; margin: 0px 0px 10px; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20.7999992370605px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">nubosys GmbH ist ein Infrastrukturanbieter und bietet für eine moderne Informations- und Kommunikationstechnologie (ICT) das ideale Umfeld.</p><br class="Apple-interchange-newline"><!--EndFragment-->
</body>
</html>
(http://freeclipboardviewer.com/)
但这是因为即使在剪贴板中也没有跨度。
更新2:
当我使用无空间时,会出现问题:
http://jsfiddle.net/mjost/r34c7fLe/5/
HTML
<body>
<textarea id="cke1"><p>nubosys GmbH wurde 2011 von inteno ag und edicomp GmbH gegründet. nubosys GmbH ist ein Infrastrukturanbieter und bietet für eine moderne Informations- und Kommunikationstechnologie (ICT) das ideale Umfeld.</p>
</textarea>
<textarea id="cke2"></textarea>
</body>
JS
CKEDITOR.replace( 'cke1', {
forcePasteAsPlainText: false,
extraAllowedContent: 'span;'
} );
CKEDITOR.replace( 'cke2', {
forcePasteAsPlainText: false,
extraAllowedContent: 'span;'
} );
更新了问题:
根据最新的实验,我认为它应该是一个插件,它会覆盖默认的Copy&amp; Paste并在源代码库上工作。这可能吗?
答案 0 :(得分:1)
CKEditor与Chrome / Webkit之间似乎有些不兼容。我不确定您是否有任何特定原因的javascript。但是forcePasteAsPlainText: false
是多余的,因为这是默认值。 extraAllowedContent: 'span;'
是导致插入跨度问题的原因。
如果您不需要设置更多选项,则可以删除所有javascript,只需在textareas上使用class="ckeditor"
即可在其上加载编辑器。
另一种方法是点击CKEditor工具栏上的来源按钮并直接复制来源,即始终为1:1,然后点击来源按钮第二个CKEditor并将其粘贴在那里,再次是1:1。
在这个小提琴中你是否还有bug? http://jsfiddle.net/tfoaw743/1/