Commit graph

2446 commits

Author SHA1 Message Date
Trevor Parscal 6bfb42639f Focus on document when notices are clicked
Change-Id: I55e4eb74e12ded79d998d155d4688ce6a1b6ce66
2012-12-07 16:42:47 -08:00
jenkins-bot 41f7b97ca4 Merge changes I75bcf984,If7bae5e2
* changes:
  (bug 37875) Scroll changes on paste
  Pasting a DocumentSlice sets the selection incorrectly
2012-12-07 23:31:30 +00:00
Rob Moen 3ef8a62aa7 (bug 42839) Whitespace links
* Collapse the new range returned by trimRange if it only contains whitespace

Change-Id: Id8461d435b22b745371a3a33caa3ea5b016c5b90
2012-12-07 15:04:49 -08:00
Trevor Parscal cdec86fb48 (bug 37875) Scroll changes on paste
This solves 2 issues:

1. Paste scrolls to the top of the editable box because we temporarily moved the focus to the paste container, and then moved it back. We solve this by saving/restoring the scroll position.
2. Scroll position adjusts vertically when pasting (using key repeat) because we handle pastes with a setTimeout and multiple paste jobs will pile up before they can be finished. We solve this by disallowing paste until we are done handling the previous one. In the case of key repeat this only is observable as slowing the repeat rate.

Thank you Christian for helping me solve this the old fashioned way - by sacrificing features you don't really need!

Change-Id: I75bcf9843b57cdff0db9b6dea62d66d4d76ac011
2012-12-07 14:58:29 -08:00
Trevor Parscal cf3b2a6765 Pasting a DocumentSlice sets the selection incorrectly
ve.dm.Document
* 2 of the 3 paths of getSlice still returned arrays instead of ve.dm.DocumentSlice objects

ve.ce.Surface
* Translate the range using the insertion transaction and truncate it, so the cursor ends up just after the pasted content

Change-Id: If7bae5e254ec84a847c1d3527f74d9c09c2d82b4
2012-12-07 14:49:11 -08:00
jenkins-bot 8a29eab7c6 Merge "Static composition of 'can' and 'not', may improve performance slightly" 2012-12-07 21:40:50 +00:00
Trevor Parscal 2473a5e7ca Static composition of 'can' and 'not', may improve performance slightly
Or at least irritate Roan less…

Change-Id: I9ea503725133ed0971f3876f199e0858c35c5aa1
2012-12-07 13:38:00 -08:00
jenkins-bot aae99aad13 Merge "(bug 42806) Copy/paste errors on unbalanced data" 2012-12-07 21:37:31 +00:00
Trevor Parscal 3002bbb591 (bug 42806) Copy/paste errors on unbalanced data
ve.ce.Surface
* Switched to using getSlice instead of getData in copy and paste handlers
* Added try/catch which attempts to build a transaction with the unbalanced data first, but falls back on the balanced data otherwise

ve.dm.*Node
* Added default style attributes (now used by ve.dm.NodeFactory)

ve.dm.Document
* Fixed bugs in fixupInsertions where parentType was being set with an object rather than a string
* Made use of getDataElement
* Added adoption capability so that inserting a</h1><p>b into <p>c[cursor]d</p> results in <p>ca</p><p>bd</p> rather than throwing an exception
* Renamed getBalancedData to getSlice, now retuning a ve.dm.DocumentSlice object

ve.dm.DocumentSlice
* Introduced new container for balanced data and a range of the original context - useful for copy/paste

ve.dm.NodeFactory
* Added getDataElement method, which uses default attributes to create a boilerplate version of a data element

ve.dm.Document.test
* Updated getBalancedData test to be a getSlice test

demos/ve/index, VisualEditor, test/index
* Added references to ve.dm.DocumentSlice

Change-Id: Id9269a29e51ca213508de8f155d3feec5e5b0774
2012-12-07 13:34:28 -08:00
jenkins-bot 619043f8d1 Merge "(bug 42836) Formatting drop-down updates" 2012-12-07 21:25:37 +00:00
Trevor Parscal 7450fa9114 (bug 42836) Formatting drop-down updates
The fix for bug 40339 supposedly modified when we emit contextChange events so that when the node changed, even if the context was the same, we consider it a context change (such as changing the heading level).

Unfortunately I was mentally absent when I wrote the patch and all it actually does it emit more select events.

Basically cb4877b0d0 - which does indeed fix the bug - doesn't do what it's commit message describes, but this fixes it.

Change-Id: I99d74f9ab0ddec15df41320389fe83de9b8b8d1e
2012-12-07 13:17:31 -08:00
jenkins-bot 487beeb452 Merge "(bug 42298) Handle URL encoding in MWInternalLinkAnnotation" 2012-12-07 21:10:45 +00:00
Trevor Parscal 42de94fc44 (bug 42298) Handle URL encoding in MWInternalLinkAnnotation
* Decode titles we get from Parsoid
* Encode titles we give to Parsoid
* Preserve the original encoded title if nothing meaningful changed (a.k.a. do not normalize unless we must)

Change-Id: If5d22e88904d6b2c438caac403ac2d78d440b017
2012-12-07 12:34:17 -08:00
Timo Tijhof a016dc2fe3 Fix CSS syntax errors from If1e08bbf.
Change-Id: I38f33a065afbe37f931934017c11d5ceedb34176
2012-12-07 17:23:51 +01:00
Inez Korczyński 6abd1c950c (bug 42801) Fixed by re-adding calls to disableRendering() (used to be lock()) and enableRendering() (used to be unlock()) - deleted accidentally in commit: 9c74c97808
Change-Id: Ia91a572c94cc3e9a81148b1484fc567941fa7c3e
2012-12-06 17:43:38 -08:00
jenkins-bot 0cf34e02a4 Merge "Fixing paste from external sources" 2012-12-07 00:09:31 +00:00
jenkins-bot aac3954384 Merge "(bug 42136) Use user prefs to set initial state of "Watch this"." 2012-12-06 23:05:00 +00:00
Timo Tijhof a600310e4d (bug 42136) Use user prefs to set initial state of "Watch this".
* Don't show at all if user isn't logged in
* Use "watch pages I create" and "watch pages I create" prefs
* If the user is already watching it, use that

Also updated relevant onMakeGlobalVariablesScript hook,
it was using old globals still, the hook has context as
of MediaWiki 1.19.

Change-Id: Ic3daf32505a745b3cccd0663a03bbf7f3885be84
2012-12-06 15:04:13 -08:00
Christian Williams 29c077ace4 Fixing paste from external sources
Since model.change now starts the surfaceObserver, a problem manifested where the surfaceObserver was observing the $('#paste') element (used for capturing and sanitizing pasted content from external sources). Simply switching the order of the transaction and the documentNode focus fixed the problem.

Change-Id: I1b542b546d7f3d97e2e954ca4b51ca74232b2877
2012-12-06 14:58:11 -08:00
Trevor Parscal 4737727f34 (bug 37837) Spinner of death on error
* Reusing deactivate method to recover from load error
* Made deactivate resilient to some properties not being set yet (so we can call it on load error)
* Restoring save dialog state after save error

Change-Id: I6a697dc6bddeebecf4e2ab26805bee9f3754c714
2012-12-06 14:18:56 -08:00
jenkins-bot 47fe85bbde Merge "(bug 42487) Don't crash the converter for "<span>\n<p>Foo</p></span>"" 2012-12-06 20:13:02 +00:00
Timo Tijhof 4e407bd59e (bug 38034) Implement MediaWiki's copyright warning
Logic taken from EditPage::getCopyrightWarning, but couldn't use
it directly because it doesn't give the message keys and wraps
the html.

Using the same logic and running the same hook, we'll get the same
message keys (and message parameters therefore) as EditPage would.

Also fixed these bugs (as they were more prominent now):
* Use Message::parse() instead of Message::plain()
* Set inLanguage properly instead of using the default
  (EditPage is user-localised, including this message, just like
  the rest of VE).
  Fixes bug 42764: minoredit/watchthis should be in user-language.

Change-Id: I84fee641162cdeed290092e56fb0e1d2562d833d
2012-12-06 06:29:13 +01:00
jenkins-bot 82746f990d Merge "Add tooltips to close and remove inspector controls." 2012-12-06 01:51:00 +00:00
jenkins-bot 2ba2b3d428 Merge "(Bug 40773) Clicking on minor edit now opens in a new tab." 2012-12-06 01:47:25 +00:00
jenkins-bot 488131e04b Merge "(bug 42750) Save button says "Create page" when creating a new page" 2012-12-06 01:43:14 +00:00
Catrope 085a6f0985 (bug 42487) Don't crash the converter for "<span>\n<p>Foo</p></span>"
The converter was misbehaving when handling <p>s inside <span>s. This
can't be expressed in the linmod, but it would try to anyway. <span><p>
would result in too many paragraph closing elements, leading to an
exception in ve.dm.Document complaining about unbalanced input.
<span>\n<p> would result in an exception in the converter itself while
trying to perform whitespace preservation on the newline.

This change makes the converter detect these scenarios and alienate the
offending node. So <span><p>Foo</p></span> converts to a wrapper
paragraph containing an alienInline whose HTML is "<p>Foo</p>" and which
is annotated with a TextStyleSpanAnnotation.

ve.dm.Converter.getDomFromData():
* Change the criteria for alienBlock vs alienInline
** Only infer from the node type if we're in wrapping mode AND we're at
   the same level where the wrapping started (wrappingIsOurs). If the
   latter isn't the case, we can't split the wrapper in the block case
   because we're at the wrong level.
** Use alienInline not only if the branch is a content branch, but also
   if there are active annotations. This catches e.g. <li><b><p>
   (and generally <span><p> on the top level).
* Before converting a child element, check that the child isn't "bad".
  Bad children are non-content children in content branches, and
  non-content children encountered within a wrapper that we can't split.
  Only good children are converted, and bad children are alienated (cue
  Santa/Sinterklaas jokes).
* Add childIsContent and rename branchIsContent to branchHasContent

Change-Id: If420ae80ab0777424a9a5517335ef9d0170e87ae
2012-12-05 17:20:07 -08:00
Rob Moen 63f96b6539 Add tooltips to close and remove inspector controls.
Addresses (Bug 41153)

Change-Id: I6fa0bb8acafbc9e4e7763f9f0e158b853bc1afaa
2012-12-05 17:18:36 -08:00
jenkins-bot b5d1074c3e Merge "(bug 41223) This temporary fix is not needed anymore." 2012-12-06 01:05:09 +00:00
Inez Korczyński e05ad22c8f (bug 41223) This temporary fix is not needed anymore.
Change-Id: Ia65b69f152396d42cd33b6d893c812076e7da6d3
2012-12-05 16:59:28 -08:00
Inez Korczyński 9b70ffba9c (bug 42655) Fix - it might be not the long-term solution - but works for now.
Change-Id: I3165654afb4bf9203cd746ed8af241168d5946a0
2012-12-05 16:54:52 -08:00
Rob Moen bf06930663 (Bug 40773) Clicking on minor edit now opens in a new tab.
Since the link is generated by a MediaWiki message and as far as
I know, the target attribute cannot be added in wikitext.

Solution is to add the target attribute via jQuery in the
save dialog.

Change-Id: I4b6cdee64e7f8e3acb28b21c32c58254d63a8daf
2012-12-05 16:05:16 -08:00
Trevor Parscal 571c2e2ff4 (bug 42750) Save button says "Create page" when creating a new page
Change-Id: I25e07f531b911eef3cf55412862b163393d03d33
2012-12-05 15:38:48 -08:00
jenkins-bot 4415aabe22 Merge "Rename and cleanup ve.ce.Surface locking state" 2012-12-05 23:30:29 +00:00
Inez Korczyński 34a7ff381d Rename and cleanup ve.ce.Surface locking state
Get rid of ve.ce.Surface.locked (and isLocked, lock, unlock) and instead introduce ve.ce.Surface.renderingEnabled (and isRenderingEnabled, enableRendering, disableRendering) which names are way less confusing and more specific. Also add use of isRenderingEnabled to ve.ce.ContentBranchNode.

Change-Id: I72e9e8f8dfbf43784d7e616369acc3e9649c715a
2012-12-05 15:19:56 -08:00
Christian Williams a9010d5928 Fixing Pre-Annotations
Initializing range var in SurfaceObserver to use this.range instead of null to avoid passing wrong information to onContentChange.

Change-Id: I1d4e3fa2393166dad887077529351a479401bf4b
2012-12-05 15:13:25 -08:00
Rob Moen 459d0428ec Add cancel button to VisualEditor MediaWiki integration.
Attempt to address (Bug 37845)

Change-Id: If1e08bbfbe4920e74f1c006e4fb18c8296ff6043
2012-12-05 15:00:46 -08:00
Inez Korczyński 6981d2d0d9 Get rid of ve.ce.Surface.sluggable - we are not using it anymore.
Change-Id: Ibcd6c7c1bae4f4dd7c3ac52719e17214dbae6558
2012-12-05 14:34:47 -08:00
Christian Williams 1b84b3b1bc Restore cursor after undo/redo
With the introduction of ActionFactory, we lost selection restoration. I've re-added it in the HistoryAction methods.

Change-Id: I018f9a9f85f5ce081e3b56c0f52aba24bc24cec5
2012-12-05 13:51:04 -08:00
jenkins-bot 3b93607fea Merge "(bug 42707) JS error when deleting across an inline alien" 2012-12-05 20:21:43 +00:00
Catrope 6d5d23d93d (bug 42707) JS error when deleting across an inline alien
ContentBranchNode shouldn't rerender on update, only on childUpdate.
When deleting across an inline node, update was emitted after the splice
had occurred in the DM but before the spice event was emitted that
caused the splice to happen in CE, leading to detached nodes and
associated sadness. See the bug for more details.

Change-Id: I2d44231b6e27efdb3f12967556cff174d9364d25
2012-12-05 11:19:18 -08:00
Trevor Parscal 78eb16035c (bug 41865) Save page behavior for oldid
ApiVisualEditor
* Reverted some of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 turned out to be full of problems - the race condition is only relevant to getting the HTML
* Fixed check for $content to be false before it was defined

ve.init.mw.ViewPageTarget
* Reverted some more of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 - wgCurRevisionId is not equal to oldid, it's equal to $title->getLatestRevId() - this was causing lots of oldid problems
* Added use of restored message
* Made save button not locked when using oldid
* Customized save buttons depending on oldid

ve.init.mw.Target
* Reverted even more of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 - we don't want to keep a copy of the wgCurRevisionId at all, we just want the oldid if it was given

VisualEditor.i18n, VisualEditor
* Added restored notification and restore save button label messages

Change-Id: I8b30c2a153911f44643e369b7c6a9b89c0fb2c5b
2012-12-05 06:44:41 +00:00
Trevor Parscal 03d56bfe2d Merge "Clean up, fix errors on demos." 2012-12-04 19:05:21 +00:00
Rob Moen 0ceee83950 If more than one title in suggestions match, select the first item.
Addresses (Bug 42665)

Change-Id: I8c425b79e34e931beb78538146a035c25023ce8a
2012-12-04 11:01:51 -08:00
Timo Tijhof 278e5f7640 Clean up, fix errors on demos.
* Fix 404 error for ve.ui.Icons-{raster,vector}.css
  Follows-up 9563f08 / I840f72426f9a.

makeStaticLoader.php:
* Clean up old code.
* Error out early for missing module.
* Put i18n stuff in the right place
  (some modules access ve.msg from the global scope to
  assign status variables, for standalone on demos this was
  failing due to wrong load order)

Change-Id: Idbff4c5136d567da747d9ae373cd2f6c3ee7fb1c
2012-12-04 08:58:20 +01:00
Timo Tijhof 381472ac99 init.Platform: Refactor parsed messages.
Rewrite VisualEditorMessagesModule:
* Replace copy-paste dump of user-css module with stuff for
  VisualEditor (class commend and module::$origin).
* Remove duplication between getMessages and getScript.
* Actually implement getModifiedTime so that the comment in
  getMessages() about cache invalidation is actually true
  Fixes bug 42670: ext.visualEditor.specialMessages cache broken

ve.init:
* Implement addParsedMessages and getParsedMessage so that we
  don't mix up plain messages with raw html messages (minoredit
  was previously overloaded in mw.msg storage with a parsed html
  message and retrieved though ve.msg, which is documented as
  retuning plain text, not raw html). This is now separated into
  a different method.
* Improved documentation of the other msg methods to emphasise
  their differences
* Removed redundant code in attachSaveDialog() that was
  (partially) already done in setupSaveDialog() and moved the
  remaining bits into it as well. Checked all callers of these and
  they are both only called from ViewPageTarget.prototype.onLoad
* Also implement them in the standalone platform implementation,
  with the html escaper based on mw.html.escape
* Update init.platform.getMessage to use undefined instead of
  discouraged 'if-in' statement.
* Add test suite.

demos/test:
* Re-run makeStaticLoader.php on test to add ve.init.Platform.test
* Re-run makeStaticLoader.php on demos and update i18n caller
  to use ve.init.platform.addParsedMessages (also moved out of the
  auto-generated block for easier updating)

Change-Id: I7f26b47e9467e850c08b9c217c4f1098590de109
2012-12-04 07:56:41 +01:00
Catrope bbf7100041 Merge "(bug 42661) Initially hide context, then update after animation" 2012-12-04 02:49:09 +00:00
Catrope be0f6f7bd7 Merge "(bug 41929) Unlist button overzealously unlists the whole list" 2012-12-04 02:48:32 +00:00
Catrope b6dd2340ad Merge "Added destroy methods and called them on deactivate" 2012-12-04 02:45:40 +00:00
Trevor Parscal 9a7b0eafb6 Merge "(bug 42469) Leading newlines in <pre>s get eaten" 2012-12-04 01:16:25 +00:00
Catrope e95cc34978 (bug 42469) Leading newlines in <pre>s get eaten
HTML DOM has annoying behavior for <pre>s where .innerHTML eats the
first newline in a <pre>. Work around this by explicitly adding a
newline in the data->DOM converter if the <pre> already contained a
newline.

There is a separate bug in Parsoid that causes the newline to be lost
anyway, filed as bug 42666

Change-Id: Ia26cd4a4c61afbe439b0562deb7f24ee8b8147d7
2012-12-03 17:14:33 -08:00