FCKEditor插件(自动排版)移植至CKEditor下,高分求救(急)

ee365ee 2010-11-23 05:23:50
公司网站要将FCKEditor编辑器升级至CKEditor,同时希望将插件也一并移植,难度不大,但是我英文很不好,试了很久都不成功!希望各位前辈帮忙.(Email:170238168@qq.com)
贴出部分代码
//格式化
function FormatText(bodyname) {
var myeditor = FCKeditorAPI.GetInstance(bodyname);
if (myeditor.EditMode==FCK_EDITMODE_WYSIWYG){
var temps = new Array();

isPart = false; //暂时无法实现局部格式化
if (!isPart) {
var imgs = FCKeditorAPI.GetInstance(bodyname).EditorDocument.images;
if (imgs != null && imgs.length > 0) {
for (j = 0; j < imgs.length; j++) {
var t = document.createElement("IMG");
t.alt = imgs[j].alt;
t.src = imgs[j].src;
t.width = imgs[j].width;
t.height = imgs[j].height;
t.align = imgs[j].align;
temps[temps.length] = t;
}
var formatImgCount = 0;
for (j = 0; j < imgs.length;) {
imgs[j].outerHTML = "#FormatImgID_" + formatImgCount + "#";
formatImgCount++;
}
}
var strongarray = new Array();
var strongcount = 0;
for(var i=0;i<myeditor.EditorDocument.body.getElementsByTagName('b').length;i++){
strongarray[strongcount] = myeditor.EditorDocument.body.getElementsByTagName('b')[i].innerText.trim();
myeditor.EditorDocument.body.getElementsByTagName('b')[i].innerHTML = "#FormatStrongID_" + strongcount + "#";
strongcount++;
}

for(var i=0;i<myeditor.EditorDocument.body.getElementsByTagName('strong').length;i++){
strongarray[strongcount] = myeditor.EditorDocument.body.getElementsByTagName('strong')[i].innerText.trim();
myeditor.EditorDocument.body.getElementsByTagName('strong')[i].innerHTML = "#FormatStrongID_" + strongcount + "#";
strongcount++;
}

var html = processFormatText(myeditor.EditorDocument.body.innerText);
if (temps != null && temps.length > 0) {
for (j = 0; j < temps.length; j++) {
var imghtml = "<p align=\"center\"><img src=\"" + temps[j].src + "\" alt=\"" + temps[j].alt + "\" width=\"" + temps[j].width + "\" height=\"" + temps[j].height + "\" align=\"" + temps[j].align + "\" border=\"0\"></p>";
html = html.replace("#FormatImgID_" + j + "#", imghtml);
}
}

for(var i=0;i<strongcount;i++){
html = html.replace("#FormatStrongID_" + i + "#", "<strong>"+strongarray[i]+"</strong>");
}

while(html.indexOf("</p></p>")!=-1) html=html.replace("</p></p>","</p>");
while(html.indexOf('<p><p align="center">')!=-1) html=html.replace('<p><p align="center">','<p align="center">');

SetEditorContents(bodyname, html);

} else {

}
}else{
alert('必须在设计模式下操作!');
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////

FCK编辑器增强插件
http://www.ittang.com/down/2010/0322/11393.html

CKEditor API(英文版)
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.html
...全文
617 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
s91201314 2012-02-02
  • 打赏
  • 举报
回复
lz,那个FCKeditor 自动排版的能发我吗?
swcml 2011-06-24
  • 打赏
  • 举报
回复
怎么搞定的啊?
ben6627 2011-04-02
  • 打赏
  • 举报
回复
看看隐藏的回复
liyuqianmao 2010-11-27
  • 打赏
  • 举报
回复
很好很强大
ee365ee 2010-11-26
  • 打赏
  • 举报
回复
我搞定了,不会用API,咱就不用了!把CK中的HTML取出来,放到创建的DIV对象中,然后就随心所欲了!
binlonghuang 2010-11-25
  • 打赏
  • 举报
回复
郁闷中,我也在搞这个,已经可以简->繁转换,插入分面符了,但自动排版函数中的:FCKeditorAPI.GetInstance(bodyname).EditorDocument.images功能的函数
在CKeditor的API中找不到,无法到到图片数组。搞不下去了,期望交流。
leehuat 2010-11-24
  • 打赏
  • 举报
回复

<html><head> <title>Sample - CKEditor</title> <script type="text/javascript" src="/ckeditor/ckeditor.js"></script></head><body> <form method="post"> <p> My Editor:<br /> <textarea name="editor1"><p>Initial value.</p></textarea> <script type="text/javascript">CKEDITOR.replace( 'editor1' );</script> </p> <p> <input type="submit" /> </p> </form></body></html>

ee365ee 2010-11-24
  • 打赏
  • 举报
回复
回4楼,我知道如何调用CKEditor,问题是CKEditor/FCKEditor两者的API不同了,插件没法正常使用
ee365ee 2010-11-23
  • 打赏
  • 举报
回复
没有人帮忙吗?
ee365ee 2010-11-23
  • 打赏
  • 举报
回复
急顶啊急顶啊

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧