Skip to content

Should be able to insert image to the beginning of content #16

@caasi

Description

@caasi

Current code will fallback to this.quill.getLength() when you move your cursor to the beginning of content.

insert(dataUrl) {
  const index =
    (this.quill.getSelection() || {}).index || this.quill.getLength();
  this.quill.insertEmbed(index, 'image', dataUrl, 'user');
}

Check the result of getSelection may be a better solution.

insert(dataUrl) {
  const selection = this.quill.getSelection();
  const index = selection
    ? selection.index
    : this.quill.getLength();
  this.quill.insertEmbed(index, 'image', dataUrl, 'user');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions