Commit Graph
177 Commits
Author SHA1 Message Date
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
Philip Peitsch 8404a2f2eb Don't modify window selection during drag
Resynchronising the shadow cursor back to the window during a drag or
mouse-move operation is ignored in Chrome & FF, but causes exceptions
and strange selection behaviour in IE. There is no benefit to doing
this, as the selection is resynchronized on mouse-up regardless.
2013-10-28 23:48:42 +11:00
Philip Peitsch c07fc903d8 Removed obsolete code
SessionController.countStepsToNode is superseded by
OdtDocument.getDistanceFromCursor. All these checks are now done within
other layers
2013-10-28 23:30:13 +11:00
Philip Peitsch ecec173d8f Cache event-related details when calculating the range from current selection
Internet explorer will occasionally discard the event before the timeout
callback is triggered, resulting in "Member not found" exceptions being
thrown.
2013-10-25 20:39:05 +11:00
Philip Peitsch 3623d07fed Handle IE10's non-standard event target name 2013-10-25 20:39:04 +11:00
Philip Peitsch 374f701da5 Compare event.which with actual value that is found in Internet Explorer 2013-10-25 20:24:38 +11:00
Philip Peitsch f5c6dd5eac Work around browsers that do no support selection.extend (IE) 2013-10-25 00:36:15 +11:00
Friedrich W. H. Kossebau c2a795e668 Update link to repo: now https://github.com/kogmbh/WebODF/ 2013-10-23 18:20:30 +02:00
Friedrich W. H. Kossebau 508570dab8 Add copy of the AGPL3 to sources (+ add to created zip files) 2013-10-21 17:55:16 +02:00
Philip Peitsch 9b32db4471 Clear any image selection chrome when exiting edit mode
Additionally, since the browser selection is no longer rendered, there
is no longer any reason to NOT synchronise it with the cursor selection.
2013-10-17 16:15:25 +11:00
Friedrich W. H. Kossebau 3b94a58e99 Add keyboard shortcut to create an annotation 2013-10-16 17:20:32 +02:00
Friedrich W. H. Kossebau 80e75c6b73 Separate annotation handling logic into a tool class AnnotationManager and UI into a editor/widgets/annotation.js
Also enable "Add annotation" button only if not inside annotations
2013-10-16 17:20:14 +02:00
Philip Peitsch ed80b875ea Only hide the browser selection once edit-mode is enabled
The recent shadow cursor implementation hides the native browser selection
highlights. However, the shadow cursor itself only starts being drawn
after edit-mode is enabled, meaning for a readonly document the selection
is invisible (#119)

This is a simple workaround that allows the native selection to be drawn
in circumstances where the shadow cursor is not active. Long term, the
shadow cursor should be also used on non-editable documents as detailed
in solution ideas for #119.
2013-10-16 21:42:59 +11:00
Philip Peitsch 71d757ce4c More tightly couple direct styling support to text manipulator
At this point, this is not intended to be open for extension as it is too
easy to break OT logic by incorrectly manipulating the operation groups.
Instead, convert this to use a specific-built extension point under tight
control of WebODF.
2013-10-16 01:31:38 +11:00
Philip Peitsch cb6292d7a1 Clear the last image selection when drawing a new virtual selection 2013-10-15 22:48:57 +11:00
Philip Peitsch a283fafc04 Cope with the window having no current selection when changing the shadow cursor 2013-10-15 21:45:29 +11:00
lli 87a378aee3 Only respond to the following keyboard events for image selection.
esc, tab, delete, backspace, undo/redo and copy/cut.

Note: MS Word behave differently from LO/AOO when image is selected.
When press letters,numbers&symbols, MS Word inserts the text just before the
image; where LO/AOO ignores all of them.
Also you can extend selectiion using keyboard shortcuts (e.g
shift+left) in MS Word, but you cannot do so in LO/AOO.

TODO:
Esc - deselect image
Tab - move to next frame in the document
2013-10-15 21:42:21 +11:00
lli 7580166fec Support image selection
*Added a ImageSelector class to draw and clear image selection

Known issue:
The selection box is moving up and down when using browser's zooming functionality. but it is working fine with the slider zoom
2013-10-15 21:42:20 +11:00
Aditya Bhatt 05d8d6ce29 * Make hand-drawn selections have proper direction.
* All cursor classes gain hasForwardSelection() methods.
* maintainCursorSelection now preserves selection direction.
2013-10-15 11:47:42 +02:00
Aditya Bhatt aae55aca50 * Add a new ShadowCursor class. This class is meant, for now, to only
hold the 'selected range' fed to it, like with any other OdtCursor. It
provides a minimal OdtCursor-like interface, with only the methods
absolutely required to make it work. It does not modify the DOM in any
way.
* Make the shadowCursor object an instance of ShadowCursor, not
OdtCursor. This is ideal because ShadowCursor does not modify anything
in the DOM, and therefore is safer and faster to use for tracking
browser selections. This makes backwards-selections work finally,
because now there are no anchor nodes to interfere with the selection
whilst dragging.
* With the introduction of the ShadowCursor, we no longer have the
selection range's endpoints coinciding the with beginning and end of the
respective startContainer and endContainer. Therefore, modify
getExtremeRanges to reflect this. If an endpoint of the selection range
does not lie within a TextNode, we latch on to the nearest text node
within.
* In the SessionController, call maintainShadowSelection() if the
selection might leak outside the allowed local root, so that the
window selection object remains root-confined.
* Clone ranges if they may be later modified.
Properly detach ranges once they are used in SelectionView, less
memory leaks.
2013-10-15 11:44:24 +02:00
Aditya Bhatt b426aab73f Add a SelectionView class that can be initialized with a cursor, a
SelectionViewManager that maintains SelectionView instances, and a
shadow cursor object that is an invisible caret-less cursor, fed to both
SessionController and SessionView, which follows the selection as it
changes.
Selections by each cursor are colored according to their memberid
2013-10-15 11:44:23 +02:00
Philip Peitsch 36f502ede2 Fix shift+click selection extension for reverse selections (FF and older Chrome)
The selection direction was being lost when the window's current selection
was resynchronised to the cursor selection. For firefox and some versions
of Chrome, this would cause selection extension behaviours (shift+click)
to work incorrectly when attempting to extend the selection to the left
of the caret.
2013-10-15 09:29:23 +02:00
Friedrich W. H. Kossebau 290822b18d Remove loading of no longer used op classes in SelectionController 2013-10-12 15:39:23 +02:00
Philip Peitsch 04a5bee3b4 Re-implement focus-without-scroll behaviour in Chrome
Previous fix attempt for issue #44 had the unintented side effect of
stopping shift+click from expanding the selection (issue #109).

The scroll-on-change behaviour has actually already been modified as
part of 90d6776. The delay put in to CaretManager.ensureCaretVisible now
ensures the caret is scrolled into view correctly once focus has been
properly set. This eliminates the need for the hidden event trap.

Fixes issue #109

Relevant test:
https://chromium.googlesource.com/chromium/blink/+/ae8d18613905f501a3ce9ba83193fe77e920afbf/LayoutTests/fast/scrolling/scroll-element-into-view.html
2013-10-09 20:11:05 +11:00
Philip Peitsch 90d67768d0 Move the cursor to the start of the annotation that has been removed
Moving the cursor to the start of the removed annotation allows the
scrollIntoView behaviour to work more smoothly. Previously, removing an on-

screen annotation would likely result in the view being reset to the
cursor which was potentially offscreen at the time.

Fixes issue #33
2013-10-07 17:48:05 +02:00
Philip Peitsch d0fcc26578 Allow public access to the SessionController's keyboard handler
This is the first step towards allowing external users to modify (or
disable) the built-in webodf keyboard shortcuts.
2013-10-07 17:15:03 +11:00
Philip Peitsch 5a04cb04e2 Prevent the backspace key from causing the browser to go back in history
The recent extraction of text manipulation functions slightly changed
the backspace key behaviour. The new interface was only returning true
if an operation was generated as a result of the call (aligning with
all other public functions on the class). This means however that back-
spacing when there is no available positions (e.g., at the beginning of
a document) was causing the browser to navigate back a page.
2013-10-07 17:15:03 +11:00
Philip Peitsch a610f3007e Ensure the selection is reset again after the event trap receives focus
The focus event will sometimes update the window's current selection
after all event handlers have been called (observed on FF24, OSX).
2013-10-04 19:24:13 +02:00
Philip Peitsch f65122d611 Redraw the current user's selection when switching focus back to the event manager 2013-10-04 19:24:13 +02:00