fix weird selection bugs during quote reply.
This commit is contained in:
parent
f99d40b419
commit
161fdcb364
|
@ -28,7 +28,8 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
|
|||
if (!this.get('controllers.topic.content.can_create_post')) return;
|
||||
|
||||
// retrieve the selected range
|
||||
var range = window.getSelection().getRangeAt(0).cloneRange();
|
||||
var range = window.getSelection().getRangeAt(0);
|
||||
var cloned = range.cloneRange();
|
||||
|
||||
// do not be present the "quote reply" button if you select text spanning two posts
|
||||
// this basically look for the first "DIV" container...
|
||||
|
@ -54,6 +55,10 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
|
|||
// insert it at the beginning of our range
|
||||
range.insertNode(markerElement);
|
||||
|
||||
var sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(cloned);
|
||||
|
||||
// find marker position (cf. http://www.quirksmode.org/js/findpos.html)
|
||||
var obj = markerElement, left = 0, top = 0;
|
||||
do {
|
||||
|
|
Loading…
Reference in New Issue