iceEditor富文本编辑器 v1.1.9

iceEditor是一款简约风格的富文本编辑器,体型十分娇小,无任何依赖,整个编辑器只有一个文件,功能却很不平凡!简约的唯美设计,简洁、极速、使用它的时候不需要引用jQuery、font、css……等文件,因为整个编辑器只是一个Js,支持上传图片、附件!支持添加音乐、视频!


优点

纯原生开发,无任何依赖,冰清玉洁

响应式布局,适应任何分辨率的设备

整个编辑器只有一个文件,高效便捷

简约的唯美设计,简洁、极速


提示

iceui 前端框架已经已集成该编辑器。


注意

iceEditor.js的引用禁止放在head标签内,请尽量放在body中或body后面!


使用

<!-- 也可以直接使用textarea,放在form表单中可以直接提交 -->
<!-- <textarea id="editor" name="content"> 欢迎使用iceEditor富文本编辑器 </textarea> -->
<div id="editor"> 欢迎使用iceEditor富文本编辑器 </div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/iceuinet/iceEditor/src/iceEditor.min.js"></script>


//第一步:创建实例化对象
var e = new ice.editor('content');
//第二步:配置图片或附件上传提交表单的路径
//如果你的项目使用的php开发,可直接使用upload.php文件
//其它的编程语言需要你单独处理,后期我会放出.net java等语言代码
//具体与你平常处理multipart/form-data类型的表单一样
//唯一需要注意的就是:处理表单成功后要返回json格式字符串,不能包含其它多余的信息:
//url:文件的地址
//name:文件的名称(包含后缀)
//error:上传成功为0,其它为错误信息,将以弹窗形式提醒用户
//例如批量上传了两张图片:
//[
// {url:'/upload/img/153444.jpg', name:'153444.jpg', error:0},
// {url:'/upload/img/153445.jpg', name:'153445.jpg', error:'禁止该文件类型上传'}
//]
e.uploadUrl="/iceEditor/src/upload.php";
//第三步:配置菜单(默认加载全部,无需配置)
e.menu = [
  'backColor',                 //字体背景颜色
  'fontSize',                  //字体大小
  'foreColor',                 //字体颜色
  'bold',                      //粗体
  'italic',                    //斜体
  'underline',                 //下划线
  'strikeThrough',             //删除线
  'justifyLeft',               //左对齐
  'justifyCenter',             //居中对齐
  'justifyRight',              //右对齐
  'indent',                    //增加缩进
  'outdent',                   //减少缩进
  'insertOrderedList',         //有序列表
  'insertUnorderedList',       //无序列表
  'superscript',               //上标
  'subscript',                 //下标
  'createLink',                //创建连接
  'unlink',                    //取消连接
  'hr',                        //水平线
  'table',                     //表格
  'files',                     //附件
  'music',                     //音乐
  'video',                     //视频
  'insertImage',               //图片
  'removeFormat',              //格式化样式
  'code',                      //源码
  'line'                       //菜单分割线
];
//第四步:创建
e.create();

设置编辑器尺寸

var e = new ice.editor('content');
e.width='700px';   //宽度
e.height='300px';  //高度
e.create();

禁用编辑器

//初始化过程中的禁用方式
var e = new ice.editor('content');
e.disabled=true;
e.create();
//通过方法禁用输入
e.inputDisabled();
//取消禁用,恢复输入状态
e.inputEnable();

获取内容

var e = new ice.editor('content');
console.log(e.getHTML());  //获取HTML格式内容
console.log(e.getText());  //获取Text格式内容
console.log(e.getValue());  //同getHTML,只是为了好记

设置内容

var e = new ice.editor('content');
e.setValue('hello world!');

追加内容

var e = new ice.editor('content');
e.addValue('hello world!');

监听输入内容

var e = new ice.editor('content');
//html:html格式
//text:纯文本格式
e.inputCallback(function(html,text){
  //console.log(this.getHTML()) 方法内的this为e对象,html等价于this.getHTML()
  console.log(html);
});

禁用截图粘贴功能

var e = new ice.editor('content');
e.screenshot=false;

禁用截图粘贴直接上传功能

//禁用后,将默认以base64格式显示图片
var e = new ice.editor('content');
e.screenshotUpload=false;

网络图片自动下载到本地

var e = new ice.editor('content');
e.imgAutoUpload=false;

网络图片自动下载到本地,域名白名单

var e = new ice.editor('content');
//默认为false,自动过滤当前域名,如果该图保存到第三方存储平台,例如七牛,可添加该域名,这样避免重复下载
//配置其它域名 格式为数组,例如七牛
e.imgDomain=['www.qiniu.com'];

开启富文本粘贴,可粘贴Word

var e = new ice.editor('content');
e.pasteText=false;



下载列表

版权声明:本文来源于互联网,如有侵权,请联系下方邮箱,一个工作日删除!