quill.js official document (two) [API Content]

deleteText

Delete the text from the editor and return the Deltadata representing the corresponding change . Source may be " user"," api"or" silent". When the editor is not available [disabled]#disable and the sourceparameter 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 Deltadata.

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 \nblank line parsed by ' ', so it getLengthwill 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 getLengthreturned 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".

lengthThe 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 Deltadata representing the corresponding change . SourceIt could be " user"," api"or" silent". When the editor is not available [disabled]#disable and the sourceparameter 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 Deltadata representing the corresponding changes .
SourceIt could be " user"," api"or" silent". When the editor is not available [disabled]#disable and the sourceparameter 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 Deltadata representing the corresponding change . If Deltathere is no invalid operation given, the return value is the same as the value passed in.

SourceIt could be " user"," api"or" silent". When the editor is not available [disabled]#disable and the sourceparameter 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 Deltathe data. Note that the Quilldocument must end with a newline character, if not, it will be added automatically.
SourceIt could be " user"," api"or" silent". When the editor is not available [disabled]#disable and the sourceparameter 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 Deltadata method, return on behalf of a corresponding change in the Deltadata. If Deltathere is no invalid operation given, the return value is the same as the value passed in.
SourceIt could be " user"," api"or" silent". When the editor is not available [disabled]#disable and the sourceparameter 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} }
// ]

Guess you like

Origin blog.csdn.net/WuLex/article/details/108277722