Expand all

ve.ui.DiffElement

Extends

Constructor

new ve.ui.DiffElement([visualDiff], [config]) #

Creates a ve.ui.DiffElement object.

Parameters:

Name Type Attributes Description
visualDiff ve.dm.VisualDiff optional

Diff to visualize

config Object optional
Source:
Creates a ve.ui.DiffElement object.

Methods

addAttributesToElement(data, offset, attributes) #

Mark an element with attributes to be added later by the converter.

Parameters:

Name Type Description
data Array

Data containing element to be marked

offset number

Offset of element to be marked

attributes Object

Attributes to set

Source:
Mark an element with attributes to be added later by the converter.

annotateNode(linearDiff, newNode) → {Array} #

Annotate some data to highlight diff

Parameters:

Name Type Description
linearDiff Array

Linear diff, mapping arrays of linear data to diff actions (remove, insert or retain)

newNode ve.dm.Node

Node from the new document

Source:

Returns:

Data with annotations added

Type
Array
Annotate some data to highlight diff

appendListItem(diffData, insertIndex, listNode, listNodeData, listItemData, depthChange) → {number}private #

Append list item

Parameters:

Name Type Description
diffData Array
insertIndex number
listNode ve.dm.ListNode
listNodeData Array

List node opening

listItemData Array
depthChange number
Source:

Returns:

Type
number
Append list item

compareNodeAttributes(data, offset, attributeChange) → {OO.ui.OptionWidget|null} #

Compare attributes of two nodes

Parameters:

Name Type Description
data Array

Linear data containing new node

offset number

Offset in data

attributeChange Object

Attribute change object containing oldAttributes and newAttributes

Source:

Returns:

Change description item, or null if nothing to describe

Type
OO.ui.OptionWidget | null
Compare attributes of two nodes

getChangeDescriptionItem(changes, classes) → {OO.ui.OptionWidget} #

Get a change description item from a set of changes

Parameters:

Name Type Description
changes Array

List of changes, each change being either text or a Node array

classes Array.<string>

Additional classes

Source:

Returns:

Change description item

Type
OO.ui.OptionWidget
Get a change description item from a set of changes

getChangedDocListData(newDoclistNode, diff, neverProcess) → {Array} #

Get the linear data for a document-like node that has been changed

Parameters:

Name Type Description
newDoclistNode ve.dm.Node

Node from new document

diff Object

Object describing the diff

neverProcess boolean

Never process the diffQueue (always show the whole document)

Source:

Returns:

Linear data for the diff

Type
Array
Get the linear data for a document-like node that has been changed

getChangedLeafNodeData(newNode, diff) → {Array} #

Get the linear data for the diff of a leaf-like node that has been changed.

Parameters:

Name Type Description
newNode ve.dm.Node

Corresponding node from the new document

diff Object

Object describing the diff

Source:

Returns:

Linear data for the diff

Type
Array
Get the linear data for the diff of a leaf-like node that has been changed.

getChangedListNodeData(newListNode, diff) → {Array} #

Get the linear data for the diff of a list-like node that has been changed.

Parameters:

Name Type Description
newListNode ve.dm.Node

Corresponding node from the new document

diff Object

Object describing the diff

Source:

Returns:

Linear data for the diff

Type
Array
Get the linear data for the diff of a list-like node that has been changed.

getChangedNodeData(diff, oldNode, newNode, move, [noTreeDiff]) → {Array|boolean} #

Get the linear data for the diff of a node that has been changed.

Parameters:

Name Type Attributes Description
diff Object

Object describing the diff

oldNode ve.dm.Node

Node from the old document

newNode ve.dm.Node

Corresponding node from the new document

move string | null

'up' or 'down' if the node has moved

noTreeDiff boolean optional

Don't perform a tree diff of the nodes (used internally to avoid recursion)

Source:

Returns:

Linear data for the diff, or false

Type
Array | boolean
Get the linear data for the diff of a node that has been changed.

getChangedNodeElements(diff, oldNode, newNode, move) → {Array.<HTMLElement>} #

Get the HTML for the diff of a node that has been changed.

Parameters:

Name Type Description
diff Object

Object describing the diff

oldNode ve.dm.Node

Node from the old document

newNode ve.dm.Node

Corresponding node from the new document

move string | null

'up' or 'down' if the node has moved

Source:

Returns:

Elements (not owned by window.document)

Type
Array.<HTMLElement>
Get the HTML for the diff of a node that has been changed.

getChangedTreeNodeData(oldTreeNode, newTreeNode, diff) → {Array} #

Get the linear data for the diff of a tree-like node that has been changed. Any node that is not leaf-like or list-like is treated as tree-like.

Parameters:

Name Type Description
oldTreeNode ve.dm.Node

Node from the old document

newTreeNode ve.dm.Node

Corresponding node from the new document

diff Object

Object describing the diff

Source:

Returns:

Linear data for the diff

Type
Array
Get the linear data for the diff of a tree-like node that has been changed.

getDiffElementById(elementId) → {jQuery} #

Get a diff element in the document from its elementId

Parameters:

Name Type Description
elementId number

ID

Source:

Returns:

Element

Type
jQuery
Get a diff element in the document from its elementId

getInternalListChangedNodeElements(diff, oldNode, newNode, move, newIndex) → {Array.<HTMLElement>} #

Get the HTML for the linear diff of a single internal list item that has changed from the old document to the new document.

Parameters:

Name Type Description
diff Object

List item diff

oldNode ve.dm.InternalItemNode
newNode ve.dm.InternalItemNode
move string | null

'up' or 'down' if the node has moved

newIndex number
Source:

Returns:

HTML elements to display the linear diff

Type
Array.<HTMLElement>

Get the HTML for the linear diff of a single internal list item that has changed from the old document to the new document.

getInternalListNodeElements(internalListItemNode, action, move, index) → {Array.<HTMLElement>} #

Get the HTML for the diff of a single internal list item that has been removed from the old document, inserted into the new document, or that is unchanged.

Parameters:

Name Type Description
internalListItemNode ve.dm.InternalItemNode

Internal list item node

action string

'remove', 'insert' or 'none'

move string | null

'up' or 'down' if the node has moved

index number
Source:

Returns:

Elements (not owned by window.document)

Type
Array.<HTMLElement>

Get the HTML for the diff of a single internal list item that has been removed from the old document, inserted into the new document, or that is unchanged.

getNodeData(node, action, move) → {Array} #

Get the linear data for the diff of a removed, inserted, or unchanged-but-moved node.

Parameters:

Name Type Description
node ve.dm.Node
action string

'remove', 'insert' or, if moved, 'none'

move string | null

'up' or 'down' if the node has moved

Source:

Returns:

Linear Data

Type
Array

Get the linear data for the diff of a removed, inserted, or unchanged-but-moved node.

getNodeElements(node, action, move) → {Array.<HTMLElement>} #

Get the HTML for the diff of a removed, inserted, or unchanged-but-moved node.

Parameters:

Name Type Description
node ve.dm.Node

The node being diffed. Will be from the old document if it has been removed, or the new document if it has been inserted or moved

action string

'remove', 'insert' or, if moved, 'none'

move string | null

'up' or 'down' if the node has moved

Source:

Returns:

Elements (not owned by window.document)

Type
Array.<HTMLElement>
Get the HTML for the diff of a removed, inserted, or unchanged-but-moved node.

getRefListNodeElements(referencesListContainer, action, move, items) → {Array.<HTMLElement>} #

Add the relevant attributes to references list node HTML, whether changed or unchanged (but not inserted or removed - in these cases we just use getNodeElements).

Parameters:

Name Type Description
referencesListContainer HTMLElement

Div containing the references list

action string

'change' or 'none'

move string | null

'up' or 'down' if the node has moved

items Array.<OO.ui.OptionWidget>

Change descriptions for the reference list

Source:

Returns:

Elements to display

Type
Array.<HTMLElement>

Add the relevant attributes to references list node HTML, whether changed or unchanged (but not inserted or removed - in these cases we just use getNodeElements).

iterateDiff(diff, callbacks) #

Iterate over a diff object and run more meaningful callbacks

Parameters:

Name Type Description
diff Object | Array

Diff object, or array (InternalListDiff)

callbacks Object

Callbacks

Properties:
Name Type Description
insert function

Node inserted, arguments: {ve.dm.Node} newNode {number} newIndex

remove function

Node removed, arguments: {ve.dm.Node} oldNode {number} oldIndex

move function

Node moved, arguments: {ve.dm.Node} newNode {number} newIndex {string|null} move

changed function

Node changed, arguments: {Object} nodeDiff {ve.dm.Node} oldNode {ve.dm.Node} newNode {number} oldIndex {number} newIndex {string|null} move

Source:
Iterate over a diff object and run more meaningful callbacks

markMove(move, elementOrData, [offset]) #

Mark an HTML element or data element as moved

Parameters:

Name Type Attributes Default Description
move string | null

'up' or 'down' if the node has moved

elementOrData HTMLElement | Array

Linear data or HTMLElement

offset number optional
0

Linear mode offset

Source:
Mark an HTML element or data element as moved

onDescriptionsHighlight(item) #

Handle description item hightlight events

Parameters:

Name Type Description
item OO.ui.OptionWidget

Description item

Source:
Handle description item hightlight events

onDocumentMouseMove(e) #

Handle document mouse move events

Parameters:

Name Type Description
e jQuery.Event

Mouse move event

Source:
Handle document mouse move events

positionDescriptions() #

Reposition the description items so they are not above their position in the document

Source:
Reposition the description items so they are not above their position in the document

processQueue(queue) → {Array.<(Array|null)>} #

Process a diff queue, skipping over sequential nodes with no changes

Parameters:

Name Type Description
queue Array.<Array>

Diff queue

Source:

Returns:

Type
Array.<(Array|null)>
Process a diff queue, skipping over sequential nodes with no changes

renderDiff(diff, internalListDiff, metaListDiff, newHtmlDocument) #

Render the diff

Parameters:

Name Type Description
diff Object

Object describing the diff

internalListDiff Object

Object describing the diff of the internal list

metaListDiff Object

Object describing the diff of the meta list

newHtmlDocument HTMLDocument

HTML document of context, for resolving attributes

Source:
Render the diff

renderQueue(queue, parentNode, spacerNode) #

Parameters:

Name Type Description
queue Array.<(Array|null)>

Diff queue

parentNode HTMLElement

Parent node to render to

spacerNode HTMLElement

Spacer node template

Source:

wrapNodeData(nodeDoc, nodeData) → {Array.<HTMLElement>} #

Get the DOM from linear data and wrap it for the diff.

Parameters:

Name Type Description
nodeDoc ve.dm.Document

Node's document model

nodeData Array

Linear data for the diff

Source:

Returns:

Elements (not owned by window.document)

Type
Array.<HTMLElement>
Get the DOM from linear data and wrap it for the diff.

compareAttributes(oldAttributes, newAttributes) → {Object}static #

Compare attribute sets between two elements

Parameters:

Name Type Description
oldAttributes Object

Old attributes

newAttributes Object

New attributes

Source:

Returns:

Keyed set of attributes

Type
Object
Compare attribute sets between two elements

getDataFromNode(node) → {Array}static #

Get the original linear data from a node

Parameters:

Name Type Description
node ve.dm.Node

Node

Source:

Returns:

Linear data

Type
Array
Get the original linear data from a node