From 136982455ae0eddc18744176db33fbd7b421e11c Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 27 Jun 2010 18:34:57 +0200 Subject: Fixed automatic insertion of listbullets in Opera FS#1877 The keydown event can't be prevented in Opera (see http://www.quirksmode.org/dom/events/keys.html) so this switches back to keypress in Opera (keypress doesn't give the correct key codes in Firefox). Furthermore Opera replaces '\n' by '\r\n' when inserting text, thus the offset for cursor/selection placement was wrong. --- lib/scripts/textselection.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/scripts/textselection.js') diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 0378b544d..742338785 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -161,7 +161,12 @@ function pasteText(selection,text,opts){ selection.obj.value.substring(selection.end, selection.obj.value.length); // set new selection - selection.end = selection.start + text.length; + if (is_opera) { + // Opera replaces \n by \r\n when inserting text. + selection.end = selection.start + text.replace(/\r?\n/g, '\r\n').length; + } else { + selection.end = selection.start + text.length; + } // modify the new selection if wanted if(opts.startofs) selection.start += opts.startofs; -- cgit v1.2.3