Quill: Cursor positioned at the end of the line when last blot on the line is an embed.

Created on 12 Dec 2016  路  3Comments  路  Source: quilljs/quill

Hi,

When an embed (formula for instance) is the last blot in a line, the cursor is positioned in the end of the line (in the edge of the editor), instead of just to the right of the embed.

Steps for Reproduction

  1. Go to: http://codepen.io/emanuelbsilva/pen/WogXvB
  2. Click with the mouse after the formula (as you were to write something after). When clicking with the mouse after the formula the cursor is in the edge of the editor.

Expected behavior:
It should put the cursor just after the embed (formula).

Platforms:
Chrome 55.0.2883.75 (OSX)
Safari 10.0 (OSX)

Version:
Quill 1.1.6

bug

Most helpful comment

Same happening with me. I got a custom embeded and the cursor goes to the end of the line
img1

img2

don't mind the react render

class Placeholder extends Embed {
  static blotName = 'chip'
  static tagName = 'span'
  static className = 'placeholder'
  static create (value) {
    const node = super.create(value)
    node.setAttribute('contentEditable', false)
    render(<Chip label={value}/>, node)
    return node
  }
  static value (node) {
    const chip = node.querySelector('.md-chip-text')
    if (!chip) return null
    return chip.innerHTML
  }
}

I actually "solved" by inserting a blank space everytime the embeded is inserted

handleChipClick = (text) => {
    const {index} = quill.getSelection() || {index: 0}
    quill.insertEmbed(index, 'chip', text, Quill.sources.USER)
    quill.insertText(index + 1, ' ', Quill.sources.SILENT)
  }

All 3 comments

Same happening with me. I got a custom embeded and the cursor goes to the end of the line
img1

img2

don't mind the react render

class Placeholder extends Embed {
  static blotName = 'chip'
  static tagName = 'span'
  static className = 'placeholder'
  static create (value) {
    const node = super.create(value)
    node.setAttribute('contentEditable', false)
    render(<Chip label={value}/>, node)
    return node
  }
  static value (node) {
    const chip = node.querySelector('.md-chip-text')
    if (!chip) return null
    return chip.innerHTML
  }
}

I actually "solved" by inserting a blank space everytime the embeded is inserted

handleChipClick = (text) => {
    const {index} = quill.getSelection() || {index: 0}
    quill.insertEmbed(index, 'chip', text, Quill.sources.USER)
    quill.insertText(index + 1, ' ', Quill.sources.SILENT)
  }

+1

This has been fixed in 1.3.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rsdrsd picture rsdrsd  路  3Comments

eamodio picture eamodio  路  3Comments

markstewie picture markstewie  路  3Comments

Yves-K picture Yves-K  路  3Comments

ouhman picture ouhman  路  3Comments