Commit Graph
276 Commits
Author SHA1 Message Date
Jos van den Oever b8ad5b3889 Upgrade to Closure Compiler 20150505.
We are now using our own copy of the externs to deal with differences
of opinion on best typing of types.
2015-06-01 08:53:35 +02:00
Philip Peitsch bb56bc684c Convert odf.OdfUtils into a static singleton 2014-09-12 10:33:27 +10:00
Philip Peitsch 3172ad8dec Convert core.DomUtils into a static singleton 2014-09-12 10:17:09 +10:00
Philip Peitsch 6aa01c682e Optimize all existing uses of getElementsByTagNameNS
Transformed all read-only uses to use node.getElements*. Any loop that
immediately modifies the nodes in the list has been updated to use the
DomUtils.getElements* version.
2014-09-11 15:10:41 +10:00
Philip Peitsch d18d2b5b8a Migrate SelectionMover.createPositionIterator to OdtDocument
Remove the SelectionMover file entirely as it no longer contains any
functionality.
2014-08-05 10:12:17 +10:00
Philip Peitsch 5b7cd7c543 Re-implement up/down movements caching the last caret X position
When navigating vi the up/down arrow keys, the user often wants to move
multiple lines in sequence (e.g., to visually place the caret in one of
the following lines). To stop the caret suddenly jumping to the left
side of the page when crossing an empty paragraph, the caret's X position
will be stored and re-used by subsequent up/down movement for up to 2s
after navigating by line.

Any other operations performed by the local user (e.g., cursor movement
to the left or right), or edit operations by collaborative users will
immediately clear the stored X position.
2014-07-23 02:17:20 +10:00
Friedrich W. H. Kossebau 561c18fd9d Handle IE10 obv. destructing event objects once the event handler is done 2014-07-16 19:20:07 +02:00
Philip Peitsch 3c1f13db24 Ensure various places always have a valid root element
There is a small edge between the canvas border and the office:text
element that the user can click in. Doing this returns null for the root
element (as it is the container that contains the office:text element),
causing an unhandled null reference exception to occur in some
circumstances.

Fixes #664.
2014-06-20 23:14:50 +10:00
Aditya Bhatt a30858b8c3 Rename SessionContextCache to SessionContext.
Stops caching cursor range.
2014-06-06 15:11:32 +02:00
Aditya Bhatt 4cea53f817 Make PasteController respect review mode constraints. 2014-06-06 15:11:32 +02:00
Aditya Bhatt c4387a83ad Turn PlainTextPasteboard into PasteController. 2014-06-06 15:11:31 +02:00
Aditya Bhatt f36aa2f79b Make text editing respect review mode constraints. 2014-06-06 15:11:31 +02:00
Aditya Bhatt b02e11f1cc Make image insertion respect review mode constraints. 2014-06-06 15:11:31 +02:00
Aditya Bhatt 58cbeabf19 Make hyperlink editing respect review mode constraints. 2014-06-06 15:11:31 +02:00
Aditya Bhatt 3f09a7d3b7 Add a new gui.SessionContextCache convenience class.
It lazily computes required information and caches it
for further use -- an initial method inside it is
isLocalCursorWithinOwnAnnotation, which contains the logic
moved from DirectFormattingController. It would have been
expensive to perform this check separately everytime the
cursor moves in each controller.
2014-06-06 15:11:31 +02:00
Aditya Bhatt 1467ea6d2a Introduce "Review Mode".
Let DirectFormattingController obey this "edit.reviewMode"
constraint by not creating any operations or processing any
action to format text when the cursor is not within the local
user's annotation.

Signals are exposed to toolbar widgets so they may
enable/disable themselves on the fly depending on the cursor
context.
2014-06-06 15:11:29 +02:00
Aditya Bhatt 51ee5624c4 Add a constraint to disallow deleting others' annotations.
This introduces SessionConstraints into SessionController
and AnnotationController. The latter comes with a new
permission, namely "edit.annotations.onlyDeleteOwn".

Code is added into AnnotationController to check
for the author name of the annotation node to be deleted,
and do nothing if it matches the name of the current
user.
2014-06-06 14:30:44 +02:00
Friedrich W. H. Kossebau 1e2a4a8323 Normalize license headers of the webodf.js source files
* remove @license tag (to prevent Closure compiler keeping the comment)
* use copyright@kogmbh.com email address everywhere
* remove "additional permission", to be added only to released webodf.js
* separate license header by empty line from following content
2014-06-02 12:19:05 +02:00
Friedrich W. H. Kossebau 5e3d2d708f Add gui.MetadataController 2014-05-27 15:03:53 +02:00
Friedrich W. H. Kossebau b91a97c21f add flags to enable/disable all editor (toolbar) action sets 2014-05-27 13:42:28 +02:00
Friedrich W. H. Kossebau fa62c38767 remove no more needed returning of the class constructor at end of class files
runtime.loadClass(...) no longer expects that eval(fileContent) yields
the constructor, and a few loaded files rely on that (e.g. all singletons/namespaces),
so let's be consistent
2014-05-22 13:31:51 +02:00
Philip Peitsch 6dc6e8a7f4 Ensure focus is returned to the event trap after an undo
This behaviour regressed in c0332ed due to the caret overlay element
being moved inside the overlay itself. As a result, the event trap was
automatically being re-added after an undo, causing the SessionController
to incorrectly skip returning focus back to the trap upon completion.
2014-05-21 00:28:50 +10:00
Philip Peitsch 2e7b1b9242 Maintain selection when right-clicking on a range that ends at an image
On OSX, right-clicking on an image at the end of a range selection will
hit this particular branch. The image should remain selected if the
right-click occurs on top of it as technically it's the same behaviour
as right clicking on an existing text selection.
2014-05-09 17:39:20 +10:00
Philip Peitsch 435a82ca58 Add some additional documentation to mouse click handling 2014-05-09 17:39:20 +10:00
Philip Peitsch fb2cd2e36f Only update the cursor selection once per mouse-down
In Chrome, right-clicking repeatedly generates both a contextmenu AND
a mouseup event for subsequent clicks. E.g. a sequence of right clicks
generates:
1st - mousedown, contextmenu
2nd...nth - mousedown, contextmenu, mouseup

This causes problems when clicking on images as the selection is
immediately reset after being processed by the first context menu,
causing the subsequent mouseup event to try and reset the cursor
selection *again*.
2014-05-09 17:39:19 +10:00
Philip Peitsch 8b2ed7f692 Add todo for existing flaw in mouse-selection click handling 2014-04-17 21:37:58 +10:00
Philip Peitsch 408efb6a90 Only expand selection on multiple clicks with the primary mouse button
Chrome + WebKit increment the click count value for the MouseEvent even
if the user switches buttons. E.g., a double click then right click
will report the last event as {button: 2, detail: 3}, causing the
selection to expand to the paragraph bounds.

Now, the click count is only reported as non-zero if the current event
is with the primary mouse button (left by default, or the right button
if the user has switched their primary mouse button around).
2014-04-17 21:37:57 +10:00
Philip Peitsch 38cbe0746d Support text composition events that contain line breaks
Using the paste-handler for text that contains new lines
allows the inserted text to correctly create new paragraphs
as necessary.
2014-04-17 19:36:27 +10:00
Friedrich W. H. Kossebau f0fe627c70 Add assertion that sessionController and sessionview agree about annotation editing 2014-04-14 15:24:26 +02:00
Friedrich W. H. Kossebau 545ece257f Fix: disable annotation creation key combo in collab editor 2014-04-14 13:11:38 +02:00
Friedrich W. H. Kossebau fd020eee3f Use Error objects in callback passed to "destroy" methods
The currently plain undefined objects are not useful at all, because
the properties are undefined.
2014-04-11 13:53:10 +02:00
Philip Peitsch a4e08ba851 Schedule UI updates using requestAnimationFrame rather than setTimeout
Using requestAnimationFrame ensures the callback is executed prior to
the next redraw, eliminating undesirable & highly visible flickers for
UI updates.

Fixes issue #491.
2014-03-28 00:12:34 +11:00
Philip Peitsch d2b7d63905 Move control of event trap inside the EventManager
Management of the event trap is not related to the IME. Moving the
coordination of the disabled and readOnly flags inside the EventManager
better hides these concepts from external consumers.
2014-03-26 10:41:22 +11:00
Philip Peitsch 158f873ab8 Refactor HyperlinkClickHandler to cleanup event binding
Move control of event bindings from SessionController to
HyperlinkClickHandler so bindings will be updated whenever modifier is
changed. This allows some simplification as HyperlinkClickHandler can
simply use the KeyboardHandler.Modifier.
2014-03-17 22:39:08 +11:00
Friedrich W. H. Kossebau 74ae34fef7 turn core.Async from class to namespace 2014-03-13 22:22:10 +01:00
Philip Peitsch dbb56a1ab9 Normalize keyboard events involving modifiers
For keys that are also modifiers (e.g., Ctrl), different browsers +
platforms may report the modifier flag as leading or lagging the
keypress event. For example, pressing the ctrl key in FF on Linux will
report (ctrlKey:false)in the keydown event, while Chrome on Linux will
report (ctrlKey:true) in the keydown event. For these specific cases,
normalize the modifier flag so it is always the set to true.

Fixes issue #322.
2014-03-11 23:33:34 +11:00
Philip Peitsch 80b94262d4 Toggle hyperlink active state via classes rather than custom XML attrs
Toggling a custom attribute on a custom XML element doesn't properly
update the visual state on some browsers (e.g., WebKit on OSX). Using
CSS classes instead seems to be better handled in these browsers,
correctly updating the mouse cursor icon on the fly.
2014-03-11 22:52:58 +11:00
Friedrich W. H. Kossebau 6232bd0917 prefix "draggable" element classname with "webodf-" 2014-03-10 15:43:48 +01:00
Aditya Bhatt db41d92cfa Inject srcElement property in CompoundEvents
for IE
2014-03-07 18:45:52 +01:00
Aditya Bhatt 92418f5eaf Make selections touch-modifiable with handles.
Two new compound events:
* 'drag', which depends on 'touchstart', 'touchmove',
and 'touchend. It fires whenever a finger is placed
on an element with class 'draggable', and then moved.
* 'dragstop', which depends on 'drag' and 'touchend'.
It fires whenever the finger is lifted after a drag
on a draggable element.

SessionController, upon encountering a drag event on
a selection handle, updates the shadow cursor's selection
to match the one prescribed by the handle movement, thus
being very fast.

When a dragstop event is encountered, the selection of
the shadow cursor is fed to the local member's cursor
via SelectionController, thus utilizing an op.
2014-03-07 18:45:52 +01:00
Aditya Bhatt 6f5d5fcb33 Add a CompoundEvent class which represents
an event that can be represented as a logical
composition of several events working together.

As a first usage of this class, the 'longpress' event
is introduced.
This event fires once when a finger is placed against the
screen for 400 milliseconds without moving or lifting.

Select a word when long-pressing on it.
2014-03-07 16:42:51 +01:00
Philip Peitsch c0d8d41ea2 Expose the SessionController's undo/redo interfaces for the editor
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.
2014-02-27 13:33:23 +11:00
Aditya Bhatt 953f6fd379 Merge pull request #410 from adityab/apple-keyboard
iOS keyboard support
2014-02-25 10:53:16 +00:00
Aditya Bhatt bad4703d50 Introduce IOSSafariSupport: Suppress auto-scrolling
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.
2014-02-24 17:51:58 +01:00
Jos van den Oever b3c77bf307 Move signals CursorAdded, CursorRemoved and CursorMoved to ops.Document.
This makes SvgSelectionView independent from ops.OdtDocument.
2014-02-24 15:13:13 +01:00
Aditya Bhatt 8376adb05b iOS Safari: Move/Open virtual keyboard by tap.
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.
2014-02-24 12:55:35 +01:00
Aditya Bhatt 67c1c23c24 Make only EventManager handle eventTrap in the
DOM.
Restore the eventTrap and focus on undo.
2014-02-20 17:35:09 +01:00
Aditya Bhatt 94d26139ac Overlay the eventTrap outside and over the cursor.
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.
2014-02-20 17:35:09 +01:00
lli 0b38def220 Fix an image related selection issue
At the moment if user start a selection in text and then release the mouse on an
image. It loses the selection and just selects the image.
2014-02-20 23:31:00 +11:00
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