File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,17 @@ export default class Selection extends Cursor {
5353 }
5454
5555 getTextRange ( ) {
56- return this . range . toCharacterRange ( this . host )
56+ const rangeUntilSelection = this . range . cloneRange ( )
57+ rangeUntilSelection . setStart ( this . host , 0 )
58+ rangeUntilSelection . setEnd ( this . range . startContainer , this . range . startOffset )
59+
60+ const numNewLinesBefore = $ ( '<div>' + rangeUntilSelection . toHtml ( ) + '</div>' ) . find ( 'br' ) . length
61+ const numNewLinesWithin = $ ( '<div>' + this . range . toHtml ( ) + '</div>' ) . find ( 'br' ) . length
62+ const textRange = this . range . toCharacterRange ( this . host )
63+ return {
64+ start : textRange . start + numNewLinesBefore ,
65+ end : textRange . end + numNewLinesWithin + numNewLinesBefore
66+ }
5767 }
5868
5969 // Get the ClientRects of this selection.
You can’t perform that action at this time.
0 commit comments