Commit graph

1396 commits

Author SHA1 Message Date
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
Inez Korczynski 9edb38353c Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-31 15:52:01 -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
Subramanya Sastry 1c80e2d7f0 First pass implementing a general tag minimization routine
* This routine attempts to rewrite the DOM to maximize tag overlap
  and thus minimize tag uses.

* This takes as input a set of tags which participate in the
  minimization.

* Tested on the following example
  <b><i><u><s>BIUS</s></u></i></b><b><i><s>BIS</s></i></b><b><u><s>BUS</s></u></b><u><i>UI</i></u>
  with multiple combinations of the 2^4 possible variations of i,b,u,s
  tags: [], ['i','b','u','s'], ['i'], ['b','s'], ['i','b','u']

  - But, I am not fully sure if this implements the right behavior when
    only a subset of inline tags are provided.  Needs discussion and tweaking
	 as necessary.

* Also tested on few others:
  <b>B</b><b><i>BI</i></b><b><i><u>BIU</u></i></b><b><i><u><s>BIUS</s></u></i></b>
  <s><i><b>SIB</s></i></b><s><i><u>SIU</u></i></s><i><u>IU</u></i><i>I</i>

* The previous pairwise tag rewriting version fails on several of these
  examples, so this new version is a definite improvement.

* No change in parserTests run (203 passing before and after).

* Possible improvements that could/should be undertaken:
  - get rid of useless/idempotent add/remove of nodes that don't change
    the DOM.
  - ensure that node attributes post-restructuring are correct.

Change-Id: Ib4a8b39583fa96a2be880a77021ca81cefa06484
2012-05-31 12:10:28 -05: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
Gabriel Wicke 4ea6b8e2be Revert part of last template syntax tweak
Change-Id: I084e1210577f80c3b96020d57cfa5c68eb5d139b
2012-05-31 12:02:42 +02:00
Inez Korczynski 065494941e Add special handling in getOffset method for a case when cursor is inside slug - required in IE
Change-Id: I27ae78632e7b28921f5fe4214d2fee658c37b564
2012-05-30 18:11:23 -07:00
Rob Moen b59d49a80d Restrict edit access to VisualEditor namespace to sysops
To allow non sysops to save via VE, refactored ve save api
to use doEdit which bypasses namespace protection.
Add edit link in view nav for non sysop so that they may edit
Add View source link in dropdown for non sysops
Add Edit source link in dropdown for sysops
Cleaned up some of the integration core code
UI tweaks

Change-Id: Ib4249bc5fb7ffa6410e4f2d278aafbb871800981
2012-05-30 17:12:25 -07:00
Inez Korczynski 43a6abec2d Introduce two different types of slugs - inline and block - this is in order to fix bug in IE with placing cursor inside slug by clicking next to it
Change-Id: Idf31a742ee98067688becf46b357c25cd10ddbc6
2012-05-30 16:45:06 -07:00
Inez Korczynski f7fb4bee5c Refactoring and performance optmization to method getNodeAndOffset - previously named getDOMNodeAndOffset
Change-Id: I067331f539bc86779c98be38e6a56ca04137c70f
2012-05-30 15:19:39 -07:00
Trevor Parscal 46d26b9f22 Added getNodeFromOffset to ce
WARNING: This is not as fast as the implementation of getNodeFromOffset in dm

Change-Id: I5fbe9b6edc66169b9caaa6751fde1b7b752814d1
NOTE: ve.ce.getNodeFromOffset and ve.dm.getNodeFromOffset should be renamed to getBranchNodeFromOffset to clarify that they only return branch nodes.
2012-05-30 14:38:18 -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
Inez Korczynski 5f9ea545cf Refactoring and performance optimizations to getOffset method in Surface view.
Change-Id: I8b57c9dc069894c82a6bafc5f282aefda505d061
2012-05-30 14:06:44 -07:00
Christian Williams e216a6f8ab Fixed scroll jumping when pasting
Change-Id: I9607dee6d1b0ca1820a9da5f48966310214e5edf
2012-05-30 13:06:19 -07:00
Christian Williams 11b1bd8884 Using string constants for node types
Change-Id: I2d18d4f54c776e299bc10206386b655605dae839
2012-05-30 11:41:31 -07:00
Gabriel Wicke c5d7e01944 Another tokenizer robustness improvement
This patch fixes a tokenizer syntax error encountered on
[[:en:Template:JacksonvilleWikiProject-Member]] and [[:en:Template:Infobox
former country]] by allowing optional whitespace before start-of-line template
syntax.

Change-Id: Ic214a731de58bf766e51f23d5e24ea2ce6788f58
2012-05-30 18:38:23 +02:00
Gabriel Wicke a133768781 Don't eat '}}' in generic attributes and similar productions
This fixes some syntax errors, at least one in Template:Geobox.

Change-Id: I32338febe25d0833c1d9bc4de293cd15b4cbb7be
2012-05-30 17:37:10 +02:00
Gabriel Wicke 36084c5d93 Preserve original newlines in HTML and serialization
254 round-trip tests (up from 184) are now passing.

Also:
* tweaked runtests.sh slightly (use less -R instead of -r).
* made sure the EOFTk is preserved in phase 3 transforms

Change-Id: I1de22186bdb78e52019370e43f096877005b8f5a
2012-05-29 23:29:03 +02:00
Subramanya Sastry 8174c9dafc First attempt implementing rewriting rules on the DOM
- This is implemented as a post-processing pass.
- Might require additional checks to verify rewriteability.
- Implemented as a pair-wise tag DOM minimization strategy,
  i.e. it takes tag pairs (B, I) for ex, and attempts to
  normalize the tree just for those tag pairs.  Normalizing
  across multiple tags is implemented as pairwise rewriting
  across all pairs:  Ex:(b,i), (b,u),(i,u) for (b,i,u)
- Copied over attributes as part of rewriting, but some of the
  attributes lose their meaning on rewriting since tags are
  reordered (ex: sourcePosn, sourceTagPosn). How do we handle this?

Output examples and possible issues to fix:
   <i><b><u>biu</u></b></i><b><u>bu</u></b><u>u</u>
gets rewritten to:
   <u><b><i>biu</i>bu</b>u</u>

But, the equivalent wikitext form:
   '''''<u>biu</u>''''''''<u>bu</u>'''<u>u</u>
does not get rewritten because of parsing differences.
This wikitext gets parsed into:
   <i><b><u>biu</u>'''</b></i><u>bu<b>u</b></u>
The extra ''' token in the middle thwarts DOM rewriting.

However, a slightly different version:
   "'''''<u>biu</u>''<u>bu</u>'''<u>u</u>"
gets properly normalized to:
   <u>'''''biu''bu'''u</u>

An alternative, but fun strategy to play with is to use the following
two normalization primitives: S(wap) and M(erge).
- S rewrites T1(T2(x)) into T2(T1(x))
  (ex: <b><i>foo</i></b> ==> <i><b>foo</b></i>)
- M rewrites (T(x),T(y)) into (T(x,y)).
  (ex: <b>foo</b><b>bar</b> ==> <b>foobar</b>)

The current rewriting strategy could possibly be re-implemented as S-M
rewriting.  The problem to solve there would be to find an efficient
rewriting strategy that is guaranteed to lead to a normal form.  I may
not play with it now, but just documenting it for later (to play with
in my spare time).

This commit is just as a record of fun/experimental code where I get to
learn details of JS, wikitext, parsing, and DOM manipulation.  Next
version of this code will attempt to introduce minimal DOM restructuring
across multiple tags at once which can be more efficient.

gwicke: Removed now passing test from whitelist, and updated another whitelist
entry which is now improved.

Change-Id: Ie97bcb164eb62c34ba61aa76ba2f4c232aa713d8
2012-05-29 08:17:57 +02:00
Inez Korczynski 8a52b41076 Working (but dirty) implementation of getOffset, getDOMNodeAndOffset and handlers for keydown/mousedown - to be refactored very soon
Change-Id: I57923218fc8e5f3e1cdde339cdc1cb5e859cdedf
2012-05-25 23:52:52 -07:00
Inez Korczynski e5897dffa4 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-25 23:36:54 -07:00
Inez Korczynski e9230968fe Set contenteditable=false for Alien wrappers (both inline and block)
Change-Id: I5fd8fcfd0b6d98b525a75b3818cc77e3aca833c9
2012-05-25 23:36:18 -07:00
Christian Williams 8db39d0bb5 Support for plain text paste
Change-Id: I60846900d61b50138fe06dacee4693166e59651e
2012-05-25 16:26:46 -07:00
Rob Moen 0227de8c8e Remove edit token Ajax api request, get edit token from wgUser on save
Change-Id: Idb51da271d3eca61230d9948fc82190383fc7143
2012-05-25 16:20:48 -07:00
Christian Williams 64b9b33eec IE and its silly events
Change-Id: I81f46eca20cc5197305cbd355751c4c90e3b670b
2012-05-25 16:12:58 -07:00
Christian Williams 83e7eddfaf Support for paste
Change-Id: Id0a3d5d421aef56eb3296a56d00686ef7d07b433
2012-05-25 15:46:58 -07:00
Rob Moen 4ca26f1805 Switch tabs from read to edit when loading editor.
On cleanup, switch tabs back

Change-Id: Iefb47536e21cd7763c0d75c976109aeb2cbecf50
2012-05-25 15:41:22 -07:00
Rob Moen 237c0fd21f Created VE parsoid API save action.
Save action
1) posts html to parsoid service in exchange for wikitext
2) saves wikitext
3) returns parsed content.
On save, VE is hidden and page content is replaced.
Demoing save in toolbar, followup commit will redesign save options

Change-Id: Ibfbe52de08e3483e1a33f0740c03f96ec2b7f90a
2012-05-25 15:27:58 -07:00
Inez Korczynski 1e5e14c2c1 Add method hasSlugAtOffset to ve.ce.BranchNode
Change-Id: Id107bf890710096bb49111ae3d0d60e3315ecb89
2012-05-25 13:44:12 -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
Rob Moen 7b47af516a Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-25 12:52:46 -07:00
Rob Moen 61413c49eb Create base integration core module
Works on VisualEditor Namespace
Created VE api wrapper for parsoid service to roundtrip pages

Change-Id: I3f2967730c1a3ece31b7262a46bef31ea8b38613
2012-05-25 12:50:48 -07:00
Christian Williams 80ed03f2a2 Support for copying
Change-Id: Icf4665f9c48896e26cb536af033ca55410af49db
2012-05-25 12:02:56 -07:00
Gabriel Wicke b2adee0ae7 Basic rt support for indent pre variant
* Added a generic stx_v 'syntax variant' round-trip attribute
* For pre, use stx:'html' vs. no syntax annotation. This might not be 100%
  safe for arbitrary html input, so we might want to flip this to stx:'wiki'
  later.
* 181 round-trip tests passing

Change-Id: If6080917a3a7c069066db3db60efe59b1f6c28d8
2012-05-25 18:55:38 +02:00
Gabriel Wicke a31ccaabe4 Support definition lists with empty definition
Change-Id: I81c39a7e49f2ea7ce32cdd3600caeb5eb9f50d84
2012-05-25 15:40:32 +02:00
Gabriel Wicke 06b51b1f3f Properly round-trip dd/dt; 178 round-trip tests passing.
Need to track variable whitespace before elements to make some more tests
pass.

Change-Id: Ia86535d6f352e2ffe7965547cd506b0dbb6dfba2
2012-05-25 13:59:55 +02:00
Inez Korczynski 8f4f076340 Added handles for mouse events (down, up, move). Implemented method SurfaceView.getOffset and applied significant fixes to SurfaceView.getDOMNodeAndOffset.
Change-Id: I06cbfa9e0e7afc7aaf19d5cda8b91fe93aeb51f8
2012-05-24 20:55:45 -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
Inez Korczynski b56b6bad6d Just for purpose of testing add some hardcoded border and cellspacing to all tables
Change-Id: I97ff937d7e7d6a91ee3f411d7f77d5e3798ba567
2012-05-24 20:51:31 -07:00
Inez Korczynski 6017050b3f Add class ve-ce-imageNode to all image nodes, also comment out mousedown event handler
Change-Id: I7565d8822bbe0547e731df1859cdde4ac78de6f2
2012-05-24 20:50:36 -07:00
Inez Korczynski d9bd47d8a6 Make example demo document even more complicated
Change-Id: I9e0406fed859c5d848a5ea52a906d24e1671f458
2012-05-24 20:49:29 -07:00
Trevor Parscal ea9191b5b4 Copied CSS styles from ve to ve2
Change-Id: Iabd5ee3edde5747952c4b78ef6e9cd5949016050
2012-05-24 15:15:29 -07:00
Christian Williams 0a3b5df6de Image nodes are not draggable
Change-Id: Ie1080045939af7c9b7ac8c30527ad6057fe7e3f6
2012-05-24 15:10:16 -07:00
Christian Williams 88e25e77f2 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-24 14:47:41 -07:00
Christian Williams 1cc8aca16d Using invisible space character in slugs
Change-Id: I36752f4bea96bad61dedfbbb4fc00422d773227b
2012-05-24 14:47:24 -07:00
Trevor Parscal f6eef19021 Added copying of .data( 'node' ) from old wrappers to new wrappers on wrapper updates
Change-Id: Ibd9535bd9ebb712910d963eedc5941f8512aaf8d
2012-05-24 14:01:42 -07:00
Trevor Parscal c8ccdb9813 Moved ve.ve.BranchNode.canNodeHaveSlug to ve.ce.Node.prototype.canHaveSlug
Change-Id: I6d5d9ca5a1c9878acb15e9526feb94986822b491
2012-05-24 14:01:17 -07:00
Trevor Parscal ebfafac3e2 Added missing documentation to methods in ve.ce.BranchNode
Change-Id: If6833e3d639e0455025762987b7f41a43892ca4a
2012-05-24 13:22:57 -07:00
Christian Williams 933ff678a4 Focus can now be set in slugs using showCursor or showSelection.
Change-Id: I12ab361a30d277a4752579bf885fd37bc46b32ed
2012-05-24 13:18:30 -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 e150ba2e54 Moved "is slug gable" functionality to a static method of ve.ce.BranchNode
Also optimized some query stuff

Change-Id: I5675258c6e276a1ba410dcf1ee111392140a04eb
2012-05-24 11:58:33 -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
Gabriel Wicke 6f62878c78 Resolve subpage links, and remove hack for H: titles
Change-Id: I6c9c64179274e5c1641a3b127ac3b273a3c5254e
2012-05-24 17:57:41 +02:00
Gabriel Wicke dc61f313a2 Notes on missing parser functions, more error reporting tweaks
Change-Id: Ib6ce60cf1b55671a6ff57aa47edb5787ec3aefea
2012-05-24 17:31:26 +02:00
Gabriel Wicke cc10aab54f Add self alias
Change-Id: I47682f407da6b554179611c7d0f63f882ab5a871
2012-05-24 17:16:35 +02:00
Gabriel Wicke 13ae7cda11 A few (partly hackish) improvements
* Very basic support attribute key-value pairs emitted from templates
* Add TALKPAGENAME stub implementation
* Only show 'no revisions' message for top-level pages

Change-Id: I4b4ac0c7b2c0531ac4b39f0f49f4217302576ab9
2012-05-24 16:30:26 +02:00
Gabriel Wicke 3e0e11b1d0 Sanity check for tokens being an array
Change-Id: Ia4e4071e1469c31e3b320d854500938bb0245f82
2012-05-24 14:35:58 +02:00
Gabriel Wicke 93ce7453f0 Fake fullpagename et al a bit better
Change-Id: I85ddf9e88e5f8ac274f371bea0879600997001e4
2012-05-24 11:05:31 +02:00
Gabriel Wicke cdd1eca42d Fix non-existing revision error reporting
Change-Id: I6b8687bcde98b92d9d6217a738a177db279fd006
2012-05-24 10:50:47 +02:00
Gabriel Wicke f03fc39d15 Report missing revisions when retrieving templates
Change-Id: I9f33acafc4d3fbd062125d824e2614dafd4cd5a0
2012-05-24 10:45:01 +02:00
Gabriel Wicke caf2fa663d Keep going on tokenizer errors
Change-Id: I76fab4528f89b425845aef1685b3a54ddfeceef4
2012-05-24 10:30:32 +02:00
Gabriel Wicke e70448e53a Use text/x-mediawiki content type, and handle tokenizer errors without --debug
Change-Id: I154cd344306aa05ada7ff30f631d487f39fa9739
2012-05-24 10:19:25 +02:00
Trevor Parscal 1ddaec8acb Added getRelativeOffset and several wrappers around it
Change-Id: Ifd10922366650165bc4c21ea8cfdd2f9b7163432
2012-05-23 17:43:24 -07:00
Inez Korczynski e86c053045 Define better example/testing article in Sandbox
Change-Id: I5df37d7e3477bd49e69f44c4902810bca66734b7
2012-05-23 17:32:22 -07:00
Inez Korczynski 5b52e5320a Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-23 17:22:23 -07:00
Inez Korczynski fdbf1ac870 Define better example/testing article in Sandbox
Change-Id: Id9ce12f8977b94aca98823fdcb86a0840565579d
2012-05-23 17:22:10 -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
Inez Korczynski fe1482e0c4 Added method proxy to ve.ce.Surface
Change-Id: I2373df4c738b49685a897c8e13acebdd7ccb3e00
2012-05-23 13:34:52 -07:00
Inez Korczynski bea881daca Refactor mechanism of adding slugs in before and after particular nodes in branch
Change-Id: I8b3f4a9b27ff09d569f366c32f96e7e8191487c0
2012-05-23 13:24:49 -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
Christian Williams 32b9ccd0bf Moving alien node styling to CSS file
Change-Id: I21e4593b81669b48cec831236398866f89616f9a
2012-05-23 12:03:28 -07:00
Gabriel Wicke 4cc2d25e70 Fix a debug print reference error
Change-Id: Ic26d29aced4129c3dd718c4751dadb62a0be1a27
2012-05-23 20:52:45 +02: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
Gabriel Wicke d6af3b3375 Improve the serializer and its output display in the web service
Change-Id: Id3ca96846cad42517d7d4bada8f4bb250d54247b
2012-05-23 17:50:35 +02:00
Gabriel Wicke 95496c02db Add an extra newline before headings, and ignore favicon.ico requests
Change-Id: Ibacac3453afefa5dbe803c1e0260e8c943785f12
2012-05-23 17:17:54 +02:00
Gabriel Wicke 21286a50df Make sure pageName is set in the web service, and handle empty page name in parser function
Change-Id: I5d36eefecc2f35a860d00a8960004f8e651ed17c
2012-05-23 16:43:45 +02:00
Gabriel Wicke a862718ad8 Add some checks against undefined tokens returned from async transforms
Change-Id: Ie19537083b96b1b2e12e1c4b65a7a044753c18ac
2012-05-23 16:32:21 +02:00
Gabriel Wicke a4c5d43ff7 Fix an external link regression, and add server shell wrapper and setup docs
Change-Id: I9a4f7690e98313d003a2fec35324ed70556e6461
2012-05-23 16:25:42 +02:00
Gabriel Wicke b89f5071e5 Basic parser / serializer web service
* After installing Parsoid (sudo npm install -g in modules/parser), run 'node
  server.js' from the api directory and navigate to http://localhost:8000/ and
  follow the directions. You can start to navigate the English wikipedia at
  http://localhost:8000/Main_Page, or manually enter wikitext or HTML DOM to
  convert.
* Uses the express framework, could also use just connect
* Uses the cluster module to manage workers per-core and restart those on
  failure

Change-Id: I443f2996ed3df00826b038b7476a2f966ab0c425
2012-05-23 12:35:00 +02:00
Gabriel Wicke febb912ead No end delimiter after template row attributes
Change-Id: Iba304fb797d221e2d65ae055d266bff2f6301df8
2012-05-23 09:30:07 +02:00
Gabriel Wicke 39c6f42879 Link round-tripping and other improvements
* Changed RDFa for links according to
  http://www.mediawiki.org/wiki/Parsoid/RDFa_vocabulary
* Added basic support for internal/external link serialization
* Moved numbering of external links from tokenizer to LinkHandler
* Added round-tripping for generic HTML tags
* Replaced nowiki tag with <meta typeOf="mw:tag" content="nowiki"> and <meta
  typeOf="mw:tag" content="/nowiki"> for now.
* 154 round-trip tests passing (node parserTests.js --roundtrip).

Change-Id: I16c4db21b1b543ee57c73e569c83025b64664542
2012-05-22 13:36:06 +02:00
Trevor Parscal 86591e5325 Restructured static node rules
Change-Id: I7023e1f334694d59767491f1010e7c4c59c0ce54
2012-05-21 17:39:12 -07:00
Rob Moen 0b9411c531 Cleanup Sanxbox.js
Change-Id: Id8ba1aacecdbb5d31888e289d23ab03a16346c60
2012-05-21 17:03:57 -07:00
Rob Moen 95e06e96bf Prepare for MediaWiki integration
Create context instance in surface.
Move over getSelectionRect into ce.surface
Cleanup ve.surface contstructor class
Move linmod/html test objects to sandbox.js

Change-Id: I0cf602ef991100bf6128c68750b02a00566911dc
2012-05-21 16:06:30 -07:00
Rob Moen 7bf15b4377 Copy ui modules to ve2
Switch sandbox demo to use new ui modules
Update VisualEditor.php to use ve2 modules
SpecialPageSandbox working

Change-Id: I8261d6bf6ceb6ae7b7bfa5f61aec6a0121906765
2012-05-21 12:39:36 -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
Rob Moen 3d5da75782 Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-21 11:01:16 -07:00
Gabriel Wicke 7e21b7380a Merge "Round-trip nowiki" 2012-05-21 17:16:56 +00:00
Gabriel Wicke fb7d5418a5 Round-trip nowiki
Change-Id: I5f7e6a43f5fdc1708ee710b2a601b20db733452c
2012-05-21 18:06:09 +02:00
Gabriel Wicke a6610e52c2 Serializer and table round-tripping improvements
* added stx: 'html' round-trip information for html tags
* added t_stx: 'row' info for row-wise table wiki syntax, and support for it
  in the serializer
* the first table row is implicit in wikitext
* renamed lastToken to prevToken in serializer
* strip first newline in an initial chunkCB

Change-Id: I014b046539d1b674d830551c5fd1b74a67f81993
2012-05-21 14:59:53 +02:00
Gabriel Wicke e069e7cb1c Merge "Support table captions and properly delimit the end of table options" 2012-05-21 12:51:58 +00:00
Christian Williams b7afcff62a Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-18 15:20:01 -07:00
Christian Williams 6d15028c68 Making showCursor work again!
Change-Id: I97e1570ffba368e570b69085daa2798b8b2725f9
2012-05-18 15:19:31 -07:00
Rob Moen f19c5917f2 remove hasChildren method as I was using it to debug something on
previous commit.  change traverseLeafNode test name to follow
ve2 test naming scheme

Change-Id: I8b953e3405f42cd58a80da676ac9b16d64f5e72d
2012-05-18 14:11:23 -07:00
Rob Moen e4a7a36761 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-18 13:48:03 -07:00
Rob Moen 62959bec7a ported traverseLeafNodes and tests to new dm
Change-Id: I98487267d6e3efc9e0c07a02b3d5acc8f8cdb4c6
2012-05-18 13:47:14 -07:00
Inez Korczynski 19a02f3798 Disable objectResizing and inlineTableEditing within execCommand
Change-Id: I06406bfd56e01e72b157fd8cb50da8d6173edc25
2012-05-18 11:40:22 -07:00
Inez Korczynski 32c2366dca Logic for adding 'slugs' before, after and between nodes in certain cases
Change-Id: I91a1c58bdb7819503a9eb24221d6a358c804b57e
2012-05-18 11:34:07 -07:00
Gabriel Wicke 54e75b93b7 Support table captions and properly delimit the end of table options
Change-Id: I15eb8df19528cfceadfee368370501b30f0e36a0
2012-05-18 10:46:43 +02:00
Gabriel Wicke c39eb36968 Use outerHTML to serialize unhandled DOM node in serializer
Change-Id: I37350712c9450c34025740a8d6de51344739c2b7
2012-05-18 10:03:16 +02:00
Gabriel Wicke 3c6d829708 Fix first bug caught by new roundtrip mode for parserTests
Change-Id: Id152fd29606d8ee34ac300945f41e2a5f48f087f
2012-05-18 09:55:22 +02: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
Trevor Parscal 08765feab3 Merged ve.dm.DocumentFragment and ve.dm.Document
* Also fixed lots of whitespace issues and some global variable introductions

Change-Id: Ia6c82ef0c3b5c4938cf72afa86da6d79e4cb385a
2012-05-17 11:23:56 -07:00
Trevor Parscal e8f15204e5 Added skeletons for transaction builders
Change-Id: Iabb2707d20c8b645ffef683f9d8160911c6dc92f
2012-05-17 10:51:01 -07:00
Rob Moen c2a89626d5 Rewrite getMatchingAnnotations to return a hashmap of matching anntations
in the new DM.  Change method name getAnnotationRange from offset to
getAnnotatedRangeFromOffset.  Write tests

Change-Id: I7028803065409e271ceced73e4803954d4a956dc
2012-05-17 10:46:27 -07:00
Subramanya Sastry ae4810b201 Renamed items to itemCount for better code readability.
Change-Id: I53851c07a4746928fddec4b3737136f081d49178
2012-05-17 12:32:46 -05:00
Subramanya Sastry 58da03bc85 Track list prefixes in the list start handler and use them to output
serialized text in list item handlers.

Change-Id: Ic7562d531d2313bedcf3b7450b4f28f02bc2b5a3
2012-05-17 12:12:46 -05:00
Gabriel Wicke e2815b516c Start to handle links
Change-Id: I1fb975910651820fd889d77152562fd4fbcb5db8
2012-05-17 14:32:56 +02:00
Gabriel Wicke b7fd4498a9 Use single _serializeToken handler for both DOM and tokens
Change-Id: I45e1d90b53a5ddc678f7744f27274bebcfc375fe
2012-05-17 13:20:39 +02:00
Gabriel Wicke 8dbc2f573f Simplistic wikitext round-tripping with parse.js --wikitext
Lists are a bit tricky, as nested lists are not wrapped in a separate list
item. Should work now though.

Change-Id: I2e5f29f6afa6bdd2d5e5c0c5d019b70c611b73d1
2012-05-17 12:44:46 +02:00
Trevor Parscal 58aa0e8137 Whitespace fixes and cleanup
Change-Id: Id2220009ed7af7e895990dd4bb373b43d6089b7b
2012-05-16 20:26:05 -07:00
Catrope bcd7431818 Remove getScope(), no longer used
Change-Id: I79e067a8e6b3eb151d3ebe1dfc3aaebe242aed39
2012-05-16 20:16:47 -07:00
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
Gabriel Wicke 3414418b1f Don't eat newline tokens in the ListHandler
This fix only affects following transforms, of which there are few right now.
Also removed a stray token mutation in QuoteTransformer.

Change-Id: Id6d4adce944b06fc1a3651cfbf63fc2670125225
2012-05-16 23:14:21 +02:00
Gabriel Wicke 542921b5a3 Removed html5 parser patch no longer needed with 0.3.8
Change-Id: Id8c23d34e8cca49a360f536e792144a85a8468a3
2012-05-16 12:06:42 +02:00
Mark Holmquist 96ee9ad45c Add a new wikitext serializer, with limited functionality.
This isn't finished at all, but Gabriel wants to take a crack at it,
so here it is!

Change-Id: I9732aa141f7c69a28c8f5978cb18180e93cb9eda
2012-05-15 10:41:28 -07:00
Gabriel Wicke d918fa18ac Big token transform framework overhaul part 2
* Tokens are now immutable. The progress of transformations is tracked on
  chunks instead of tokens. Tokenizer output is cached and can be directly
  returned without a need for cloning. Transforms are required to clone or
  newly create tokens they are modifying.

* Expansions per chunk are now shared between equivalent frames via a cache
  stored on the chunk itself. Equivalence of frames is not yet ideal though,
  as right now a hash tree of *unexpanded* arguments is used. This should be
  switched to a hash of the fully expanded local parameters instead.

* There is now a vastly improved maybeSyncReturn wrapper for async transforms
  that either forwards processing to the iterative transformTokens if the
  current transform is still ongoing, or manages a recursive transformation if
  needed.

* Parameters for parser functions are now wrapped in abstract Params and
  ParserValue objects, which support some handy on-demand *value* expansions.
  Keys are always expanded. Parser functions are converted to use these
  interfaces, and now properly expand their values in the correct frame.
  Making this expansion lazier is certainly possible, but would complicate
  transformTokens and other token-handling machinery. Need to investigate if
  it would really be worth it. Dead branch elimination is certainly a bigger
  win overall.

* Complex recursive asynchronous expansions should now be closer to correct
  for both the iterative (transformTokens) and recursive (maybeSyncReturn
  after transformTokens has returned) code paths.

* Performance degraded slightly. There are no micro-optimizations done yet
  and the shared expansion cache still has a low hit rate. The progress
  tracking on chunks is not yet perfect, so there are likely a lot of unneeded
  re-expansions that can be easily eliminated. There is also more debug
  tracing right now. Obama currently expands in 54 seconds on my laptop.

Change-Id: I4a603f3d3c70ca657ebda9fbb8570269f943d6b6
2012-05-15 17:05:47 +02: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
Catrope c256ea7d71 Fix fatal error in parse.js
Trying something trivial like echo 'Hello world' | node parse.js
would throw TypeError: Function.prototype.apply: Arguments list has wrong type

Change-Id: Ia0a1154b0f3edbfb1f228a1d2072fced1b147141
2012-05-10 12:04:57 -07:00
Gabriel Wicke b1bd0d73ec Don't eat end token in ListHandler, and lazier Quote handler registration
* Setting the rank on tokens is still used currently, but will be phased out
  in favor of setting it on chunks. Tokens will be immutable to allow sharing
  and caching without a need for cloning.
* Only register for newline and end tokens in QuoteTransformer when active.

Change-Id: I2c45bc7e4a105219a1404ab221eed7f242128f1e
2012-05-10 09:47:53 +02: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
Trevor Parscal 44b311920e Cleanup/refactor/documentation work for ve.dm.DocumentSynchronizer
Change-Id: I5f70460e0d4496c91d92b83025fdf9ae1d9dece6
2012-05-09 17:14:15 -07:00
Rob Moen d417c571a4 * Ported getAnnotationsFromOffset into DocumentFragment
* Wrote unit test for getAnnotationsFromOffset

Change-Id: Ie88b15ac6c16838b2d2bf9a2d83ca2952f5df817
2012-05-09 16:31:56 -07:00
Trevor Parscal a0178fd3bb Cleanup and renaming
Change-Id: Ie0b742029f95e1475d58bb38b790bae3110259b0
2012-05-09 15:27:18 -07:00
Catrope 17f4dc220a Don't use data.length in selectNodes()
I was using data.length to check if the range was out of bounds, but
this is a problem when using selectNodes() inside of tree sync code
(which happens when performing rebuilds). While tree sync is in
progress, the model tree and the linear model don't match, so we
shouldn't be looking at the linear model for information about the model
tree. Instead, get the length of the DocumentNode and use that.
`

Change-Id: I11a378544ce1281a89cdcd4363c5cb1bf56f3434
2012-05-08 18:31:51 -07:00
Catrope 00950f3a67 Add rebuild action to DocumentSynchronizer
Change-Id: I379ceef3829026c4b4157e59243b7663b6c7ab2f
2012-05-08 18:31:51 -07:00
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
Adam Wight 0a7f0b7630 List markup is created during the sync23 phase.
This makes it possible to transclude list items from a template.

Note: "5 quotes" test is broken by this patch, it appears that ListHandler
newline processing is changing some state which mysteriously affects the
QuoteTransformer.  This is ominous, hopefully there's a simple explanation...

gwicke: fix a bug in tokenizer triggered by definition lists like this:
**; foo : bar

Change-Id: I4e3a86596fe9bffcbfc4bf22895362c3bf742bad
2012-05-08 11:39:36 +02: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
Inez Korczynski 82ef058cb7 Add two more cats to demo/example article
Change-Id: I25757965ffdfceed2c85c9d76ce58af3d23716f2
2012-05-07 14:30:05 -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