Commit Graph
227 Commits
Author SHA1 Message Date
Philip Peitsch 105a84afce Don't re-capture focus when the cursor is re-added to the document
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.
2014-02-18 02:10:37 +11:00
Philip Peitsch dc1c9c3e7e Restore focus after an undo or redo operation
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
2014-02-18 02:08:13 +11:00
Friedrich W. H. Kossebau f7aa96ecd2 Add gui.EventManager.destroy() 2014-02-12 01:23:53 +01:00
Friedrich W. H. Kossebau 989f26d459 Fix incomplete destroy of SessionController 2014-02-12 01:23:53 +01:00
Friedrich W. H. Kossebau cb691213e6 No longer cursor insertion in SessionController.startEditing, fix cursor removal where missing 2014-02-12 01:22:26 +01:00
Jos van den Oever ff3c396aa6 Add core.Destroyable interface.
Every class that has a destroy() method now implements this interface.
2014-02-11 12:42:41 +01:00
Jos van den Oever 8e0b32525a Fix nullablility in a number of places.
And add a few unrelated clarifying comments.
2014-02-11 09:12:20 +01:00
Jos van den Oever 59d2e09611 Make CaretManager and SessionView 100% typed. 2014-02-08 15:57:20 +01:00
Jos van den Oever ed7270442f Remove loadClass calls from class files. The load system reads the dependencies from the manifest.json files now. 2014-02-07 15:38:09 +01:00
lli c1a0f2dcae Fix a couple of selection issues
* 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.
2014-02-07 23:16:58 +11:00
Jos van den Oever a9e64e645f Remove circular dependency between OdtDocument and OdtCursor.
OdtCursor does not depend on OdtDocument any more. In fact, it is not specific
to ODF any more so at some point it could be renamed.
2014-02-05 14:24:25 +01:00
Philip Peitsch 26a9252edb Save and restore focus once per batch of operations
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.
2014-02-05 23:41:57 +11:00
Jos van den Oever 9e0059236d Add a general document interface for use in operations.
The UndoManager and TrivialUndoManager classes are adapted to the generalized interface.
2014-02-04 10:01:08 +01:00
Friedrich W. H. Kossebau 73b6f505cb clickStartedWithinContainer -> clickStartedWithinCanvas 2014-01-31 15:33:43 +01:00
Friedrich W. H. Kossebau d2671e2a00 @returns -> @return 2014-01-31 15:33:43 +01:00
Andreas Obergrusberger 45ebc8e02a Add ctrl+arrow per-word cursor movement 2014-01-30 21:33:39 +01:00
Philip Peitsch 34d1e37d21 Re-use session.enqueue to replay operations for the undo manager
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.
2014-01-23 23:01:27 +11:00
lli 6e24de30f0 In edit mode, resets hyperlink cursor style to text whenever the editor got focus.
This prevents the cursor stays as hand icon in case user release the ctrl key after the editor lost focus.
2014-01-23 15:58:23 +11:00
lli 8cbe8b4afc Respond to ctrl key press event in edit mode only. 2014-01-23 14:52:47 +11:00
lli 2acd473a19 In edit mode, only open a hyperlink with Command+Click on MacOS
This matches the behaviour of LibreOffice.
2014-01-23 12:09:44 +11:00
lli 716e5bdc11 Disable the paragraph related styling methods if directParagraphStylingEnabled is false 2014-01-20 23:01:49 +11:00
lli 32f148930a Preserve the text style when splitting at the end of paragraph.
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.
2014-01-20 22:32:24 +11:00
Philip Peitsch b559fac679 Recapture focus after deleting an annotation 2014-01-16 17:30:31 +11:00
Philip Peitsch ea0dcf3cdc Recapture focus after clicking on an already selected image
Clicking on a selected image will lose the event trap focus. Focus needs
to be restored back to the event trap after this.
2014-01-16 17:06:43 +11:00
Aditya Bhatt 6921bffe71 Rename TextManipulator to TextController 2014-01-15 13:37:47 +05:30
Aditya Bhatt 1c65c0eeec Rename ImageManager to ImageController 2014-01-15 13:37:47 +05:30
Philip Peitsch 492fe5a409 Fix a performance regression when deleting large amounts of text
Having the event manager in focus during deletion causes text removal to
be approximately 3x slower.
2014-01-14 01:40:14 +11:00
Philip Peitsch 18312d6359 Only make the event trap editable if the document is in edit mode
Various browser menus (cut, delete) should only enable if the document
is currently in edit mode.
2014-01-10 20:58:15 +11:00
lli e2b7b378f1 Uses the previous selection style for the newly inserted character when replacing text 2014-01-09 22:01:40 +11:00
Philip Peitsch e2ec5af9d4 Don’t reset the undo manager state when entering or exiting edit mode
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).
2014-01-08 21:48:32 +11:00
Philip Peitsch efe36bf4c0 Capture cursor registration for undo event even when not in edit mode
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.
2014-01-08 21:48:32 +11:00
Philip Peitsch 8de8dde612 Restore focus to the event trap if reset by an 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
2014-01-08 21:32:10 +11:00
Philip Peitsch dabbd2739f Provide a mechanism for forcibly overriding a keybinding
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.
2013-12-24 13:49:28 +11:00
Philip Peitsch 70dc7e5415 Annotations controller is always specified in a SessionController 2013-12-24 13:47:18 +11:00
Philip Peitsch 354056f68c Stop event trap from receiving focus on a mouse-down event
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
2013-12-24 00:48:20 +11:00
Philip Peitsch b17176ed34 Fix shift+click selection extending
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
2013-12-24 00:48:20 +11:00
lli cde721f758 Updated the SessionController to use the same virtual selection in both edit and read only mode. 2013-12-19 10:39:42 +11:00
Friedrich W. H. Kossebau 432100d18c No longer needed to pass focus explicitely back for IE in synchronizeWindowSelection 2013-12-18 15:35:53 +01:00
Friedrich W. H. Kossebau a521f78304 Put custom data into drag handler instead of built-in nodes text extraction, concentrate mimedata export in new gui.MimeDataExporter 2013-12-18 15:12:22 +01:00
lli 66e25e096d Move selection related operations into the new SelectionController.js 2013-12-18 23:26:30 +11:00
Philip Peitsch 372485885a Workaround Safari post-composition key press event error
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.
2013-12-18 11:05:32 +11:00
Philip Peitsch 693702f332 Support back-to-back composition end & start events
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
2013-12-18 11:05:32 +11:00
Philip Peitsch 8b6ef8f6ff Support text input using the OS’s IME system
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.
2013-12-18 11:05:32 +11:00
Philip Peitsch c665b1a57f Workaround for Firefox selection.collapse bug
Attempting to collapse a selection if a content editable element is the
current activeElement for the document will cause the collapse call to
throw an exception.

https://bugzilla.mozilla.org/show_bug.cgi?id=773137
https://bugzilla.mozilla.org/show_bug.cgi?id=787305
2013-12-18 11:05:31 +11:00
lli dca79408b0 Hyperlink usability improvement
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
2013-12-17 17:59:17 +11:00
Philip Peitsch 9ed4ac0db4 Renamed HyperlinkManager to HyperlinkController 2013-12-13 23:35:51 +11:00
lli 05f41bac2f Added hyperlink support for text elements 2013-12-13 17:40:21 +11:00
Philip Peitsch 9642b9ffe0 Re-implement select-all behaviour using new StepsTranslator interfaces
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)
2013-12-11 00:50:30 +11:00
Philip Peitsch 2ec3d857ec Re-implement the selection commands using new StepsTranslator interfaces
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.
2013-12-11 00:50:25 +11:00
Friedrich W. H. Kossebau ecf4d19c81 Clear more timeouts on call of destroy() methods 2013-12-06 14:31:41 +01:00