55 Commits
Author SHA1 Message Date
Philip Peitsch bb56bc684c Convert odf.OdfUtils into a static singleton 2014-09-12 10:33:27 +10:00
Satvik Kumar a714866c52 Removed getParagraphElement from OdtDocument
This function only redirected to the OdfUtils version and many callers
already had an existing instance of OdfUtils to use. Any callers who did
not have an instance of OdfUtils now create one to continue using the
function.
2014-08-13 23:15:50 +10: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
Philip Peitsch 4f631ac8f1 Remove obsolete length parameter from step insert/remove cache signals
The length parameter is incorrect under many circumstances, and has
proven so difficult to get correct that the cache implementation now
ignores it entirely. Remove this tech debt to simplify future ops.
2014-05-23 00:44:06 +10:00
Philip Peitsch 21f2462dec Re-align downgrade whitespace logic to match upgrade whitespace
Downgrade whitespace now follows the same logic as upgrade, and will
downgrade a whitespace element just to the left of the step, and to the
left of the next step to the right.

Using step iterators instead of position iterators also fixes some failing
operation tests by ensuring one step to the right is checked irrespective
of how many positions there are between steps.
2014-05-16 21:40:13 +10:00
Philip Peitsch db1dd02731 Allow insert text op to gracefully cope with strange whitespace
If an insert text operation is created that contains non-tab non-space
whitespace characters (e.g, \r\n etc.), these will now be treated as if
they were simply space characters and inserted accordingly. A warning
is logged for diagnostics purposes.

This prevents crashing on unexpected behaviour because the number of
inserted steps is consistent with the operation's text length.
2014-04-17 19:36:26 +10: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
Jos van den Oever ddcb6009eb Add a number of more precise types and remove unneeded casts. 2014-02-10 15:59:37 +01:00
Jos van den Oever ffb52fbfa6 Make gui.SelectionView, ops.EditInfo, and ops.OpInsertText 100% typed. 2014-02-08 10:37:22 +01:00
Jos van den Oever 8a171bb30f Make gui.TrivialUndoManager and gui.UndoStateRules 100% typed. 2014-02-05 15:28:06 +01:00
Jos van den Oever a9e64e645f Remove circular dependency between OdtDocument and OdtCursor.
OdtCursor does not depend on OdtDocument any more. In fact, it is not specific
to ODF any more so at some point it could be renamed.
2014-02-05 14:24:25 +01:00
Friedrich W. H. Kossebau d2671e2a00 @returns -> @return 2014-01-31 15:33:43 +01:00
Philip Peitsch b17147ed47 New cursor re-arrangement behaviour for OdtDocument.getTextNodeAtStep
The new logic no longer provides special behaviour for the requested member's
cursor. Instead, all inserted data will occur after any cursors occupying
that particular step.
2013-12-05 17:26:19 +01:00
Aditya Bhatt 47db07fb99 * Add an additional flag moveCursor to OpInsertText,
and obey it to explicitly move the cursor to the
desired resultant position.
When doing this, take care to specify the correct
textnode position for text insertion (i.e. before
or after the cursor).
* Adapt the rest of the code that uses OpInsertText
to pass the correct moveCursor flag (true).
* Remove the 'return null' from the transform of
InsertText vs InsertText.
2013-12-05 17:26:19 +01:00
Jos van den Oever 619e47b1d5 Add types to operations and operation matrix. 2013-11-26 16:56:00 +01:00
Aditya Bhatt bfdc14b907 Add isEdit properties to all operation classes
to make life easier by avoiding the need to listen
to various signals or look at optypes when you just
want to know whether any edits have taken place.
2013-11-22 20:35:29 +01:00
Philip Peitsch dd166cb00c Refactor getPostionInTextNode to use cached step information
The new implementation should be equivalent in every way, except
it now is able to benefit from the cached step information to be
significantly more faster.

This patch also addresses parts of issue #3.
2013-11-14 20:28:36 +11:00
Philip Peitsch 410280fe14 Add signals necessary to keep a caching implementation in sync with the document 2013-11-14 20:28:33 +11:00
Philip Peitsch e4e7618a84 Always upgrade the final whitespace in inserted text
The final character of inserted text must always be upgraded
on insertion, and conditionally downgraded post-insertion.
This covers the situation where a space is inserted as the last
character in a paragraph. In this instance, the space must be
a space character so it isn't discarded as trailing insignificant
whitespace.
2013-11-06 23:03:52 +11:00
Philip Peitsch 367a5a0d94 Call Node.insertBefore with null rather than undefined
IE10 will throw an error if Node.insertBefore is called with the second
argument
as null rather than undefined.
2013-10-25 00:34:19 +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
Friedrich W. H. Kossebau 4f584a5efe Fix inserting text at positions with other cursors, but not the one of the same member 2013-09-23 13:34:52 +02:00
Philip Peitsch b09acfc983 Correctly calculate nodeOffset when joining text nodes together
* Downgrade all positions that are potentially upgraded
2013-09-20 00:05:33 +10:00
Philip Peitsch bc09db181c Upgrade/downgrade whitespace around boundaries near inserted and removed text
Under various conditions inserting or removing text should cause existing
whitespace to be upgraded, or allow it to be downgraded. Note, OpSplitParagraph
doesn't require downgrade checks as a split paragraph always requires
any leading or trailing spaces to be upgraded.
2013-09-19 12:16:53 +02:00
Philip Peitsch 476c487318 Make OpInsertText only add space elements when necessary
Overuse of space elements when pasting text causes the "justified"
paragraph alignment to appear to not function. Both LO and a standard
web browser do not expand the spacing inside space elements when the
paragraph is justified, resulting in it appearing to be simply left-aligned.
2013-09-19 12:16:53 +02:00
Philip Peitsch d40c02f444 Remove unnecessary cursor workaround
The cursor range is now automatically reset every time the cursor's
getSelectedRange method is called. This negates the need for this
workaround.
2013-09-19 12:16:53 +02:00
Friedrich W. H. Kossebau decaaeaf4e use OdtDocument.getDOM() consistently 2013-08-13 00:22:22 +02:00
Aditya Bhatt 374ffc2fbc * Allow annotations to be enabled/disabled via OdfCanvas
* Documentation++
* Enable annotations by default in editor and viewer.
* Detach range in highlighter after use

Also: Annotation handling is broken when annotations overlap. Add TODO for
that.
2013-08-01 16:17:08 +02:00
Aditya Bhatt 7d6c95d9f2 A new AnnotationManager class in gui that handles wrapping the
annotation in html containers, adds connector elements, and a text
highlight.
Trigger OdfCanvas's anntationManager instance whenever any text
modification operation occurs.
2013-08-01 16:17:00 +02:00
Jos van den Oever 967e5c0ba0 Update closure compiler and fix ensuing problems. 2013-07-24 17:56:39 +02:00
Lu Li 03915b2896 handle Tab key 2013-07-24 12:08:38 +02:00
Philip Peitsch eca37e6771 Modified Cursor api to allow the selection to be specified directly
This provides better encapsulation and clarifies the usage slightly.
Hopefully, it will decrease the ways to cause the selection & actual
cursor position can get out of sync.

As this was the only use of the Selection stack, the whole class is
now removed
2013-06-12 16:30:48 +10:00
Philip Peitsch d81584cb6a Preserve cursor selection during text insertion 2013-05-28 15:35:57 +10:00
Aditya Bhatt 4cb5d5fb93 * Give rightmost-priority to the cursor with the current memberid, if
specified in getPositionInTextNode. Also, if there is a preferred cursor
node, then return the empty text node as immediately to the left of that
cursor.
* Add the memberid argument to it's call in OpInsertText. Now if many
cursors are at the same position and one cursor inserts text, the others
don't move along.
2013-05-23 14:42:26 +02:00
Aditya Bhatt 59da7fb421 split previousnode before insertion with an offset 2013-05-13 10:18:10 +00:00
Aditya Bhatt db760b568e Check for length of texts[i], not texts. 2013-05-13 10:18:10 +00:00
Aditya Bhatt 60fe6497aa Less textNode creation and faster text insertion. 2013-05-13 10:18:10 +00:00
Aditya Bhatt f6af4ee88a Handle insertion offsets more gracefully 2013-05-13 10:18:10 +00:00
Aditya Bhatt b1f1c261c5 Create text nodes only when necessary during string insertion 2013-05-13 10:18:10 +00:00
Aditya Bhatt b92389c98d * Stop using cursorTextNode, and use the simplest way to delete and
split textNodes for a cursor.
* Delete any empty text nodes that are created and unused during
insertion.
2013-05-13 10:18:10 +00:00
Aditya Bhatt 8d57a04c8e Insert text:s elements instead of spaces in OpInsertText.
Also make the cursor behave properly around such elements.
2013-05-13 10:18:10 +00:00
Friedrich W. H. Kossebau be545658d7 Trigger an update of the canvas size on changes of the content/styles
The root node element of the flat ODF, <document>, is not a direct child of the
variable "sizer" in the odf.OdfCanvas code) which is used to implement the
zooming feature, by using the scale() transformation via the styles.
Problem is that this scaling does not also scale the actual space used by the
element. To fix this there is a method fixContainerSize() which is used to adapt
the size of the canvas element to the actual rendering size of the document
content. This code then sets the width and height properties to fixed values.
But all this results in another problem: the canvas element is not resized
automatically by the usual DOM behaviour if the content below the <document>
 node or the CSS applied to it parts is changed.

The initial plan was to use DOMSubtreeModified & friends, to have the
odf.OdfCanvas care for updates itself. But as it seems outdated and has quite
some overhead on larger changes to the document, in the end it was decided to go
for now with the approach that was chosen for the style changes, to rely on the
document modifying ops to trigger the needed canvas updates themselves. Not
perfect, but seemed consistent at least.
2013-04-24 11:20:08 +02:00
Friedrich W. H. Kossebau 263002f70f Update Copyright years of ops code files 2013-04-09 13:45:33 +02:00
Friedrich W. H. Kossebau 16f634ce1a Have ops return the success of their execute 2013-04-09 13:45:33 +02:00
Friedrich W. H. Kossebau 6f5ced4d1e Do not pass session as parameter to the ops contructors, pass odtDocument instead of domroot in the execute method 2013-04-09 13:45:33 +02:00
Friedrich W. H. Kossebau 7868d6bfa3 Move eventNotifier from ops.Session to ops.OdtDocument 2013-04-09 13:45:33 +02:00
Friedrich W. H. Kossebau 54b3a1381c move all DOM manipulation code to the ops
Also:
* merge paragraphEdited event of ops.OdtDocument into paragraphChanged event of ops.Session
* remove any event subscription/emitting from ops.OdtDocument
2013-04-09 13:44:49 +02:00
Aditya Bhatt 9d8bd8e063 Add timestamp fields to operation specs 2013-03-14 18:21:03 +05:30
Friedrich W. H. Kossebau 6a568a8f58 Split ops.OdtCursor from core.Cursor & rename ops.Document to ops.OdtDocument
Also:
* rename gui.CaretTests to ops.OdtCursorTests (as it is testing ops.OdtCursor)
* remove test-less CaretTests.js, had broken setup now
2013-03-06 15:44:28 +01:00