Commit graph

1643 commits

Author SHA1 Message Date
Rob Moen 932324c016 Fix clear button tool. Getting / clearing all annotations
Change-Id: I2fc2da20da149cd5fdf3f2cd33aeed2e033fd979
2012-06-14 15:04:40 -07:00
Inez Korczynski 7ab079bc52 Add ve.log, ve.debug and change rendering animation debug effect used in TextNode. 2012-06-14 15:00:29 -07:00
Inez Korczynski ee475cc54a Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-14 14:33:38 -07:00
Inez Korczynski 260d3c0413 Fix bug with losing selection direction. 2012-06-14 14:33:33 -07:00
Trevor Parscal 656439240d Added support for clicking section edit links
Also now hiding the TOC with animation

Change-Id: Ia355d4104e0bfc276fe0c08d6faa2719e3556c06
2012-06-14 14:31:23 -07:00
Rob Moen 1e45a06185 Debounced contextView icon on selection in surfaceView.
Squashed old list button methods, list & unlist.

Change-Id: Ic522c761636b2126990ee194b7a441e8bf0396aa
2012-06-14 14:27:01 -07:00
Subramanya Sastry 8978e406fc Minor code refactoring
Change-Id: Ib7f70a3ac42e3d5a5985e9a9bcffa313bdac289b
2012-06-14 15:18:53 -05:00
Subramanya Sastry d7e83c4e2b Fixed/updated newline handling for <p> tags
- More pieces are now simplified and all(?) newline handling
  is now centralized in the serializeToken function.

- This commit fixes bugs in rt-ing some code snippets
    ----------
    Ex 1: foo<p>bar</p>baz
    ----------

- This commit fixes bugs serializing VE generated html
    ----------
    Ex 2: <p>foo</p><pre>bar</pre> ==> foo\n bar
    ----------

- But, this round of fixes introduces RT failures for certain
  code examples in parserTests.txt.  In all these failing cases,
  inline text/html is embedded within a generated <p> tag during
  parsing.  If these generated <p> tags can have a "gc:1" attribute
  added to them, we can properly serialize them to the original
  form.
    ----------
    Ex 3: foo<pre>bar</pre>
          Parsed HTML: <p>foo</p><pre>bar</pre>
    ----------
  Note how this parsed HTML is identical to what the VE outputs
  in Example 2 above.  So, without the gc:1 attribute, we now
  have conflicting requirements on the example same HTML.
  This increases confidence in the correctness of my commit here.

Change-Id: I86beadec91c445a7f8a6d36a639b406697daa0a2
2012-06-14 14:59:18 -05:00
Catrope bb5c82745e Handle aliens correctly in the converter
Previously, data-mw-gc (generated content) elements were unconditionally
converted to alienInline nodes, and unrecognized elements were
unconditionally converted to alienBlock nodes. This is wrong and
produced weird results when I started experimenting with <code> tags.

Instead, I made both gc and unknown element trigger alienation, but the
decision of whether we generate an alienInline or an alienBlock node is
separate and is based only on whether we're inside a content node.

Change-Id: I12335337c3fa60c725ae7bcfbfb52a1dda153fb5
2012-06-14 12:24:14 -07:00
Christian Williams 86d891605d Most of backspace and delete support, methods for starting and stopping polling.
Change-Id: Ic387d9eed3a1368dd70c7a86c7b9761400c76f93
2012-06-14 12:17:42 -07:00
Subramanya Sastry 13e03ec1d7 Refix <pre> serialization.
- Effectively reverted fix from f882a65153
  and added a new fix.

Change-Id: I8b81e26525a5f1a22acaf2c7067f2dcd9b962818
2012-06-14 13:10:02 -05:00
Inez Korczynski 9d487c1824 Special handling in pollChanges loop for case when node is null. 2012-06-13 22:23:59 -07:00
Inez Korczynski 3667c2cf83 Block triple click (select node) - temporary - as long as we don't have robust support for it. 2012-06-13 22:19:10 -07:00
Subramanya Sastry 51227f2a4a Improved, simplified newline handling in wikitext serializer.
- Eliminated newline handling from several places in code and
  mostly isolated it to serializeToken thus simplifying newline
  handling logic.
- Fixing some bugs in the process: # of green roundtrip tests
  went up by 5 (294 --> 299) but actually introduced failures on
  a few originally succeeding tests (additional leading/trailing
  newlines on the entire test output).
- Added bonus: made list serializing (mostly) insensitive to
  newlines between tags.  So, all the following DOM serialize
  identically to the following wikitext:

  *foo
  *bar

  ----------
  <ul><li>foo</li><li>bar</li></ul>

  ----------
  <ul>
  <li>foo</li>
  <li>bar</li>
  </ul>
  ----------
  <ul>

  <li>
  foo

  </li>

  <li>
  bar</li>

  </ul>
  ----------

Change-Id: I76be56c4b2789039dff5f47de4659746882e45d6
2012-06-14 00:10:51 -05:00
Inez Korczynski c3cf5617fd Use ve.ce.getDomText and ve.ce.getDomHash instead of ve.ce.Surface.getDOMText and ve.ce.Surface.getDOMHash. 2012-06-13 22:05:38 -07:00
Inez Korczynski ba680afcc3 Fix bugs in getDomText method. 2012-06-13 22:04:52 -07:00
Inez Korczynski f4a4952d18 OMG. We have typing, autocorrect and spellcheck working. (Still no IME and still may break cut/paste) 2012-06-13 21:46:29 -07:00
Inez Korczynski 94d29eaf49 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 21:17:13 -07:00
Catrope e6751e3f03 Set data.title based on sHref so LinkInspector can use it
Change-Id: I7589740ec5661afd7c8dd0f54e955d170e3096e6
2012-06-13 19:32:49 -07:00
Catrope f83cdc4eaa Hack around Parsoid bug in link handling
Parsoid ignores sHref when converting back to wikitext, so we have to
set the href attribute to "/$title"

Change-Id: I1068116c0be72197619d0df3b4d1231a3879fa14
2012-06-13 18:53:13 -07:00
Catrope 9c939047be Fix return value of ve.ui.LinkInspector.getSelectedLinkAnnotations()
Was returning a single annotation, but all callers were expecting an
object.

Change-Id: I55be083e5451f4ace5e54dfecb904ae53041054b
2012-06-13 18:49:38 -07:00
Catrope 9d9c06f4e2 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 18:31:05 -07:00
Catrope d0adb112c0 Needs copyArray instead of copyObject, d'oh
Change-Id: Ic185d328a87579262458fe24fd01539c495f09a2
2012-06-13 18:30:50 -07:00
Trevor Parscal 75ac5b03e6 Improved appearance of activating and deactivating editor
Also prevented double-initializing

Change-Id: I9e64eb1f331489f6acee469fdab64133d817e7b1
2012-06-13 18:26:21 -07:00
Inez Korczynski 092e84d31f Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 17:19:11 -07:00
Trevor Parscal 31a2a0243a Removed duplicate update event on length change and cleaned up some methods that were being called by symbolic operation name
Change-Id: Ica623d1c5619b8268eb97f631e09f9e2f5b67bf0
2012-06-13 17:16:04 -07:00
Trevor Parscal e266905b94 Moved history tracking into a startable/stoppable service
And made it not start on it's own, but be started by ve.Surface - this makes it so it's not polling in the unit tests, for instance

Change-Id: I940df04d392fd134d18847949efe0e2232328323
2012-06-13 17:16:04 -07:00
Catrope efa93c24be Copy objects in newFromWrap() to prevent reference pollution
Change-Id: Ia1f71341342bea44f6ca08088a1276d54187b22a
2012-06-13 16:56:51 -07:00
Inez Korczynski 29a8ac77c3 Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-13 16:23:35 -07:00
Inez Korczynski 81473a8119 Make method ve.dm.Document.addAnnotationsToData accept collection of annotations as a param - instead of an array 2012-06-13 16:23:19 -07:00
Catrope 7dd65cda91 Add newFromWrap(), ported 98% verbatim from the old code
Change-Id: I81fc74b1d23bc6b60e476bfefbae4d7d9a9bf5f6
2012-06-13 16:17:23 -07:00
Catrope 0bc1693998 Fix partial undo of ab0c37 in 2ea103
Change-Id: I42225802c45b3867a2aafd40e6941754b1b415b4
2012-06-13 16:16:07 -07:00
Trevor Parscal 429225fb57 Whitespace fixes (jshint was tweaking out)
Change-Id: Id75a097ae4958029caf0a0315343c2fab9c99b89
2012-06-13 16:06:21 -07:00
Trevor Parscal 56c0f597cd Fixed use of "pre", "preformatted" is the correct symbolic name
Change-Id: Ifc7e8e3291b8dd29a7fa4c42529bb4fd36a6ed9a
2012-06-13 15:15:05 -07:00
Trevor Parscal 8cb5cbf75d Merge branch 'refs/heads/master' into dmrewrite 2012-06-13 15:00:44 -07:00
Trevor Parscal 84ce839ce5 Removed context menus on tear down of surface
There needs to be a proper tear down system for ve at some point

Change-Id: I6454423ab96a15932695fbc5429d9e731acc9071
2012-06-13 15:00:13 -07:00
Trevor Parscal 1628038bdb Using wikiLink instead of internal to match actual documents
Change-Id: I24b9c0a5f27ed8f4a7861090ab4049c4614cea78
2012-06-13 14:48:29 -07:00
Trevor Parscal 95c601c8e9 Make save dialog initially hidden
Change-Id: I8fc4bd67f16266d9355fe639487728ad91ad6ede
2012-06-13 14:44:39 -07:00
Trevor Parscal 169b7e754d Cleaned up toolbar annotation updates
Change-Id: I8cefd6c871ed6d1ad71f64eb66236de1b8b719b5
2012-06-13 14:31:46 -07:00
Rob Moen 26e0f6ed5f Real cross browser fix for invisible iframe bug.
Change-Id: Ia2d3c83562542aaaddf0b81dfeaef9aa408aaed3
2012-06-13 13:29:18 -07:00
Subramanya Sastry bf0f5d1b7e Minor code cleanup
Change-Id: Ic5d99b6c483841310b0c295c1c30246f907455b4
2012-06-13 13:47:26 -05:00
Subramanya Sastry 23ec054013 Fixed round-tripping of interwiki links.
Change-Id: If0427b9865b3e9cf8c0ad0b4efaebc9f9f7fb865
2012-06-13 13:39:18 -05:00
Subramanya Sastry 445780b4d3 Revert default tokenization result from null to ''
* As part of an earlier fix, I had changed default value of 'res'
  to null instead of ''.  But, this was potentially buggy because
  the previous check was (res !== '') which could be triggered
  by return values of handlers.  By changing the check to null,
  I was effectively changing the code paths for those handlers that
  returned ''.

Change-Id: I2302023be7422ce4fb384ff5a50fe53fa7732855
2012-06-13 11:53:05 -05:00
Subramanya Sastry cfe94eed1f Minor code refactoring
Change-Id: Iec3cb4d83d16174371f0b1f3f23b1056aeed458e
2012-06-13 09:46:34 -05:00
Rob Moen a991cefbe7 Fix inspector close bug where iframe was blocking editor below
Fix Inspector bug which prevented applying a link annotation to data
already containing annotations.

Change-Id: I6f315d50805c8c71f2155f955ea5674a7ce98656
2012-06-12 13:52:42 -07:00
Rob Moen b843762d9e rewrite comment
Change-Id: Ibc8aab4843ecc0211149aa673d312384e9bd668e
2012-06-12 13:29:13 -07:00
Rob Moen 75e9b2cb2d On transact, redraw selection
Change-Id: Ia2f82dd1516113a3c6e77377fec19047fcbd32d0
2012-06-12 13:27:23 -07:00
Catrope c9605066cd Merge remote-tracking branch 'origin/master' into dmrewrite 2012-06-12 11:57:32 -07:00
Subramanya Sastry f882a65153 Fix serialization of <pre> tags
Change-Id: I7ae95e7ec06167d0c1bfdaba3d0c67d941043299
2012-06-12 13:54:35 -05:00
Rob Moen bf5b682809 Fix clearButtonTool
Change-Id: I92e55efb9c82f4d2ef55a71bea318cdc7495c2ea
2012-06-12 11:43:56 -07:00
Rob Moen bf08347922 Fix js error
Change-Id: I3424f205649345a97a7f4d28c4c040c3c3bb6aa7
2012-06-12 11:17:46 -07:00
Rob Moen 2ea1030ab4 Rewrite document annotation getters to return collection objects
vs arrays

Change-Id: Ib48a39fff501cdb769f5b9b9fc7717805b74236e
2012-06-12 11:10:29 -07:00
Rob Moen da3e366758 Updating tools on transactions. Working towards finishing clear
button

Change-Id: I7b6f8cae04fc181b7c8c61d4977e42480e608829
2012-06-12 10:44:58 -07:00
Trevor Parscal 722c30466d Got rid of wrapping whitespace (like \n and \t) in a span that made text white
This was causing some issues when you started typing there, and it's not clear that the white text is really the best way to go anyways

Change-Id: I8a9d6571ea204603729e96b7ff77184279a31a95
2012-06-12 10:40:44 -07:00
Trevor Parscal 9b9dcca6e2 Made save page button only work when an edit is made
Also added confirmation dialog for abandoning unsaved changes

Change-Id: I3388a8f7def9bee5eda32b97ef78e9565a7e33ea
2012-06-12 10:32:19 -07:00
Trevor Parscal cd3cf1d856 Changed use of getSurfaceModel to getModel and surfaceModel to model
Also cleaned up other stuff that was a little wonky

Change-Id: I6769b0cb53adb9fd4a9411937084efb03a6e3029
2012-06-12 10:32:18 -07:00
Christian Williams 05ee4e7dac Binding to 'before paste' for IE only
Change-Id: I3e3125d2faf75ea79e7f4c4d86fa1ccd666074b6
2012-06-12 10:23:58 -07:00
Christian Williams 1e4c52237c Enter key handling
Change-Id: I1b5f901a542328c3ae7c19a5cd816112dcac4042
2012-06-11 19:40:09 -07:00
Trevor Parscal 77853609ed Merge branch 'refs/heads/master' into dmrewrite
Conflicts:
	.gitignore

Change-Id: I73ff881ef3beef702748a2bfffee9e1661004f86
2012-06-11 18:36:46 -07:00
Trevor Parscal 70234d2507 Fixed missing arg, kept stuff from saving
Change-Id: I6c02b2a009f03b2d9e293591166819743fe7ee24
2012-06-11 18:35:24 -07:00
Trevor Parscal 4cc88b9850 Fixed some minor-ish UI stuff
Change-Id: Ibc3fa2fb7ce9193703263ab708ce18f6aefe5b09
2012-06-11 18:21:41 -07:00
Trevor Parscal f0ef6bda70 Fixed drop-down arrow placement
Change-Id: Ia9ce735a7938c2db0bad28b44384cf7d206a2023
2012-06-11 18:21:40 -07:00
Catrope 92d715df92 Fix some comment typos
Change-Id: I58e21bb4cb75580369b89a10cf324c100ed15724
2012-06-11 18:19:12 -07:00
Catrope 44af6bdb18 Factor out redundant getNodeFromOffset() call
Change-Id: Ie01282447fab589466554f7c637515289cf570af
2012-06-11 18:10:09 -07:00
Catrope ab0c37def9 Rip out the offset map
The offset map was broken from the start because it wasn't updated when
adjusting the length of a text node, and if we fix that bug it's
doubtful whether the costs of updating the offset map outweigh the
benefits, especially considering that adjusting the length of a text
node is something we do for almost every keypress. If it turns out
having an offset map does make sense, we can always reintroduce it
later.

Change-Id: I59e8bc154f7d07aa1bab2f473c13ff466d0e463f
2012-06-11 18:10:08 -07:00
Catrope 407ea15373 Make the LinkAnnotation code a bit more robust
Change-Id: I42603788cf112541df67811858bd8854dd224b24
2012-06-11 18:10:06 -07:00
Catrope 48abc8e30a Terrible hacks to work around Parsoid bugs
This makes my test document round-trip cleanly though, yay!
2012-06-11 17:32:58 -07:00
Rob Moen dcf104428f Clear button tool now properly clearning selection annotations.
Create method to return matched annotations button tool pattern.

Change-Id: I5ba2369f1ec81a74570bcfeb1ee86bb7ef07e691
2012-06-11 16:29:09 -07:00
Rob Moen 810ba6df89 Modify FormatDropDownTool to use new transaction builder
newFromContentBranchConversion

Change-Id: Ifcec60ed57c7c92a5c08219d5f046e904300d5c2
2012-06-11 16:20:14 -07:00
Trevor Parscal 59f9bdf22f Made use of ve.proxy instead of surface having it's own implementation
Other cleanup as well

Change-Id: I5de5c048e341dd3dc3ef222ae5686c49e51a32a5
2012-06-11 16:11:49 -07:00
Trevor Parscal 7d7fd74d29 Renamed EditPageTarget to ViewPageTarget (since it's targeting view pages, not edit pages, duh...)
Change-Id: I810de87940e0d061c59d32de6654f1f2431f8d82
2012-06-11 16:06:35 -07:00
Trevor Parscal c8c4ed8f99 Added ve.dm.Transaction.newFromContentBranchConversion
Change-Id: I0e272b24dddae028e44d4c693297b1875000ef57
2012-06-11 15:58:44 -07:00
Trevor Parscal 2c393d4cad Added normalization to ranges given to selectNodes
Change-Id: I11b7d9b4f8359ab60c1a2f0443dea209a3735711
2012-06-11 15:58:44 -07:00
Trevor Parscal 9891adf116 Added getRange and getOuterRange to ve.dm.Node
Change-Id: If1b226d7944335e9b78d59433e322faf5d48382e
2012-06-11 15:58:44 -07:00
Subramanya Sastry 727c2119bb Refactored serializeToken method and added special-case handling of
paragraphs in lists.

* We need to look at other special-case handling requirements of
  html tags in lists (and other contexts like tables).

Change-Id: I84b8402d90a186c9075c2d45263c94377312927a
2012-06-11 17:55:41 -05:00
Inez Korczynski a609afe52f Port static method addAnnotationsToData from ve to ve2 2012-06-11 15:31:55 -07:00
Catrope dcdc1737ca Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite 2012-06-11 14:53:28 -07:00
Rob Moen 542131e080 Properly clearing link annotations now
Change-Id: I2342ad496566e6d7f6e39a30f70af1f886398069
2012-06-11 14:50:52 -07:00
Catrope b26649a2e8 Guard against passing undefined into ve.compareObjects(), was causing errors 2012-06-11 14:48:46 -07:00
Trevor Parscal 82c409ca18 Changed loading graphic, added focus on load
Change-Id: I2d91c25edc7b759f07fe1581953fa0e5baecb51c
2012-06-11 13:24:35 -07:00
Rob Moen 29c76e6dd4 Fix link annotation from inspector by changing link type to wikiLink
Change-Id: I5b3497755c6a13e2767f59cc5c95b3e4b43b3be7
2012-06-11 12:56:18 -07:00
Trevor Parscal a0d5cbd42a Animated the margin of the first heading and fixed animation of save dialog
Change-Id: If4a37aa9e35d9d507577643e4bd40ea4fa3dfad8
2012-06-11 12:28:31 -07:00
Trevor Parscal 17fff0d163 Fixed dependency on mw, now demo works again
Change-Id: I26599e065a521cf08a16f5a65e36960a692421e9
2012-06-11 12:11:07 -07:00
Trevor Parscal 21ff108c28 Bring link converter in line with Parsoid
Parsoid outputs rel="mw:wikiLink" or rel="mw:extLink", so we convert that to link/wikiLink and wiki/extLink respectively.

Also preserve the data-mw attribute; we probably need to do this more generally but this'll do for now.

Change-Id: I32e570bffa5a73a733a120d52cfd8b75d3191e02
2012-06-11 00:36:20 -07:00
Trevor Parscal c40dd953ca Remove stray debugger statement
Change-Id: Ie7c37e658d6d6bc15d5d7c24b2f5cd13945c5243
2012-06-11 00:33:13 -07:00
Trevor Parscal ce8efd6b15 Refactored veCore class into ve.init and ve.init.EditPageTarget
Change-Id: I52ef09aee38471ca49f3f4a845daf02e6dcc024c
2012-06-10 23:54:41 -07:00
Rob Moen 38e64418b5 Move inspectors into iframe loaded in contextView.
TODO- needs cleanup

Change-Id: I62d86260b48ef570ce18833dee3390ec9fff47e1
2012-06-08 17:17:11 -07:00
Trevor Parscal 2e1b304a48 Cleaned up styles for editor in both demo and sandbox/integration
Change-Id: I9b4a3727fd04b3c3ff3f297c6656db2592856173
2012-06-08 16:20:37 -07:00
Christian Williams 80194260f3 Undo and Redo
Change-Id: I2d7c1bfd164a42e5d52001054e52e47ca245ad18
2012-06-08 16:21:47 -07:00
Trevor Parscal a2231cb6ca jQuery expects a string for the data, not a DOM element
Change-Id: I16b6f00952a2d9e38d631409b9bf3dd7ada644e7
2012-06-08 16:00:30 -07:00
Trevor Parscal 89b2260bfc Revert "Support for basic text insertion - typing"
This reverts commit 21056ff5ec.

Change-Id: I86bb28d868b2c931f4b6e18ba5023a8a75b40231
2012-06-08 15:54:05 -07:00
Inez Korczynski 21056ff5ec Support for basic text insertion - typing 2012-06-08 15:31:29 -07:00
Trevor Parscal 3cef118240 Added real round-tripping, instead of canned HTML
Change-Id: I73cef900e0777352e34818396c1e5d6f218da967
2012-06-08 15:17:36 -07:00
Trevor Parscal d61045085a Fixed link conversions to match parser
Change-Id: I67838a8c05729e4d32e6e2dfca53c7d457143ce3
2012-06-08 15:17:18 -07:00
Trevor Parscal 20d1c290d4 Fixed multi-auto-wrapping issue and added tests to track regressions
Roan mostly wrote this

Change-Id: Id292c84a4da97d6608aa7c17ab6a4cf5a2e3f409
2012-06-08 15:16:55 -07:00
Trevor Parscal 402d6dc53a Added rendering for link/unknown
Change-Id: I47cdc8679c533f15059b290bf30ae74518dce724
2012-06-08 15:15:43 -07:00
Trevor Parscal 5969f55550 Delete HTMLConverter and update demo&sandbox
Also update the demo and sandbox for ve.{dm,ce}.TableSectionNode

Change-Id: I5a73a8250d283e8666b93561ce9e9374739936a5
2012-06-08 12:40:43 -07:00
Trevor Parscal faa58d1e4a Merge branch 'refs/heads/master' into dmrewrite 2012-06-08 12:29:57 -07:00
Trevor Parscal 2e0d4ef094 Make tableCell represent both <td> and <th>
Adding a 'style' attribute which is set to either 'data' or 'header'

This breaks even more tests because of missing style attributes

Change-Id: I0a75d8c1578b4414eeae8c484f6c4d6f8a59472a
2012-06-08 12:27:22 -07:00
Trevor Parscal c614d3391b Add ve.dm.TableSectionNode and ve.ce.TableSectionNode
Yes, this breaks a bunch of tests, because tableRows are now required to be inside tableSections

Change-Id: Idb52d988df69173647c85f7602344650456e078e
2012-06-08 12:26:45 -07:00
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