Model
find
Static method, given a DOM
node, return the corresponding Quill
or Blot
instance.
Return the latter parameter bubble
is true
, the search for a given direction DOM
of ancestor nodes, find the corresponding known Blot
.
method
Quill.find(domNode: Node, bubble: boolean = false): Blot | Quill
Example
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
Returns Blot
the distance from the beginning of the document to the given object position.
method
getIndex(blot: Blot): Number
Example
let [line, offset] = quill.getLine(10);
let index = quill.getIndex(line); // index + offset should == 10
getLeaf
Specify the distance in the document and return the corresponding leaf Blot
instance.
method
getLeaf(index: Number): Blot
Example
quill.setText('Hello Good World!');
quill.formatText(6, 4, "bold", true);
let [leaf, offset] = quill.getLeaf(7);
// leaf should be a Text Blot with value "Good"
// offset should be 1, since the returned leaf started at index 6
getLine
Specify the distance in the document and return the line Blot
.
method
getLine(index: Number): [Blot, Number]
Example
quill.setText('Hello\nWorld!');
let [line, offset] = quill.getLine(7);
// line should be a Block Blot representing the 2nd "World!" line
// offset should be 1, since the returned line started at index 6
getLines
Returns the row contained in the specified position.
method
getLines(index: Number = 0, length: Number = remaining): Blot[]
getLines(range: Range): Blot[]
Example
quill.setText('Hello\nGood\nWorld!');
quill.formatLine(1, 1, 'list', 'bullet');
let lines = quill.getLines(2, 5);
// array with a ListItem and Block Blot,
// representing the first two lines
Extension
debug
Enable the static method of logging information, the given levels are: ' error
',' warn
', ' log
' or ' info
'. Incoming is true
equivalent to incoming ' log
'. Incoming false
means to disable all levels of message logging.
method
Quill.debug(level: String | Boolean)
Example
Quill.debug('info');
import
Quill
Static methods that return libraries, formats, modules, or themes. Generally, the path should accurately map to Quill
the directory structure of the source code. Unless otherwise stated, modifications to the returned entity may interrupt the Quill
functionality that has already been introduced , so never do this.
method
Quill.import(path): any
Example
var Parchment = Quill.import('parchment');
var Delta = Quill.import('delta');
var Toolbar = Quill.import('modules/toolbar');
var Link = Quill.import('formats/link');
// Similar to ES6 syntax `import Link from 'quill/formats/link';`
register
Register a module, theme or format to make them available for adding to the editor. After registration, it can be Quill.import
imported. Use the ' formats/
',' modules/
'or' themes/
'path prefix to register the format, module and theme respectively. For the format, there is a short method that only needs to pass in the format object, and the path will be automatically generated. If the path is passed in, it will directly overwrite the path already defined.
method
Quill.register(format: Attributor | BlotDefinintion, supressWarning: Boolean = false)
Quill.register(path: String, def: any, supressWarning: Boolean = false)
Quill.register(defs: {
[String]: any }, supressWarning: Boolean = false)
Example
var Module = Quill.import('core/module');
class CustomModule extends Module {
}
Quill.register('modules/custom-module', CustomModule);
Quill.register({
'formats/custom-format': CustomFormat,
'modules/custom-module-a': CustomModuleA,
'modules/custom-module-b': CustomModuleB,
});
Quill.register(CustomFormat);
// You cannot do Quill.register(CustomModuleA); as CustomModuleA is not a format
addContainer
In the Quill
new and returning a container element, inside the container itself and editors are brothers. By convention, Quill
modules should have a prefixed ql-
class name. You can specify a reference node, and the new node will be inserted before the changed node.
method
addContainer(className: String, refNode?: Node): Element
addContainer(domNode: Node, refNode?: Node): Element
Example
var container = quill.addContainer('ql-custom');
getModule
Return a module that has been added to the editor.
method
getModule(name: String): any
Example
var toolbar = quill.getModule('toolbar');
disable
enable(false)
The shortcut method.
enable
Allow users to edit content through input device settings such as a mouse or keyboard. When it source
is " api
" or "
silent`", it does not affect API calls.
method
enable(value: Boolean = true)
Example
quill.enable();
quill.enable(false); // Disables user input