Opera:

When inserting line breaks into an editor instance using the replaceSelection() method, the selection is incorrectly set so that the end moved to the left of where it should be. The offset from the "correct" selection seems to depend on the amount of newlines inserted.

This can be reproduced with the following code snippet (assuming editor.active is set)
javascript:editor.active.setContent(""); editor.active.replaceSelection("foo\n\n\nbar"); void 0

Tested in Opera 9.24 (3707) on Mac OS X 10.5.1.

Safari:

Line breaks seem to cause problems here as well, although I haven't figured out a probable cause.

Reproduce with: javascript:editor.active.setContent(""); editor.active.replaceSelection("foo\n\nbar"); editor.active.focus(); void 0

Tested in Safari 3.0.4 (5523.10) on Mac OS X 10.5.1.

Comments

Adam_Bergmark’s picture

I forgot to mention that my guess is that line breaks are inserted as "\r\n", this is supported by the fact that editor.active.getContent().length is 10 after the code snippet for Opera even though only 8 characters were inserted (two line breaks).

ufku’s picture

Priority: Critical » Normal

is it really critical :)
in the documentation as a known issue i wrote about platform-browser combos might show unexpected behaviours regarding selection position. Bueditor is optimized for the browsers entering single newline character(\n) and for IE entering (\r\n) (enters 2 chars but counts it as 1 when it comes to selection pos. bue tries to correct this).
Opera(WIN), for example, behaves in between by entering 2(\r\n) and counting 2.

I didnt want to write an endless switch or if-else statement for all platform-browser combos. Instead there is 3 modes of the editor:
0- for browsers that does not support selection handling
1- browsers supporting selectionStart,selectionEnd,setSelectionRange methods for textareas() (FF, Opera, Safari)
2- IE(document.selection)
What BUE does is to create a selection-handling abstraction layer for these 3 modes.

if you want to implement a more specific new line character handling have a look at editor.processText method which changes \r\n to \n for only IE. Or you can check the browser and use a new line char accordingly in your scripts.

ufku’s picture

Status: Active » Closed (works as designed)