You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When triple-clicking on a paragraph or drag-selecting where the pointer is released just underneath the selected text, the selected range's tail ends up at offset 0 on the following section. Any subsequent use of editor.toggleSection applies the formatting to the visibly selected paragraph but also unexpectedly to the following paragraph.
I'm not sure if this is expected behaviour or a bug, if it's a bug is it in the cursor handling or the toggleSection implementation? Anyway, to work around this I had to add some extra logic to my editor.cursorDidChange event handler:
_cursorDidChange(editor){let{head, tail, direction}=editor.range;// do not include the tail section if it's offset is 0// fixes triple-click unexpectedly selecting two sections for section-level formattingif(direction===1&&!editor.range.isCollapsed&&tail.offset===0){letprevSection=tail.section.prev;letnewRange=newMobiledocKit.Range(head,prevSection.tailPosition());returneditor.run(postEditor=>{postEditor.setRange(newRange);});}if(!editor.range.isCollapsed){set(this,'hasSelection',true);}else{set(this,'hasSelection',false);}}
The extra selection is a little easier to see on Safari because the space between paragraphs is shown as selected. In Chrome (shown below) there's zero visual difference between selecting the just text of the paragraph and the selection expanding to offset 0 of the following section
The text was updated successfully, but these errors were encountered:
kevinansfield
changed the title
Triple-click + toggleSection affects visibly unselected next section
Triple-click + toggleSection affects visibly unselected section
Dec 18, 2017
kevinansfield
changed the title
Triple-click + toggleSection affects visibly unselected section
Triple-click+toggleSection affects visibly unselected section
Dec 18, 2017
kevinansfield
changed the title
Triple-click+toggleSection affects visibly unselected section
Triple-click + toggleSection affects visibly unselected section
Dec 18, 2017
When triple-clicking on a paragraph or drag-selecting where the pointer is released just underneath the selected text, the selected range's tail ends up at offset 0 on the following section. Any subsequent use of
editor.toggleSection
applies the formatting to the visibly selected paragraph but also unexpectedly to the following paragraph.I'm not sure if this is expected behaviour or a bug, if it's a bug is it in the cursor handling or the
toggleSection
implementation? Anyway, to work around this I had to add some extra logic to myeditor.cursorDidChange
event handler:Editor:
ember-mobiledoc-editor
Browser: Chrome 63/Safari 11 on MacOS 10.13.2 (High Sierra)
The extra selection is a little easier to see on Safari because the space between paragraphs is shown as selected. In Chrome (shown below) there's zero visual difference between selecting the just text of the paragraph and the selection expanding to offset 0 of the following section
The text was updated successfully, but these errors were encountered: