Commit Graph
205 Commits
Author SHA1 Message Date
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
Philip Peitsch f56f474494 Reset the browser selection on drag end
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.
2013-12-05 17:49:09 +11:00
Philip Peitsch a5173eaf71 Don't synchronize browser & WebODF selections unnecessarily
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.
2013-12-05 17:35:42 +11:00
Philip Peitsch b77b99719d Reset selection to collapse on anchor when performing shift+click
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.
2013-11-30 01:18:28 +11:00
Philip Peitsch 93ba89b2d5 Expand to word and paragraph boundaries on mouse down
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.
2013-11-30 01:18:28 +11:00
Philip Peitsch bc7677af0e Don't allow paragraph selection to creep after mouse release
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.
2013-11-30 01:18:28 +11:00
Philip Peitsch a662d7b2c6 Constrain anchor and focus nodes to the containing paragraph
This ensures that a cursor or selection remains within the
current paragraph container.

Fixes issue #161.
2013-11-30 01:17:54 +11:00
Philip Peitsch 5db32daa9d Ensure expand to word and paragraph boundaries keep selection direction
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.
2013-11-30 00:58:51 +11:00
Philip Peitsch 533c4d5681 Batch up multiple calls to redraw selection region
This does not need to be done immediately after every operation.
2013-11-30 00:54:05 +11:00
Jos van den Oever 3c96e17009 Make sure the cursor always has a Range. 2013-11-26 16:56:01 +01:00
Jos van den Oever 6e217df8a4 Better typechecking in SessionController and Namespaces. 2013-11-26 16:55:00 +01:00
Friedrich W. H. Kossebau 248e35ad8b Rename AnnotationManager to AnnotationController
also call do not call AnnotationViewManager objects not annotationManager
2013-11-19 19:56:15 +01:00
Philip Peitsch b5f848861e Restore focus to canvas without clearing selection in IE10
This also requires the next focus event to be suppressed after modifying
the selection
2013-11-19 20:25:17 +11:00
Friedrich W. H. Kossebau db0ecac6ee Make directTextStyler no longer optional, now that it works also in collab mode 2013-11-15 15:30:32 +01:00
Philip Peitsch cc0613754d Clarified Pasteboard.paste to Pasteboard.createPasteOps to be indicate behaviour 2013-11-15 18:42:17 +11:00
Philip Peitsch 13cd41b018 Pasting data will replace the currently selected content 2013-11-15 18:42:17 +11:00
Philip Peitsch 9f93032a4e Add support for pasting plain text with line breaks
Pasting plain text with line breaks allows intelligent
merging into lists as well as multiple paragraphs.

Currently does not do the right thing on undo/redo,
as the undo manager does not respect operation groups
(yet).
2013-11-15 18:42:17 +11:00
Philip Peitsch 07ba518034 Simplify select-all codepath to not require custom iterators 2013-11-14 20:28:35 +11:00
Philip Peitsch eb15563fd3 Use cached step translator to speed up cursor movement operations
The new step translator is also stricter about the requested number
of steps and will assert if more steps are requested than are available
in the document. This revealed a test that was asking for an invalid
step.
2013-11-14 20:28:35 +11:00
Philip Peitsch abb9e55dd1 Cope with translating DOM points outside the root node to steps
Previously, various consumers needed to be careful about only
asking for nodes inside the root node. Failure to do so resulted
in unpredictable behaviour.

To simplify the interface and improve the system robustness, this
rounding is now taken care of behind the StepsTranslator interface.
2013-11-14 20:28:33 +11:00
Philip Peitsch ba18df5017 Add profiling and performance application
Custom documents can be specified in the url by adding
the file-name after the url #. E.g., "src-index.html#1000pages.odt"
2013-11-13 17:39:18 +11:00
Philip Peitsch eeac880f46 Improve mouse selection peformance by throttling shadow cursor redrawing
Drawing the cursor on every mouse move event badly impacts the responsiveness
of the application, because the move events buffer in the browser until
every single event is processed. By setting these on a background timer,
the cursor is updated asap, but is able to aggregate multiple move events
received in this time period.
2013-10-31 23:07:02 +11:00
Philip Peitsch bea6e447ec Don't synchronize the shadow cursor to window selection and back
The shadow cursor has a stand-alone range that can be passed straight
into the processing logic that updates the input member's cursor.
2013-10-29 17:08:48 +11:00