Quill中文文档
  • 简介
  • 文档(Document)
    • 快速开始(QuickStart)
    • 下载(Download)
    • 配置项(Configuration)
    • 格式化(Formats)
    • API
      • content
      • formatting
      • selection
      • editor
      • events
      • model
      • extension
    • Delta
    • 模块(Modules)
      • 工具栏(Toolbar)
      • 键盘(Keyboard)
      • 历史(History)
      • 剪贴板(Clipboard)
      • 格式化(Formula)
      • 语法高亮(Syntax Highlighter)
    • 主题(Themes)
  • 指南(Guides)
    • 为什么要用Quill?(Why Quill)
    • 怎么自定义Quill
    • 将Quill添加到你的构建系统
    • 构建自定义模块
    • 通过Parchment克隆Medium
    • 设计Delta的格式
    • 与其他富文本编辑器对比
    • 升级到1.0
  • 其他相关库(Other)
    • Parchment
    • 自定义总结
  • 更新日志
Powered by GitBook
On this page
  • find (实验性api)
  • getIndex (实验性api)
  • getLeaf
  • getLine (实验性api)
  • getLines (实验性api)
  1. 文档(Document)
  2. API

model

说明:实验性api对于语义化版本不适用

find (实验性api)

静态方法,返回给定的DOM节点的Quill或者Blot实例。后面一种情况下,如果传入的参数为bubble,则会向上查询DOM的父节点,直到找到相应的Blot。

方法

Quill.find(domNode: Node, bubble: boolean = false): Blot | Quill

例子

var container = document.querySelector("#container");
var quill = new Quill(container);
console.log(Quill.find(container) === quill);   // Should be true

quill.insertText(0, 'Hello', 'link', 'https://world.com');
var linkNode = document.querySelector('#container a');
var linkBlot = Quill.find(linkNode);

getIndex (实验性api)

返回文档开始于给定的Blot之间的距离。

方法

getIndex(blot: Blot): Number

例子

let [line, offset] = quill.getLine(10);
let index = quill.getIndex(line);   // index + offset should == 10

getLeaf

返回文档给定索引出的叶子Blot。

方法

getLeaf(index: Number): Blot

例子

quill.setText('Hello Good World!');
quill.formatText(6, 4, "bold", true);

let [leaf, offset] = quill.getLeaf(7);
// leaf应该是一个值为“Good”的Text Blot
// 偏移值应该是1,因为开始的索引为6

getLine (实验性api)

返回文档给定索引出的行级Blot。

方法

getLine(index: Number): [Blot, Number]

例子

quill.setText('Hello\nWorld!');

let [line, offset] = quill.getLine(7);
// line应该是一个第二行“World!”的Block Blot
// 偏移值应该是1,因为开始的索引为6

getLines (实验性api)

返回指定位置内的所有行。

方法

getLines(index: Number = 0, length: Number = remaining): Blot[]
getLines(range: Range): Blot[]

例子

quill.setText('Hello\nGood\nWorld!');
quill.formatLine(1, 1, 'list', 'bullet');

let lines = quill.getLines(2, 5);
// 一个ListItem的数组和Block Blot,
// 代表前两行
PreviouseventsNextextension

Last updated 5 years ago