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
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.
Current behaviour:
Left click causes navigation in both edit and view mode
After the change:
Same as current behaviour in view mode.
In edit mode, left click will just move the cursor to desired position. In order to navigate, user need to hold control key and then click
This also addresses an outstanding TODO in code that select-all was only
ever selecting the entire document, rather than all the text inside the
current root (e.g., the current annotation)
This re-implementation also addresses problems when navigating passed
annotations as identified in issue #65 & #65.
This also fixes a large performance issue with extending or moving the
cursor via short-cut keys.
A drag end will consume the corresponding mouse up operation, meaning
the window selection is not cleared. Cope with this by listening for
the drag event and clearing the selection.
The window selection only needs to be synchronized with WebODF on a
mouse down operation. In all other cases, the selection doesn't need to
be maintained. Removing the selection most of the time significantly
helps performance as there is heavy costs to modifying part of a DOM
tree that is selected.
In order to allow cut/copy to continue to function, an event trap was
necessary that "holds" the selection after mouse-up. This is set as
content editable to allow the cut/copy events to be fired in Firefox and
Safari.
Firefox seems to get rather confused about the window selection when
shift+extending it. Help this poor browser by resetting the window
selection back to the anchor node if the user is holding shift.
Fixes issue #123.
Previously, the editor would wait for mouse up before expanding the
virtual selection.
Now, this can easily be done on mouse down as well. this makes the
editor feel a lot more responsive when double or triple clicking to
increase expansion. It now mimics built-in Chrome behaviour.
Chrome's built-in paragraph expansion will put the end of the selection
at (p,0) of the FOLLOWING paragraph. Round this back down to ensure the
next paragraph doesn't get incorrectly selected.
Fixes issue #165.
SessionController had some internal confusion about whether to work in
selection or range+bool. This cleans these up to ensure the direction is
properly preserved throughought.