The Parsoid team has changed their spec to always use multi-part
format even for one-part transclusions. This commit changes VE's
output format to always be multi-part, but still accepts single-part
format on the way in.
Change-Id: I6b3156b0b599ad042bb52d7f53dcdeb1c4a0954a
CODING.md
* Document the procedure for adding a new javascript class
ve.dm.MWExternalLinkAnnotation.js
ve.dm.MWInternalLinkAnnotation.js
ve.dm.ElementLinearData.js
ve.dm.LinearData.js
* Add whitespace line before preformatted code to fix a
rendering bug
Change-Id: I54443ea3d4799328655d279f379d4ddc176c50a0
ce.MWExtensionNode
* Build up the wikitext for round-tripping using jQuery, and pass
through the attributes from data-mw
dm.MWExtensionNode
* Use a static getExtensionName to correctly get the extension
name from the dataElement (as the getMatchRdfaTypes hack won't
work for MWAlienExtensionNode's)
dm.MWAlienExtensionNode
* Implement new static getExtensionName function
Bug: 53543
Change-Id: Id4e83c14ec68c3b3970d05317477f19aaf31abe4
This avoids problems when unnamed references were copy-pasted.
Knowing that key is always non-null simplifies a lot of logic
elsewhere.
Bug: 53365
Change-Id: I3a23123ae732d9583814d38dd880a0cdf691fd5d
Return an array of languages instead of a single language. Languages
containing hyphens return themselves along with the root code e.g.
'en-GB' => ['en-GB', 'en']
Change-Id: I840b689d0021d865f93d16d075473a2ed0a9f0d8
toDataElement part fixed in I6d496f7. This fixes the
toDomElement part so we don't trigger a round trip warning.
Bug: 51963
Change-Id: I27a7579890d669a8b980710db1bafe066b744236
We were assuming images were wrapped in <a> tags. Images with
link='' are only <span> wrapped.
Bug: 51963
Change-Id: I6d496f719cfbbc7556c55f0a660cb192040f29de
Create getter for extensionsName which is overriden by
MWAlienExtensionNode.
Also removed angle brackets around Alien title as the inspector
already has an angle bracket icon, and a '<' close button.
Change-Id: Ice8c5d73ed621f8e585b5f372788666f8c5aeb50
VisualEditor.i18n.php, VisualEditor.php
* Button title
* New experimental files
ve.*.MWAlienExtensionNode.js
* Very basic extension of ve.*.MWExtensionNode
ve.ui.MWAlienExtensionInspector.js
* Default to inline-block for wrapper. Should probably
get rid of styled wrappers for GeneratedContent eventually.
ve.ui.MWAlienExtensionInspector.js
* Basic extension of MWExtensionInspector. Override title to
use tag name e.g. '<easytimeline>'. Could be changed in future
to 'Extension: easytimeline' or similar.
*.png, *.svg, *Icons*.css, ve.ui.MWAlienExtensionButtonTool.js
* Angle bracket icon for button (open to suggestions)
ve.ui.MWInspector.css
* Make extension inspector text input tall by default.
Change-Id: I07f0686839192cad3cd8dfd3233ae907fe5cdf6a
Mostly as a demonstration of how easy this is with MWExtensionNode.
The icon was chosen with the following criteria:
1. Recognisable (the ankh is quite common in popular culture, right?)
2. Doesn't look idiotic to academics (I've consulted an Egyptology
PhD and they can confirm it's not the glyph for penis)
3. Renders well at <16x16
That said it does look a little like a stick man...
Bug: 43118
Change-Id: I9f9e8af501401866bfeecf0eec3690a705fbd4db
MWMath and other simple extensions all behave in a similar way, e.g.
<tagname>Foreign syntax</tagname>.
This creates a base class that should make supporting such extensions,
and editing their contents in a plain text box, very simple.
Change-Id: Icc0acb33fe32704f71dacb552d9dfa3142eaef2b
Not having a description yet is fine, but they should at least
be indexed as blocks so that they are searchable and listed
in the jsduck generated pages. jsduck defaults to @method + name
of prototype property. And it even guesses parameters sometimes.
Search: \n\n([a-zA-Z\.]+\.prototype\.[a-zA-Z]+)
Where: modules/ve,modules/ve-mw
Where-Not: modules/ve/test
Replace: \n\n/** */\n$1
Added @return in a few places where it was easy to add.
Change-Id: I830c94cc7dbc261bd7a077391f930cbfff165f9d
VisualEditor.php
* Add CSS file
ve.ce.MWMathNode.js
* Wrap the image in a span, so GenerateContentNode doesn't
try to nest an image inside an image
* Remove unnecessary attribute setting
* Only pass unwrapped image to deferred.resolve
* Retrigger MathJax rendering
ve.ce.Node.css
* Use inline-block for image wrapper
ve.dm.MWMathNode.js
* Mixin GeneratedContentNode and implement getHash
* Copy over functionality of MWTransclusionNode:
+ Just store data-mw for attributes
+ Store orignal(DomElement|MW|Index) for selser
ve.init.mw.ViewPageTarget.js
* Add mwMath to the toolbar
ve.ui.MWMathInspector.js
* Remove static.InputWidget, not required in this architecture
* Use multiline TextInputWidget
* Only update mw attribute
* Allow creation of new math nodes
ve.ui.MWInspector.css
* Set height of TextInputWidget
Change-Id: I520f8ccc9f89a2ce70aa1d9e02ed0c6cacbecc2f
It's totally unnecessary, and actually caused a bug where new references
got about="undefined", which caused Parsoid to about-group adjacent
new references together.
Bug: 52228
Change-Id: Id40d53c72a35412d612ae9441ae3d561622c1bec
When we encounter a ref tag inside the mw-data of a references
tag, we pass it off to the converter and store it as nested data.
In toDomElements we convert any nested children and write them
back to mw-data if changed.
As refs in references are invisible we exclude them when generating
the references list in ve.ce.MWReferenceListNode.
Bug: 51741
Change-Id: I31d06616849a00449df0fc77f3b33e46207cdc7f
These have been pointing to the same method for a while now,
we can safely remove these obsolete aliases and just use it
as generic copy.
* Each file touched by my editor had its new line at EOF fixed
where absent
* Don't copy an otherwise unused empty object
(ve.dm.Converter)
* Use common ve#copy syntax instead to create a link
(ve.dm.Document, ve.dm.example)
* Remove redundant conditionals for isArray/copyArray/copyObject
(ve.dm.example)
Change-Id: If560e658dc1fb59bf01f702c97e3e82a50a8a255
Whenever there is more than 2 spaces (except the extra space
on a continued line of an @ tag, or the extra space on a
continued line of a list item) it causes a <pre> context.
Removed both spurious spaces that caused a <pre> and ones that
didn't but looked like it could.
When making an ordered or unordered list, the first item needs
to be on a new line and in block context (e.g. an empty line
before it). Otherwise it is rendered inline as 1. Foo 2. Bar
(such as in #rebuildNodes where both the ordered and unordered
lists were broken).
Change-Id: Id0f154854afbdc8e5a8387da92e6b2cdf0875f69
To achieve this we need to evaluate the DOM contents of
transclusion nodes to see if it consists solely of meta items
and whitespace.
To check for meta items we do a model registry match, but with an
additional parameter to exclude mwTransclusion types as a possible
result (as the first item may be a meta tag, but with a mw:Transclusion
typeof attribute).
Bug: 51322
Change-Id: I89a220350fb7e10e15f3682d21438539196a5846
* changes:
Add a node class for mw:Nowiki
Move getHashObject() from dm.Node up into dm.Model
Allow annotations to render nothing
Pass child DOM elements to annotations' toDomElements()
Process annotations bottom-up rather than top-down in data->DOM
These represent <nowiki> tags. If the user doesn't edit the text inside
the nowiki, we round-trip the <span typeof="mw:Nowiki"> wrapper cleanly,
but if they do edit it, we unwrap it. This then triggers re-escaping
in Parsoid, and prevents cases where the user edits the text to no
longer need escaping but Parsoid still wraps it in <nowiki> because
of the <span typeof="mw:Nowiki"> wrapper.
In order to detect whether the contents have changed, the nowiki
annotation stores a copy of its contents. To avoid infinite recursion,
we have to exclude this attribute for hash generation.
Bug: 47678
Change-Id: I2edc46b6d87d2f91e952efcb09c0edae5166958f
Problem:
Adding or moving templates or content resulted in the incorrect item
being selected.
Diagnosis:
Although recently we solved a few issues by making addPart async, it
caused some other issues where callers of addPart were assuming
otherwise
Solution:
Return a promise from addPart which is resolved after the part is
actually added and setup callers to use the promise when needed
Changes:
ve.ui.MWTransclusionDialog.js
* Use promises to auto-select new or moved parts
ve.dm.MWTranclusionModel.js
* Make addPart return a promise
* Resolve promise when queue is processed
* Automatically remove existing items before adding them in different
locations at the time of processing the queue we don't yield between
removing and adding
Change-Id: Ie43c5b89ca4ed34d5f797714e19c9a7e1824cdec
Problem:
Parsoid has a property called "i" which we don't use, but they need for
round-tripping purposes. Since we were generating a structure from
Parsoid data and then generating data from the structure without
preserving properties we didn't use, it was getting lost.
Solution:
Abstract creating a template from data vs. creating it from name. Make
only templates have an origin argument in their constructors, so and
set it within a set of static constructors that create a template for
either data or a template name. Store the original data in the former
case, and use it as a base when serializing.
Changes:
ve.ui.MWTranslcusionDialog.js
* Remove no-longer-needed mw global declaration
* Move most of the addTemplate function to a static constructor in the
template model class
ve.dm.MWTransclusionPartModel.js,
ve.dm.MWTransclusionContentModel.js,
ve.dm.MWTemplatePlaceholder
* Remove unused origin argument/property/getter
* Add serialize method (if needed)
ve.dm.MWTranclusionModel.js
* Move template/parameter generation from data into static constructor
of template model
* Move serialization to part classes
ve.dm.MWTemplateModel.js
* Add mw global declaration
* Stop passing origin to parent constructor, store it locally instead
* Add original data property/setter for preserving unused properties
when round tripping
* Add static constructors for generating a template from data or by name
* Add serialize method
Bug: 51150
Change-Id: Ide596a0ca0ae8f93ffce6e79b7234a1db7e0586c
Objectives:
* Automatically add required parameters to templates that users create
using the GUI, without touching existing templates loaded from data
* Cleanup some confusing terminology and APIs
Changes:
ve.ui.MWParameterSearchWidget.js
* Remove special logic for skipping aliases, which are no longer included
in the list of names given by getParameterNames
ve.ui.MWTransclusionDialog.js
* Add origin arguments to constructors of transclusion parts
* Re-use onAddParameter method during initial construction of parameter
pages
* Add required template parameters for user created template parts
ve.dm.MWTransclusionPartModel.js
* Add origin argument/property/getter for tracking where a part came from
ve.dm.MWTransclusionContentModel.js,
ve.dm.MWTransclusionPlaceholderModel.js,
ve.dm.MWTemplateModel.js
* Add origin argument pass through
ve.dm.MWTranclusionModel.js
* Add origin arguments to constructors of transclusion parts
ve.dm.MWTemplateSpecModel.js
* Rename origin to name - was a bad name to start with and will be even
more confusing with the new part origin property
* Add isParameterAlias method
* Make getParameterNames only return primary names, excluding aliases
ve.dm.MWTemplateModel.js
* Update use of parameter origin, now called name
Bug: 50747
Change-Id: Ib444f0f5a8168cd59ea52a6000ba5e42ccdc2a24
Also in this commit is a fix to the regex for brackets in general
as previously it was grouping multiple pairs together which was
making the stack count incorrect.
Bug: 50801
Change-Id: I2cd825eaa7242e37a6317286cb8f9a4a78e693e2
This is harmful because we don't know whether <span> is acceptable
in context. They're not allowed in <tbody> for instance, and so if
we replace a <tr> with a <span> that breaks things.
Instead, use the nodeName of the first original DOM element.
Change-Id: I95ea9f13985767123f692706c6cc71fefd74d517
Objectives:
* Trim leading or trailing whitespace that parsoid may have left on
parameter names
* Preserve the original name for round-tripping cleanliness
* Ignore leading or trailing whitespace when entering new parameter names
in the parameter search widget
* Consider aliases when listing suggested parameters
Changes:
ve.ui.MWParameterSearchWidget.js
* Use hasParameter method instead of using indexOf - uses map lookup
internally, which is much faster, and also take aliases into account
* Trim query input value to prevent leading or trailing whitespace from
being considered when filtering known or creating unknown parameters
* Take aliases into account when showing filtered results
ve.dm.MWTransclusionModel.js
* Use original name when round-tripping
ve.dm.MWTemplateParameterModel.js
* Store original name for round tripping, and trim the original name for
other uses
* Add getOriginalName method
ve.dm.MWTemplateModel.js
* Add hasParameter method, which currently just does a map lookup, but can
do other processing in the future
ve.dm.MWTemplateSpecModel.js
* Add isParameterKnown method
Bug: 50715
Bug: 50717
Change-Id: I36a5e93ca8938ac3401a6e274647597704700468
Show an inspector with inputwidget when the user clicks a math
node. The data of the math equation is shown in the
edit box, it can re-render the math tag image when
the inspector is closed, and save the change when
saving the page.
TODO:
* Change the icon from link to math
* Translate title by translatewiki in i18n
* Other further UI improvements
Change-Id: I4d7533af25186cc39cc4bc6a4326d222ffd6db19
This patch creates two files handling math node matching,
which are:
ve.dm.MWMathNode.js - a basic version of toDataElement
and toDomElement functions work
ve.ce.MWMathNode.js - math formulas in VisualEditor are
clickable and render as img tags
Change-Id: Ib909c5fb02e385c88050f42d02d207ab6a97d0dd
Move all MW-specific files into the ve-mw directory, in preparation
for moving them out into a separate repo.
All MW-specific files were moved into a parallel directory structure
in modules/ve-mw . Files with both generic and MW-specific things were
split up. Files in ve/init/mw/ were moved to ve-mw/init/ rather than
ve-mw/init/mw ; they're still named ve.init.mw.* but we should change
that. Some of the test files for core classes had MW-specific test cases,
so those were split up and the test runner was duplicated; we should
refactor our tests to use data providers so we can add cases more easily.
Split files:
* ve.ce.Node.css
* ve.ce.ContentBranchNode.test.js (MWEntityNode)
* ve.ce.Document.test.js (some core test cases genericized)
* ve.dm.InternalList.test.js (uses mwReference test document)
* ve.dm.SurfaceFragment.test.js, ve.ui.FormatAction.test.js
** Made core tests use heading instead of mwHeading
** Updated core tests because normal headings don't break out of lists
** Moved test runners into ve.test.utils.js
* ve.ui.Icons-*.css
* ve.ui.Dialog.css (MW parts into ve.ui.MWDialog.css)
* ve.ui.Tool.css
* ve.ui.Widget.css (move ve-ui-rtl and ve-ui-ltr to ve.ui.css)
ve.dm.Converter.test.js: Moved runner functions into ve.test.utils.js
ve.dm.example.js:
* Refactored createExampleDocument so mwExample can use it
* Removed wgExtensionAssetsPath detection, moved into mw-preload.js
* Genericized withMeta example document (original version copied to mwExample)
* Moved references example document to mwExample
ve.dm.mwExample.js:
* Move withMeta and references example documents from ve.dm.example.js
* Add createExampleDocument function
ve-mw/test/index.php: Runner for MW-specific tests only
ve-mw/test/mw-preload.js: Sets VE_TESTDIR for Special:JavaScriptTest only
ve.ui.Window.js:
* Remove magic path interpolation in addLocalStyleSheets()
* Pass full(er) paths to addLocalStyleSheets(), here and in subclasses
ve.ui.MWDialog.js: Subclass of Dialog that adds MW versions of stylesheets
ve.ui.MW*Dialog.js:
* Subclass MWDialog rather than Dialog
* Load both core and MW versions of stylesheets that have both
ve.ui.PagedDialog.js: Converted to a mixin rather than an abstract base class
* Don't inherit ve.ui.Dialog
* Rather than overriding initialize(), provide initializePages() which the
host class is supposed to call from its initialize()
* Rename onOutlineSelect to onPageOutlineSelect
ve.ui.MWMetaDialog.js, ve.ui.MWTransclusionDialog.js:
* Use PagedDialog as a mixin rather than a base class, inherit MWDialog
bullet-icon.png: Unused, deleted
Stuff we should do later:
* Refactor tests to use data providers
* Write utility function for SVG compat check
* Separate omnibus CSS files such as ve.ui.Widget.css
* Separate omnibus RL modules
* Use icon classes in ViewPageTarget
Change-Id: I1b28f8ba7f2d2513e5c634927a854686fb9dd5a5