Fine text selection to quote on Opera.

This commit is contained in:
Nicolas Stepien 2012-06-15 18:05:21 +02:00
parent 4f8cfa82d8
commit 0b26a4d817
2 changed files with 7 additions and 2 deletions

View File

@ -1562,6 +1562,9 @@
text = ">>" + id + "\n";
sel = window.getSelection();
if ((s = sel.toString()) && id === ((_ref = $.x('ancestor-or-self::blockquote', sel.anchorNode)) != null ? _ref.id.match(/\d+$/)[0] : void 0)) {
if ($.engine === 'presto') {
s = d.getSelection();
}
s = s.replace(/\n/g, '\n>');
text += ">" + s + "\n";
}
@ -1571,7 +1574,7 @@
ta.focus();
range = caretPos + text.length;
if ($.engine === 'presto') {
range++;
range += text.match(/\n/g).length;
}
ta.setSelectionRange(range, range);
e = d.createEvent('Event');

View File

@ -1145,6 +1145,8 @@ QR =
sel = window.getSelection()
if (s = sel.toString()) 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() if $.engine is 'presto'
s = s.replace /\n/g, '\n>'
text += ">#{s}\n"
@ -1156,7 +1158,7 @@ QR =
# Move the caret to the end of the new quote.
range = caretPos + text.length
# XXX Opera counts newlines as double
range++ if $.engine is 'presto'
range += text.match(/\n/g).length if $.engine is 'presto'
ta.setSelectionRange range, range
# Fire the 'input' event