VisualEditor/WikiDom Specification

From MediaWiki.org
Jump to: navigation, search

WikiDom is a serialization of Wikitext based on JSON and optimized for transport and adaptive processing. The structure is based on two basic types of nodes, branches and leafs. Branch nodes have child nodes and leaf nodes have content. A node can not be a branch and a leaf. Content objects in leaf nodes use offset annotations for formatting.

Object Types[edit | edit source]

  • Branch Node
    • type
    • attributes
    • children (branch/leaf nodes)
  • Leaf Node
    • type
    • attributes
    • content
  • Content
    • text
    • annotations
  • Annotation
    • type
    • range
    • data
  • Range
    • start
    • end

Node Types[edit | edit source]

Symbolic Name Node Type Parent Node Types Child Node Types
paragraph Leaf any none
heading Leaf any none
list Branch any listItem
listItem Branch list any
table Branch any none
tableRow Branch table tableCell
tableCell Branch tableRow any
horizontalRule Leaf any none
comment Leaf any none
pre Leaf any none

Annotation Types[edit | edit source]

Symbolic Name Description HTML equivalent WikiText equivilant
textStyle/bold Bold <b> ''' '''
textStyle/italic Italic <i> '' ''
textStyle/emphasize Emphasize <em>
textStyle/strong Strong <strong>
textStyle/big Big <big>
textStyle/small Small <small>
textStyle/subScript Sub-script <sub>
textStyle/superScript Super-script <sup>
link/internal Internal link <a> [[ ]]
link/external Internal link <a> [ ]
object/hook Parser Hook <ref></ref>
object/template Template transclusion {{ }}

Node Examples[edit | edit source]

Table
{
    'type': 'table',
    'attributes': {
        'html/class': 'wikitable',
        'html/width': '300'
    }
    'children': [
        {
            'type': 'tableRow',
            'children': [
                {
                    'type': 'tableCell',
                    'attributes': {
                        'html/style': 'background-color: red',
                    }
                    'children': [/* ... */]
                }
            ]
        }
    ]
}
Paragraph
{
    'type': 'paragraph',
    'content': {
        'text': 'test 123',
        'annotations': [
            { 'type': 'textStyle/bold', 'range': { 'start': 0, 'end': 4 } }
        ]
    }
}