CKEDITOR使用与配置

【Django富文本编辑】Ckeditor的配置、使用和踩坑(应该全) 目录 一、基本应用 1.安装 2.配置ckeditor 3.models字段使用,引用步骤2中的ckeditor配置 4.forms字段使用 5.admin后台使用 二、前端应用 1.基本使用中的全部执行完后可以设置前端页面了(没有步骤5也可以) 2.urls路由 3.views配置 4.html页面配置 5.post后台处理数据 三、带图片上传的编辑器 1.安装pillow(所有屠屏功能都需要这个库) 2.添加配置ckeditor 3.urls文件配置 4.修改modes 阅读详情

安装:

  下载CKEDITOR的文件,解压后复制到工程的WEBROOT目录下就OK!

引用CKEDITOR的JS文件:

  新建JSP页面,添加其JS文件<script type="text/javascript" src="ckeditor/ckeditor.js"></script>

  注意:1.src的路径。

     2.不要写成<script type="text/javascript" src="ckeditor/ckeditor.js />样式,在现有的3.0.1版本中会出现CKEDITOR未定义的脚本错误提示,致使不能生成编辑器。

替换TEXTAREA标签:

 

CKEDITOR.replace( 'editor1',     {         customConfig : ''     });
 
  

This setting is definitely recommended if you are not setting configurations in the config.js file nor a custom configuration file.

这段就不翻译了,so,easy!

 

配置个性化工具栏:

 

A toolbar definition is a JavaScript array that contains the elements to be displayed in all "toolbar rows" available in the editor. There are two ways to set the desired toolbar definition in the editor. It can be set directly into the "toolbar" setting, or it can instead be set to a configuration named "toolbar_<name>", where "<name>" is a name that can be used to identify the toolbar in the "toolbar" setting. The following is the default setting we have in the editor.

上面的英文太罗嗦了说重点算了:工具栏是通过数组来设定的,工具栏的名字以toolbar_<name>的方式命名,其中的<name>是用来赋值给config.toolbar这一变量的。

那么以下代码定义了toolbar_Full和toolbar_Basic的两种工具栏配置,并使用了config.toolbar = 'Full';定义当前的编辑器的工具栏为Full。

其中("-") 为空间栏的水平分割,("/") 为换行。

Code
CKEDITOR.replace( 'editor1',     {         toolbar : 'MyToolbar'     }); CKEDITOR.replace( 'editor2',     {         toolbar : 'Basic'     });
复制代码
 
  

It's also possible to set the toolbar definition in-page, when creating the editor instance directly. In that case, just assign it to the toolbar setting directly, for example:

也可以通过IN-PAGE的方式定义工具栏参数。

   
Code CKEDITOR.replace( 'editor1',     {         toolbar :         [             ['Styles', 'Format'],             ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', '-', 'About']         ]     });

 The Styles Definition

The styles definition is a JavaScript array which is registered by calling the CKEDITOR.addStylesSet() function. A unique name must be assigned to your style definition, so you can later set each editor instance to load it. It means that you can have a single style definition which is shared by several editor instances present on the page.

The following is a sample style definition registration:

通过CKEDITOR.addStylesSet() 函数,我们可以定义一个样式,结合以下的例子,my_styles为样式的名称,具体的样式为一个JAVASCRIPT数组。通过样式的名称我可以让页面的多个编辑器应用该样式。

   
Code CKEDITOR.addStylesSet( 'my_styles', [     // Block Styles     { name : 'Blue Title', element : 'h2', styles : { 'color' : 'Blue' } },     { name : 'Red Title' , element : 'h3', styles : { 'color' : 'Red' } },     // Inline Styles     { name : 'CSS Style', element : 'span', attributes : { 'class' : 'my_style' } },     { name : 'Marker: Yellow', element : 'span', styles : { 'background-color' : 'Yellow' } } ]);

The above definition registration can be placed inline in the page using the editor, or can even live in an external file, which is loaded "on demand", when needed only (see below).

样式可以通过IN-PAGE或配置文件中进行注册。

After that, you must instruct the editor to use your newly registered style definition by using the stylesCombo_stylesSet setting. This may be set into the config.js file, for example:

你可以通过在config.js 加入以下代码使编辑器应用该样式:

   
config.stylesCombo_stylesSet = 'my_styles';

 

Using an External Styles Definition File 使用自定义的样式文件

You can include the above styles definition registration call into an external JavaScript file. This is the preferred way for it because it will be loaded only when opening the Styles selection box, enhancing the page loading performance. Users may feel a small loading gap because of it though.

By default, the editor uses the "plugins/stylescombo/styles/default.js" file, which is a "minified" JavaScript file. You can find the uncompressed version of it at "_source/plugins/stylescombo/styles/default.js". You can see it online at our SVN also: http://svn.fckeditor.net/CKEditor/trunk/_source/plugins/stylescombo/styles/default.js. It can be used as a template for your custom file.

Your style definition file can be saved anywhere at your web site (or the web). You must just know the URL to reach it. For example, you can save at it at the root of your web site, so you can reach it with "/styles.js", or even place it in a central web site, so you can locate it with "http://www.example.com/styles.js". At that point, simply change the stylesCombo_stylesSet setting to point the editor to your file:

默认的样式文件在"_source/plugins/stylescombo/styles/default.js"目录中,我们也可以自己定义一个样式文件,如在站点的跟目录中有styles.js这一个样式文件,这个文件通过以下代码指定其路径:

   
config.stylesCombo_stylesSet = 'my_styles:/styles.js'; OR config.stylesCombo_stylesSet = 'my_styles:http://www.example.com/styles.js';

Style Rules

The entries inside a style definition are called "style rules". Each rule defines the display name for a single style as well as the element, attributes and css styles to be used for it. The following is the generic representation for it:

   
Code {     name : 'Display name',     element : 'tag name (for example "span")',     styles :     {         'css-style1' : 'desired value',         'css-style2' : 'desired value',              }     attributes :     {         'attribute-name1' : 'desired value',         'attribute-name2' : 'desired value',              } }

The "name" and "element" values are required, while other values are optional.

 

Style Types

There are three types of style types, each one related to the element used in the style rule:

  • Block styles: applied to the text blocks (paragraphs) as a whole, not limited to the text selection. The elements values for that are: address, div, h1, h2, h3, h4, h5, h6, p and pre.
  • Object styles: applied to special selectable objects (not textual), whenever such selection is supported by the browser. The elements values for that are: a, embed, hr, img, li, object, ol, table, td, tr and ul.
  • Inline styles: applied to text selections for style rules using elements not defined in the other style types.

Output Formatting

 The HTML Writer

这个是用来对各种标签的排版进行设定的

Technically speaking, writing the final output is a task executed by the CKEDITOR.htmlWriter class ("writer"), used by the CKEDITOR.htmlDataProcessor class. Therefore, the current writer instance for a specific editor instance can be retrieved by the <editorInstance>.dataProcessor.writer property.

By setting the writer properties, it's possible to configure several output formatting options. The following example is the best way to summarize the most used of them, with their default values:

   
Code var writer = editor.dataProcessor.write; // The character sequence to use for every indentation step. writer.indentationChars = '\t'; // The way to close self closing tags, like <br />. writer.selfClosingEnd = ' />'; // The character sequence to be used for line breaks. writer.lineBreakChars = '\n'; // Set writing rules for the <p> tag. writer.setRules( 'p',     {         // Indicates that this tag causes indentation on line breaks inside of it.         indent : true,         // Insert a line break before the <p> tag.         breakBeforeOpen : true,         // Insert a line break after the <p> tag.         breakAfterOpen : true,         // Insert a line break before the </p> closing tag.         breakBeforeClose : false,         // Insert a line break after the </p> closing tag.         breakAfterClose : true     });

 

Setting Writer Rules

Because the writer is a property of each editor instance, and also because it's dependency on the writer plugin to be loaded, the best way to make changes to it is by listening to the "instanceReady" event, so it's safe to assume that the dataProcessor property will be loaded and ready to changes. The following is an example of it, when creating an editor instance:

可以为单一得编辑器指定标签的格式。

   
Code CKEDITOR.replace( 'editor1',     {         on :         {             instanceReady : function( ev )             {                 // Output paragraphs as <p>Text</p>.                 this.dataProcessor.writer.setRules( 'p',                     {                         indent : false,                         breakBeforeOpen : true,                         breakAfterOpen : false,                         breakBeforeClose : false,                         breakAfterClose : true                     });             }         }     });

Another way for it is by using the CKEDITOR object, so all editor instances will be changed:

也可以对所有的编辑器进行设定。

   
CKEDITOR.on( 'instanceReady', function( ev )     {         // Out self closing tags the HTML4 way, like  < br > .         ev.editor.dataProcessor.writer.selfClosingEnd = '>';     });
【前端HTML生成条形码——MQ】 本文将展示前端HTML如何根据用户输入内容生成对应的条形码,附HTML和JS代码。代码如下(示例): 阅读详情

相关推荐

移相变压器Simulink建模与HVDC系统仿真实践

移相变压器是电力电子领域实现精确相位调节的核心设备,其通过特殊绕组设计改变输出电压相位角,在解决环网潮流不均、阻尼功率振荡等场景具有关键作用。本文基于MATLAB/Simulink环境,详细解析移相变压器的建模原理与技术实现,包括磁路耦合特性模拟、参数计算方法和控制策略设计。针对HVDC高压直流输电和FACTS柔性交流输电系统等典型应用,提供仿真模型搭建技巧与问题排查指南,特别涵盖新能源并网场景下的相位调节优化方案。通过实测数据验证,所建模型在稳态精度和动态响应方面均满足工程要求,为电力系统稳定性分析提供有

weixin_28278377的博客 271

CKEditor配置及使用

注:使用CKEditor版本为js版本的CKEditor 4,所有配置均参考自CKEditor官方API:http://docs.ckeditor.com/,以及实践经验 一、快速使用 1、引入CKEditor的js文件 // 当此文件载入完毕之后,CKEditor的JavaScript API就已准备就绪,可以使用 <script src="ckeditor/cked...

aby2106的博客 1467

Python-Opencv中的膨胀和腐蚀

Python-Opencv中的膨胀和腐蚀 腐蚀和膨胀是对白色部分(高亮部分)而言的,不是黑色部分。 膨胀就是图像中的高亮部分进行膨胀,“邻域扩张”,效果图拥有比原图更大的高亮区域。腐蚀就是原图中高亮部分被腐蚀,“邻域被蚕食”,效果图拥有比原图更小的高亮区域。 1.膨胀 膨胀过程是有一个结构元素或者模板去在原图像素比对,当比对过程中,中心像素位置的值根据其八邻域取或运算,或运算为1就取自己的中心值,...

qq_44262417的博客 1万+

ckeditor快速使用

参考来源: http://www.cnblogs.com/Fskjb/archive/2009/11/16/1603461.html http://blog.youkuaiyun.com/xiao__gui/article/details/7684505

素履之往 756

PS/2鼠标接口协议

一、PS/2鼠标接口        PS/2接口用于许多现代的鼠标和键盘,由IBM最初开发和使用。物理上的PS/2接口有两种类型的连接器:5脚的DIN和6脚的MINI-DIN。        二、鼠标的接口协议原理             PS/2鼠标接口采用一种双向同步串行协议。即每在时钟线上发一个脉冲,就在数据线上发送一位数据。但是在相互传输中 ,主机是拥有总线控制权的

Ant's home 1万+

保姆级教程:在Zynq UltraScale+ EV系列FPGA上,用VCU IP核搞定4K60帧H265视频解码与HDMI2.0输出

本文提供在Zynq UltraScale+ EV系列FPGA上使用VCU IP核实现4K60帧H265视频解码与HDMI2.0输出的全流程指南。从开发环境准备、Vivado工程配置到PetaLinux系统定制,详细解析硬件选型、IP核参数设置及性能优化技巧,帮助开发者快速构建高效视频处理系统。

weixin_30800987的博客 432

初次使用CKeditor replace使用方法

1. 官网下载CKeditor ,解压后粘贴到项目中 2.查看ck自带的案例, 导入相应的js 和css   /ckeditor/ckeditor.js"> 3. 替换文本域即可 textarea class="ckeditor" cols="50" id="editor1" rows="100" name="goodsdesc">textarea> 4.显示的

太快的幸福,措手不及 8830

WSL2迁移后用户名不见了?一招教你快速恢复Ubuntu22.04默认用户

本文针对WSL2迁移后Ubuntu 22.04默认用户名丢失的常见问题,提供了详细的诊断与修复方案。通过分析迁移底层逻辑,指导用户使用`ubuntu2204.exe config --default-user`命令或配置`/etc/wsl.conf`文件快速恢复用户身份,并涵盖权限修复、冲突解决及自动化迁移脚本等进阶内容,确保子系统迁移后环境完整可用。

web39explorer的博客 558

ckeditor富文本编辑器使用

CKEditor 是新一代的 FCKeditor,是一个重新开发的版本。CKEditor 是全球最优秀的网页在线文字编辑器之一,因其惊人的性能与可扩展性而广泛的被运用于各大网站。 本文使用的github中名为es-ckeditor包含大量功能,包含数学运算...谁用到了更多好用的功能,记得艾特我,我也不会。 效果图: 如何使用: 1.github搜索es-ckeditor下载,这是有大牛搞好的包含一批插件的ckeditor; 2.创建页面引入ckeditor <!DOCTYPE

鱼儿眼中的海 1267

Zabbix Trigger actions访问出现500

本篇博客详细介绍了Zabbix访问'Trigger actions'出现的错误状况,访问界面出现500,并提供了解决方案。

格子的博客 562

被搜狗输入法背刺了!偷偷装的 “AI 汪仔” 狂占 CPU!手把手教你如何彻底关闭删除搜狗AI功能AI汪仔

手把手教你如何彻底关闭删除搜狗输入法的AI汪仔🚀

XiaoqiangClub的博客 2万+

CKEDITOR配置

安装:   下载CKEDITOR的文件,解压后复制到工程的WEBROOT目录下就OK! 引用CKEDITOR的JS文件:   新建JSP页面,添加其JS文件   注意:1.src的路径。      2.不要写成样式,在现有的3.0.1版本中会出现CKEDITOR未定义的脚本错误提示,致使不能生成编辑器。 替换TEXTAREA标签: CKEDITOR.replace( 'e

shuchangwen的专栏 622

【Qt开发】管理OpenGL上下文QOpenGLContext类及应用实践示例代码

QOpenGLContext 提供了一个简单、高效的接口来管理 OpenGL 上下文。本文详细介绍了 QOpenGLContext 的基本功能、常用方法、信号槽机制、高级应用技巧及常见问题的解决方法。通过这些介绍,读者可以更好地掌握和利用 QOpenGLContext 进行 OpenGL 渲染和管理实验。对于有特殊需求的开发者,也可以通过探索更多高级设置和优化策略,以满足具体的应用场景。

科技改变人类,技术成就未来 1875

ckeditor的详细配置

一、使用方法: 1、在页面中引入ckeditor核心文件ckeditor.js cript" src="ckeditor/ckeditor.js"> 2、在使用编辑器的地方插入HTML控件 如果是ASP.NET环境,也可用服务器端控件 注意在控件中加上 class="ckeditor" 。 3、将相应的控件替换成编辑器代码 cript"> CKEDITOR.replace(

trialwalker的专栏 567

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

CKEditor配置使用

一.使用方法 引入ckeditor核心文件ckeditor.js 在使用编辑器的地方插入HTML控件 二.配置编辑器 ckeditor的配置都集中在 ckeditor/config.js 文件中,下面是一些常用的配置参数: // 界面语言,默认为 'en' config.language = 'zh-cn'; // 设置宽高 config.width

ChibiMarukoChan的博客 577

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

CKEditor配置

CKeditor 配置使用 CKeditor 配置使用 一、使用方法: 1、在页面中引入ckeditor核心文件ckeditor.js 2、在使用编辑器的地方插入HTML控件 如果是ASP.NET环境,也可用服务器端控件 注意在控件中加上 class="ckeditor" 。 3、将相应的控件替换成编辑器代码     CKEDITOR.r

u014394255的博客 619

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

ckeditor配置设置

1return top editor具有丰富的配置来定制它的用户界面,特性和功能,主要的配置文件名为“config.js”。它在CKEditor安装文件夹的根目录上。 Power by xuan at 2009-11-03 11:41 2return top 可用的配置选项

Yedy2000的专栏 3174

ckeditor 配置

一、使用方法: 1、在页面中引入ckeditor核心文件ckeditor.js 2、在使用编辑器的地方插入HTML控件 如果是ASP.NET环境,也可用服务器端控件 注意在控件中加上 。 3、将相应的控件替换成编辑器代码     CKEDITOR.replace(‘TextArea1′); //如果是在ASP.NE

zh_fn的专栏 947

CKeditor配置

文件上传 下载PHP上传代码文件”imgupload.php”; 把下载的 imgupload.php 文件移动到 ckeditor/plugins/image/ 里; 修改 imgupload.php 里的 $upload_dir 为项目完整上传图片路径,如项目 test ,则改为 /test/uploads/ckeditor/; 最好紧接着 $upload_dir 下一行判断创建目录:if( !

William-A 840

CKEditor详细配置

<br />CKEditor是一个文本编辑器是内部的网页使用。这是一个所见即所得的编辑器,这意味着上的案文是编辑看起来尽可能的用户提供类似的结果时发表。它带来了网络上常见的编辑功能,如微软Word和OpenOffice桌面编辑应用程序中。由于CKEditor正在灵活的开放源代码和商业授权协议,您就可以使用内部集成和任何类型的应用程序了。这是理想的编辑器的开发,制造,提供方便和强大的解决方案,以他们的用户。<br />CKEditor与WordCKEditor不是像微软的Word或OpenOffice桌面应用

fjun0910的专栏 693

CKEDITOR config.js配置

CKEditor配置使用ckeditor 的官方网站是 http://ckeditor.com/ ,当前使用的版本是v3.0.1。一、使用方法:1、在页面中引入ckeditor核心文件ckeditor.js2、在使用编辑器的地方插入HTML控件如果是ASP.NET环境,也可用服务器端控件注意在控件中加上 class="ckeditor" 。3、将相应的控

Herr Apfel的专栏 3万+

ckeditor2详细配置

<br />一、使用方法:<br />1、在页面<head>中引入ckeditor核心文件ckeditor.js<br /><script type="text/javascript" src="ckeditor/ckeditor.js"></script><br />2、在使用编辑器的地方插入HTML控件<textarea><br /><textarea id="TextArea1" cols="20" rows="2" class="ckeditor"></textarea><br />如果是ASP.N

jingjingzhanghy的专栏 561

CKeditor 配置使用

CKeditor 配置使用 一、使用方法: 1、在页面中引入ckeditor核心文件ckeditor.js 2、在使用编辑器的地方插入HTML控件 如果是ASP.NET环境,也可用服务器端控件 注意在控件中加上 class="ckeditor" 。 3、将相应的控件替换成编辑器代码     CKEDITOR.replace('T

xmlife的专栏 789
上一篇: select top多出几条数据
下一篇: 清除浮动的几种写法
richlu2011
博客等级 码龄15年 2粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值