Extends
Constructor
new ve.ui.DiffElement([visualDiff], [config])
#
Hierarchy
Creates a ve.ui.DiffElement object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
visualDiff |
ve.dm.VisualDiff |
optional |
Diff to visualize |
config |
Object |
optional |
Methods
addAttributesToElement(data, offset, attributes)
#
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 |
Returns:
Data with annotations added
- Type
- Array
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 |
Returns:
- Type
- number
compareNodeAttributes(data, offset, attributeChange) → {OO.ui.OptionWidget|null
}
#
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 |
Returns:
Change description item, or null if nothing to describe
- Type
-
OO.ui.OptionWidget
|
null
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 |
Returns:
Change description item
- Type
- OO.ui.OptionWidget
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) |
Returns:
Linear data for the diff
- Type
- Array
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 |
Returns:
Linear data for the diff
- Type
- Array
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 |
Returns:
Linear data for the diff
- Type
- Array
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) |
Returns:
Linear data for the diff, or false
- Type
- Array | boolean
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 |
Returns:
Elements (not owned by window.document)
- Type
- Array.<HTMLElement>
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 |
Returns:
Linear data for the diff
- Type
- Array
getDiffElementById(elementId) → {jQuery}
#
Get a diff element in the document from its elementId
Parameters:
Name | Type | Description |
---|---|---|
elementId |
number | ID |
Returns:
Element
- Type
- jQuery
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 |
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 |
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 |
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 |
Returns:
Elements (not owned by window.document)
- Type
- Array.<HTMLElement>
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 |
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:
|
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 |
onDescriptionsHighlight(item)
#
Handle description item hightlight events
Parameters:
Name | Type | Description |
---|---|---|
item |
OO.ui.OptionWidget | Description item |
onDocumentMouseMove(e)
#
positionDescriptions()
#
Reposition the description items so they are not above their position in the document
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 |
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 |
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 |
Returns:
Elements (not owned by window.document)
- Type
- Array.<HTMLElement>
compareAttributes(oldAttributes, newAttributes) → {Object}static
#
Compare attribute sets between two elements
Parameters:
Returns:
Keyed set of attributes
- Type
- Object
getDataFromNode(node) → {Array}static
#
Get the original linear data from a node
Parameters:
Name | Type | Description |
---|---|---|
node |
ve.dm.Node | Node |
Returns:
Linear data
- Type
- Array