Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7395950
ve.dm.ListNode.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ve.dm.ListNode.js
View Options
/*!
* 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
:
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
;
}
}
);
if
(
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'
};
if
(
key
===
'style'
&&
change
.
from
in
messageKeys
&&
change
.
to
in
messageKeys
)
{
return
ve
.
htmlMsg
(
'visualeditor-changedesc-no-key'
,
// Message keys documented above
// eslint-disable-next-line mediawiki/msg-doc
this
.
wrapText
(
'del'
,
ve
.
msg
(
messageKeys
[
change
.
from
]
)
),
// eslint-disable-next-line mediawiki/msg-doc
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
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 13:57 (7 h, 37 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ac/9a/53aad0c7c65b788f4b1e3e6f2404
Default Alt Text
ve.dm.ListNode.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment