Commit graph

840 commits

Author SHA1 Message Date
MatmaRex e6fd823d6f ve.ce.Surface: Prevent focus loss on the document node in Opera
Opera triggers 'blur' on the document node when clicking on any <a>
link and never trigger 'focus' until after the user blurs the document
node *again* (by clicking outside of it or pressing 'Esc').

This causes the change polling to stop (SurfaceObserver#stop is called
without a subsequent call to SurfaceObserver#start).

To avoid this let's bind a delegated 'focus' event on all <a> links
inside the document and refocus it whenever that happens.

Bug: 47793
Change-Id: I7962f59bd02e075f91e42e6514b390c0d0feb3ab
2013-07-22 21:09:52 +02:00
James D. Forrester 79aff53400 De-alienate <code>foo</code> blocks (code element)
Adding the <code> element as a matched text style annotation, plus some
tests (for all the other un-tested text styles as well, whilst I'm at
it).

We'll need an icon, a button and a way of the buttons not forever
extending the length of the toolbar to properly edit <code> spans, but
this is a start.

Bonus: unit test coverage for all TextStyleAnnotations

Bug: 51590
Change-Id: I5438bcf2ec6eeb2e50400f8013964f91c33ce455
2013-07-19 00:48:46 +00:00
jenkins-bot a2ea33fb95 Merge "Handle backspace correctly when in a slugs" 2013-07-18 22:20:05 +00:00
Ed Sanders c414147b5a Handle backspace correctly when in a slugs
We need to detect if the endNode we are trying to move is
inside our original delete selection, and not perform the
move if it is.

Bug: 50076
Change-Id: Ib89706c8717d13829bf89e44c4fb39e16a00821e
2013-07-18 12:33:42 +01:00
Ed Sanders 56ef8cb5b5 Create MWResizeableNode mixin to control defaultSize flag
Previously wasn't being updated to 'false' after a width/height
attribute change.

Bug: 50645
Change-Id: Id5dcd6998e0125757238426f8052505d131d712d
2013-07-16 23:13:40 +01:00
Roan Kattouw ce3014c768 Remove superfluous clear() when pawning
We already call clear() 4 other times in this code path, including
one right at the end of change(), which is called right before this
clear() call.

Change-Id: I6d5ba5075e1b24a981546243977c6a8501748c5f
2013-07-16 00:37:51 +00:00
Roan Kattouw f9864e9288 Continue links
This isn't as simple as just dropping applyToAppendedContent = false
on LinkAnnotation, because browsers differ in their continuation
behavior. Firefox continues links, but Chrome doesn't.

To work around this, add a property indicating that the annotation
needs its continuation behavior to be forced.

Rename areAnnotationsCorrect() to needsPawn() accordingly.

Bug: 49931
Change-Id: Id6424af89c92bba2be87736e8a937e0f2067c007
2013-07-16 00:29:55 +00:00
Ed Sanders 4af4f7928d Replace text strings with grapheme arrays in onContentChange
Was previously generating incorrect transactions when document
contained multibyte characters.

Bug: 51140
Change-Id: Ie5f749768f970b2aef09e667f844d2ef5961207b
2013-07-15 22:57:40 +01:00
jenkins-bot 691d9fe462 Merge "Language Inspector: CE / DM" 2013-07-10 19:13:40 +00:00
Moriel Schottlender fdcec169d1 Language Inspector: CE / DM
This is the infrastructure for the Language Inspector prototype, defining
the dm and ce pieces of the <span lang='xx' dir='yy'> annotations. It also
sets up a visual indicator for language blocks (with informational tooltip
for the user while editing. The UI is built on top of this.

Bug: 47759
Change-Id: I239eef5124e29369ea9c5d8c0f49b2f6a61bc053
2013-07-10 12:11:27 -07:00
Trevor Parscal 33e2c8f280 Lock surface while inspectors are animating open
Objective:

* Prevent input while the inspector is animating open

Changes:

ve.ui.LinkInspector.js
* Disable and then re-enable the surface while the inspector is opening

ve.ce.DocumentNode.js
* Remove opacity changes on disable/enable

ve.init.mw.ViewPageTarget.js
* Change the opacity of the document when save dialog is open

Bug: 51075
Change-Id: Ic7910a666b33b41b57b035a15cf1f8c9264e7111
2013-07-09 17:16:25 -07:00
Catrope 30ebc9a656 Revert "Add support for <blockquote> elements"
Whoops, merged too soon. The dropdown part of it doesn't
actually work right.

This reverts commit 3c51ebad93.

Change-Id: Ieafbf18ca8a43b07e33a787772abbc77aef63e4c
2013-07-09 21:35:47 +00:00
James D. Forrester 3c51ebad93 Add support for <blockquote> elements
Bug: 51009
Change-Id: I7ba1635e4f856a021e1a7a2d26a8714230c9364a
2013-07-09 13:15:06 -07:00
Christian Williams 1e298ffbc0 Fix focusable highlights
!$element.is( ':visible' ) - jQuery .is() returns boolean based on the
parameter.

$element.not( ':visible' ) - jQuery .not() returns a filtered jQuery
collection with elements matching the parameter removed.

Change-Id: Iedf55f3453514ee710bbb6d702bbf9a5570a4a1d
2013-07-03 13:49:11 -07:00
Roan Kattouw 92c38eab85 The great directory split of 2013
Move all MW-specific files into the ve-mw directory, in preparation
for moving them out into a separate repo.

All MW-specific files were moved into a parallel directory structure
in modules/ve-mw . Files with both generic and MW-specific things were
split up. Files in ve/init/mw/ were moved to ve-mw/init/ rather than
ve-mw/init/mw ; they're still named ve.init.mw.* but we should change
that. Some of the test files for core classes had MW-specific test cases,
so those were split up and the test runner was duplicated; we should
refactor our tests to use data providers so we can add cases more easily.

Split files:
* ve.ce.Node.css
* ve.ce.ContentBranchNode.test.js (MWEntityNode)
* ve.ce.Document.test.js (some core test cases genericized)
* ve.dm.InternalList.test.js (uses mwReference test document)
* ve.dm.SurfaceFragment.test.js, ve.ui.FormatAction.test.js
** Made core tests use heading instead of mwHeading
** Updated core tests because normal headings don't break out of lists
** Moved test runners into ve.test.utils.js
* ve.ui.Icons-*.css
* ve.ui.Dialog.css (MW parts into ve.ui.MWDialog.css)
* ve.ui.Tool.css
* ve.ui.Widget.css (move ve-ui-rtl and ve-ui-ltr to ve.ui.css)

ve.dm.Converter.test.js: Moved runner functions into ve.test.utils.js

ve.dm.example.js:
* Refactored createExampleDocument so mwExample can use it
* Removed wgExtensionAssetsPath detection, moved into mw-preload.js
* Genericized withMeta example document (original version copied to mwExample)
* Moved references example document to mwExample

ve.dm.mwExample.js:
* Move withMeta and references example documents from ve.dm.example.js
* Add createExampleDocument function

ve-mw/test/index.php: Runner for MW-specific tests only

ve-mw/test/mw-preload.js: Sets VE_TESTDIR for Special:JavaScriptTest only

ve.ui.Window.js:
* Remove magic path interpolation in addLocalStyleSheets()
* Pass full(er) paths to addLocalStyleSheets(), here and in subclasses

ve.ui.MWDialog.js: Subclass of Dialog that adds MW versions of stylesheets

ve.ui.MW*Dialog.js:
* Subclass MWDialog rather than Dialog
* Load both core and MW versions of stylesheets that have both

ve.ui.PagedDialog.js: Converted to a mixin rather than an abstract base class
* Don't inherit ve.ui.Dialog
* Rather than overriding initialize(), provide initializePages() which the
  host class is supposed to call from its initialize()
* Rename onOutlineSelect to onPageOutlineSelect

ve.ui.MWMetaDialog.js, ve.ui.MWTransclusionDialog.js:
* Use PagedDialog as a mixin rather than a base class, inherit MWDialog

bullet-icon.png: Unused, deleted

Stuff we should do later:
* Refactor tests to use data providers
* Write utility function for SVG compat check
* Separate omnibus CSS files such as ve.ui.Widget.css
* Separate omnibus RL modules
* Use icon classes in ViewPageTarget

Change-Id: I1b28f8ba7f2d2513e5c634927a854686fb9dd5a5
2013-07-02 20:51:38 -07:00
Rob Moen c472b2fe4a Make local overlays local to surface and remove insane z-indexes
ve.ui.Surface.js
* Make local overlay a child of ve-ui-surface and a sibling to
  ve-ce-surface elements.
** This keeps local overlays relative to their surface and eliminates the
   need for insane z-indexes.

ve.ui.PopupWidget.js
* PopupWidget boundaries are now relative to ve-ce-surface and no longer
  protrude out

ve.ce.Node.css, ve.ui.Window.css
* Removal or replacement of insane z-indexes.

ve.ce.FocusableNode.js, ve.ce.ProtectedNode.js, ve.ce.ResizableNode.js,
ve.ui.Context.js
* Translate offsets from local overlay

ve.init.mw.ViewPageTarget-monobook.css,
ve.init.mw.ViewPageTarget-vector.css
* Skin specific z-indexes for global overlay

ve.init.mw.ViewPageTarget.js
* Applied direction specific mw class to ce.Surface vs ui.Surface to
  prevent mw content styles from being applied to ui elements.

ve.ui.Dialog.css
* Adjustments to surface inside of dialog so that relative offsets for
  local overlays can be properly calculated.

ve.ui.Surface.css
* Explicitly force .ve-ui-surface to be relative so that it's children can
  be relatively positioned.

ve.ui.Widget.css
* Removal of unnecessary font-size properties now that local overlay is
  sibling of surface.

ve.js
* Added get relative position helper method to translate position offsets
  from target parent

Bug: 50241
Change-Id: Ibadce404a2286bc5dcec48f0d9da89004dbbd867
2013-07-02 19:35:43 +00:00
jenkins-bot 1e57c72122 Merge "Disconnect bound reference list events on teardown" 2013-07-02 19:22:09 +00:00
Christian Williams f2a51d7383 Resizing Images Sometimes Sets Unusable Size
Resize handle event handling was set up to bind on focus and
unbind on document mouse up. The problem is that focus can be
set programmatically and sometimes more than once. This would
cause the image to be properly resized once, but immediately
resized again to 0x0. Now, before binding events to the resize
handles, all resize handle events are unbound.

Change-Id: I22b7902d303b5ca43e132c121d743d6815980fc6
2013-07-02 12:12:39 -07:00
Christian Williams 5d44800b53 Correct Rendering for Block Images After Resize Undo
If a block image is resized and undone, there are lots of problems.

* The block image gets the wrong size. When rolling back the
transaction, height and width are passed as strings.
MWBlockImage tries to set the width to: width + 2. A 300px image
became 3002px.

* Resize handles didn't reposition and resize

* Relocatable drag marker didn't reposition and resize

* Focusable highlights didn't reposition and resize.

Change-Id: I8792b567b77da90ce5a2ad132e306705c5706606
2013-07-02 12:08:42 -07:00
Trevor Parscal 9b91bb1cf3 Disconnect bound reference list events on teardown
Reference lists would never disconnect, and some transactions would cause them to be "updated" even though they don't have a document anymore.

A way to test this is to insert an image in a document with some references. When you click apply, it crashes.

The solution was to make sure we actually disconnect from the internalList and listNode on teardown.

Change-Id: Ieb0354938b68fe5e7965f61f9ccce07cd6fb1120
2013-07-02 12:08:02 -07:00
jenkins-bot c331c1980e Merge "Minor performance optimization and cleanup in FocusableNode" 2013-06-30 20:05:16 +00:00
Inez Korczyński daa83d2cfa Minor performance optimization and cleanup in FocusableNode
Change-Id: I4385b07c35e330a43827c891b94460424986526d
2013-06-30 13:01:47 -07:00
Inez Korczyński a08da9ffe4 Make node resizing happen inside onAttributeChange
This change fixed not yet reported bug that undo/redo for resizable nodes wasn't working.

Change-Id: Id61389bc6dcfffdd6df1d22cdb5c85e58513fb8c
2013-06-30 12:59:42 -07:00
Inez Korczyński 59e7a7bdcf Simplify ve.ce.ResizableNode by removing code for 'transition' which is not used anyway
Change-Id: I561395cab3271a93f43d14d17db0c2dcee74ae4a
2013-06-29 21:47:58 -07:00
jenkins-bot 7fbc4e8add Merge "Firefox misplaces cursor when moving between lines" 2013-06-29 00:25:17 +00:00
jenkins-bot f8fd236a05 Merge "Stop floated transclusions floating out of themselves" 2013-06-28 23:46:00 +00:00
Inez Korczyński 887255500a Stop floated transclusions floating out of themselves
This is done by setting renderHtmlAttributes to false, for both block
and inline transclusions.

Bug: 49925
Change-Id: I975cf1de3b273a5189e6edf7db937c4388fa4fbe
2013-06-28 16:44:00 -07:00
Christian Williams ca0d79f340 Firefox misplaces cursor when moving between lines
When the cursor is programmatically moved, as we need to do
from time to time, Firefox's internal reference for the appropriate
cursor location on nearby lines is maintained, creating an
unexpected experience.

The fix is to wiggle the selection. This tricks Firefox into thinking
that it adjusted the selection natively.

Bug: 48289
Change-Id: I75e7e4467ec1c3faf344709886b9be5b1423cd3e
2013-06-28 15:37:26 -07:00
Rob Moen 57673643a2 Don't draw highlights over hidden elements.
Rational is that you wouldn't want to highlight something that is not
visible.  And, obtaining offsets for hidden slugs in this case does not
return correct values.

Bug: 49818
Change-Id: Ic2818423c26f5bbb2c056c3c94740d822be4f1b8
2013-06-28 15:30:17 -07:00
Ed Sanders 9df1a59818 Disable inspection of references with unknown contents
Ed & Roan:
 Disable editing of references of which we are unable to find the
 source (e.g. <ref name="x"> without a target, or when the target is
 currently nested in something we don't yet process such as inside a
 <references> block or a template).

Timo:
 Improve UI to not be a regular focusable node where the inspector just
 won't show up but add a not-allowed cursor and explanatory tooltip.

James:
 Fix messages to refer to VisualEditor instead of "the" VisualEditor.

Change-Id: Ib2bca092ce13c9187fa8b27ad6a6404cae02aea2
2013-06-27 20:34:32 -07:00
Trevor Parscal 0aac4c7e60 Reference insertion, new and existing
Objectives:

* Split reference dialog (at least for now) an edit and an insert dialog
* Add reference search widget for selecting an existing source, or
  choosing to add a new one
* Abstract reference names, don't allow editing them and generate them
  when needed
* When editing groups, move the internal item and update all references
  to it
* Resolve name conflicts when moving a reference to a new group by
  generating a new list key

Bonus:

* Add getNodeGroups method to internal list
* Add getUniqueListKey method to internal list
* Add destroy functionality to ce.node to release events and references

Bug: 49733
Change-Id: Ib244ff6ad9b4cee1decfd9b9e1d3d4e9cdcfb78c
2013-06-27 18:11:31 -07:00
jenkins-bot d467c5a05e Merge "Unhack detached protected CE node shields" 2013-06-28 00:45:06 +00:00
Trevor Parscal ae6f91677e Unhack detached protected CE node shields
Objectives:

* Make protected CE nodes only add shields when attached to a surface
* Remove hack in reference list node used to work around this issue

Change-Id: I48d4478558b49037b80b6131e1b2e01dc4f9ec47
2013-06-28 00:42:34 +00:00
jenkins-bot d5d4d2a220 Merge "Pasted content is annotated" 2013-06-28 00:42:02 +00:00
Christian Williams 68f635b482 Local Overlay Stacks
After a spirited discussion, localOverlay is getting some children.

* localOverlayBlockers - UI elements that are meant to prevent
interaction with the element. This includes Phantoms and
Highlights.

*localOverlayControls - UI elements that are meant to be
interacted with in order to modify the element. This includes
resize handles and drag marker.

*localOverlayMenus - UI elements that should always position
above all other controls. This includes the context menu.

Bug: 50159
Change-Id: Ic69c2ad275389a31c9fbaf47f3665dcdbb7ac2af
2013-06-28 00:30:54 +00:00
Christian Williams 7d5d779320 Pasted content is annotated
Applying insertionAnnotations to pasted content.

Change-Id: I8f8a240ae8970624c34ae005290acc77cea73180
2013-06-27 17:30:31 -07:00
Trevor Parscal 20585c956a Close dialogs on escape
Objective:

* Make the escape key close dialogs, like pressing the X button
* Auto-focus the iframe on window open

Bonus:

* Add ESCAPE and SHIFT to ve.Keys and use instead of hardcoding numbers
* Use ve.Keys in some other places too

Bug: 49809
Change-Id: Ibf1fce5e24efcd83d9e1465c3cdaac24ff3fb45d
2013-06-27 17:00:35 -07:00
jenkins-bot da866e1c33 Merge "Invoke getClonedElement() on each element on copy" 2013-06-27 22:31:39 +00:00
Roan Kattouw c3340e273c Invoke getClonedElement() on each element on copy
This ensures that attributes and properties that are supposed to be
stripped on copypaste are actually stripped.

Bug: 49307
Change-Id: I8c90f4a0b33acba6eea3180cc077f8dc440e6e7b
2013-06-27 14:20:53 -07:00
Rob Moen 4f773438fb Don't advance cursor when adding new line at start of node
Bug: 48735
Change-Id: I934888ce727258cf3feb3e28d822e507554da701
2013-06-27 12:03:43 -07:00
Ed Sanders 10948ba91f Preserve scroll position after dialog close
Bug: 49977
Change-Id: I8cc12ba7845eebc6199fbcd2d355bf0d5f38264b
2013-06-26 13:03:59 +01:00
jenkins-bot a7844ec34a Merge changes Icbf9ac6c,I1e7a1e67
* changes:
  Prevent visual effect on disabled toolbar buttons
  Remove use of filter property for CSS opacity
2013-06-26 02:37:14 +00:00
Christian Williams 867ec44a9f Reposition phantoms on init
When the toolbar animates, the position of the surface changes.
ProtectedNode now listens for the toolbarPosition event and
repositions the phantoms.

I also tried moving the localOverlay to be a sibling of the surface
(instead of child of body), but the same problems persisted.

Bug: 49853

Change-Id: I8ae1c8f66c6083b4ffee7107a78a298126e1064c
2013-06-26 00:59:46 +00:00
Trevor Parscal c2196b1fe7 Remove use of filter property for CSS opacity
Was used for IE8 support, no longer needed.

Change-Id: I1e7a1e676022dd7607c808bd44848cbf22a9e958
2013-06-25 16:44:06 -07:00
Inez Korczyński d31918d145 Proper handling for block level frameless images
Change-Id: Idd438dd256e1877ee7c18b8286a2c32fe2326f23
2013-06-24 17:47:03 -07:00
jenkins-bot 3e6db2cb19 Merge "Use this.$$ for $relocatableMarker" 2013-06-25 00:03:42 +00:00
jenkins-bot 1a8bb8c6ab Merge "(bug 50113) Do not display captions for block images which are neither frame nor thumb" 2013-06-24 23:57:28 +00:00
Inez Korczyński 4ddf123b7c (bug 50113) Do not display captions for block images which are neither frame nor thumb
There is still a problem that those images would get inspector for opening media edit dialog
displayed, and that dialog let's edit caption, which does not make sense in this case, however
that should be a separated bug.

Change-Id: I24491979bc7a27d2380924e48cb677b01e9f8f9b
2013-06-24 15:40:30 -07:00
Rob Moen 8f005fa1ae Don't put slugs after internal nodes.
Bug: 50132
Change-Id: I3818ebe9816e7d781233f087b15694bf7ba12965
2013-06-24 15:20:08 -07:00
Roan Kattouw 89c45edda1 Use this.$$ for $relocatableMarker
Change-Id: I39d4b8bc4f7c88068ad7e290130389f6c532743d
2013-06-24 11:01:14 -07:00
Ed Sanders 2352613b66 Code style fix: (X) -> ( X )
Change-Id: I7f3ac95621f70d9a89e70e9a51905673240cb51f
2013-06-24 18:51:59 +01:00
Ed Sanders 89e1bd1a51 Implement triple click functionality
On detecting a triple click the nearest non-content node
is selected.

Bug: 38011
Change-Id: Ic80d24581535766714d80104222924f7a0d20f1a
2013-06-24 12:10:13 +01:00
jenkins-bot dbabfe5514 Merge "Restore selection after dialog close" 2013-06-23 05:49:24 +00:00
jenkins-bot d22053c017 Merge "Resize focus highlights on generated content update" 2013-06-23 05:48:45 +00:00
jenkins-bot f10925bf79 Merge "Create ref list insertion tool" 2013-06-23 03:24:53 +00:00
Timo Tijhof 8a2c9431e6 Create ref list insertion tool
Fixes (follows-up I1b48ef5240, I6daff5c596):
* Invalid html passed to jQuery constructor.
* Use prop() instead of attr() for boolean values.
* Use append() instead of html() when appending nodes instead
  of parsing html.
* Rename shadowed variable name clash 'mw' to 'mwData'.
* Fix odd construction where we parse '{}' to create an empty
  object.
* Have ve.ce.MWReferenceListNode#update perform changes off-document
  in a detached tree.
* Fix deep property access that can fail. mwData is set to
  either JSON parse of data-mw attr or empty object.
  Accessing mwData.attrs.group needs to be guarded by whether
  mw.attrs is indeed set.
* Have `mw` and `about` attribtue in references list roundtrip
  (especially mw which can data we aren't editing/re-creating).
* Add missing 'refGroup' property to MWReferenceListNode's
  data element (similar to what MWReferenceNode already has).

Change-Id: I67e4f378ccd04e97361d8e58ae57db5353075756
2013-06-22 20:23:22 -07:00
jenkins-bot 9f3b36da7a Merge "ve.ce.BranchNode: Use DOM rather than jQuery in #onSplice" 2013-06-23 03:11:56 +00:00
jenkins-bot 3327f0fa7d Merge "Use DOM methods rather than jQuery in setupSlugs()" 2013-06-23 03:10:38 +00:00
jenkins-bot f1aba583a9 Merge "getRenderedContents() optimizations" 2013-06-23 03:09:58 +00:00
Roan Kattouw d9fb612538 ve.ce.BranchNode: Use DOM rather than jQuery in #onSplice
Change-Id: I75337048e9ae81c95333da5c0277dbf7dc562b1c
2013-06-23 03:09:46 +00:00
Roan Kattouw 1459bb418b Use DOM methods rather than jQuery in setupSlugs()
Also use .importNode() rather than .cloneNode() so the slugs are
created in the right document.

Change-Id: Ia0b6ee5f4e4ef0fbcc9a3fe16f20587da027ae2e
2013-06-23 02:39:56 +00:00
Roan Kattouw fe5f4fdce0 getRenderedContents() optimizations
* Use plain text rather than HTML in TextNode
** Bypasses HTML parsing, and doesn't cause regeneration of nodes like
   appending to .innerHTML does
** We were only using HTML so we could use entities, so replace those
   with \uNNNN sequences
* Use native DOM functionality rather than jQuery
* Inline flushBuffer()

Change-Id: I7c6376b55cc0f1420a01a77b365b073fe1636263
2013-06-22 19:37:10 -07:00
Ed Sanders 847edb4fb5 Restore selection after dialog close
Change-Id: I534e38633700191782a7b088de0ae46a5f800fa8
2013-06-22 00:39:21 +01:00
Ed Sanders f1e1dd7fcb Resize focus highlights on generated content update
Create a new rerender event. Also added a check to see
if the node is actually focused.

Change-Id: I9f74e82f72a9ddfd1e4a9ab7d1c0c8289b6525e8
2013-06-22 00:29:32 +01:00
jenkins-bot 22f4c6454a Merge "RelocatableNode for Inline and Block Images" 2013-06-21 21:54:49 +00:00
Christian Williams e71655304e RelocatableNode for Inline and Block Images
HTML5's drag and drop has a ton of benefits and a couple of
limitations. To achieve a native drag marker, an image tag helper
is used to indicate the size of the relocatable node. Chrome
shades the marker gray natively, Firefox is styled to match.

Change-Id: I755b698a3d968cc7e6ff125109d68ac83fd8a8a2
2013-06-21 14:53:10 -07:00
jenkins-bot dcb0d04cc8 Merge "Don't build the CE tree and DOM for the internal list" 2013-06-21 21:25:58 +00:00
Roan Kattouw 921a95de78 Don't build the CE tree and DOM for the internal list
This is a waste of time, because we hide it anyway. This took
quite a bit of time for long articles.

Change-Id: I1bcfd5b908c89dc2e08d5520e8870b145177ca10
2013-06-21 14:19:55 -07:00
jenkins-bot 5cfd21754a Merge changes If3d01346,I4e5317f1
* changes:
  Fix incorrectly written CSS that was affecting all table cells on the page instead of cells in mwMetaDialog only
  Fix for rendering block images
2013-06-21 21:00:33 +00:00
jenkins-bot 014b6ed33a Merge changes I379bc2b3,I99acbd16
* changes:
  Straighten out variances in parent method invocation
  ve.ui.MWReferenceDialog: Clean up
2013-06-21 20:53:25 +00:00
jenkins-bot b9c386e49c Merge "Fix splitClusters usage in ve.ce.Surface#onContentChange" 2013-06-21 19:50:23 +00:00
Timo Tijhof 2fb1a11a1a Straighten out variances in parent method invocation
Follows-up I99acbd1699:
* "Parent method" comment
* Remove redundant slice() call to convert arguments to array,
  native JavaScript methods that take array-like arguments such
  as Function#apply and Array#slice are both compatible with
  the Arguments objects, no need to convert it. Most invocations
  already did this right but a few were recently introduced again.
* Removed silly "Document dialog." descriptions.
* Removed a few redundant "@method" tags in the near vicinity
  of code I changed.
* Fixed function invocation to be either on one line or
  one parameter per line. Having all arguments on one line
  but the name + "(" looks confusing as it suggest there
  is only 1 parameter. Same as object literals:
  so:
  { foo: 1, bar }
  or:
  {
    foo: 1,
    bar: 2,
  }
  not:
  {
    foo: 1, bar: 2
  }

Change-Id: I379bc2b32603bcf90aba9b4cd0112e7f027d070e
2013-06-21 19:20:37 +00:00
Inez Korczyński 659bb8e6d0 Fix for rendering block images
Change-Id: I4e5317f128f2b3f6742e7ed280c96fde37f52bb4
2013-06-21 12:19:38 -07:00
Inez Korczyński e91fee2ca7 There is no need to apply CSS changes (width and height) to an image inside ve.ce.MWBlockImageNode because it is already handled in ve.ce.ResizableNode
Change-Id: I416008688b967cbbbe3e585abb3be9924ca47dc6
2013-06-21 10:38:07 -07:00
Ed Sanders 3a44ae9be3 Fix splitClusters usage in ve.ce.Surface#onContentChange
Was previously doing the text slicing before the cluster split
using substring, instead of after using splice.

Bug: 49233
Change-Id: If9c0860e2fe7b01eb0b27aae67c671062799a0fa
2013-06-21 00:28:56 +01:00
Inez Korczyński bed2c1d00d Match MediaWiki's rendering of non-thumb/-frame block images
Change-Id: I43ad72ef2d6b650692e1a0fd4460e4dec70fde7f
2013-06-19 17:44:55 -07:00
jenkins-bot 3d98a73cba Merge "One method onAttributeChange in ve.ce.MWBlockImageNode is plenty" 2013-06-19 18:47:05 +00:00
Inez Korczyński c632bfc65b Ignore shortcut keys inside key press handler
Bug: 49732
Bug: 49760
Bug: 49816
Change-Id: I8f814a0f369c470038896041f157b3dbd0d7f1a7
2013-06-19 17:31:45 +00:00
Inez Korczyński 44c174734b One method onAttributeChange in ve.ce.MWBlockImageNode is plenty
Change-Id: Ibcf93047c93e411c6c7167720e5d92a311d647f1
2013-06-18 19:31:01 -07:00
jenkins-bot fedcf454a0 Merge "Added ve.ce.FocusableNode mixin to ve.ce.MWReferenceListNode" 2013-06-19 00:53:56 +00:00
Roan Kattouw dfbd870e16 Fix copyDomElement issues
* Fix bug in MWTransclusionNode sometimes passing a NodeList rather
  than an array (caused an error because NodeLists can't be .map()ped)
* Use copyDomElements in ce.AlienNode as well

Change-Id: I11c6483d3c062047be80f75a3fac03f13bff9662
2013-06-18 23:37:09 +00:00
jenkins-bot 60da007ab9 Merge "Copy DOM elements properly, into the correct document" 2013-06-18 22:52:14 +00:00
Roan Kattouw dc798befcf Copy DOM elements properly, into the correct document
* Provide a utility for copying an array of DOM elements into a
  different document
* Copy the DOM elements returned in toDomElements(), otherwise weird
  issues arise when the same data is converted to DOM twice

Change-Id: Ie927420624f0d4af0692e18d1bc6f952c8013d61
2013-06-18 15:40:33 -07:00
Roan Kattouw d5365d2b5a Correctly distinguish between Deferred and Promise
Deferred is read-write, Promise is read-only. Document and return
the correct types.

Change-Id: Icfd6efb07b222c73d49b97ddbfe6565b8542ad00
2013-06-18 10:56:56 -07:00
Inez Korczyński b6fc9d9217 Added ve.ce.FocusableNode mixin to ve.ce.MWReferenceListNode
So its selection looks better after a user clicks on it

Change-Id: I4343a67d7b488c42e40270d25b9b4104a07872fb
2013-06-17 21:22:34 +00:00
Ed Sanders dcbea2328c Code style fix: @return -> @returns
Change-Id: I26daca6313bf09055af8f980ba0065782257fd54
2013-06-17 11:50:24 +01:00
jenkins-bot df4e191020 Merge "Handle deletion programmatically always" 2013-06-15 00:12:21 +00:00
Inez Korczyński ec92614906 Handle deletion programmatically always
Change-Id: Ic68f80d92d32169ff60258b81a438e342b136128
2013-06-14 17:05:28 -07:00
Trevor Parscal fc8c46dd74 Reference name and group editing
Objective:

* Allow editing reference groups and names in the reference dialog

Bonus:

* Modify attribute transaction builder to support multiple attribute
  changes in a single transaction

Changes:

ve.ui.MWReferenceDialog.js
* Load ref name and group from model
* Save ref name and group, if changed, to model

ve.ui.ListAction.js, ve.ui.Transaction.test.js, ve.ce.ResizableNode.js
* Update use of newFromAttributeChange to newFromAttributeChanges

ve.dm.SurfaceFragment.test.js
* Add test for new changeAttributes method

ve.dm.InternalList.js
* Missing new line at end of file

ve.dm.Transaction.js
* Change newFromAttributeChange to accept an list of attribute changes and
  produce a single transaction that applies one or more attribute changes
  at once

ve.dm.SurfaceFragment.js
* Fix bug in getCoveredNodes where the wrong mode name was being used
* Add changeAttributes method, which applies attributes to all covered
  nodes and allows filtering of which types of nodes the attributes are
  applied to

ve.dm.MWReferenceNode.js
* Actually write key and group back to DOM
* Separate onRoot functionality into addToInternalList so it can be called
  separately (similarly onUnroot/removeFromInternalList)

ve.ce.MWReferenceListNode.js
* Clone internal item CE node before appending to avoid rendering bug.

*.php
* Add links to messages and sort them

Change-Id: Ic4121e4fcfc09265d5863af6f078cdeb77926c8e
2013-06-14 15:29:56 -07:00
Ed Sanders beaf7a588c Pass selection to ve.dm.Surface.change when pasting over text
Bug: 49551
Change-Id: I7497b5195961e46718c7382409a66b7eec1162a9
2013-06-14 11:50:08 +01:00
jenkins-bot bb59895d92 Merge "(bug 48335) Use more generic approach to filter out non-character key presses." 2013-06-14 03:34:44 +00:00
jenkins-bot 6144976c1e Merge "(bug 43082) Fix problem by calling surfaceObserver.stop( true ) first - before calling handleEnter." 2013-06-14 00:16:51 +00:00
Inez Korczyński 44f57135f0 (bug 43082) Fix problem by calling surfaceObserver.stop( true ) first - before calling handleEnter.
Change-Id: I35c892581943057acbf9ddd638576e998cc82c1a
2013-06-12 17:14:57 -07:00
Trevor Parscal d3a2fab2c4 Transclusion editing
Objectives:

* Rename just about every use of "template" to "transclusion"
* Make a proper data structure for transclusions
* Abstract away template data
* Use more template data in the user interface
* Allow adding parameters
* Allow removing templates, parameters and content

Changes:

ve.ui.Dialog.css
* Add rule to place add param controls on a single line

ve.ui.MWTemplateDialogs.js
* Move template spec loading into transclusion class
* Add remove button for parts and parameters
* Add parameter adding form
* Use template data for labels and descriptions

ve.dm.*
* Add new transclusion data structures

*.php
* Add links to new files

*.*
* Rename all things "template" to "transclusion"

Bug: 39598
Bug: 49403
Change-Id: I3bcf924a3e179cb65f19e833277a39dfd3dad8bd
2013-06-12 16:39:13 -07:00
Inez Korczyński 4e377629e3 (bug 48335) Use more generic approach to filter out non-character key presses.
Change-Id: Ie00becf1162f145134f006b0b4514ba874de9c43
2013-06-12 15:03:40 -07:00
jenkins-bot a61adfea45 Merge "Fix conversion of byte to grapheme offsets/lengths" 2013-06-11 16:46:13 +00:00
Ed Sanders 348d2355c6 Fix conversion of byte to grapheme offsets/lengths
Missed one case in ve.ce.Docuemnt#getNodeAndOffset.

Bug: 49246

Change-Id: Iff1dfb90130685bb710821f8386cfa2f296f2f95
2013-06-11 13:39:11 +01:00
jenkins-bot fcfaa4c832 Merge "Wrap inline images in spans with display: inline-block." 2013-06-10 22:36:30 +00:00
Inez Korczyński 4d880cb28d Wrap inline images in spans with display: inline-block.
Change-Id: I8daac35c752ad33691955b2493191be990c78f58
2013-06-10 15:34:53 -07:00
Inez Korczyński 435b61303c Fix selection and hover for MW inline images.
Change-Id: I82444157a2f57739dc81039dd919233201041634
2013-06-10 15:03:38 -07:00
Trevor Parscal 8039b1c2f8 Insert Reference
Objective:

* Allow opening reference dialog with arbitrary selection
* Auto-insert reference when selection is not a reference node

Changes:

ve.init.mw.ViewPageTarget.js
* Added reference button to toolbar

ve.init.Target.js
* Add getToolbarSubset so we can exclude the reference button from
  the toolbar in the reference dialog (nested references are not
  allowed).

ve.ui.MWReferenceDialog.js
* Stop storing referenceNode (not needed)
* Only store internalItem on open if there's a focused node that's a
  reference
* Use wrapper paragraph when creating a new reference
* Create new reference on dialog close if required

ve.dm.InternalList.js
* Major rewrite to support key less references.
* Add new method for creating a transaction to insert a new iternal
  item. Also returns the index of the new item to be passed to the
  reference node.

Change-Id: I839ae165c299248484ce93d4ab087318a95fbb94
2013-06-10 20:14:08 +01:00
Christian Williams babaa4118d FocusedNode Selection
Introduction of fake selection for single focused nodes. This
change specifically makes the selection much nicer in appearance
for Chrome users selecting floated FocusableNodes (block images)
for example.

Added ve-ce-surface-highlights DOM element to contain styled
highlight elements.

Made adjustments to getSelectionRect to return fake selection
bounds if necessary.

Replaced old uses of showSelection with model.change().

Change-Id: I96e66567cdce6455ef3eb77568e72f23140448ff
2013-06-07 17:49:35 -07:00
jenkins-bot cd2f411a93 Merge "Support for inline images" 2013-06-07 23:13:19 +00:00
Inez Korczyński 2f15cb0067 Support for inline images
Handles typeof mw:Image and mw:Image/Frameless

Change-Id: Ie2fbd4a3e12fb6faa4ab8e6dd0aa8d1334ff6498
2013-06-07 23:09:32 +00:00
Catrope 10d415e63a Render block templates as <div>s and inline ones as <span>s
Right now block templates are rendered as <span>s

Change-Id: I4c941a03e0e34a435990f0392080a3a8bf3e2835
2013-06-07 20:04:01 +00:00
Trevor Parscal 5aac2f756c Block Image Resizing
Allow block images to be resized by mixing in ResizableNode.

Made transitioning optional, and disabled it for block image nodes.

Change-Id: If89948d285ffb5efb104c44cbc9553a3d56f52e7
2013-06-07 10:52:04 -07:00
jenkins-bot 089cebd8e1 Merge "Hack around exceptions thrown when closing the reference dialog" 2013-06-07 00:13:10 +00:00
jenkins-bot 06551322ea Merge "Let's not put slugs around lists because there is no such need." 2013-06-07 00:10:19 +00:00
jenkins-bot baa2f22db9 Merge "Fix freaky disappearance of template nodes" 2013-06-07 00:09:05 +00:00
Catrope 778a74daf7 Hack around exceptions thrown when closing the reference dialog
ce.ProtectedNode doesn't like to be torn down when it's detached,
and this was happening to CE nodes created in the MWReferenceList.

Hack around this by attaching the CE nodes generated by the
MWReferenceList to the ce.MWReferenceListNode (so they have a
parent and a way of getting to the surface), and by guarding against
multiple successive setups/teardowns in ce.ProtectedNode.

Change-Id: If00e75b939ccbdbaf681bbb6609fec54805bf9a0
2013-06-07 00:08:54 +00:00
Inez Korczyński 42d32286c7 Let's not put slugs around lists because there is no such need.
It is easy to exit the list at any given point by using the toolbar
button or pressing enter twice while at the end of the list.

Change-Id: Ie34300fc13a4548e283348ef58c88ce420fbe0c1
2013-06-07 00:08:26 +00:00
Catrope 4ce69758cc Fix freaky disappearance of template nodes
ce.GeneratedContentNode had an interesting bug where it called .append()
directly on DOM elements stored in the store. They weren't cloned,
which meant the previous rendering of the same node would just disappear,
and they also weren't adopted into the correct document which would
probably have caused other issues as well.

Properly clone and transplant the nodes from the store before attaching
them to the DOM.

Change-Id: I423db85cb7c3851a9bf68de03c72aa22994d9474
2013-06-07 00:06:23 +00:00
jenkins-bot bf05782972 Merge "Fix protectedness of MWReferenceList" 2013-06-06 23:48:22 +00:00
jenkins-bot 22796f925d Merge "Fixing resize handle size" 2013-06-06 23:46:52 +00:00
jenkins-bot 72f661dc69 Merge "ve.dm.MWBlockImageNode: Make toDomElements add more information to its output so round-tripping can work properly." 2013-06-06 21:46:21 +00:00
Christian Williams eaba9833d2 Fixing resize handle size
Handles were missing vendor-specific box-sizing declarations.

Change-Id: I6f8e8a37df29cc351f4ca50b7dd02fadcc3bdda3
2013-06-06 11:18:57 -07:00
jenkins-bot 1bab467c61 Merge "Rename character to (grapheme) cluster when dealing with unicode." 2013-06-06 17:49:12 +00:00
Ed Sanders fc5ead9212 Code style fixes: 'function(' => 'function ('
Change-Id: I905f6bec5c12903775bf3bb1085d26c9ea001eca
2013-06-06 13:02:16 +01:00
jenkins-bot 507a61bfd5 Merge "Proper support for frame images (do not display magnify icon)." 2013-06-06 03:26:49 +00:00
Catrope 3aae3e80bd Fix protectedness of MWReferenceList
The update() method wiped out the entire contents of the node, including
the shield that makes ce.ProtectedNode work. Fixed by only wiping out and
reconstructing the contents of the <ol>

Change-Id: Ib2978a72939884be67964ce8a3d89a570f70bfa3
2013-06-05 18:10:04 -07:00
Ed Sanders 22d1908bd4 Update reference lists and inline numberings automatically.
The easy part is getting the correct numbers from the InternalList
and generating the ordered list HTML. The tricky part is connecting
up the events to make sure the renumberings/list generations are
triggered when required.

InternalList can emit an update event on document transaction, which
triggers the renumbering/relisting if any references have been
added or deleted during that transaction.

ve.ce.MWReferenceListNode also listens to changes on the
InternalListNode (i.e. changes to the contents of the references)
and always triggers a rebuild.

Change-Id: I1b48ef5240e433c3b314259aa68cde13841ea98b
2013-06-05 15:11:16 -07:00
Inez Korczyński d14b2c514d ve.dm.MWBlockImageNode: Make toDomElements add more information to its output so round-tripping can work properly.
Change-Id: Ieacf9187371a1687869bcb4bb0244f1bc251a803
2013-06-05 14:37:28 -07:00
Ed Sanders 605fe147dc Rename character to (grapheme) cluster when dealing with unicode.
Change-Id: Ia72e19289ba7f15a921d22698ab5d8c354ef120d
2013-06-05 17:30:28 +01:00
Inez Korczyński 1cd93f11ca ve.ce.Document: Introduce getRelativeRange method
A new method to be used for cursor left and right movement.

Change-Id: I9b32ccf6800d34f94793fc9086ba2c7341e30c61
2013-06-05 13:10:38 +01:00
Timo Tijhof 57960a73bd Add .csslintrc file and fix remaining warnings
Adding a fairly loose .csslintrc file so that our code
passes it.

The following options cause warnings in our code and have been
disabled for now:

* adjoining-classes
  > Don't use adjoining classes.
  > .ve-ui-widget-disabled.ve-ui-textInputWidget textarea:focus {

* box-sizing
  > The box-sizing property isn't supported in IE6 and IE7.
  > box-sizing: border-box;

* box-model
  > Using width with border can sometimes make elements larger than you expect.
  > border: solid 1px #ccc;
  > Using width with padding can sometimes make elements larger than you expect.
  > padding: 0 0.75em 0 0.75em;
  > Using width with border-right can sometimes make elements larger than you expect.
  > border-right: 1px solid #eee;

* fallback-colors
  > Fallback background-color (hex or RGB) should precede RGBA background-color.
  > background-color: rgba(104,171,255,0.1);

* important
  > Use of !important
  > position: relative !important;

* outline-none
  > Outlines shouldn't be hidden unless other visual changes are made.
  > .ve-ce-documentNode[contenteditable="true"]:focus {

* qualified-headings
  > Heading (h1) should not be qualified.
  > .ve-ce-branchNode h1:empty:before,

* universal-selector
  > The universal selector (*) is known to be slow.
  > .ve-ce-protectedNode * {

* unqualified-attributes
  > Unqualified attribute selectors are known to be slow.
  > .ve-ce-documentNode[contenteditable="true"]:focus {

Fixes made:
* modules/ve/ce/styles/ve.ce.Surface.css:
 [L66:C2] margin can't be used with display: inline.
* modules/ve/ui/styles/ve.ui.css: Unknown @ rule: @-ms-keyframes
 Internet Explorer < 10 doesn't support keyframes. IE10+ supports
 the standard property. I don't think ms-keyframes ever existed
 http://caniuse.com/css-animation. ms-transform did exist
 http://caniuse.com/transform.

Change-Id: I728a48e489c079e1c94a506bb00c245de9551eb6
2013-06-05 11:07:00 +00:00
Timo Tijhof b463c5d377 jshint: Fix trailing comma
Due to the "es5: true" jshint option we enabled, these
warnings were surpressed. I've disabled the option since
we no longer require it. It was enabled in 07c86fc to fix
a bug with jshint. This bug has now been fixed.

Change-Id: I55b7d031eb5581af5f733f050cf2ea98dacb2af6
2013-06-05 13:00:49 +02:00
Inez Korczyński a9812ad4c6 Proper support for frame images (do not display magnify icon).
Change-Id: I94792760e6b1ff69ab13501939bf8d10e0558e5b
2013-06-04 17:41:35 -07:00
jenkins-bot 3dfc960576 Merge "Store DM nodes in InternalList" 2013-06-04 17:06:24 +00:00
Ed Sanders 2925966944 Store DM nodes in InternalList
Also keep items in the order they appear in the document
and grouped by group and key.

Additions and removals are triggered by the new root/unroot events.

Change-Id: Ia3e90ccfdab88f352b89992b90554e5f03ff9952
2013-06-03 22:10:07 +01:00
jenkins-bot 722b193f45 Merge "Convert GeneratedContentNode into a mixing (instead of an abstract class)." 2013-05-30 16:50:53 +00:00
Catrope 7a616429a0 Unwrap excess <p>s in inline template rendering
This is a hack, in the future Parsoid will have a template re-expansion
API that will produce the correct result.

Change-Id: I328c11330fb3db71c51882717d6b84099c9270d1
2013-05-30 17:41:20 +01:00
Inez Korczyński 394a40f27c Convert GeneratedContentNode into a mixing (instead of an abstract class).
Change-Id: I280d2a59326bd83357c7a09c3a188a70fbc75335
2013-05-29 14:54:57 -07:00
jenkins-bot efb3f21b13 Merge "A fix for arrow movements in RTL wikis." 2013-05-28 21:50:58 +00:00
Moriel Schottlender 5e9c9b9367 A fix for arrow movements in RTL wikis.
This will make sure the marker moves correctly (backwards/forward)
in RTL languages as well as LTR languages, judging from the wiki pageLanguage.
This can be a quickfix until the movement can be decided per the direction
of the specific element (span/paragraph/div) the marker is in.

Bug: 38546
Change-Id: Ic01e110a5e6094cd275327a2e8cea90c900f1bd1
2013-05-28 14:50:20 -04:00
Trevor Parscal 8eb0efab9b Fix resizable nodes
Making sure resize handle events are bound and unbound on focus, and that elements are created in the right window.

Change-Id: Ie90bb82aa6c81c372d76278dab3665bd49bf573c
2013-05-28 17:36:31 +01:00
Trevor Parscal 3be13a7cbc Consistent use of mw in HTML classes, and data element and annotation types
MWfooBar or MWfoobar should be mwFooBar

Change-Id: I30f0ef05960c9df218ef6f1cb161ff6ccd529bc7
2013-05-28 13:49:56 +01:00
Catrope e6c7aa4275 Clear phantoms on teardown in ProtectedNode
When you typed after a ProtectedNode that was previously at the end of
a paragraph, then moved the mouse, you'd get a JS error.

What happened was the typing caused a new TextNode to be created after
the ProtectedNode, which caused the ParagraphNode to be rebuilt,
detaching the original ProtectedNode and creating a new one. The
detached ProtectedNode was still bound to mousemove on the body, and
when that event fired it would try to remove its phantoms from the
surface and fail because detached nodes can't get to the surface.

Change-Id: I9f38776f0267645b14d7b26e2a25007cf3be8ec7
2013-05-26 12:23:55 +02:00
jenkins-bot d6b801aa7d Merge "Store multi byte characters as one element" 2013-05-25 09:00:49 +00:00
Ed Sanders 90e4f4d665 Store multi byte characters as one element
Getting & setting the cursor is done with byte offsets
instead of data model offset (characters) so we need to
be able to convert between the two as well as splitting
characters.

TODO: The regex only works on surrogate pairs, not
yet combining accents.

fixupInsertion will combine a combining mark with the
character to its left it it can.

Bug: 48630

Change-Id: I8d936fb15d82f73cd45fac142c540a7950850d55
2013-05-25 00:50:11 +02:00
jenkins-bot 601f01dbd3 Merge changes I2dc0c151,I807a0f32
* changes:
  Attach resize handles to $localOverlay
  Remove resize handles on surface teardown
2013-05-24 22:17:50 +00:00
James D. Forrester 83c79bd586 Wrap pre-formatted nodes at word boundaries, not window width
Bug: 38043
Change-Id: I9b5e3b3e62b52c86743ee345b1cc31beec0a061e
2013-05-24 22:44:44 +02:00
Ed Sanders e14defc76f Attach resize handles to $localOverlay
Because that's where they should be.

Change-Id: I2dc0c1511f459fea6bf7db86eff9a55c07dd911b
2013-05-24 22:43:15 +02:00
Ed Sanders 80a37e9df3 Remove resize handles on surface teardown
Add teardown call to surface destruction in mw target, and
teardown listener to resizeable node.

Bug: 48530
Change-Id: I807a0f32d3d1eb490456d887f7bf867bdb896df4
2013-05-24 22:19:18 +02:00
Trevor Parscal 2e76271b4e The Great ve.ui.Surface refactor of 2013
Prologue:

Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.

Note to Roan and/or Ed:

Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.

Objectives:

* Make it possible to have multiple surfaces be instantiated, get along
  nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog

Approach:

* Move what's left of ve.Editor to ve.ui.Surface and essentially
  obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
  the top level one
* Resolve stacking order issues by removing the excessive use of z-index
  and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
  and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype

Bonus:

* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
  was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed

Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
2013-05-24 14:01:02 +02:00
Inez Korczyński 57317e2327 Use our own collection of constant to key code. The one based on w3c is not reliable.
Also, for next few months, please don't mention w3c when I'm around.

Change-Id: I4c8577ae50c16b177dbe370a0deac0d3272e9a06
2013-05-23 16:39:01 -07:00
Inez Korczyński 1d7cf569e6 Support for thumb and frame images with captions.
* VisualEditor.hooks.php
** export URL to magnify clip as a configuration variable so thumbnail image can render correctly

* ve.ce.Surface.css
** add CSS styling to make image captions look the same way in edit mode as they look in the view mode

* ve.ce.ParagraphNode.js
** add CSS class ve-ce-generated-wrapper if it is a generated wrapper

* ve.ce.MWImageCaptionNode.js
** make image caption rendering match the view mode

Change-Id: I0cd1b25e8f8355e0500aabc90e7c4cdf591545f3
2013-05-23 00:44:43 -07:00
jenkins-bot c1477bc1da Merge "Move selection to end of insertion after paste" 2013-05-20 23:19:55 +00:00
Inez Korczyński 7c8bc08470 Added very basic support (rendering) for captions of thumb and frame images.
Change-Id: I4a59d4601c9bf44b241bb1432c9f1abc3f961743
2013-05-20 13:15:35 -07:00
jenkins-bot 791fdfb6d4 Merge "Refactor HTML attribute preservation" 2013-05-20 17:29:09 +00:00
jenkins-bot fb9f6df6b5 Merge "Wrap <img> in <a> inside image thumb in order to match MediaWiki parser output." 2013-05-18 16:54:24 +00:00
Ed Sanders 95f41c176b Move selection to end of insertion after paste
Assuming this was broken by changes to translateRange.

Bug: 48603
Change-Id: Ia2a2120cb75aa86374b594ae3f484c5161028919
2013-05-18 16:41:58 +01:00
Ed Sanders 57b9167bb5 Fix call to getWindow
Using the wrong namespace.

Bug: 48602
Change-Id: I31dc071328123b57b778aa1b21f0e1daf6405e5c
2013-05-18 16:29:03 +01:00
Catrope 9ff6737f4c Refactor HTML attribute preservation
Rather than using namespaced linmod attributes, store the preserved
HTML attributes in the .htmlAttributes property of the linear model
element, in a nested structure to allow for easier treatment of child
nodes. Also added attribute order preservation by storing attributes
as an object plus an array of keys.

ve.ce.Node.js:
* Remove html/* attribute synchronization. Doesn't make sense any more
  because these things aren't in the attributes object any more. I don't
  think it ever made sense because these attributes were never supposed
  to be changed anyway.

ve.ce.View.js:
* Replace renderAttributes() with a simple wrapper around
  renderHtmlAttributeList()

ve.dm.Converter.js:
* Add buildHtmlAttributeList() and renderHtmlAttributes() for building
  and rendering HTML attribute lists

ve.dm.Model.js:
* Add getter for .htmlAttributes

ve.dm.Node.js:
* Drop .htmlAttributes on clone, and remove logic dropping html/*

ve.ui.MWCategoryWidget.js:
* Remove html/0/about hack, was already unnecessary and now doesn't
  work any more

tests/:
* UPDATE ALL THE TESTS

Change-Id: I620573afd70d36ade6b80413075b6e1f4a435abe
2013-05-17 20:57:33 -07:00
Inez Korczyński e196c2f247 Wrap <img> in <a> inside image thumb in order to match MediaWiki parser output.
Change-Id: I91cfcd9ea319b4429abbbe9ddbb07d1cd8a65b62
2013-05-17 11:42:27 -07:00
jenkins-bot 0eb2581b64 Merge "ve.ui.Context: Add embedding feature" 2013-05-16 18:26:39 +00:00
Trevor Parscal 55b5f30edb ve.ui.Context: Add embedding feature
Objectives:

* Make the context menu display in the top right corner of the currently
  focused inspectable node (if there is one)
* Prevent clicking on anything to do with the toolbar or popup from doing
  anything at all, ever

Bonus:

* While we are using the clever feature in jQuery's on method which allows
  passing boolean false to cancel the event - may as well do that in
  ve.ui.Dialog as well

Changes:

ve.ui.FocusableNode
* Add ability to specify the focusable element so that dimensions can be
  derived from it

ve.ce.Surface
* Add quotes to object keys

ve.ui.MediaDialog
* Change association from being MW specific to handling images in general

ve.ui.Context
* Add embedded styles for context
* Add embedded mode, which is triggered when the context is a single
  focusable node, and the node is large enough to fit the context
  reasonably

ve.ui.Dialog
* Inline mousedown handler

ve.ui.Toolbar, ve.ui.PopupWidget
* Cancel stray mousedown events

Change-Id: I4b25d33f64b4bcb8a3ecfd7e9728f54a2d4886f3
2013-05-16 11:23:59 -07:00
Inez Korczyński 995a20219a Emit teardown event before replacing generated content node content and emit setup event after.
Change-Id: I397d4dfb5fd0177255a0b4389ba5380807969ef4
2013-05-15 17:35:49 -07:00
Ed Sanders b5ead95ee8 Implement roundtrip update of template contents
Currently there is no Parsoid call for this so we're using the PHP
parser API.

Change-Id: I8bc4f96924d88de7bc67203336bf465ba91fc37b
2013-05-16 00:56:44 +01:00
Christian Williams e669f8faf6 Fixing block template styling
Trailing comma borks everything.

Change-Id: Ic4eb97f84b45297312b45ab64355836ef8a329d1
2013-05-15 16:37:27 -07:00
Inez Korczyński ba5c4f104d Build TemplateDialog based on parameters that are passed to template
(instead of TemplateData as before).

Change-Id: I50b0e6ef1936c4b56f40fa73bd42b03587bdf979
2013-05-15 22:47:59 +00:00
jenkins-bot d97114ad10 Merge "Implement ve.ui.MWTemplateDialog" 2013-05-15 19:38:20 +00:00
Trevor Parscal 231a50f2b6 Implement ve.ui.MWTemplateDialog
Objective:

* Add button to launch template dialog
* Add template dialog

Changes;

*.php
* Add messages and links to files

ve.ce.Node.css
* Make inline templates display as inline-block to contain their
  contents (allowing shields to work properly)

ve.ui.MWTemplateDialog.js
* New empty dialog for templates

ve.ui.MWTemplateButtonTool.js
* New template button, appears in context and launches dialog

Change-Id: I9174ed7c9012522246a6defc859276bf36763f5b
2013-05-15 19:36:18 +00:00
Timo Tijhof 25d6e6f136 ve.ce.Surface: Append phantoms to overlay instead of surface
Surface can be deep inside a skin layout of which it is not
unlikely for one or more of the parents to have position
relative.

Change-Id: Ie202fa43b837650fd296fa6804d035622e2599e1
2013-05-15 21:28:56 +02:00
Trevor Parscal a56e795f58 ve.Editor
Objectives:

* Split ve.Surface into ve.Editor and ve.ui.Surface
* Move actions, triggers and commands to ve.ui
* Move toolbar wrapping, floating, shadow and actions functionality to configurable options of ve.ui.Toolbar
* Make ve.ce.Surface and ve.ui.Surface inherit ve.Element and use this.$$ for iframe friendliness
* Make the toolbar separately initialized so it's possible to have a surface without one, as well as control where the toolbar is

Some change notes:

VisualEditor.php
* Added standalone module for mediawiki integrated unit testing

ve.ce.Surface.js
* Remove requirement to pass in an attached container to construct object
* Inherit ve.Element and use this.$$ instead of $
* Make getSelectionRect iframe friendly
* Move most of the initialize stuff to a new initialize method to be called after the surface is attached to the DOM

ve.init.mw.ViewPageTarget.js
* Merge toolbar functions into setup/teardown methods
* Add toolbar manually (since it's not added by the surface anymore)

ve.init.sa.Target.js
* Update new init procedure for editor, surface and toolbar separately
* Move toolbar floating stuff to ve.Toolbar

Change-Id: If91a9d6e76a8be8d1b5a2566394765a37d29a8a7
2013-05-15 10:39:12 -07:00
jenkins-bot 44e0b7e345 Merge "Make ve.ce.ProtectedNode use setup (for setup) and teardown (for teardown) events so it is going to work well after node is rewrapped (example: MWBlockImageNode)." 2013-05-15 17:31:53 +00:00
Inez Korczyński 2a53329f0d Make ve.ce.ProtectedNode use setup (for setup) and teardown (for teardown) events so it is going to work well after node is rewrapped (example: MWBlockImageNode).
Change-Id: Ibd539813f4302d8bbf8eaa35af71817a55fb1f4b
2013-05-15 10:28:56 -07:00
Inez Korczyński b8d81f5238 Make MWBlockImageNode a ProtectedNode (by adding mixin).
Change-Id: Ib15efaf4964f16b86020367e42848d228efd09ba
2013-05-15 10:01:19 -07:00
jenkins-bot 3109e96bb1 Merge "Better support for MediaWiki block level images (thumb and frame)" 2013-05-15 02:58:23 +00:00
Christian Williams 991859d5d1 MWInlineImageNode should be img
Change-Id: I0cc43c59031f970b879b64696e824ebaa28a4b53
2013-05-14 17:36:04 -07:00
Inez Korczyński c6c7af5a62 Better support for MediaWiki block level images (thumb and frame)
Change-Id: Id6f65e4e1971e21035c89f32fa7ab0009c84695c
2013-05-14 17:14:36 -07:00
Inez Korczyński a3f6008bd4 Introduction of setup and teardown events for ve.ce.View nodes
* modules/ve/ve.Node.js - remove ve.EventEmitter mixin
* modules/ve/ve.dm.Node.js - added ve.EventEmitter mixin
* modules/ve/ce/ve.ce.BranchNode.js - make updateTagName use newly added
  events

Change-Id: I349155b8e986fe09b615bb5f0617409d723936ef
2013-05-14 19:47:40 +00:00
Trevor Parscal c2defc9783 ve.Element refactor
Objectives:

* Move ve.ui.Element to ve.Element
* Make CE nodes inherit from ve.Element

Changes:

ve.ui.Element.js, ve.Element.js
* Move and rename
* Move ve.ui.get$$ to ve.Element.static.get$$
* Add static getDocument and getWindow methods
* Add instance getElementDocument and getElementWindow methods
* Add getTagName method, which by default reads the static tagName property, but when overridden can return a tag name based on other factors

*.php
* Updated file link

ve.ce.*Annotation.js, ve.ce.*Node.js, ve.ce.View.js, ve.ce.Document
* Added config options pass through
* Replaced passing elements through constructor with defining static tag names
* Added getTagName overrides where needed that derive tag name from model
* Refactore dom wrapper methods, now consistently using getTagName

ve.ce.Surface.js
* Removed static initialization (not needed)

ve.dm.Model.js, ve.ui.Window.js
* Added missing docs

ve.ui.GroupElement.js, ve.ui.Layout.js, ve.ui.Widget.js,
* Updated class name for elements

ve.ui.Frame.js, ve.ui.LookupInputWidget.js
* Updated location of get$$

ve.ui.js
* Move get$$ to ve.Element

ve.js
* Add auto-init of static properties to mixinClass

Change-Id: I39ae14966456903728e4d9e53f806ddce9ca2b70
2013-05-14 19:47:32 +00:00
Trevor Parscal 5012ed101b Floating toolbar cleanup
Objective:

Move toolbar floating functionality to ve.init and clean it up

As a bonus:

demo.css
* Fix CSS path to set width of inputs properly

Changes:

demos/ve/index.php
* Allow ve.init.sa.Target to construct it's own surface object

ve.ce.Surface.js
* Move object resizing and table editing disabling commands from ve.Surface
* Add method for getting the currently focused node

ve.init.mw.ViewPageTarget.js
* Remove initializing surface property (now done in parent class)
* Normalize all uses of "setup" to "setUp"
* Replace uses of getDocumentModel with getModel().getDocument()
* Add calls to set up and tear down for toolbar floating

ve.init.mw.Target.js
* Replace uses of getDocumentModel with getModel().getDocument()

ve.init.sa.Target.js
* Move example from ve.Surface
* Change constructor to accept document model
* Create ve.Surface object in constructor
* Add set up for toolbar floating

ve.ui.init.Target.js
* Initialize surface property
* Move and cleanup toolbar floating functionality from ve.Surface

ve.ui.Surface.js
* Remove example now that init.sa creates it's own surface (moved)
* Document options
* Simplify toolbar options and remove the concept of multiple toolbars
* No longer cache the options object
* Move toolbar initialization to constructor
* Change setupCommands to addCommands, making it useful after construction
* Inline selection initialization
* Move and cleanup toolbar floating functionality to ve.ce.Surface
* Reorganize a few methods
* Move toolbar floating to ve.init.Target.js

Change-Id: I393a426e35567d57c048122bf64a83c1ef45e6e8
2013-05-14 12:43:30 -07:00
Inez Korczyński 9f8ababfa9 Fix inability to split lists
Fixes change made in I7a8d6c474ecca5af02b72b6453c900ed61acea58 by using
DOM_VK_ENTER instead of DOM_VK_RETURN (which is not defined anymore).

Bug: 48386
Change-Id: I8d7aeffc8166487806e3489b054f508c5e9418ff
2013-05-13 14:59:16 +00:00
Inez Korczyński b32b5702d4 (bug 48022) Ignore certain function keys in key press handler
This is a temporary solution that still may some function keys go through.

Change-Id: I7a8d6c474ecca5af02b72b6453c900ed61acea58
2013-05-10 13:51:23 -07:00
Trevor Parscal 8858ed932f Make reference list nodes render contents again
Really Roan? How dare you!

See I3f5116d7dfbaa5889b7c5cac01d7341272749c58

Change-Id: Ia0ae514fc07752edb7b7100716e09163d3bfacba
2013-05-10 10:47:10 -07:00
jenkins-bot 8bac303893 Merge "When removing an empty list item, also remove the list if it's now empty" 2013-05-10 17:17:36 +00:00
jenkins-bot d7c3dd8ec6 Merge "Reduction of renderContents calls" 2013-05-10 15:35:37 +00:00
Catrope 811721f1e1 When removing an empty list item, also remove the list if it's now empty
When the user presses Enter in an empty list item, we remove it. But if
the list item was the only child of the list, that leaves an empty list
which then gets a block slug, leading to all sorts of weird things, and
even pawns in Firefox. So check whether the list item was the last child
and if so, remove the list.

Bug: 48287
Change-Id: If22d9b904b8861e24d56944d791545635b2e4254
2013-05-09 17:47:36 -07:00
Inez Korczyński 1e85621bd9 Reduction of renderContents calls
There is no need to call renderContents in ContentBranchNode constructor
because it is going to be called anyways in onSplice

Change-Id: Id1ab983668299658ecd6e89a37667cc34c701689
2013-05-10 00:28:30 +00:00
Catrope 9372ca60ad Kill getOffsetFromNode() with fire
The way it operated was evil. It did a depth-first search from the root,
finding the node using reference equality. For documents with deep
structures, this could take a long time. Inez did some profiling and
found it was called tens of millions of times on a complex document.

Kill getOffsetFromNode() and move its functionality to getOffset().
The logic has been completely rewritten: getOffset() now traverses
up from the node rather than down from the root, and pretty much does
the reverse of what getNodeFromOffset() does. This should be much more
efficient even without offset caching in the node objects (which we may
still implement later).

Change-Id: I125f9fa423c40db6472e2c4a7c94214218ba3bc7
2013-05-09 17:26:22 -07:00
Catrope 3d21609ca9 Move completeHistory from dm.Surface to dm.Document
Per IRL conversation with Trevor, that's where it belongs.

Change-Id: I9eae05380597ed83122f29864b77d2278d3dd863
2013-05-09 14:54:25 -07:00
Christian Williams 30cfe6998f Fixing shields
Shields were being added twice. Switched the blank png to gif
because the red IE background couldn't be replicated. Changed
some styles from Alien to Protected.

Change-Id: I9c62665e4e0dc54b8511749b9d2a629db7990a16
2013-05-08 12:29:25 -07:00
Catrope 31c2165770 Also render attributes of the form html/i-j/attrName in CE
Factored the parsing of html/* attributes out into a static function.
Factored attribute (re)rendering out into ce.View, attribute updates
are much simpler now.

Change-Id: I4caa6d5e1e2c21c28ddff61c3c864e47f66cc6b2
2013-05-08 18:10:46 +00:00
Timo Tijhof 13dd31c046 ve.ce.FocusableNode: Fix documentation
The constructor doesn't use any parameter named "$resizable".
And the one usage of it (ve.ce.ImageNode) doesn't pass any
arguments.

Follows-up 3fe3032.

Change-Id: I30530f4199a7c8383933be286b7b7a705c05c26c
2013-05-07 21:51:38 +02:00
jenkins-bot ab7f7ae915 Merge "ve.ce.ProtectedNode" 2013-05-07 01:33:43 +00:00
Trevor Parscal 92f6688162 ve.ce.ProtectedNode
Objective:

Generalize the shield and phantom magic, so we can use it for pretty much
any node we like. Usually this will be used with generated content nodes,
but also with aliens (of course) and possible other stuff in the future.

Bonus:

Also fixes a bug in DM that would crash VE when you selected to the end
and hit backspace.

Changes:

*.php
* Added links to files

aliens.html
* Added attributes to aliens to make them aliens again

ve.ce.AlienNode.js
* Moved shield and phantom functionality to ve.ce.ProtectedNode

ve.ce.AlienNode.js, ve.ce.MWReferenceListNode.js,
ve.ce.MWReferenceNode.js, ve.ce.MWTemplateNode.js
* Mixed in ve.ce.ProtectedNode

ve.ce.Node.css
* Reorganized styles and updated class names
* Added simple light blue hover with outline (using inset box shadow) for
  protected nodes, same style as before for aliens

ve.ce.Surface.css
* Moved phantom styles to ve.ce.Node.css

ve.ce.BranchNode.js
* Moved call to setLive(false) to happen before detach() so that the
  surface object is still available and events can be disconnected

ve.ce.BranchNode.js, ve.ce.Document.js, ve.ce.js, ve.ce.Surface.js, ve.ce.SurfaceObserver.js
* Adjusted CSS class names

ve.ce.Node.js
* Moved shield template to ve.ce.ProtectedNode

ve.ce.ProtectedNode.js
* New class, mix into another class to protect it from editing

ve.ce.RelocatableNode.js
* Renamed temporary surface property to relocatingSurface to avoid
  confusion when debugging

ve.ce.Surface.js
* Moved phantom template to ve.ce.ProtectedNode

ve.dm.Transaction.js
* Fixed bug where most of the internal list was being deleted when the
  end of the document was selected and the user pressed backspace

Change-Id: I2468b16e1ba6785ad298e38190e33493135719c3
2013-05-07 00:08:48 +00:00
jenkins-bot 152009c327 Merge "Context menu in wrong place" 2013-05-06 23:10:32 +00:00
Trevor Parscal 2706b6dc50 Context menu in wrong place
A bug in I4bad882d1d6fb83bcdcfd0de3bfc9af52960c2ff caused the vertical
position to sometimes be NaN, and thus make the context in the wrong
place (but only vertically).

Change-Id: I5216af5c432caaa0fb400d8d006647b9f2488619
2013-05-06 16:08:47 -07:00
Christian Williams d23c10fd8e Fix insertion annotations
Now comparing annotations in surface to insertionAnnotations
by comparable object to trigger pawn trick. Adding annotations
correctly to placeholder.

dm.Surface change method now uses setInsertionAnnotations()
and passes the AnnotationSet from offset-1. The set is cloned.

Added ve.ce.Surface.areAnnotationsCorrect() to compare either
annotations to the left or right to the insertionAnnotations.

Also use compareTo() and getComparableAnnotations() rather than
comparing by name, and fix SurfaceFragment.annotateContent() to
actually be selective when clearing rather than clearing everything.

Change-Id: I6116afa2e176daa0a0f2103a551501426829e2a6
2013-05-06 15:53:29 -07:00
Ed Sanders 830de420e1 Code style fixes
* "function(" -> "function ("
* "{String}" -> "{string}"
* collapse unintentional double spaces

Change-Id: I3ce3f02d1e31d4797b44e04d28457dec363be296
2013-05-06 12:36:52 +01:00
Trevor Parscal 7233ea8f1b EventEmitter API cleanup
The EventEmitter API we inherited from Node.js and then bastardized was
getting awkward and cumbersome. The number of uses of ve.bind was getting
out of control, and removing events meant caching the bound method in a
property. Many of the "features" of EventEmitter wasn't even being used,
some causing overhead, others just causing bloat. This change cleans up
how EventEmitter is used throughout the codebase.

The new event emitter API includes:
* emit - identical to the previous API, no longer throws an error if you
  emit error without a handler
* once - identical to the previous API, still introduces a wrapper* on -
  compatible with the previous API but has some new features
* off - identical to removeListener in the previous API
* connect - very similar to addListenerMethods but doesn't wrap callbacks
  in closures anymore
* disconnect - new, basically the opposite of addListenerMethods

Another change that is made in this commit is mixing in rather than
inheriting from EventEmitter.

Finally, there are changes throughout the codebase anywhere
connect/disconnect could be used.

Change-Id: Ic3085d39172a8a719ce7f036690f673e59848d3a
2013-05-02 15:05:59 -07:00
Ed Sanders 7cb4a30ff3 GeneratedContentNodes store DOM elements, not HTML (like aliens)
To avoid serialisation bugs, and for consistency.

Change-Id: I02e202a2ab52c88da039349ec079bea55e000665
2013-05-02 18:22:56 +01:00
jenkins-bot ac5524b26d Merge "Make ve.ce.Surface.getSelectionRect() tollerate browser bugs" 2013-05-01 20:25:10 +00:00
MatmaRex 11c56f79c9 Make ve.ce.Surface.getSelectionRect() tollerate browser bugs
.getClientRects() somestimes returns an empty collection which causes an
exception to be thrown by rangy. This corresponds to
.getBoundingDocumentRect() returning a hash full of zeroes.

Detect this and handle such ranges separately, by inserting dummy DOM
elements at the selection's beginning and end, then using their
position to determine where the actual selection was.

This behavior is seen sometimes in Opera, and in Chrome by using the link tool on text at the beginning of the document.

Bug: 47772
Change-Id: I4bad882d1d6fb83bcdcfd0de3bfc9af52960c2ff
2013-05-01 20:23:50 +00:00
jenkins-bot 929d6b9e22 Merge "Also respect .static.renderHtmlAttributes when rerendering for attribute changes" 2013-05-01 18:07:11 +00:00
James D. Forrester b9ba3c92a3 Add support for <div>s as user-editable blocks
Bug: 47907
Change-Id: I794927a881082e0113c0ce8ee8f1d908b0960899
2013-04-30 18:43:41 -07:00
Roan Kattouw 6f2040badf Also respect .static.renderHtmlAttributes when rerendering for attribute changes
Change-Id: I5baa41987e04cb0bee771d530f779df7e4fd86b2
2013-04-30 15:30:18 -07:00
jenkins-bot a287b2e257 Merge "Move Phantoms onChange" 2013-04-30 18:05:30 +00:00
jenkins-bot d8d61126ea Merge "Fix range translation for surface fragments" 2013-04-30 17:58:39 +00:00