Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7409264
ve.ce.NodeFactory.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ve.ce.NodeFactory.js
View Options
/*!
* VisualEditor ContentEditable NodeFactory class.
*
* @copyright See AUTHORS.txt
*/
/**
* ContentEditable node factory.
*
* @class
* @extends OO.Factory
* @constructor
*/
ve
.
ce
.
NodeFactory
=
function
VeCeNodeFactory
()
{
// Parent constructor
OO
.
Factory
.
call
(
this
);
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
ce
.
NodeFactory
,
OO
.
Factory
);
/* Methods */
/**
* Get a plain text description of a node model.
*
* @param {ve.dm.Node} node Node to describe
* @return {string} Description of the node
* @throws {Error} Unknown node type
*/
ve
.
ce
.
NodeFactory
.
prototype
.
getDescription
=
function
(
node
)
{
const
type
=
node
.
constructor
.
static
.
name
;
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
this
.
registry
,
type
)
)
{
return
this
.
registry
[
type
].
static
.
getDescription
(
node
);
}
throw
new
Error
(
'Unknown node type: '
+
type
);
};
/**
* Check if a node type splits on Enter
*
* @param {string} type Node type
* @return {boolean} The node can have grandchildren
* @throws {Error} Unknown node type
*/
ve
.
ce
.
NodeFactory
.
prototype
.
splitNodeOnEnter
=
function
(
type
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
this
.
registry
,
type
)
)
{
return
this
.
registry
[
type
].
static
.
splitOnEnter
;
}
throw
new
Error
(
'Unknown node type: '
+
type
);
};
/**
* Create a view node from a model node.
*
* @param {ve.dm.Node} model Mode node
* @return {ve.ce.Node} View node
* @throws {Error} Unknown object name
*/
ve
.
ce
.
NodeFactory
.
prototype
.
createFromModel
=
function
(
model
)
{
let
type
=
model
.
getType
();
if
(
ve
.
dm
.
nodeFactory
.
isMetaData
(
type
)
)
{
// Metadata never has an explicit view representation, so a generic
// ve.ce.MetaItem should be fine
type
=
'meta'
;
}
return
this
.
create
(
type
,
model
);
};
/* Initialization */
// TODO: Move instantiation to a different file
ve
.
ce
.
nodeFactory
=
new
ve
.
ce
.
NodeFactory
();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 22:24 (1 d, 19 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5c/e0/53e8923eb1a3b71210092e90da70
Default Alt Text
ve.ce.NodeFactory.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment