This commit is contained in:
Nicolas Stepien 2012-12-13 12:00:17 +01:00
parent 642519834a
commit f28bfd4e7e
3 changed files with 7 additions and 14 deletions

View File

@ -1991,23 +1991,17 @@
}
id = this.previousSibling.hash.slice(2);
text = ">>" + id + "\n";
sel = window.getSelection();
sel = d.getSelection();
if ((s = sel.toString().trim()) && id === ((_ref = $.x('ancestor-or-self::blockquote', sel.anchorNode)) != null ? _ref.id.match(/\d+$/)[0] : void 0)) {
if ($.engine === 'presto') {
s = d.getSelection().trim();
}
s = s.replace(/\n/g, '\n>');
text += ">" + s + "\n";
}
ta = $('textarea', QR.el);
caretPos = ta.selectionStart;
ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd);
ta.focus();
range = caretPos + text.length;
if ($.engine === 'presto') {
range += text.match(/\n/g).length;
}
ta.setSelectionRange(range, range);
ta.focus();
return $.event(ta, new Event('input'));
},
characterCount: function() {

View File

@ -1,4 +1,6 @@
master
- Mayhem
Fix selection quoting on Opera.
2.37.0
- noface

View File

@ -1552,10 +1552,9 @@ QR =
id = @previousSibling.hash[2..]
text = ">>#{id}\n"
sel = window.getSelection()
sel = d.getSelection()
if (s = sel.toString().trim()) and id is $.x('ancestor-or-self::blockquote', sel.anchorNode)?.id.match(/\d+$/)[0]
# XXX Opera needs d.getSelection() to retain linebreaks from the selected text
s = d.getSelection().trim() if $.engine is 'presto'
# XXX Opera doesn't retain `\n`s?
s = s.replace /\n/g, '\n>'
text += ">#{s}\n"
@ -1563,12 +1562,10 @@ QR =
caretPos = ta.selectionStart
# Replace selection for text.
ta.value = ta.value[...caretPos] + text + ta.value[ta.selectionEnd..]
ta.focus()
# Move the caret to the end of the new quote.
range = caretPos + text.length
# XXX Opera counts newlines as double
range += text.match(/\n/g).length if $.engine is 'presto'
ta.setSelectionRange range, range
ta.focus()
# Fire the 'input' event
$.event ta, new Event 'input'