Commit graph

70 commits

Author SHA1 Message Date
Catrope 94697a3241 Emit an 'update' event in addition to an 'annotation' event
Change-Id: Idab673bce4fa4b10816d753020adae40598c8b7a
2012-05-08 18:31:51 -07:00
Catrope 09631f1466 Make TransactionProcessor actually use DocumentSynchronizer
Change-Id: If0ac69026fa34430d811de5f7ca0748d9b1e01cc
2012-05-08 18:31:51 -07:00
Catrope 22c88f77c3 Add a 'siblings' mode to selectNodes(), and add tests for it
Change-Id: Ib3fd3ee5aba7aab7c26193a2a9c48612f624862a
2012-05-08 18:31:50 -07:00
Trevor Parscal d061b62a72 Added some documentation to ve.dm.DocumentSynchronizer constructor
Change-Id: Ib24f0101e60b34af292d46d3ea866859a89a18f5
2012-05-07 19:43:34 -07:00
Trevor Parscal d43ee569ac Cleanup of HTMLConverter
Change-Id: I145bfbbb8b759ea33eef291b53daf935e97ac341
2012-05-07 19:43:03 -07:00
Trevor Parscal 123c64cbd5 Added more tests for selectNodes
Change-Id: Ibd9672fb9b6ce682905d20f9346fada6fb47b380
2012-05-07 19:03:59 -07:00
Catrope 4d9299b808 Fix bugs in selectNodes(), tests pass now
Also fix one instance of bad expected data in a selectNodes test

Change-Id: Ie226b237cf537143bce2f6b1e531b9067b140cb4
2012-05-07 17:03:42 -07:00
Catrope 32c65cdaa8 Change 'leaf' to 'leaves' and document it
Change-Id: I09d5995d3d9bf82670802f0efe849f40be2a18a3
2012-05-07 17:03:42 -07:00
Trevor Parscal f4fcf9663e Added documentation and tests for ve.dm.Document.selectNodes
Also:
* Broke node lookup method out into ve.dm.example.lookupNode
* Added ve.dm.example.nodeSelectionEqual

Change-Id: I437cdd3f3154d10782f03f78df6d5c457ecfc845
2012-05-07 15:15:21 -07:00
Catrope ad5ee8f822 First implementation of selectNodes()
Currently only implements mode=='leaves', i.e. traverse all leaf nodes.
Seems to work from casual testing, but is missing unit tests. See also
other TODO comments in this commit

Change-Id: I41292c21c627a18af7985e8ef9e23c7b14252b21
2012-05-07 13:57:58 -07:00
Catrope 93d6adb5f2 Add an isWrapped property and make getOuterLength use it
This gets rid of the length == outerLength-2 hack in getDataFromNode()
and will make it easier to implement similar logic in selectNodes()

Change-Id: I1294350b67ca3eefde2b7fe9fea0bc6d8b90f772
2012-05-07 12:00:07 -07:00
Christian Williams 1ef380984f Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-04 20:44:10 -07:00
Christian Williams 6e7588a33b Support for new annotation format
Change-Id: Ib873981792d2cb4d78a3e4805287c48b3de78558
2012-05-04 20:22:05 -07:00
Trevor Parscal e34ec4b479 Added canHaveChildren and canHaveGrandchildren to all nodes
Change-Id: Ibe53292f7269736750e03da49e5bb5913c0124ab
2012-05-04 17:50:54 -07:00
Trevor Parscal 1d74945dfc Fixes for Roan's crazy half-baked commit
Change-Id: Ic104debc3a941e4cf8e4dca19633dcad04a0fe0a
2012-05-04 16:13:54 -07:00
Christian Williams 28eb0c82e5 Adding HTML DOM -> Linear Model converter
Change-Id: Iae109d75e64321a7fe4ee8492d79ef5481716246
2012-05-04 15:47:41 -07:00
Catrope d11af2b687 Queue and deduplicate events in DocumentSynchronizer
Change-Id: I90577cd078c3d0b6706f5f827b66b46a450e7086
2012-05-04 15:42:35 -07:00
Rob Moen d42e738636 - Optimize surface model and write unit tests
Change-Id: I8de24c840c5aa2d4232e6e2cc5f72cbd30be96b4
2012-05-04 15:29:47 -07:00
Inez Korczynski 0562d83f2f Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-04 15:20:47 -07:00
Inez Korczynski bab1a9672c Fix method getDocument in dm.Surface and start using it
Change-Id: I613b1e938cd0d8f3a6ac8a48121901287c8fc5af
2012-05-04 15:20:14 -07:00
Catrope 2baeb5532d Initial stab at DocumentSynchronizer
Change-Id: I7176fd7235a82a6314bf431d00870d9ddb40f370
2012-05-04 15:18:07 -07:00
Trevor Parscal dc27d8acb4 Refactored dom wrapper functionality in ce nodes
* Moved implementation of getting and updating a DOM wrapper to ve.ce.BranchNode
* Updated ve.ce.BranchNode tests
* Renamed ve.NodeFactory.createNode to ve.NodeFactory.create
* Added  ve.NodeFactory.lookup which gets the constructor of a type
* Added attribute pass-through to ve.dm.BranchNodeStub

Change-Id: I8f5b7d3d3ae616cc5f39828b24b655163d782ae5
2012-05-04 13:31:14 -07:00
Trevor Parscal d2480baed0 Removed bubbling update events in dm and ce node trees and splice events from ce branches
The bubbling update events are not needed with ce or dm, but were once upon a time useful for es, this just eliminates some unused cruft that was costing extra function call overhead.

Change-Id: Ia16d0f4cd74c84cded5caecada33ee83d0882f30
2012-05-04 12:28:32 -07:00
Trevor Parscal 9887dbd96f Split Broke DefinitionListNode out of ListNode and DefinitionListItemNode out of ListItemNode
* Makes it simpler in the linear model because we don't have to use style: "item" for regular list items and style: "definition" for definition lists
* Enforces correct nesting through existing node rules systems
* Updates tests accordingly

Change-Id: I64d80af938e325f1961226505bdc386bb35ccdda
2012-05-04 11:56:32 -07:00
Catrope 11a3b6886b Implement basic replace processor
* Implement basic TransactionProcessor.replace(), only does content
  replacements
* Add ve.dm.Document.containsElementData()
* Fix bug in attribute()
* Write basic tests for attribute() and replace()

Change-Id: Ie9c22aec3f2631be5b0bd66790408ad283565491
2012-05-04 11:09:10 -07:00
Rob Moen da65ad48c8 - extend surface model and surface view with event emitter
- added surface view base methods
- enabled toolbar in ve.Surface

Change-Id: Ib6a62ef2509712f812f262283c45bb30c8f97ef1
2012-05-03 16:02:21 -07:00
Trevor Parscal 7b7ff5a503 Added ve.dm.Surface, ve.ce.Surface, ve.ce.Document
Change-Id: I382730e1a9f1abcb4b42499267c8dcaf76fc64e1
2012-05-03 13:21:13 -07:00
Trevor Parscal b1b9fb5133 Added tests for getDataFromNode
Change-Id: Ic762832dcdda3bdaf92dbd989659235fdff73596
2012-05-03 13:11:36 -07:00
Trevor Parscal d412c8c159 Removed unused method (using factory instead)
Change-Id: I0ed9260d261b7e4c19e5d57f70331aef1a341cdf
2012-05-02 15:58:40 -07:00
Inez Korczynski dd6094842e Created a test file for ve.ce.TextNode and fixed some minor issues.
Change-Id: Ifbf6b7ba2a27eedf6d5d4f6cb06b98c38eb52c5b
2012-05-02 14:18:02 -07:00
Trevor Parscal b4313ae262 Moved getOffsetFromNode to ve.dm.BranchNode
* Also updated a call to getOffsetFromNode in ve.dm.Document

Change-Id: Ief8f9e532e39cd1051d7f3b6df6ed341747098e5
2012-05-02 14:06:35 -07:00
Trevor Parscal fd28fff50f Added test for replaceDomWrapper and onSplice in ve.ce.BranchNode
* Also fixed calls to addListenerMethod
* Also routed adding children in the constructor of ve.dm.BranchNode to the splice method
* Renamed types of ve.dm stub nodes to avoid collisions (since we have to register ce nodes by the same names for them to be generated by onSplice)

Change-Id: Ia2e75cf0a62186cc0e214683feb25c619590318a
2012-05-02 13:58:50 -07:00
Trevor Parscal fee375cf4e Removed global variable introduction
Change-Id: I331b19cafeb20610f7b42bacaff20757a342dffc
2012-05-02 12:37:30 -07:00
Trevor Parscal 1d94af144a Added update handlers to heading, list, list item and image ce nodes
* Also renamed convertDomElement to replaceDomWrapper in ve.ce.BranchNode
* Also added extra documentation for node rules

Change-Id: Ia8ac6be34e2b021be96974ac1ba9119bd8077d60
2012-05-02 11:30:37 -07:00
Trevor Parscal 158c9f7692 Consolidated before/after attach/detach events
Change-Id: I4220715ac4505152fb30ac2d5664a0ffb2b846f5
2012-04-30 19:50:45 -07:00
Trevor Parscal dcd0fa38c6 Fix variable name typo
Change-Id: Icfd42a5ee00e14f2485a93a5817f0f7f3e701234
2012-04-30 19:48:54 -07:00
Trevor Parscal cac3c6efd0 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-04-30 19:39:02 -07:00
Trevor Parscal 370070dfa2 Lots of ce porting, got text nodes fully supported
* Fixed constructor of ve.ce.BranchNode which was calling the wrong method to perform an onSplice and with the wrong arguments
* Removed/renamed events emitted from ve.ce.BranchNode.onSplice
* Reintroduced .$ to all ce nodes
* Ported over functionality for DOM node type variance used in headings, lists and list items
* Moved the old ve.ce.Content guts to ve.ce.TextNode
* Added getOffsetFromNode and getDataFromNode to ve.dm.DocumentFragment
* Added setDocument and getDocument to dm nodes

Change-Id: I185423ba2f1a858dde562cb2f5bc3852aec930db
2012-04-30 19:38:42 -07:00
Catrope d9cd1392fc Add TransactionProcessor tests, and fix TP to make them pass
* Add .process() and its helpers from ve1
* Fix applyAnnotations()
** Use data[i] rather than data[j]
** Don't add empty annotation objects for no reason
** Remove empty annotation objects
*** I thought this wasn't needed, but it is needed for clean rollbacks
* Remove unused second parameter in applyAnnotations() call

Change-Id: Ia338f62d2eaf2a76f8ef653eead05bc44757a122
2012-04-30 19:06:20 -07:00
Trevor Parscal 35af704173 Added initial ce nodes
Change-Id: Ibdcb4502a8fdc5b1a6c22ae0e9c42c86b3a7d4dc
2012-04-30 17:36:22 -07:00
Trevor Parscal c2d4a2d928 Added basic ve.ce nodes
* Also removed beforeSplice and afterSplice in favor of just plain splice which is the same as afterSplice used to be - beforeSplice was never used and it was making things more complex looking than needed

Change-Id: Icbbc57eac73a2a206ba35409ab57b3d1a49ab1a5
2012-04-30 16:58:41 -07:00
Trevor Parscal a667425874 Moved canHaveChildren and canHaveGrandchildren back to ve.NodeFactory
This is generally useful information, not only for dm

Change-Id: I9511467285e9594b4a7aa659bf65bb0417da25a1
2012-04-30 16:25:44 -07:00
Trevor Parscal 9b2098cb56 Added documentation to static rules on ve.dm nodes
They are used by ve.dm.factory so this might make it easier for people to understand what's going on.

Change-Id: I490627e3bfc55ca9c96fdc4f5d047737b6a3db8c
2012-04-30 15:47:54 -07:00
Trevor Parscal 2cee2adb6d Split node factory into dm specific implementation
* Added support for asking if a given node type can have children or grandchildren and what types of nodes can be it's parent or child
* Removed canHaveChildren methods from leaf and branch nodes and converted use of them to depend on factory to read static rules from constructor lookup by type

Change-Id: I9769f95647066576416bacb791c4b68dd0285b35
2012-04-30 15:42:36 -07:00
Trevor Parscal 0d4fb6fdb5 Got rebuildNodes tests working
* Moved node tree assertion to ve.dm.example
* Added rebuildNodes test
* Fixed some typos in rebuildNodes

Change-Id: I4853ded4b062aaa3758435093368bc23667ca3bf
2012-04-30 13:42:32 -07:00
Trevor Parscal 8ce7fd0c85 Fixed length calculations and added tests for node tree
Image nodes are leafs, so providing an empty array to their children/length "contents" constructor argument ends up setting the numeric length to [], which casts to an empty string in arithmetic, causing all further calculations to be concatenations instead of additions.

Change-Id: I40e1ea2295f6095318bc4c24185cadfdfb684557
2012-04-30 13:23:46 -07:00
Trevor Parscal 139210df0d Added getOuterLength override to ve.dm.BranchNode
Also fixed use of getElementLength which should be getOuterLength

Change-Id: I794a4624fca60b3f2e2dde7f8c51db2da526436b
2012-04-30 12:38:15 -07:00
Trevor Parscal 7de381ea14 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-04-30 11:38:37 -07:00
Trevor Parscal 489794c89c Renamed rootNode to documentNode and added tests
Within ve.dm.DocumentFragment it makes more sense to call the root node (which is always a document node) a document node, especially since there may be a different node used as a root.

This commit also adds test for getDocumentNode and getNodeFromOffset which uses the offset map.

Change-Id: Ic4609233cedc41f7e5a5f8fdb0e6178652c95554
2012-04-30 11:37:48 -07:00
Catrope 80decda935 Mostly-finished TransactionProcessor
Change-Id: I7d2cd684fafa16c85d0d9c9ad2b6d42d7e6f1448
2012-04-30 11:26:22 -07:00