Adjusting the selected range in the event trap can trigger a new focus
event under some conditions. Prevent this from going into an infinite
loop by ignoring new focus events that arise while currently processing
a focus event.
Text-to-speech and screen readers use the browser's selection to determine
what the current selected text is. Some browsers (e.g., Safari on OSX) think
the text content of the event trap is the currently selected content, and
only vocalise the letter "b".
Cope with this by serialising the currently selected text to the input
field on redraw. On a 1000 page text-only document, this can add sizeable
performance impact (400ms to execute synchronizeWindowSelection), but
as this only occurs when the cursor is updated, and only once per redraw,
the actual end user impact is reasonably minimal.
* remove @license tag (to prevent Closure compiler keeping the comment)
* use copyright@kogmbh.com email address everywhere
* remove "additional permission", to be added only to released webodf.js
* separate license header by empty line from following content
runtime.loadClass(...) no longer expects that eval(fileContent) yields
the constructor, and a few loaded files rely on that (e.g. all singletons/namespaces),
so let's be consistent
The window selection should be synchronised every time the local user's
cursor is moved. When the local user's selection is modified using the
keyboard, the event trap never loses focus, so the focus event is not
fired, meaning the window selection was not being reset.
Now, the local cursor's update event is directly subscribed to, and if
the document has focus, the window selection is reset. Note, if the
document does not have focus, no reset will occur to prevent focus
stealing.
Fixes a regression introduced in 8de8dde.
Using requestAnimationFrame ensures the callback is executed prior to
the next redraw, eliminating undesirable & highly visible flickers for
UI updates.
Fixes issue #491.
Management of the event trap is not related to the IME. Moving the
coordination of the disabled and readOnly flags inside the EventManager
better hides these concepts from external consumers.
A contextmenu event is fired instead of a mouseup event, therefore
both these events need to be listened for to ensure the event trap
becomes re-enabled.
A disabled element is not able to become the document's activeElement.
The better way of setting the event trap to non-editable is through
the readOnly flag. This still allows focus to be passed to the trap.
During a mouse down event, the event trap should be disabled however
to ensure it doesn't capture the window selection.
Changing to an input element (1038583) affected how text ranges are
created in IE and Firefox. This stopped cut/paste from functioning.
setSelectionRange is supported on all major browsers.
This commit pulls the event trap outside the cursor,
and as a child of the canvas,
and makes the Caret track the cursor's position and
position the trap above the cursor.
This means that there is no need to manually
blur and focus the eventManager whenever an
operation is executed.
Toggling the content editable flag while the element is in focus will
sometimes stop the browser from allowing the IME to be activated.
Blurring the focus and then restoring ensures the browser re-evaluates
the IME state after the content editable flag has been updated.
With the event trap now being inside the cursor, any repositioning of
the cursor causes the document.activeElement and window selection to
change. This causes the document to stop being editable after actions
such as bolding current text.
Now, the focus state of the event trap is checked prior to each
operation, and will be reset back to the event trap if disrupted by an
operation. Note, checks are in place to prevent stealing focus if the
document is not active when an operation is executed.
Fixes issue #298
If the event trap receives focus on a mouse-down event, the selection will
become "trapped" inside the content-editable bounds. This can happen when
the user double-clicks on the caret (to start word expansion) and drags.
In this instance, the selection will appear to "stick" on the single word
surrounding the caret.
Problem introduced in 8b6ef8f
The textInput event provides a more accurate view of the resulting text
from a key press on Chrome and Safari. Use this as the fallback if the
key press event is ignored (e.g., user is inputing character code using
the Mac OS option key or Windows alt key).
In Chrome 31.0.1650.63 onUbuntu 13.10, the composed character isn't set
in the compositionend event. The text is added to the focused field
immediately after however in a textInput event. Firefox appears to be
unaffected by this bug.
When composition session is ended on Safari under MacOS by pressing
another text char, Safari incorrectly reports the next keypress event’s
“which” value as the last compositionend data, rather than the new key
that was pressed.
Some IMEs will stack end & start requests back to back. If the selection
is modified between an old and new session (e.g., via text updates), the
new composition session never starts. One mainstream example of this is
inputting text using MacOS’s option+char method
This change extends the use of the event trap to allow in-line character addition
using the OS's IME. The event trap will now be moved to within the local user's
cursor block, and will become visible when a composition start event is detected.
This has been tested on Chrome, FF & Safari on all platforms. In addition, this
enables support in FF on Android.
Known issues
- No IME support on Chrome under Linux. The compositionend event emitted by Chrome
contains no data, so the input character can't be detected.