fckeditor代码总结

多数都是在网上copy的,只是自己整理下,方便以后查看

 

1、特殊字符:/editor/dialog/fck_specialchar.“var aChars = ” 在其里面添加,注意逗号及引号。
2、模版:根目录下的fcktemplates.xml,在其内按照预提供的格式,添加自己想要的模版即可。

3、修改快捷方式:fckconfig.js下找到FCKConfig.Keystrokes,在其里面添加如下[ CTRL + 68 /*D*/, 'executejs' ],

     注意逗号,65是A,以此类推D是68。

 

 

在按钮旁边加文字
-------------------------------------
打开 editor/js/ 两个js文件
fckeditorcode_gecko.js
fckeditorcode_ie.js

第一个是支持非ie浏览器的
第二个文件是支持ie浏览器的

搜索 FCKToolbarButton,可以看到许多类似这样的语句:
case 'Save':B = new FCKToolbarButton('Save', FCKLang.Save, null, null, true, null, 3); break;

'Save'是按钮英文名字
FCKToolbarButton 的四个参数分别是:
按钮命令名称,按钮标签文字,按钮工具提示,按钮样式,按钮是否在源代码模式可见,按钮下拉菜单其中将第4项参数设置为 FCK_TOOLBARITEM_ICONTEXT 即可使按钮旁边出现文字,注意没有引号。
例如:
case 'Preview':B = new FCKToolbarButton('Preview', FCKLang.Preview, null, FCK_TOOLBARITEM_ICONTEXT, true, null, 5);
这样我们就可以将 我们经常用的3种模式源代码、预览、全屏编辑按钮都加上文字了。

解释fck样式的工作原理
-------------------------------------
fck的样式设置涉及到了两个文件,一个是你定义好的样式表文件.css,另一个是告诉fck样式表如何使用的xml文件,两个文件确一不可。
css文件的位置是不做要求的,但是需要你在应用的编辑器的页面上插入样式表文件的链接。这样才能显示出来样式。
fckstyles.xml 在与editor目录同级的目录下。该文件定义了那些样式可以使用在那些标签里面。

这就是fck自带的样式xml定义:
<?xml version="1.0" encoding="utf-8" ?>
<Styles>
  <Style name="Image on Left" element="img">
    <Attribute name="style" value="padding: 5px; margin-right: 5px" />
    <Attribute name="border" value="2" />
    <Attribute name="align" value="left" />
  </Style>
  <Style name="Image on Right" element="img">
    <Attribute name="style" value="padding: 5px; margin-left: 5px" />
    <Attribute name="border" value="2" />
    <Attribute name="align" value="right" />
  </Style>
  <Style name="Custom Bold" element="span">
    <Attribute name="style" value="font-weight: bold;" />
  </Style>
  <Style name="Custom Italic" element="em" />
  <Style name="Title" element="span">
    <Attribute name="class" value="Title" />
  </Style>
  <Style name="Code" element="span">
    <Attribute name="class" value="Code" />
  </Style>
  <Style name="Title H3" element="h3" />
  <Style name="Custom Ruler" element="hr">
    <Attribute name="size" value="1" />
    <Attribute name="color" value="#ff0000" />
  </Style>
</Styles>

每 一个<style>将来会生成一个样式的菜单项。name名称就是显示在菜单里的文字;element定义了该样式可以应用在那种html标 签上,<Attribute>的 name 指定了将会修改标签的哪个属性来应用样式,value则是修改成的值。
看这个:
<Style name="Title" element="span">
  <Attribute name="class" value="Title" />
</Style>

如 果你在fck选定了文字 "经典论坛 > 前台制作与脚本专栏 > FCKeditor 实战技巧 - 1 > 编辑帖子" 应用该样式 则原来文字就会变成<span class="Title">经典论坛 > 前台制作与脚本专栏 > FCKeditor 实战技巧 - 1 > 编辑帖子</span>

注意:如果编辑器呈整页编辑状态,那么整页里面也需要插入样式表链接才能显示出来样式。

============================================

FCKeditor Javascript API(翻译整理)
原文地址:http://wiki.fckeditor.net/Developer%27s_Guide/Javascript_API
--------------------------------------------
FCK 编辑器加载后,将会注册一个全局的 FCKeditorAPI 对象。

FCKeditorAPI 对象在页面加载期间是无效的,直到页面加载完成。如果需要交互式地知道 FCK 编辑器已经加载完成,可使用"FCKeditor_OnComplete"函数。
<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance) {
  FCKeditorAPI.GetInstance('FCKeditor1').Commands.GetCommand('FitWindow').Execute();
}
</script>

在当前页获得 FCK 编辑器实例:
var Editor = FCKeditorAPI.GetInstance('InstanceName');

从 FCK 编辑器的弹出窗口中获得 FCK 编辑器实例:
var Editor = window.parent.InnerDialogLoaded().FCK;

从框架页面的子框架中获得其它子框架的 FCK 编辑器实例:
var Editor = window.FrameName.FCKeditorAPI.GetInstance('InstanceName');

从页面弹出窗口中获得父窗口的 FCK 编辑器实例:
var Editor = opener.FCKeditorAPI.GetInstance('InstanceName');

获得 FCK 编辑器的内容:
oEditor.GetXHTML(formatted); // formatted 为:true|false,表示是否按HTML格式取出
也可用:
oEditor.GetXHTML();

设置 FCK 编辑器的内容:
oEditor.SetHTML("content", false); // 第二个参数为:true|false,是否以所见即所得方式设置其内容。此方法常用于"设置初始值"或"表单重置"哦作。

插入内容到 FCK 编辑器:
oEditor.InsertHtml("html"); // "html"为HTML文本

检查 FCK 编辑器内容是否发生变化:
oEditor.IsDirty();

在 FCK 编辑器之外调用 FCK 编辑器工具条命令:
命令列表如下:
--------------------------------------------
DocProps, Templates, Link, Unlink, Anchor, BulletedList, NumberedList, About, Find, Replace, Image, Flash, SpecialChar, Smiley, Table, TableProp, TableCellProp, UniversalKey, Style, FontName, FontSize, FontFormat, Source, Preview, Save, NewPage, PageBreak, TextColor, BGColor, PasteText, PasteWord, TableInsertRow, TableDeleteRows, TableInsertColumn, TableDeleteColumns, TableInsertCell, TableDeleteCells, TableMergeCells, TableSplitCell, TableDelete, Form, Checkbox, Radio, TextField, Textarea, HiddenField, Button, Select, ImageButton, SpellCheck, FitWindow, Undo, Redo
--------------------------------------------
使用方法如下:
--------------------------------------------
oEditor.Commands.GetCommand('FitWindow').Execute();
------------------------------------------

转载于:https://www.cnblogs.com/DennisChen/archive/2010/07/22/1532010.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值