多种 网页文本编辑器 分析(一)

2014-11-24 08:19:57 · 作者: · 浏览: 2

文本编辑器应用总结

一. lhgeditor文本编辑器

lhgeditor组件文件结构:

1. lhgeditor.js: 组件的核心JS文件

2. lhgeditor.css:组件的样式表文件

3. images:组件所需的图片都在此文件夹中

以上三个文件为组件所必须的三个文件,组件包中其它以“_”开头的文件为示例的演示文件,实际使用中不需要这些文件。当然框架核心文件lhgcore.js是每个组件都必须用到的文件,记得加载组件前先要加载此文件。

lhgeditor组件使用说明:

1. 在调用组件的页面加载lhgcore.js和lhgeditor.js两个文件。

2. 在window.onload函数里加入J.editor.add(编辑器的id).init();

例:

<script type="text/java script">

window.onload = function()

{

J.editor.add('elm1').init();

}


\

< http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+IDwvcD4KPHA+tv6jriBuaWNFZGl0zsSxvrHgvK3G9zwvcD4KPHA+Jmx0O3NjcmlwdCB0eXBlPQ=="text/java script">

bkLib.onDomLoaded(function() {

new nicEditor().panelInstance('area1');

new nicEditor({fullPanel : true}).panelInstance('area2');

new nicEditor({iconsPath : '../nicEditorIcons.gif'}).panelInstance('area3');

new nicEditor({buttonList :['fontSize','bold','italic','underline','strikeThrough','subscript',

' superscript','html','image']}).panelInstance('area4');

new nicEditor({maxHeight : 100}).panelInstance('area5');

});

//默认模式

//new nicEditor().panelInstance('area1');


//All Available Buttons

//new nicEditor({fullPanel : true}).panelInstance('area2');

\

//new nicEditor({iconsPath : "../nicEditorIcons.gif'}).panelInstance('area3');



//自定义按钮

//new nicEditor({buttonList :['fontSize','bold','italic','underline','strikeThrough','subscript',

'superscript','html','image']}).panelInstance('area4');




//设置文本编辑器的最大高度

//new nicEditor({maxHeight : 100}).panelInstance('area5');




三. kindeditor文本编辑器

(1) 支持多种语言php、asp

(2) 功能强大

默认模式

<script charset="utf-8" src="../kindeditor-min.js">

<script charset="utf-8" src="../lang/zh_CN.js">

<script>

var editor;

KindEditor.ready(function(K) {

editor = K.create('textarea[name="content"]', {

resizeType : 1,

allowPreviewEmoticons : false,

allowImageUpload : false,

items : ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic','underline','removeformat', '|', 'justifyleft','justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist', '|', 'emoticons', 'image', 'link']

});

});

\


Multi Language Examples(多语言)

<script charset="utf-8" src="../kindeditor-min.js">

<script>

var editor;

KindEditor.ready(function(K) {

K('select[name=lang]').change(function() {

if (editor) {

editor.remove();

editor = null;

}

editor = K.create('textarea[name="content"]', {

langType : this.value

});

});

K('select[name=lang]').change();

});

\


粘贴设置:

<script charset="utf-8" src="../kindeditor-min.js">

<script charset="utf-8" src="../lang/zh_CN.js">

<script>

KindEditor.ready(function(K) {

K.create('#content1', {

pasteType : 0

});

K.create('#content2', {

pasteType : 1

});

K.create('#content3', {

pasteType : 2

});

});

禁止粘贴




纯文本粘贴




HTML粘贴




自定义插件

<script charset="utf-8" src="../kindeditor-min.js">

<script charset="utf-8" src="../lang/zh_CN.js">

<script>

// 自定义插件 #1

KindEditor.lang({

example1 : '插入HTML'

});

KindEditor.plugin('example1', function(K) {

var self = this, name = 'example1';

self.clickToolbar(na