Commit graph

163 commits

Author SHA1 Message Date
Christian Williams 51aa317df3 Undo and Redo support
Change-Id: Icdbebccefe3cc162b9ff6c0d978d5e4fc1f2c561
2012-06-06 20:28:06 -07:00
Rob Moen 232f2c58f7 Fix linkInspector tool
Change-Id: I89fa17b1a72c3f45bce5a11b49aa5445c5990f68
2012-06-06 17:50:01 -07:00
Trevor Parscal b62beed2e2 Added implementation for ve.dm.Converter.getDataFromDom
Change-Id: I8561d4a00ba630b86fb7bcd3e347fe2c6c2f6aa3
2012-06-06 17:47:27 -07:00
Rob Moen 8db70ed263 Annotation buttons now working
Created new document method to determine if a specific annotation
object is inside an annotation array.

Change-Id: Id645929cbf31030b8b0fcacb8dfb36e61aaad129
2012-06-06 17:06:37 -07:00
Catrope 5e47bdc57f Maintain a transaction-wide offset adjustment
This fixes a bug where the second replace operation in a transaction
would cause the rebuild of the wrong range, or the adjustment of the
wrong text node.

Change-Id: I9b1c68d84999d538fe10bb193f4dfdd694121d2a
2012-06-06 15:34:55 -07:00
Catrope 02b19f337f Add zero-length text nodes to empty content nodes
This is needed to make the results of certain transactions' tree sync
round-trip cleanly through the ve.dm.Document constructor

Change-Id: I2ab0758ec6bd7afba5b6645c7330f9fa2d45205d
2012-06-06 15:33:42 -07:00
Catrope ae3d31d447 Shallow-copy annotation objects in HTMLConverter
This fixes an annotation contamination issue that was causing Rob's
tests to throw exceptions

Change-Id: Ic5171d600b0b2ff97cc569e1e6f9488fab177c7c
2012-06-06 12:21:01 -07:00
Catrope e524152319 Fix typo in variable name
Change-Id: I6772555da86a186ec2421d01f82de14463061362
2012-06-06 12:20:05 -07:00
Catrope 1429a3da59 Rewrite newFromRemoval() using 'covered' mode
Change-Id: If0736aff6d194ec09c2a109f046dd6362ddc64fb
2012-06-06 11:47:35 -07:00
Catrope d39fb9dd1c Make pushReplace([], []) do nothing
Change-Id: Ifa8df99f376ce22add9d06e76831e8b661e6ddbf
2012-06-06 11:47:35 -07:00
Rob Moen 2439c0149a Created secondary method for getMatchingAnnotations
new static method looks for annotation in annotation object.
ve2 Cleanup on annotate method and surface model.
Partially revive UI tools by exchaning old method usage
for ve2 methods.

Change-Id: Id0ac58330292d76801bbcf1d71a919b493f8ab9e
2012-06-06 11:27:23 -07:00
Trevor Parscal 5d20f45120 Added getHtmlElementFromDataElement and getDataElementFromHtmlElement
Change-Id: Ie5f4fd86612b5a6c34b5843d1e9a521edc626a63
2012-06-06 10:17:51 -07:00
Catrope d378182bff Reapply typo fixes from c0e1991 , were undone in b0f6f64
Change-Id: If84e13b91781ed96d3bd9e94171e16020c65ea42
2012-06-05 06:54:35 -07:00
Trevor Parscal b0f6f64d90 Made pushRetain do nothing if you give it 0 and throw an exception if you give it a negative length
Change-Id: Ib9955660b05a04503325ddb20f9e9a525b4d6832
2012-06-04 16:27:33 -07:00
Catrope c0e19915ef Typo fixes and missing 'var' in newFromRemoval()
Change-Id: Ibb984d862670b5386ff76fc55ef3322f695b6ae1
2012-06-04 16:07:16 -07:00
Catrope db793009be fixupInsertion() variable documentation and cleanup
Functional changes (fixes):
* Make writeElement() also update parentNode and parentType for openings
* Also add to fixupStack when opening a wrapper for a text node

Non-functional changes (cleanup&docs):
* Document all variables at the beginning of the function
* Group variables according to where/how they're used
* Move expectedType into writeElement()
* Kill node, duplicates parentNode unnecessarily
* Kill paragraphOpened, was misnamed and unnecessary
* Rename closedElements to reopenElements

Change-Id: Ie5b4e4f30b267943048fdc170accb29139039192
2012-06-04 16:07:16 -07:00
Catrope f7445b37b8 Retain attributes when reopening closed nodes
* Push entire elements onto openingStack rather than type strings
* When closing an element, build a clone of the opening and push it onto
  closedElements, then insert that clone when reopening the element

Change-Id: I8b0fb44394aed6c471dc6dacaab03e44c2333733
2012-06-04 16:07:16 -07:00
Catrope b167453f0d Add ve.dm.Node.getAttributes() to get a reference to the attributes object
Change-Id: Ic2463d4f7053a5f6defd212f04deb5ea71542843
2012-06-04 16:01:14 -07:00
Catrope 109624e8b3 fixupInsertion fixes, wrapping content works now
Change-Id: I1eee6afcffbf09955578b7f0534aa5b7234802df
2012-06-04 16:01:13 -07:00
Rob Moen fd5eb80dd7 Document annotate method in surface model.
Comment cleanup

Change-Id: Ifd3eeab9046f376529a827dfafdc28506845ac15
2012-06-04 15:06:37 -07:00
Rob Moen c338304d33 Rewrite annotate as more low level method in Surface model.
TODO: follow up with annotate tests

Change-Id: If0e68bd3a09840b1e5f3e8d85fd22a8c10134b58
2012-06-04 14:29:27 -07:00
Trevor Parscal 73c5dd8f1d Added ve.dm.Node.getOffset
Change-Id: I4fb99040af44c063ad3b6489f2fd895d843fcf0c
2012-06-01 17:44:01 -07:00
Trevor Parscal 386faa5569 Fixed ve.dm.Transaction.newFromRemoval so it supports trimming off extra openings and closings
Change-Id: Icbcf4129a51aa92d47aa89738facd0d288337cbd
2012-06-01 14:34:59 -07:00
Trevor Parscal e7f03c6d70 More cleanup, removed ObjectAnnotation (they are inline elements now)
Change-Id: I2c53c145eed1a801392c954001de7641f928216c
2012-05-31 17:18:28 -07:00
Trevor Parscal 294abb0a38 Simplified converters data structures
Change-Id: I1734bc7e06462595ea2f27715948fbb3d9e552ad
2012-05-31 17:03:03 -07:00
Trevor Parscal 042ffb4e3b Added foundation for new converter
* Added converters to all relevant node implementations
* Added new annotation objects with their own factory

Change-Id: I9870d6d5eac45083929d74d2e58917d0939ca917
2012-05-31 16:50:16 -07:00
Trevor Parscal f6864b0c04 Changed use of "factory" to "nodeFactory" to make way for other kinds of factories
Change-Id: I96db0f28bb220f1c3b23990824e9523278cb8f9b
2012-05-31 15:20:58 -07:00
Trevor Parscal 32bddaf088 Added ve.dm.Transaction.newFromRemoval
Also:
* Refactored tests
* Added tests for ve.dm.Transaction.newFromInsertion
* Added tests for ve.dm.Transaction.newFromRemoval
* Fixed problems with ve.dm.Transaction.newFromInsertion
* Added ve.dm.Node.canBeMergedWith which is partially a port of ve.Node.getCommonAncestorPaths merged with canMerge from within ve.dm.DocumentNode.prepareRemoval from the old ve codebase

Change-Id: Ibbc3887d08286d8ab33fd6296487802d65b319fa
2012-05-31 14:39:34 -07:00
Catrope 2f18605a1a Fix buggy replace behavior when inserting content that contains nodes
Copy-pasting things like "text<IMAGE>moretext" failed spectacularly,
this commit fixes that.

* Check for content rather than structure in the inserted/removed data
* In the content case
** Run selectNodes() over the removal range, rather than just the cursor
*** i.e. no longer assume that content replacements only affect one node
** If there is structure involved, rebuild all affected nodes

Change-Id: I80e40b5b7c514a3fb105d57e4a17770d0fefaaea
2012-05-31 07:27:36 -07:00
Catrope f6ca37926d Add ve.dm.Document.isContentData()
Some of the replacement code was assuming that "does not contain
elements" and "is content" were the same. They're not any more, because
we have content nodes (like image) now, so I need a separate function
to distinguish between these cases.

Change-Id: I206ccdf082b7baddf99d382eb3cdd77ea34fb479
2012-05-31 06:19:34 -07:00
Catrope e92db86046 Fix bug in ve.dm.Document constructor for input ending with text
If the last element of the input data array was text, the resulting text
node would have length=0 rather than the expected length value.

Change-Id: I3d089a80b8a447a12ba411b2e11c1b84f14f2959
2012-05-31 06:17:23 -07:00
Trevor Parscal 8328fc8786 Removed aliases for node type constants, on the client we have them already in Node
Change-Id: Id68dd43930a51a857e73af0215fd215c89e9bbbe
2012-05-30 14:38:18 -07:00
Trevor Parscal 14862a1212 Fixed bug in isStructuralOffset which didn't consider neighboring a non-content leaf to be a structural offset
This was caused by the fact that a non-structural leaf can not have children, which makes it appear incompatible as a sibling to an arbitrary structural element (like a paragraph) but since it can not contain content we can check that instead.

Change-Id: Ie3c58b4b43f2aa6921f8f82aa82511e231207854
2012-05-25 13:19:56 -07:00
Inez Korczynski afe18a685a Fix methods getNearestStructuralOffset and getNearestContentOffset for case of passing offsets that are already structural or content
Change-Id: I23cd2daab9cef181b01131b3b9c6ead5ec47f9f4
2012-05-24 20:53:50 -07:00
Trevor Parscal 3ce705313e Replaced static array with real logic inside of ve.ce.BranchNode.canNodeHaveSlug
Also added more static config getters and fixed some typos in prototype definitions

Change-Id: Ib9093a625b944e6a4ca4da50c51fb475b5895b8d
2012-05-24 13:12:45 -07:00
Trevor Parscal c9dddf60da Made getRelativeOffset return -1 if no valid offset is found in document
Change-Id: If4cef5fe800b241c3efe1d27cdf01cd1ceef2248
2012-05-24 11:43:47 -07:00
Trevor Parscal 1ddaec8acb Added getRelativeOffset and several wrappers around it
Change-Id: Ifd10922366650165bc4c21ea8cfdd2f9b7163432
2012-05-23 17:43:24 -07:00
Trevor Parscal 541d786ced Added optional "unrestricted" argument to isStructuralOffset
Using this argument will only return true if the offset is a place you can add any element to (hence the unrestricted part of it). This is good for testing if a paragraph could potentially be inserted there.

Change-Id: I6cc91da437c52493de03eb687b28966198270fea
2012-05-23 14:56:33 -07:00
Catrope cce32103ff Implement newFromInsertion()
Mostly just wraps around fixupInsertion()

Change-Id: I5c9128439b9ed29b112590c0004a749f9b529346
2012-05-23 12:45:28 -07:00
Catrope 3be3f55c91 Rough first stab at ve.dm.fixupInsertion()
This code still needs a lot of work, but it seems to work for most
cases. Things that still need to be done:
* Documentation and comments
* Handling of content and text nodes
** Use Trevor's isContent/canContainContent code which I don't have yet
* Preserve attributes when reopening closed elements
* Tests :)

Change-Id: I3bc16c964ef158693490a61ce12beb21e6fe2a9d
2012-05-23 12:45:28 -07:00
Catrope 9a1ec62f0d Remove pushInsert() and pushRemove()
The 'insert' and 'remove' operations weren't implemented in the
transaction processor and were a holdover from the old DM
implementation.

Also migrated the tests, especially those that asserted that consecutive
insert/remove operations were combined (this is no longer the case now
that they are replace operations)

Change-Id: I2379fe92b331c5316f70f4b695397da41581cce9
2012-05-23 12:45:27 -07:00
Trevor Parscal 9af03a29b1 Updated demo and fixed HTML converter
Removed hard-coding of alien nodes, now aliens are automatically used for anything unknown, and block or inline aliens are selected based on whether the parent element can contain content or not.

Change-Id: I5d2a521ead4f4c96cb44d084a5c160cc20d8048e
2012-05-23 10:15:44 -07:00
Trevor Parscal 86591e5325 Restructured static node rules
Change-Id: I7023e1f334694d59767491f1010e7c4c59c0ce54
2012-05-21 17:39:12 -07:00
Trevor Parscal c38a552442 Fixed case on mapping to $.toJSON
* Also made uses of JSON.stringify use ve.getHash

Change-Id: I05dc0374e05b72c798ae0fd44239e5f8bb45ca52
2012-05-21 12:21:07 -07:00
Rob Moen 272f502693 Modify getAnnotationsFromOffset to account for annotated leaf nodes.
Refactor remaining annotation methods
Refactor tests to use correct annotation types

Change-Id: Ia3ce42b3d11296b4d63277e0e2a1997d23236613
2012-05-21 12:02:04 -07:00
Trevor Parscal 4dd9a143ae Added newFromAttributeChange and newFromAnnotation
Change-Id: I1e85ccee3fa1591867fea52359508bfa99bad7df
2012-05-17 15:17:17 -07:00
Trevor Parscal 445006d4a8 Made tests a bit stricter before iterating over annotations
Change-Id: I7c7f11395cfb4ad392bad9380119b647c0c1b629
2012-05-17 14:58:01 -07:00
Trevor Parscal 43d62ee8a7 Refactored getMatchingAnnotations and it's tests, and added offsetContainsMatchingAnnotations
Change-Id: I9098ef8d9c7f3a4f5db112cfdcb9edb7ffd17b80
2012-05-17 14:37:29 -07:00
Rob Moen a937ad22f7 Fix getAnnotatedRange to return propper contained range.
Fixed tests

Change-Id: I305eb81644fb3c804455b4fc13bdabcce97ea471
2012-05-17 13:17:18 -07:00
Trevor Parscal 24c35b853f Whitespace fixes
Change-Id: I691c4e16cf22de8dce0858cdcad522d1f6cfef72
2012-05-17 11:27:25 -07:00