Commit Graph
167 Commits
Author SHA1 Message Date
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
Philip Peitsch 84e221082f Allow event focus to be returned to SessionController without scrolling to the top of the ODF canvas
Element.focus() has additional logic that attempts to bring the top of
the element into view. This causes the a document that has been vertically
scrolled to reset back to the top of the document each time an Editor
button is clicked.

This redesign abstracts the event management away, and uses an invisible
div as the primary event trap. Because the div is always visible and
centred, the browser does not perform any scrolling. Non-bubbling events
are automatically forwarded from the event trap to subscribers.

Fixes Issue #44
2013-10-04 19:24:13 +02:00
Friedrich W. H. Kossebau f46bb9e502 Change ops.OperationRouter.push to take a sequence of ops
Taking a sequence of ops also enables to give the guarantee that all
contained operations will be executed directly after each other,
in the given order. So creator of the ops can calculate the spec of each op
by relying on the known effect of the other ops.
2013-10-02 19:29:52 +02:00
Lu Li f295b71cf8 add support for inserting inline images into text document
TODO: eliminating duplicates, resize image to fit in table cell
2013-10-02 16:37:48 +10:00
Lu Li 3b5b28afd5 refactor StyleNameGenerator into ObjectNameGenerator
- moved getAllStyleNames from Formatting to ObjectNameGenerator
- renamed StyleNameGeneratorTest to ObjectNameGeneratorTest and added a couple of more unit tests
2013-10-02 13:39:35 +10:00
Philip Peitsch 06be7045ec Extract text manipulation functions from SessionController 2013-09-27 18:30:07 +02:00
Philip Peitsch a67e54ead0 Allow double-click drag selection changes
Previously, the selection was being reset back to the word-boundary
of the word that contained the cursor at the time of the double-click.

Now, the browser selection is always updated, with additional logic to
expand the selection to the nearest boundary based on the double or
triple-click status of the event.
2013-09-24 18:10:31 +10:00
Philip Peitsch eff5a99281 Fix for issue #4: reported click count can be 0 under some situations
According to the specs, the click count is 0 if the user moves the
mouse between mousedown and mouse up. The definition of "moved" seems
a little loose, meaning there are still some unfixed side-effects (e.g.,
double-click & drag will reset back to word selection).
2013-09-24 18:10:31 +10:00
Philip Peitsch ac893eccf4 Replace the current selection when the enter key is pressed
Pressing enter should clear the existing selection before adding a new
line to the document. This was missed when the functionality was added
to the insert text behaviour.
2013-09-19 12:04:19 +02:00
Friedrich W. H. Kossebau b0aa66b7b0 Magic value -> FILTER_ACCEPT 2013-09-17 17:40:17 +02:00
Friedrich W. H. Kossebau de1103fcfe Add gui.DirectParagraphStyler, a UI-less tool specialized on direct styling of paragraphs 2013-09-10 15:52:39 +02:00