Commit graph

1110 commits

Author SHA1 Message Date
Catrope 80db7a593e Rethink of structural replacement code
Splits and merges now work, or at least the tests for it pass

The strategy I used is to gather the affected ranges for each of the
following:
* removed stuff
* the entirety of each node touched by a non-zero removal
* if the inserted data busts out of its parent, the entirety of that
  parent node (the 'scope')
then get the covering range of all those ranges, and rebuild that.

Change-Id: I7c3b421abc0ba134157ac8b59042675bb1b5073c
2012-05-16 16:48:02 -07:00
Catrope 5e4f0293f2 Add ve.Range.coveringRange()
Change-Id: Ifd9932d7a9f9dae2354fa7aa75cee2e3e639ef42
2012-05-16 16:48:02 -07:00
Catrope 6f4b68274d Rename removeLevel to insertLevel
Change-Id: I339c830547d19af0b04927e1ebccd0468c9e2a20
2012-05-16 16:48:02 -07:00
Rob Moen fbaea888b9 Rewrite data model methods needed for ui tools
getAnnotationRangeFromOffset and offsetContainsAnnotation
which deprecated getAnnotationBoundaries, and getIndexOfAnnotation
write unit tests for proof

Change-Id: I6c0d4e3ca96dd569b1909cd22fce68c3a6fe382c
2012-05-16 15:55:01 -07:00
Catrope d6cf4fff7f Add comment about bug that makes tests accidentally pass
Change-Id: I842ffe00bdad025797f9c71f550efd24d2ce39da
2012-05-14 23:16:28 -07:00
Catrope 7e1aa2336e Support splitting nodes in replace tree sync
This means inserting things like </p><p> are now synced correctly and
split the paragraph in the model tree. Merges (removing e.g. </p><p>)
aren't supported yet.

Also, this needs tests, Trevor tells me he's working on porting replace
tests from the old ve/ directory

Change-Id: Ic5050849d7d007a1696dc36548654979aedb53a8
2012-05-14 21:46:39 -07:00
Catrope 59f74de3b8 Fix bug causing replacement tree sync to adjust the wrong node
The tree sync for content replacements was adjusting the parent of the
text node affected, rather than the text node itself. This was because
it called getNodeFromOffset(), which returns branch nodes. Switched it
to use selectNodes() in leaves mode

Change-Id: I50a9be18151a1b75815ab19b787b16b6be385bf9
2012-05-14 21:42:53 -07:00
Catrope 2008858830 Fix bug in selectNodes: input (0,0) returned []
This was because the while loop was never entered as end >= left was
true from the start. Convert the while loop to a do-while loop to make
sure it runs at least once

Change-Id: I9c6436a7b296e65a36b8301095b6edd00507d321
2012-05-14 21:41:08 -07:00
Trevor Parscal e28a1a188a Fixes typo, need to check if object is empty, not if it's an object
Related to: 14a4c7b780

Change-Id: Iede66d1e01ed010705362611e90fb4b13e7e4a1c
2012-05-14 17:22:37 -07:00
Trevor Parscal 14a4c7b780 Fixed annotation processing to support leaf nodes and detect more errors
Also added lots of tests

Change-Id: I45fe4fb569d9050d7d79f71f777d82f5b34fdd11
2012-05-14 17:16:30 -07:00
Trevor Parscal 94613589e0 Removed more trailing whitespace in multi-line comment blocks
Continues cleanup work done in e0de881a8a

Change-Id: I7165a8f8c4b468793d936fe695de92335c106271
2012-05-14 17:16:30 -07:00
Rob Moen 68414e4d28 give array bulider loop better names
Change-Id: I67f5b89b3e58f052c197732a1298c60ec6b8fd89
2012-05-14 16:48:10 -07:00
Rob Moen ca48a4a8a1 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-14 16:44:08 -07:00
Rob Moen d2fc95fa52 Optimize getAnnotationsFrom dramatically by less object manipulation
Now returning an empty array when a non annotated character is found
in the range.  No longer looping through each annotation, simply
comparing to previous characters annotations and trimming differences.
Write additional test.

Change-Id: I41d2422a931a74325693edca409aed6d5da20ba8
2012-05-14 16:40:49 -07:00
Catrope 5b398f95f8 Fix botched rename: opReplacement -> opInsert
Change-Id: I34091dbbc9a46466823ee7407f151fd67112ee03
2012-05-14 15:12:44 -07:00
Trevor Parscal e0de881a8a Removed trailing whitespace in multi-line comment blocks
JSHint and various git tools complain about this, so let's just do away with them altogether

Change-Id: I731866bd21f1ee0088fb0a71df3abf92692aca23
2012-05-14 15:05:09 -07:00
Trevor Parscal 03be3c0668 Removed debugger statement from 5b9a2645a6
Change-Id: I047b0c89a7420a86b9350a8d0c0fc8aec695227f
2012-05-14 14:34:50 -07:00
Rob Moen 17b58db5c6 Optimize getAnnotationsFromOffset with ve.getObjectValues
Change-Id: I2150335b6f0fa305c1d1bc93e50d30d874c76345
2012-05-14 11:34:08 -07:00
Trevor Parscal f40e4f2f9d Added ve.getObjectValues
Could maybe be optimized with map or something?

Change-Id: I033804e893bfa93f991dee9efefaa2c2d1740627
2012-05-14 11:31:18 -07:00
Trevor Parscal d7febe6009 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-14 11:15:02 -07:00
Trevor Parscal 1363e7ff89 Added ve.getObjectKeys which falls back to Object.keys if present
Change-Id: I9eedf93239b22497fe6fe6497e20b1fe0525de9c
2012-05-14 11:14:54 -07:00
Rob Moen b8302c715f Rewrite getAnnotationsFromOffset to work with new Linear Model.
Properly init variables in getAnnotationsFromRange
Polish up tests.

Change-Id: Idc231998ce27e3a1c64363e862da22c837ea2ca2
2012-05-14 10:47:48 -07:00
Rob Moen bd9a0b6fba Rewrite DocumentFragment getAnnotationsFromRange method
Write unit tests for getAnnotationsFromRange

Change-Id: I82ff15e97378c07e5c555a72231da4161a72993c
2012-05-11 16:14:46 -07:00
Catrope 5b9a2645a6 Port getScope() from the old VE code and add tests for it
Change-Id: I8c34fed919e60fa1b8cb6a13cb9ca98f3e695421
2012-05-11 16:03:46 -07:00
Catrope 43c2393c03 Remove outdated comment
Change-Id: I3a5db50aafa01d07bfb34359dfbe73812b3a7ab5
2012-05-11 16:03:46 -07:00
Trevor Parscal db0e050b39 Renamed uses of "replacement" to "insert"
Change-Id: I69ad0f84e8fefe1715339068b7685958f8f8546f
2012-05-11 15:25:01 -07:00
Christian Williams 13f26682da Removing data from annotations when empty, more tests for HTMLConverter
Change-Id: I3c3e234e9392e4afdcb4c8bc748aaa74a1fb30ca
2012-05-11 14:07:20 -07:00
Trevor Parscal 9cdfb84f9b Added tests to getRelativeContentOffset
Also fixed a typo in the implementation

Change-Id: I86855795009e34d42a3a5857addc5ccb6366130f
2012-05-11 12:14:29 -07:00
Rob Moen 469a55bde4 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-11 10:31:12 -07:00
Rob Moen ced54d06a9 Write better test for DocumentFragment getAnnotationsFromOffset
Fix errors in example test data
Remove whitespace

Change-Id: Ibb2b5c0851d6abac9974035753b95354b3c8dd5e
2012-05-11 10:29:09 -07:00
Catrope ca17ea0943 Port structural replace code from the old VE code
This makes TransactionProcessor work for regular replacements, as well
as insertions and deletions of self-contained pieces of data. This does
NOT yet work for inserting and deleting unbalanced data
(splitting/merging nodes).

I've tested this from the console for insertions and deletions and
simple replacements, but I haven't tested wrappings. We should write a
bunch of unit tests for this some time :)

Change-Id: Ic2fd75d1cf2e127bc9ae58debce67576be2c912f
2012-05-10 20:20:42 -07:00
Catrope 3cc22b00cb Use index and indexFromNode (from selectNodes()) in DocumentSynchronizer
This makes insertions work (using indexFromNode), and eliminates the
indexOf() call (using index)

Change-Id: Ibfa77353af99534edc324c0e314c8b95c5136d8b
2012-05-10 20:20:42 -07:00
Catrope 6652f7573b Add indexInNode to selectNodes() output
This is for the case where we have a zero-length range in between two
siblings, and we need to know what index that corresponds to in order to
be able to insert nodes there (rebuildNodes() will use it for this
purpose)

Change-Id: I357d1cd665667a76f955a10b8d9d2810976cdbd7
2012-05-10 20:20:42 -07:00
Catrope 379bc8da3c selectNodes() fixes:
* Initialize startOffset to 0 not 1, don't know what I was thinking
* Use currentFrame for nodeRange instead of parentFrame, don't know what
  I was thinking there either
* If the returned node has no parent (is the document node), don't
  attempt to access parentFrame and don't set index

Change-Id: Iad969a7c29436cdf4151ead7e9d3d8e2a30befb3
2012-05-10 20:20:42 -07:00
Catrope 7eeb6c7cac Throw an exception when DocumentFragment gets unbalanced input
Change-Id: Ie891bd7ea4d9e9b1c84e7a0390f1af39c0e55fd4
2012-05-10 20:20:42 -07:00
Trevor Parscal 1475100a22 Ported isContentOffset, isStructuralOffset, isElementData, containsElementData and getRelativeContentOffset
Tests for all but getRelativeContentOffset are done too

Change-Id: Iee953647ec89e13259ae2a402c50c809f93bc655
2012-05-10 17:20:57 -07:00
Catrope 8834145f9e Fix nodeSelectionEqual() so it doesn't explode when a and b have unequal lengths
Change-Id: Idb84bc1238576c711a201cdbf05f63a7b603a819
2012-05-10 16:42:58 -07:00
Catrope 9b6402801a Fix the selectNodes() bug that Inez reported
Selecting a zero-length range at the start or end of a text node
(e.g. (1,1)) would return the text node's parent instead of the text
node

Change-Id: I7fe089bf66b93185dd3415eff53aa7e04e3ffdb2
2012-05-10 16:42:58 -07:00
Catrope f79e56b4f1 Document the stack properties used in selectNodes()
Change-Id: Ibaf178830a0b7b99a4ab1c0ec09283bd3dd552e0
2012-05-10 16:42:58 -07:00
Catrope ec449d168a Fix startOffset computation in selectNodes()
* Needs to be initialized to 1, not 0
* Needs to be stored *after* left is incremented to account for an
  opening

Change-Id: I7978ae241578a8a17120e494684e6e93626a8529
2012-05-10 16:42:58 -07:00
Catrope 38a9b8b301 Fix typo in selectNodes()
Change-Id: I320728bafa289290c4c2a91fee736a8afb17be80
2012-05-10 16:42:58 -07:00
Catrope 13b79d309c Add 'index' and 'nodeRange' to selectNodes() output
Change-Id: I38712545b713cc24663ebec3fe3e5c8741b4fad7
2012-05-10 15:03:23 -07:00
Trevor Parscal d4363c04f4 Don't set classes on non-wrapped elements
* Text nodes do not have a wrapper to set classes on
* Use CSS class names that are equivalent to JS class names, swapping . with -

Change-Id: I49c877dd5c9b5dd2a9afad3137f12b14883043a1
2012-05-10 14:54:33 -07:00
Inez Korczynski 3848e77c33 Basic support for Alien node in HTMLDom -> LinMod converter
Change-Id: Ie9b08027c58694022a7b01609d25d720bfb35873
2012-05-09 23:04:57 -07:00
Inez Korczynski 41a7451ea2 Store reference to view node (ve.ce.Node) in jQuery data of it's wrapper
Change-Id: I84920b20346b4ef5e1203d834bf4c3fb9657ae69
2012-05-09 22:43:46 -07:00
Inez Korczynski 1a4e488b06 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-09 22:40:51 -07:00
Inez Korczynski ee39e837b8 Get Alien node (leaftnode) working - it reads its content from attribute
'html'

Change-Id: Idd84da9af61369277df18fee577032de765b1205
2012-05-09 22:36:25 -07:00
Trevor Parscal 1798a478e7 Massive refactor of node trees, generalizing lots of previously dm only stuff
Change-Id: I9dbb7094f86338ea2e725ad29f66e9e4ca2b52ed
2012-05-09 21:11:09 -07:00
Christian Williams 0848eaca04 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-09 18:36:05 -07:00
Christian Williams 3d289365bc Images and tables working with HTMLConverter
Change-Id: I2e45eeddf031d00b006498f9b2fb4840a2f6df44
2012-05-09 18:35:05 -07:00