Commit graph

2702 commits

Author SHA1 Message Date
jenkins-bot e1c49ace99 Merge "Refactor ve.ui.PagedDialog" 2013-10-04 20:25:43 +00:00
Kyle Florence 4efc6cadb7 Refactor ve.ui.PagedDialog
This commit extracts the page and outline handling logic from
ve.ui.PagedDialog (RIP) and moves it into two layouts: ve.ui.PagedLayout
and ve.ui.PagedOutlineLayout, respectively. These layouts are now implemented
inside the dialogs that used to mixin the ve.ui.PagedDialog class. This
brings a much cleaner separation of concerns between Dialogs and Layouts
and allows the use of page handling logic without the accompanying
outline logic.

Change-Id: I5efa2f893f4b7e962438b3aff34b737573bbd5ca
2013-10-04 12:09:15 -07:00
jenkins-bot b36c401ec7 Merge "Get rid of 'reversed' flag on transactions" 2013-10-04 06:18:06 +00:00
Roan Kattouw 10bf7b34ca Followup 571d6cac: when the selection changes, undo highlights
Ignoring all bounced change events led to the logic for unhighlighting
the previously selected FocusableNode being skipped. This caused a bug
where if you clicked a FocusableNode, it would stay highlighted even
if you then selected some text, until you highlighted another node
(which would then be highlighted forever, etc.)

Change-Id: Ia8d74ef85eaa47326d49ef6c0f395b44b90da4dc
2013-10-03 15:50:51 -07:00
jenkins-bot 2b46215a2c Merge "Make toolbars, toolgroups and tools toolFactory independent" 2013-10-03 22:42:58 +00:00
jenkins-bot 5ba2dcfe3c Merge "ve.Element: Fallback to body, window is not scrollable" 2013-10-03 22:27:37 +00:00
jenkins-bot c21c8556fc Merge "Make ve.Factory require static name property" 2013-10-03 22:03:26 +00:00
Trevor Parscal 61ddfb76e4 Make ve.Factory require static name property
Objective:
* Make ve.Factory behave like ve.NamedClassFactory
* Remove the only remaining use of ve.Factory (actions)
* Remove ve.NamedClassFactory

Change-Id: Ie302ef5ea31081de7ab0db6091058a59946aef4c
2013-10-03 14:52:19 -07:00
jenkins-bot c98624a7be Merge "When cloning the InternalList, pass through properties that aren't rebuilt" 2013-10-03 21:51:45 +00:00
Trevor Parscal 7297108a48 Make toolbars, toolgroups and tools toolFactory independent
Objectives:
* Pass a specific tool factory into a toolbar, allowing it to be used
  with different collections of tools and not depend on the
  ve.ui.toolFactory global
* Move syntax highlight editor tools to their own factory

Change-Id: I307bf180bd6817bc044bc474a77861e13f431ddb
2013-10-03 21:49:36 +00:00
Roan Kattouw 69ad031bff When cloning the InternalList, pass through properties that aren't rebuilt
InternalList.clone() assumed that all properties are automatically rebuilt
when a new document is built, but that's not true for .nextUniqueNumber
(or for .itemHtmlQueue for that matter). This meant that, in practice,
.nextUniqueNumber was being reset to 0 after auto/N numbers for existing
references had been assigned, but before assigning numbers to newly
created references. This caused all sorts of naming collision fun.

Bug: 54712
Change-Id: I1d087a5f3c23979d7d488e3ab32eb064ebc23e94
2013-10-03 14:43:20 -07:00
Trevor Parscal 1a7a5a9948 Allow menu tool groups to be wider if needed
Using a min-width instead of a width ensures it gets larger only if
needed.

Bug: 54870
Change-Id: I9953d21134d722547efa0cdbe32e1bc0c13d6093
2013-10-03 21:25:46 +00:00
Timo Tijhof f6d409e09b ve.Element: Fallback to body, window is not scrollable
Bug: 54928
Change-Id: Ifec0dae598f7fd99270588bd8ca77777a07e9669
2013-10-03 23:06:47 +02:00
jenkins-bot dd9511f249 Merge "Change ve.dm.DocumentSlice to a mixin to ve.dm.LinearData" 2013-10-03 18:45:55 +00:00
Ed Sanders 5c31d3215b Change ve.dm.DocumentSlice to a mixin to ve.dm.LinearData
Document slice only ever contained linear data, with extra functionality
to preserve the range. It pre-dated LinearData, but now we should
refactor it to reflect its purpose.

Change-Id: Ifc908f7526c83a43a51372c8d2494d7260e7facd
2013-10-03 19:38:59 +01:00
jenkins-bot 1a9f6489d7 Merge "Rename getDocumentSlice to cloneFromRange" 2013-10-03 18:19:13 +00:00
Ed Sanders 1957eb3e28 Rename getDocumentSlice to cloneFromRange
We already getSlice which returns a ve.dm.DocumentSlice, so using
the word slice in this method is very confusing. What we are actually
doing is creating a ve.dm.Document from a range. Also remove argument
overloading as it's not particularly helpful and would make the new
name a lie.

Change-Id: I93da3419510410b170396e6765fbe2a87f9795be
2013-10-03 12:48:01 +01:00
Roan Kattouw 6772f92e70 Get rid of 'reversed' flag on transactions
The way we implemented undoing transactions was horrible. We'd process
the original transaction, but with a reversed=true flag. That meant we
had to keep track of the 'reversed' flag everywhere, and use ternaries
like insert = reversed ? op.remove : op.insert; all over the place to
access transaction operations. Redo then worked by reapplying the
transaction. We would verify that this was OK by tracking whether the
transaction was in an applied state or an undone state.

This commit makes it so every transaction can only be applied once. To
undo, you obtain a mirror image of the transaction with tx.reverse(),
then apply that. To redo, you clone the original transaction with
tx.clone() and apply that. All the code that had to use ternaries to
check whether the transaction was being applied in reverse or not is
gone now, because you can only apply a given transaction forwards,
never in reverse.

Bonus:
* Make ve.dm.Document's .completeHistory a simple array of
  transactions, rather than transaction/boolean pairs
* In the protection of double application test, clone the example
  document properly; it modified ve.dm.example.data, which was "fine"
  because it ran .commit() and .rollback() the same number of times

Change-Id: I3050c5430be4a12510f22e20853560b92acebb67
2013-10-02 19:37:08 -07:00
Roan Kattouw 087fd6c348 Followup 5592ea26: bind native focus/blur events instead of jQuery events
In jQuery 1.8, if you focus something using jQuery, the jQuery focus
event fires before the jQuery blur event, which is wrong. If you focus
something natively, the events do fire in the correct order.
See http://jsfiddle.net/WGy9h/4/ .

Fortunately, the native events always fire in the correct order, so
listen to those instead. Normally, we're not concerned with the order,
but in ce.Surface we bind the same focus/blur handlers to a pair of two
nodes, and then if the focus moves from one to the other, we'll get
confused by the events being emitted in the wrong order.

Change-Id: Ia585b42b6deb74ba55a2d55ce1922b1e04d85e81
2013-10-02 17:59:51 -07:00
Ed Sanders 7d9eee7b5b Use element.textContent in ve.getDomElementSummary
.text() returns empty for comment nodes, where textContent returns
the contents of the comment node.

Change-Id: I5e2798a6dba9d0f8fc13d5c0f78fe1fd255f1ebe
2013-10-02 15:47:34 +01:00
Roan Kattouw 5592ea2602 Make cursoring over a FocusableNode work again
When you cursor onto a FocusableNode, it's selected, and we focus the
paste target as part of our hack to make copying FocusableNodes work
in Firefox. But then when you press the arrow key again, that event
isn't picked up by anything, and you can't move the cursor off the
FocusableNode using the keyboard.

Fixed by attaching the EventSequencer to this.$ (which is the parent
of $documentNode and $pasteTarget) and listening for focus/blur on
both $documentNode and $pasteTarget.

Bug: 54443
Change-Id: I7bddcfa9fa6f38908e315c97623bd27133daa98d
2013-09-30 18:16:41 -07:00
jenkins-bot 7052472c2b Merge "Don't bounce selection changes DM->CE" 2013-09-30 23:56:25 +00:00
David Chan 571d6cac59 Don't bounce selection changes DM->CE
ve.ce.Surface.js
* changeModelSelection: store selection temporarily for bounce detection
* onChange: do nothing if bounce is detected

Change-Id: I758e7a72a5690463f12f456419c6e471dd29a9db
2013-10-01 00:49:27 +01:00
jenkins-bot f2189a97b5 Merge "Add more tests for ve.ce.Surface#onContentChange" 2013-09-30 23:23:23 +00:00
jenkins-bot a3854ad50a Merge "Typing into an annotation next to a word break keeps annotation" 2013-09-30 23:21:29 +00:00
Roan Kattouw cf19aff8b1 Follow-up to 9b999622: don't slug paragraphs that contain just a text node
Bug: 54791
Change-Id: Ide8b5320fae2622085f183c771173ef7190406ed
2013-09-30 09:33:59 -07:00
jenkins-bot d1b3c89c7e Merge "ce.BranchNode: Insert slugs based on CE children length, not DM" 2013-09-29 17:14:43 +00:00
Timo Tijhof 9b99962215 ce.BranchNode: Insert slugs based on CE children length, not DM
Due to Firefox' Ctrl-A creating an outer selection (0,len) as
opposed to inner select like in Chrome (1,len-1), deleting leaves
the document completely empty (with no cursor anywhere in the
document).

However, setupSlugs() wasn't inserting a slug because the internal
list still existed (so this.model.length !== 0).

Using this.$.children().length instead.

Bug: 50947
Change-Id: I1517ebcc5b31e2544559b851174482b0c872b24b
2013-09-29 10:12:22 -07:00
Inez Korczyński e4daeea01e removedItems[i] is already an item, no need to pass removedItems[i].item
Bug: 54727
Change-Id: Iff8e9c8f1dc7a701d4773bf15817897a871d9e98
2013-09-29 17:09:09 +00:00
jenkins-bot 7a7b31b267 Merge "Move repeated code for creating a test ve.ui.Surface in utils" 2013-09-27 12:03:03 +00:00
Ed Sanders 686564246d Add more tests for ve.ce.Surface#onContentChange
Change-Id: I8ad12ca086d4dadce82a954ee015af2cc3bbd7cc
2013-09-27 11:55:43 +01:00
Ed Sanders f3899c4041 Typing into an annotation next to a word break keeps annotation
Logic was failing because we were passing the index of the annotation
within the AnnotationSet, instead of the index within the Store, to
containsIndex().

Bug: 54332
Change-Id: Ibfd9abe6e4b44d9db744e0c5019418eee12f84a4
2013-09-27 11:53:57 +01:00
Ed Sanders 807df9827e Move repeated code for creating a test ve.ui.Surface in utils
Pattern is used in half a dozen places, so let's use a utility function.

Change-Id: I3e2d0024f0a2887c32ba96537195dd374a11c560
2013-09-27 11:53:51 +01:00
Roan Kattouw 069eefe343 Fix JS error in ve.ui.ClippableContainer
Sometimes, .clip() would be called when clipping had already been
disabled again, and accessing this.$clippableContainer would cause
an error. This happened to me when typing quickly in MWLinkInspector.

This probably happens when enabling and disabling clipping right after
each other in response to the same event, such that the setTimeout()
for the initial clip is run after clipping has already been disabled.

Change-Id: I0f85ea5f10955188bae51160e1c88eca858ea1bf
2013-09-26 17:39:35 -07:00
jenkins-bot 164d16eb86 Merge "Fix timing of rerender event in GC nodes" 2013-09-26 21:46:09 +00:00
jenkins-bot bea113fee2 Merge "Introduce newFromDocumentReplace() transaction builder" 2013-09-26 20:45:54 +00:00
Ed Sanders 515ad01713 Fix timing of rerender event in GC nodes
Move the triggering of the rerender event into an overridable method
'afterRender'. Some nodes don't have the correct dimensions
immediately after rendering their DOM elements as they may need
to wait for images to load, or for a script to run (e.g. MathJax)

Change-Id: If204f665dcb2fd69d00a183279056d11188ddd74
2013-09-26 21:39:39 +01:00
jenkins-bot 23dd5f9fb9 Merge "'Config' -> 'Configuration' in all comments" 2013-09-26 19:02:30 +00:00
jenkins-bot f2c48e82b9 Merge "Missing param comments in methods updating popup widget" 2013-09-26 17:58:34 +00:00
Ed Sanders a69ce9b2b6 Missing param comments in methods updating popup widget
Change-Id: Id90ba76719472fe0b61e9d232b5cf72f086af915
2013-09-26 15:26:54 +01:00
jenkins-bot 642e6e7b97 Merge "Pass config object from ce.GeneratedContentNode.update() to forceUpdate()" 2013-09-26 13:03:57 +00:00
Roan Kattouw cf17789985 Introduce newFromDocumentReplace() transaction builder
Replaces newFromNodeReplacement(). newFromNodeReplacement was very
simplistic and didn't support metadata or internal list items, so
if you had comments or references inside of the data you were editing
(reference contents or an image caption), they'd get mangled.

With this, you can do:
newDoc = doc.getDocumentSlice( node );
// Edit newDoc
tx = ve.dm.Transaction.newFromDocumentReplace( doc, node, newDoc );
surface.change( newDoc );

and that takes care of metadata, internal list items, and things like
references that reference internal list items.

ve.dm.Document.js:
* In getDocumentSlice(), store a reference to the original document
  and the number of items in its InternalList at the time of slicing
  in the created slice. This is used for reconciliation when the
  modified slice is injected back into the parent document with
  newFromDocumentReplace().

ve.dm.InternalList.js:
* Add a method for merging in another InternalList. This provides a
  mapping from old to new InternalList indexes so the linear model data
  being injected by newFromDocumentReplace() can have its InternalList
  indexes remapped.

ve.dm.Transaction.js:
* Replace newFromNodeReplacement() with newFromDocumentReplace()

ve.ui.MWMediaEditDialog.js, ve.ui.MWReferenceDialog.js:
* Use getDocumentSlice/newFromDocumentReplace for editing captions/refs
* Change insertion code path to insert an empty internalItem/caption, then
  newFromDocumentReplace into that
* Add empty internalList to new mini-documents

ve/test/dm/ve.dm.Transaction.test.js:
* Replace newFromNodeReplacement tests with newFromDocumentReplace tests

ve-mw/test/dm/ve.dm.Transaction.test.js (new):
* Add tests for newFromDocumentReplace with mwReference nodes

ve.dm.mwExample.js:
* Add data for newFromDocumentReplace with mwReference tests

VisualEditor.hooks.php:
* Add new test file

Bug: 52102
Change-Id: I4aa980780114b391924f04df588e81c990c32983
2013-09-25 21:46:38 +00:00
Ed Sanders 81d8699249 Various context menu display issues
* Check the popup fits within the node horizontally as well
  as vertically before embedding.
* Calculate the position of the node relative to the document.
  Previously we assumed the parent was the document and so used
  jQuery#position but this is not the case if a custom $focusable
  is passed to FocusableNode.
* Forcefully re-show the context menu on resizable node mouse up.
  This is apparently done automatically by a redraw event, but if
  the user just clicked on a resize node without dragging the context
  menu would be lost.

Change-Id: Id477a30827c9393a446e9c44466c83dabc7e0ab4
2013-09-25 21:54:59 +01:00
Ed Sanders e6f48c5c93 'Config' -> 'Configuration' in all comments
Because the former isn't a real word.

Change-Id: Ie6ed15f9e390b357bbaa768b57f3c3fd7cf21181
2013-09-25 11:23:16 +01:00
jenkins-bot 05ec83657e Merge "Fix variable names in newFromInsertion" 2013-09-25 03:44:27 +00:00
Ed Sanders 0a49efe9e7 Fix variable names in newFromInsertion
Documentation says third argument is 'data' when in fact it is
'insertion' which is then re-used as the result of fixupInsertion :/

Change-Id: I17c959f858eddddc90a6fa839da0d32da69a784f
2013-09-24 20:06:01 -07:00
Roan Kattouw 7ed197c7a6 Pass config object from ce.GeneratedContentNode.update() to forceUpdate()
This is obviously necessary, but wasn't done, so calling update()
with a config object was broken.

Change-Id: I30d67bcb117885c792c0f08ea55d60cb294de18b
2013-09-24 16:57:51 -07:00
jenkins-bot 1546485fed Merge "No more configuration overrides" 2013-09-24 22:11:06 +00:00
jenkins-bot 8ecbfa05b5 Merge "Add abstract method for getMediaSources." 2013-09-24 19:47:43 +00:00
Ed Sanders 888de344d9 Delete empty nodes instead of merging into them
When you press delete inside an empty node (e.g. Heading) that
node should be removed, instead of the paragraph beneath it being
merged into and effectively converted. If the heading is non-empty
then merging is still the correct behaviour.

Also add in test case.

Bug: 50254
Change-Id: If9cee79feb4b4ee9d7c367e392b00fee5e8c0669
2013-09-24 18:27:07 +00:00