Model

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

find (实验性api)

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

方法

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

例子

  1. var container = document.querySelector("#container");
  2. var quill = new Quill(container);
  3. console.log(Quill.find(container) === quill); // Should be true
  4. quill.insertText(0, 'Hello', 'link', 'https://world.com');
  5. var linkNode = document.querySelector('#container a');
  6. var linkBlot = Quill.find(linkNode);

getIndex (实验性api)

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

方法

  1. getIndex(blot: Blot): Number

例子

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

getLeaf

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

方法

  1. getLeaf(index: Number): Blot

例子

  1. quill.setText('Hello Good World!');
  2. quill.formatText(6, 4, "bold", true);
  3. let [leaf, offset] = quill.getLeaf(7);
  4. // leaf应该是一个值为“Good”的Text Blot
  5. // 偏移值应该是1,因为开始的索引为6

getLine (实验性api)

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

方法

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

例子

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

getLines (实验性api)

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

方法

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

例子

  1. quill.setText('Hello\nGood\nWorld!');
  2. quill.formatLine(1, 1, 'list', 'bullet');
  3. let lines = quill.getLines(2, 5);
  4. // 一个ListItem的数组和Block Blot,
  5. // 代表前两行