slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.39k stars 3.37k forks source link

Multi-cursor incorrect position when scaled #635

Closed Joeao closed 8 years ago

Joeao commented 8 years ago

Caret is out of place when the container element and/or a parent is scaled

Steps for Reproduction

  1. Visit [http://quilljs.com/examples/]
  2. Set transform:scale(1.2) on #docs-container
  3. Type on either Quill element

Expected behavior: Caret will be in the same position a user typed on the other quill editor

Actual behavior: Caret is in position * scale and height of the caret is normalHeight * scale

Platforms: Chrome 49, OSX 10.11

Version: 0.20.1

I'd updated it for 0.20.1 with the following changes:

_updateCursor: (cursor) ->
    bounds = @quill.getBounds(cursor.index)
    containerBounds = @quill.container.getBoundingClientRect()
    scale =
        x: containerBounds.width / @quill.container.offsetWidth
        y: containerBounds.height / @quill.container.offsetHeight    
    return this.removeCursor(cursor.userId) unless bounds?
    cursor.elem.style.top = (bounds.top + @quill.container.scrollTop) / scale.y + 'px'
    cursor.elem.style.left = bounds.left / scale.x + 'px'
    cursor.elem.style.height = bounds.height / scale.y + 'px'
    flag = cursor.elem.querySelector('.cursor-flag')
    dom(cursor.elem).toggleClass('top', parseInt(cursor.elem.style.top) <= flag.offsetHeight)
                                    .toggleClass('left', parseInt(cursor.elem.style.left) <= flag.offsetWidth)
                                    .toggleClass('right', @quill.root.offsetWidth - parseInt(cursor.elem.style.left) <= flag.offsetWidth)
    this.emit(MultiCursor.events.CURSOR_MOVED, cursor)

However couldn't update the development branch as the code has changed so significantly and the mutli-cursor module may have been removed. I'm very unfamiliar with this branch.

jhchen commented 8 years ago

Not sure how to categorize this Issue but the multi-cursor and authorship modules are not being included in 1.0. They are planned to be re-introduced in a future version.

Joeao commented 8 years ago

Legacy bug? I think it's fair to close this as it isn't relevant to the current branches. I'll make sure to test this issue out again when the multi-cursor module is re-introduced.

jhchen commented 8 years ago

Okay sounds good.