VisualEditor/Node types

From MediaWiki.org
Jump to: navigation, search

This documents the current state of support for various node types and annotations.

Legend[edit | edit source]

Type
symbolic name in the data model;
attribute=value
used if different values for a certain attribute map to different HTML tags
HTML tag
HTML tag this node type is converted from/to
Valid parents
Node types that this type can have as its parent. * means any, - means none
Valid children
Node types that this type can have as its children. * means any, - means none
Other attributes
Attributes that have a special meaning for this node type, if any
Properties (annotations only)
Properties in annotation.data
Rendering
Whether the editor renders nodes of this type correctly
Editing
Whether the user can edit the contents of this node type. For annotations, this means the user can edit text with this annotation and change the annotation's properties if any
Creating
Whether the user can create new nodes of this type. For annotations, this means the user can apply this annotation to existing text
Saving
Whether a node of this type will be converted back to wikitext correctly. This can be true even for non-editable nodes if they round-trip correctly. A "no" in this column means even untouched nodes of this type don't round-trip correctly


Structural nodes[edit | edit source]

These nodes can contain child nodes as long as those nodes aren't content nodes. They do not have their own content.

Type Data model properties Editor support
attribute=value HTML tag Valid parents Valid children Other attributes Rendering Editing Creating Saving
document[1] N/A - * N/A N/A N/A N/A
table table * tableSection Yes No No No
tableSection style=header tfoot table tableRow Yes No No No
style=body tbody
style=footer tfoot
tableRow tr tableSection tableCell Yes No No No
tableCell style=data td tableRow * Yes Yes No No
style=header th
list style=bullet ul * listItem Yes Yes Yes [2] Yes
style=number ol
listItem li list * Yes Yes Yes Yes
definitionList dl * definitionListItem Yes Yes No Yes
definitionListItem style=term dt definitionList * Yes Yes No Yes
style=definition dd
alienBlock *[3] * - html[4] Yes No[5] No[5] Yes

Nodes that can contain content (TODO terminology?)[edit | edit source]

These nodes can only contain child nodes that are content. They do not have their own content.

Type Data model properties Editor support
attribute=value HTML tag Valid parents Valid children Other attributes Rendering Editing Creating Saving
paragraph p * * Yes Yes Yes Yes
heading level=1 h1 * * Yes Yes Yes Yes
level=2 h2
level=3 h3
level=4 h4
level=5 h5
level=6 h6
preformatted pre * * Yes Yes Yes Yes

Nodes that are content (content nodes?)[edit | edit source]

These are the only nodes that have content. Text nodes contain text, other nodes in this category cannot contain anything but represent content.

Type Data model properties Editor support
attribute=value HTML tag Valid parents Valid children Other attributes Rendering Editing Creating Saving
text N/A[6] * - Yes Yes Yes Yes
image img[7] * - html/src[8] Mostly[9] No No No[10]
alienInline *[3] * - html[4] Yes No[5] No[5] Yes

Annotations[edit | edit source]

These aren't nodes, they're JSON objects, but they do correspond to HTML tags. Annotations can be applied to individual characters in a text node and to other content nodes, but not to non-content nodes. Attribute types are denoted as type/subtype.

Type Data model properties Editor support
HTML tag Properties Rendering Editing Creating Saving
textStyle/italic i Yes Yes Yes Yes
textStyle/bold b Yes Yes Yes Yes
textStyle/underline u Yes Yes No Yes
textStyle/strike s Yes Yes No Yes
textStyle/small small Yes Yes No Yes
textStyle/big big Yes Yes No Yes
textStyle/span span Yes Yes No Yes
link/wikiLink a rel="mw:wikiLink" href[11], title[12] Yes Yes Yes Yes
link/extLink a rel="mw:extLink" href[13], title[14] Yes No[15] No Yes[16]
link/unknown[17] a href, title  ??  ??  ??  ??

Footnotes[edit | edit source]

  1. This is the root node that all other nodes descend from, it has no HTML equivalent. Each document has exactly one document node.
  2. Creating and editing nested lists is not supported yet
  3. 3.0 3.1 Represents unrecognized tags or tags with the data-gc attribute (generated content)
  4. 4.0 4.1 Stores the raw HTML found in the Parsoid output
  5. 5.0 5.1 5.2 5.3 By design
  6. Text nodes represent HTML TextNodes, kind of
  7. Only in the context of an inline image, not in the context of a framed, floating image (thumbnail)
  8. URL of image. Ideally we'd have another attribute for the image title if the image is internal
  9. The width and height attributes aren't taken into account
  10. But this is not the editor's fault, images are converted back to HTML correctly, Parsoid's HTML->wikitext serializer just doesn't support images at all.
  11. Corresponds to href in HTML. Ideally this would only be used for external links
  12. Title of the target page, corresponds to data-mw.sHref[0]
  13. Link target, corresponds to href in HTML
  14. Same as href. Ideally this would only be used for internal links
  15. Can edit text but cannot edit target
  16. Provided the target is not edited; this is not supposed to be possible but the UI currently does allow it
  17. Unused, deprecated, should be an alien instead