Commit graph

1239 commits

Author SHA1 Message Date
Timo Tijhof 95742d65f6 Save dialog: Various clean up.
Drop "-down" class in favour of :active CSS pseudo-class.
* http://kimblim.dk/css-tests/selectors/
* http://www.quirksmode.org/css/contents.html
* http://caniuse.com/#search=css%202.1

Rename methods consistently to enableFoo and disableFoo.

Use mw.notify instead of mw.util.jsMessage (the latter takes a
string of html and parses it, instead of taking text).
Also, jsMessage is obsolete (legacy wrapper around mw.notify).

Rename slide-main to slide-save in preparation of other slides
and introduction of multi-step save dialog.

Re-introduce "disabled" state (not css, but actual state) so that
pressing "Show changes" multiple times will not spawn multiple
async operations. The save function guards against this by keeping
a static property in the internal helper method, but there are
still some operations happening between the button and that method
this should be guarded in the UI instead. Follows-up I67819168.

Change-Id: Idf0331377e6be814ccae853228d6159b4ad5a159
2012-12-11 23:13:54 +01:00
jenkins-bot ffc8ec5e50 Merge "Re-apply fixes made in a patch set that were accidentally reverted on rebase" 2012-12-11 21:35:31 +00:00
Catrope 3f903adb09 Add .reportProblem() to submit reports
Change-Id: I55ffd8bfc7664ead3827ef6be178a0b6f3b991a1
2012-12-11 13:19:51 -08:00
Trevor Parscal baa5754b2f Re-apply fixes made in a patch set that were accidentally reverted on rebase
In the change: I6781916822b4173ba906b9bc4c341219fbf10d82

71b97ec45b was reversed when I submitted 1789545284

Change-Id: I6cc59a27817bfbe55c7cbf45bba746a4bd6c375f
2012-12-11 13:06:40 -08:00
jenkins-bot 6460df5cff Merge "Improve truncate and truncateRange to allow negative values" 2012-12-11 19:34:07 +00:00
jenkins-bot 49bd56ffe9 Merge "Move the cursor to the end of newly inserted links" 2012-12-11 19:34:02 +00:00
jenkins-bot a9f5639aab Merge "Fix the "list of US Presidents" bug" 2012-12-11 19:24:25 +00:00
Catrope 045b597253 Fix the "list of US Presidents" bug
I noticed this bug on [[List of Presidents of the United States]]. When
there's HTML that looks like "<td>Foo\n<meta/></td>", the converter will
collect the newline in wrappedWhitespace, then attempt to splice it out
and store it in internal data. But instead, it ends up splicing out the
/metaBlock element, which causes strange unbalanced input, which causes
an empty table in the node tree.

Change-Id: I79ed2fa9a834cc42759c7d21250d8842f563d38f
2012-12-11 11:23:31 -08:00
Trevor Parscal f8061a97eb Improve truncate and truncateRange to allow negative values
Positive values will move the end, negative values will move the start

Change-Id: I566653664bf2a8a74781f1059a51873ab72560f9
2012-12-11 11:10:22 -08:00
Trevor Parscal abdcacd68a Move the cursor to the end of newly inserted links
Inserted links happen when the cursor is not near a word, so we insert the target as text

Change-Id: I06c2c425d28db7ca61f13c438e25cc9c75f391f4
2012-12-11 11:09:26 -08:00
Timo Tijhof 3a2453b1b2 mw.ViewPageTarget: Move diff button logic, min-height for dialog.
Follows-up Ic77c5ce4 and I9d05ef6e.

Change-Id: I077172d590e53737691020c1265203134eea3c9c
2012-12-11 18:33:16 +01:00
jenkins-bot 64abfff53c Merge "Enable change makers by default" 2012-12-11 07:05:48 +00:00
Catrope 0d5db4eb4e Enable change makers by default
Change-Id: I7b5af42abe81cc5f41dd80692ac5d5ff007f99ed
2012-12-10 22:55:00 -08:00
Catrope 1a195b33e1 And also use a 100s timeout for show changes
Change-Id: I437d125cd1944299991d80f22fdaedd490bcb45f
2012-12-10 21:16:21 -08:00
Catrope 2e6425a16b Set the save timeout to 100s as well
Change-Id: Ic01ffaae2a0c4bbe91bee7705c60f26b7b34d0f9
2012-12-10 20:33:34 -08:00
jenkins-bot a90f79178a Merge "Hide the show changes button when we are creating a page" 2012-12-11 03:25:50 +00:00
Trevor Parscal 1edd9ad504 Hide the show changes button when we are creating a page
Change-Id: Ic77c5ce4757fd0cf6d7cdd9a991206b649fc2e5a
2012-12-10 19:24:26 -08:00
jenkins-bot dff8570850 Merge "Check if there's a document before we try and set focus on it" 2012-12-11 03:24:05 +00:00
Trevor Parscal c59e6b1638 Check if there's a document before we try and set focus on it
Change-Id: Ia7776c70c2593e4524adab3a347230ee3cccad29
2012-12-10 19:14:43 -08:00
Trevor Parscal c91ef9306c Add left margin to save dialog, visible with show changes
Change-Id: Iaadbfd30f7270fa90dc4adefc9855a55d087ce0c
2012-12-10 19:04:01 -08:00
jenkins-bot 220d07ac43 Merge "Prevent Inspector frame from reloading on close." 2012-12-11 02:56:00 +00:00
jenkins-bot 8d04dd20ad Merge "Fix typo'ed documentation issue with gerrit change 38009" 2012-12-11 02:55:45 +00:00
jenkins-bot 6bb6f6b790 Merge "Throw edit warning on cancel." 2012-12-11 02:55:32 +00:00
Trevor Parscal 99ccfab9f0 (bug 42920) Add the feedback tool
icons, comment.*, ve.ui.Icons-*
* Added comment icon

ve.init.mw.ViewPageTarget
* Refactored editNoticeButton into being just a tool
* Added feedback tool, which shares the editNoticeButton code
* Added feedback object construction in init constructor
* Added launching code to feedback tool

VisualEditor.i18n
* Renamed editnotices-button message to editnotices-tool to match changes in code
* Added feedback tool message

VisualEditor
* Added dependency on mediawiki.feedback
* Updated changed message key
* Added reference to new message

Change-Id: I813c89a505386a9b3206bfbcb176016e28a592cb
2012-12-10 18:47:53 -08:00
Trevor Parscal 1789545284 Adjustments and fixes for styles
* Made buttons use shared CSS code
* Stopped using <button> elements and got all browsers looking the same
* Fixed focus on text area issue - had to let the stack clear first

Change-Id: I6781916822b4173ba906b9bc4c341219fbf10d82
2012-12-10 18:34:58 -08:00
James D. Forrester 00d86d69cb Fix typo'ed documentation issue with gerrit change 38009
Change-Id: I1238001949bae519d49428f98dcdd1428388aa0d
2012-12-10 18:34:37 -08:00
jenkins-bot fafd3c53c4 Merge "(bug 42937) Removing copy/pasted link annotations removes the original as well" 2012-12-11 02:22:22 +00:00
Trevor Parscal 29cdbe0ea5 (bug 42937) Removing copy/pasted link annotations removes the original as well
Basically a copy should be a deep copy, so this was a blatant mistake.

Change-Id: I702fb425783293c4ddde8b9ac568dfe6abc8f782
2012-12-10 18:12:55 -08:00
Catrope e5883ac201 Remove FIXMEs resolved in 15c5495255
Change-Id: I03dcf9040bb40e5550e9ff56609d479715904a65
2012-12-10 18:09:49 -08:00
Trevor Parscal 50f89a675e Add recursion guard back in
This was removed in I0873d906c058203b83b8d4bbe5a4b274f05a26fd because I had fixed another cause of the recursion - this is still needed however because the following still happens:

1. Link inspector is opened away from a word, so it goes into a mode that will insert text based on the chosen target
2. The link inspector is closed, causing a context change when the new annotated text is inserted
3. The context change event triggers the link inspector to close, leading us back to step 2
4. Browser dies in infinite loop hell

We may be able to fix this in a different way, like performing the document changes after the inspector has already closed by running it in a timeout. In any case, this works for now, and we can improve the design of this area of the code later on.

Change-Id: I7f3c17dad08521bb1ae7c2a1e8a4e21e2c4ba210
2012-12-10 18:01:10 -08:00
Rob Moen 1953f12fd8 Prevent Inspector frame from reloading on close.
In the event the page explodes from a huge js error, prevent
the iframe from reloading to slightly reduce the confusion of the
user.

Change-Id: I0c88678437f0bad994fa97f4df63d8b288f69e7a
2012-12-10 17:43:40 -08:00
jenkins-bot b3e2ebe6ee Merge "Fix tests for bug 42806 patch" 2012-12-11 01:03:53 +00:00
jenkins-bot 294962092c Merge "Alien support for IE" 2012-12-11 01:03:09 +00:00
Rob Moen f4cbfa5d87 Throw edit warning on cancel.
-Added reset and hide calls to deactivate to prevent problems
with the save dialog if the user exits to the view.
-Remove unneeded teardown routines from cancel.
-Calling deactivate without override.

Change-Id: I888019146186fb7cbc1ee2b8efee9a0c45286c23
2012-12-11 00:50:05 +00:00
Trevor Parscal 353297e5b5 (bug 42925) Inspector doesn't open properly
ve.Range
* Rewrote truncate so that it works as expected, truncation should always reduce the length using the start/end values, not the from/to values

ve.ui.Inspector
* Added a comment about where the name argument to onBeforeInspectorOpen comes from, since it's a little bit confusing on first read (and I wrote it!)
* Calling onInitialize, onOpen and onClose methods directly, since we need to control the before or after-ness of listeners getting in there and doing their stuff - plus it's more direct
* Removed onRemove stub, which is never actually called
* Added before/after versions of initialize, open and close events
* Got rid of recursion guard since we don't need it anymore thanks to changes made in ve.dm.Surface (see below)

ve.ui.Context
* Updated event names to deal with new before/after naming of initialize, open and close events
* Removed fade-in logic since fading in doesn't even work anymore - since now we now annotate first, then open the inspector, the menu will actually exist and be open when we open the inspector even though you don't see it because it's quickly obscured

ve.ui.LinkInspector
* Made fragments non-auto selecting, in the case of onInitialize we actually call select(), which is silly since we were using an auto-selecting fragment - it's clear that this was a mistake

ve.dm.Surface
* Moved locking (polling stop and start) to the far outside edges of the change method
* I need a lot of eyes and testing on this change, it seems OK to me, but I'm suspicious that it may have side effects
* What was happening is that selection changes were being applied and then the poll was picking them up, and then the selection was coming in again as a change, but it wasn't a change at all, it was just feedback - this change event was then closing the inspector the instant it was opened - the odd part was that this only occurred when you selected backwards, which seems to be caused by the range being normalized, so it looked like a new selection even though it wasn't

ve.dm.Document
* trimOuterSpace from Range didn't consider annotated spaces to be spaces, by using the [0] trick (first character of a plain text character string or first element in an annotated character's array both are the character's value - but elements don't have a property named '0' so it skips those safely as well) we can always get the right value for comparison

Change-Id: I0873d906c058203b83b8d4bbe5a4b274f05a26fd
2012-12-10 16:48:13 -08:00
Trevor Parscal 15c5495255 Fix tests for bug 42806 patch
Repairs what 619043f8d1 breaks

Change-Id: I2f98ca0dbb292d98dddc86b39c8916e76a5e9d8b
2012-12-10 16:45:46 -08:00
jenkins-bot b6d0cebe59 Merge "(bug 42654) Implement Show changes in Save dialog." 2012-12-10 21:49:38 +00:00
jenkins-bot 3618e9846b Merge "Focus on document when notices are clicked" 2012-12-10 19:12:28 +00:00
jenkins-bot 4bd26cb24b Merge "(bug 42842) Do not call update (temporary solution to prevent error" 2012-12-10 18:41:39 +00:00
Inez Korczyński f93fd9ffe3 (bug 42842) Do not call update (temporary solution to prevent error
Solution: do not call update (temporary solution to prevent error - however content will never be at offset 0 - so it should never hurt)

Change-Id: I9ed6f9fbea23d5e2e55c56f8483321442049bd51
2012-12-10 10:41:01 -08:00
Timo Tijhof f79f6055e3 (bug 42848) Notifications should not use db-variant of page titles
Change-Id: Ie84168cd2509a17c180c6143a87a18ae8bbb3d0a
2012-12-08 02:38:05 +01:00
Timo Tijhof 97fa232c8f (bug 42654) Implement Show changes in Save dialog.
Turned saveDialog-body into slide-based swapper.

Moved footer into saveDiaog-body so that the license text doesn't
stay under the diff-slide (and move body bottom padding to foot
top)

Wrapped buttons and title in a saveDialog-header and converted
closeButton from absolutely positioned to a floated layout.
This way the title doesn't need to be repositioned but will scooch
over if the prevButton gets shown/hidden.

Update API "diff" action to include table wrapper and table
header. Without it the mediawiki CSS for diff doesn't work
properly (needs colgroups for proper width of the "-" and "+" column etc)

Renamed -saving class to -disabled for consistency.

Set prop.disabled to really lock/unlock buttons, not just visual
(otherwise the click handlers are still triggered on click, can
potentially cause actions to be triggered when not expected)

Using a ve message for "Show your changes" title instead of
re-using core tooltip-savepage in a different context.

Diff slide triggers "auto width" on dialog (inline undo of width: 29em), keeping min-width, to allow it to expand as wide as needed.

Functions that I copied as base for onShowChanges and
onShowChangeError had some incorrect argument descriptions. Fixed
in both.

Note:
* Pass function to .off(), so that only that one is unbound
  instead of any "resize" handler on the page (by other extensions
  or gadgets or core)
* NB: ve.bind ($.proxy) preserves internal guid, so that $.Event
  can find the bound function by the original reference.
* keydown has an anonymous function, should either moved to
  prototype or namespaced, did latter for now, save enough and
  better than destructive .off('keydown')

Change-Id: I9d05ef6e3e2461bdcf363232f7b0fbad5e24f506
2012-12-08 02:26:24 +01:00
Trevor Parscal 6bfb42639f Focus on document when notices are clicked
Change-Id: I55e4eb74e12ded79d998d155d4688ce6a1b6ce66
2012-12-07 16:42:47 -08:00
Christian Williams 61de058d08 Alien support for IE
We got lucky - the fact that our alien styling choice required phantom overlays had the nice side-effect of preventing the ability to focus the aliens. Therefore, as soon as we started ignoring IE to deliver nice alien handling for standards-compliant browsers, we inadvertently solved(?) the IE alien problem. I've touched up the styling to look nice in IE 9 (solid green phantoms) and IE 10 (stripes). Shield GIF switched to PNG because IE 10 renders the transparent GIF as solid red. Yeah, red.

Change-Id: I3bc69acba9ed883a823cdf722117b90966bc332b
2012-12-07 15:51:15 -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
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
Rob Moen 30dadb6c8c Address error caused by changing focus from context menu to window.
DocumentNode element loses focus when the context is opened.
When clicking out of the context into window, polling error
occurs.

Change-Id: Ie8f8af763d221c59e47e8c240653f8b817c26f64
2012-12-03 16:59:14 -08:00
Trevor Parscal 4c4372255a Merge "Don't phantomize inline aliens when dragging" 2012-12-04 00:56:55 +00:00
Trevor Parscal de6f4a4254 (bug 41504) ve.ce throws error when surface loses focus
ve.ce.Surface
* Used getModel() as per TODO
* Simplified code by pre-calculating 2 statements that were being used 4 times each
* Re-structured logic so that simple insertion and deletion are only possible if next and previous have a range, triggering complex change otherwise
* Added some documentation

ve.ce.SurfaceObserver
* Added checks for whether rangy found a branch node within the document or not before accessing it's node via .data() and made it so we are only performing DOM > document range conversion if we did
* Removed some commented out code

Change-Id: Iaaf30a5b201710ab4235e775f18808a8d512f1f9
2012-12-03 16:34:27 -08:00
Trevor Parscal b04a920616 (bug 41929) Unlist button overzealously unlists the whole list
ve.IndentationAction
* Fix incompatibility with working with multiple nodes by using surface fragments
* Bug was caused by unindent causing rebuilding, which for all groups other than the first meant their nodes were detached and broken

ve.ListAction
* Employ unindent in a loop to remove all list levels

This is all still a bit hacked together, the use of surface fragments saved us this time, but we need to refactor this code. Badly. Next year.

Change-Id: Idddef35230b04d64cf8338d53bbab730fadec2fc
2012-12-03 15:57:10 -08:00
Christian Williams b02ea35298 Don't phantomize inline aliens when dragging
This will prevent inline alien phantoms from appearing while dragging. This was a usability enhancement identified by Inez/Christian.

Change-Id: Idf046db72e25875e899f5926ab7d50d2f514586b
2012-12-03 15:52:36 -08:00
Krinkle d045722240 Merge "(bug 40339) Out of bounds errors" 2012-12-03 22:36:33 +00:00
Trevor Parscal cb4877b0d0 (bug 40339) Out of bounds errors
Detecting contextChange events was making assumptions about the previous state, and causing a mess of problems.

Solution: detect contextChange events in a smarter way.

We also now emit contextChange event when moving to a different node. This helps fix other issues because it's possible for the selection to be the same, but the node at that range to change, and that's a context change for sure. Example would be changing the heading level.

Change-Id: I99d6fa94fae76aa940077abc9b5beacd38eb7b0b
2012-12-03 14:23:58 -08:00
Trevor Parscal c051107b39 Removed all browser-specific box-shadow rules
These aren't needed for any of our target browsers anymore.

Change-Id: Idae4acb5f0f6387cad52f2ea7594dbad1929af59
2012-12-03 23:08:33 +01:00
Trevor Parscal 98ef0da3ee (bug 42661) Initially hide context, then update after animation
Change-Id: I35a0c3359ffc1a62ee3c0456c33475e32189f4b4
2012-12-03 14:06:24 -08:00
Krinkle 3b3dab11c7 Merge "Removed all browser-specific border-radius rules" 2012-12-03 22:05:59 +00:00
Trevor Parscal 5812c8babe Removed all browser-specific border-radius rules
These aren't needed for any of our target browsers anymore.

Change-Id: I86d1964f163827673c090b67a472254b73e365a4
2012-12-03 23:05:30 +01:00
Krinkle 46e52ae7bc Merge "(bug 42220) Added support for edit notices, which appear on the toolbar" 2012-12-03 22:02:16 +00:00
Trevor Parscal a55217ec3b Added destroy methods and called them on deactivate
This prevents memory waste when switching between read and visual editor tabs, which happens entirely on the client.

Change-Id: I31b50accac38d72a9367b9035504552dc0150104
2012-12-03 13:45:38 -08:00
Timo Tijhof 0760d2b4a9 (bug 42137) Sync availability of "minor edit" with MW backend.
Which for now is just "not when creating a new page". This is
already strictly enforced in the MediaWiki backend through EditPage.php, but not reflected in the Save dialog of VE yet.

Now the checkbox for Minor edit matches the logic for EditPage.

Change-Id: I9c659845feebb3e9bbf8e13ee67be27c6adb4321
2012-12-03 12:22:31 -08:00
Timo Tijhof 42757a724d Cleanup oldid: Use mw.config for page existence and revision id.
Use mw.config wgCurRevisionId for oldie instead of uri query.
That way it also set on regular views, and as a bonus it the
normalised value (e.g. if on a page with oldid in query but the id
doesn't exist or is somehow invalid, it won't use it).

Centralise page existence logic in JS and rename Target.oldId to
Target.pageRevId (to further indicate that it is always set, not
just on oldId views. To detect an oldId view, do a boolean check
on value from currentUri.query.oldid directly).

In PHP Api, move oldid logic to execute() method instead of
locally from the getHTML call. That way it is always set, avoids
hitting this bug in other methods instead of just getHTML().

Since the mw.Target constructor now retrieves the ID from
mw.config directly, the second argument was removed.

Change-Id: I223235a6ea8b4178c50beeaaedb709b2de7cf0b5
2012-12-03 12:22:30 -08:00
Timo Tijhof 04fc47b919 (bug 42553) Only replace url on veaction=edit if there is no other query
Change-Id: Ia63c937d3a0a68acaa178486ab439bc1ea9db8af
2012-12-03 12:22:30 -08:00
Timo Tijhof bae3eb081a mw.Platform: Only show minor edit option if user has "minoredit" right
Had to make the retrieval of the Save dialog html template
asynchronous due to mw.user.getRights being asynchronous.

Entire block indented, ignore whitespace changes.

Also:
* Fixed 2 cases where ve.msg value was interpreted as HTML
instead of adding a text node directly.
* Alphabetically sorted the dependencies (after adding
  user.options and mediawiki.user).
* Removed redundant inline jshint comment, multistr is already
  tolerated from the central .jshintrc file.

Change-Id: Ie09bb5c8bdbfbb3ec0d4983b74d0697b941153e0
2012-12-03 12:21:35 -08:00
Trevor Parscal 4d073cdaa5 Merge "Init: Fix incorrect context for mw.msg.apply." 2012-12-03 20:01:43 +00:00
Trevor Parscal f740198933 Merge "(bug 41159) Position of VisualEditor's "Create" tab is wrong." 2012-12-03 19:59:51 +00:00
Trevor Parscal a63f812d52 (bug 42220) Added support for edit notices, which appear on the toolbar
ApiVisualEditor
* Including notices in response to parse actions

ve.init.mw.ViewPageTarget
* Added styles for editNoticeButton and editNotices

ve.init.mw.ViewPageTarget
* Added toolbarEditNoticeButton and toolbarEditNotices
* Combined toolbarEditNoticeButton and toolbarSaveButton setup
* Moved toolbar buttons setup to onLoad (it could vary per-parse now)
* Added tearDownToolbarButtons which fires on deactivate
* Renamed some instances of teardown to tearDown
* Added click handler for toolbarEditNoticeButton
* Added toolbarEditNotices setup method, called on load
* Made notices fade in and out, in by default on load if any
* Made notices hide when save dialog is opened

ve.init.mw.Target
* Added storing of notices on parse

icons, alert, ve.ui-Icons
* Added alert icon

VisualEditor.i18n, VisualEditor
* Added notices button message

Change-Id: I581bf5a005a9c18422f952d71064d17d0ba9b540
2012-12-03 11:49:33 -08:00
Timo Tijhof 407de829dd Init: Fix incorrect context for mw.msg.apply.
Context should be 'mw', not 'mw.msg'.
Also updated to using ve.bind instead and documented that ve.msg
cannot ve.bind because the reference 've.init.platform.getMessage'
does not exist yet at run time of the ve.js file.

Change-Id: I7eb692bdc4b63cc44fab118054d8eea05c2a71ff
2012-12-02 03:45:51 +01:00
Krinkle f614019b5d Merge "Renamed API from ve-parsoid to visual editor" 2012-12-02 02:02:39 +00:00
Timo Tijhof 105b5865aa (bug 41159) Position of VisualEditor's "Create" tab is wrong.
Change-Id: Id88a160621093e4db4cf01c0fa34793cc1a929b4
2012-12-02 02:52:15 +01:00
Trevor Parscal 26d06a98ed Renamed API from ve-parsoid to visual editor
Change-Id: I3bfe2e813b31f9010010f63902b1e8e22f3bcd59
2012-11-30 15:00:04 -08:00
Rob Moen bad4de89b6 Add hover state to link inspector suggestion items.
Addresses (Bug 39977)

Change-Id: I159f86b070544f829ff801ac3ab913d36c5a0b30
2012-11-30 14:52:57 -08:00
Catrope 38e37f40ee Merge "(bug 42555) Fixed onUpdate over-writing in ve.ce.HeadingNode" 2012-11-30 19:44:32 +00:00
Trevor Parscal 6f3db44cc1 Merge "Restyle suggestion dropdown into a single column." 2012-11-30 19:43:56 +00:00
Trevor Parscal 23bd31a855 (bug 42555) Fixed onUpdate over-writing in ve.ce.HeadingNode
When the content rendering stuff was moved to ve.ce.ContentBranchNode the onUpdate methods being used to update the DOM wrapper in ve.ce.HeadingNode was overlooked, so heading were not rendered on update anymore.

Change-Id: I994b8c43123c3cd02b9a550d5d7eac7d5052418e
2012-11-30 11:39:46 -08:00
Rob Moen 766b5f3d3c Restyle suggestion dropdown into a single column.
* Permits longer page titles in suggestions without changing
  the width of the  dropdown.
* Addresses (Bug 40675)

Change-Id: Ie76a551970a040074b86c49bb44bda640ecd4845
2012-11-30 11:08:49 -08:00
Trevor Parscal bf98af7bcb (bug 42552) Link inspector close on selection change
The logic in ve.ui.LinkInspector.onUpdate was very flawed. This patch makes it so:
* When something happens, if there's an inspector open then so long as the selection hasn't changed the inspector is updated (such as the window being resized)
* If the selection does change, the inspector is closed
* If there's no inspector open, we try to show a menu of available inspectors

Change-Id: I859123a5fcd36bc2afb2e578f81f30a944c8583a
2012-11-30 10:12:41 -08:00
Catrope 752639bf6c Merge "(bug 42401) Cursor movement fixes" 2012-11-30 17:54:51 +00:00
Trevor Parscal 5e477cbe98 (bug 42401) Cursor movement fixes
ve.ce.Surface
* Added ve.ce.Surface.adjustCursor, which replaces repetitive and buggy code that was handling left and right arrow key presses
* New method only affects the selection target, so it won't collapse the selection on you - this was what caused bug 42401
* Made hasSlugAtOffset() actually return a boolean

ve.dm.Document
* Fixed turn-around issue in ve.dm.Document.getRelativeOffset - if the offset is already valid and we can't move in the direction we want, we should just leave it be, not turn around
* Since this method was being used by ve.ce.Surface to correct the cursor position on arrow key presses, it was causing the strange cursor jumping when you pressed an arrow key while at the edge of a document

ve.dm.SurfaceFragment
* Fixed typo where getAnnotationRangeFromSelection was preserving selection direction, but checking the wrong properties

ve.dm.Document.test
* Added tests that verify turn-around issue is fixed

Change-Id: Iba55cfc3d531e7d1333b78c94912ff22179aace8
2012-11-30 09:50:47 -08:00
Rob Moen 9ba19af1c0 Immediately provide default suggestions based on 0 results.
Allows suggest tool to open immediately and provide new page and
external link suggestions for link inspector.

Resolves (Bug 42341)

Change-Id: I79bc3e31033b5c38c3ed6ab23e601476cb17ba8f
2012-11-29 15:26:47 -08:00
Trevor Parscal 1d0ad9573e (bug 37828) Handle edit conflicts
ApiVisualEditor
* Added basetimestamp and starttimestamp to all methods where appropriate
* Added new serialize method which converts HTML to Wikitext

ve.init.mw.ViewPageTarget
* Added edit conflict handling
* Moved form value reading code into getSaveOptions method
* Prevented edit warning from appearing while submitting

ve.init.mw.Target
* Added serialize and submit methods
* Fixed some documentation
* Added support for baseTimeStamp and startTimeStamp

VisualEditor.i18n
* Added edit conflict confirmation box message

VisualEditor
* Included new edit conflict message to resource loader module

Change-Id: I002c5aa23704c1c46ef46fa1970a4254614b9eb1
2012-11-28 17:55:23 -08:00
Trevor Parscal a57288575f (bug 42350) Delete and backspace broken around inline aliens in Firefox
ve.ce.Surface.handleDelete did not support inline elements. This patch resolves this by detecting them and using programatic delete instead of native browser delete.

Change-Id: I73215df88519450965be35d9e04cf4e621d1e90d
2012-11-28 16:44:34 -08:00
Trevor Parscal e1a15b8845 Merge "(bug 42221) (bug 42142) Refactor init.mw setupSkinTabs." 2012-11-28 19:38:05 +00:00
Catrope e148234c29 Render inline annotations in CE
Moved annotation rendering from ce.Textnode into the new
ce.ContentBranchNode class. This allows us to render annotations that
span across multiple nodes.

* Add ce.ContentBranchNode, inheriting ce.BranchNode
* Make ce.{Paragraph,Heading,Preformatted}Node inherit ce.ContentBranchNode
* Made ce.ContentBranchNode render its child nodes with anntations,
  using .getAnnotatedHtml() on the child nodes
* Put a default implementation for .getAnnotatedHtml() in ce.LeafNode
* Override this in ce.TextNode to do escaping and whitespace handling
* Removed rendering code from ce.TextNode (this.$ is now unused there)
* Removed ce.TextNode.onUpdate() and ce.BranchNode.clean(), now unneeded
* Have ce.BranchNode propagate update events from children, so
  ce.ContentBranchNode can rerender when its children change
* Update tests, add test case for escaping of &<>'"

Change-Id: I4600e984b287c6ff9267f4281d2f09bab9e1ad95
2012-11-28 11:21:59 -08:00
Catrope ce16b275c9 Fix rebase artefact in ve.dm.Node.getAttributes()
This caused it to always return {} when asked for all attributes with a
given prefix

Change-Id: Id3cc053e1911aebb2b7e60e3dd2f325ec7772a6c
2012-11-28 11:20:54 -08:00
Timo Tijhof a48581945b (bug 42221) (bug 42142) Refactor init.mw setupSkinTabs.
* Remove the logic where we create a ve-edit button even though
  we know there is no native ca-edit button (bug 42142).
  This was previously in place to allow ve-editing a page while
  restricting source editing, but this is no longer wanted.

* Implement new tabLayout mode "add", which adds a VE tab.
  Previous default is now the "replace" mode, which replaces the
  native "Edit" tab and creates a "Edit source" link.

Change-Id: I3fe29c52b743837c2e1d66f25ccdca6115b8bd25
2012-11-28 19:15:13 +01:00
Catrope 4de2242e72 Merge "Added contextChange event to surface model, replacing annotationChange" 2012-11-27 22:54:11 +00:00
Catrope e123a39b4e Handle annotated inline nodes in the converter
Was broken both on the way in and on the way out.

* Move alien restoration (data->DOM) out of the main getDomFromData()
  function and into getDomElementFromDataElement(). This means the
  comment about District 9 is gone (sniff), but moving this here ensures
  all code paths hit it (previously, it was assumed annotated nodes
  could never be aliens).
* In the DOM->data converter, add annotation application to
  getDataElementFromDomElement() (for content nodes) and createAlien()
  (for aliens). Previously, these nodes would not get annotations.
** ve.AnnotationSet doesn't have a constructor that takes an array, we
   should fix that.

Change-Id: I65f8e9a322111ca3af275bf9997b0b1e7ee93769
2012-11-27 14:41:40 -08:00
Catrope 5e2c421b77 Make annotating inline elements actually work
The transaction builder would step around inline content elements when
building annotation transactions. This is now fixed.

I also tweaked the processor to tolerate attempts to annotate inline
closings. This allows the builder to generate simpler transactions,
because it doesn't have to step around the closing.

Change-Id: I1e0d7f95b38bad1b35b3e125a53350d2d126a7de
2012-11-27 14:41:40 -08:00
Catrope 49963c75fd Store the data model element in the DM tree
This is cleaner than passing around the attributes separately, and it
allows us to access the annotations in dm.LeafNode as well.

Change-Id: Ie5b90988114835831cbe5cdccf63c7cd45719e31
2012-11-27 14:36:29 -08:00
Inez Korczyński a9082e6dde Only apply HTML attributes to DOM nodes that are "safe"
* Added whitelist argument to setDomAttributes which allows filtering of attributes being set
* Added prefix argument to ve.dm.Node.getAttributes to allow extracting a subset of attributes by name prefix
* Added a whitelist to ve.ce.Node which was extracted from MediaWiki's Sanitizer class
* Replaced attribute copying code with a call to setDomAttributes using the whitelist argument, passing in attributes from a call to ve.dm.Node.getAttributes using the prefix argument

Also…

* Removed comment in constructor of ve.ce.Node, documentation for properties is usually in the getters/setters, and already was in this case
* Renamed ve.setDOMAttributes to ve.setDomAttributes
* Renamed ve.getDOMAttributes to ve.getDomAttributes
* Renamed ve.getDOMText to ve.getDomText
* Renamed ve.getDOMHash to ve.getDomHash
* Updated all callers of renamed methods

Change-Id: Id556172d5d18ea431044b9d402400e1f0e67a293
2012-11-27 14:34:29 -08:00
Trevor Parscal 7404d6438a Merge "Fix tests for fda2e6c1b54a0139a3123de413f672e895ff3352" 2012-11-27 21:38:24 +00:00
Trevor Parscal d4b3910013 Merge "(bug 42277) First character in empty document behaves strangely in Firefox" 2012-11-27 21:36:27 +00:00
Trevor Parscal 2cc8f09204 Added contextChange event to surface model, replacing annotationChange
The contextChange event is fired when:
* Changes to insertion annotations
* Changes to which nodes are selected (start/end nodes have changed)
* Attributes have changed on any element (it's probably more expensive to detect if the changes are relevant than to just emit the event and let listeners do their thing)

This fixes most of the strange behavior with the toolbar not updating properly.

Change-Id: I5321d2e30bebd80987e0c779a9d8e061d8aa80bc
2012-11-26 15:57:02 -08:00
Trevor Parscal ee80af5f96 (bug 42404) Errors passing "incorrect" offsets to ve.ce.Surface.getNodeAndOffset
* Adjust offsets to correct positions before showing selection with them
* Throw an error inside of getNodeAndOffset if we can't find a match rather than mysteriously not retuning anything

Change-Id: Ia7347527e6466262e819f456404b32926fd95e34
2012-11-26 15:01:35 -08:00
Catrope 1bc74b0f6d Fix tests for fda2e6c1b5
Change-Id: I2725f3f775e092bafe7aa9dca71d2a9022f16db8
2012-11-26 21:39:14 +00:00
Catrope 568e0e5701 (bug 42277) First character in empty document behaves strangely in Firefox
This was because Firefox intially puts the selection before the first
paragraph, which translates to a model selection of (0,0). Typing with
the cursor at that position causes bad things to happen.

CE normally fixes up the selection when this happens, but it doesn't do
this automatically on initialization. So I added some code to ve.Surface
that causes this fixup to happen.

Change-Id: I0dcee3a29c1242c49ec30c743f1b69686fbb8436
2012-11-26 21:39:01 +00:00
Timo Tijhof 1ba75b7ea9 The last ever mw.ext.ve jshint fixup
Change-Id: I262673214dd59e5bcaf4e0855e68728365b041fe
2012-11-26 22:36:07 +01:00
James D. Forrester c33de35a98 (bug 42402) Split out two cases so as not to throw an error
Logic called for A || B but then used both; this splits that into two distinct
code paths.

Change-Id: I959e0649fbd5b4f404b5804e26806ba51c31c836
2012-11-23 18:25:23 -08:00
Catrope 8e2414677f (bug 42279) Inserted characters get annotated with empty set
Turns out this was actually a bug in addAnnotationsToData()

Change-Id: I0c9da662c091811e4053ab0ea2771c4a20b26e09
2012-11-21 17:05:10 -08:00
Trevor Parscal 9c74c97808 Fix even more inspector issues, and some ce ones as well
ve.dm.SurfaceFragment
* Removed flawed implementation of word mode for expandRange method and made use of new getNearestWordBoundary method in the document model

ve.dm.Surface
* Got rid of useInsertionAnnotations, which allowed disabling and enabling of insertion annotations - this isn't needed anymore because it was just a dirty hack around the improper starting and stopping of surface observer that's now solved more elegantly by emitting lock and unlock before committing or rolling back transactions
* Get annotations from the first character of the selection if the selection is not collapsed
* Only emit annotationChange events if it really changed

ve.dm.Document
* Added getNearestWordBoundary method which performs the work behind the surface fragment expandRange word method

ve.ce.SurfaceObserver
* Allow using an initial selection to avoid the observer thinking the selection has changed just because it started out with null
* Only emit selectionChange event if there was a meaningful change

ve.ce.Surface
* (bug 42279) Only annotate characters if insertion annotations are not empty
* Remove manual locking and unlocking, this is now done inside the change method of surface model
* Provide an initial selection to surface observer when we clear it
* Remove enabling and disabling of insertionAnnotations, this isn't needed anymore
* Stop/start observer on key presses that execute actions as well as those that have no special handling

ve.ce.Document
* Make getNodeFromOffsetand getSlugAtOffset return null when given -1 as an offset

Change-Id: Ibf6b26de299e54ae8688a2653bf5d5538927f8c3
2012-11-21 15:26:12 -08:00
Trevor Parscal c9d6d35968 (bug 42219) Fix for document sync issue
When working with a document containing only a slug in an empty paragraph, tree synchronization would break because it was trying to rebuild a non-existent text node.

This change makes the rebuild always occur on the outer range, rather than the inner range, which prevents absent text nodes from being asked to be rebuilt.

Thank you to Roan for debugging this for like 20 min.

Change-Id: I8c3dad921ace395f0694f77cec44305a680657fe
2012-11-21 14:59:09 -08:00
Trevor Parscal b6139ba65e Merge "(bug 42124) Store comments in the meta-linmod" 2012-11-21 22:12:41 +00:00
Trevor Parscal 43b2c86102 Merge "(bug 42140) Don't force spaces to underscores in internal links" 2012-11-21 22:00:24 +00:00
Trevor Parscal f825e0093a Merge "(bug 42212) Fix JS error when inserting after alien at the end" 2012-11-21 21:56:19 +00:00
Catrope bf7b243627 (bug 42121) Change markers lost for first paragraph on new page
When editing a new page, or loading an empty page into the editor, the
converter generates a paragraph so the document isn't completely empty.
This paragraph is then unwrapped on the way out, potentially destroying
change markers and generally producing strange HTML output.

Mark this paragraph with generated=empty rather than generated=wrapper,
and only unwrap it on the way out if it's still empty. This means we
cleanly round-trip empty documents (and empty list items and the like),
but if the user enters text, we create a paragraph like we're supposed
to.

Change-Id: Id0241221a67b769445676b833b5741320d99ea5f
2012-11-21 13:54:52 -08:00
Catrope 662880605c (bug 42119) Handle alienation in wrapping mode properly
When alienating in wrapping mode, we need to look at the type of tag to
decide whether to create a wrapped alienInline, or to interrupt the
paragraph for an alienBlock.

This was being done just fine for the general alienation case
(unrecognized tag), but not for the special cases (mw:unrecognized,
about groups).

* Centralize the logic for ending a wrapper in stopWrapping()
* Move the wrapping-contingent block/inline detection logic into
  createAlien()
* Simplify the terrible if statement to decide whether a future decision
  requires us to stop wrapping. Instead, detect the cases in each code
  path separately and call stopWrapping() as appropriate
* Add tests

Change-Id: I4054584ae05e7d5daa71edead3e6a6588cf5d3bb
2012-11-21 13:42:13 -08:00
Trevor Parscal e0e5e43303 Merge "Make entity nodes work in CE" 2012-11-21 21:25:03 +00:00
Catrope 9f1eb9b991 Merge "(Bug 42335) Adding IE to the browser blacklist for the December release" 2012-11-21 20:33:17 +00:00
James D. Forrester 1780d4e610 (Bug 42335) Adding IE to the browser blacklist for the December release
Unfortunately support for Internet Explorer is currently insufficient in the CE module
which means we have to kill it for December; it will return once we've worked out a way
around various bugs in IE.

Change-Id: I0b44ae2c1d75ffe748a5139ca74dcda615e12a6a
2012-11-21 12:30:14 -08:00
Catrope 6230c322ec Merge "Fixed inspector behavior" 2012-11-21 20:23:35 +00:00
Catrope 0516b1d7f0 Make entity nodes work in CE
Check for all node classes in getOffsetFromTextNode(), not just
branches and aliens (an entity is neither)

Render entities with contenteditable=false. Without this, selection was
still broken, because:

Foo|€Bar was really <p>Foo<span>|€</span>Bar</p> which maps correctly.
Foo€|Bar was really <p>Foo<span>€|</span>Bar</p> which maps to the same,
which is incorrect.

With cE=false, the cursor can't be inside the span, so we get:
Foo|€Bar is really <p>Foo|<span>€</span>Bar</p> which maps correctly.
Foo€|Bar is really <p>Foo<span>€</span>|Bar</p> which maps correctly.

Change-Id: Iaf603346590a9ad553c152565eb203136be7a399
2012-11-21 12:04:31 -08:00
Trevor Parscal 8fc98868c9 Fixed inspector behavior
ve.ui.Inspector
* Removed disabled state and interfaces - this isn't needed
* Renamed prepareSelection to onInitialize
* Using event emitter to run onInitialize, onOpen and onClose methods
* Left removal up to the child class to handle in the onClose method
* Replaced calls on context to close inspector to calling close directly
* Renamed prepareSelection stub to onInitialize
* Emitting initialize event from within the open method
* Added recursion guarding to close method
* Changed the close method's argument to be remove instead of accept - the more common case is to save changes, and the only time you wouldn't save changes is if you were to remove the annotation
* Moved focus restore to close method

ve.ui.Context
* Moved the majority of the code in openInspector and closeInspector to event handlers for onInspectorOpen and onInspectorClose
* Updated calls to closeInspector re: accept->remove argument change

ve.ui.LinkInspector
* Renamed prepareSelection to onInitialize and rewrote logic and documentation
* Removed unused onLocationInputChange method
* Moved restore focus (now it's in the inspector base class)

ve.dm.SurfaceFragment
* Added word mode for expandRange

ve.dm.Surface
* Added locking/unlocking while processing transactions - this was not an issue before because this was effectively being done manually throughout ce (which needs to be cleaned up) but once we started using the content action to insert content dm and ce started playing off each other and inserting in a loop - we already do this for undo/redo so it makes sense to do it here as well

ve.InspectorAction
* Updated arguments re: close method's accept->remove argument change

Change-Id: I38995d4101fda71bfb2e6fe516603507ce820937
2012-11-21 12:01:14 -08:00
Catrope 1234a702c9 (bug 42218) Add MWEntityNode
<span typeof="mw:Entity"> tags are now correctly represented in the
model, and rendered in CE. There are still issues with cursor movement
etc. in CE.

Because the prioritization mechanism for annotations vs nodes is broken
in the current "node API", I had to hack two special cases for mw:Entity
into the converter. I also had to change the converter to ignore the
children of inline nodes (this was a legitimate bug, but had never come
up before).

Change-Id: Ib9f70437c58b4ca06aa09f7272bf51d9c41b18f2
2012-11-20 16:19:55 -08:00
Catrope 3a047e0208 (bug 42124) Store comments in the meta-linmod
* Make converter generate meta nodes with 'style': 'comment'
* Handle style==='comment' in MetaBlockNode toDOM converter
* Add some comments to the meta test case
** Update other tests accordingly
* Change getDomElementSummary() to actually assert presence of comment
  nodes (specifically, all non-text child nodes)

Change-Id: Ieef9418f4c47df3541477d9420aa2ab8df6e3df1
2012-11-19 20:01:09 -08:00
Catrope fda2e6c1b5 (bug 42140) Don't force spaces to underscores in internal links
MWInternalLinkAnnotation was normalizing spaces to underscores. This is
bad. Instead, we now do the following:
* Normalize underscores to spaces for display purposes
* Store the original title without underscore/space mangling
* If the user didn't change the title (display title === original title
  with s/_/ /g), use the original title. Otherwise use the user's title
  verbatim, without normalizing either underscores or spaces.

Also, per a conversation with Gabriel, we now only restore hrefPrefix
when we're also restoring origTitle, otherwise Parsoid will barf.

Change-Id: Ia74a493b2bce96c9345b60ed692eeb2e43ebceff
2012-11-19 18:55:49 -08:00
Trevor Parscal 05e39c1733 Always apply inspected annotations to the right range
When you leave the inspector by changing the selection, we need to apply changes to the old selection.

ve.ui.Inspector
* Added initialSelection
* Change getMatchingAnnotations to use a given fragment rather than generating it's own
* Set initialSelection on open

ve.ui.Context
* Make hiding the context accept changes

ve.ui.LinkInspector
* Passing a fragment into getMatchingAnnotations now
* Using fragment API instead of actions API to control the range of the fragment

Change-Id: If6c8845285d87d0f144b15d50c38e192c797be59
2012-11-19 17:54:55 -08:00
Catrope a833691421 Merge "Fixing Pre-Annotations" 2012-11-20 01:11:04 +00:00
Catrope f856a10fa0 Merge "Added undo-before-apply for new link annotations" 2012-11-20 01:10:29 +00:00
Trevor Parscal 9c22ee346a Added undo-before-apply for new link annotations
When the link inspector is used to create a new annotation, the text is annotated with the default link target derived from the selected text. Then if the inspector is used to change that value, yet another transaction is processed when the inspector is closed.

To avoid having to press undo 2x, this change makes the inspector undo it's first change before applying the changed annotation.

This change also introduces insert, remove and select content actions.

Change-Id: I3e29189158fb01336d6b053bc2a8bda2a91a0a46
2012-11-19 17:10:05 -08:00
Christian Williams 9787166bab Fixing Pre-Annotations
AnnotationAction and SurfaceFragment now use insertAnnotations.

ve.dm.Surface.test
* Removed test for annotate method (not needed anymore)

ve.dm.SurfaceFragment
* Now using getInsertionAnnotations method
* Added support for modifying insertion annotations when annotating a zero-length selection

ve.dm.Surface
* Moved in insertion annotations state from document model
* Added insertion annotation interface (enable, disable, areEnabled, get, set, add, and remove)
* Simplified handling of annotations on change
* Removed annotate method (not used anymore)

ve.dm.Document
* Removed insertion annotations (moved it to surface model)

ve.ce.Surface
* Cleaned up handleInsertion and changed it to use the insertion annotations interface on the surface model

ve.AnnotationAction
* Moved insertion annotation handling out of here since it's now included in the surface fragment

Change-Id: I047d656acf7fa1c63f726ca2b0801e1476f84f96
2012-11-19 17:09:08 -08:00
Trevor Parscal 96fcbbd695 Cleanup var statements
Put non-assignment vars first

Change-Id: Id868976bc4d7c21032aef5020fe5fd0eb5df7a14
2012-11-19 17:05:34 -08:00
Catrope 22a01bfc4f Merge "The great inspector and context rewrite of 2012" 2012-11-19 23:23:48 +00:00
Trevor Parscal d2476a26d2 The great inspector and context rewrite of 2012
ve.AnnotationAction
* Added filter to the clearAll method to allow clearing all matching annotations only

ve.dm.Document
* Some variable renaming for consistency

ve.dm.SurfaceFragment
* Added truncateRange method
* Added annotation scope to expandRange method
* Added support for passing an annotation object into annotateContent method
* Switched to using name instead of type in annotateContent method to match the ve.dm.Annotation class
* Fixed logic in annotation mode of expandSelection so that expansion only takes place if the annotation is found

ve.ui.LinkInspector
* Moved most of the functionality elsewhere
* General reorganization
* Changed setOverlayPosition to accept 2 arguments instead of an object with 2 properties and renamed it to positionOverlayBelow
* Check for annotation object before extracting target information from it
* Initialize default target as empty string to avoid undefined being cast to a string and the default target becoming 'undefined'

icons.ai, inspector.png, inspector.svg
* Added generic inspector icon which will be used when a custom icon is not specified in future inspector subclasses

ve.ui.Inspector.Icons
* Added inspector icon
* Renamed clear icon to remove to match it's actual image

ve.ui.Context
* Greatly simplified the interface, reducing the number of methods by inlining a few things and combining others
* Now always listening to resize events on the window rather than only while document is focused
* Not listening to scroll events anymore, they used to affect the top/bottom positioning of the menu which we don't do anymore
* Lots of cleanup and reorganization
* No need to fallback to empty array since getInspectorsForAnnotations does so already
* Only consider fully-covered annotations for inspectors

ve.ui.Frame
* Simplified the constructor by introducing the createFrame method
* General cleanup
* Typo fixes

ve.ui.Inspector
* Generalized lots of functionality previously located in the link inspector class which will be useful to all inspectors (such as title, clear button, saving changes, etc.)
* Added setDisabled and isDisabled methods to manage CSS changes and avoid needing to check the CSS to determine the state of the inspector (storing state in the view is evil)
* Added getMatchingAnnotations method for convenience
* Added prepareSelection stub
* Lots of cleanup and documentation
* Type pattern is now defined in base class
* Added stubs for onOpen and onClose with documentation so that subclass authors know what these methods do
* Removed checks for onOpen or onClose methods since they are now noop stubs and are always there
* Added stub and removed checks for onRemove
* Made esc key close and accept - the illusion is supposed to be that the link changes are applied instantly, even though they are only updated when you close, so all closing except for when removing should apply changes - i.e. esc is now equal to back rather than being a special function that doesn't have an associated affordance
* Only consider fully-covered annotations when getting matching annotations

ve.ui.InspectorFactory
* Depending on type pattern now since it's always there
* Added getInspectorsForAnnotations method
* Return empty array if annotation set is empty

VisualEditor, VisualEditor.i18n
* Added default inspector message

Change-Id: I1cc008445bcbc8cba6754ca4b6ac0397575980d5
2012-11-19 15:21:27 -08:00
Catrope 79e4b139fb (bug 42212) Fix JS error when inserting after alien at the end
TransactionProcessor was using parentOuterRange without checking whether
it was present, so it was exploding for indexInNode results.

Now checking for parentOuterRange presence, and falling back to
nodeOuterRange when missing.

This fix causes inconsistencies with zero-length text nodes. We should
fix these eventually, but for now I've just made the unit tests
tolerant of zero-length-text-node deviations.

Change-Id: Id9eadd57a0d5fcbaf009c0781da0a03928aebb31
2012-11-19 14:35:30 -08:00
Catrope 7fb9b1c09a Merge "(bug 42123) Add i18n for aliennated content tool tip." 2012-11-17 01:08:07 +00:00
James D. Forrester c7fd1819a3 (bug 42123) Add i18n for aliennated content tool tip.
Change-Id: Ibb98d256fb989cd69407b487df673ee22f8c9758
2012-11-16 16:52:22 -08:00
Trevor Parscal 2c8411eb62 (bug 41947) Propagate change markers when unwrapping generated nodes
Editing the text of a list item results in a change marker on the
paragraph within that list item. However, that paragraph usually isn't
present in the HTML, so the converter unwraps it when converting back to
HTML, and the change markers are lost. Instead, transfer the change
markers to the <li>.

Change-Id: Id675075d19c08d69bc8e990174841dc393b749fc
2012-11-16 15:39:35 -08:00
Catrope 29a0c38e05 Add ce.AlienNode to tests
Change-Id: I591501067732ae36c89da340398ad35e8d4b6e3d
2012-11-16 15:35:09 -08:00
Christian Williams 1932e0907f Phantoms not vanishing on mouseout
If the mouse is moved too quickly, the phantoms have a tendency to stick. This change moves the event from phantom.mouseleave to surface.mousemove.

Change-Id: I2c7e7bdc838427d4355a6c0c13bafe3198636dbe
2012-11-16 11:32:59 -08:00
Inez Korczyński ebbd297841 (bug 42134) Add shields after node is attached to the live DOM
This changeset introduces new variable property of ve.ce.Node called "live", which stores information whether or not given node is attached to the live DOM. When the value of this property changes event "live" is called.

Change-Id: I6d0ce923c25ff2c4015914f367582c9a15e62c65
2012-11-15 14:17:12 -08:00
Christian Williams fcfca947a9 Better Shield Logic
jQuery.css('float') returns different null values for Chrome and Firefox. This fix takes this into account and applies shields only to aliens and floated descendants.

Change-Id: I4c1db148043ee95991a17720dee8febad62c415a
2012-11-14 18:38:42 -08:00
Christian Williams 9f4a4d9e92 Disable Table Editing
Native contenteditable execCommands were being tried before the surface was attached to the DOM. This is necessary for disabling native contenteditable object editing and resizing.

Change-Id: Idff6a30432396726deb8a38356172380ea12fced
2012-11-14 17:14:45 -08:00
Trevor Parscal 17b33dc94e Merge "(bug 41722) Remove use of the Feedback tool for December release" 2012-11-15 00:24:50 +00:00
James D. Forrester 42fb99728b (bug 41722) Remove use of the Feedback tool for December release
We do not want to use the Feedback tool for the December release, as it does not
work cleanly with LiquidThreads and would strand most users in an unfamiliar
wiki and expect them to have more complex/technical responses than they are
likely to be able to give; instead, have just purged it entirely from the code
(except for i15d strings, per Roan).

Change-Id: Ieebdca3d365943d901e2df37228120fdcff50afd
2012-11-14 16:16:52 -08:00
Trevor Parscal e808e67a64 Merge "Display overlay phantoms for inline blocks (no need to use shields)." 2012-11-15 00:11:21 +00:00
Trevor Parscal ba01a76363 Merge "Support for node HTML attributes" 2012-11-15 00:05:16 +00:00
Catrope 8a2781356c We'll want a 100s timeout, not 10s
Barack Obama takes 60s to parse, according to Gabriel

Change-Id: I1a63225c0961ca9d56dccd018d400831b1d528e9
2012-11-14 16:02:36 -08:00
Catrope b133c52ce8 Merge "Temporary quick fix for BugId 41223. It is just for release purpose and I will keep working on solid solution." 2012-11-14 23:04:26 +00:00
Inez Korczyński 4c7f3d2182 Temporary quick fix for BugId 41223. It is just for release purpose and I will keep working on solid solution.
Change-Id: I3f428f88b0e8d6d837f1dfd9d269ca3c99147ed7
2012-11-14 15:02:40 -08:00
Trevor Parscal fc7c0e7d4c Merge "<br> isn't a block element" 2012-11-14 22:48:36 +00:00
Trevor Parscal f9b2f94659 Merge "Rewrite ve-parsoid API module" 2012-11-14 22:48:14 +00:00
Catrope 50f94d53da Rewrite ve-parsoid API module
* Factor out getHTML(), postHTML(), saveWikitext() and parseWikitext()
* Use the API to save instead of using doEdit() directly
** This fixes a lot of integration bugs
** Get rid of the blocked user check, edit API checks this
* Check the namespace parameter
* Require tokens and POST
* Add diff functionality

Change-Id: I31891d1485985629db4e39532fb34e0e7fe23796
2012-11-14 14:47:20 -08:00
Inez Korczyński 2da5676fe1 Support for node HTML attributes
Walk through node model attributes and pick just the HTML ones, then apply them to the DOM element

Change-Id: I7e0ffd71023ad692fcad7386b853410747398793
2012-11-14 14:22:03 -08:00
Trevor Parscal 61a5d2137e Merge "Disable change marking by default" 2012-11-14 21:53:32 +00:00
Inez Korczyński 0d15980638 Display overlay phantoms for inline blocks (no need to use shields).
Change-Id: Ife362035c43daf863a3b6a5f892dc928d1f6ec80
2012-11-14 13:43:03 -08:00
Christian Williams 836f7dea9e Alien Phantoms
This changeset adds a visual treatment to uneditable AlienBlockNodes to indicate to the editor that the elements are uneditable. To deal with odd shapes, the alien's shields are cloned and added to a phantom container. The phantom container and the phantoms themselves may be styled appropriately.

Change-Id: I7ad52707966bc18be627aa4269725004edba86cd
2012-11-14 13:11:29 -08:00
Catrope 3acc6cb8f4 Disable change marking by default
It's causing problems with Parsoid in production

Change-Id: Id47493baafe1ec7f7c0e2bbdb2ea60a82913dfaf
2012-11-14 11:58:32 -08:00
Catrope c8661c0033 <br> isn't a block element
Also remove commented-out <img>

Change-Id: I7dc9f3b23c15008047cad938ed3408f55ea568d2
2012-11-14 11:27:49 -08:00
Inez Korczyński 72c564b47f (bug 41072) Add support for adding outer length in ve.ce offset getters
ve.ce.getOffsetFromElementNode now supports adding outer length
of given node to status functions.

It is temporary solution that I will review in the future.

Change-Id: If779802156aa78dbced9d4c769e8e7877120b337
2012-11-13 11:17:59 -08:00
Trevor Parscal 151db97a94 Merge "Fix JS error in unlisting" 2012-11-13 18:26:13 +00:00
Trevor Parscal da1d7e4a70 Merge "Nicely highlightable alien nodes" 2012-11-13 18:25:27 +00:00
Christian Williams e03cef06a7 Nicely highlightable alien nodes
Browsers handle highlighting of our alien nodes differently. This change normalizes by hiding the native selection on the aliens, inserting blank image "shields" with native highlighting enabled.

Change-Id: Ica3576ef0e3c42b4aeae1da374cd1dc92f203d7d
2012-11-13 10:25:05 -08:00
Inez Korczyński 27ddb456c8 Fix for ve.ce.BranchNode.setupSlugs - insert each slug only once
When using jQuery insertBefore and insertAfter make sure to pass as a parameter jQuery selection of only one element (first for insertBefore and last for insertAfter).

Change-Id: Id469ed775642ab5be8e274ab3cb7730899e9487a
2012-11-12 15:32:22 -08:00
Catrope 2952ff344e Fix JS error in unlisting
The signature of getUnlistRanges() changed in the UI rewrite, but the
recursive call wasn't updated. This caused unlisting of lists that
contain lists to break and throw a JS error.

Change-Id: I990120a906868a5160561cff6b963f5ba5473427
2012-11-09 14:14:04 -08:00
Trevor Parscal 5f56694b75 Merge "Add basic support for about groups" 2012-11-08 18:23:19 +00:00
Catrope d4ea93b872 Add basic support for about groups
About groups are HTML structures like the following:
<div about="#mwt1">....</div>
<span about="#mwt1">...</span>
<div about="#mwt1">...</div>
When about groups are alienated, they are now merged into one alien
node, rather than producing a separate alien node for each sibling.

This is very basic about group handling, because it only works for
groups of directly adjacent siblings (text nodes are permitted in
between, but nothing else) assumes all about groups are aliens (which
is currently true).

* Before processing an element in the DOM->data converter, perform about
  grouping on its children. This temporarily wraps about groups in
  <div data-ve-aboutgroup="value of about attribute">
* Extended createAlien() to handle single nodes as well as wrappers
  holding multiple nodes.
* In the data->DOM converter, temporarily wrap multi-node aliens in
  <div data-ve-multi-child-alien-wrapper="true"> . This makes the rest
  of the algorithm easier.

Change-Id: I2df5f62bc222b570fc11a89fe43d353f8363ead8
2012-11-07 18:13:50 -08:00
Trevor Parscal bd72ee65d8 Added some more key bindings for IE and Mozilla support
Change-Id: Ic4bcd53d41fcd676d5929bfb94d0cbf3afb6968e
2012-11-07 16:49:34 -08:00
Catrope f10ca89888 Merge "Mapped tab key to indentation action" 2012-11-08 00:31:10 +00:00
Trevor Parscal 614dd307f7 Mapped tab key to indentation action
* Added cancelable action return value to surface execute method

Change-Id: I57a58962399a46a0e41b4e95e438dc528770d619
2012-11-07 16:26:13 -08:00
Catrope 7052730628 Merge "(bug 41865) Make the save button available immediately for oldid pages" 2012-11-08 00:05:17 +00:00
Catrope 03827764a7 Merge "Refactored commands into a registry" 2012-11-07 23:52:59 +00:00
Trevor Parscal 443c5438ab Refactored commands into a registry
* Now ve.Factory inherits from the more general ve.Registry
* New class ve.CommandRegistry
* Refactored setupToolbar and command setup code into setupComands

Change-Id: Ic548e5de95b77889727362d3e66d7be83c12a603
2012-11-07 15:52:30 -08:00
Catrope 3d76ce60fe Merge "Replaced command factory with new command class" 2012-11-07 23:51:19 +00:00
Trevor Parscal ab57bed7da Replaced command factory with new command class
The port of mousetrap wasn't really what we needed. This is much simpler, matches the rest of our code, and does exactly what we need.

Change-Id: I67f413e097fc2d4078336edb14dd9440e771f196
2012-11-07 15:47:03 -08:00
Catrope 66efe62108 Merge "Fixed line-height variations between sa and mw integrations" 2012-11-07 23:43:39 +00:00
Christian Williams 05c3e088d0 Fixing native selection rendering for floats
This fixes a problem with how Chrome renders native selection around floated elements. By adding pseudo elements before and after block aliens, the rendering is fixed.

Change-Id: I7fdbb8f4c42e29d0574b308b8c5740066bb58e94
2012-11-07 15:07:43 -08:00
Trevor Parscal f4a674e2c5 Merge "Flag pre nodes as having significant whitespace" 2012-11-07 22:12:45 +00:00
Trevor Parscal 66b3f5364d (bug 41865) Make the save button available immediately for oldid pages
Also consider making it say "Restore page" initially for oldid pages until a change is made

Change-Id: I9e5ce76520e091612afe4fbc0300cff8ca645335
2012-11-07 13:57:13 -08:00
Trevor Parscal 273c6ac7bd Made commandFactory tests not break anymore
Sequences that were scheduled directly after each other, such as "a b c" and "1 2 3" would end up overlapping sometimes, producing "a b 1 c 2 3" which failed to trigger the correct commands.

Change-Id: I27bb60e856e9d692a21e1587dc227f8aeb5fcf4e
2012-11-07 13:56:53 -08:00
Catrope 1f01100eb9 Flag pre nodes as having significant whitespace
This causes the converter not to strip inner whitespace in them, and
causes CE to suppress the whitespace mangling logic that is normally
applied (↵ for newlines, ➞ for tabs, alternating &nbsp;s for spaces).

Change-Id: I738a750c91a4ca4836c485e282865bb7525bf30a
2012-11-07 12:10:58 -08:00
Trevor Parscal 6082953562 Made jquery.multiSuggest it's own RL module
* Also updated resource paths in tests and demo pages

Change-Id: Ic21b678f91ed8d1fe1c7ac2a53d89270aacf7c26
2012-11-06 16:37:01 -08:00
Trevor Parscal cd58340f1c Removed introduction of global variable
resetSequences was being called in the context of window instead of a contextFactory

Change-Id: I1b9ee25547bd18d59eac4b991ecc813b81f92a4c
2012-11-06 10:52:30 -08:00
Trevor Parscal cab7f84b55 Fixed line-height variations between sa and mw integrations
* Also fixed format drop-down's preformatted label styling

Change-Id: I983ff71959f5e78e52fbe4c585db20357b7ca2d5
2012-11-06 10:24:58 -08:00
Catrope 04a999f991 Add change marking for Parsoid's benefit
* Add map of change markers per offset to Transaction
* Map is populated by TransactionProcessor
* Markers are reversed on rollback
* Removals aren't marked, Parsoid can detect these using DSR
  discontinuities

Change-Id: I2290886ab411c6ad6162044ed85c091313613e51
2012-11-06 10:11:11 -08:00
Trevor Parscal 1e3f42f764 Merge "Styling aliens with a yellow background; preventing absolute positioning" 2012-11-06 00:09:41 +00:00
Trevor Parscal 692a67dc3d Merge "Integration revamp for December release" 2012-11-05 23:19:10 +00:00
Christian Williams 901eea203e Styling aliens with a yellow background; preventing absolute positioning
Change-Id: I86fbbda841d69beeabf4e683de3b032fb70b1ac6
2012-11-05 14:22:10 -08:00
Trevor Parscal d2b839a2cb Fixed font-size issues for monobook integration
Change-Id: If71fbd186979777b73c84f64610c8485017de654
2012-11-05 13:32:06 -08:00
Catrope efbb94e548 Merge "Improved the responsiveness of the context menu" 2012-11-05 20:52:58 +00:00
Trevor Parscal 4e377480cf Improved the responsiveness of the context menu
* Added selectionStart and selectionEnd events to ve.ce.Surface
* Switched from debouncing model change events to just ignoring
  model change events while the user is in selection mode
  (dragging mouse or pressing shift+arrow keys)
* Fixed bug with callout appearing on resize.

Change-Id: I3bb9952867a983a4f7612964ff719a1179dd0fc6
2012-11-05 12:47:47 -08:00
Catrope 4d7952d55c Integration revamp for December release
* Remove VisualEditor namespace, and restrictions on it
** For MW.org these will be moved to mediawiki-config
* Add $wgVisualEditorNamespaces
* Add visualeditor-enable preference and respect it
* Use $skin->getTitle() rather than $wgTitle
* Remove "Sandbox" from i18n message
* Remove duplicate enforcement of VE namespace from JS

Change-Id: I956f68c2dde55e4063530fcc7c90eda048e0d78b
2012-11-05 12:46:14 -08:00
Trevor Parscal 0b6c6e7bf1 Merge "Introduce meta-linmod" 2012-11-05 19:01:32 +00:00
Trevor Parscal 289e762812 Removed ve.init's dependencies on ve.ui styles
* Things broke when ve.ui stuff was refactored
* Save dialog is now completely stand-alone

This is an alterantive to Ib028e6967e8d2e158b05fd7582620c21cf9b85fb
which I believe is a better approach.

Change-Id: I7cb52d0750e859c4052e2008d929d197b88b9877
2012-11-05 10:35:36 -08:00
Catrope 857535b63f Introduce meta-linmod
* ve.dm.Converter still generates metaInline/metaBlock elements as
  before, it's not affected by this change
* ve.dm.Document constructor splits its input into "real" data and
  metadata
** Metadata is stored in this.metadata (the meta-linmod) as a sparse
   array of arrays, with an element for each offset in this.data
** this.data itself does not contain the metadata
** This means the node tree also doesn't contain the metadata
** Which means CE doesn't know about it at all
* All splice operations on the linear model are sent through
  ve.dm.Document.spliceData(), which performs the splice and syncs the
  meta-linmod
** Metadata in the removed range is reaped and added to the metadata for
   the offset immediately following the removal
* ve.dm.Document.getFullData() splices the linmod and meta-linmod back
  into each other; this "full data" is then fed back to ve.dm.Converter

Change-Id: Ief6dfd5b59cc13a8457993ed85c725413029c4fb
2012-11-02 19:06:49 -07:00
Trevor Parscal d631bac3db Merge "Base for inspectors & context menu to operate on 0 length selection." 2012-11-02 21:38:14 +00:00
Rob Moen 5d86bc4379 Base for inspectors & context menu to operate on 0 length selection.
* Allow inspector to open with 0 length selection.
* Allow context menu to open with 0 length selection.
* Fixed bug in doc.getAnnotationsFromRange on zero length selection:
  Method now returns annotations from start vs empty annotation set.

Change-Id: I3937c5c2824c7396d0c3ee11c13ffecdbed6052a
2012-11-02 13:08:32 -07:00
Catrope 471836ef35 Merge "Cleanup tool API" 2012-10-31 18:23:45 +00:00
Trevor Parscal a4e0e83f24 Cleanup tool API
* Moved to tool specific configuration to static properties (left tool instance specific stuff in the constructors)
* Added documentation for tool configurations
* Centralized typePattern matching for inspectors

Change-Id: Ieacf61b320c10fd37ea69a05e543313fa990b403
2012-10-31 11:10:17 -07:00
Catrope 6ef9fa78ff Fix ve.batchSplice() to behave in line with docs
* Actually return the spliced data like the docs claim we do
* Remove false claim that offset can be negative
* Add that data=[] && remove=0 is invalid; native splice() doesn't allow
  this, and there is a case where we call native splice() directly
* Add tests

Change-Id: I90e77c1b22ea1c36cb61e89ea47831885a0b1cb9
2012-10-30 10:05:49 -07:00
Trevor Parscal 82a15d66fc Merge "Fix copyObject/copyArray behavior with null values" 2012-10-30 16:59:02 +00:00
Catrope d30096ebd3 Fix copyObject/copyArray behavior with null values
Previously copyObject and copyArray would silently drop null values,
which is bad, especially considering we have example data for meta nodes
that has { 'key': null } somewhere.

Also added a test case that failed prior to this change.

Change-Id: I4f233cce041fbf38f701c494f1f78ac3d8535d88
2012-10-29 19:45:25 -07:00
Catrope 6df508cf8b Add InspectorFactory to tests
Tests were completely broken because the link inspector threw a JS error
when trying to register itself with the nonexistent inspector factory.

Change-Id: I8a47222f0a5a37348262ed939b37fbc47d14e222
2012-10-29 18:36:54 -07:00
Rob Moen 765f7589ac Fix bug where link inspector / context overlay would no longer show.
Change-Id: I73281dc32eae5660662898d0290468434e7326d9
2012-10-29 10:56:11 -07:00
Trevor Parscal f2a83960f8 (bug #41434) Converting format across 2 lists with paragraphs in between fail
Thanks to Roan for suggesting this fix.

Change-Id: I754dc34fbd3aaf2bdcb78bf89bfc896b612b4ee6
2012-10-26 15:18:44 -07:00
Trevor Parscal 21ea11c161 Really properly initialize static member before adding stuff to it
Kill them console log errors 'til they're dead.

Change-Id: I7329f4c869f46a9ef664af8ab49cb2504abdf972
2012-10-26 15:10:01 -07:00
Trevor Parscal cd0b28d407 Properly initialize static member before adding stuff to it
This was causing a console error

Change-Id: Ic394cf4d4821bd7c03fd32bb9e202801dccde085
2012-10-26 15:02:24 -07:00
Catrope a87ffeefa1 Merge "Whitespace and comment cleanup on ve.ce.SurfaceObserver" 2012-10-26 21:59:00 +00:00
Trevor Parscal 3142a4e66f Add commands to ve.Surface
First stab at a simple command interface. This and commandFactory
will be refactored significantly before this code is put into
action.

Change-Id: I0de5d3271198c987baf06fb3011aebdc1671f498
2012-10-26 14:50:23 -07:00
Trevor Parscal 238feeb881 Tools changes
* Rewrite of all tools, dramatically simplifiying them and decreasing
  duplication
* Tools are now created using a tool factory instead of
  a make-shift facility built into the toolbar
* All UI object have a surface or a toolbar reference instead of a
  surface view

Change-Id: I589ecba36bf715b452d03c8fd5c0547dc3c1dc61
2012-10-26 14:48:27 -07:00
Rob Moen 9563f0880d UI context reorganization, inspector rewrite, iframe refactor, icon generalization
* Only show the inspector if the selected text has an inspectable annotation
* Replace the inline menu with a toolbar containing inspectable annotations
* Change the appearance of the inspector to match new mockups
* Add the trash can icon for removing annotations
* Move iframe handling code into a class that manages all that nonsense

Change-Id: I840f72426f9a9e50054a28de950393f0e9913153
2012-10-26 14:46:11 -07:00
Trevor Parscal 735ed96f5f Add ve.Action, ve.ActionFactory, subclasses
Moved implementation of all the tools into a reusable action
system. To execute an action just call

surface.execute( actionName, method, param1, param2, ... );

This helps keep tools simple, and opens the door to key commands
reusing the same code.

Change-Id: Ie786fa3d38d1ea17d39b5dfb8eeeb5f2256267ce
2012-10-26 14:44:17 -07:00
Trevor Parscal ed7273da25 Add ve.dm.Surface.has{Past,Future}State, add docs
Will be used by the history tools in a future commit, providing
a reasonable interface to this information rather than the tool
reaching into private members.

Change-Id: I0472349968e9b48ec17eb47b6845ec9ccf3811e2
2012-10-26 14:43:09 -07:00
Trevor Parscal fcbe1d7b9c Add ve.dm.Node.hasAttributes()
Will be used in future commits to reduce duplication.

Change-Id: Ibde934d5a55b980010e84b6242f8d968e88cea54
2012-10-26 14:42:40 -07:00
Trevor Parscal 79944333a4 Add ve.dm.Node.hasMatchingAncestor()
Will be used in future commits to avoid traversing up the tree and
comparing type and attributes.

Change-Id: I993f4cbe20018406dbb4a3c9d1ce2f8766f8e1ba
2012-10-26 14:41:49 -07:00
Trevor Parscal 7d741253f3 Add ve.dm.SurfaceFragment.getAnnotations()
Change-Id: Ifb731e8fdd0f111f5da4ac0d882adaad3f48fdce
2012-10-26 11:03:51 -07:00
Catrope bc8b042e5f Merge "Fix annotation object creation in SurfaceFragment" 2012-10-26 17:53:10 +00:00
Trevor Parscal 44a78129c4 Whitespace and comment cleanup on ve.ce.SurfaceObserver
Change-Id: Ice4058f1041f3d0118c7955122b8ea4d538790e0
2012-10-26 10:27:54 -07:00
Trevor Parscal 52f1aac90a Merge "Test: Enforce # of expected assertions." 2012-10-26 16:48:18 +00:00
Krinkle b6b899c396 Merge "Documentation fixes" 2012-10-25 21:19:05 +00:00
Timo Tijhof 4cc2101ffd Test: Enforce # of expected assertions.
Change-Id: I041c792d1841f69677f8c7d38f67108475a0afc9
2012-10-25 22:06:07 +02:00
Krinkle dae235111c Merge "Fix JS error in ve.setProp()" 2012-10-25 19:55:16 +00:00
Catrope 84efb81e7e Fix JS error in ve.setProp()
Attempting to descend into a string or number would cause a JS error,
because we would attempt to create prop[arguments[i]] as an empty object
(which is ignored), then try to descend into it (which blows up because
it's undefined, even though we've just set it). Guard against this by
explicitly checking for non-object-ness.

Change-Id: Ie65550baaae0ab88476c9a1ff40cc136090740a0
2012-10-25 21:54:45 +02:00
Trevor Parscal 4e87a7a79b Fix number of doc sync tests
Follow up to I84f0368b1d7b601ed0766806607152dc97f34603

Change-Id: Ic1e9de1e755b8966b6e964b01b00f4d99d27245e
2012-10-25 11:06:12 -07:00
Catrope 2c1683ecff DocumentSynchronizer fix and cleanup
* Adjust the range in the annotation synchronizer, otherwise we emit
  events for the wrong node
* Expanded test suite to the point where it was able to catch the bug
  caused by not adjusting annotated ranges
* Removed selection.length === 0 check, no longer needed because
  selectNodes() now throws an exception in this case
* Added a FIXME comment about duplicate update events that occur when
  length adjustments are combined with something else
* Add a few more comments

Change-Id: I84f0368b1d7b601ed0766806607152dc97f34603
2012-10-25 11:02:58 -07:00
Trevor Parscal 551a30bc64 Merge "Actually use nodeOuterRange, selectNodes() has provided this forever" 2012-10-25 18:00:15 +00:00
Trevor Parscal fe5c5b78f9 Merge "Reorganize text-only replacement detection" 2012-10-25 17:56:45 +00:00
Trevor Parscal 8e7facf222 Merge "Guard transactions against double commit/rollback" 2012-10-25 17:55:56 +00:00
Trevor Parscal 9c51bb2d7b Merge "No longer copy data in ve.dm.Document constructor" 2012-10-25 17:54:23 +00:00
Catrope f1dbdac3d8 Actually use nodeOuterRange, selectNodes() has provided this forever
Change-Id: Ie1d3cbb6e475248927d10f411cf383f701a3ad71
2012-10-24 17:48:48 -07:00
Catrope 5d5335b498 Reorganize text-only replacement detection
* Lift node assignment out of the if/else
* Flip the condition so we detect text-only replacements rather than
  non-text-only replacements
* Additionally assert that there is exactly one selected node, and that
  it is a text node

Change-Id: Iaaddf532f06709e860ac44457470e6d8bfcb6dd9
2012-10-24 17:48:20 -07:00
Catrope 29cff8c105 Guard transactions against double commit/rollback
* Store the applied state in the Transaction
* Store the Transaction in the TransactionProcessor (previously, only
  its operations were stored)
* Have commit() and rollback() throw exceptions when passed transactions
  with the wrong applied state
* Add tests for this behavior

Change-Id: I27b7a96fdf4d3555d78f64c05a03702ea560c802
2012-10-24 17:47:41 -07:00
Catrope 43f1612324 No longer copy data in ve.dm.Document constructor
The data array is now taken by reference, and the caller must perform
any copying required.

Changed tests to make a deep copy of shared data sets (mostly
ve.dm.example) before passing them to ve.dm.Document().

Change-Id: Iedc64f9fd9cd689640de9a19379cf5f3db94a2bb
2012-10-24 17:32:35 -07:00
Catrope aa2836aa6e Remove 'internal' property from DM nodes
There's no use case for keeping a deep copy of the 'internal' property
in the node tree, and it was breaking some of my new tests concerning
change markers. We could keep internal data in the node tree if we
wanted to, but to be correct we'd have to synchronize every time we
changed it, which is a pain.

Change-Id: I024de1ff8b6b6154da82c103c4bb21db8ff2ec14
2012-10-24 16:47:14 -07:00
Trevor Parscal 8c3802308e Fix annotation object creation in SurfaceFragment
Also add a comment about how the way data is passed to a new annotation
needs to be improved

Change-Id: I693e4f5632b4eae0d2ee3468ee979454314f6364
2012-10-24 16:47:04 -07:00
Trevor Parscal f17fc65c41 Documentation fixes
Change-Id: I5020623ba59cd9d1794b7d1f97d3adf77b833d6e
2012-10-24 16:47:04 -07:00
Trevor Parscal b8dc697f17 Merge "ve.ui.CommandFactory: Initial implementation" 2012-10-24 18:48:40 +00:00
Timo Tijhof 34cbc729db ve.ui.CommandFactory: Initial implementation
Based on https://github.com/ccampbell/mousetrap.

Cleaned up to fit our coding standards, pass JSHint, and assume
jQuery's fixes where possible (e.g. no need for an addEvent
utility, no need for filling e.target, e.which, etc. cross-browser
which jQuery.Event already does).

Initially all were local functions in the constructor, but to
allow some customisations in subclasses moved various methods
to the prototype instead and marked with @private.

Really, only .register() must be called from the outside. The rest
assumes normalisation etc. or might break things if called
incorrectly.

Change-Id: Ic69a3c70759052094aefbeab623d885f8b118e14
2012-10-24 17:48:16 +00:00
Timo Tijhof 37f3a288ec Standards: Fix global variables and pass JSHint.
Follows-up:
* IK 714e29d30f
* IK 3b8a5ae4d5
* IK 72eb2825e5
* RK 7fe7182f43
* ...

Change-Id: I671f08e4899bfb9508cef272190ec72721a0af9a
2012-10-23 00:53:48 +02:00
Trevor Parscal bb97cd928b Merge "Add parentOuterRange to selectNodes() output" 2012-10-22 17:34:53 +00:00
Catrope 8d82da1fb5 Merge "Rename property "timeout" to "timeoutId" - more descriptive." 2012-10-22 17:08:39 +00:00
Inez Korczyński 88c22b3a46 Rename property "timeout" to "timeoutId" - more descriptive.
Change-Id: I198d07e3c59ba1283085135f45882ce606bb2389
2012-10-19 17:11:59 -07:00
Catrope 4e89867fc0 Merge "Removed htmlTagName and htmlAttributes from hash" 2012-10-19 23:35:57 +00:00
Trevor Parscal d09bc496c3 Merge "Fix for native deletion - it was breaking document (model and view) when deleting really fast (holding the key for example). This solution completely fix the problem, however it is not optimal - stop and start is called more often than should be." 2012-10-19 23:33:24 +00:00
Trevor Parscal 8ea206c743 Removed htmlTagName and htmlAttributes from hash
This was only causing data bloat and also errors because htmlTagName and htmlAttributes are only set if the annotation was constructed from an HTML element

Change-Id: I3d36bca6cd0194e1a4456bb51156117f70b96b13
2012-10-19 16:01:28 -07:00
Catrope 61b6c1ce86 Add parentOuterRange to selectNodes() output
This is the outer range of the parent of the node, if known. We'll need
this for change marking: when resizing a text node, for instance, we
need to mark its containing parent. This way we get the containing
parent's element's offset for free (selectNodes already tracks it in
currentFrame) rather than having to compute it with another traversal.

Change-Id: Ia335d8080ea9d414ab9f89b943e2ea0cd11d7df3
2012-10-19 15:28:26 -07:00
Trevor Parscal 54171d03b6 Merge "Do reference comparison in selectNodes() tests and fix test data" 2012-10-19 22:21:55 +00:00
Trevor Parscal 2aec6b04e8 Merge "Add missing var statement" 2012-10-19 22:20:46 +00:00
Catrope ef513244be Do reference comparison in selectNodes() tests and fix test data
Some tests were using the wrong node in the expected data, but because
only the summaries were compared, this would succeeed as long as the
type and length were equal (and paragraphs of length 1 are quite common
in our test data). Fixed equalNodeSelection() to compare each node by
reference as well as comparing the summaries. If one of the equality
tests fails, the summaries will still be displayed as expected/actual
data (even though they might be equal), and the message will  have
"(reference equality for selection[3].node)" appended to it.

This change broke the tests because a few test cases had bad data, fixed
those in this commit as well.

Change-Id: Iab420cf29d47f7368c8a9ce79f6309efae75685c
2012-10-19 13:56:46 -07:00
Catrope cc9c530690 Add ve.setProp()
Change-Id: I6f932917f8e6321e9c415900b70404406af96d5c
2012-10-19 11:22:12 -07:00
Catrope bfb7e6f40c Add missing var statement
Change-Id: I573e952c60550c29bf7958c221899b72a934fb0c
2012-10-19 11:06:46 -07:00
Christian Williams bab6ca6a60 (bug 41055) Fixing large content copy and paste from external source for Firefox/Windows
Change-Id: I7169566cca486eb5085922c5ac8d932c60a7dcbb
2012-10-18 15:59:55 -07:00
Inez Korczyński 6735a47dcb Fix for native deletion - it was breaking document (model and view) when deleting really fast (holding the key for example). This solution completely fix the problem, however it is not optimal - stop and start is called more often than should be.
Change-Id: Ied5b34f92056407311aa1e84fbff35943138987f
2012-10-18 13:22:20 -07:00
Trevor Parscal 7ee5245a2d Merge "Fix selectNodes() bug reported by Inez" 2012-10-17 23:24:43 +00:00
Catrope 937607893c Fix selectNodes() bug reported by Inez
For <p>1<br/>2</p>, selectNodes([2,2]) correctly returned the end of the
first text node, but selectNodes([4,4]) returned index 2 in the
paragraph (i.e. between the break node and the second text node). The
correct behavior is to return the start of the second text node, i.e.
the mirror image of the behavior for [2,2].

Fixed this by applying the startBetween/endBetween logic only if the
relevant adjacent node is wrapped (or if it's missing). In the code,
this is expressed as !(adjacent node present && adjacent node wrapped).

Change-Id: Ie3b7fdf1de38ee253a798a7a73bc89734f4ca4fa
2012-10-17 16:09:49 -07:00
Inez Korczyński 4b1b63d357 "Is there data?" a.k.a. Insert data only if there is a data to be inserted.
Change-Id: If5957c38668f4dedcba72fc79f9a273614c6dce3
2012-10-17 16:08:02 -07:00
Trevor Parscal 435d45cf9e Merge "Fix bug in ve.ce.BrancNode.setupSlugs. It was removing slugs from the DOM, but not from the internal (this.slugs) collection, so getSlugAtOffset was returning incorrect information." 2012-10-17 21:17:23 +00:00
Inez Korczyński 829b070330 Fix bug in ve.ce.BrancNode.setupSlugs. It was removing slugs from the DOM, but not from the internal (this.slugs) collection, so getSlugAtOffset was returning incorrect information.
Change-Id: I0307d2dfe5c62f992287532ef8925fead2899c58
2012-10-17 13:54:14 -07:00
Catrope 84e598953a Wrap inline elements properly
The HTML "1<br/>2" was being converted to a linmod that looked like
"<p>1</p><br></br><p>2</p>". This commit fixes the wrapping logic such
that the result is "<p>1<br></br>2</p>" instead. In general, inline
nodes (content nodes) should not interrupt the wrapping, but block nodes
should.

This creates a problem for alien nodes: normally, we determine whether an
alien node is a block alien or an inline alien based on context, but if
we're in wrapping mode we're unsure of the context. We can't tell the
difference between "1<tt>Foo</tt>2" (should be wrapped as one, because
tt is inline) and "1<figure></figure>2" (1 and 2 should be wrapped
separately, because figure is block) using context alone, so in these
cases (and ONLY in these cases) we look up whether the HTML tag in
question is an inline tag or a block tag and use that to decide.

Change-Id: I75e7f3da387dd401d9b93e09a21751951eccbb83
2012-10-17 13:50:29 -07:00
Christian Williams 156e56b47b Fixing location of ve.ce.CenterNode.js and adding comma between variable declarations
Change-Id: If54e314f47860ac30060bec6b3f5997ed3709e0b
2012-10-17 13:18:57 -07:00
Inez Korczyński 5c83742313 (Bug 41120) Missing coma. Who knows how it happened...
Change-Id: I4c0a65cc751bf378368df9f8b793f672fb7cca15
2012-10-17 12:48:11 -07:00
Trevor Parscal 5cd4222d9c Whitespace and comment cleanup for dm annotation classes
* Added comments to classes and methods
* Quieted a jshint warning
* Broke some long lines
* Replaced instances of "var\t" with "var "

Change-Id: I1d617ed9e5180f1a3dff42078fb5debb5d718407
2012-10-17 12:35:28 -07:00
Trevor Parscal 1c5ac9d502 Merge "Fix exception when deleting all text (Ctrl+A Backspace)" 2012-10-17 19:33:48 +00:00
Inez Korczyński 874adec1ac (Bug 41120) When getOffset is called for a slug offset there is no need to traverse DOM - we can simply just call getSlugAtOffset and use that information.
Change-Id: I46b21ca0d3ca11d72c77feeb884f7d92a201de36
2012-10-17 12:32:27 -07:00
Trevor Parscal 64442e03d8 Merge "Fix JS error in DocumentSynchronizer when adding to an empty document" 2012-10-17 19:28:58 +00:00
Trevor Parscal 020a04f3dc Merge "Get annotations from first character of a range" 2012-10-17 19:28:05 +00:00