Commit graph

2856 commits

Author SHA1 Message Date
jenkins-bot b15374751e Merge "Toolbar action widgetization and UI refactoring" 2013-10-05 00:17:28 +00:00
Trevor Parscal 6ec34a3dee Toolbar action widgetization and UI refactoring
Objectives:

* Use widgets to render toolbar actions
* Remove labels next to help notices and edit notices buttons
* Add a close button to the help notices and edit notices

Overview:

* ve.ui.ButtonWidget is now abstract, use ve.ui.PushButtonWidget instead
* ve.ui.IconButtonWidget now inherits from ve.ui.ButtonWidget
* ve.ui.PopupWidget's display method no longer takes x and y arguments
* Fixup naming issues in MWCategoryPopupWidget
* Fixup naming issues with some ve-init-mw CSS classes
* Rename ve-mw/ui/styles/ve.ui.Widget.css to ve.ui.MWWidget.css
* Change uses of "callout" to "tail"
* Add hyperlink functionality to buttons
* Make buttons accessible through focusing, but make unfocusable by
  clicking
* Add head option to popup for rendering a title and close button

Bug: 52386
Change-Id: Iea2c8df1be64d40f9c039873d89ee540cc56e687
2013-10-04 16:26:13 -07:00
Trevor Parscal 4a459e40a8 Remove surface dependencies from lookup widget
Objective:
* Use <body> instead of the closest surface overlay as the default
  overlay (wasn't actually being used anyway)
* Use this.$.offsetParent instead of closest surface when measuring
  parent frame offset to position text input menu

Change-Id: I04fc5ff1da4bafd342093922a5bd3b3a784b327c
2013-10-04 21:16:47 +00:00
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 241f146c8a Prevent context menu from flickering after FocusableNode redraw
Pass an extra parameter to show() to let it know when the menu is
just being moved, and therefore doesn't need to perform the fade-in
transition.

Change-Id: I2cf2ff07db6cc7d226f3d626755792a06dfcbe54
2013-09-26 21:39:54 +01: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
jenkins-bot 37c416dd24 Merge "Detect collapsed range inside focusable node in ve.ce.Surface#onChange" 2013-09-24 17:21:43 +00:00
Ed Sanders 0c2b6c353e Detect collapsed range inside focusable node in ve.ce.Surface#onChange
When the document starts with a focusable node, and we try to initialise
the selection to [1,1], the current logic does not detect that as being
on the focusable node and tries to do a native selection.

Bug: 54446
Change-Id: Ib515c435314c35c4e9b3802da117b963b3ef4169
2013-09-24 16:53:55 +01:00
jenkins-bot e4a05cef7b Merge "Allowing for config data when instantiating dialogs" 2013-09-24 15:53:50 +00:00
jenkins-bot 4717bd9248 Merge "Revert drag marker GIF to previous version" 2013-09-24 15:52:03 +00:00
jenkins-bot fbf126e972 Merge "Add basic ve.ce.tests and fix documentation" 2013-09-24 15:38:46 +00:00
Ed Sanders 8547dbc032 Tests for handleDelete in ve.ce.Surface
Trigger fake delete/backspace events and assert changes to the DM.

Change-Id: I69659a3e49b6520376cac3c795e8a96e7fbda9ae
2013-09-24 15:32:37 +00:00
jenkins-bot d1b2ef6525 Merge "Don't apply attributes to GC wrapper" 2013-09-24 15:31:38 +00:00
Ed Sanders e1b158880e Don't apply attributes to GC wrapper
this.$ on a GC node is just a wrapper, so shouldn't take the
HTML attributes from the model, otherwise you may end up with
double borders and padding.

Change-Id: I5641df341c9b118461e7e8fb89266dd300e09755
2013-09-24 11:04:30 +01:00
jenkins-bot 9740d1683e Merge changes I9e065aa4,Iac7649f4
* changes:
  MW*ImageNode's can't take link annotations
  Node annotation blacklists
2013-09-24 00:09:22 +00:00
Erick Guan 30f1ed4c75 No more configuration overrides
In various places in the UI code, certain properties of config objects
were overridden and in some cases the configurations were documented as
private as a strange hack to prevent them from being advertised in the
docs.

I, Trevor, have been convinced of the error of my ways, and gladly
reverse this situation, allowing all configurations to always be
overridden when desired, while still allowing default values.

Change-Id: I242e3b1902dec8e09eeea38fa64381e69ee04215
2013-09-23 23:59:14 +00:00
jenkins-bot 48c60153a6 Merge "Extend SurfaceToolbar into TargetToolbar" 2013-09-23 23:48:41 +00:00
jenkins-bot 2f4c41ae01 Merge "Add opacity-setting class to GC nodes when generating" 2013-09-23 23:47:13 +00:00
jenkins-bot 5144b8b23c Merge "Cleanup action methods" 2013-09-23 23:35:20 +00:00
jenkins-bot 9a6fa4fb77 Merge "Ignore all node attributes in clipboard hash" 2013-09-23 23:01:43 +00:00
jenkins-bot 4077ed0f55 Merge "LanguageAnnotation Touchup" 2013-09-23 21:46:52 +00:00
Timo Tijhof 5276bf13c1 ve.Element: Account for getComputerStyle returning null
Follows-up 143b086c74.

When the page settings dialog is opened, ve.Element.getBorders
gets called twice and in both cases, style is null in Firefox:

* HTMLLIElement
  classList: "ve-ui-widget ve-ui-optionWidget ve-ui-outlineItemWidget
   ve-ui-outlineItemWidget-level-0 ve-ui-optionWidget-selected"
  childNodes: [object HTMLSpanElement, object HTMLDivElement]

* HTMLDivElement
  classList: "ve-ui-layout ve-ui-panelLayout ve-ui-panelLayout-scrollable
   ve-ltr ve-ui-pagedDialog-outlinePanel"
  childNodes: [object HTMLUListElement]

Bug: 54322
Change-Id: I86264007c2d5b4930640a352b8896dff2d0d9ce5
2013-09-23 19:16:25 +00:00
Moriel Schottlender b8d0807407 LanguageAnnotation Touchup
Fixing a couple of mishaps in the language annotation, including adding a
getComparableObject in the ve.dm.LanguageAnnotation class.

Change-Id: Ia28900df55969f60576cfd716c70ffc1ba5f4c27
2013-09-23 11:41:34 -07:00
Timo Tijhof 7481ea024d ve.Element: Clean up logic
* Remove redundant ' ? true : false'.
* Reuse loc instead of repeating win && win.getComputedStyle.

Change-Id: I753121f358d3ffc190869a64f44af3daa0ce5a42
2013-09-23 20:00:36 +02:00
Ed Sanders 86f3f7cd5e Add basic ve.ce.tests and fix documentation
Also add TODO's for untested methods.

Change-Id: I905f3ecf17e4ea5ec33fdded4c7683340e08b549
2013-09-23 16:33:15 +01:00
Ed Sanders 3a08aa9b62 Add opacity-setting class to GC nodes when generating
So that they appear 'greyed-out' while updating.

Change-Id: Icbc92d293517beb72d64e4011b0cd5197820de9a
2013-09-23 13:57:56 +01:00
Ed Sanders 936ad149cf Ignore all node attributes in clipboard hash
Some browsers normalise attributes (e.g. Firefox makes
URLs absolute) so we have to remove them from the clipboard
hash to make the comparable.

Bug: 54377
Change-Id: Iadc4d886a5345b28370cbfa31eb665661e577eeb
2013-09-23 12:48:53 +01:00
jenkins-bot a55ca0a0c3 Merge "Only listen for copy/paste on documentNode and pasteTarget" 2013-09-20 18:34:25 +00:00
Ed Sanders caa05f3315 Fix exception thrown by converter when data ends in text
Conversions usually end in a close tag so this hasn't been a problem
before, but the mini-conversion we do in onCopy may not be balanced.

Change-Id: Ia2db29f116ca84ee886b4c5cafd4ac45cd926b79
2013-09-20 18:26:14 +00:00
Ed Sanders 25ae630009 Only listen for copy/paste on documentNode and pasteTarget
As these are the only places we want to override the events.

Bug: 54375
Change-Id: I8a4e207f38508cdaf35cd869f267dd9f1059c83d
2013-09-20 14:48:30 +01:00
Roan Kattouw eb64743436 Prevent naming collisions when generating unique reference names
Simply generating ':3' as the "unique" name for the 4th reference
doesn't work. Even if getUniqueListKey() had been used, that only
checks for conflicts with names that have already been encountered
(i.e. occur in <ref> tags that precede the current one), not for
conflicts with names that first occur further down in the document.

The solution is to generate names at serialization time, when we
have full knowledge of which names are in use. Internally, we use
'literal/<name>' for names that literally appeared in the source,
and 'auto/<number>' for unnamed references. Then at serialization
time, we translate 'auto/<number>' to 'literal/:<number>' if needed
(i.e. if the reference was reused).

ve.dm.MWReferenceNode.js:
* toDataElement()
** Prefix listKey with literal/ or auto/ as appropriate
* toDomElements()
** Map auto/ listKeys to unique names
** Don't try to unset the name if not present (was unsetting a property
   that didn't exist anyway)

ve.dm.InternalList.js:
* Remove now-unused isUniqueListKey()
* Rewrite getUniqueListKey()
** Make prefix configurable
** Take previously generated unique keys into account
** Map the same old key (auto/N) to the same generated key (literal/:M)
* Add getNextUniqueNumber() as a source for auto/N numbers: previously
  used the length of the itemHtmlQueue, but that only works during
  conversion, not from the UI dialog

ve.ui.MWReferenceDialog.js:
* For new references or conflicting names, generate an auto/N key and
  let toDomElements() deal with actually mapping that to name

ve.dm.InternalList.test.js:
* Rename listKeys to new style
* Split the test case into two groups so we can test multi-group cases
* Add tests for getUniqueListKey()

ve.dm.mwExample.js:
* Rename things to new style
* Modify the test case so it attempts to trigger bug 54341

Bug: 54341
Change-Id: I726fb83e6fb66ffec643d996768a854ec9474b3d
2013-09-19 21:03:15 -07:00
Ed Sanders f001d306ad Node annotation blacklists
Allow nodes to specify a blacklist of annotations which can't be applied
to it.

Bug: 53151
Change-Id: Iac7649f4b38d8bfa94c64f734634afd45a5afc53
2013-09-19 19:09:25 +01:00
Christian Williams 86e12cac61 Revert drag marker GIF to previous version
When we switched all base 64 encoded blank GIFs to the "stable" version,
we created a regression that prevented proper styling of the drag marker.
This restores the correct drag-drop experience.

Change-Id: I9c2a195fd866a5919245667a436106772debcffd
2013-09-18 19:39:33 +00:00
C. Scott Ananian 7c1ba7750c Minor doc fixes to ve.dm.Transaction.
Correct the return value descriptions for the `newFromMetadataInsertion` and
`newFromMetadataRemoval` methods (which appear to have been cut-and-pasted
from another method).

Change-Id: I019b0ef9c75ff47fc0f2df8c95da9d090710a5a8
2013-09-18 15:18:42 +00:00
jenkins-bot c98a964d5f Merge "Fix check for preformatted when stripping whitespace" 2013-09-18 01:11:46 +00:00
jenkins-bot 17131a15e1 Merge "dm.Surface: Initialize selection at (1,1) instead of (0,0)" 2013-09-18 01:09:12 +00:00
Roan Kattouw d3af8b877b dm.Surface: Initialize selection at (1,1) instead of (0,0)
Code with a similar purpose was added in 568e0e5701 but got lost
when some things were moved from ve.Surface to ve.ce.Surface in
5012ed10.

Initializing the selection at (0,0) was known to cause problems before,
and since 789d0caf09 breaks editing of empty documents: typing in an
empty document begins in an inline slug, but SurfaceObserver doesn't
notice typing in an inline slug unless the ce.Surface pawns it, which
is OK because insertions in slugs are always pawned, but the pawning
logic believes the cursor to be at offset 0 where there is no slug
(it's at offset 1) and so it doesn't pawn.

Bonus: update tests and add descriptions for dm.Surface.change tests

Change-Id: Id72314d0fe650dacc7cdb842f5cea2f3bfba5145
2013-09-18 01:06:34 +00:00
jenkins-bot 1baf90130a Merge "Fix function naming conventions, comments and whitespace" 2013-09-18 00:58:43 +00:00
jenkins-bot 973d9f999d Merge changes I899d2b3c,I0272fe38,I7ad24e7f
* changes:
  Rewrite MetaList.onTransact
  Allow replace operations to replace metadata as well
  Fix processing of double metadata replacements
2013-09-17 21:01:41 +00:00
Ed Sanders 232856e172 Fix function naming conventions, comments and whitespace
* Convert some spaces to tabs
* Move private function to top and document
* Give constructor a global name

Change-Id: I7ec144303d32b1bb454b4164222601c263fb75bf
2013-09-17 19:37:08 +01:00
jenkins-bot bcc5d04aba Merge "Scroll into view support" 2013-09-17 16:19:18 +00:00
Ed Sanders 4d1d632ebd Extend SurfaceToolbar into TargetToolbar
Toolbars may want to control the target as well as the surface (spoiler alert!).
The new TargetToolbar has a pointer to its target as well as its surface.

Change-Id: I928316d9e23ac3f3de3e76c34ef0ac3d27855ab3
2013-09-17 17:05:01 +01:00
Trevor Parscal 143b086c74 Scroll into view support
Objectives:

* Scroll when needed to show highlighted (with keyboard) or selected (by
  any means) options in select widgets
* Allow clipping and automatic scrolling for certain elements when they
  are otherwise going to be rendered partially out of view

Changes:

*.php
* Add links to new file

ve.ui.Widget.css, ve.ui.Dialog.css
* Removed unneeded x-axis overflow rules

ve.ui.ClippableElement.js, ve.ui.Element.css
* New mixin, adds visible area clipping support to an element

ve.ui.PopupToolGroup.js, ve.ui.MenuWidget.js
* Mixin clippable element

ve.ui.OptionWidget.js, ve.ui.OutlineItemWidget.js
* Add scroll-into-view configuration for option widgets

ve.ui.SearchWidget.js
* Scroll items into view when highlighting with keyboard

ve.Element.js
* Add getBorders, getDimensions, getClosestScrollableContainer and
  scrollIntoView static methods
* Add getClosestScrollableElementContainer and scrollElementIntoView
  methods

Bug: 53610
Change-Id: Ie21faa973a68f517c7cfce8bd879b5317f536365
2013-09-16 16:46:58 -07:00
Ed Sanders 8fb2f4467d Remove ve.log debugging calls from EventSequencer
Change-Id: I642acf09e7ed52d6dbf4312e054134b264c3428d
2013-09-16 18:44:33 +01:00
Ed Sanders e7aed52d93 Fix check for preformatted when stripping whitespace
Previous was checking by string match to 'preformatted' which didn't
match 'mwPreformatted'. Now using node factory to see if
hasSignificantWhitespace is set.

Bug: 54083
Change-Id: I1be2d4568df7848e08074d200fb374acd508f6fa
2013-09-16 16:41:45 +01:00
Ed Sanders c0650459df Fix merge conflict breaking localised bold/italic icons
Bug introduced by change Ic97a636f9.

Bug: 53094
Change-Id: I4bf0bd4d340dfbad26a0d729de866985f81d14aa
2013-09-12 11:44:20 -07:00
jenkins-bot c65d01fbfe Merge "Transactions: Add trailing retainMetadata when there is trailing metadata." 2013-09-12 04:14:01 +00:00
jenkins-bot bdd9094279 Merge "Move text style tools out of experimental" 2013-09-12 03:06:03 +00:00
David Chan 789d0caf09 Fix pawn on pre-annotation and keypress
modules/ve/ce/ve.ce.SurfaceObserver.js
* pollOnceNoEmit method to update SurfaceObserver's benchmark text

modules/ve/ce/ve.ce.Surface.js
* pollOnceNoEmit from onUnlock

Change-Id: Idb14a6aea723c42109b3825478766799d4abef22
2013-09-11 19:47:39 -07:00
James D. Forrester 1a1ef97336 Move text style tools out of experimental
These were meant to have been de-experimental-ised with the toolbar
commit; oh well. This moves the following text styles from being in
"experimental" mode to being regular annotations:

* Code
* Strikethrough
* Subscript
* Superscript
* Underline

Change-Id: I21be2dc844b47b825d7a1e48a592067166ecd122
2013-09-11 19:41:14 -07:00
C. Scott Ananian 3928ca16fd Transactions: Add trailing retainMetadata when there is trailing metadata.
Ensure that all transactions move the cursor past the trailing
metadata, if present.

Change-Id: I869c75f8cfabe1e14bb66d8e627d0b750bde46af
2013-09-11 16:02:12 -07:00
Roan Kattouw ccef625a08 Rewrite MetaList.onTransact
The previous implementation couldn't deal with transactions that
replaced both data and metadata at the same time (rather than replacing
data while moving metadata around), and extending its approach to
deal with that case would have made it much more complex.

So I rewrote the algorithm from scratch. The previous implementation
scheduled deferred moves for existing items, but immediately processed
insertions and removals. This is problematic for replacements and
maintaining the order in the binary search list. So instead, this new
implementation builds an array representing what the new item list
should be, then processes insertions, removals and moves in the correct
order to achieve that state.

It looks like the previous implementation didn't always work correctly,
which was masked because the test suite passed full=false to
assertItemsMatchMetadata(). This rewrite fixes this.

Also remove setMove/applyMove from MetaItem, because we don't need them
anymore and they're evil anyway; and add isAttached(), because the new
algorithm needs it.

Change-Id: I899d2b3c94c2cfa55823879bca95456750f64382
2013-09-11 15:29:28 -07:00
Roan Kattouw 13cd29ea62 Allow replace operations to replace metadata as well
This was already possible in the operation structure by using
removeMetadata and insertMetadata, but no transaction builders
generated transactions like that.

With this change, pushReplace() can be instructed to overwrite the
metadata with arbitrary data rather than collapsing it by passing the
optional insertMeta parameter.

Change-Id: I0272fe38e053161c738591cf0a7b447a0827d4dc
2013-09-11 15:26:12 -07:00
Roan Kattouw eb90af29e0 Fix processing of double metadata replacements
Transactions that replaced metadata twice at the same offset
(with retainMeta-replaceMeta-retainMeta-replaceMeta) were broken
because the processor for replaceMetadata didn't advance the
metadata cursor.

Change-Id: I7ad24e7ffb4c39b40ec9c347db301f8e28f3692d
2013-09-11 15:26:12 -07:00
jenkins-bot 71df5562e4 Merge "The Great [...] Rewrite of 2013: Clipboard edition" 2013-09-11 18:15:07 +00:00
Trevor Parscal 3e460a02df Cleanup action methods
Changes:
* Remove reference to inspector close method, which didn't actually exist
* Use more spacy array syntax for all action methods

Change-Id: I08ee2d262acc7b39456766fb4a0b490da88ad041
2013-09-11 10:25:46 -07:00
jenkins-bot 67be7db1eb Merge "Fix off-by-one error with metadata-mutating transactions." 2013-09-11 17:09:07 +00:00
C. Scott Ananian 1f5b78ab94 Fix off-by-one error with metadata-mutating transactions.
Add some test cases for documents with trailing metadata, and fix an
off-by-one error in the metadata-mutating transactions (since the
document metadata array is one larger than the document data array).

Change-Id: I8f049466e03ed55010dfcf0a35702536edfa7b0a
2013-09-11 10:07:20 -07:00
Moriel Schottlender 63056eaa6d Allowing for config data when instantiating dialogs
Currently, WindowSet open method uses the Window factory to call up
the instantiation of a new dialog or inspector class. This commit will
also allow sending further config options to these classes if needed.

Specifically, this will also allow the use of ve.ui.Context.js for
block inspectors that are not dependent on current selection or current
location of the cursor.

It will also let us generalize the dialog/inspector window instantiations
by adding in any needed config settings on call.

Change-Id: If14384d74ab91ef01b1c7641ff84f327f2a12112
2013-09-11 08:36:05 -07:00
David Chan 23921df6dc Refactor CE Surface to reduce event feedback
Restructure SurfaceObserver methods so that the method calls are more precise.

modules/ve/ce/ve.ce.SurfaceObserver.js
* Move timing code into startTimerLoop / stopTimerLoop / timerLoop
* Move poll logic into pollOnce

modules/ve/ce/ve.ce.Surface.js
modules/ve/ui/ve.ui.Surface.js
* Change all surfaceObserver calls to use new API

Change-Id: I0085e4a53c5a776733dce6944b867b8d2228ba4b
2013-09-10 11:54:57 -07:00
Ed Sanders 06c86b3881 The Great [...] Rewrite of 2013: Clipboard edition
Firefox:
* Doesn't fire events without a selection, so when all we have is a
  focusable node, create a dummy selection in the paste target so the
  browser triggers an event on command+C.

Clipboard keys:
* Instead of just creating a text hash which may or may not match up
  with the plain text in the clipboard data, just convert the clipboard
  store into an array and use the index as the key. Also prepend a
  random number (clipboardId) so on paste we can verify the copy came
  from the same CE document.
  The text hash is now used for validation if only HTML is written
  to the clipboard.

HTML:
* Instead letting the browser grab CE HTML, always get DM HTML from
  the converter as it is cleaner (no phantoms, linefeed markers, extra
  class names etc.), and will make cross-ve-instance pasting easier
  in the future.

Clipboard overriding:
* Always override the clipboard with the above HTML, either using
  clipboardData.setData if it is available (webkit) or by throwing
  the HTML into the pasteTarget and selecting it during pre-copy.

Bug: 53375
Bug: 49396
Bug: 52096
Change-Id: Id0f39c10818047bb4b8922e97cead153a770757f
2013-09-10 10:38:34 -07:00
jenkins-bot cba2935173 Merge "Add alt attribute to core image nodes" 2013-09-10 01:43:40 +00:00
jenkins-bot 272b27a959 Merge "Use EventSequencer for CE Surface events" 2013-09-10 01:29:52 +00:00
jenkins-bot 6a81acb44a Merge "Always deep copy when writing to and reading from the fake clipboard" 2013-09-08 03:46:03 +00:00
Ed Sanders dd73b873a8 Add alt attribute to core image nodes
Also update and refactor tests.

Change-Id: I96d08faed42118b713af8011c5d6befb760e65c9
2013-09-07 12:56:17 -07:00
jenkins-bot 78cba8cc24 Merge "doc: Fix incorrect syntax" 2013-09-07 02:10:57 +00:00
David Chan 79a1bdd691 Use EventSequencer for CE Surface events
Change-Id: I662b164b7bff16ec957f3e06004e477be27282b0
2013-09-06 18:13:44 -07:00
David Chan 8e77752deb Timoize the EventSequencer into a sleek, purring monster
Change-Id: Ia925d76d9a41b777861621724ced4db8371786b8
2013-09-06 17:30:50 -07:00
jenkins-bot 0c327d4f73 Merge "Replace renderingEnabled toggle with lock counter" 2013-09-06 23:15:49 +00:00
David Chan 495e83cf2b Replace renderingEnabled toggle with lock counter
modules/ve/ce/ve.ce.Surface.js
* remove methods enableRendering/disableRendering/isRenderingEnabled
* add methods incRenderLock/decRenderLock/isRenderingLocked
* Consequential method call changes
* try-finally blocks around incRenderLock/decRenderLock pairs

modules/ve/ce/ve.ce.ContentBranchNode.js
* Consequential method call changes

Change-Id: Icb71bf536c7bad3a6c0c6512a2efb9565b5bd086
2013-09-06 16:02:51 -07:00
Timo Tijhof 6843f15962 doc: Fix incorrect syntax
These are not considered errors in jsduck 4.x but are in 5.x.

Though we don't specifically want to support 5.x yet, these are
actually genuine errors that were already causing incorrect
documentation to be generated, even under 4.x (it just doesn't
warn for these under 4.x).

Not from 5.x warnings, but fixed while at it:
* Removed more redundant @method
* Added a missing @returns for ve.Range#flip
* Added newline at EOF

Change-Id: Idc22b46b082a813e8e1761403e1ebf908bf690c4
2013-09-06 20:29:18 +00:00
C. Scott Ananian 47545a5d6f Remove no-insertion metadata corner case from ve.dm.Transaction.pushReplace().
This version pushes a `replaceMetadata` operation after a `replace` to
fixup trailing metadata if there is no inserted region and the removed
region includes metadata.  This avoids a corner case where the
size of the metadata arrays inserted/removed in `Transaction.pushReplace()`
do not match the size of the data arrays inserted/removed.

We remove the now-unused `Document.getMetadataReplace()` method.

We also adjust `MetaList.onTransact()` so that it continues to work
properly when the number of metadata entries in `replace.insert` is
not the same as the number of metadata entries in `replace.remove`.

Change-Id: I1d600405b855ca1cb569853bb885b0752df47173
2013-09-06 01:07:37 +00:00
C. Scott Ananian 5830bce72c Correctly preserve metadata in Transaction.newFromUnwrap.
The `Transaction.pushReplace` method has a corner case if the removed
region has metadata and the inserted region is empty.  This works fine
unless there are two adjacent `pushReplace` operations, which can occur
in `Transaction.newFromUnwrap`.  Fix this by having `pushReplace` look
at a preceding replace and correctly merge the two operations if
possible (in particular in the tricky case where the previous case has
a zero-length insertion).  Pleasantly, this can be done without a lot of
special-casing code in `pushReplace` or `newFromUnwrap`.

Add test cases verifying the `newFromUnwrap` works correctly (both
in commit and in rollback) when there is metadata present.

Change-Id: I6cfec0d2b1823dad724422f018a3c73dc0c7f186
2013-09-06 01:06:59 +00:00
David Chan 8a2b55321c docs: Minor improvements
CODING.md
* Document the procedure for adding a new javascript class

ve.dm.MWExternalLinkAnnotation.js
ve.dm.MWInternalLinkAnnotation.js
ve.dm.ElementLinearData.js
ve.dm.LinearData.js
* Add whitespace line before preformatted code to fix a
  rendering bug

Change-Id: I54443ea3d4799328655d279f379d4ddc176c50a0
2013-09-05 23:56:59 +00:00
Rob Moen f7b6b1e99c Add abstract method for getMediaSources.
Change-Id: I8c51d91a1f8ad1a8c688a6dd3de8ac53d4f8d3f9
2013-09-05 16:39:13 -07:00
jenkins-bot c0fe8b877c Merge "Apply DOM changes in onProtectedSetup and onProtectedTeardown instead of constructor" 2013-09-05 22:57:53 +00:00
Inez Korczyński 301b287515 Apply DOM changes in onProtectedSetup and onProtectedTeardown instead of constructor
It's important in case of replacing root element ($) of a node, so new element
does have CSS class and contenteditable property set.




Change-Id: Icf14e2164e89114e6b7c10672b782d02f4c5daac
2013-09-05 22:05:23 +00:00
Roan Kattouw fce7b0e4e7 Fix doc comment in ve.ui.Surface.js
Change-Id: I3784ff22bde13440ad63b042337ae38e07661995
2013-09-05 11:25:49 -07:00
Roan Kattouw 73edc2a46f Add group to internal list items in test data
Previously we were just omitting the first parameter to
queueItemHtml()

Change-Id: Ib4b6d2877d6cfe6b8469a300f89a4a54cbec6da3
2013-09-05 11:25:49 -07:00
Roan Kattouw 0e51375aa9 Fix ridiculous MetaList test case
Doing retainMetadata followed by a replace (not replaceMetadata)
doesn't make any sense and its behavior is undefined, so don't do that
in the test suite.

Change-Id: Ica032b0a5122d24e40e43e3eb43fea940270aece
2013-09-05 11:25:49 -07:00
jenkins-bot 27dfe83e6f Merge changes I247d1b68,I5a8ca28a
* changes:
  Fix getOffsetFrom(Element|Text)Node for annotated aliens
  Add test for getOffsetFrom(Element|Text)Node
2013-09-05 07:51:16 +00:00
Ed Sanders 3c24c91a46 Fix getOffsetFrom(Element|Text)Node for annotated aliens
* Replace addOuterLength with a recursionDirection as we only
  want to add length when the first recursion was to the left,
  and add nothing if we recursed to the right.
* Use isContentEditable which is the proper calculated boolean.
  contentEditable is often just (string)'inherit' :/
  Mercifully this works in in IE.
* Only check for the IE ce bug if we aren't recursing at all.

Bug: 53766
Change-Id: I247d1b68484cb510335b5f6789269ec254376cfe
2013-09-05 00:35:53 -07:00
Ed Sanders e30c81d5a4 Add test for getOffsetFrom(Element|Text)Node
Assert the result at every offset in the DOM.

Change-Id: I5a8ca28a7ee22c49d23077ad6993499ec726bbb3
2013-09-05 00:25:35 -07:00
jenkins-bot ae62a0cde8 Merge "Internal lists render nothing in the CE" 2013-09-05 04:56:59 +00:00
Ed Sanders 8f72b083d3 Internal lists render nothing in the CE
Previously they were rendering hidden spans.

Remove hiding from internal items as they have no rendered parent.

Change-Id: Iacc12715900123cd5ab0ddefa713e57e9bea0d1b
2013-09-04 16:49:03 -07:00
Roan Kattouw 2c29dab288 Always deep copy when writing to and reading from the fake clipboard
Otherwise, changes to deeply nested structures like template blobs or
references will leak from the data model into the clipboard data.

Change-Id: I85d8d311f676d45856f30b3747e7383c70c95460
2013-09-04 16:03:56 -07:00
jenkins-bot feff1fbc24 Merge "Improve welcome dialog support for large fonts" 2013-09-04 23:02:05 +00:00
jenkins-bot ee1044d43d Merge "Fix context menu position for small inline nodes" 2013-09-04 22:59:13 +00:00
Trevor Parscal 0c42e51c8f Improve welcome dialog support for large fonts
Objective:

* Make the welcome dialog work with smaller fonts by increasing its
  size a bit, and also making its contents scroll vertically if needed

Changes:

ve.ui.MWBetaWelcomeDialog.js
* Move content into a scrollable and padded panel layout element

ve.ui.MWDialog.css
* Remove padding, now provided by panel layout

ve.ui.Dialog.css
* Remove min-height override, inherited value is fine
* Use max width and height instead of setting them directly

Bug: 52667
Change-Id: Ie35b041e13ef18ffcacef6d9e70439e4e1351e0a
2013-09-04 22:58:52 +00:00
jenkins-bot 8dc93b6a71 Merge "Merge undefineds into undefined rather than []" 2013-09-04 22:40:17 +00:00
Moriel Schottlender 6744af7733 Quickfix Language Tool
Correcting the language span tool so the ve.ui.LanguageInspector has
static name changed from 'language' to 'meta/language'

Change-Id: I66fd3d2558663c9f1304365a11fd1276e204a7e7
2013-09-04 18:32:21 -04:00
Trevor Parscal 416537ecb7 Fix context menu position for small inline nodes
The context menu was being positioned incorrectly for small inline
nodes, such as references or small templates. This fix moves the context
to the bottom, as well as placing it on the right or left in LTR and RTL
directions respectively.

Change-Id: I55de2a6464d0544e32118bf95dbb85c33354f025
2013-09-04 22:22:52 +00:00
Roan Kattouw 247368b902 Merge undefineds into undefined rather than []
ve.dm.MetaLinearData.static.merge( [ undefined, undefined, ... ] )
returned [ [] ], make it return [ undefined ] instead. This allows
us to lazily use the merge function to create metadata without having
to worry about denormalizing undefined to [] all over the place.

Change-Id: I41fe6472c2185a6315119a546a73765966d013d3
2013-09-04 13:09:04 -07:00
jenkins-bot 8dfa827a97 Merge "ve.EventSequencer: Post-event listening" 2013-09-04 20:08:42 +00:00
David Chan 793172e41e ve.EventSequencer: Post-event listening
modules/ve/ve.EventSequencer.js
* Class to sequence pre-event and post-event listening correctly

demos/ve/eventSequencer.html
* Plain HTML example page for testing EventSequencer and event sequences

Change-Id: I4ddb10a30c2f44015136a7978a185d0b13f0690b
2013-09-04 11:20:46 -07:00
jenkins-bot fc5003aa35 Merge "Collapse metadata on any removal." 2013-09-04 02:22:31 +00:00
C. Scott Ananian 7c1623d915 Cleanups for ve.dm.Transaction
Avoid making a copy of the entire data array by using `doc.data` and
`doc.data.getLength()` instead of `doc.getData()` and
`doc.getData().length`.

Get rid of some unnecessary conditionals in `Transaction.newFromWrap`: the
`tx.pushReplace()` and `tx.pushRetain()` methods will already gracefully
no-op if the replaced/retained region is empty; we don't need to add
extra control flow to handle that case.

Clarify offset math in `Transaction.newFromWrap`.

Fix a minor bug in `Transaction.newFromInsertion`: the final retain didn't
account for the length of the removed region, if `doc.fixupInsertion`
creates one.  (This usually doesn't happen.)

Remove an inaccurate TODO in `Transaction.pushReplaceMetadata()` -- it is
no longer a straight copy/paste of `Transaction.pushReplace`, so a refactor
isn't really called for.

Change-Id: I7d86a2449978365d69d4a5ed43116c2e9945475d
2013-09-04 01:41:07 +00:00
jenkins-bot 630edd049c Merge "Kill domAttributeWhitelist in favor or renderHtmlAttributes" 2013-09-04 00:28:14 +00:00
Trevor Parscal c457d8afcc Add keyboard shortcuts for formatting tools
Objective:
* Add keyboard shortcuts for paragraph, heading 1-6 and pre-formatted

Testing:
* Using [control+num] triggers appears to work well on Chrome, Safari, Firefox and Opera on Mac

Changes:
ve.init.Target.js, ve.init.mw.ViewPageTarget.js
* Add formatting commands to targets
ve.ui.MWFormatTool.js
* Add mediawiki specific format tools and commands
ve.ui.CommandRegistry.js
* Add commands for all formatting tools
ve.ui.TriggerRegistry.js
* Add triggers for formatting tools

Bug: 33512
Change-Id: I5d6176eff50aa3cea72aed226ca06512629412d4
2013-09-03 17:17:03 -07:00
Trevor Parscal 8dfbc5baa5 Make tools generic and add fancy tool groups
Objectives:

* Got rid of mw prefixing in tools, inspectors and dialogs
* Simplify tool classes so they can be generically used as items in bars, lists and menus
* Add support for a catch-all toolbar group
* Simplify tool registration, leaning on tool classes' static name property
* Move default commands to command registry
* Move default triggers to trigger registry
* Get language tool working in standalone

Change-Id: Ic97a636f9a193374728629931b6702bee1b3416a
2013-09-03 11:27:39 -07:00
C. Scott Ananian 5095e27925 Collapse metadata on any removal.
In ve.dm.Document.getMetadataReplace(), we used to only merge metadata
if the amount removed is larger than the amount inserted.  But this
could end up putting metadata in odd positions, for example if you
have Foo[[Category:Bar]]Baz and you delete 'ooBa' and replace it with
{image}xxx{/image}, then the category ends up inside the image.

We should always merge metadata when a segment is deleted, so that it
appears outside any new structure added.

There's a weird corner case here when a segment is removed but no
insertion is made: the removed metadata then needs to get glommed onto
the next element.  We extend the insert/replace metadata array
when this happens.

Bug: 53444
Bug: 53445
Change-Id: I51d55fb370b473273f9cf152fdd0f356377d4109
2013-09-01 11:00:51 -04:00
Timo Tijhof 8cea089f3b ce: Use a better transparent pixel image
See also http://stackoverflow.com/a/13139830/319266:

> Some are unstable and cause CSS glitches. [If] you have an
> <img> and you use the tiniest transparent GIF possible, it
> works fine[. if] you then want your transparent GIF to have a
> background-image, then this is impossible. For some reason,
> some GIFs such as the following prevent CSS backgrounds (in
> some browsers).
>
> == Shortest (but unstable) ==
> data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
>
> == Stable (but slightly longer) *use this one* ==
>
> data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
>
> Also: don't ommit image/gif. This will break in several browsers.

For the record, this is not limited to rare browsers.
It also affects latest Chrome in some cases as confirmed by
Christian (it'd be white instead of transparent in some cases
when uses as a css background-image without border).

Change-Id: If9ff8a0820c217b6c23e3335944907939a37bef7
2013-08-30 17:51:20 -07:00
Ed Sanders 2d720bd6d9 Allow phantoms and focus areas to be overridden
And actually use this functionality on MWBlockImage to
highlight centred images correctly.

FocusableNode
* Actually use $focusable to render the highlight correctly

ProtectedNode
* Allow a $phantomable element to define which element to
  highlight on mouseenter
* As phatoms are built off shields, make sure a shield is
  given to $phantomable

RelocatableNode
* Allow a $relocatable element to define which element the
  relocatable marker is measured against

ui.Context
* Use $focusable (when available) for positioning the popup

Plus some documentation fixes

Change-Id: I370337239af4fc935cd86757b3ce03011bae5ba8
2013-08-30 14:04:17 -07:00
Timo Tijhof bdd1a73eaa data: Rename MessagesModule to DataModule
Also..
* removed an incorrrect comment referring to the old module
  name (standalone didn't use the VisualEditorMessagesModule).
* made it use debug mode to determine whether to minify or
  prettify the js code.

Change-Id: I493007649fba27e7faab0cf743eded5f68714c50
2013-08-29 18:07:35 -07:00
Moriel Schottlender 84cca4f472 Cursor fix after link insertion
When a link was inserted, the cursor position was backwards (at the
beginning of the word rather than its end) - this commit fixes that
problem.

Also, thanks for the help Ed!

Bug: 53560
Change-Id: I04fe1ca4c9126898e7bf85cdf519794d66b4f38b
2013-08-29 21:46:28 +00:00
jenkins-bot 4291b2a308 Merge "When pasting, try to use original range" 2013-08-29 18:26:53 +00:00
jenkins-bot 0cdcf2d155 Merge "Always give references names. Ignore if used once." 2013-08-29 18:26:04 +00:00
jenkins-bot 0ae19ffa40 Merge "Set contentEditable using jQuery#prop" 2013-08-29 17:54:56 +00:00
Ed Sanders 98cad0f410 Set contentEditable using jQuery#prop
Also always use strings 'true'/'false' for the value, because
it is a string property (spellcheck, however, is a boolean)
and always use a capital second 'E' in the name.

Change-Id: Ia4e1f9edfd8f236fe81df190e6a68729d7b52243
2013-08-29 09:59:55 -07:00
jenkins-bot 467ddf5ab8 Merge "Followup 41a4b3fb: use .not()" 2013-08-29 01:55:19 +00:00
jenkins-bot b41d3bee07 Merge "Add ULS to the standalone" 2013-08-29 00:44:02 +00:00
Roan Kattouw c68e550bb3 Add ULS to the standalone
Also rerun makeStaticLoader

Change-Id: If9fae5dc5ea37567c50ab5d462308ff05e053c8c
2013-08-28 17:35:37 -07:00
Moriel Schottlender d4c2374515 Fixing inspector popup position
The inspector popup should appear relative to the position of the related
calling method - either relative to the cursor (like in links and language)
or relative to the focusableNode (like in templates/transclusion).

Bug: 50905
Change-Id: I07f58d0c6561adecbec560fc24bcb6e590f2cd9f
2013-08-28 23:59:36 +00:00
jenkins-bot ae4fee0883 Merge "AnnotationInspector insertion over blank selection" 2013-08-28 23:44:07 +00:00
Ed Sanders 458f8d1a82 Move contentEditable=false to protected node
Because that's where it should be.

Bug: 53507
Change-Id: I9afffea238a774b884d4d2434d3523e4c4e445b2
2013-08-28 16:18:55 -07:00
Ed Sanders e0018e8e94 Rename 'DOM Changes' => 'DOM changes'
Because we don't use title case in comments

Change-Id: I5cdd3241aba0727a3cd5d0ded972ae54abf1efd0
2013-08-28 15:55:35 -07:00
Ed Sanders 52de8b76ec Always give references names. Ignore if used once.
This avoids problems when unnamed references were copy-pasted.

Knowing that key is always non-null simplifies a lot of logic
elsewhere.

Bug: 53365
Change-Id: I3a23123ae732d9583814d38dd880a0cdf691fd5d
2013-08-28 12:47:33 -07:00
Ed Sanders 182d9bbeea Check clipboardData exists before accessing it
Bug fix for browsers which don't have an event.clipboardData
property. The check is done correctly in onCopy but not onPaste.

Change-Id: I3cdf4c0358aa145dcb70c2c103d08a0002001fd4
2013-08-28 11:47:13 -07:00
Moriel Schottlender ba7e0ff273 AnnotationInspector insertion over blank selection
This commit fixes two issues with insertion of annotations in blank space:
* LanguageInspector issue with inserting an language annotation inside any
  whitespace (selection of space between words or collapsed selection in
  blank line)
* AnnotationInspector issue with collapsed selection inside slugs. If
  the marker was in a slug collapsed selection, activating
  AnnotationInspector would expand the range to the closest word (on the
  next paragraph). This commit makes sure the expansion for the next word
  only happens if the selection is outside a slug.

Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
2013-08-27 20:34:57 -04:00
Ed Sanders f50102f521 Disable inserting/changing references when surface widget is empty
This listens to change events on the surface and checks to see if
there is more than just an empty paragraph node.

Bug: 53345
Change-Id: Ic8fa84d7cdcbffd154178939d0ec8c2c4f86c415
2013-08-27 17:18:52 -07:00
Ed Sanders ddb608e6bc When pasting, try to use original range
This functionality was (accidentally?) removed by I8f8a240a. It
stops us from over-zealously balancing data when we can get away
with just pasting the original selected range (e.g. it always wraps
collections of text and content nodes in another paragraph).

Bug: 53364
Change-Id: I93fa56c4e43083993c310e0050087e9d1de1e08b
2013-08-27 15:40:59 -07:00
jenkins-bot 92c7be9b31 Merge "Detect outdated pending post KeyPress handler" 2013-08-27 22:31:07 +00:00
David Chan d867ef8fc0 Detect outdated pending post KeyPress handler
modules/ve/ce/ve.ce.Surface.js
* Schedule the post-keypress async handler in a way that can be cancelled.
* Cancel it and run the handler immediately if another key event happens.

Bug: 53079
Change-Id: If139ff3230c10caa616743f71659c4606d290310
2013-08-27 13:55:02 -07:00
Roan Kattouw 10393b8773 Followup 41a4b3fb: use .not()
I claimed that it didn't preserve text nodes, but it does. It's just
that there's a bug where it doesn't preserve text nodes if the selector
passed to it is too simple, but 'link, meta, style' is complex enough
to avoid triggering this bug.

Change-Id: Id4a60dc87b8d4c613bc7013641b116dd7c331ac1
2013-08-27 13:53:17 -07:00
Roan Kattouw 051867c3ab Actually use GeneratedContentNode in AlienNode
ce.AlienNode was mixing in GeneratedContentNode, but wasn't actually using
it properly. This commit fixes this so that AlienNode can benefit from
the <meta>/<link>/<style> stripping code in GeneratedContentNode.

Also added a getHashObject() function to dm.AlienNode to summarize the
domElements attribute because ve.getHash() chokes on it otherwise.

Change-Id: Ief3be94f9730297abe0e3c57506b81a8ff1d136d
2013-08-27 13:53:17 -07:00
jenkins-bot 0ef918b6f0 Merge "Language Inspector Default Fix" 2013-08-27 20:36:42 +00:00
jenkins-bot 8b773cf9a4 Merge "Give document real focus after cut" 2013-08-27 20:21:42 +00:00
jenkins-bot 80ded50c8b Merge "Copy-paste data fixes" 2013-08-27 20:21:00 +00:00
jenkins-bot 78141a6f33 Merge "Don't render <meta>/<link>/<style> tags in GeneratedContentNode" 2013-08-27 18:28:34 +00:00
Roan Kattouw 41a4b3fb51 Don't render <meta>/<link>/<style> tags in GeneratedContentNode
There is no good reason why we'd render these tags, and their presence
causes Chrome to crash while cutting across them.

Bug: 50043
Change-Id: I611e3907cf20fa27dbef89ea941d0b787a44ba4f
2013-08-27 11:26:37 -07:00
jenkins-bot d7702819e8 Merge "Make ve.dm.Surface.{start,stop}HistoryTracking idempotent." 2013-08-27 16:27:41 +00:00
C. Scott Ananian 4fee78227d Make ve.dm.Surface.{start,stop}HistoryTracking idempotent.
Add a little robustness, guaranteeing that we don't end up with multiple
history tracking tasks running, leaking one, or try to clear a non-running
interval.

Change-Id: I41db2d6fefc7f45f150aa14ecefc648760ad6200
2013-08-27 09:25:54 -07:00
C. Scott Ananian 7fb7665608 Avoid crash after ve.dm.Surface.purgeHistory().
The selection property is never null; it is initialized to Range(0,0).
If it is set to null in purgeHistory(), the next call to
ve.dm.Surface.change() will crash.

Change-Id: Ia45c0ba26291e8ad09c445fdf2323710b5ab409f
2013-08-27 09:37:37 -04:00
Roan Kattouw ce138adbdb Kill domAttributeWhitelist in favor or renderHtmlAttributes
domAttributeWhitelist wasn't actually being observed. Instead, we
already had the code in place to treat renderHtmlAttributes as a
boolean/whitelist/blacklist hybrid, it just wasn't used that way
yet.

This makes the interface nicer and fixes the bug where all attributes
(including data-parsoid and even things like onmouseover) were
rendered by CE.

Change-Id: I02e266c7c7dc197ed845164b7a705d786846a33b
2013-08-26 18:37:50 -07:00
Ed Sanders fd410c03a7 Give document real focus after cut
If only a FocusableNode is selected the document doesn't have
real focus, so we must do it manually.

Bug: 53362
Change-Id: I781f59dda7f2884ff02f6688c2c8c037ac7ed1a6
2013-08-26 23:06:13 +00:00
Ed Sanders 99692230b1 Copy-paste data fixes
* Assign cut/copy/paste events to the document so that
  they are triggered when the CE doesn't have real focus
  e.g. only a FocusableNode is selected
* Use clipboardData.setData when available. The key can
  be stored and retrieved perfectly in text/xcustom but
  this technique doesn't work in FF or IE
* Just use text content for key as this is what is written
  to the clipboard, so this can be used directly without
  having to get the content from the pasteTarget.

Bug: 48604
Bug: 49396
Change-Id: Ib3702f9441f6ee3fa34ec071f00994dd7e591d99
2013-08-26 15:25:15 -07:00
Timo Tijhof d0d0e156b8 doc: Restore and clean up documentation for Platform subclasses
- Added missing @inheritdoc so that generated documentation is
  not empty.
- Fixed type of mw.Platform#getMessage from (implied) @property
  back to @method.
- Removed notes from mw methods. They are prepended instead of
  appended, thus overriding the useful single-line summary
  of the method with this random note. Description should either
  be replaced entirely (e.g. no @inheritdoc) or inherited.
- Rephrased a few description to be consistent with the others
  (e.g. "Get .." and "Add .." instead of "Gets .." or "Adds..").

Follows-up cbe35632f1.

Change-Id: Ie55bb9e18f1524b706f0e195300170e4d552bf73
2013-08-26 12:47:28 -07:00
Moriel Schottlender 47f9c66798 Language Inspector Default Fix
Fixes the situation where there's a language set but not a direction.

Change-Id: If353b36ff0700717f1b8fd917b39c230de5ec272
2013-08-26 03:17:45 -04:00
jenkins-bot 56ff25cb7c Merge "Fix copy and paste of backwards selction" 2013-08-22 18:14:17 +00:00
jenkins-bot 9a7b7e9176 Merge "getAnnotationsFromRange should only ignore non-content data" 2013-08-22 18:12:03 +00:00
Ed Sanders f9b92e8909 Fix copy and paste of backwards selction
Was previously broken as getSlice was using ve.Range#equals to
compare ranges which is direction-sensitive.

Bug: 51538
Change-Id: Ib58d1d8fd11b62388c111a5da66171d13a9db9c2
2013-08-22 18:10:34 +00:00
jenkins-bot 97c03da395 Merge "Don't emit Surface changes back to the Surface" 2013-08-22 09:48:23 +00:00
Ed Sanders 380b368986 getAnnotationsFromRange should only ignore non-content data
Currently ignores all non-element data, but element content (e.g.
images) can be annotated.

Added test cases and updated the test runner to only compare
store indexes for a more readable output.

Bug: 50127
Change-Id: I234586a28072811c8288aab56f6abaaa0da0c88d
2013-08-21 22:32:34 +01:00
David Chan 24dae99065 Don't emit Surface changes back to the Surface
modules/ve/ce/ve.ce.SurfaceObserver.js
* add emitContentChanges argument to poll (and start and stop)

modules/ve/ce/ve.ce.Surface.js
* Pass emitContentChanges=false to calls to start/stop in certain places
* Explicitly pass emitContentChanges=true elsewhere, to preserve prior
  behaviour

modules/ve/ui/ve.ui.Surface.js
* Explicitly pass emitContentChanges=true to poll

modules/ve/test/ve.test.js
* Escape non-BMP unicode text literals (to prevent potential editor
  problems)

Bug: 50105
Bug: 50346
Bug: 50631
Bug: 51477
Bug: 52716
Change-Id: I19ec7eaa0e3224cbfc7e7188e964183d7393c9a7
2013-08-21 17:26:32 +00:00
jenkins-bot ffdbc92a41 Merge "Toolbar API" 2013-08-20 23:17:42 +00:00
Trevor Parscal 332e31fb00 Toolbar API
Objectives:

* Make it possible to add items to toolbars without having to have all
  toolbars know about the items in advance
* Make it possible to specialize an existing tool and have it be used
  instead of the base implementation

Approach:

* Tools are named using a path-style category/id/ext system, making them
  selectable, the latter component being used to differentiate extended
  tools from their base classes, but is ignored during selection
* Toolbars have ToolGroups, which include or exclude tools by category or
  category/id, and order them by promoting and demoting selections of
  tools by category or category/id

Future:

* Add a way to place available but not yet placed tools in an "overflow"
  group
* Add a mode to ToolGroup to make the tools a multi-column drop-down style
  list with labels so tools with less obvious icons are easier to identify
  - and probably use this as the overflow group

Change-Id: I7625f861435a99ce3d7a2b1ece9731aaab1776f8
2013-08-20 16:08:26 -07:00
jenkins-bot 841a414c31 Merge changes Id2328d6e,I840b689d
* changes:
  Remove language variants from bold/italic now we have fallbacks
  Implement fallback langauges
2013-08-20 21:38:33 +00:00
jenkins-bot cd5ee730ab Merge "Remove duplicate comments from platform code" 2013-08-20 21:25:48 +00:00
jenkins-bot 4f6e42b699 Merge "Subscript is one word (and so is superscript for that matter)" 2013-08-20 20:37:49 +00:00
Trevor Parscal 4e6694c75e Subscript is one word (and so is superscript for that matter)
Objective:

* Unify the capitalization of subscript and superscript

Change-Id: I5a7fbc2d864c896ebb26177cf05c7adddacd8829
2013-08-20 13:34:50 -07:00
Ed Sanders 433f1eebcb Remove language variants from bold/italic now we have fallbacks
Bug: 53094

Change-Id: Id2328d6e7f89cd9deddde67b57cd7e3fc55683e6
2013-08-20 20:18:37 +00:00
Ed Sanders 069b757afc Implement fallback langauges
Return an array of languages instead of a single language. Languages
containing hyphens return themselves along with the root code e.g.
'en-GB' => ['en-GB', 'en']

Change-Id: I840b689d0021d865f93d16d075473a2ed0a9f0d8
2013-08-20 20:12:46 +00:00