php - 为什么我的 CKEditor 添加了垃圾代码?

标签 php javascript ckeditor

我正在为我的后端应用程序使用 CKEditor。

我已经按照官方文档中的说明进行了安装(非常简单)。 然而,例如,当尝试添加此文本时(我可以从这篇文章的 SO 复制/粘贴它,它完全相同):

You don't just want people to hear you. You want them to listen.

Barraged as we are with news clips and op-eds that get linked, blogged, posted, tweeted and re-tweeted on a minute-to-minute basis, that's a lot to ask for. Countless voices across the nation drown each other out in the echo chamber of modern media. Would-be revolutions can wind up footnotes on corporate memos, and reputations can die or reincarnate in the time it takes to post a Facebook status.

For businesses and agenda-setters worldwide, this all amounts to one important question: "How do we rise above the noise and really make an impact?"

That's where we come in.

Drawing from a wealth of public relations experience in political, advocacy and corporate arenas, N** * Communications spearheads creative and downright effective communications campaigns that infiltrate national conversations and direct them to our clients' goals. Synchronizing the buzz means harmonizing the noise. Suddenly you're listened to, not just heard.

We service clients in both the nonprofit and for-profit spheres, leading projects which range from political campaign strategy to executive speechwriting. We've worked for CEOs, elected officials, political candidates from the presidential to local level, and progressive organizations from 527 groups to major national unions.

我有这样的东西:

<p>
    &nbsp;</p>
<p 0px="" color:="" font-family:="" font-size:="" hear="" helvetica="" just="" line-height:="" p="" people="" style="margin: 0px 0px 10px; text-align: justify; font-size: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 20px; " t="" them="" to="" want="" you="" you.="">
    &nbsp;</p>
<p 0px="" color:="" font-family:="" font-size:="" hear="" helvetica="" just="" line-height:="" p="" people="" style="margin: 0px 0px 10px; " t="" them="" to="" want="" you="" you.="">
    Barraged as we are with news clips and op-eds that get linked, blogged, posted, tweeted and re-tweeted on a minute-to-minute basis, that&#39;s a lot to ask for. Countless voices across the nation drown each other out in the echochamber of modern media. Would-be revolutions can wind up footnotes on corporate memos, and reputations can die or reincarnate in the time it takes to post a Facebook status.</p>
<p 0px="" above="" agenda-setters="" all="" amounts="" an="" and="" businesses="" color:="" do="" font-family:="" font-size:="" for="" helvetica="" how="" important="" line-height:="" make="" noise="" one="" p="" question:="" really="" rise="" style="margin: 0px 0px 10px; " the="" this="" to="" we="">
    That&#39;s where we come in.</p>
<p 0px="" a="" advocacy="" and="" buzz="" campaigns="" color:="" communications="" conversations="" corporate="" creative="" direct="" downright="" drawing="" effective="" experience="" font-family:="" font-size:="" from="" goals.="" harmonizing="" heights="" helvetica="" in="" infiltrate="" just="" line-height:="" listened="" means="" national="" new="" noise.="" not="" of="" our="" p="" public="" re="" relations="" spearheads="" style="margin: 0px 0px 10px; " suddenly="" synchronizing="" that="" the="" them="" to="" wealth="">
    We service clients in both the nonprofit and for-profit spheres, leading projects which range from political campaign strategy to executive speechwriting. We&#39;ve worked for CEOs, elected officials, political candidates from the presidential to local level, and progressive organizations from 527 groups to major national unions.</p>

这完全是垃圾且无法使用,所以如果我决定保存该文本,这就是我在源代码(如果我单击源代码)和数据库中获得的内容。它显然来自 CKEditor 本身。

这个问题从何而来?

最佳答案

您确定您使用的是最新版本的 CKEditor 并且您没有以某种奇怪的方式修改它吗?我正在选择、复制引用的文本并粘贴到 http://ckeditor.com/demo 上的编辑器中,这是源代码的一部分:

火狐:

<blockquote>
    <p>
        You don&#39;t just want people to hear you. You want them to listen.</p>
    <p>
        Barraged as we are with news clips and op-eds that get linked, blogged, posted, tweeted and re-tweeted on a minute-to-minute basis, that&#39;s a lot to ask for. Countless voices across the nation drown each other out in the echo chamber of modern media. Would-be revolutions can wind up footnotes on corporate memos, and reputations can die or reincarnate in the time it takes to post a Facebook status.</p>
    <p>
        For businesses and agenda-setters worldwide, this all amounts to one important question: &quot;How do we rise above the noise and really make an impact?&quot;</p>

Chrome :

<p>
    &nbsp;</p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; ">
    You don&#39;t just want people to hear you. You want them to listen.</p>
<p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 18px; ">
    Barraged as we are with news clips and op-eds that get linked, blogged, posted, tweeted and re-tweeted on a minute-to-minute basis, that&#39;s a lot to ask for. Countless voices across the nation drown each other out in the echo chamber of modern media. Would-be revolutions can wind up footnotes on corporate memos, and reputations can die or reincarnate in the time it takes to post a Facebook status.</p>
<div>
    &nbsp;</div>

现在,是什么导致了浏览器之间的这种差异,第二个来源是否正确?

首先 - 这不是 CKEditor 的错,而是 Chrome 的错,它看起来像这样。它会将 样式化的 HTML 放入剪贴板,我们对此无能为力。当然你可以这样说,例如TinyMCE 你只会得到文本,没有格式。但这是处理粘贴内容的一种盲目方式。这样 TinyMCE 也会丢失编辑器中应用的内联样式 - 例如字体大小。在那里写几个字,应用字体大小,复制和粘贴,然后你就失去了它。

那么...两个输出(Firefox 和 Chrome 的)都是正确的,这是我们能做的最好的。但是,如果您的 HTML 确实与您所附的内容相似,那么问题很可能出在您的网站上。

关于php - 为什么我的 CKEditor 添加了垃圾代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12788667/

相关文章:

javascript - 根据属性值从数组中选择一个对象

javascript - 如何在ckeditor编辑器中获取保存事件?

php - 选择所有最新关系为真的地方?

php - 如何在 WooCommerce 中显示每个自定义选项卡的内容

javascript - 如何使用数据库中的数据动态修改 Google Maps 热图位置

javascript - 使用reduce函数返回一个数组

javascript - 删除所有 CKEditor 实例

javascript - 更改 CKEditor 中 "format"下拉菜单的大小

php - 不同用户类型的 Laravel 关系

php - 方法参数的首选做法是什么?