Model

注意:本节的api都是实验性的。

find

静态方法返回给定DOM节点的Quill或Blot实例。 在后一种情况下,为bubble参数传入true将搜索给定DOM的祖先,直到找到相应的Blot

Methods

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

Examples

  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

返回文档开头与给定Blot出现之间的距离。

Methods

  1. getIndex(blot: Blot): Number

Examples

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

getLeaf

返回文档中指定索引处的叶Blot

Methods

  1. getLeaf(index: Number): Blot

Examples

  1. quill.setText('Hello Good World!');
  2. quill.formatText(6, 4, "bold", true);
  3. let [leaf, offset] = quill.getLeaf(7);
  4. // leaf should be a Text Blot with value "Good"
  5. // offset should be 1, since the returned leaf started at index 6

getLine

返回文档中指定索引处的BlotBlot行。

Methods

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

Examples

  1. quill.setText('Hello\nWorld!');
  2. let [line, offset] = quill.getLine(7);
  3. // line should be a Block Blot representing the 2nd "World!" line
  4. // offset should be 1, since the returned line started at index 6

getLines

返回指定位置中包含的行。

Methods

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

Examples

  1. quill.setText('Hello\nGood\nWorld!');
  2. quill.formatLine(1, 1, 'list', 'bullet');
  3. let lines = quill.getLines(2, 5);
  4. // array with a ListItem and Block Blot,
  5. // representing the first two lines