Undo has additional logic to ensure the event trap is restored after
an undo is performed. At some point, this will need to split out of
the SessionController, but for now it is simplest to expose this to
the EditorSession for use.
Fixes remaining problems causing issue #426.
on click-to-move when keyboard is open.
This is done by momentarily hiding and displaying
the eventTrap when the keyboard is opening.
IOSSafariSupport is a drop-in class that should
make webodf function well in iOS Safari without
having to do any special platform handling anywhere
else in the code.
Do not set focus in a timeout on iOS.
When attempting click-to-move, in most desktop
browsers we need to get the new selection in a
simple 0-timeout, because the window selection
is not immediately updated when handling the
mouseup event. The focus to the event trap is
set after this is ready. Otherwise, clicking
within a selection will not do anything.
Unfortunately, in iOS Safari, it is impossible
to set focus within a timeout. Therefore, this
commit takes the least painful and simplest
thing route: check navigator.platform for
iPad, iPod, and iPhone (the hope is that this
will be reliable because of Apple's consistency),
and in that case avoid computing the selection
and focus assignment within a timeout.
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.
Performing the focus capture when a cursor is registered to the document
causes undo/redo to slow down, as the focus gets pulled into the cursor
as soon as the AddCursor op is executed. The focus should not be changed
while executing operations.
Recent changes introduced in 26a9252 caused the focus to no longer be
correctly restored after replacing the document root. Prior to the
broken commit, the focus was saved & restored after every operation.
When the cursor was re-added to the document after an undo, the focus
would be reset to the event trap and would be kept in sync after each
operation following.
26a9252 introduced measures to minimise when the focus was restored,
and would only try and save the focus once before a group of ops,
and restore once after the group was complete. As the group of ops
was executed *after* the ODF container had been replaced, the focus
was already lost by the time the group started. Subsequently, the
focus was never restored after the batch was complete.
Fixes issue #397
* In FireFox if an image has no text around it, click on either side of the image resulting the same selection get returned. focusNode: image, focusOffset: 0. To workaround it, move the cursor to the next walkable position when clicking on the right side of an image.
* Another corner case is that when click on the right side of an image that has no text elements, non-FireFox browsers will retrn focusNode: frame, focusOffset: 1 as the selection. Since this is not a valid cursor position, move the cursor to the next walkable position after the frame node.
Focus saving and restoring is expensive on most browsers, so major gains
in performance are realised by not doing this for every operation. A new
pair of signals implemented by operation routers denotes when a batch of
operations is about to processed, and when the router has completed this
batch.
Note, there is no implied promises about how many operations are executed
within a batch. This is left as a choice to the router implementations.
An executing operation needs to emit various other signals (e.g.,
signalOperationStart) in order for various other controllers and UI
managers to perform correctly (e.g., preserving focus, re-drawing
the selection etc.).
The simplest way to ensure this happens is to use the session.enqueue
call. The UndoManager will ignore any new operations while performing
an undo.
At the moment, splitting at the end of the following paragraph
<p style-name="standard">hello <span style-name="bold">world|</span></p>
will create a new paragraph like below
<p style-name="standard">|<span style-name="bold"></span></p>
The cursor is moved out of the span due to empty span is not considered as
a valid cursor position in the current design. this causes newly entered
text are not formatted correctly.
Merged DirectTextStyler and DirectParagraphStyler into
DirectFormattingController. These have become closely related concepts as
a result of changes in this patch.
This allows consumers to enter and exit edit mode multiple times without
the undo stack being reset. Once the initial undo state has been captured
after the document is loaded, there is no major problems with preserving
the undo state (other than the undo manager’s shameful performance).
Any cursor add or removal commands should be tracked for the purposes
of restoring the document state. If a cursor operation is missed, the
document will not re-add the cursor after an undo operation.
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
SessionController needs to override the backspace key at all times, and
if the document is not editable, simply return true. The easiest way to
do this is to switch out the keybinding, and forcibly clobber the existing
keybinding when leaving edit mode.
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
If the current selection is inside the content editable event trap, attempting
to collapse the window selection will have no effect. This results in the
shift+click selection method just moving the cursor to the location of the
second click.
Problem introduced in 8b6ef8f
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