Commit Graph
153 Commits
Author SHA1 Message Date
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
Friedrich W. H. Kossebau eb57ef2def Add gui.DirectTextStyler, a UI-less tool specialized on direct styling of text 2013-09-10 13:02:28 +02:00
Philip Peitsch 108809dd0b Replace click handler with equivalent event.detail property
As per http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseup,
event.detail records the number of clicks in the same way ClickHandler
was attempting to.

This has the happy side-effect of fixing an issue where double or triple
clicking on the editor's toolbar would result in the selection expanding
to word or paragraph boundaries.
2013-09-09 09:22:54 +10:00
Philip Peitsch 2b15d50727 Add support for direct paragraph styling
Supported commands include:
- Paragraph alignment (left, center, right, justify)
- Paragraph indentation/unindentation
2013-09-06 10:38:14 +10:00
Friedrich W. H. Kossebau 3662d04807 Adding a destroy() method to most classes, for proper shutdown 2013-09-03 01:02:48 +02:00
Philip Peitsch 41ff062e6b Only update the user's selection if the mouse down occurs within the canvas
This fixes a regression introduced in f7e9c89. Binding to the global
window's mouse up is necessary to allow the user selection to update.
The change introduced an undesirable side-effect though that caused clicks
entirely outside the odf canvas to reset the user selection to the
first or last position in the document.
2013-08-30 16:58:25 +10:00
Lu Li 4842c428b3 double click to select the word even if it is spread across multiple text:span
eg. <text:span>he</text:span><text:span>llo</text:span>, double click 'h' or 'e' will select the whole word 'hello' instead of just 'he'
2013-08-22 12:21:14 +10:00
Aditya Bhatt d17e0a1c02 * Add a cicrular button to the annotation note in AnnotationViewManager
to delete the annotation
* Add click-handling for such buttons in SessionController
* Add OdfCanvas.forgetAnnotations() to untrack annotations
* Add OpRemoveAnnotation that takes a position within the
 annotation, and deletes that annotation. It also takes the
 walkable length of the annotation node for OT purposes.
 Any cursors inside are moved to the left of the annotation.
2013-08-14 13:49:33 +02:00
Lu Li f7e9c89607 Properly update odf cursor when mouse released ouside canvas
click and drag over a scetion of text to select it, ensuring to release the mouse-click outside of the editor. the section of text highlights but cursor remains where it was previously.
this is because the canvas element does not receive the mouse up event when releasing the mouse-click outside the canvas

changes include:
* listen to the window object rather than canvas element
* if anchor node or foucs node is outside the canvas, replace it with the closest node within the document
* ensure selectWord/selectParagraph is not called when user clicks outside of canvas
2013-08-07 11:11:53 +02:00
Lu Li 1d1e8900da refactor SessionController.js. store runtime.getWindow() in a variable; refactor selectRange method 2013-08-07 11:10:51 +02:00
Philip Peitsch 575b42ed99 Resynchronize the cursor position on a right-click selection (OSX only issue)
Right-clicking on Safari or Chrome on OSX causes the context menu to
appear, but the cursor is not properly updated to reflect the selection.
This means that the user could right-click & paste (for example), and
the text would appear where the cursor last was, rather than where
the right-click occurred. This problem does not occur on Windows.

This patch still is unable to expand to word-selection properly in the
browsers that try and do this as the current word expansion behaviour is
still broken in some circumstances.

TODO:
-Recreate browser default behaviours on right click (e.g., expand to word boundary on OSX)
2013-08-06 02:56:26 +02:00
Lu Li 7f1734b569 handle Clear key on Mac machine 2013-08-02 09:01:45 +02:00
Aditya Bhatt ae5899c4a2 Add a call odtDocument.createRootFilter to get a rootfilter, and use
that in SessionController.
Better code structure in extend/moveCursorByAdjustment
2013-08-01 18:00:02 +02:00
Aditya Bhatt ff55958701 * Better styling for annotation metadata
* A new RootFilter in OdtDocument
* A new core.PositionFilterChain to concatenate filters and chains
* Functions to convert steps between two filter spaces in SelectionMover
* A keyboardMovementsFilter = { base filter + RootFilter } chain in
SessionController, used to calculate steps to move triggered by keyboard
events. These steps are then mapped to base filter's space for op
initialization
2013-08-01 16:16:33 +02:00
Philip Peitsch daab12202a Fix incorrect cursor movement after range selection
Selecting a range of text then pressing the left or right arrow keys
(without holding shift) would cause the cursor to reset back to the
anchor node (front of the selection) rather than the focus node (end
of the selection).

The existing code was mis-using selection.position, which odtDocument
indicates is the anchor node. This was made more obvious by dividing
cursor adjustments up into extend vs. move commands.
2013-07-30 12:56:33 +02:00