Commit graph

1708 commits

Author SHA1 Message Date
jenkins-bot b0eca923bd Merge "Make .static.storeHtmlAttributes more versatile" 2013-05-07 21:53:46 +00:00
Catrope f6d28e6117 Fix ContentBranchNode test broken by ve.ce.ProtectedNode
Also make sure Jenkins actually runs that test suite

Change-Id: I72b10db3875370da95cb20e127ac8f1efee425bf
2013-05-07 14:48:23 -07:00
Catrope 317a404ece Make .static.storeHtmlAttributes more versatile
It now allows you to specify which attributes to preserve in various
ways rather than just setting true or false.

Removed unused factory methods that exposed the old value.

Change-Id: I914164adcf1f0e48fa3fa85277e68c72dbad393e
2013-05-07 14:45:26 -07:00
jenkins-bot ba8ffe629b Merge "ve.ce.FocusableNode: Fix documentation" 2013-05-07 20:01:44 +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
Timo Tijhof a631af342d ve.isMixedIn: Fix bugs and add unit tests
* It returned undefined instead of false if the subject
  didn't have a 'mixins' property. This is because '&&'
  is a DEFAULT operator, not an AND operator, it returns the
  value, not a boolean per se.
* The logic of traversing to the constructor property was
  broken since all objects in javascript have a constructor
  property, and functions/constructors are also objects.

Follows-up Ic3e4472b9e694.

Change-Id: I462e7ce270c8cfc7e1970e359894ee4b7d90b881
2013-05-07 19:44:55 +00: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
jenkins-bot a302cf3754 Merge changes I5f279b06,I6116afa2
* changes:
  Configurable insertion annotations
  Fix insertion annotations
2013-05-06 23:08:40 +00:00
Trevor Parscal c6e0eee837 Configurable insertion annotations
This makes it possible to use a static property to configure whether an
annotation should be applied to content added after it. This makes it
possible to do this for normal style stuff, but not for links.

TODO: Inez is going to add IE support for this since it inverts the
problem where the UI gets out of sync in all non-IE browsers to now make
it so it only gets out of sync in IE.

Bug: 48171

Change-Id: I5f279b06b098960be7bd4ad3f5e6f74b67e31d1a
2013-05-06 22:57:35 +00: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
jenkins-bot 76b277485e Merge "Fix placement of whitespace when element ends in meta" 2013-05-06 20:04:04 +00:00
jenkins-bot bf0a227fd6 Merge "Use a smarter comparison of annotations when creating open/close tags" 2013-05-06 18:52:30 +00:00
jenkins-bot fdb6b845de Merge "Adjust binding to section edit links after changes in core" 2013-05-06 18:00:40 +00: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
Ed Sanders 8c87882633 Use a smarter comparison of annotations when creating open/close tags
Currently we just compare by store index, but a bold annotation
with data-parsoid attributes set should merge with a new clean bold
annotation. Similar rules apply to link annotations.

Bug: 48110
Change-Id: I93586919002c78732228e08b134e67e1a94f8ad7
2013-05-05 20:41:53 +01:00
Roan Kattouw c801099c7b Hack MWTemplate so it also does partial type matches
For extension-specific types such as mw: , we require that all
types be matched. But we want MWTemplateNode to match
anything with an mw:Object/Template type, even if it also has
other types (like mw:WikiLink/Category in our test case).

Hack this into MWTemplate by matching on /^mw:/ then using
a matchFunction to assert that mw:Object/Template is in the
typeof attribute.

Update the test case. Because it's now a template, there's a bunch
of store stuff involved. Remove the other test case for about
group forcing because it's now a duplicate of this one.

Change-Id: Iacbe952a66d610c19b46bd76b84c50488857ac29
2013-05-05 00:07:30 -07:00
Roan Kattouw ef24ac5879 Force about grouping for multi-element about groups
When converting an element that starts an about group with at
least one other element in it, we now only consider models that
support about grouping. This prevents the first node from being
converted to something else and leaving the others hanging.

In practical terms, this means that elements like
<link rel="mw:WikiLink/Category" typeof="mw:Object/Template">
get alienated and pull in the rest of their about group, rather than
being converted to a category or alienMeta or whatever and
leaving the other elements to be converted normally.

Added a test case that asserts this. Really the result should be an
MWtemplate rather than an alien, but that's a separate issue.
Also removed superfluous mustMatchAll checks; we've already
filtered the array by the time we get there.

Change-Id: I522ba4c56d5bc52c7e9aab1e2535385540c1315d
2013-05-05 00:07:29 -07:00
MatmaRex a90ee007cf Adjust binding to section edit links after changes in core
Match the new .mw-editsection class, after core change I6a6c12a9.

Change-Id: I22daf7f9bc720b2be35695ca78c5603e80999986
2013-05-04 19:37:49 +02:00
Ed Sanders 8cfb4ee62f Fix placement of whitespace when element ends in meta
This was broken for both normal elements, where the meta item is
inside the element, and wrapper paragraphs, where the meta item
gets moved outside the wrapper.

Bug: 47712
Change-Id: I42daaf142e548e5b221ff0a52df0ad24ec6a4fd0
2013-05-03 22:45:34 +01:00
jenkins-bot 46dce49462 Merge "Edit source tab should be 'selected' when... selected" 2013-05-03 17:40:50 +00:00
Ed Sanders 33bfeeed41 Update oldid on successful page save (if a new id is generated)
New ID is now passed from the API to the save event, to the onSave
handler. Empty diffs won't generate a newrevid.

Bug: 47420
Change-Id: I12ce27c8dc57f7aa753bcf5840635d5fea6b4e80
2013-05-03 18:10:10 +01:00
Ed Sanders 9dc93451c4 Edit source tab should be 'selected' when... selected
VE recreates the tab from scratch and deletes the old one
so as not to copy over access key settings. This fix
copies over classes from the old tab.

Bug: 47452
Change-Id: Ic2d42bb3034be25f388b587a00c3f523cfcc163c
2013-05-03 13:15:54 +01:00
jenkins-bot d4d8e9075d Merge "EventEmitter API cleanup" 2013-05-02 23:48:30 +00:00
jenkins-bot 9751b28a6a Merge "RTL fix for VE's link widget" 2013-05-02 23:12:47 +00: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
Moriel Schottlender 29f5630957 RTL fix for VE's link widget
The purpose is to flip the direction of the input inside
the link widget for RTL wikis, but flip it again to LTR
if the user inserts an external URL. This is my first VE
fix, I tried to follow conventions and avoid touching the
parent objects that are unrelated to URLs.

Bug: 47717
Change-Id: Ic13b9c3b155ce2979298cac9518c7419b9d45bac
2013-05-02 20:43:46 +00: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
jenkins-bot ff168661b0 Merge "When annotating, skip any branch nodes that are content" 2013-05-01 18:06:34 +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 c77ffee98c When annotating, skip any branch nodes that are content
We don't have these yet, but when we do, we'll need this

Change-Id: I1c2572f00fc0b9a144bb4092a44cd5af2bb752da
2013-04-30 17:41:04 -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
Ed Sanders e29ed7f2b6 Remove all code related to change markers
Specifically by looking for "data-ve-changed",
"ChangeMarker*" and internal.changed.

Various tests, test counters and unused variables also
affected.

Bug: 45061
Change-Id: Ibd1ee68e0d650979d40574eff9cebded1a28499f
2013-04-30 23:15:47 +01:00
jenkins-bot bf35436428 Merge "Allow merging of content nodes with nodes that can contain content (but are not content themself)" 2013-04-30 19:49:13 +00:00
Inez Korczyński afab43a762 Allow merging of content nodes with nodes that can contain content (but are not content themself)
This changeset addresses a problem of pressing backspace in empty list item in order to merge it with list item above it.

Change-Id: I598da6ef24de97b0a7a7bbab6c9ee775aaab460b
2013-04-30 12:09:22 -07:00
jenkins-bot 713fa24d10 Merge changes I5eafaa48,Ia8f23a37,I17534d67,If5ed1b64
* changes:
  Category editing
  Remove singular adding for ve.ui.GroupElement
  Implement ve.dm.Surface#truncateUndoStack
  ve.ui.LookupWidget
2013-04-30 18:34:26 +00:00
jenkins-bot 29e2b6c060 Merge "Make loading VE work on Opera again" 2013-04-30 18:26:47 +00: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
Christian Williams 4dfb137bc0 Move Phantoms onChange
Aliens now listen for surface model change events in order to
adjust the position of the phantoms.

Change-Id: I1e8bfba331a10678e9ca7e64b7818197237eb0a2
2013-04-30 10:55:59 -07:00
Trevor Parscal 718db58fd5 Category editing
Modifications:

VisualEditor.php
* Added links to new widgets

VisualEditor.i18n.php
* Added placeholder text for category input

ve.ui.Widget.css
* Added styles for new widgets

New:

ve.ui.MWMetaDialog.js
* Create category widget with categories from dm.
* Listen to metaList for insert and remove events
** insert / remove bound methods to be improved upon additional meta groups
* Add listeners to mwCategoryWidget for new categories and updates

ve.ui.MWCategoryWidget.js
* Top-level category editing widget

ve.ui.MWCategoryItemWidget.js
* Items within a category widget

ve.ui.MWCategoryInputWidget.js
* Input for new categories, handles menu and API requests

ve.ui.MWCategoryPopupWidget.js
* Mini-inspector for a category item

Bug: 39597
Change-Id: I5eafaa484a1924a566d3a1ee1d869293089d0ecf
2013-04-30 17:50:31 +00:00
Trevor Parscal 52529d790b Remove singular adding for ve.ui.GroupElement
By making the API for adding/removing/clearing always plural, it greatly
simplifies the interfaces and reduces function call overhead in most
situations.

Change-Id: Ia8f23a373a01a8f6d5081587a591563e4f25ea42
2013-04-30 17:50:22 +00:00
Trevor Parscal e9346fdb60 Implement ve.dm.Surface#truncateUndoStack
ve.dm.Surface.js
* Allow manual truncation of the undo stack to prevent redoing something
  that's been undone

Change-Id: I17534d6724fc2b325152cb2f665c6816f44232c1
2013-04-30 17:50:17 +00:00
Trevor Parscal cd6b54a4e8 ve.ui.LookupWidget
Refactoring of externally sourced suggestions for text inputs.

*.php
* Added links to new file

ve.ui.InputLabelWidget.js
* Changed to focus input element, not wrapper div

ve.ui.InputWidget.js
* Fixed incorrect documentation

ve.ui.LookupInputWidget.js
* New mixing that abstracts placing a menu of options below a text input
  and filling it with data from an external source

ve.ui.MenuWidget.js
* Fixed to get reference to input element, no wrapper div

ve.ui.MWLinkTargetInputWidget.js
* Moved pending and lookup functionality to mixing
* Implemented menu population using only matching pages, rather than a
  combination of that and page existence checks (fewer API calls)

ve.ui.TextInputMenuWidget.js
* Added configurable container to render underneath, rather than assuming
  this.input.$
* Added auto-position-on-window-resize functionality
* Fixed frame position correction to ensure that it only is used when the
  overlay is in a different frame from the container to position
  underneath

ve.ui.TextInputWidget.js
* Added placeholder text feature

Change-Id: If5ed1b64fd15982807691ce8bb0362970633108a
2013-04-30 10:47:32 -07:00
Ed Sanders d4eef1b879 Fix range translation for surface fragments
Remove all manual changes to SF ranges as these are not
undoable. Instead change translate range to default to
outer expand and build functionality around that behaviour
never changing.

As translate range is always outer I don't think we need to
check for start and end crossing over?

Added more undo tests to assert these selections are maintained
properly, and added the test case to 'update' for when and undo
point is overwritten.

Insert content now results in a selection over the inserted
content. Most usages were expecting this anyway and were
followed up with an adjustRange(-length,0) which is no longer
necessary.

Noticed that the link inspector case was never being triggered
as word boundary was always expanding to at least one char (mainly
for Hanzi selection). This doesn't make much sense as single
spaces get auto selected so removed this functionality.

Split collapseRange out into collapseRangeToStart and
collapseRangeToEnd as this may be required to get the old
behaviour (range moves to end after insert).

Change-Id: I3dc0b4d00d37bad1ca3076a69b41c5f0b3fa0570
2013-04-30 17:08:15 +01:00
Timo Tijhof 56584ff4f9 makeStaticLoader: Implement --write-file option
Takes a path as input, reads it in and replaces the
"Generated by" sections and writes it back to disk.
:
Change-Id: Idd68032ba5b621958a353582ea994acd0c4cfbd3
2013-04-30 15:08:55 +00:00
MatmaRex 23102fdc19 Make loading VE work on Opera again
Once more, with feeling. The first reverted attempt was I90ea547c.

Detailed comments inside.

Change-Id: I1ab60665987614e5757e2b108d614b680321d8eb
2013-04-30 14:36:47 +02:00
jenkins-bot 6cd91d6c34 Merge "Get back to where you once belonged" 2013-04-30 04:32:59 +00:00
jenkins-bot 00b1458099 Merge "ve.ce.Surface.getSelectionRect() might return null" 2013-04-30 02:11:55 +00:00
jenkins-bot 11056cf07b Merge "Fixed a comment" 2013-04-30 02:11:29 +00:00
jenkins-bot b6fd811c7f Merge "Per Timo's comment, change $.makeArray( foo ) to foo.toArray()" 2013-04-30 01:14:41 +00:00
Roan Kattouw a59f622d54 Per Timo's comment, change $.makeArray( foo ) to foo.toArray()
Change-Id: Ideee46640bc82f979578d5cc467c9c79d9806ae0
2013-04-29 18:08:04 -07:00
jenkins-bot 30c6dfd84a Merge "Fix ce.AlienNode" 2013-04-30 00:51:18 +00:00
Roan Kattouw fdea620ffe Fix ce.AlienNode
Was completely broken after the dm.AlienNode changes

Change-Id: I3f5116d7dfbaa5889b7c5cac01d7341272749c58
2013-04-29 17:35:08 -07:00
jenkins-bot 619f5209f2 Merge "Revert "Redo ve.createDocumentFromHTML() properly"" 2013-04-30 00:32:40 +00:00
jenkins-bot 8e24547c27 Merge "Use duck typing instead of instanceof Node" 2013-04-30 00:30:45 +00:00
Catrope c5af2fcbce Revert "Redo ve.createDocumentFromHTML() properly"
Completely breaks in Firefox

This reverts commit 7287c80293

Change-Id: I1c34842e156fd5668aac097ba6dd80201e54ecca
2013-04-29 17:24:46 -07:00
Roan Kattouw 43ea9a42d8 Use duck typing instead of instanceof Node
instanceof Node doesn't work with nodes generated by the iframe hack
for some reason. Instead, use duck typing by checking for a .cloneNode
method.

>>> ve.createDocumentFromHTML('<body><tt>Foo</tt></body>').body.childNodes[0]
<tt>Foo</tt>
>>> ve.createDocumentFromHTML('<body><tt>Foo</tt></body>').body.childNodes[0] instanceof Node
false

Change-Id: I1ea1253bd204d1070cd01b666b8a90f1cb7e5e14
2013-04-29 17:24:41 -07:00
Christian Williams 5e84ac9ee5 (bug 47746) Fixing Phantom placement in RTL
CSSJanus flips left for right for RTL languages. To ensure proper positioning of phantoms, the phantom container must actually be set to left:0, not right:0. Added the @noflip option before the phantoms selector to prevent CSSJanus from modifying it.

Change-Id: Id7662362d117d6c5719b9b98d7a0dbf62e9ba3ff
2013-04-29 17:00:29 -07:00
Trevor Parscal 4ee9e1f28d Get back to where you once belonged
The toolbar has a high z-index when being floated, it doesn't need one
otherwise. This was causing an issue where the Vector actions drop-down
menu was being obscured.

Change-Id: I3c0ff7c4cf3b4a6c3d94f00ef56d7f299aeb6020
2013-04-29 22:59:46 +00:00
jenkins-bot f39499b656 Merge "Fixed docs" 2013-04-29 22:41:53 +00:00
Trevor Parscal 27287188ac Fixed docs
Wrong param type.
<pre> tags quoted to avoid jsduck warning.

Change-Id: Ieb9b5527ea69c8f02a175d29c1534290f85ba032
2013-04-29 21:58:51 +00:00
Ed Sanders b85c7f0628 Create meta item for defaultsort
Bug: 46465
Change-Id: I604a79c25e5b0315f7e6437da657977b0efa77db
2013-04-29 15:33:37 +01:00
MatmaRex ee241223ae ve.ce.Surface.getSelectionRect() might return null
Protect against this. Also fix misnesting of updateDimensions()
function's body.

Change-Id: I5040d46d51bd59bf4d2fd7d4d8853c8675420ad0
2013-04-29 15:27:31 +02:00
MatmaRex 6e4f86bf47 Fixed a comment
Change-Id: I97917f70d42820105f6cdbaa3a1724cee3d6731b
2013-04-29 14:29:50 +02:00
Ed Sanders 6aaa54bc5f Fix new test case to use new domElements instead of html
This was missed by the merge as it doesn't cause any tests to fail (yet).

Change-Id: I6d106279d31276817ea718fdef3d8199b80693f6
2013-04-28 21:24:20 +01:00
jenkins-bot e7d335b1c7 Merge "Paragraph->heading conversion was broken when cursor next to an inline node" 2013-04-28 20:01:08 +00:00
jenkins-bot 9ddcd88a00 Merge "AlienNode stores original DOM elements instead of HTML" 2013-04-27 21:08:59 +00:00
Ed Sanders cddb3f1b39 AlienNode stores original DOM elements instead of HTML
As jQuery hash problems in some cases converting HTML, it is
easier just to store the original DOM elements.

The bulk of this commit is fixing the tests as although we have an
assertion for comparing DOM elements, we don't have one for comparing
objects or arrays which may contain DOM elements.

ve.js
* copyObject & copyArray fixed to run cloneNode(true) on any item
  of type Node.
* Added callback function so an object/array can be copied with
  modifications.

ve.qunit.js
* Added deepEqualWithDomElements: Using the new copyObect/Array
  callback, we can copy the incoming object and convert any nodes
  to node summaries, then just run the normal deep equal comparison.

ve.dm.AlienNodes.js
* Instead of storing HMTL we store cloned DOM elements which we can
  send straight back to the converter without any processing.

ve.dm.example.js
* Updated tests to expect DOM elements instead of HTML.

ve.dm.Converter.test.js
* Updated tests to use deepEqualWithDomElements

Bug: 47737
Change-Id: I3df8f49b170c31da9610129d53cf8cb65dd5d5f8
2013-04-27 21:04:58 +00:00
jenkins-bot fd9c381ef1 Merge "Add a copy of jquery.client so the standalone still works" 2013-04-27 13:30:06 +00:00
Roan Kattouw e89e991037 Paragraph->heading conversion was broken when cursor next to an inline node
In this case, selectNodes() returns the paragraph, which is not a content
node, and so newFromContentBranchConversion() decides to do nothing at all.

This change makes newFromContentBranchConversion() more intelligent about
finding the content branch to operate on, fixing cases such as these
where selectNodes() returns the content branch itself rather than one of
its children.

Bug: 41203
Change-Id: I710fbf184ef5ef84d9c2f5bca2b115e0660f5b8f
2013-04-27 00:16:46 +00:00
jenkins-bot b010e491bc Merge "Stop dropping properties in copyObject/copyArray" 2013-04-26 23:28:02 +00:00
jenkins-bot c3131e1856 Merge "Allow fixUpInsertion to move offsets when inserting at start/end" 2013-04-26 23:23:58 +00:00
Ed Sanders 60cf31bcb6 Allow fixUpInsertion to move offsets when inserting at start/end
fixUpInsertion now returns an object with both data and offset
which allows offset changes.

Within fixUpInsertion we lazy-generate first/lastChildStack which
is a list of parent nodes for which the current node is the first/last
child. Whenever we try to close off a node we check these stacks and
if they are populated we instead use a recursive call to start
fixUpInsertion again but with the offset shifted by 1.

Bug: 46799

Change-Id: Ic51dd03725c11f1f7e279929534ee3afea14d662
2013-04-26 22:52:27 +00:00
Catrope 2656dbf445 Stop dropping properties in copyObject/copyArray
Previously, if we didn't know about a property type we would just drop it.
This led to various fixes to add support for booleans, nulls, etc. We're
now having problems again, this time with functions not being copied.

So instead of only copying types we know how to copy, deep clone the ones
we know how to and shallow copy the ones we don't know about. This seems
like a saner approach to me. Besides, it doesn't seem like cloning a
function is even possible in JS.

Change-Id: Idd1546ce3a43087a8b96a37101431e466e02f04f
2013-04-26 15:41:56 -07:00
Roan Kattouw 6d2a6491c8 Add a copy of jquery.client so the standalone still works
The tests passed just fine in Gerrit, because it runs the tests via
MediaWiki using ResourceLoader, which was able to load jquery.client
just fine from MW core.

Change-Id: I004514ab761107b687be2fe1ff49ecfd25bead5b
2013-04-26 14:40:03 -07:00
jenkins-bot 82a7c1b2ef Merge "UI Refactor" 2013-04-26 21:20:48 +00:00
Trevor Parscal 6a068e7d83 UI Refactor
Changed:

VisualEditor.i18n.php
* Updated Link inspector i18n messages

ve.ui.MetaDialog.js -> ve.ui.PagedDialog
* Moved paging functionality into Paged dialog

ve.ui.EditorPanelLayout -> ve.ui.PagePanelLayout.js
* Renamed from EditorPanelLayout to work nicely with the concept of
  stacks and pages

ve.ui.GroupElement.js
* Added addItem method and change addItems to use it

ve.ui.Dialog.css
* Updated classname as per refactor of meta dialog

ve.ui.StackPanelLayout.js
* Set currentItem property on showItem
* In addItems method, show currentItem with class method
** rather display block on element

ve.ui.Layout.css
* Make editorPanel layout 100% in width.

ve.ui.Widget.css
* Added CategoryWidget and CategoryPopup styles
* Other adjustments

ve.ui.PopupWidget.js
* Added auto-close on loss of focus
* Made friendly with being initialized inside a frame

ve.ui.MWLinkTargetInputWidget.js
* Mixin ve.ui.PendingInputWidget and remove pending methods
* Prevent querying on spaces
* Reintroduce i18n messages for menu sections

ve.ui.MenuWidget.js
* Update cases of $input config property to input

New:

ve.ui.PagedDialog.js
* Refactored base-class for mwMeta dialog (and probably other dialogs
  too)
* Abstracts adding and accessing pages

ve.ui.PendingInputWidget.js
* Moved pushPending and popPending methods into pending class

Change-Id: I29bcd92b7b5641941a4e98e65b2a56424a5263ff
2013-04-26 21:18:13 +00:00
jenkins-bot 892be200b5 Merge "Add TableCaptionNode" 2013-04-26 21:12:09 +00:00
jenkins-bot a6d916637e Merge "(bug 47711) Fix FF specific bug" 2013-04-26 21:11:34 +00:00
Roan Kattouw c68765639a Add TableCaptionNode
Because we have a node for <table>, we also need one for <caption>,
otherwise we'll try to alienate it and fail.

Added the test case as a separate example document so Ed can use it
for his tests.

Removed test case asserting <caption> is alienated.

Change-Id: I3a917db58e6c0eb97899b214b07d01fc8d86b56d
2013-04-26 14:09:54 -07:00
Inez Korczyński b9c2f855e1 (bug 47711) Fix FF specific bug
Firefox fires key press events for arrow keys - but we handle them
already in keydown - so the solution is to just ignore those
key presses in the handler.


Change-Id: I1aff295a0958b75697c4d362e0d6095283f37fe8
2013-04-26 20:09:10 +00:00
jenkins-bot 8c10bfd7de Merge "Redo ve.createDocumentFromHTML() properly" 2013-04-26 19:45:25 +00:00
jenkins-bot af4868badc Merge "Further AnnotationSet optimisation: create containsIndex" 2013-04-26 01:28:20 +00:00
jenkins-bot 82b591bc63 Merge "Add method to ElementLinearData to get IVStore items in use" 2013-04-26 01:27:39 +00:00
jenkins-bot 38e9495d5f Merge "Make clearing by type actually work" 2013-04-26 00:47:54 +00:00
jenkins-bot 26020ab113 Merge "Deduplicate childUpdate events based on transaction and appliedness" 2013-04-26 00:42:24 +00:00
Roan Kattouw 72e06d9cbf Deduplicate childUpdate events based on transaction and appliedness
Previously, they were only being deduplicated based on the transaction,
which meant that an undo was seen as a duplicate (but then if you undid
again, that wasn't a duplicate).

Change-Id: If432ea28e6c206a2ad5562e529e2d3ed808c20e4
2013-04-25 17:08:30 -07:00
Roan Kattouw d975762c00 Tolerate <!DOCTYPE>
Parsoid switched from <!doctype> to <!DOCTYPE>, which exposed the fact
that our dirty regex to detect whether we're dealing with a full
document or a fragment was case-sensitive. Made it case-insensitive.

Change-Id: Ia8a38488e06ca7d7a6fb9a9699b5d9b5c5eb03f2
2013-04-25 16:55:29 -07:00
Roan Kattouw 5c5d64f5d1 Make clearing by type actually work
Clearing by type in SurfaceFragment didn't actually work. Instead,
it followed a code path intended for setting and created an annotation
of that type with no data, then tried to clear that. What we really
want to do there is clear anything with that type.

This fixes the bug where unbolding of text that was already bold in
the article didn't work.

Bug: 47680
Change-Id: I77f00e63c8732420063b0453fede7f453083c913
2013-04-25 16:53:25 -07:00
jenkins-bot 841a8925c8 Merge "New static property - renderHtmlAttributes" 2013-04-25 23:44:13 +00:00
jenkins-bot 8d4c87a388 Merge "Initial support for MWBlockImageNode - thumb images with captions :-)" 2013-04-25 23:36:08 +00:00
Ed Sanders 3d64c3043c Further AnnotationSet optimisation: create containsIndex
In most places we call .contains we already know the index, so we
can avoid store lookups by using .containsIndex.

Change-Id: I45a9a421473f9bec479ab8ccceceb162b7004c3a
2013-04-25 22:55:43 +01:00
Inez Korczyński 4c6d296067 Initial support for MWBlockImageNode - thumb images with captions :-)
Change-Id: I4d81533ed9193ff934333f7c1ad80e03e33b236c
2013-04-25 21:49:32 +00:00
Inez Korczyński 2286259681 New static property - renderHtmlAttributes
It is going to be used at least for figure tags for which Parsoid gives as a lot of CSS class names that are useless for rendering purpose

Change-Id: I4b1e8084a6b7ab5294e0c3cf153fc6cffb3e8dac
2013-04-25 14:42:12 -07:00
Ed Sanders 09a90c1c7a Add method to ElementLinearData to get IVStore items in use
This is minimise the amount of data we need to serialise when
sending this over the wire.

The minimal IVStore data is added to the MW bug report, and
editedData fixed to only return the data array, not the full
LinearData object.

Documentation in AnnotationSet has finally been updated to
refelect the fact that it only stores Annotations
(was previous the generic OrderedHashSet).

getAnnotationFromOffset has been split out into a function
that just returns this indexes so that in cases where we
don't need the values we don't do an unneccesary store lookup.

Bug: 47318

Change-Id: I4819cf06d1bd0ae4f8b896052e278ca75c9551bf
2013-04-25 22:40:56 +01:00
jenkins-bot 13710a1ed4 Merge "Performance improvement for getRenderedContents" 2013-04-25 21:37:25 +00:00
Inez Korczyński 93357b8f34 Performance improvement for getRenderedContents
Instead of calling $.append for every single char - buffer and call $.append only when really needed.

Change-Id: I53acfa795ea5dc6a8ca39ce11017daa85c9151d2
2013-04-25 14:15:01 -07:00
jenkins-bot f56b83e07e Merge "Remove fixUpStack to fix blank paragraph insertion bug" 2013-04-25 21:14:53 +00:00
Ed Sanders cd4ee24c0e Remove fixUpStack to fix blank paragraph insertion bug
The fixUpStack is actually redundant code and closingStack
and openingStack handle all our cases. It was causing the
insertion to try to correct balance itself in the middle
of inserting two paragraphs, causing the creation on an
empty paragraph between them.

Added a test case for the fix and other cases to make
sure removing fixUpStack hasn't caused problems.

Bug: 46800

Change-Id: I35e54165709ac56e8116359a7c3b487eecf08ff7
2013-04-25 14:04:51 -07:00
jenkins-bot e7ee9564e6 Merge "Improve resizable node rendering" 2013-04-25 20:47:10 +00:00
Trevor Parscal a64ceb74e0 Fix link inspector undefined madness
Reuse the existing internal link annotation builder instead of using a
constructor directly, and incorrectly (it's meant to be passed an
element, not an attributes object)

Change-Id: I4cda6a9c3442cb10ebbc0844630fedba403adc91
2013-04-25 19:43:39 +00:00
Trevor Parscal f8621f9ef8 Improve resizable node rendering
* Only place them in a high z-index while resizing so they don't render
  above dialogs and menus
* Add resize transition

ve.ce.ImageNode.js
* Switch from element attributes to CSS for setting dimensions

ve.ce.Node.css
* Add resizing class for resizable nodes for z-index
* Add transitioning class for resizable nodes for transitions
* Switch from border to inset box-shadow to not affect handle position
  calculation

ve.ce.ResizableNode.js
* Add/remove resizing class while resizing
* Switch from using $image to $resiable to make the class useful for
  non-image node
* Enable transition and set new dimensions before transaction processing
  which will cause re-rendering)
* Delay transaction processing for resize until after transition is
  complete
* Add hiding of context menu on resize start

ve.ce.Surface.js
* Add getSurface method so we can get to the context menu

Change-Id: I4667e394d0af4a80b651c2a0f6d11d30e196bf60
2013-04-25 11:45:11 -07:00
MatmaRex 7287c80293 Redo ve.createDocumentFromHTML() properly
Redone using document.implementation.createHTMLDocument instead of the
iframe trick. It's supported by all browsers we target, including IE9.

This also makes VE work on Opera using a nasty hack.
* Previously, for reasons I'm not even trying to understand, Opera
  would sometimes return an empty generic object from
  ve.createDocumentFromHTML() - but only if you weren't debugging it
  (Dragonfly was disabled). I have no idea what is it about the iframe
  hack that makes it not like it, but fact is, it doesn't work.
* Calling .open(), .write() or .close() on the document returned by
  document.implementation.createHTMLDocument acts as if it was
  window.document - that is, the entire contents of the web page are
  replaced with new ones. That's probably a one-word bug somewhere
  deep in Opera's innards; I reported it (it got the identifier
  DSK-384486). Until it gets fixed, we work around it by using
  document.documentElement.innerHTML, which works reliably.

Change-Id: I90ea547c735edaba9f7ecb8f685351ac6499c53e
2013-04-25 20:08:21 +02:00
jenkins-bot 5ed4f15460 Merge "Make the feedback link language-variable for release" 2013-04-25 16:09:39 +00:00
James D. Forrester 73cb0c7506 Make the feedback link language-variable for release
This involves setting some i18n messages for the target languages based on the
translations already provided - I hope this doesn't break anything for TWN but
the need for this only just became apparent; apologies!

Longer-term we will need to come up with a better way of doing this, if we are
keeping the in-VisualEditor feedback link around.

Change-Id: Id6ed80cdcd4314e84e75fb718421767162d73ef3
2013-04-25 09:02:28 -07:00
Ed Sanders bdb4a116d9 Hack to escape angle brackets in data-parsoid attribute
Parsoid is sending us some unescaped HTML in the data-parsoid
attribute. When we try to rebuild ref nodes (inline aliens)
this confuses Firefox which tries to sanitise the HTML by converting
<ref/> to <ref></span>.

As a temporary fix we can manually escape <>'s inside the
data-parsoid attribute.

Also in this commit the new MWReference nodes have been moved
to experimental as they are incomplete.

Bug: 47417
Change-Id: Ib6a0cfb880e769f28b42c9fa63ddc1abc75c399d
2013-04-25 14:55:17 +01:00
jenkins-bot dfe4c1b98f Merge "Link inspector fixes" 2013-04-25 01:31:33 +00:00
Trevor Parscal 3f3c87ce24 Link inspector fixes
ve.ce.Node.css
* Added prefixes for use of box-sizing

ve.ui.MWLinkInspector.js
* Whitespace

ve.ui.Inspector.css
* Corrected input width, always 100% wide now by using box-sizing

ve.ui.DialogButtonTool.js, ve.ui.Context.js
* Updated use of getViewsForNode

ve.ui.ViewRegistry.js
* Added inheritance-based prioritization for matching views with annotations and nodes

Bug: 47413

Change-Id: I286a28002c1691e58bbd7de04ed08cceb8b3bb07
2013-04-24 18:29:55 -07:00
jenkins-bot dc37f3132e Merge "Create and process transaction only if the value of given attribute (width or height) really changed" 2013-04-25 00:27:04 +00:00
Inez Korczyński 6b7d62e4a4 Rename MWImageNode to MWInlineImageNode (get ready for adding MWBlockImageNode soon)
Change-Id: I617e2a17cb6fbd11e486c2981e361ae931ac1870
2013-04-24 16:49:07 -07:00
jenkins-bot 4d64b0bb8f Merge "Mixin tracking" 2013-04-24 23:23:00 +00:00
Inez Korczyński 939985ccd8 Create and process transaction only if the value of given attribute (width or height) really changed
Change-Id: I4177478171e1d417634adb06f3bf74af0c77c15e
2013-04-24 15:49:33 -07:00
Christian Williams f8f82c8eaa Selecting generated content with cursor keys
Using left and right arrow key to move to and over an image will
select the entire node.

Bug: 37870
Bug: 38129
Change-Id: I70deadd2c2707149ea33e3b8ee42fb0d8508aacc
2013-04-24 13:22:41 -07:00
Trevor Parscal 898866a598 Mixin tracking
Change-Id: Ic3e4472b9e69458f0797c17f72dbcd2ec5267893
2013-04-24 12:45:53 -07:00
Timo Tijhof c1383b8012 ve.init.mw.ViewPageTarget: Account for serialize error
This is showing a separate need for refactoring. We call
"this.serialize( ..., callback )" but if it failed callback
is never called and an event is emitter for the error.

That makes it rather disconnected from each other.

In this case we're lucky that all calls to serialize are similar
in nature and need the same kind of error callback but other
wise this would be pretty messed up. It obviously needs to be
untangled and get rid of this akward eventemitter dance.

This doesn't fix bug 47581, but it does fix the "Infinite loader
with no error" problem as a result of it by handling the error
in a more intuitive way.

Bug: 47581
Change-Id: Icdf64a792c13a326f494e051be47f2946928d142
2013-04-24 02:06:12 +02:00
jenkins-bot 7a75e6309d Merge "Added unit tests for getRelativeOffset method" 2013-04-23 23:57:26 +00:00
Inez Korczyński f21a385bd9 Refactor renderContents() deduplication code
Change-Id: Ib8672b51fc236cac805b88a99d07b3c496548cbd
2013-04-23 16:10:18 -07:00
jenkins-bot c762dced66 Merge "Add menu icon" 2013-04-23 19:32:40 +00:00
jenkins-bot bb34823cbb Merge "ViewPageTarget: Refactor 'replace' tabLayout" 2013-04-23 19:11:14 +00:00
jenkins-bot 599ad7e7f5 Merge "Add data model support for MediaWiki references" 2013-04-23 14:05:26 +00:00
Ed Sanders 6ad61d4ddb Add data model support for MediaWiki references
So far just read-only.

Bug: 39599
Change-Id: I6daff5c5969e5fdc871f8f346cf790b4302ae080
2013-04-23 10:17:42 +01:00
jenkins-bot 65602e1b84 Merge "Minor logic fix in ve.createDocumentFromHTML()" 2013-04-23 05:09:36 +00:00
jenkins-bot f5529dbabd Merge "Fix ve.ui.get$$'s handling of jQuery selection" 2013-04-23 03:10:01 +00:00
MatmaRex f4d28243a2 Minor logic fix in ve.createDocumentFromHTML()
iframe.contentDocument doesn't seem to have a key called 'document' at
all; I assume a different nesting was intended.

Change-Id: Ia37e3719d5247408bac2dfad1717d9193fb84c06
2013-04-23 00:41:41 +02:00
jenkins-bot e7fb5d9cce Merge "AnnotationSet optimisations." 2013-04-22 21:20:15 +00:00
jenkins-bot 196123e7a5 Merge "MWTemplateNode should serialise original HTML if unchanged" 2013-04-22 21:15:41 +00:00
Inez Korczyński 390f884aed Added unit tests for getRelativeOffset method
Change-Id: I45538f3e698229c003097c84edceac7ae4e4eb05
2013-04-22 14:12:56 -07:00
Ed Sanders 2bd6f8576a MWTemplateNode should serialise original HTML if unchanged
To help the selective serialiser we can return the original
HTML for generated content if it is unmodified.

As the output of toDomElements now depends on changes
to the dataElement we now have a 'modify' function in
the some test cases.

We also now have 'storeItems' to assert that the index-value
store is correctly populated and for loading values back
into the store for toDomElements tests.

Also make 'mw' an attribute and remove 'about' property.

Bug: 47394
Change-Id: I2bbb5d2d6a90c4eb87fa129671112c92a9b931e7
2013-04-22 20:44:21 +00:00
Trevor Parscal 3bcac07aab Fix ve.ui.get$$'s handling of jQuery selection
Turns out, the context property of a jQuery selection isn't always
there.

For example:

$( 'body' ).context === document
$( '<div>' ).context === undefined

Even if you later attach that div, so long as you have the old
selection around, the cached `context` property won't magically be
updated. This makes sense (although it's poorly documented in the
jQuery API) but causes issues for us, and pretty much makes the
context property useless.

Instead, we can just use the standard `ownerDocument` property,
available on all DOM elements.

This change also add support for passing in a DOM element directly, in
addition to the existing support of passing jQuery or Document objects
in.

Change-Id: Ib8a31b74f2a4f455b1318be9f5c7805a2a193c79
2013-04-22 20:36:42 +00:00
Timo Tijhof cc37ba242b ViewPageTarget: Refactor 'replace' tabLayout
The 'add' tabLayout path is pretty basic and up to date. The
older (now active again) tabLayout 'replace' was fairly outdated
and unmaintained.

Fixes:
* Attributes copied from the original (except for the 'id'
  attribute) were not actually beinged copied over because they
  don't exist on the ca-edit list item, but on the anchor link
  inside that list item.
* Clean up messages from the module registry that were unused.
  Keys 'accesskey-ca-edit' and 'tooltip-ca-edit' were also inexistant.
* Add message keys for tooltip and accesskey of editsource tab.

Depends on I0bde1a228983c58b in mediawiki/core.

Bug: 47396
Change-Id: If598552fac639da645a8b1273c5fc6028695fcc1
2013-04-22 20:09:46 +00:00
Catrope 3848c3f220 Factor the <pre> newline hack out of the converter into ve.properInnerHTML()
Also add detection for whether the browser is actually broken (most are,
but some, like Opera, aren't), treat <textarea> and <listing> in addition
to <pre>, and fix a bug where the function would crash if the <pre> was
empty (because .firstChild was undefined/null).

Change-Id: I541b57e9fd5c9c42d19d0a59f6e29fb43d35c9b6
2013-04-22 20:09:52 +01:00
jenkins-bot b3850a65e3 Merge "The resurrection" 2013-04-22 18:38:12 +00:00
Ed Sanders 1998496e49 AnnotationSet optimisations.
addSet:
* Instead of indexing items in the store, just union the indexStore arrays

removeSet/removeNotInSet:
* difference or intersect the indexStore arrays

filter:
* push indices into the result set instead of values

simpleArrayUnion/Intersect/Difference have been created as utilities
in ve. They are prefixed 'simple' because they use object keys to
do fast in-array comparisons. This means they are limited to string
values or values which will compare as strings (e.g. numbers).

Change-Id: I079cbdfece4f6d80ec0afd61959913f13217fcb3
2013-04-22 19:37:19 +01:00
Trevor Parscal 66afffa685 Add menu icon
Also fix reference icon class name

Change-Id: I3ace9644c74687047995f8c896d4133bbb59ede2
2013-04-22 10:51:10 -07:00
jenkins-bot dc57d8a3d2 Merge "Move config vars that are global in nature to the startup module" 2013-04-22 15:06:07 +00:00
Ed Sanders 8b09dd7650 The resurrection
By removing the transaction listeners from surface fragments we
no longer have to make sure they are always manually destroyed.

In order to retain the functionality of having fragments update
with transactions elsewhere we keep a pointer to a place in the
new complete history stack in the surface. The complete history
stack records all transactions, even undone ones.

Whenever getRange is called we replay all transactions in the
complete history (in the correct order) since the fragment was
last updated.

Also in this commit:
* Updated Format/IndentationAction to test undo(). This increases
  coverage of surface fragment behaviour.
* .range is always accessed by .getRange now, although as an
  optimisation we can use the noCopy mode when we a sure the
  returned range will not be modified.
* Added undo test to .update (previously .onTransact)

Bug: 47343
Change-Id: I9e9818da1baa8319a3002f6d74fd1aad6732a8f5
2013-04-22 12:50:23 +01:00
Trevor Parscal b3cd473f33 Allow resizing nodes
Actually really resizing the image

Show bounding box on mouseover with 4 handles. Bounding box is resizable. Image resizes to match bounding box on mouse up.

Change-Id: I1f3dac64eb86dd1f258937e4915af101b3ac19d8
2013-04-19 12:44:33 -07:00
Trevor Parscal 1878c7c5a8 Allow node relocation
*.php
* Added links to new file

ve.ce.ImageNode.js
* Added relocatable node mixin
* Added $image reference to the actual img element, so if it's wrapped
  in a sub class the functionality in the parent class  doesn't break.
* Moved drag start event handling to relocatable node
* Removed drag end binding, not needed.

ve.ce.MWImageNode.js
* Moved addClass to initialization section of constructor.
* Copied 'view' data prop from image element to keep stuff working after
  the wrapping.

ve.ce.Node.css
* Switched to default (arrow) cursor for images.

ve.ce.RelocatableNode.js
* New mixing for nodes that should be relocatable
* Added implementation for drag start, which tells the surface to allow
  dragging this node.

ve.ce.Surface.js
* Added relocation support, which is used by relocatable nodes
* Split onDocumentDragDrop into onDocumentDragOver and onDocumentDrop
  which now have implementations that support relocation of nodes

ve.ui.Context.js
* Added relocation tracking to prevent context being shown while
  relocating

Change-Id: I8703adfb707af2c3224431afc3418356ac2c686c
2013-04-19 12:07:18 -07:00
jenkins-bot 832137de50 Merge "Initialize iframe for dialog with correct doctype" 2013-04-19 18:53:12 +00:00
Catrope f3b03a64f6 Move config vars that are global in nature to the startup module
If they're in the per-page config, we'll have to deal with caching
nightmares when changing them.

Change-Id: Ic8866500b1f20aee36c436dcc3d132c8fde0a8fc
2013-04-18 20:00:55 -07:00
Inez Korczyński c5218b9fef Initialize iframe for dialog with correct doctype
Change-Id: I93bf12754b5c4d99e117c822d287015765651eb3
2013-04-18 19:49:09 -07:00
Ed Sanders fd23c9522f Separate experimental features out into a new module
Currently some issues, probably with loading nodes
after factories.

Toggled by global $wgVisualEditorEnableExperimentalCode.

Change-Id: Idab3dd68572c037289c6742d03fd327285110f67
2013-04-18 17:20:11 -07:00
jenkins-bot ab06788309 Merge "Fix broken config for this.restoring" 2013-04-19 00:14:07 +00:00
James D. Forrester fe4dce7890 Fix broken config for this.restoring
Current set up leaves us with restoring when we're not and vice
versa. Not good. :-) (Partial fix of change 59968.)

Change-Id: Ia33a2f3318cf2e46b7469b2c773e91c5ee8fdefa
2013-04-18 17:10:29 -07:00
Trevor Parscal bb232a0ee7 Frame initialization exceptions
Don't call initialize inside the try-catch, it ends up sending exceptions thrown inside that method to /dev/null.

Change-Id: I8e0945f35c639ec156ee9a163b86fddfaed0ea7b
2013-04-18 16:52:03 -07:00
Catrope 93cb630aed Don't show "Restore page" button when editing most recent version
Change-Id: Iaeb11e0d5323e0276e66fc4c994d705cde68411d
2013-04-18 16:23:08 -07:00
jenkins-bot ed89820614 Merge "Fix whitespace preservation around meta items" 2013-04-18 23:18:12 +00:00
Inez Korczyński a13713e3a4 Fix bug in ContentBranchNode that caused renderContents to be called not enough
Change-Id: Idff61d405404eccb43c0f36cbfc7eba5af30bad9
2013-04-18 16:11:59 -07:00
Catrope 83a592f312 Fix whitespace preservation around meta items
This was broken, especially in wrappers.

Changed the wrapping algorithm so that meta items are placed outside
wrappers if possible. On the left-hand side, this is already the case:
we don't open wrappers for meta items. On the right-hand side, this is
accomplished by buffering the meta items and only inserting them when
we encounter either real text (not whitespace) or the end of the wrapper.
If we're interrupted by real text, we insert the meta items with the
unmodified whitespace. If we're interrupted by the end of the wrapper,
we insert the meta items outside of the wrapper with whitespace stripped.

Internally, this is done by stripping the whitespace into the whitespace[0]
of the meta item to its right. Then when we output the meta items, we
either decide to 'restore' the whitespace, or to 'fixup' by also setting
whitespace[3] on the element before the whitespace.

Change-Id: Ibeea2a9906c4aae9fe6d284613edd6ec853ca5e7
2013-04-18 16:06:58 -07:00
jenkins-bot 151c325c0d Merge "Allow node focusing" 2013-04-18 23:03:19 +00:00
Trevor Parscal bf254f44da UI "Views" refactor
Objective:

Make it possible for inspectors to inspect nodes or annotations, rather
than only annotations. Meanwhile, also make it possible for dialogs to
edit an annotation.

Strategy:

Switch from using type patterns to associate inspectors with annotations
to using arrays of classes, similar to how dialogs already work.
Introduce a view registry which provides lookups for relationships
between models and views. This is more centralized and less repetitive
than implement matching functions for both annotations and nodes in both
the dialog and inspector factories.

Changes:

*.php
* Added links to new file

ve.AnnotationAction.js
* Removed unused parameter to filter annotations using a string or regexp

ve.dm.AnnotationSet.js
* Switched from property/value arguments to callbacks

ve.ui.*(Dialog|Inspector).js
* Replaced type patterns with class lists
* Added class to view registry

ve.ui.*Tool.js, ve.ui.Context.js
* Updated model/view relationship lookup

ve.ui.*Factory.js
* Removed overly-specific lookup functions

ve.ui.Inspector.js
* Removed typePattern property
* Updated model/view relationship lookup

ve.ui.ViewRegistry.js
* New class!
* Migrated node and annotation lookup functions from factories

Change-Id: Ic2bbcf072fdd87e5ce8a03fe1ae3e6d8d50e2593
2013-04-18 15:53:50 -07:00
jenkins-bot f2276214cd Merge "ve.ui.SelectWidget: Keep track of mouse down" 2013-04-18 22:43:29 +00:00
jenkins-bot bed8e8a17a Merge "Simplified iframe initialization" 2013-04-18 22:41:40 +00:00
jenkins-bot 267d800415 Merge "Actually pass oldid parameter when serializing" 2013-04-18 22:34:17 +00:00
jenkins-bot 889e62a0ff Merge "Remove html/* attributes in getClonedElement()" 2013-04-18 22:32:24 +00:00
jenkins-bot d28c5548d5 Merge "Make the AnnotationSet constructor take an array of indexes" 2013-04-18 21:50:25 +00:00
jenkins-bot d03aaa102c Merge changes I7b0e3fa4,I559232f3
* changes:
  ve.init.mw.ViewPageTarget: Put the Edit source link in the visible tab area
  ve.init.mw.ViewPageTarget: Switch tabLayout from 'add' to 'replace'
2013-04-18 21:02:23 +00:00
jenkins-bot eac3cb99e0 Merge "Added inline comment explaining not obvious purpose of code" 2013-04-18 20:59:25 +00:00
jenkins-bot 22622c922b Merge "Death and/or destruction" 2013-04-18 20:58:19 +00:00
Trevor Parscal 2419f7638c Death and/or destruction
So. It turns out that the design of SurfaceFragment is a little -
shall we say - wonky.

One of the best things about ve.dm.SurfaceFragment is its magical
ability to retain the intention of its range, even as transactions
are being processed. This ability is granted by each fragment
listening to the surface's change event, and responding by using
translateRange for each transaction that gets processed. Surface
fragments also have these clever methods that allow you to get a
fragment based on another, which makes adjusting the range easy to do
inline without having to manually store multiple fragments or
modifying the original.

This sounded good, and we seemed to all be convinced it was well
designed. But if you add a console.log( 'hello' ); to the first line
of ve.dm.SurfaceFragment.prototype.onTransact, and then start using
the bold tool on various selections of text, you will find that there
may indeed be a flaw. What you will probably realize is that the
number of times that particular line of code is being called is
disturbingly large, and increases each time you do just about anything
in the editor. What's going on? How did we get here? Read on…

It turns out that fragments are immortal. We create them, they listen
to the surface's transact event, we are done with them, but the
surface keeps on emitting events to the now long forgotten about
fragments. They continue to build up over time, never go out of scope,
and bloat the hell out of our program.

The same ended up being true of toolbars - and each time the context
menu fired up a new one the old one was left in limbo, still
responding to events, still taking up memory, but not being visible to
the user.

All of this immortality was causing strange and difficult to track
down problems. This patch fixes this by introducing a destroy method.
This method unbinds events, allowing the object to finally fall out of
scope and die - and more importantly stop receiving notifications of
changes.

This is a hack, but Ed will no doubt get this situation sorted out
properly by making fragments lazy-evaluate their selections by only
storing an identifier of the most recent transaction they were based
on, see bug 47343.

Change-Id: I18bb986001a44732a7871b9d79dc3015eedfb168
2013-04-18 13:56:20 -07:00
Trevor Parscal 3fe30323e5 Allow node focusing
*.php
* Added links to new file

ve.ce.ImageNode.js
* Added focusable node mixin

ve.ce.FocusableNode.js
* New class!
* Adds isFocused and setFocused methods
* When a node is focused or blurred, 'focus' and 'blur' events are emitted
* While a node is focused, it will have the 've-ce-node-focused' class added to it's this.$

ve.ce.Surface.js
* Add detection of node focusing and setting focus and blur on nodes on change

Change-Id: I3f1ad6309571f2bfe568550e2e8f1bd5a0302085
2013-04-18 13:54:37 -07:00
Inez Korczyński d809dc7e37 Added inline comment explaining not obvious purpose of code
Change-Id: Ib9ea1307ebe58c03abd00dcf8b96681d6901a3d4
2013-04-18 13:39:56 -07:00
jenkins-bot d54cf4c131 Merge "Transactions to store metadata merge info when present" 2013-04-18 20:04:51 +00:00
jenkins-bot 1bfc9594b3 Merge "Avoid rendering content of ve.ce.ContentBranchNode multiple times when only one transaction is applied" 2013-04-18 18:58:42 +00:00
Catrope eac44c39f4 Make the AnnotationSet constructor take an array of indexes
Before, it took an array of objects and translated those to indexes
using the store. Literally every caller outside of the test suite got
an array of indexes from the linear model, translated those to objects,
then passed them into the AnnotationSet constructor which translated
them right back to indexes.

The previous behavior was kind of ridiculous on its face, but the
reason we found it is because Inez was investigating the performance
degradation when bolding a line and found that half of it was due
to the hundreds of ve.getHash() calls caused by this behavior.

Change-Id: I38df8ae9f6392849dacf477ea2f804283c964417
2013-04-18 10:56:03 -07:00
Catrope 533e43ea80 Remove html/* attributes in getClonedElement()
Subbu said that cloning of attributes like data-parsoid or typeof would
cause problems for Parsoid.

Also remove the attributes object if it becomes empty, and do the same
for the internal object.

Bug: 47297
Change-Id: I428becf95c70d0ed8af5b0c408e3966dc47fd8c3
2013-04-18 09:27:28 -07:00
jenkins-bot 16d164ed6d Merge "Delete spurious normalizedHtml" 2013-04-18 15:32:53 +00:00
jenkins-bot 289116c493 Merge "When we say originalHtml, we'd better mean it" 2013-04-18 15:27:25 +00:00
Catrope cdba5f2800 When we say originalHtml, we'd better mean it
Gabriel noticed whitespace diffs in the problem reports. These were
caused by browsers' .innerHTML being broken on <pre>s. We compensate
for this in the converter, but not when generating originalHtml.

However, a variable called originalHtml really shouldn't be generated,
it should just literally be the original, unprocessed HTML. This
does mean it includes the doctype, <html> and <head> which aren't
included in editedHtml (that one's just the contents of the <body>), but
that's much easier to deal with on Parsoid's end than random newline
diffs all over the place.

Change-Id: I8e66cb79887f49f84114ab6b4d0e0d24aea744b6
2013-04-18 08:09:50 -07:00
jenkins-bot 17a93e96ec Merge "Serialize alienated context-sensitive nodes correctly" 2013-04-18 11:10:37 +00:00
jenkins-bot 52a666956c Merge "Fix a weird whitespace stripping bug" 2013-04-18 10:56:17 +00:00
Catrope 42c1aa10cd Serialize alienated context-sensitive nodes correctly
Context-sensitive nodes are HTML elements like <caption> that can only
appear in certain contexts (<table> in this case). This means that
serializing them by throwing them in a <div> and calling .innerHTML
fails, because the browser knows a <caption> can't be in a <div> and
unwraps it. jQuery's .html() function is clever though and knows to wrap
<caption> in a <table> (and has similar rules for other elements).
So use jQuery's .html() rather than manual .innerHTML stuff.

Change-Id: Id7d3eff968b3a2ba345680772f7cc32e3dcdb529
2013-04-17 18:26:54 -07:00
Catrope 50e14d42d4 Delete spurious normalizedHtml
Was equal to the HTML before conversion, so not needed

Change-Id: I48e3b3d48334562f605bccfddc5f2aa7cf883087
2013-04-17 17:54:35 -07:00
Catrope 2f1ee49213 Fix a weird whitespace stripping bug
In HTML like <td>Foo <b>Bar</b></td>, the space would be stripped and
registered as trailing whitespace in the <td>, so it wouldn't be visible
in the editor and would be inserted after the </b> on the way out.

Thanks to Subbu for reporting this. This case was kind of ridiculous and
we're lucky the JRuby article contained it. To trigger the bug, you had
to have:
* a table cell
* containing unwrapped content
* consisting of
** some text
** whitespace
** open annotation (bold in my example, link in Subbu's case)
** text
** close annotation
** and nothing else

Change-Id: I2b83f02764b311a32a50956d4c8930a9394e91a4
2013-04-17 17:08:47 -07:00
Catrope 6c1e4cfdd2 Partly fix the "Report problem" button
This was broken ever since the introduction of IndexValueStore, because
the call to getDataFromDom() wasn't updated, so it crashed with a "doc
is undefined" error. Fixing part of this by passing in a new IVStore.

The data that is transmitted over the wire still has indices with no way
to find out what the corresponding annotations are. It needs to be fully
expanded but there's no way to do this in DM quite yet.

Bug: 47319
Change-Id: I761523d22e51ac560e37ae991d01a6b84224ca40
2013-04-17 23:04:56 +00:00
Inez Korczyński e786c5c2f0 Avoid rendering content of ve.ce.ContentBranchNode multiple times when only one transaction is applied
Change-Id: I940bb96b670afb7ab3de524919b56912d027a2ef
2013-04-17 12:16:04 -07:00
Catrope eab968d7f0 ve.init.mw.ViewPageTarget: Put the Edit source link in the visible tab area
Instead of in the collapsed section.

Change-Id: I7b0e3fa4e35ce6135e3a47360da51fd8e0231ca1
2013-04-17 18:15:43 +00:00
Catrope 116321afe5 Make the "Report problem" POST URL configurable
Defaults to "$wgVisualEditorParsoidURL/_bugs/"

Change-Id: I4847d54b0effe433d5d179d91fdf361c249515ad
2013-04-17 17:05:58 +00:00
Trevor Parscal 8f6b042eaf ve.ui.SelectWidget: Keep track of mouse down
This helps with some differences between browsers, specifically Firefox,
where e.which would be "1" even if the mouse button was not pressed.

Change-Id: Ia88449c2bc84073d903dc702bb586127618d86f2
2013-04-17 11:40:16 +00:00
Catrope 4511a9e6be Actually pass oldid parameter when serializing
Apparently Parsoid has always required this, and we've never sent it,
yet somehow the code in production works. This may well be the cause
of some of the selser issues we saw after the deployment attempt in
January.

Made oldid a required parameter in the API module, and default it to 0.
When we get 0, we translate that to the empty string for Parsoid's
benefit. We also need to explicitly get wgCurRevisionId in
ViewPageTarget, and that's also 0 on new pages.

Change-Id: I3a55025246014cd74e15d6d5b6c4ede7b823e5df
2013-04-17 11:31:20 +00:00
Catrope 04516bb02e Whitespace preservation was broken after the first run
The first run of getDomFromData() would preserve whitespace just fine,
but it blanked out the .veInternal.whitespace[1] element in certain
cases, contaminating the linear model and making the whitespace data
inconsistent. Subsequent runs of getDomFromData() would then refuse to
serialize that whitespace because the information about it was
inconsistent.

In getDomFromData(), we sometimes unset .veInternal.whitespace[1] (i.e.
set it to undefined) to prevent double processing. Because we're
potentially going to modify .veInternal, don't assign it by reference,
but copy the object.

Added tests asserting that the linear model is unchanged after calling
getDomFromData(), because that function should never modify
linear model data. This test failed in 4 cases (all whitespace-related)
before I added the copyObject() call.

Bug: 43543
Change-Id: Ic4c93510518163894201a693ab50331413715967
2013-04-17 11:28:05 +00:00
Catrope 9a98d8bce4 ve.init.mw.ViewPageTarget: Switch tabLayout from 'add' to 'replace'
This makes the Edit tab point to the VisualEditor, and adds a
"Edit source" link to the p-cactions menu.

Bug: 46872
Change-Id: I559232f3d8e42df0d45311b65df8c30425b1a368
2013-04-17 10:25:36 +00:00
jenkins-bot 1b072d2e0c Merge "Inside ve.ce.Document.getRelativeOffset fallback to 'character' mode if 'word' mode returns the same offset as was passed originally" 2013-04-16 22:54:27 +00:00
Ed Sanders ff7b8a2591 Transactions to store metadata merge info when present
ve.dm.Transaction
* Replace operations are now built directly from the
  linear model and automatically determine what metadata
  replace information they need to include:
** retainMetadata
** replaceMetadata
** insertMetadata

ve.dm.Document
* Metadata array created empty and padded out after data parsing
  as we are no longer using Document.spliceData to build it (a new
  test checks for correct metadata length)
* spliceData replaced with getMetadataReplace, which instead returns
  transactional steps of spliceData (retain, replace, insert)

ve.dm.MetaLinearData
* Add function for merging metadata items together. Only used
  once in the code (Document.getMetadataReplace) but useful
  for generating test data.

ve.dm.MetaList
* Replace operations with metadata need to calculate new offset
  and indices directly, but can't be applied immediately lest they
  put a metaItem out of place and affect findItem.

ve.dm.MetaItem
* Add methods to support queued moves as required by MetaList

Test files
* Updated to match new pushReplace API
* Remove any instances of Document.spliceData
* Extra check on sparse metadata array length
* Rewrite spliceData tests as getMetadataReplace tests
* Count expected cases in Transaction(Processor) tests

Bug: 46954
Change-Id: I4edad1c2dd37c723bff2792bab7d694ef17a86dc
2013-04-16 22:26:56 +01:00
Inez Korczyński 9d5b9525d6 Inside ve.ce.Document.getRelativeOffset fallback to 'character' mode if 'word' mode returns the same offset as was passed originally
Change-Id: Ia3de5d5c1f37f17161fb1c8c9a284c868bb4a5fb
2013-04-16 13:12:25 -07:00
Trevor Parscal 17c9aadf8f Simplified iframe initialization
Rather than attach a function to the window and trigger it from a script
tag in the document body, it's much simpler to just use the references
we already have to execute the code immediately and directly.

This also fixes issues in Firefox where reaching in and adding functions
to the window wasn't allowed.

Change-Id: If7a84edf6ae4549b19ce36a3477311c46dbadea7
2013-04-16 12:59:11 -07:00
jenkins-bot 11f4bbbb9d Merge "There was no check if anchorNode of selection range is inside an element with CSS class ve-ce-slug." 2013-04-16 18:35:36 +00:00
jenkins-bot 5000cbaa80 Merge "Make returning the same offset the least preferred option in ve.ce.Document.getRelativeOffset" 2013-04-16 18:26:54 +00:00
Catrope 383a669f7c Fix annotation breakage
Inez reported that unitalicizing from the toolbar was broken, because
the toolbar was somehow generating annotations that had .attributes={}
as opposed to .attributes=undefined. Turned out the cause was in the
default value for element in the ve.dm.Model constructor.

Change-Id: I64ea9ef56cd15d1131c1aa23484d7420c95a8225
2013-04-15 17:04:50 -07:00
Inez Korczyński d4e41e2908 Make returning the same offset the least preferred option in ve.ce.Document.getRelativeOffset
Change-Id: If21cdea220b58aec92b8735e92f594d8c16c8f6f
2013-04-15 14:59:04 -07:00
Inez Korczyński 097fd3c1a4 There was no check if anchorNode of selection range is inside an element with CSS class ve-ce-slug.
Adding that check let me simplify logic around a little bit as well.

Bug: 47258

Change-Id: I51bf5e9caecf6a8b4e0f75118a93cfe69a5a6542
2013-04-15 21:40:13 +00:00
jenkins-bot 887465b159 Merge "Filter our zero-coverage updateState nodes" 2013-04-14 02:53:01 +00:00
jenkins-bot 5764026d00 Merge "TransactionProcessor: Fix offset bug" 2013-04-14 02:51:12 +00:00
Trevor Parscal 504a1bafd0 Filter our zero-coverage updateState nodes
Added filter for nodes being passed to update state event - this
ensures that nodes are not being included with zero-length coverage, a
side effect of how selectNodes handles the virtual boundaries of text
nodes.

Change-Id: I6362114b57469b1108da11f94dc345a2bcdfc7cd
2013-04-14 02:50:01 +00:00