Commit graph

1076 commits

Author SHA1 Message Date
Trevor Parscal 489794c89c Renamed rootNode to documentNode and added tests
Within ve.dm.DocumentFragment it makes more sense to call the root node (which is always a document node) a document node, especially since there may be a different node used as a root.

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

Change-Id: Ic4609233cedc41f7e5a5f8fdb0e6178652c95554
2012-04-30 11:37:48 -07:00
Catrope 80decda935 Mostly-finished TransactionProcessor
Change-Id: I7d2cd684fafa16c85d0d9c9ad2b6d42d7e6f1448
2012-04-30 11:26:22 -07:00
Inez Korczynski d6ae8390f5 Get rid of selectionDirection. Introduce getDirection() methdo in
ve.Range.

Change-Id: Iaf11b2dbfb7ae82a7f54ee205cd6cdc8ee235aef
2012-04-27 17:36:55 -07:00
Inez Korczynski af6a9f9ccc Created a named method inside a Surface (instead of anonymouse one) to
handle logic for rangeChange event handler.

Change-Id: Ief32e647f9399e3ea47c5613902cebcbaaf4874c
2012-04-27 17:31:49 -07:00
Trevor Parscal a774b3dbf6 Added test for getOffset map
And fixed ve.dm.DocumentFragment constructor to generate a correct offset map which creates references to branch nodes only

Change-Id: If9e515be0c63d272bfed9bf4da625a48edd36f48
2012-04-27 17:16:29 -07:00
Trevor Parscal eeded0eb1d Renamed batchedSplice to batchSplice
Change-Id: If7b2b56f9eb79f810461fc49bbdc9aa860461662
2012-04-27 15:09:10 -07:00
Trevor Parscal 0245f6a6a8 Fixes for 44fe109f14 which mistakingly added .children to a few uses of batchedSplice
Change-Id: I2c876a66b64c6f1ae3cbd1577b7e1102618997ba
2012-04-27 15:08:15 -07:00
Trevor Parscal 44fe109f14 Added test data and fixed test suite links
Change-Id: Idb5de70b58c525a67f16b21f7adc53214af9b486
2012-04-27 14:59:52 -07:00
Gabriel Wicke 2291fe8364 Reduce the need for token cloning slightly
Change-Id: I31c71bddca4855afdffc3fe5c8d759cfa1994d86
2012-04-27 23:12:25 +02:00
Trevor Parscal f19897fefa Merge "Build out ve.Surface constructor to support multiple editor instances Now setting up multiple toolbars per config Tools & Modes are now configurable per toolbar per instance Base elements are created on demand and no longer id specific Note: There are some bugs with multiple instances." 2012-04-27 21:01:10 +00:00
Gabriel Wicke 5fb2c46073 Clone cached tokens, and fix switch for empty needle
Change-Id: I63946e5a56f6fd7dd30d00b12d36032dd1dd0017
2012-04-27 15:59:01 +02:00
Gabriel Wicke ed8cb54831 Simplify transformToken slightly, and fix JSHint warnings
Change-Id: I95769ed063ea855a9109148f5db83ea43f423e56
2012-04-27 15:31:30 +02:00
Gabriel Wicke 2d7b4a2a59 Make .to more consistent and add optional parentCB arg
* parentCB (if set) is called with { async: true } if expansion is going to be
  asynchronous.
* Strings are handled efficiently
* all value parameter chunks can now be converted using .to().

Change-Id: Ib013e1bc3d8e7f692009038209db6a056887326e
2012-04-27 13:57:23 +02:00
Gabriel Wicke fd1a67aa16 Add .to('text/plain/expanded', cb) support and convert ifeq to use it
Change-Id: I99c78de12fed41ba36811402f7ecacb420391d70
2012-04-27 12:18:30 +02:00
Gabriel Wicke 30a83d7fd7 Accept wikilink parameters with dangling equal ('|arg=|')
Change-Id: Ib4f6d186da2a74522b17c377dac5c9a7de7e5861
2012-04-27 11:35:00 +02:00
Gabriel Wicke 1d70e7b81c Disable preformatted text from indents in template args
Change-Id: I84144d3fab6541ed264d9b092806c8bf9de6e8b2
2012-04-27 10:45:08 +02:00
Trevor Parscal 42eaba05e7 First go at ve.dm.Document and ve.dm.DocumentFragment
Change-Id: I6099ec0dbdac8d00cdde138b6b9a1b3a5781daea
2012-04-26 19:44:44 -07:00
Inez Korczynski f188772259 Introduce new method called "proxy" in surfaceView to avoid using the same
construct with anonynous function over and over.

Change-Id: I1e96cf1efaa6fa5d551fdfa8bb5a80c31e519579
2012-04-26 14:49:12 -07:00
Rob Moen 94479bd79d Build out ve.Surface constructor to support multiple editor instances
Now setting up multiple toolbars per config
Tools & Modes are now configurable per toolbar per instance
Base elements are created on demand and no longer id specific
Note: There are some bugs with multiple instances.

Change-Id: Id0bbbca2d1b76fd2db3f3b0f9abd90194930b610
2012-04-26 11:56:47 -07:00
Gabriel Wicke 56d6757f67 Fixes for the template fetch retry feature
Change-Id: Id36cb02c535d07f4f2cdd54ae682b6a144a2faa9
2012-04-26 20:31:23 +02:00
Gabriel Wicke 027d77e0c9 Fix --wikidom and --linearmodel parse.js options; retry on template fetch failures
Change-Id: I444397936fd87971fe085df4b467089367e9ffa6
2012-04-26 19:51:00 +02:00
Gabriel Wicke 3be4992782 'Obama finally expands' ;) Misc fixes and documentation updates
* [[:en:Barack Obama]] can now be expanded in 77 seconds using 330MB RAM,
  while it would prevously run out of RAM after ~30 minutes. Wohoooo!
  The token transform framework rework really paid off.
* 303 parser tests are passing in the new record time of 5.5 seconds. Two more
  tests are passing since these tests expect the day of the week to be
  Thursday.  Won't be the case tomorrow.

Change-Id: I56e850838476b546df10c6a239c8c9e29a1a3136
2012-04-26 18:18:08 +02:00
Gabriel Wicke 8ff810659a Rename text/wiki and tokens/wiki to text/x-mediawiki and similar
Change-Id: I70113629f4633685cd6db3914303a15e4c79a50a
2012-04-25 20:19:43 +02:00
Gabriel Wicke 814511f523 Remove dead parser pipeline code
Change-Id: I802f1798d5163c1ce82d648f739c2e79b17eda41
2012-04-25 17:12:32 +02:00
Gabriel Wicke 5a3f5544a5 Merge "Biggish token transform system refactoring" 2012-04-25 15:07:44 +00:00
Demon 5feb5ebcbf Merge "Fix typo" 2012-04-25 14:51:47 +00:00
Gabriel Wicke 8368e17d6a Biggish token transform system refactoring
* All parser pipelines including tokenizer and DOM stuff are now constructed
  from a 'recipe' data structure in a ParserPipelineFactory.

* All sub-pipelines of these can now be cached

* Event registrations to a pipeline are directly forwarded to the last
  pipeline member to save relatively expensive event forwarding.

* Some APIs for on-demand expansion / format conversion of parameters from
  parser functions are added:

  param.to('tokens/expanded', cb)
  param.to('text/wiki', cb) (this does not work yet)

  All parameters are additionally wrapped into a Param object that provides
  method for positional parameter naming (.named() or conversion to a dict
  (.dict()).

* The async token transform manager is now separated from a frame object, with
  the frame holding arguments, an on-demand expansion method and loop checks.

* Only keys of template parameters are now expanded. Parser functions or
  template arguments trigger an expansion on-demand. This (unsurprisingly)
  makes a big performance difference with typical switch-heavy template
  systems.

* Return values from async transforms are no longer used in favor of plain
  callbacks. This saves the complication of having to maintain two code paths.
  A trick in transformTokens still avoids the construction of unneeded
  TokenAccumulators.

* The results of template expansions are no longer buffered.

* 301 parser tests are passing

Known issues:

* Cosmetic cleanup remains to do
* Some parser functions do not support async expansions yet, and need to be
  modified.

Change-Id: I1a7690baffbe8141cadf67270904a1b2e1df879a
2012-04-25 16:51:36 +02:00
Demon 28e44b1d0f Merge "Add --wikidom flag to parse.js" 2012-04-25 14:18:59 +00:00
Catrope 47969e20a1 Add --wikidom flag to parse.js
Also remove unused import of DOMConverter

Change-Id: I1eabe6bf9935970c1f049681b52e867a510ea77a
2012-04-23 15:01:12 -07:00
Catrope 69df3eefbc Implement ve.NodeFactory and add tests
Change-Id: I34fdf24c0099072fe5f7178400abbc323be975d4
2012-04-23 11:46:30 -07:00
Catrope a239b73746 Don't instantiate classes in ve.extendClass(), it's unnecessary
Change-Id: Iebb9c871750a19a806ebdd911e1ef476a0acaddc
2012-04-23 11:46:30 -07:00
Catrope e84b6b656b Rename ve.dm.NodeFactory to ve.NodeFactory
Change-Id: Ic2a0389ca4855ac1afc3fb9a151145fea2b4795e
2012-04-23 11:46:30 -07:00
Catrope d1d70ddf3e Add a note that I need to implement insert and remove as replace
Change-Id: Id076921707bf6295a6bbac3264fa0074178e9321
2012-04-23 11:46:30 -07:00
Trevor Parscal 3d6391419d Added more nodes and removed canHave[Grandc|C]hildren methods
Replacing them with static members on each node type

Change-Id: I455debf880bef4e280eea072364f5f57308ec2b1
2012-04-20 16:34:47 -07:00
Trevor Parscal 8ce68e1ac8 Merge "Modify rangeChange event to save selection direction. Renamed Selection method to more suitable name. Misc cleanup Patchset 2, whitespace cleanup Patchset 3: Change values used with selection direction to -1 or 1 1 for left to right (normal) -1 for right to left (opposite) Change-Id: If9ecc721ace1c7550903170f92395947f1ccc22c" 2012-04-20 23:29:21 +00:00
Rob Moen 5fc9f1c7e4 Modify rangeChange event to save selection direction.
Renamed Selection method to more suitable name.
Misc cleanup
Patchset 2, whitespace cleanup
Patchset 3: Change values used with selection direction to -1 or 1
1 for left to right (normal)
-1 for right to left (opposite)
Change-Id: If9ecc721ace1c7550903170f92395947f1ccc22c
2012-04-20 16:27:26 -07:00
Trevor Parscal 29d1ebeca7 Merge "Put a space in the toolbarDropdownTool-label div for default Addresses dropdown tool ui inconsistency on load" 2012-04-20 22:56:36 +00:00
Trevor Parscal 5eca12cca2 Added skeleton class for ve.dm.NodeFactory
Roan will finish the rest

Change-Id: I8da5c493b13f00ca9abdc94ef20e0d2923893d28
2012-04-20 14:40:31 -07:00
Catrope d4d2ae88ad Update lengthDifference in ve.dm.Transaction.pushReplace()
This makes the tests pass

Change-Id: Iede7f47183378d80419f616ff62732a07d136d87
2012-04-20 11:29:30 -07:00
Catrope 0a43cf1f32 Remove documentation for nonexistent parameter
Change-Id: I3237eca92d5962a415c596da84cd3f51d3d8cebb
2012-04-20 11:29:30 -07:00
Catrope 08f792a198 Remove the parameter from the ve.dm.Transaction constructor
It's not being used at all, and it's broken because
this.lengthDifference is set to zero regardless of what length
difference the operations passed into the constructor might cause

Change-Id: I3b7a312a1920347e7bf34df88a05bf6f2ff11f7d
2012-04-20 11:29:30 -07:00
Catrope d93f2f2bab Copy ve.dm.Transaction.js from modules/ve
Change-Id: I629376bfa935ff120d93d8cfc020884524a0ae2f
2012-04-20 11:29:30 -07:00
Trevor Parscal b004b22241 Added tests for all exceptions
We are now checking for the exception messages as well.

Change-Id: I3a306ce9fe82afe6fd1e46a2e4da4d0a70952688
2012-04-19 18:05:48 -07:00
Trevor Parscal 9a3784301b Improved test coverage for ve.dm.BranchNode.splice and ve.dm.TwigNode.splice
* Changed splice to check all elements about to be inserted are allowed before inserting any of them so that catching an exception leaves you in a sane state
* Fixed the order of execution of parent class constructors in ve.dm.LeafNode and ve.dm.TwigNode so that canHaveChildren and canHaveGrandchildren produce correct values and added tests to ensure these methods are correctly inherited in subclasses
* Added tests that check for exceptions when adding nodes that can have children to nodes that can not have grandchildren
* Added test that check for events being emitted before and after splicing, including that beforeSplice should be emitted even in cases where a splice fails and throws an exception because the nodes are incompatible (but afterSplice is not called in this case) since beforeSplice might modify the nodes in some way before the compatibility tests are run

Change-Id: Id12aea995a42c26ff63a74ae3d31f2bf455759e3
2012-04-19 17:45:58 -07:00
Trevor Parscal f081c0932a A few fix ups for fd49e8d
* Moved getParent and getRoot from ve.dm.Node back to ve.Node
* Fixed use of getElementLength that should have been changed to getOuterLength, but was changed to getLength (oops)

Change-Id: Ibe5b855aef533dcd493f762a8a02c6a11ce6e7de
2012-04-19 16:47:40 -07:00
Trevor Parscal fd49e8df32 Added more tests for ve.*Node and ve.dm.*Node classes
In this commit several methods (child node add/remove and parent/root modification) were also moved to ve.dm.BranchNode ve.dm.Node respectively. ve.Node and ve.BranchNode are immutable. ve.dm.Node and ve.dm.BranchNode are mutable. Other subclasses of ve.Node and ve.BranchNode should implement functionality to mimic changes made to a data model.

Change-Id: Ia9ff78764f8f50f99fc8f9f9593657c0a0bf287e
2012-04-19 16:03:59 -07:00
Rob Moen 8398696fe0 Put a space in the toolbarDropdownTool-label div for default
Addresses dropdown tool ui inconsistency on load

Change-Id: I855ac15e939fa895adb67daaeb45aadbac01f10b
2012-04-19 15:31:09 -07:00
Rob Moen 1a68c42049 Modify VE constructor to have the default set of tool configuration
Configuration options are to extend base options in the constructor.

Change-Id: Ic430a6489d8cf9a703e374c3f416feaf0e3d2521
2012-04-19 15:14:57 -07:00
Trevor Parscal c9ce7dbffe Added some basic coverage for ve.*Node classes
* prototype.canHaveChildren
* prototype.canHaveGrandchildren
* prototype.getType
* prototype.getParent
* prototype.getRoot
* prototype.setRoot
* prototype.attach
* prototype.detach

Change-Id: I920f7c9504e467f4818df537608760165c28d432
2012-04-19 14:43:58 -07:00
Trevor Parscal b16ed2b12d Setup tests, which are still empty
Had to fix a few namespace typos too

Change-Id: I3ebdc418f374bd3e151c516e1c0cfe85398772f0
2012-04-19 14:17:59 -07:00
Trevor Parscal 7ea475ebcf Initial commit of data model rewrite
Ground-up rewrite of the data model. Putting this in the ve2 directory for now so we still have the old code floating around.

Main changes so far in this rewrite:
* Renamed hasChildren() to canHaveChildren()
* Added canHaveGrandchildren()
* Added a new node type TwigNode that can have children but not grandchildren (so all of its children must be LeafNodes)
* Implemented push/pop/shift/unshift as wrappers around splice()
* Renamed getElementType() to getType(). Nodes now take a string as a type, and the element stuff is gone and won't be back
* Removed clearRoot(), replaced it with setRoot( this ) where needed

Change-Id: I23f3bb1b4a2473575e5446e87fdf17af107bacf6
2012-04-19 13:54:34 -07:00
Gabriel Wicke e2ca8c24c7 Delay some token duplication until actual mutation happens
This is a bit better than cloning tokens wholesale, but not by much. There is
a lot of potential for much better per-token caching with reduced token
cloning. Need to map out all dependencies besides token attributes expanded
from template parameters or other scoped state. Even if tokens themselves
don't need transformation, they might still need to be considered for other
token transformers, so simply keeping the final rank won't quite work even if
the token itself is fully transformed. As a minimum, a shallow clone would
need to be made and the rank reset (as in env.cloneTokens).

Change-Id: I4329113bb21750bae9a635229ed1b08da75dc614
2012-04-18 17:53:04 +02:00
Gabriel Wicke bf84638bc0 Add tokenizer cache and clone token state on mutation
* Added an LRU cache (using the lru-cache node module) for tokenizer output
* Mutation of nested attributes now replaces the containers. A shallow copy of
  tokens is sufficient to isolate token transformations. Need to investigate
  if we can actually get away without isolation and re-transformation for most
  ordinary tokens.

Change-Id: I9136b1d7a1fbcc538183a319d4ecaa290d616fdf
2012-04-18 14:40:47 +02:00
Catrope 80e383c346 Merge "Removed line-height from preview panel" 2012-04-17 21:05:48 +00:00
Catrope fa9e02cfad Merge "Improved the appearance of the warning at the top of the editor" 2012-04-17 20:36:44 +00:00
Gabriel Wicke aaca5eac7d More tweaks: safesubst and image options
* Ignore safesubst for now
* Remove an unneeded whitelist entry
* Make sure the caption is not lost for thumbs (fix to last commit) and remove
  debug print

Change-Id: I243584ed0838cf7c3b4110fe9cdf869272477312
2012-04-17 11:02:52 +02:00
Gabriel Wicke 7fe5a86b60 Improve image option handling
Change-Id: If1376766f41ff1288bfe2af19beecd3299c09a01
2012-04-17 10:46:20 +02:00
Catrope bd900a4bd4 Add ve2 directory for rewriting code in
Change-Id: Id71ba248c73baa05e5fbeb8ad91f9225c1d1f412
2012-04-16 19:38:13 -07:00
Catrope 4b6e1401a3 Fix typo
Function was renamed but error message wasn't updated

Change-Id: I61a9effa8dedcbdbc75c5c6842fb05f909561327
2012-04-16 12:20:16 -07:00
Gabriel Wicke afa5b95bc1 Don't work around html5 library tokenizer attribute reordering
The HTML5 parser we are using to normalize expected HTML output in parserTests
reverses the order of attributes (see
https://github.com/aredridel/html5/pull/53 for the fix). Remove whitelist
entries concerned with this and use the proper order in external image
attributes.

Change-Id: If1868cae05396a150757c85a20473ab756cbcd97
2012-04-16 17:09:06 +02:00
Gabriel Wicke c688b039de Collected tweaks
* less verbose logging in noinclude processing and template expansion
* Give priority to the processing of templates transcluded from transclusions
  to get closer to depth-first processing. This serves to minimize memory
  usage from queued-up tokens.
* Increase the maximum outstanding requests per template retrieval. 10000
  amazingly proved too low a limit on some big pages.
* Only process a single template request callback at a time for now
* Add a debug print in the treebuilder wrapper
* Don't treat multiple comments on a single line as a single comment to match
  the PHP parser's behavior

Change-Id: I9a86b6d7bec3b9e1f17415daf1bf74170240721a
2012-04-16 15:47:03 +02:00
Gabriel Wicke 1bf8a9e5e1 Small tweak in comment about onlyinclude forcing buffered expansion
Change-Id: Ib324e24c51c97e07e6737bf23f16db07043b69ab
2012-04-16 15:42:29 +02:00
Gabriel Wicke efd4c026ea Disallow < and > in external link urls
Change-Id: Id865c3d46b33b182bb5b244e77e815c0afd7fa49
2012-04-16 15:36:56 +02:00
Gabriel Wicke 25523f4cf0 Implement urlencode parser function
Change-Id: I4fca3134c9c3eb9a7d6f3360be6de054fb47477c
2012-04-16 14:54:03 +02:00
Gabriel Wicke 421ef44621 Match the empty string as whitespace too
Change-Id: I1a8ed882021804f62855b9db4368270feebbfc16
2012-04-16 14:48:39 +02:00
Trevor Parscal 387b3160ca Merge "Add and update an offset map in DocumentNode" 2012-04-13 23:48:57 +00:00
Catrope 7465b670e1 Add and update an offset map in DocumentNode
This has some TODOs still but I want to land it now anyway, and fix the
TODOs later.

* Add this.offsetMap which maps each linear model offset to a model tree node
* Refactor createNodesFromData()
** Rename it to buildSubtreeFromData()
** Have it build an offset map as well as a node subtree
** Have it set the root on the fake root node so that when the subtree
   is attached to the main tree later, we don't get a rippling root
   update all the way down
** Normalize the way the loop processes content, that way adding offsets
   for content is easier
* Add rebuildNodes() which uses buildSubtreeFromData() to rebuild stuff
* Use rebuildNodes() in DocumentSynchronizer
* Use pushRebuild() in TransactionProcessor
* Optimize setRoot() for the case where the root is already set correctly

Change-Id: I8b827d0823c969e671615ddd06e5f1bd70e9d54c
2012-04-13 16:46:02 -07:00
Rob Moen efb8384c1e Merge "Cleanup terms used in annotation method" 2012-04-13 21:37:07 +00:00
Gabriel Wicke 08453199df Increase number of callbacks per reactor iteration to 4
In experiments this dropped the memory consumption further, and reduces the
queuing overhead in the node reactor.

Change-Id: I9409b6ca863b43b7557663bbec9572365059c078
2012-04-13 14:50:36 +02:00
Gabriel Wicke 06ae53fdfe Drastically reduce memory usage for template-heavy pages
Only call back a few callbacks per reactor iteration from the template fetch
request queue. This changes the expansion pattern from a (memory intensive)
breadth-first expansion to something quite close to depth-first expansion.
Additionally, retrieved pages are quickly added to the page cache so that a
lot of request queuing is avoided in favor of synchronous expansion from the
cache. On pages like Barack Obama that previously ran out of memory after
consuming node's 1.6G heap limit, expansion now runs in relatively constant
100-300M resident (so far, still running).

Change-Id: Ie34a1eeff00d868416de45ef8d289898258f560c
2012-04-13 14:31:03 +02:00
Gabriel Wicke df050e4481 Convert external link syntax stops to stack
Eat unbalanced external link parts within template parameters. This does not
produce the same output as the PHP parser
(try echo '{{YouTube}}' | node parse.js), but preserves a level of sanity.
Need to check how common this is for external links. If it is rare enough,
moving the ']' after the parser function manually would fix the rendering for
the YouTube case.

Change-Id: I597d808efff36baa22191e7946a0061cc31120e8
2012-04-13 11:08:42 +02:00
Rob Moen d37a325f44 Cleanup terms used in annotation method
Change-Id: I509a1f1b680cc8a2973188f0ed7c7d67b8a15f4f
2012-04-12 16:37:23 -07:00
Rob Moen 1fa462ce92 Fix up FormatDropdownTool
Effectively stopping & starting polling prior to conversion
Getting Selection from model
Reselecting after conversion (TODO: modify selection to entire block ?)

Change-Id: I9ba331b5393bf568cc8d137646b43244ae2640a8
2012-04-12 16:21:10 -07:00
Rob Moen 961f83d326 Elminiated isSelection method
Determine actual selection from model by checking length

Change-Id: I1c58a4de31b26d49b55c7a2c55c9c6462741bdfb
2012-04-12 14:05:14 -07:00
Trevor Parscal 51b479f04f Improved the appearance of the warning at the top of the editor
Change-Id: I38e2295f38ab8be101dba2dca251ed27ae65e5c2
2012-04-12 13:40:01 -07:00
Robmoen 3e6e736cc0 Merge "Removed unused fake cursor div" 2012-04-12 18:53:17 +00:00
Rob Moen 28e86c8688 New Method isSelection() in Surface View
Used to properly hide/show Context menu and UI elements.

Change-Id: I8b3750c270651498b7e6c54a1921f5012cf33ea6
2012-04-12 10:22:42 -07:00
Gabriel Wicke 5bb2d96869 Token stream transform improvements
* add past paths for empty arguments etc
* cache attribute token transform pipelines
* fix bugs in TokenCollector and NoIncludeOnly handler, and improve its
  efficiency by only registering for 'end' tokens on demand
* Remove empty reset methods from a few handlers
* Add a simple 'ap' debug print function that makes it easy to only print some
  debug prints by temporarily changing 'dp' to 'ap'
* Improvements and bug fixes in AttributeExpander

Change-Id: Ie69729c8f62d48bba922712e44ebce484c621c50
2012-04-12 15:42:09 +02:00
Gabriel Wicke 3124deca2c Track inclusion status on CachedTokenPipeline
Non-include attribute pipelines are not cached for now. Adding separate
caching for non-include attribute pipelines is very likely worth it, but
deferred for now.

Change-Id: I13f949d9f0a04536f9ccfcb73a2be69c5c08be01
2012-04-12 10:21:50 +02:00
Erik Moeller 9f5a45f138 Add simple warning to indicate that VE is still in early dev.
Change-Id: Iea2abf9660556eca1d981fbbaab30d75a813e92d
2012-04-11 18:32:45 -07:00
Trevor Parscal f6a8619b95 Removed unused fake cursor div
This was an artifact from experimentation with multiple cursors long long ago in a land far far away

Change-Id: I14491c4adbd40bb8df4b1c31725cb1621351bef2
2012-04-11 14:56:15 -07:00
Rob Moen b5befb1d57 On annotate, get current selection from model
Fixes link annotation, and any annotation that pops up an inspector as selection is lost.

Change-Id: Idd8812b05f4fddfa4e613dea28a1a8421792656d
2012-04-11 14:15:52 -07:00
Gabriel Wicke 23331abf21 Merge "Set inclusion flag for attribute transform managers too" 2012-04-11 20:47:01 +00:00
Rob Moen 224cc1f9a0 Migrate tools from SurfaceObserver Class
ContextView positioning, Italic, and Bold annotations working

Change-Id: Ifc68bd61c8f27b6a14d314dc2999753af6e0ee04
2012-04-11 13:19:58 -07:00
Gabriel Wicke efa41370d3 Set inclusion flag for attribute transform managers too
Change-Id: Ice15d8fde6de4a3e850a028db9917e976218fc43
2012-04-11 21:55:52 +02:00
Gabriel Wicke bff43938f6 Support noinclude/includeonly/onlyinclude in attributes
Fun test case:
{|
|-<includeonly>
foo
</includeonly>
|Hello
|}

Change-Id: I353bb287d3967ade549fbcb4ae64511a1f1f7e36
2012-04-11 17:37:25 +02:00
Gabriel Wicke 9ae572cca0 Fixes to template expansion / token transform managers, 296 tests passing.
* Convert isNoInclude logic to positive isInclude throughout and set it
  properly on attribute pipelines. Also don't cache non-include pipelines.
* Add a --pagename parameter to parse.js, which sets the page name in the
  environment. This is then returned by {{PAGENAME}}. Not the final solution,
  but useful for taxobox testing as taxons are selected based on PAGENAME.
* Add rudimentary pagenamebase parser function

Change-Id: If9c0be4c255200d0f2a30f02e5619437b4fd8f12
2012-04-11 16:34:27 +02:00
Gabriel Wicke bbae66cd69 Nominate more HTML5 sectioning and heading elements for block-level treatment
Block-level (in HTML4 lingo) elements are not wrapped into paragraphs.

Change-Id: I4a01c9721be30b526172952915d528dea79e2f30
2012-04-11 12:53:49 +02:00
Gabriel Wicke 5a33099875 Improve template tokenization in template arguments
Taxobox tables now render pretty much correctly.

Change-Id: I5a0564138ff0c688d8a5a69b7867646fd3763946
2012-04-10 16:40:49 +02:00
Gabriel Wicke 577ef1f916 Add some support for alignment of thumbs
Change-Id: I70570f48423628f7a87a35647698a66a5f413088
2012-04-10 12:11:59 +02:00
Trevor Parscal cf59563f50 Removed line-height from preview panel
This is not needed because the line height is no longer being forced in the editable view

Change-Id: Ic759e6e15dd6f2462cb6dbc26ba0f245821e1c15
2012-04-09 14:42:08 -07:00
Gabriel Wicke 403be4af42 Add basic thumb rendering support
* DOM based on Wikia's thumb output: HTML5, clean caption without magnify
  icon.
* basic RDFa annotations, but most options additionally in data-mw object-
  might want to move more (or all?) of those into RDFa data using meta tags.
* no support yet for framed or other formats, image scaling etc
* also tweaked some config options in the environment

Change-Id: Ie461fcdce060cfc2dec65cc057709ae650ef3368
2012-04-09 23:04:26 +02:00
Gabriel Wicke f99cb06e10 Merge "Improve parameter tokenization support especially for table rows" 2012-04-09 21:04:08 +00:00
Rob Moen 01e02e888d Fix copy / paste errors for setStyle method in ListNode and ListeItemNode
Change-Id: Ifc8183e047398fd7f4b0436e61768992a3a94612
2012-04-06 11:37:53 -07:00
Robmoen 8a06ea5adc Merge "Changed to using structured lists" 2012-04-06 18:28:04 +00:00
Inez Korczynski 50acc0c785 Make toolbar and context menu works
Change-Id: Ice981390b22a257158b3417dda3a1945d777cb14
2012-04-06 17:43:14 +02:00
Inez Korczynski 68cf13fb1e getLeafNode is now a static method and should be called as a static method
Change-Id: I4f079523add81ef14537c950b29436422e1de850
2012-04-06 17:13:43 +02:00
Inez Korczynski 5827843182 Merge changes from branch ce-poll
Change-Id: Id7602ed33a09720c53310a032d2824395b82ff7f
2012-04-06 17:11:35 +02:00
Inez Korczynski a57ae2692e Merge changes from branch ce-poll
Change-Id: Ibb6da1ac5229ed5afeda1a3944fe7deff3bfb9a7
2012-04-06 17:10:30 +02:00
Inez Korczynski 090e42c8d9 Just a test
Change-Id: I74fb371a26b4b6068fee593bf7e6ee950080bca8
2012-04-06 16:49:30 +02:00
Trevor Parscal 85b807ed5d Changed to using structured lists
This makes it possible to get identical rendering in the editor, but may make other things more complex. The Wikitext serializer is no longer compatible for rendering lists so it's been stubbed out. Also the way the toolbar works with lists is broken, so that's been disabled. The HTML serializer has been fixed to work correctly and no-longer-used styles have been removed.

Change-Id: If156f55068b1f6d229b3fa789164f28b2e3dfc76
2012-04-05 14:32:08 -07:00
Gabriel Wicke dbdd320348 Improve parameter tokenization support especially for table rows
Change-Id: I961d69e228b96adc69ea9acb3733d13f5898602d
2012-04-05 16:00:26 +02:00
Gabriel Wicke de4fb0c8c4 Merge "Remove behaviors var in tokenizer, now handled in token handler" 2012-04-05 13:57:13 +00:00
Christian e48aca43b9 Merge "Updated CSS classes and rules for CE, which for the most part uses native elements" 2012-04-04 21:08:47 +00:00
Gabriel Wicke 7a35e5db16 Remove behaviors var in tokenizer, now handled in token handler
Change-Id: I68eeff3f05ce29c13e347c2cd7ea6519e58b0e03
2012-04-04 21:17:29 +02:00
GWicke da60861be8 Merge ""magic words" are tokenized and used to set parser.environment flags" 2012-04-04 19:11:03 +00:00
Trevor Parscal a2eee63525 Updated CSS classes and rules for CE, which for the most part uses native elements
Also:
* Simplified ve.ce.Surface.getLeafNode, which may be better to just be removed and be used inline in the few places it's being used.
* Removed method wrapper for static function ve.ce.Surface.getLeafNode

Change-Id: I1d4cf0bb7ecc8f07f030753e40a13ebef7d02daa
2012-04-04 11:54:06 -07:00
Adam Wight a85ed36efa "magic words" are tokenized and used to set parser.environment flags
behavior switches are converted to tokens which set parser.environment flags during the async transformation stage.

The next step would be for handlers in the sync23 stage to generate the TOC, section edit links, and so on according to these directives.

No tests written, because the switches are consumed and don't appear in rendered html.  We can test the magic word layout controls individually, once they're implemented.

Another small change was to store option flags directly in the environment object, not that it makes much difference.

Change-Id: I863fbf4be1a17d2f6c31158298dd301f19ae1137
2012-04-04 11:25:29 -07:00
Adam Wight b234edba88 As much as I have loved writing Makefiles... I've replaced its functionality with package.json, mostly so we can avoid non-node dependencies. This is one of the recommended practices. We should consider moving tests/parser into modules/parser/tests, other node projects keep all module code in one directory.
Explained in the README how to use npm to load the dependencies and run tests.  Too bad about NODE_PATH...

Don't try to find parserTests.txt in assorted places--if it isn't present, fetch from gerrit.  You can symlink from core if you're developing on both parsers, and the fetch script will not overwrite.

Use __dirname in parserTests.js to allow the script to run independent of current working directory.

Change-Id: I4c8b884e91f4fdeae385c7697aff768bdd199dd5
2012-04-04 11:02:58 -07:00
Gabriel Wicke e3a745a024 Improvements for template / -argument precedence; support for empty params
Change-Id: Id0894ccbedfa47fa3658817ca65119a2af76be3e
2012-04-04 16:29:47 +02:00
Gabriel Wicke 2037215185 Disallow '[' in generic attribute names
This avoids interpreting something like

! [[foo|bar]]

as

<th [[foo=''>bar]]</th>.

Change-Id: If59708fa90eb0117a15b2b6446890d1ae19a857c
2012-04-04 14:31:11 +02:00
Gabriel Wicke f588d2a7aa Fix table headings in template parameters
Change-Id: Icdfc5655968fc845230ad7638124309d6b8c1ada
2012-04-04 12:54:34 +02:00
Gabriel Wicke b8d980a229 Don't eat newline / space in template parameters
..so that block_lines can match.

Change-Id: I4c464dc44249f40e4aa280df35fb726bfce3a745
2012-04-04 11:22:31 +02:00
Trevor Parscal 606d97da99 Merge "Add HTML DOM -> linear model converter" 2012-04-03 17:52:55 +00:00
Gabriel Wicke 47de122a95 Improve support for table / template interaction
Match pairs of {{!}} or | for template productions, but not a mix of the two.
Example:

{{#if:1|{{!}}-
{{!}} {{#if:1|style="color: red"{{!}}|}}
}}

Note that the style parameter ends up as the *key* of an empty-valued
attribute on the table cell currently.

Change-Id: I5f9357dd1645ef97b0af89f32e8d92ae49218c72
2012-04-03 18:48:35 +02:00
Gabriel Wicke 0fe062fbe1 JSHint cleanups and parser function argument handling improvements
Parser functions which only accept positional arguments now return both the
key and value of arguments. Complete attributes (key and value) for templates
and the like from parser functions are not yet supported though.

Change-Id: I3f81bb35acd27186222ce6d5217e820042527c01
2012-04-03 18:10:48 +02:00
Trevor Parscal 519d225d2f Cleanup of white space, missing semi-colons, line breaks, etc.
Change-Id: Ifa96a9f70fa8d149a4c403521aaa88a3e0546ef0
2012-04-02 15:28:26 -07:00
Rob Moen d8de26d7e9 On selection, update selection in the model. Fixes selection.clone() error.
Change-Id: Ibd5cf0398002e5fbb2c50549e4a7043ba8fd00a7
2012-04-02 14:19:53 -07:00
Rob Moen c1300ba949 Fixed surfaceView undefined error
Change-Id: Iba3ae54b4e508afbfa132e0f0b2b0b237e685395
2012-04-02 13:49:45 -07:00
GWicke b7db83e09a Merge "Magic links and behavior switch tokenization by Ori Livneh" 2012-04-02 16:43:13 +00:00
Gabriel Wicke f662690d02 Shorten data-mw-rt to data-mw and clean up whitelist
Instead of a proliferation of data-mw-* attributes, it should be easier to
stash all private / non-semantic round-trip information in a JSON object
stored in data-mw.

Change-Id: Id200a6a8789fa152f29ea530e5a24b6ee7b4b285
2012-04-02 18:12:49 +02:00
Gabriel Wicke 5248fd31e8 Magic links and behavior switch tokenization by Ori Livneh
Commit first patch by Ori, lets 288 parser tests pass. Yay!

Change-Id: Iac8c3d1ad1984900350b20f7e725c40618a1e8ba
2012-04-02 17:31:34 +02:00
Trevor Parscal 19f3d5c107 Added ve.Surface, a wrapper around an editor instance
* This high level surface object is responsible for creating & managing editor instances
* Revised Sandbox demo to invoke in this way.

Change-Id: I4043779af9a2ab964deaf26079a992e82ebeef27
2012-03-29 15:55:33 -07:00
Trevor Parscal c44ef066b9 Replaced es with ce for Sandbox and main demo
* Configured VisualEditorSandbox to use es
* Reconfigured the ce demo to share the sandbox module
* Removed es demo
* Renamed ce demo to ve (es is broken anyways)

Patchset 2: squashed in https://gerrit.wikimedia.org/r/3953

Change-Id: If8d13bf7011616d222be78899b23186859d5ed70
2012-03-29 15:43:59 -07:00
Catrope 8dc994f037 Add HTML DOM -> linear model converter
Also, in ParserPipeline:
* Import the LM converter and expose it through getLinearModel()
* Fix getWikiDom() to actually work (still unused)

In parse.js:
* Add --help option that prints usage information (was unreachable)
* Add --linearmodel option to output linear model JSON instead of HTML

Change-Id: Ic534e03ff40a7c9117bb63f0c635a4213d5e3406
2012-03-29 12:47:14 -07:00
Catrope 7a726b0278 Add tree synchronization for replace
To handle replace operations that are not themselves consistent (these
are common, for instance when replacing an opening element in one place,
then replacing the closing element somewhere else), we process
subsequent replace operations inside the first one until things are
balanced again, then issue a single rebuild for the whole thing.

Change-Id: Ide4613f046fabfeeef383138c39e350b1b710033
2012-03-26 02:51:30 -07:00
Catrope 826437950c adding clearState function for tools and using clearState if no selection exists
Originally committed in SVN as r114418 by Christian, missed the git
conversion

Change-Id: I56e91c170670519fa2b482a4b7f30cdcbc8ff163
2012-03-22 14:22:15 -07:00
Roan Kattouw 3b193a1e57 Fully revert r114142, was previously reverted in Collection only 2012-03-21 20:45:24 +00:00
Sam Reed 1bab092ead Fix many more occured typos 2012-03-19 14:54:43 +00:00
Rob Moen e5df79229d make clear button tool work with annotate method in ce surface 2012-03-16 22:20:16 +00:00
Inez Korczynski 299c77db84 Make LinkInspector works (using annotate method in SurfaceView) 2012-03-16 22:16:15 +00:00
Inez Korczynski b2f4b48a9a Use on and off insteaf of bind and unbind. 2012-03-16 22:01:09 +00:00
Rob Moen 277e239796 CE surface has no hidden input, removed input focus 2012-03-16 22:00:42 +00:00
Inez Korczynski 6ef8ac182a No more endless looping! And fix getSelectionRect to return document relative coordiantes instead of viewport relative. 2012-03-16 21:52:17 +00:00
Rob Moen cde7a3bf7e adapt LinkInspector to use surfaceObserver for selection 2012-03-16 20:18:26 +00:00
Rob Moen 93376d68eb add surfaceObserver on select methods to ui toolbar and surfaceView for responding to select event. tools now updating to selected node annotations. revise getSelectionRect to return actual start & end pos. context icon properly showing on range selection 2012-03-15 22:06:40 +00:00
Gabriel Wicke 5ef2074251 Enable support for block-level wiki constructs in template arguments. This
gets a bit closer to supporting table fragments passed through template
arguments. Next, we'll need a way to indicate start-of-line position to
enable sol block-levels in template parameters. 

Example:

{|
{{#if: true|{{!}}Table cell|}}
|}
2012-03-15 11:43:49 +00:00
Roan Kattouw 05333b1f3d Put the invert state / method (commit or rollback) in the TransactionProcessor object and no longer pass it as a parameter to each operation. This makes it easier for operations to execute other operations. 2012-03-14 21:02:36 +00:00
Roan Kattouw bf5ea06db5 Factor out process() into nextOperation() and executeOperation() 2012-03-14 21:02:34 +00:00
Roan Kattouw 2c43a34f74 Rewrite the rebuild action to take two ranges rather than a node and some data. 2012-03-14 21:02:31 +00:00
Roan Kattouw 37a59016e8 Break out pushAction() into separate functions for each action. This will allow me to change the rebuild action to take totally different parameters. 2012-03-14 21:02:29 +00:00
Roan Kattouw bd9a86dd55 Remove the offset adjustment feature from DocumentSynchronizer. It gets in the way when I try to use this class in TransactionProcessor. 2012-03-14 21:02:27 +00:00
Roan Kattouw 1e17285afb Move computation of missing offset from pushAction() to synchronize(), and only compute offsets for actions that require them. This also fixes an issue where offsets computed by pushAction() would be adjusted incorrectly by pushAction(). 2012-03-14 21:02:26 +00:00
Roan Kattouw 7dd2b8b725 Make DocumentSynchronizer clear the queue after it's done with it 2012-03-14 21:02:24 +00:00
Gabriel Wicke 7e22020398 Convert syntactical break flags for templates from counters to the stack
variant to fix the precedence for {{!}} (break on these inside table content,
but not in template options within tables).
2012-03-14 16:30:59 +00:00
Gabriel Wicke 77a61dd687 Improve support for {{!}}, and don't produce a pre for indented tables. 2012-03-14 10:58:11 +00:00
Gabriel Wicke 835914b2de Support {{=}}. 2012-03-14 09:07:01 +00:00
Inez Korczynski f87709d6bb Use <h[1-6]> tags for rendering headings (instead of divs) 2012-03-14 00:51:04 +00:00
Rob Moen d77c0b91dc fix dropdown tool to use selection from ce surfaceView 2012-03-14 00:29:41 +00:00
Inez Korczynski 294d474c54 Replace CursorObserver and ContentObserver with SurfaceObserver 2012-03-14 00:04:24 +00:00