Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
caasi opened this issue Jun 5, 2019 · 1 comment
Open

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

caasi opened this issue Jun 5, 2019 · 1 comment

Comments

@caasi
Copy link

caasi commented Jun 5, 2019

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');
}
@singleseeker
Copy link

@caasi Good job, You should give a PR to this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants