使用 ckeditor 整理 html

2024-01-04

您好,我在 ckeditor 方面遇到了一个小问题,基本上我需要让编辑器运行它的 html 清理命令。 有什么办法可以做到这一点吗? 目前,在我在源代码中输入一些内容然后按保存后,它似乎没有运行我希望它像在“正常”编辑器视图中那样整理 html 有任何想法吗? 谢谢 理查德

这是一些示例代码

<SCRIPT type=text/javascript src="http://www.johnpricephotography.co.uk/crawler.js">
/* Text and/or Image Crawler Script v1.5 (c)2009-2011 John Davenport Scheuer
   as first seen in http://www.dynamicdrive.com/forums/
   username: jscheuer1 - This Notice Must Remain for Legal Use
   updated: 4/2011 for random order option, more (see below)
*/

</SCRIPT>
<div class="marquee" id="mycrawler2">
    <img alt="Derby wedding photographer - masa restaurant wedding" src="http://johnprice.foliopic.com/images/3539/homepage//226.jpg" style="width: 204px; height: 162px" /> <img alt="Shottle Hall Derby by Nottingham wedding photographer, shottle hall wedding" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/large/049_1314978790.jpg" style="width: 204px; height: 162px" /> <img alt="Shottle Hall wedding Derby wedding by Nottingham wedding photographer" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/large/13150063462954.jpg" style="width: 204px; height: 162px" /> <img alt="derby conference centre wedding by nottingham wedding photographer" src="http://johnprice.foliopic.com/images/3539/homepage//146_1.jpg" style="width: 250px; height: 162px" /> <img alt="professional wedding photographer john price" src="http://johnprice.foliopic.com/images/3539/homepage//31.jpg" style="width: 181px; height: 162px" /> <img alt="Leicestershire wedding photographer john price" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/ian---jo--24-of-62-_1312848448.jpg" style="width: 223px; height: 162px" /> <img alt="Leicestershire wedding photographer john price" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/ian---jo--47-of-62-_1312849131.jpg" style="width: 124px; height: 162px" /> <img alt="Derby river lights holiday inn wedding by derby wedding photographer john price" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/112_1314726892.jpg" style="width: 164px; height: 162px" /> <img alt="alvaston park wedding from derby conference centre wedding" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/163_1311890753.jpg" style="width: 220px; height: 162px" /> <img alt="London uk wedding photographer" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/flashmo-800x450-30_1311894940.jpg" style="width: 215px; height: 162px" /> <img alt="London uk wedding photographer" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/flashmo-800x450-04_1311894907.jpg" style="width: 212px; height: 162px" /></div>
<div class="marquee">
    &nbsp;</div>
<h1 align="center">
    <font face="Times New Roman, Times, serif" size="4"><b><font size="5">By Nottingham Wedding Photographer - John Price, </font></b></font><br />
    <span style="color: #a9a9a9"><font face="Times New Roman, Times, serif" size="4"><b><font size="5">&#39;Give me a wedding and I will give you memories&#39;</font></b></font></span></h1>
<table align="center" border="0" cellpadding="1" cellspacing="1" style="width: 800px">
    <tbody>
        <tr>
            <td>
                <p>
                    <br />
                    <span style="font-size: 14px"><font face="Times New Roman, Times, serif"><span style="color: #000000">Welcome to the&nbsp;website of Nottingham wedding photographer John Price. </span><span style="color: #000000">If you are browsing my website, the chances are that you already are or have recently become engaged. Congratulations. You are now both embarking on an exciting journey together and never before will you have so many choices to make, not least choosing a wedding photographer in nottingham or a wedding photographer in Derby or Leicester and beyond.&nbsp;</span></font></span></p>
            </td>
        </tr>
    </tbody>
</table>
<div>
    &nbsp;</div>
<SCRIPT type=text/javascript>
marqueeInit({
    uniqueid: 'mycrawler2',
    style: {
        'padding': '2px',
        'width': '840px',
        'height': '160px'
    },
    inc: 10, //speed - pixel increment for each iteration of this marquee's movement
    mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
    moveatleast: 1,
noAddedSpace: false,
    neutral: 106,
    savedirection: true,
    random: true

});
</SCRIPT><div>
    &nbsp;</div>
<p>
    <span style="font-size: 16px"><span style="font-family: arial, helvetica, sans-serif">&nbsp;</span></span></p>
<p>
    &nbsp;</p>
<table border="0" cellpadding="1" cellspacing="1" style="width: 800px">
    <tbody>
        <tr>
            <td>
                <p>
                    <strong><span style="font-size: 18px"><span style="font-family: arial, helvetica, sans-serif"><strong><span style="font-size: 18px"><span style="font-family: arial, helvetica, sans-serif">Nottingham wedding photographer - John Price<br />
                    Receives wedding photographer recommedation by Insight Magazine. </span></span></strong></span></span></strong></p>
                <p style="text-align: center">
                    <strong><span style="font-size: 18px"><span style="font-family: arial, helvetica, sans-serif">&nbsp;</span></span></strong></p>
                <p>
                    <strong><span style="font-size: 18px"><span style="font-family: arial, helvetica, sans-serif"><span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">October 2011 edition of the Insight Magazine features a full page recommended article on the wedding photography services that I provide. </span></span></span></span></strong></p>
                <p>
                    &nbsp;</p>
                <p>
                    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">This is also a privilege for the beautiful bride and grooms which also feature in this article. The photos was all taken from real weddings that I photographed during 2011</span></span></p>
                <p>
                    &nbsp;</p>
                <p>
                    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">A big thank you to the couples featured.</span></span></p>
                <p>
                    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">Wayne&nbsp;&amp; Katey was married at the Derby Riverlights Holiday Inn, </span></span></p>
                <p>
                    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">Ian &amp; Jo were had an amazing wedding at&nbsp;Shottle Hall, Derby..&nbsp; </span></span></p>
                <p>
                    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">James &amp; Kerry-Ann was married at the Derby Conference Centre.</span></span></p>
                <p>
                    &nbsp;</p>
                <p>
                    &nbsp;</p>
                <p>
                    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">You can view a pdf copy of this interview <a href="http://www.johnpricephotography.co.uk/Nottingham Wedding Photographer.pdf"><strong><span style="color: #0000ff"><span style="font-size: 14px">Here</span></span></strong></a>.or see an image <strong><a href="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/large/1317302692.jpg"><span style="color: #0000ff"><span style="font-size: 14px">Here</span></span></a></strong></span></span></p>
            </td>
            <td style="text-align: center">
                <img alt="Nottingham Wedding Photographer Recommended By Insight Magazine" src="http://www.nottinghamweddingphotography.co.uk/images/sites/3539/gallery/normal/1317297874.png" style="width: 264px; height: 187px" /></td>
        </tr>
    </tbody>
</table>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p>
    &nbsp;</p>
<p style="text-align: center">
    &nbsp;</p>
<p>
    <span style="font-size: 12px"><span style="font-family: arial, helvetica, sans-serif">Wedding photographer in Nottingham, Wedding photographer in Derby, Wedding photographer in leicester.</span></span></p>
<p>
    <font face="Times New Roman, Times, serif"><font color="#666666"><font color="#666666">John Price is a Nottingham NG based wedding photographer who enjoys capturing that special moment that you know you can look back on time and time again. As a Nottingham wedding photographer, I make no distinction between a Church or Civil Ceremony, Registry Office or Civil Partnerships. Every wedding commands the very best.<span style="display: none">&nbsp;</span></font></font></font></p>
<p>
    <font face="Times New Roman, Times, serif"><font color="#666666">Nottingham Wedding Photography, Nottingham Boudoir Photography, Nottingham Portrait Photography, Nottingham Trash The Dress Photography Covering not just Nottingham, Mansfield, Derby, Leicester, Lincolnshire, Peterborough but the whole of the UK</font></font>&nbsp;<span style="display: none">&nbsp;<span style="display: none">&nbsp;</span></span></p>
<p>
    &nbsp;</p>
<p>
    &nbsp;&nbsp;</p>
<p>
    <a href="http://www.nottinghamweddingphotography.co.uk/article/shottle-hall-wedding-photos-of-ian---jo-1963">Shottle Hall Wedding Photos by Derby Wedding Phototographer John Price&nbsp;Photography at shottle hall&nbsp;&nbsp; </a></p>
<p>
    <a href="http://www.nottinghamweddingphotography.co.uk/article/the-wedding-of-james---lisa-at-rufford-abbey-country-park-2144">Rufford Abbey Wedding Photos by Nottingham Wedding Phototographer Nottingham Rufford Abbey Country Park.</a></p>
<p>
    <a href="http://www.nottinghamweddingphotography.co.uk/article/masa-restaurant-wedding--the-old-chapel--mark---anna-1915">Masa Restaurant Wedding photos Derby wedding photography at Massa Restaurant.</a></p>
<p>
    <a href="http://www.nottinghamweddingphotography.co.uk/article/the-derby-conference-centre-wedding---james---kerry-ann-1911">The Derby Conference Centre Wedding photos by Derby wedding photographer John Price Photography</a></p>
<p>
    <a href="http://www.nottinghamweddingphotography.co.uk/article/the-wedding-of-craig---sarah-at-the-nottingham-council-house-1906">Nottingham Council House Wedding Photos Photographer</a></p>
<p>
    <a href="http://www.nottinghamweddingphotography.co.uk/page/nottingham-boudoir-photographer-1949">Nottingham Boudoir, Derby Boudoir, Leicester Boudoir Photographer</a></p>

这是如何工作的,但我想做的是修复 html(如果有问题)。 基本上发生的情况是,该 html 被保存到隐藏元素中,然后当用户单击“保存”时,所有内容都会被整理出来。 老实说,现在考虑一下,这可能不是处理此问题的最佳方法,但目前只是试图解决问题。 理查德


请在保存之前尝试执行以下操作(只是为了处理数据CKEditor http://ckeditor.com本机数据处理器):

    var yourEditor = CKEDITOR.instances.yourEditor;
    // retrieve current data from editor and process it with its dataprocessor
    var formattedDataForWysiWyg = yourEditor.dataProcessor.toHtml(yourEditor.getData());
    // "decode" content processed by ckeditor
    var sourceData = yourEditor.dataProcessor.toDataFormat(formattedDataForWysiWyg);
    // set formatted data back
    yourEditor.setData(sourceData);

当然,如果您经常这样做,性能将会受到影响。

UPDATE:抱歉,我有点误导你了,但是在你提到“{cke_protected}”之后我想起来了。因此,dataProcessor 的“toHtml”方法执行以下操作:修复损坏的 html 并将受保护的元素(脚本、flash)包装到特殊的代码结构中,以禁止通过所见即所得模式进行编辑,但是当相同的 html 应在源模式下显示时,编辑器使用“ dataProcessor 的“toDataFormat”方法,用于删除所有与 ckeditor 相关的代码结构。所以,请参阅上面我的更新。

更新2:新的解决方案适用于 3.6.2 和 3.5.3 版本CKEditor http://ckeditor.com.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 ckeditor 整理 html 的相关文章

  • 在随机位置启动 HTML5

    我有一个大约 2 小时长的音轨 我想在我的网站上使用它 我希望它在页面加载时在随机位置开始播放曲目 使用 HTML5 可以吗 我知道您可以使用 element currentTime 函数来获取当前位置 但是如何在完全下载之前获取曲目的总时
  • 如何在不阻止触摸启动的情况下防止“过度滚动历史导航”?

    我正在实现基于滑动的导航 但我在使用 Chrome 时遇到了麻烦 当页面向右拖动时 会触发新实现的功能 过度滚动历史导航 从而导致跳回 到 历史 1 为了防止这种情况 我必须打电话 preventDefault on touchstart
  • 在javascript中访问函数内的实例变量?

    如何以最简单的方式访问函数内的实例变量 function MyObject Instance variables this handler Methods this enableHandler function var button doc
  • JSP/Servlet HTTP 404 错误处理

    我想在我的网络应用程序中处理 HTML 404 错误 我可以这样写
  • 此页面上的脚本导致 ie 运行缓慢

    问题就在标题中 IE 行为异常 并说有一个脚本运行缓慢 FF 和 Chrome 没有这个问题 我怎样才能找到问题所在 那个页面有很多JS 手动检查不是一个好主意 EDIT 这是我正在处理的一个项目的页面 但我需要一个工具来查找问题 End
  • 访问 nuxt 配置文件中的存储

    我想添加通过 Nuxt 静态生成的动态路由 我定义了一个客户端 服务器端存储asyncData方法 我想将这个存储值 一个数组 映射到我的nuxt config js文件使其成为 动态 静态 路线图nuxt generate命令 但如何访问
  • karma/jasmine 控制台更详细的测试结果

    我使用 Karma 和 Jasmine 进行 javascript 单元测试 假设我有一个失败的测试 如下所示 expect objectA toEqual expectedObjectA 当失败时 我看到控制台上转储了两个对象 并显示一条
  • 全局传递 xhr onload 函数的值

    在我正在创建的应用程序中 我有以下 XMLHttpRequest 并且我正在尝试传递结果data在 的里面xhr onload 到在同一父函数中创建的数组中 var url http api soundcloud com resolve j
  • 为什么在 JavaScript 中 if([]) 被验证而 [] == false ?

    if false alert empty array is false alert alert 0 if alert empty array is true 他们都会运行警报 Demo http jsfiddle net roine ZFD
  • 使用 JQuery 禁用和启用所有超链接

    我有以下禁用所有超链接的内容 但在事件发生后我想再次启用它们 我该如何执行此操作 a click function return false 我认为这不仅仅是将其设置为 true 那么简单 谢谢大家 不要以这种方式绑定 点击 处理程序 而是
  • 如果一个对象结构与另一个对象结构不匹配/不匹配,如何引发异常

    我将读取格式正确的用户输入对象 也就是说 输入对象现在可以具有接口中未定义的任何键或子结构 如果用户提供了无效的对象 我如何抛出异常 预定义接口 export interface InputStructureInterface tableN
  • 如何使跨度标签不可删除?

    我正在尝试使 contenteditable div 内的跨度标记不可删除 div Editable span Read Only span div 只读范围确实是只读的 但我可以通过单击删除键来删除整个范围 有没有一种属性方法可以告诉sp
  • 电话输入自动填充会删除国际前缀

    我有一个类型为 tel 的输入字段 并启用了自动完成功能
  • HTML 代码中的 PHP [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我用 HTML 代码编写了 PHP div div 但这出现在输出页面中 else print 我怎样才能让PHP执行 你的文件有一个 p
  • 如何使用 window.onerror 捕获所有 javascript 错误? (包括道场)

    这个问题是后续问题javascript 如何在弹出警报中显示脚本错误 https stackoverflow com questions 2604976 javascript how to display script errors in
  • 如何通过 jQuery 中的类获取特定 html 元素的innerHTML?

    我有这样的 HTML 代码 div class a html value 1 div div class a html value 2 div 我怎样才能访问html value 1 and html value 2使用jquery 分别地
  • javascript 是否有等效的 __repr__ ?

    我最接近Python的东西repr这是 function User name password this name name this password password User prototype toString function r
  • 适用于移动设备的响应式订单确认电子邮件?

    我从未见过令人惊叹的订单确认 发票电子邮件 即使是最好的 html5 网站也会发送糟糕的订单确认电子邮件 有时是纯文本 我相信这是因为发票通常需要使用表格来显示购买的物品 这在移动设备上实现起来非常困难 我发现了一些让手机上的表格更易于管理
  • CSS 精灵按钮

    这些精灵按钮让我抓狂 我几乎可以让他们工作 但不完全是 我正在玩这个非常简单的精灵图像 我有一个 jsfiddle 项目 gt gt 这里 如果你想看的话 但如果你只想看一下 代码就在下面 http jsfiddle net jp2code
  • 如何在数据列表 HTML PHP 中设置选择

    您好我想知道是否有一种方法可以在数据列表中设置选定的值 我想要这样的东西

随机推荐

  • Ember.js 如何引用 Grunt.js 预编译的 Handlebars 模板?

    我一直在探索 Ember js 以及 Grunt js 但我无法理解 Ember js 如何找到并使用预编译的 Handlebars 模板 现在我的 Gruntfile js 看起来像这样 module exports function g
  • jquery 选择 iframe 子元素

    我正在使用 editArea 库和 jquery 来完成我需要的操作 所以在我的html中有一个iframe标签 editArea使用我需要的是使用jquery访问类似的东西 iframe textarea keydown function
  • 即使使用导航2.2.1后仍然有错误没有当前导航节点

    我尝试过阅读this https stackoverflow com questions 59970818 navcontroller no current navigation node after device rotation但这并不
  • 有没有办法在 Sparx Enterprise Architect 中搜索元素类型?

    模型搜索功能似乎没有办法将结果限制为特定类型 例如Class Node等有没有办法实现呢 我知道我可以编写 SQL 查询 但是无法找到正确的表名 EDIT 看来我可以执行以下操作 Select Object Type AS CLASSTYP
  • 如何修复 CA2100 Review SQL 查询的安全漏洞问题

    我正在分析我的代码并遇到这个安全问题 CA2100 检查 SQL 查询是否存在安全漏洞 传递到 Add item loadgrid 中的 SqlDataAdapter SqlDataAdapter string SqlConnection
  • 使用模型进行 ID 分配

    我尝试使用模型绑定将 ID 分配给选择控件中的项目 但最终出现错误 这是我的代码 Model languages language English locale en language German locale de 选择控制 var o
  • android书签ContentProvider制作书签但在浏览器的书签中不可见

    我正在使用 Android 的浏览器书签 ContentProvider 以编程方式创建新书签 书签已创建 我可以通过 ContentProvider 以编程方式检索它 但书签在浏览器书签视图中不可见 想法 Saving the bookm
  • 如何正确removeFromSuperview?

    苹果说 removeFromSuperview 取消链接 来自其超级视图的接收者及其 窗口 并将其从 响应者链 void 从超级视图中删除 切勿在以下情况下调用此方法 显示 所以 当我想删除一个视图时 我习惯于将它从它的超级视图中删除 为什
  • 操作系统关闭过程中会发生什么?

    我希望这与编程足够相关 操作系统关闭过程中到底发生了什么 我们以开源的 Linux 为例 可能对此有更多的了解 如何 内核线程终止 当计算机处于 清除 状态时 电源是否停止供电 很明显 我所说的清晰状态是指 CPU 中不再发生任何事情 等等
  • 在文档中查找 HTML 字符串

    我想获取所有 HTML p p 在一个文档中 Using Regex使用以下命令查找所有此类字符串 Regex regex new Regex
  • Android Studio“项目结构”未正常显示

    我遵循 Android Studio 安装的所有必要步骤 我也检查过this https stackoverflow com questions 17961397 android studio new project missing fol
  • 在 Dyalog RIDE 中设置条件断点

    In 对话骑行 https github com Dyalog ride 我知道如何设置断点来停止 APL 源代码中特定行的执行 有没有办法使断点有条件 这样只有满足一组特定的条件 我才能在一行处停止 例如0 lt 没有IDE 或RIDE
  • 为什么 iostream 定义了一个 abs 函数,我该如何阻止它?

    以下 C 代码无法编译 int main double a abs 5 1 return 0 它抱怨说abs当然 没有定义 但以下内容确实可以编译 include
  • 如何在保存 Sitecore 项目时显示弹出窗口?

    保存 Sitecore 项目时 我尝试显示一个弹出窗口以与用户交互 根据他们更改的数据 我可能会显示一系列 1 或 2 个弹出窗口 询问他们是否要继续 我已经弄清楚如何利用 OnItemSaving 管道 这很简单 我不知道如何显示弹出窗口
  • 保留提交的JSP表单数据

    我有一个网络表单 JSP 它将数据提交到托管在不同服务器上的不同应用程序 提交表单数据后 该应用程序重定向回同一 JSP 页面 现在 我想保存输入的数据 以网络形式保留提交的数据有哪些不同的方法 我不喜欢将数据存储在数据库或任何文件中 PS
  • 当我在终端中调用 Emacs 错误“无法初始化颜色列表解档器”时

    我刚刚在 MacBook Pro 上安装了 emacs 但是当我在终端中输入 emacs 时 出现以下错误 Emacs x86 64 10 10 5647 247335 无法初始化颜色列表解档器 错误域 NSCocoaErrorDomain
  • AngularJS ui-router $state.go('^') 仅更改地址栏中的 URL,但不加载控制器

    我正在尝试使用 angularjs 创建一个 Todo App ui router 它有 2 列 第一栏 待办事项列表 第 2 列 Todo 详细信息或 Todo 编辑表单 在保存待办事项后的编辑和创建控制器中 我想重新加载列表以显示适当的
  • portaudio.h:没有这样的文件或目录

    我在 ubuntu 16 04 中尝试使用 pip3 安装 pyaudio 时出现以下错误 Collecting pyaudio Downloading PyAudio 0 2 11 tar gz Installing collected
  • python 3.4 谷歌浏览器历史

    我真的被我想做的事情困住了 我想制作一个非常简单的脚本来显示 Google Chrome 的历史记录 当我使用以下代码行时 f open C Users joey AppData Local Google Chrome User Data
  • 使用 ckeditor 整理 html

    您好 我在 ckeditor 方面遇到了一个小问题 基本上我需要让编辑器运行它的 html 清理命令 有什么办法可以做到这一点吗 目前 在我在源代码中输入一些内容然后按保存后 它似乎没有运行我希望它像在 正常 编辑器视图中那样整理 html