Commit graph

1643 commits

Author SHA1 Message Date
Trevor Parscal 5e6713eae5 Throw an exception when attempting to annotate a closing element
Change-Id: Ifd4e49ee05e74db8bec754a6c1f79c969c1f2eac
2012-06-08 12:23:59 -07:00
Trevor Parscal 5aa6f4b342 Fix bug in fixupInsertion()
When a text node was closed (either by encountering a non-text node or by reaching the end of the document), the fixupStack would not be processed. This led to attributes being dropped when nodes were split because of text being inserted into them

Change-Id: I41f6d20e0c1bfc8d8689b7e6325e724dd8156ab1
2012-06-08 12:23:58 -07:00
Trevor Parscal acdd5679ec Finish implementing ve.dm.Converter and document it
* Add code to handle elements and annotations
* Drop support for aliens from getDomElementFromDataElement() and move it into getDomFromData()
* Implement getDomElementFromDataAnnotation()
* Document a few functions

Change-Id: Ic6a418cbf9d7d1ad96299d7d3633970a876c6103
2012-06-07 21:58:56 -07:00
Trevor Parscal cc0c490502 Fix typo in LinkAnnotation
Change-Id: Idfb969a73c59aef1acf54edd61d555cdc295534c
2012-06-07 21:16:55 -07:00
Trevor Parscal f2b3df8027 Cleaned up some useless/unused functions
Change-Id: I6aa5d0ed3d21993ed653ee64b4928ef98874db2d
2012-06-07 15:02:40 -07:00
Rob Moen e1b8f9422d Fix bug in getAnnotationsFromRange where if the range length was 0
it would return no annotations.

Change-Id: Iec33366b2a1249122a21617d6681ae039557c2fe
2012-06-07 14:53:30 -07:00
Christian Williams 244551ff96 Updating model selection after cut and paste
Change-Id: Iefaec5a3d705c6caae76941bc05810152d870bb8
2012-06-07 14:48:46 -07:00
Trevor Parscal 453bec4555 Fixed alienInline and alienBlock conversion (was missing closings)
Change-Id: Ie8e51eb8d9a452c656aebf341071da5627dd80b5
2012-06-07 14:30:06 -07:00
Trevor Parscal fa9fe8b08a Added support for alienInline nodes
Change-Id: I15b9cbcdb66b966dca28edcb26bf5d54a4f17be6
2012-06-07 14:16:19 -07:00
Rob Moen 9fe6658a0e Put getSelectionRect method back in surface view.
Change-Id: Iaec899bec157ef39810d391b2ed51d4f8fe3be9d
2012-06-07 14:13:55 -07:00
Rob Moen 4b940c3b19 Init rangy in case of Toshiba
Annotate button redraws selection after annotation
Added contextView hooks to select listener in toolbar.

Change-Id: I598fe715dd84976862eed63e4f55cb6bc6e75b18
2012-06-07 14:04:39 -07:00
Christian Williams 1f86885d47 Fixing copy and paste
Change-Id: I57ead6a6d831aa739df49960f97cb2f91f672730
2012-06-07 14:03:48 -07:00
Catrope 9cab267911 Fix some JS errors in the ve.ui code
Change-Id: I57057369f56dc20b56231ed4bbe34816c3c718d7
2012-06-07 13:29:14 -07:00
Catrope 3c1de3dc4f Add ve.dm.Document.getBalancedData()
Change-Id: I2420ef5369b9eae053962898b64dd7324e714bbd
2012-06-07 13:17:57 -07:00
Catrope feac2f6069 Factor out element cloning into a getClonedElement() function
Change-Id: Id6024c15d4d9c9141bc4e1afa39fce29992b8647
2012-06-07 13:17:57 -07:00
Inez Korczynski 6704b01e30 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-07 11:44:35 -07:00
Inez Korczynski 5c41fa2fb8 Define min-height for P and HX tags - needed when those tags are empty.
Change-Id: I0ba1c950cc06b3ff040c208c1b9a4970b2f73493
2012-06-07 11:44:05 -07:00
Trevor Parscal 18461387c0 Roan officially does not owe the team lunch (at this precise moment)
Change-Id: I90a6198da97ea90f60d9668c21d7386984a03ff0
2012-06-07 11:33:58 -07:00
Inez Korczynski ffd411b5e7 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-07 11:26:48 -07:00
Inez Korczynski 22ebab2fa5 Simplify example document that we are currently using in our sandbox (now
it does not include Alien nodes and Images - because we are not going to
support them for June release).

Change-Id: I229e4b5f2881714252699f23aef164655fa8bcf6
2012-06-07 11:25:40 -07:00
Christian Williams f318d68966 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-07 11:17:14 -07:00
Christian Williams 88ae9b0826 Simplified demo HTML (no images or aliens)
Change-Id: If882086eeccf27a55f1ff7ae0d3657c17268c23e
2012-06-07 11:16:56 -07:00
Inez Korczynski 02f913a7db Added accidently removed registrations for events handling.
Change-Id: I6e5df649909b025f7e7aeb35ff9e8ff0b7fcd5f9
2012-06-07 11:10:08 -07:00
Inez Korczynski 97001e1301 Improvements to selection mechanism.
Change-Id: I031dd3493832034c985b15bf213cafe2c4813136
2012-06-07 11:03:22 -07:00
Inez Korczynski 95297a2c73 Delete from ce.BranchNode code that is not needed anymore.
Change-Id: I64f869a9fd54d089d2c6a31d827ddaccb9ece900
2012-06-07 11:02:59 -07:00
Inez Korczynski f711d78d4d Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-07 10:58:42 -07:00
Gabriel Wicke 1ca586e5f1 Improve interwiki config a bit
* Moved wikipedia default prefixes to environment
* Added 'addInterwiki' method
* Adjusted link handling normalizeTitle to reflect this

Change-Id: If5b2314cc36346b6da8649ed410457a612d80a22
2012-06-07 12:30:16 +02:00
Gabriel Wicke 2fa5baabbb Make it easier to configure the default wiki, and add support for mediawiki.org
* mw:Foo now loads pages from mediawiki.org
* The default prefix still is 'en'. You can switch this to 'mw' in ParserService.js.

Change-Id: I1208667e6114bd711b7988a8b3adb32ffab70969
2012-06-07 11:50:40 +02:00
Subramanya Sastry b665a2558f Fixed bugs handing/transforming quotes
- Three bugs that were messing up quote transformations.
- Now, the following cases are handled properly:

  * ''foo'''
  * '''foo''
  * ''foo''''
  * ''''foo''

  These tests (and other quote tests) have to be added to core parser
  tests file.

- One more parser test green.

Change-Id: I4f93e8910639f546bfc9304becab17d26d5529de
2012-06-07 01:37:45 -05:00
Christian Williams 51aa317df3 Undo and Redo support
Change-Id: Icdbebccefe3cc162b9ff6c0d978d5e4fc1f2c561
2012-06-06 20:28:06 -07:00
Inez Korczynski d96db8dce7 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-06 18:50:02 -07:00
Catrope d8359da409 Change calls to getElementType() (which doesn't exist) to getType()
Change-Id: I894835a0178beddce480c48917700090b31c80b2
2012-06-06 18:03:55 -07:00
Rob Moen 72ee6bac1a Comment out robs selection test stuff
Change-Id: I251de0935f733915042684d186da57b43bc35c51
2012-06-06 17:50:28 -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
Christian Williams 77d5cae575 Consecutive spaces
Change-Id: I3f51ce0a2ee0a78e56c55de94bd45796b400680d
2012-06-06 16:29:02 -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
Rob Moen 337e9b8eee Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-06 12:02:22 -07:00
Rob Moen 21ee17a192 Fix up some tools to not break on selection, added some test selection
stuff to sandbox

Change-Id: Ic97144e634111c489507814c6634c66831726191
2012-06-06 11:51:19 -07:00
Catrope 1429a3da59 Rewrite newFromRemoval() using 'covered' mode
Change-Id: If0736aff6d194ec09c2a109f046dd6362ddc64fb
2012-06-06 11:47:35 -07:00
Catrope 1566306937 Add 'covered' mode in selectNodes
Change-Id: I4d24c011ce7a94bc75508dea410fb0ed9ebce6a1
2012-06-06 11:47:35 -07:00
Catrope 244349aedb Fix stupid typo in selectNodes()
Change-Id: I1e308c9f3a6e6eb8fe7fe8ae3c6abf7cc3a84d09
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
Gabriel Wicke 350e700d8f Add core-upgrade
Change-Id: I5ad0955e8272d376f009f89461bed310978b25e4
2012-06-06 15:58:17 +02:00
Gabriel Wicke a146fcb8ad Improve the handling of newlines for round-tripping
An improvement, but there still are some extra newlines inserted after
paragraphs. Example input:

-------

Foo:
{|
|foo
|}
-------

Extra newlines are inserted after the Foo: and the foo in the table. They are
not fed as tokens or text to the tree builder, so there is likely a bug in the
html5 library or JSDom.

Change-Id: I83eb6180e3cd1c4e7f9b15b31d339e1d32bccd3f
2012-06-06 10:17:03 +02:00
Gabriel Wicke 59fc634cce Update patched html5 library to version 0.3.8
Change-Id: I321d9a58ea1af33842a606fc8706938093a8330f
2012-06-06 10:17:03 +02:00
Subramanya Sastry fe6f289486 Merge changes I5d98c704,Ib8d3de75
* changes:
  A few tweaks to link round-tripping
  Use word diff if --color is enabled
2012-06-05 16:04:23 +00:00
Subramanya Sastry b095db4303 Simpler implementation of flatten.
* Possibly more efficient under heavy GC load -- untested.
* No change in time and memory use for single file parsing.

Change-Id: Id2f3f65cc0e5f38ed968bbda60b97e46523e700e
2012-06-05 10:47:46 -05:00
Gabriel Wicke dc3168cf6d A few tweaks to link round-tripping
* Moved the tail attribute to the second attribute (a bit cleaner)
* Disallowed newlines in the tail production
* Improved the selection of round-tripped href vs. generated content vs. href
  in the serializer
* renamed state.linkTail to state.dropTail

Change-Id: I5d98c704b6ea566011e22237786f8da17548570f
2012-06-05 17:26:27 +02:00
Catrope d378182bff Reapply typo fixes from c0e1991 , were undone in b0f6f64
Change-Id: If84e13b91781ed96d3bd9e94171e16020c65ea42
2012-06-05 06:54:35 -07:00
Catrope 528728558b Fix bug in selectNodes's logic for traversing back up the tree
Change-Id: I0fc5a2ad2c9a8d162e8ddbf3cc6d31684d364928
2012-06-05 06:50:09 -07:00
Gabriel Wicke d16032ae9a Track html syntax in block_tag production
Change-Id: If560523644f007485809762f12216e08fb3c3ed3
2012-06-05 12:39:56 +02:00
Gabriel Wicke cc96ff4f5e Very basic interwiki support
Pages titles with a wikipedia interwiki prefix now load the page from
corresponding Wikipedia. Links in a page then stay within the given language.

Note that Parsoid currently makes no effort to recognize localized namespaces,
so it won't render media files, categories etc correctly.

Change-Id: I7bc4102e81a402772ea23231170734d580ea15b9
2012-06-05 11:19:58 +02: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
Trevor Parscal 9111e34a0b Added nodeOuterRange to selectNodes
Change-Id: I9ef0c383fbb2515c752d2d3c52e8632aac73d811
2012-06-04 16:21:29 -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
Gabriel Wicke 92f753a365 Pre and link target improvements
* Don't explicitly add the newline in the pre, as we preserve newline tokens
  now. This avoids doubling of newlines when round-tripping.
* Use the sHref attribute even if the href contains spaces.

Change-Id: I8bec8fbfd6a7836bf2e5eec20869a0edd95c93b6
2012-06-04 14:03:05 +02:00
Gabriel Wicke ee2ddbd3cb Fix list handler issues
Lists interrupted by non-empty lines would not close the list properly.
Register for any token instead of just for newlines and close the list if no
listItem follows the newline.

Change-Id: I1743901e3db541bbeda78d17707db943e6ceb9b9
2012-06-04 13:38:43 +02:00
Gabriel Wicke f821eac102 Optionally round-trip sHref in data-mw
If the href would not denormalize, add a copy of the original href in data-mw
and use it to preserve non-conventional capitalization etc.

Change-Id: Ifef50eec7343b0e6b0ba66b6d19a8a3e8c9f8001
2012-06-04 12:28:05 +02:00
Gabriel Wicke e0809209ec Don't set the data-mw attribute if the object is actually empty.
Change-Id: I984f1b44bba67d7a9f1a709738d14c0ee02f69a9
2012-06-04 12:26:03 +02:00
Gabriel Wicke 2774e5aa6c Actually replace all underscores in wikilink target
Change-Id: I633f8d6e4f639aff90fd456600376b7c6515fd50
2012-06-04 11:48:59 +02:00
Gabriel Wicke 3f2c72f920 Fix padleft / padright (mis)use as substr
Change-Id: I0645e11c8ef8b550ad35300d1904788940fc748a
2012-06-04 11:30:45 +02:00
Gabriel Wicke 4533c274ca Fix a crasher in the serializer
A tail containing regexp syntax (a ? in [[:en:Main Page]]) would crash the
serializer. Use substr instead.

Change-Id: I8519aec9c07dfe31893d676b1c936a42d2af74a0
2012-06-04 00:00:54 +02:00
Gabriel Wicke 31522d3d49 Add ApiRequest
Change-Id: I5f2a1cb65223a68f10bc63903000248efca05586
2012-06-02 16:52:51 +02:00
Gabriel Wicke 63abd57fc8 Improve newline-before-paragraph round-tripping support
Change-Id: I9176a97f9695018650d9a63b89514c07e0d6be90
2012-06-02 16:39:33 +02:00
Gabriel Wicke d3975a8d03 Very basic round-trip test mode for the API
Returns both the resulting wikitext and the diff with the original input.

Change-Id: Iad25039beb054a84e1ad51ffa9fee924db49c60b
2012-06-02 16:20:54 +02:00
Gabriel Wicke 74135b295f Some more switch fixes
Change-Id: If1a6086348c45a73a941bc8e6728ef75d002be50
2012-06-02 15:04:20 +02:00
Subramanya Sastry 8f216af2f5 Handle link tails properly.
- Added a tail json attribute for wikiLinks
- During serialization, this attribute is used to strip the tail from
  the link target and render it after the link

  [[hen]]s ==> <a ... data-mw="{gc:1, tail: 's'}" ...>hens</a>
           ==> [[hen]]s

- 2 more roundtrip tests green

Change-Id: I84f3dabaf0271f7a67641a00148467daa8310eb0
2012-06-01 23:41:10 -05:00
Trevor Parscal 73c5dd8f1d Added ve.dm.Node.getOffset
Change-Id: I4fb99040af44c063ad3b6489f2fd895d843fcf0c
2012-06-01 17:44:01 -07:00
Christian Williams 3ef601f04e Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-01 16:38:43 -07:00
Christian Williams cf63a2dd36 Support for pasting into a range
Change-Id: I13e29caba4d912db2477a2c3c4edeca5d21d06b4
2012-06-01 16:38:27 -07:00
Rob Moen 3f3b525d56 Add MakeGlobalVariablesScript hook to add new global, vePageWatched.
This allows us to check the watchlist checkbox on save dialog.
Added watchlist toggling to ve save api.
Added some i18n messages to core integration.

Change-Id: Ibed8edb2c59ad49e1738c937c3bea518238d0845
2012-06-01 16:30:17 -07:00
Christian Williams 2bd615c6d2 Cut, copy, and paste now working with images
Change-Id: Ic3b99d39bd41a8fe39e015ca05d159a5a4ea2b15
2012-06-01 15:52:51 -07:00
Subramanya Sastry 413fc5e043 Fixed bug serializing wikilinks with implicit link text.
* Simple fix but greens 10 more roundtrip tests.

Change-Id: I7f82d788a10bd83e0e3215568c2168081c332c50
2012-06-01 17:25:21 -05:00
Inez Korczynski a2e7335ed6 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-01 14:37:34 -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
Inez Korczynski 8a35e6eafe Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-01 13:51:24 -07:00
Gabriel Wicke 16219ddc6d Fix up #switch a bit
* Re-establish the value-only default
* Fix value expansion

Change-Id: I32e62789b25bbe17a74c564e41e9101ad5528fb7
2012-06-01 22:15:43 +02:00
Gabriel Wicke e2301813ed Merge "Tokenizer backtracking cache bug fix and memory savings" 2012-06-01 12:06:00 +00:00
GWicke befd223476 Merge "First pass implementing a general tag minimization routine" 2012-06-01 11:15:48 +00:00
Gabriel Wicke ece2b0f810 Tokenizer backtracking cache bug fix and memory savings
* The state of syntax stops is now properly included in the cache key for the
  tokenizer-internal backtracking cache. This fixes some mis-parses when
  re-parsing a bit of text with different flags.
* Clear the backtracking cache after each toplevelblock. This drops the peak
  memory usage when expanding [[:en:Barack Obama]] from ~380M to ~110M.

Change-Id: Icdb879cae5907e4595903dd6acba2e686e8c2e4b
2012-06-01 12:53:49 +02: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 ba8d1b46f2 Cleanup
Change-Id: Ida9c94d5aa410ee699b706492f444a6449922ede
2012-05-31 17:11:01 -07:00
Trevor Parscal 294abb0a38 Simplified converters data structures
Change-Id: I1734bc7e06462595ea2f27715948fbb3d9e552ad
2012-05-31 17:03:03 -07:00
Rob Moen 7d96b8426f Created save dialog in core integration
Stash content element styles and remove transitions
Working towards a cleaner saving experience

Change-Id: Ic67022456f46b2bef56a9b0ccfcf93c3283573c4
2012-05-31 16:56:40 -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
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
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
Gabriel Wicke 909633ea08 Improve template / tplarg precedence in tokenizer
Change-Id: If9b24b42ea223e0f30f906a83496d73ec60c4a0d
2012-05-04 13:17:06 +02:00
Gabriel Wicke 8a30f76370 Use upright option, including the 0.75 default width
Change-Id: Iacdf6173e0ee8f58ca4385fd9b2cde77b2fdf3c4
2012-05-04 11:15:35 +02:00
Trevor Parscal a9b26c8b55 Removed recursive rendering calls in favor of 100% event driven updates
Change-Id: I636222518e4cbeddb1c02901b79a9dcb09eeb952
2012-05-03 17:19:01 -07:00
Rob Moen 014084fc65 - fix demo styling for docs list
Change-Id: I5e5d16fe9a002e3cafd01138ad9b92ff987178d6
2012-05-03 16:27:28 -07:00
Rob Moen 0cd31fba2e rename surfaceModel to model in ce.Surface
Change-Id: I5d49915b4645464729ab1e4552982cbd38f712b1
2012-05-03 16:14:54 -07:00
Rob Moen b05347ac4e removed margin-top for documentNode
Change-Id: I6e888ca858bc2d9e6772150715b10ab157f84b46
2012-05-03 16:07:51 -07:00
Rob Moen bead2050b9 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-03 16:04:47 -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
Christian Williams 99e841d31a Making document contenteditable
Change-Id: If79bb8c69431e07de2a42cc5b565b3093c29c4cd
2012-05-03 15:42:02 -07:00
Inez Korczynski 1ecb762d35 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Conflicts:
	modules/ve2/ve.Surface.js

Change-Id: I1c81426203f01fa2f698819bf6c63a3afd1239c9
2012-05-03 15:02:04 -07:00
Inez Korczynski d01d27cc09 Get more tags/nodes working in the demo
Change-Id: I5335fbbe15d010a73a06f24bc56ebb3c3c6bd2d7
2012-05-03 15:00:34 -07:00
Rob Moen cdcca3eeb2 Move linearModel object into sandbox.js
Change-Id: Ia87e6fb13abab31f14f997f8ba7a9b631f6fb667
2012-05-03 14:27:36 -07:00
Rob Moen 56dff6dacb Added new node types
Change-Id: I6b5f2e5a7dbdb7c59b4799d44f7924c5594c0e34
2012-05-03 14:22:09 -07:00
Inez Korczynski 6224c60075 Rendering works in very basic version
Change-Id: I8789860fe82f2e7db1e503889e20ce51de57bfa2
2012-05-03 14:02:35 -07:00
Inez Korczynski 06ca808b65 Missing keyword: new
Change-Id: Id65d30d702e991620e0d454fa000c438f4738b41
2012-05-03 13:32:23 -07:00
Rob Moen 7bcb65e036 - Port surface constructor into dmrewrite.
- Create document model object linear model instead of wikidom

Change-Id: I16307c290ead3e4b29dfbd1b76759e4c19c3fc8b
2012-05-03 13:23: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
Inez Korczynski 619f10108c Minor fixes to getHtml method in TextNode
Change-Id: I53c873b6e307d53cc87c2e111ab99f694972b17b
2012-05-03 11:11:46 -07:00
Inez Korczynski a1db1537ad Minor fixes to getHtml method in TextNode
Change-Id: I4d0b1a0295071ead413d68945310d3a4ef6fe7e4
2012-05-03 10:11:39 -07:00
Gabriel Wicke 57dfd89383 Handle upright option properly
Change-Id: I831fcccf874f9a0505e88eb76d269b1d2f68e3e0
2012-05-03 16:15:34 +02:00
Gabriel Wicke c4fc7508a7 Add basic # REDIRECT handling
Change-Id: I71f659201c1d5de4a528ddfac7f65bf20a89f97d
2012-05-03 15:54:36 +02:00
Gabriel Wicke 6ab017308b Only specify the width for thumbnails to keep the aspect ratio
Change-Id: I4e55ff719da6cb58f396ad6043e46acaed4a504d
2012-05-03 15:36:42 +02:00
Gabriel Wicke 6139398494 Reduce debugging overhead a bit, and provide default internal image size
Change-Id: I345af8c5905a5fa747f9ed342ba2ba8c1026d044
2012-05-03 14:49:55 +02:00
Gabriel Wicke 6e21f6bb27 Forward-port Cite extension
* Adapted Cite extension to use current interfaces and token formats
* Improved TokenCollector

Change-Id: I20419b19edd9bbad2c2abf17a2ff1411b99c0c04
2012-05-03 13:22:01 +02:00
Inez Korczynski 09c7393901 Minot fix
Change-Id: If10f9135f9bf33af17be6f8a2db59433d9898944
2012-05-02 22:32:34 -07:00
Inez Korczynski a3b32b6615 Big refactoring to TextNode to make it work with new format of storing
annotations.

Change-Id: If84fcfdd04ff42e9b2449e1c8186d64fec4fb1ac
2012-05-02 22:28:57 -07:00
Inez Korczynski 9f11f437d2 Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite 2012-05-02 19:29:49 -07:00
Inez Korczynski d81b972cdf Very dirty but working version of getHtml method for TextNode (with bunch
of tests that are passing now).

Change-Id: Ie76bd59bc0a5e10e2a3b3e014b2d0e4701fcc368
2012-05-02 19:29:03 -07:00
Trevor Parscal 64d56971a9 Removing unused code
Change-Id: I23213531eeef95110d0a3d1e2476449c580b55b7
2012-05-02 17:05:22 -07:00
Trevor Parscal b7b2fc1179 Made render for ce leaf nodes abstract and added a test for it
Change-Id: Iee228d5f1a18a5c9618680fa81ab132a85472fa6
2012-05-02 15:59:43 -07:00
Trevor Parscal 947c3ddf22 Fixed incorrect class name for method typo
Change-Id: I82390896ef7136bfc8ed8734d8bd9014e756af5e
2012-05-02 15:59:15 -07:00
Trevor Parscal d412c8c159 Removed unused method (using factory instead)
Change-Id: I0ed9260d261b7e4c19e5d57f70331aef1a341cdf
2012-05-02 15:58:40 -07:00
Trevor Parscal 16e12debdc Added ve.getHash and ported ve.Json
Change-Id: I4a5d86426902e0473cdb0f98c3d121eed607f93c
2012-05-02 15:23:01 -07:00
Inez Korczynski ff40652099 Get rid of range parameter in ve.ce.TextNode.prototype.getHtml as it is
not being used anyway.

Change-Id: I7c54d35001fa0db6d7ab9d12f35ab2d841016f0d
2012-05-02 14:21:41 -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 8bd0d385eb Added test for whitespacePattern, getDomText and getDomHash in ce
* Also fixed some naming typos in the units under test

Change-Id: I17f753a122f94dd16f7783f60b5c0eb1c6d3e480
2012-05-02 12:54:42 -07:00
Trevor Parscal fee375cf4e Removed global variable introduction
Change-Id: I331b19cafeb20610f7b42bacaff20757a342dffc
2012-05-02 12:37:30 -07:00
Trevor Parscal 676ffa4dbc Ported getDomText and getDomHtml from ve to ve2
Change-Id: I3547d95c2749543eae745722ceddaa0a969e4e80
2012-05-02 12:28:27 -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 94f53dc6c7 Made text nodes not rely on a wrapper
By using this.$ as a selection of contiguous top-level nodes (text or otherwise) we can avoid wrapping each text node in a span

Change-Id: I141c2df8f13646db3fff0da93d218c2dcf154c8a
2012-05-02 10:58:14 -07:00