Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1x 1011x 1x 1x 1x 1x 1x 1x 1x 3x 1x 264x 264x 1x 98x 98x 1x 24x 24x 3x 3x 6x 3x 3x 3x 3x 24x 1x 22x 22x 22x 6x 16x 1x 1514x 1x | /*!
* VisualEditor DataModel ListNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* DataModel list node.
*
* @class
* @extends ve.dm.BranchNode
*
* @constructor
* @param {Object} [element] Reference to element in linear model
* @param {ve.dm.Node[]} [children]
*/
ve.dm.ListNode = function VeDmListNode() {
// Parent constructor
ve.dm.ListNode.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.dm.ListNode, ve.dm.BranchNode );
/* Static Properties */
ve.dm.ListNode.static.name = 'list';
ve.dm.ListNode.static.childNodeTypes = [ 'listItem' ];
ve.dm.ListNode.static.defaultAttributes = {
style: 'bullet'
};
ve.dm.ListNode.static.matchTagNames = [ 'ul', 'ol' ];
ve.dm.ListNode.static.isDiffedAsList = true;
/**
* Creates a list item element
*
* @return {Object} Element data
*/
ve.dm.ListNode.static.createItem = function () {
return { type: 'listItem' };
};
ve.dm.ListNode.static.toDataElement = function ( domElements ) {
const style = domElements[ 0 ].nodeName.toLowerCase() === 'ol' ? 'number' : 'bullet';
return { type: this.name, attributes: { style } };
};
ve.dm.ListNode.static.toDomElements = function ( dataElement, doc ) {
const tag = dataElement.attributes && dataElement.attributes.style === 'number' ? 'ol' : 'ul';
return [ doc.createElement( tag ) ];
};
ve.dm.ListNode.static.describeChanges = function ( attributeChanges, attributes, element ) {
attributeChanges = ve.copy( attributeChanges );
if ( 'listType' in attributeChanges ) {
let mapped = false;
[ 'from', 'to' ].forEach( ( fromOrTo ) => {
if ( attributeChanges.listType[ fromOrTo ] === 'definitionList' ) {
attributeChanges.style[ fromOrTo ] = 'indent';
mapped = true;
}
} );
Eif ( mapped ) {
delete attributeChanges.listType;
}
}
// Parent method
return ve.dm.ListNode.super.static.describeChanges.call( this, attributeChanges, attributes, element );
};
ve.dm.ListNode.static.describeChange = function ( key, change ) {
const messageKeys = {
bullet: 'visualeditor-listbutton-bullet-tooltip',
number: 'visualeditor-listbutton-number-tooltip',
indent: 'visualeditor-changedesc-list-style-indent'
};
const hasOwn = Object.prototype.hasOwnProperty;
if ( key === 'style' && hasOwn.call( messageKeys, change.from ) && hasOwn.call( messageKeys, change.to ) ) {
return ve.htmlMsg( 'visualeditor-changedesc-no-key',
// Message keys documented above
this.wrapText( 'del', ve.msg( messageKeys[ change.from ] ) ),
this.wrapText( 'ins', ve.msg( messageKeys[ change.to ] ) )
);
}
// Parent method
return ve.dm.ListNode.super.static.describeChange.apply( this, arguments );
};
/* Methods */
ve.dm.ListNode.prototype.canHaveSlugAfter = function () {
// A paragraph can be added after a list by pressing enter in an empty list item
return false;
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.ListNode );
|