quill富文本编辑器 API
//1. 从第三个开始删除,删除4个
// console.log(this.quill.deleteText(2, 4)); // 12345678 1278
// 2.(返回对象)返回从第三个开始,返回4个,编辑器里面不变 .insert = 3456; 不写参数参数,默认全部
// console.log(this.quill.getContents(2, 4)); // 12345678 3456
//3.检索编辑器内容的长度 返回值是要加一
// console.log(this.quill.getLength(3)); // 12345678 9
//4.同quill.getContents(2, 4);返回值不一样,
// console.log(this.quill.getText(2, 4)); // 12345678 3456 //5.编辑器里值不会被覆盖 编辑器里插入值 (位置,类型,内容)
// console.log(this.quill.insertEmbed(10, 'image', 'https://quilljs.com/images/cloud.png'));
//6.编辑器里值不会被覆盖 编辑器里插入值(文本) (位置,内容, 格式)
// console.log(this.quill.insertText(0, 'Hello', 'bold', true));
// console.log(this.quill.insertText(5, 'Quill', {
// 'color': 'red',
// 'italic': true
// }));
//7.编辑器里值被覆盖 编辑器里插入值(文本) (位置,内容, 格式) 以{ insert: '\n' }结尾
// console.log(this.quill.setContents([
// { insert: 'Hello ' },
// { insert: 'World!', attributes: { bold: true } },
// { insert: '\n' }
// ]));
//8.编辑器里值被覆盖
// console.log(this.quill.setText('Hello\n'));
//9.没研究,会报错 home.vue?250d:109 Uncaught ReferenceError: Delta is not defined
// console.log(this.quill.updateContents(new Delta()
// .retain(6) // Keep 'Hello '
// .delete(5) // 'World' is deleted
// .insert('Quill')
// .retain(1, { bold: true }) // Apply bold to exclamation mark
// )); //10.设置编辑器里内容格式format
// this.quill.format('color', 'red');
// this.quill.format('align', 'right');
// this.quill.setText('Hello\nWorld!\n');
//11.formatLine
//formatLine(index: Number, length: Number, source: String = 'api'): Delta
// formatLine(index: Number, length: Number, format: String, value: any,
// source: String = 'api'): Delta
// formatLine(index: Number, length: Number, formats: { [String]: any },
// source: String = 'api'): Delta
// this.quill.formatLine(0, 2, 'align', 'right'); // right aligns the first line
// this.quill.formatLine(4, 4, 'align', 'center'); // center aligns both lines
// 12.formatText
// this.quill.setText('Hello\nWorld!\n'); // this.quill.formatText(0, 5, 'bold', true); // bolds 'hello' // this.quill.formatText(0, 5, { // unbolds 'hello' and set its color to blue
// 'bold': false,
// 'color': 'rgb(0, 0, 255)'
// }); // this.quill.formatText(5, 1, 'align', 'right'); // right aligns the 'hello' line
// 13 getFormat 获取格式
// this.quill.setText('Hello World!');
// this.quill.formatText(0, 2, 'bold', true);
// this.quill.formatText(1, 2, 'italic', true);
// this.quill.getFormat(0, 2); // { bold: true }
// this.quill.getFormat(1, 1); // { bold: true, italic: true }
// 14. 移除格式 removeFormat
// this.quill.setContents([
// { insert: 'Hello', { bold: true } },
// { insert: '\n', { align: 'center' } },
// { insert: { formula: 'x^2' } },
// { insert: '\n', { align: 'center' } },
// { insert: 'World', { italic: true }},
// { insert: '\n', { align: 'center' } }
// ]);
// this.quill.removeFormat(3, 7); // 15.getBounds 获取区域
// getBounds(index: Number, length: Number = 0):
// 返回值 { left: Number, top: Number, height: Number, width: Number }
// this.quill.setText('Hello\nWorld\n');
// console.log(this.quill.getBounds(0, 2)); // Returns { height: 15, width: 0, left: 27, top: 31 }
// 16.获取鼠标的位置 getSelection
// var range = this.quill.getSelection();
// if (range) {
// console.log(range)
// if (range.length == 0) {
// console.log('User cursor is at index', range.index);
// } else {
// var text = this.quill.getText(range.index, range.length);
// console.log(this.quill.getLength());
// console.log('User has highlighted: ', text);
// }
// } else {
// console.log('User cursor is not in editor');
// }
// 17
this.quill.on('text-change', function(delta, oldDelta, source) {
if (source == 'api') {
console.log("An API call triggered this change.");
} else if (source == 'user') {
console.log("A user action triggered this change.");
}
});
quill富文本编辑器 API的更多相关文章
- Quill 富文本编辑器
Quill 富文本编辑器 https://quilljs.com/ https://github.com/quilljs/quill https://github.com/quilljs/awesom ...
- Vue整合Quill富文本编辑器
Quill介绍 Quill是一款开源的富文本编辑器,基于可扩展的架构设计,提供丰富的 API 进行定制.截止2021年1月,在github上面已有28.8k的star. Quill项目地址:https ...
- 轻量级quill富文本编辑器
因为公司产品需要在移动端编辑文本,所以发现了这个轻量级的好东西,网上也没找到比较好的案例,就自己总结了下,有兴趣的直接复制代码运行看看就知道啦! 下面是quill.js的CDN加速地址: <!- ...
- Vue2 封装的 Quill 富文本编辑器组件 Vue-Quill-Editor
1.安装 npm install vue-quill-editor --save 2.使用 import { quillEditor } from 'vue-quill-editor' 3.组件中 & ...
- react-quill 富文本编辑器
适合react的一款轻量级富文本编辑器 1.http://blog.csdn.net/xiaoxiao23333/article/details/62055128 (推荐一款Markdown富文本编辑 ...
- quilljs 一款简单轻量的富文本编辑器(适合移动端)
quilljs入门使用教程: quill.js是一款强大的现代富文本编辑器插件.该富文本编辑器插件支持所有的现代浏览器.平板电脑和手机.它提供了文本编辑器的所有功能,并为开发者提供大量的配置参数和方法 ...
- angular4 富文本编辑器
使用quill富文本编辑器实现,angular项目中用到了ngx-quill插件. quill的GitHub地址:https://github.com/quilljs/quill ngx-quill的 ...
- vue-quill-editor 富文本编辑器插件介绍
Iblog项目中博文的文本编辑器采用了vue-quill-editor插件,本文将简单介绍其使用方法. 引入配置 安装模块 npm install vue-quill-editor --save in ...
- Quill – 可以灵活自定义的开源的富文本编辑器
Quill 的建立是为了解决现有的所见即所得(WYSIWYG)的编辑器本身就是所见即所得(指不能再扩张)的问题.如果编辑器不正是你想要的方式,这是很难或不可能对其进行自定义以满足您的需求. Quill ...
随机推荐
- Elastic 之倒排索引(二)
常规索引建立: 文档-->关键词的映射过程(正向索引) 缺点:费时 便利全部文档 倒排反向建立索引: 关键词-->文档的映射 反向到倒排索引:将索引的关键词出现的文档的位置和出现频率通过文 ...
- Centos 7 上使用nginx为Node.js配置反向代理时错误:(13: Permission denied) while connecting to upstream
错误来源:Centos 7 上使用nginx为Node.js配置反向代理时产生(13: Permission denied) while connecting to upstream的错误 nginx ...
- Python Learning - One
## Create a directory each day, and can create files in the directory. 1. variable 2. comments 1) # ...
- Codeforces 1154E - Two Teams - [线段树+链表]
题目链接:https://codeforces.com/contest/1154/problem/E 题意: $n$ 个人排成一排,第 $i$ 个人的能力值为 $a[i]$,$a[1 \sim n]$ ...
- 【Python基础】lpthw - Exercise 44 继承与组合
一.继承 原则:大部分使用继承的场合都可以用组合取代或者简化,而多重继承则需要不惜一切的避免. 1. 什么是继承 继承:用于指明一个类的大部分或者全部功能都是从一个父类获得的.此时,父类的实例的所有动 ...
- WSGI 相关的东东(转载)
WSGIWSGI的全称是Web Server Gateway Interface(Web服务器网关接口),它不是服务器.python模块.框架.API或者任何软件,只是一种描述web服务器(如ngin ...
- PySe-007-解决“Chrome正在受到自动软件的控制”
python使用selenium启动chrome的代码如下所示: #!/usr/local/bin/python # -*- coding: utf-8 -*- from selenium impor ...
- Jmeter学习之--dubbo接口测试
背景:公司的h5和APP都需要调用许多非http的服务,需要对服务的性能和自动化测试 工具:IDEA ,maven,Jmeter 参考文档: https://testerhome.com/topics ...
- javascript的ES6学习总结(第二部分)
1.数组循环 介绍数组循环之前,先回顾一下ES5数组的循环 (1)数组遍历(代替普通的for):arr.forEach(callback(val,index,arr){todo}) //val是数组的 ...
- Ubuntu16.04调整屏幕分辨率至1920*1080
安装好ubuntu 16.04桌面版后,发现屏幕分辨率调整选项里没有1920*1080这一选项,经过一番查找,可通过如下方式进行屏幕分辨率设置.以下操作均在ubuntu 16.04桌面版操作,不要用远 ...