deleteText
Delete the text from the editor and return the Delta
data representing the corresponding change . Source may be " user
"," api
"or" silent
". When the editor is not available [disabled]#disable and the source
parameter is " user
", the call will be ignored.
method
deleteText(index: Number, length: Number, source: String = 'api'): Delta
Example
quill.deleteText(6, 4);
getContents
Returns the content of the editor-data containing format Delta
data.
method
getContents(index: Number = 0, length: Number = remaining): Delta
Example
var delta = quill.getContents();
getLength
Returns the length of the editor content. Note that when Quill is empty, it still contains a \n
blank line parsed by ' ', so it getLength
will be returned 1
.
method
getLength(): Number
Example
var length = quill.getLength();
getText
Returns the string content of the editor. Since non-string content will be ignored, the length of the returned string content will be smaller than the getLength
returned length. Note that even though Quill is empty, there is still a blank line in the editor, so in this case it will return " \n
".
length
The parameter defaults to the length of the remaining documents.
method
getText(index: Number = 0, length: Number = remaining): String
Example
var text = quill.getText(0, 10);
insertEmbed
Insert the content of the embedded object into the editor and return the Delta
data representing the corresponding change . Source
It could be " user
"," api
"or" silent
". When the editor is not available [disabled]#disable and the source
parameter is " user
", the call will be ignored.
method
insertEmbed(index: Number, type: String, value: any, source: String = 'api'): Delta
Example
quill.insertEmbed(10, 'image', 'https://quilljs.com/images/cloud.png');
insertText
Insert text into the editor, optionally with a specified text format or multiple text formats, and return Delta
data representing the corresponding changes .
Source
It could be " user
"," api
"or" silent
". When the editor is not available [disabled]#disable and the source
parameter is " user
", the call will be ignored.
method
insertText(index: Number, text: String, source: String = 'api'): Delta
insertText(index: Number, text: String, format: String, value: any,
source: String = 'api'): Delta
insertText(index: Number, text: String, formats: {
[String]: any },
source: String = 'api'): Delta
Example
quill.insertText(0, 'Hello', 'bold', true);
quill.insertText(5, 'Quill', {
'color': '#ffff00',
'italic': true
});
setContents
Overwrite the original editor content with the given content. The content will end with a newline character. Returns Delta
data representing the corresponding change . If Delta
there is no invalid operation given, the return value is the same as the value passed in.
Source
It could be " user
"," api
"or" silent
". When the editor is not available [disabled]#disable and the source
parameter is " user
", the call will be ignored.
method
setContents(delta: Delta, source: String = 'api'): Delta
Example
quill.setContents([
{
insert: 'Hello ' },
{
insert: 'World!', attributes: {
bold: true } },
{
insert: '\n' }
]);
setText
With the given text editor is set to the content, returns the representative of corresponding changes in Delta
the data. Note that the Quill
document must end with a newline character, if not, it will be added automatically.
Source
It could be " user
"," api
"or" silent
". When the editor is not available [disabled]#disable and the source
parameter is " user
", the call will be ignored.
method
setText(text: String, source: String = 'api'): Delta
Example
quill.setText('Hello\n');
updateContents
Let content editors to perform Delta
data method, return on behalf of a corresponding change in the Delta
data. If Delta
there is no invalid operation given, the return value is the same as the value passed in.
Source
It could be " user
"," api
"or" silent
". When the editor is not available [disabled]#disable and the source
parameter is " user
", the call will be ignored.
method
updateContents(delta: Delta, source: String = 'api'): Delta
Example
// Assuming editor currently contains [{ insert: 'Hello World!' }]
quill.updateContents(new Delta()
.retain(6) // Keep 'Hello '
.delete(5) // 'World' is deleted
.insert('Quill')
.retain(1, {
bold: true }) // Apply bold to exclamation mark
);
// Editor should now be [
// { insert: 'Hello Quill' },
// { insert: '!', attributes: { bold: true} }
// ]