Commit graph

600 commits

Author SHA1 Message Date
Roan Kattouw 393925a868 Build the internalList linmod even if it's empty
Otherwise fun exceptions occur when you have a <references /> tag
with no <ref>s, for instance.

Also disregard the internalList in the data->DOM conversion, to prevent
a nasty interaction where the whitespace information on the last element
is considered invalid because it doesn't match the internalList's.

Plus test updates from hell because this touches ve.dm.example.data

Change-Id: I62881d9fc27fa081123856d1b35a6021af469271
2013-06-17 13:23:20 +01:00
Ed Sanders dcbea2328c Code style fix: @return -> @returns
Change-Id: I26daca6313bf09055af8f980ba0065782257fd54
2013-06-17 11:50:24 +01:00
Ed Sanders 642a84483e Fix logical conflicts from the transclusion merge.
Change-Id: Ic9d708cdba74c908d14839def5050c8825134c56
2013-06-17 10:36:47 +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
jenkins-bot 86406d5e48 Merge "Outline controls" 2013-06-14 21:47:36 +00:00
Trevor Parscal ac26f5fc69 Outline controls
Objectives:

* Allow reordering items in outline widgets using an outline control
  widget
* Use an outline control widget to reorder transclusion parts

Changes:

ve.ui.SelectWidget.js
* Emit add and remove events

ve.ui.OutlineItemWidget.js
* Add movable config options
* Add isMovable method

ve.ui.OutlineControlsWidget.js
* New class
* Displays move up/down buttons which are synchronized with an outline
  widget
* Doesn't actually move items (since an outline widget is probably
  data-driven) just emits events

ve.ui.Widget.css
* Add disabled style for icon button widgets
* Add styles for outline controls widget

ve.ui.Icons*.css
* Add missing icon styles

ve.ui.Dialog.css
* Add styles for outline and controls in editable paged dialogs

ve.ui.GroupElement.js
* Fix bug where items are insertions are in the wrong place when "moving"
  them

ve.ui.PagedDialog.js
* Add editable config option which shows outline controls under the
  outline
* Pass through movable config option when creating pages

ve.ui.MWTranclusionDialog.js
* Configure paged dialog outline as editable
* Add initialize method to connect outline controls widget events
* Make addPart method automatically add parameters when templates are
  added
* Add handler for outline controls move event which re-orders parts
* Make parts movable (params are automatically ordered, so they aren't
  movable)

ve.dm.MWTransclusionModel.js
* Add addPart method and use it within the addContent and addTemplate
  methods
* Fix documentation lies
* Add getPartFromId method

*.php
* Add links to new files and messages

Change-Id: I919d4c3e9b85d07a97a99c0b2e8739a859bdf2b1
2013-06-14 11:56:30 -07:00
Roan Kattouw 0c16066eb3 Kill attribute order preservation
Per the bug report, it's useless because Firefox does not preserve order
in the .attributes array (but sorts it alphabetically instead), and so we
actually get the same exact behavior regardless of whether we use ordering
cleverness or just a straight-up plain object: order is preserved in Chrome,
and alphabetized in Firefox.

Bug: 48980
Change-Id: I1463d06db4900083dd4c565292bbabef09194b43
2013-06-13 23:17:08 -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
Ed Sanders da51566d56 Store empty annotations as alienMeta nodes
Not a perfect solution, but better than deleting them completely.

Bug: 48605
Change-Id: I0f3a194f629b054f193a61af105733a555775d79
2013-06-12 19:46:41 +01:00
Ed Sanders 59bfc081df Store alien meta items' dom nodes only
We don't need to decompose and rebuild alien meta items
as they are uneditable, so just store the dom node and return that
in toDomElements.

Update test cases and several tests now need to use
assert.deepEqualWithDomElements.

Change-Id: I4d2eed267dac7855cb929a17d7aef566eaf0e287
2013-06-12 16:37:37 +01:00
Ed Sanders e67b4030f3 Remove Parsoid hack and fix new references.
Now that I797b2bd87 is in we can remove the data-parsoid hack
for new references. Also fix the converter to always insert content
for keyless references.

Change-Id: Ia42907feb8f64637189eba15139177c7eb5e8899
2013-06-10 23:01:17 +01: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
Ed Sanders 1a86cb9c61 Preserve location of reference body within key
Previously we populated the reference body into all <ref> tags
with the same key. Now we store an internal attribute marking
which element originally had the data.

If that tag is deleted the body is moved to the first <ref> tag
with that name.

Change-Id: If9f12bfb699e6ce85bb8f7d2ea9e6df528610a3d
2013-06-10 02:54:26 +00: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
jenkins-bot 8a614ae395 Merge "Use blacklist instead of whitelist for storeHtmlAttributes of MWBlockImageNode." 2013-06-07 23:09:17 +00:00
Inez Korczyński b6b4855434 Use blacklist instead of whitelist for storeHtmlAttributes of MWBlockImageNode.
Change-Id: Ief029005b3326a94a8432a3bd6de50669bd3a3b2
2013-06-07 16:04:45 -07:00
Inez Korczyński c67c1f714d For performance reasons use classes collection instead of jQuery.hasClass
Change-Id: Id64a58d71c49ad74c55e3a24b86955ece668ebba
2013-06-07 00:09:15 +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
jenkins-bot 1bab467c61 Merge "Rename character to (grapheme) cluster when dealing with unicode." 2013-06-06 17:49:12 +00:00
jenkins-bot 8c20fb278f Merge "'typeof' for templates changed in Parsoid, it is 'Transclusion' now and used to be 'Object/Template'" 2013-06-05 23:06:15 +00:00
Inez Korczyński 2f58dd3d40 'typeof' for templates changed in Parsoid, it is 'Transclusion' now and used to be 'Object/Template'
Change-Id: Ia5b826bc1a2a648a8e618642697484000b68bfc2
2013-06-05 15:31:51 -07:00
jenkins-bot 0730e4af6e Merge "Update reference lists and inline numberings automatically." 2013-06-05 22:13:31 +00: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
Inez Korczyński 5079bbae9a ve.dm.Converter: Fix too-much-ascending bug in Converter.
Change-Id: I748003d316614717c8eaf58dcf5735246951532a
2013-06-05 14:04:42 -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
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
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
Trevor Parscal b0f464ef0e Add support for editing multi-template nodes
Objectives:

* Refactor template dialog to support loading template data for, and
  editing multiple templates and interleaved content in a template node
* Update template node model to generate multi-template wikitext

Changes:

ve.dm.MWTemplateNode.js
* Rewrite getWikitext method to work with multi-template formats

ve.dm.MWTemplateDialog.js
* Retain information about the node and template calls
* Break AJAX handler into its own method
* Attach event handlers to inputs directly so template values are
  edited directly on the fly
* Refactor page building to support multiple templates
* Add multi-template support for template data API call
* Add support for editing plain text content

Change-Id: I92ff8a9e186701a3f8da88def92a5b7dcb607897
2013-05-29 01:10:57 +01:00
Trevor Parscal 4c5c18c241 Compare objects/arrays fix
Objectives:

* Fix compareObjects so it doesn't break when given arrays
* Remove compareArrays
* Rename compareObjects to compare and update callers of both methods

Changes:

ve.js
* Loosen check for whether to recurse so both arrays and objects qualify
* Remove compareArrays
* Rename compareObjects to compare

ve.dm.MWTemplateNode.js, ve.dm.AnnotationSet.js, ve.dm.Document.js,
ve.dm.Transaction.js
* Update uses of compare(Arrays|Objects) to use compare

Change-Id: I7d4f7ceb28c0389f0157b7598e291f21393b5b85
2013-05-29 00:39:04 +01:00
Inez Korczyński 0b46b44809 Add class mw-figcaption to figcaption tag inside mwimage
This is currently required by Parsoid in order to serialize
(HTMLDOM -> wikitext) correctly.

Change-Id: I827f63420d05c62d689902c9b348d234f20a5d19
2013-05-28 23:21:59 +00:00
jenkins-bot 57c75a5e41 Merge "Adjust coverter getDomSubtreeFromData method call inside ve.dm.MWBlockImageNode to pass correct arguments (there was an API change)." 2013-05-28 23:03:57 +00:00
Inez Korczyński 476d10b1c3 Adjust coverter getDomSubtreeFromData method call inside ve.dm.MWBlockImageNode to pass correct arguments (there was an API change).
Change-Id: I1918aee714363babf5182c699fd96ef9fd4fce55
2013-05-28 16:01:16 -07:00
Catrope 1365c4a5d5 Fix internal node weirdness
* In getDataElementOrSlice(), we were slicing one too far
* When encountering a closing for an internal node, don't traverse
  up. Doing this caused weird bugs, like inserting text where it didn't
  belong in some cases an exceptions in others, but these issues were
  parly masked by the off-by-one error in the data slice.

Change-Id: Ieda9afa95b7c1953d09e391774350a9b4148c2fe
2013-05-28 15:30:15 -07:00
Ed Sanders c1136ca8e2 Add tests for ve.dm.InternalLists
Also fix clone method when no document supplied.

Change-Id: I7b24e8622049c6293fa0ef813696d5d91a901e75
2013-05-28 22:08:52 +01:00
jenkins-bot 5add8cc4c0 Merge "Cleanup internalList method names and data stores" 2013-05-28 14:39:14 +00:00
Ed Sanders aa6eca10db Cleanup internalList method names and data stores
Rename some methods and erase the HTML data after conversion.

Change-Id: Ic7317db2c7693591fda4bea459631981a69003f3
2013-05-28 15:11:17 +01:00
Trevor Parscal 8511f8ab3e Treat acronyms like words in camel case names
No matter what the W3C says, getDomFromHtmlString is more legible than
getDOMFromHTMLString.

Change-Id: Ic843b6671871024cce8acd82b6be435599ed168b
2013-05-28 12:51:41 +00: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 cba55b9330 Don't do evil shadowing of mw
Having local variable called mw that shadows the global variable mw
is evil. Rename it to mwAttr.

Change-Id: I87bd3698c73608076424c10fdb0559dfdc3e3045
2013-05-26 14:34:47 +02:00
jenkins-bot a0b6de8e5e Merge "Make reference editing work" 2013-05-26 12:09:19 +00:00
Catrope c36df77e3f Make reference editing work
The only reason it doesn't save correctly right now is because Parsoid
doesn't serialize reference edits correctly.

Change-Id: Ia0f272c07cc28ee829372eb848f23aec99eb92f0
2013-05-25 18:06:57 +02:00
Catrope 65c3540da7 Fix getAnnotationIndexesFromOffset() to always return an array
It used to, but a recent change broke it

Change-Id: I03ecfd5a515855a286136b57217779fd1c5912a5
2013-05-25 13:41:32 +02:00
jenkins-bot c6e06f3917 Merge "Merging and remapping of IVStores and InternalLists" 2013-05-25 11:37:12 +00:00
jenkins-bot e25aa4f199 Merge "Add getDocumentSlice" 2013-05-25 11:36:37 +00:00
Catrope 238d68eb74 Merging and remapping of IVStores and InternalLists
Add merge() methods to IndexValueStore and InternalList, which merge
another store/list in to the current one and return a mapping
translating old indexes to new ones.

Also add functions that, given such a mapping, traverse a linear
model data array and remap store/list indexes using simple logic for
annotations and node type-specific functions for node attributes.

Change-Id: I1e90755ced1a87c190947c037cf151c4d17cf8b7
2013-05-25 11:33:35 +00:00
Catrope 6562b32aa7 Add getDocumentSlice
A document slice is a document built from a data slice of an existing
document. It's completely separate from the original document and has
its own store and internalList. The new document's data also contains
the entirety of the original document's internal list. It's possible
to create a document slice of data located inside the internal list,
in which case the resulting document will contain that data twice (one
mutable copy at the top level, and one immutable copy in the internal
list).

ve.dm.Document.js:
* Optionally take an internalList in the constructor. This allows us to
  create a document with a clone of an existing internalList rather than
  an empty one.
* Add edgeMetadata flag to getFullData()

ve.dm.IndexValueStore.js, ve.dm.InternalList.js:
* Make these classes cloneable

Change-Id: I93e06f764ace16aee9df941b07f8c2bff1a28e2b
2013-05-25 11:33:14 +00: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
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 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 f25572a992 Merge "Fix for check if data is balanced" 2013-05-22 22:05:43 +00:00
Inez Korczyński 02d522500c Fix for check if data is balanced
Previous check wouldn't make sense, cause the last offset in the data
could be that one that makes data balanced (and j is increased always
after iteration).


Change-Id: Ie9498d0ac9e3417d09b8b3043bf3281e7dfbf9db
2013-05-22 14:19:42 -07:00
Inez Korczyński bf6df1ff37 Get rid of try..catch by using ve.dm.nodeFactory.lookup.
Change-Id: I017ed60f7d7ce8af34c94fe237cc4101192518f1
2013-05-22 12:51:51 -07:00
Catrope 7aefae885a Add a transaction builder for replacing the contents of a node
Change-Id: I69d362c4694104313dd2634434eddfbaf9435b22
2013-05-20 13:09:54 -07: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 531c049679 Support for nodes that handles their own children in ve.dm.Converter.prototype.getDomSubtreeFromData
Change-Id: I784dec71d3f0b23001075234e324a8e06a6cfc6b
2013-05-16 16:01:46 -07:00
Trevor Parscal e64d900fc3 Fix image block node error
When loading an image block node in the demo, there are no classes on the figure, which caused the code to crash because it was assuming that jQuery's attr method would always return a string.

Change-Id: Ib13e7bfa3fb2bd76ac71dfef085bed209d880b4a
2013-05-15 16:24:10 -07:00
Catrope 54cd04c391 Implement ve.dm.MWTemplateNode.getWikitext()
Escapes }} and | by wrapping them in <nowiki> tags, and steps around
<nowiki> tags so as to not double-wrap things.

Change-Id: Ia50906524c1fcf55c9f390a114856bc7f20b2d3a
2013-05-15 15:16:34 -07:00
Inez Korczyński abe81d42d7 Added method getDataFromDomRecursionClean to ve.dm.Converter - used by nodes that handle their own children.
Change-Id: I604cf201515152824ec159b8c86f2010afcd3369
2013-05-15 10:02:08 -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
Trevor Parscal cce80e63c0 Fix for crashing on save
converter.documentData contains the full data with metadata interleaved,
but it was being sliced using offsets relevant to the element data.

Change-Id: Iddbef23212da818a2a399b4abdc223aad130eb4e
See: I6daff5c5969e5fdc871f8f346cf790b4302ae080
2013-05-14 21:34:06 +00: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
jenkins-bot 3fc753e39b Merge "Fix categories with multiple ../ in their hrefPrefix" 2013-05-13 19:00:02 +00:00
Catrope f586d3ea8f Fix categories with multiple ../ in their hrefPrefix
Was already fixed for links.

Bug: 48408
Change-Id: I84d2b23a05585890b2d5023c7c7f38a43889fd7f
2013-05-13 11:10:02 -07:00
Ed Sanders 2c782fba92 Optimise code for first/last child detection in fixupInsertion
The code to record the first/last child stacks was written before
I decided on using a recursive call going only one step when such
a stack was encountered.

As we only ever test the length of the stack most of the code around
calculating the stack can be thrown away, and all we need is a simple
test to see if we are the first/last child of the immediate parent.

Change-Id: Iffb03c649e166c9f89061a4d944fa07633f16aba
2013-05-13 12:37:01 +01:00
Catrope 9d99cdbb67 Fix breaking getLength() call
Change-Id: Iaa6cb22bf93a677aff077ce38ee11e606430cee5
2013-05-10 17:02:07 -07:00
jenkins-bot db644e915f Merge "Fieldsets and default sort keys" 2013-05-10 23:58:17 +00:00
Trevor Parscal 8409d16f0f Fieldsets and default sort keys
Objective:
* Add default sort key field to meta dialog
* Replace PagePanelLayout with a generic panel containing one or more FieldsetLayout elements

Changes:

*.php
* Added/removed file links

ve.dm.MWDefaultSortMetaItem.js
* Added getContent method

ve.dm.MetaItem.js
* Added replaceWith method

ve.dm.MetaList.js
* Allow insertion at the end by omitting offset and index

ve.dm.MWMetaDialog.js
* Added default sort key field
* Put category and default sort fields inside fieldsets
* Added loading/saving default sort key

ve.ui.PagedLayout.js
* Changed class used for pages to generic panel layout

ve.ui.PagePanelLayout
* Moved title/icon stuff to field set

ve.ui.FieldsetLayout.js
* New class, adds fieldset with legend

ve.ui.StackPanelLayout.js
* Moved up to the layouts directory

ve.ui.Dialog.css
* Moved style for paged panel from layout stylesheet

ve.ui.Layout.css
* Added styles for fieldsets

ve.ui.Widget.css
* Adjusted margins of input label widgets

ve.ui.MWCategoryWidget.js, ve.ui.MWCategoryPopupWidget.js
* Added setDefaultSortKey method

Change-Id: I979f5e3f08a688790c9f54086206ed1999af13ea
2013-05-10 16:46:08 -07:00
jenkins-bot ff15fbf21b Merge "Whitespace between unwrapped inline nodes assigned to paragraph" 2013-05-10 17:13:15 +00:00
Ed Sanders 328dd8e21f Whitespace between unwrapped inline nodes assigned to paragraph
In stopWrapping we assign any left over whitespace to the paragraph
in position 3, however we weren't clearing this whitespace buffer
if an inline content node followed it.

Change-Id: I8b3ee3915044abd6bafda386430bf7f992ca4aa8
2013-05-10 16:40:11 +01:00
jenkins-bot f966e9c41d Merge "Clone template dom elements being sent to converter" 2013-05-10 15:37:24 +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
Ed Sanders 3495c6f747 Clone template dom elements being sent to converter
The dom elements in the IV store are used for rendering, so if they
are sent by reference to the converter they get re-attached, causing
all templates to disappear from the page whenever you press 'review
and save'.

Fix is to run it through ve.copyArray, which clones all the nodes.

Change-Id: I1b03351a28ac82e0fdb7e94e761cf65d6548e501
2013-05-09 13:42:44 +01: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
Catrope 05828cc3f1 Preserve HTML attributes recursively
For nodes that handle their own children (as well as leaf nodes and
meta items), store the first child's attributes in html/0-0/*, the
second child's attributes in html/0-1/*, the second element's third
child's fourth child's attributes in html/1-2-3/* , etc.

This obsoletes the ad-hoc code that basically did the same thing in
MWInlineImageNode.

Change-Id: If5abd2d5d9c361b359617ff4b0f3d6ba4c9b0142
2013-05-08 11:10:07 -07:00
Catrope 85d67ce44f Do proper HTML preservation in ve.dm.MWReferenceListNode
Store the HTML as a domElements array like everywhere else, rather than
as a string. Also disable HTML attribute preservation because there's
no point doing that when we're already preserving all of the HTML.

Also fixed a misnamed attribute (<li li="foo"> --> <li id="foo">) in
the test case.

Change-Id: I36bf8bade8118e07a75eb6f3a2427a00ef4915d7
2013-05-07 21:41:29 -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 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 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
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
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
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 ff168661b0 Merge "When annotating, skip any branch nodes that are content" 2013-05-01 18:06:34 +00:00