Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7409377
ve.ui.MWExtensionPreviewDialog.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.ui.MWExtensionPreviewDialog.js
View Options
/*!
* VisualEditor UserInterface MWExtensionPreviewDialog class.
*
* @copyright See AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Dialog for editing generic MediaWiki extensions with a preview.
*
* @class
* @abstract
* @extends ve.ui.MWExtensionDialog
*
* @constructor
* @param {Object} [config] Configuration options
*/
ve
.
ui
.
MWExtensionPreviewDialog
=
function
VeUiMWExtensionPreviewDialog
()
{
// Parent constructor
ve
.
ui
.
MWExtensionPreviewDialog
.
super
.
apply
(
this
,
arguments
);
this
.
updatePreviewDebounced
=
ve
.
debounce
(
this
.
updatePreview
.
bind
(
this
),
1000
);
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
ui
.
MWExtensionPreviewDialog
,
ve
.
ui
.
MWExtensionDialog
);
/* Methods */
/**
* @inheritdoc
*/
ve
.
ui
.
MWExtensionPreviewDialog
.
prototype
.
initialize
=
function
()
{
// Parent method
ve
.
ui
.
MWExtensionPreviewDialog
.
super
.
prototype
.
initialize
.
call
(
this
);
// Properties
this
.
previewNode
=
null
;
this
.
previewElement
=
new
ve
.
ui
.
MWPreviewElement
();
// Initialization
this
.
$element
.
addClass
(
've-ui-mwExtensionPreviewDialog'
);
};
/**
* @inheritdoc
*/
ve
.
ui
.
MWExtensionPreviewDialog
.
prototype
.
getSetupProcess
=
function
(
data
)
{
return
ve
.
ui
.
MWExtensionPreviewDialog
.
super
.
prototype
.
getSetupProcess
.
call
(
this
,
data
)
.
next
(
()
=>
{
let
element
;
if
(
this
.
selectedNode
)
{
element
=
this
.
selectedNode
.
getClonedElement
();
}
else
{
element
=
this
.
getNewElement
();
}
const
linearData
=
[
element
,
{
type
:
'/'
+
element
.
type
}
];
if
(
ve
.
dm
.
nodeFactory
.
isNodeContent
(
element
.
type
)
)
{
linearData
.
unshift
(
{
type
:
'paragraph'
}
);
linearData
.
push
(
{
type
:
'/paragraph'
}
);
}
linearData
.
push
(
{
type
:
'internalList'
},
{
type
:
'/internalList'
}
);
// We assume that WindowAction pass
const
doc
=
data
.
fragment
.
getDocument
().
cloneWithData
(
linearData
);
const
rootNode
=
doc
.
getDocumentNode
().
children
[
0
];
this
.
previewNode
=
doc
.
getNodesByType
(
element
.
type
)[
0
];
this
.
previewElement
.
setModel
(
rootNode
);
}
);
};
/**
* @inheritdoc
*/
ve
.
ui
.
MWExtensionPreviewDialog
.
prototype
.
onChange
=
function
()
{
// Parent method
ve
.
ui
.
MWExtensionPreviewDialog
.
super
.
prototype
.
onChange
.
call
(
this
);
this
.
updatePreviewDebounced
();
};
/**
* Update the node rendering to reflect the current content in the dialog.
*/
ve
.
ui
.
MWExtensionPreviewDialog
.
prototype
.
updatePreview
=
function
()
{
const
mwData
=
ve
.
copy
(
this
.
previewNode
.
getAttribute
(
'mw'
)
),
doc
=
this
.
previewNode
.
getDocument
();
this
.
updateMwData
(
mwData
);
doc
.
commit
(
ve
.
dm
.
TransactionBuilder
.
static
.
newFromAttributeChanges
(
doc
,
this
.
previewNode
.
getOuterRange
().
start
,
{
mw
:
mwData
}
)
);
this
.
previewElement
.
updatePreview
();
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 22:27 (1 d, 20 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
84/20/d1adca11a42e4f55a4f9e20373fc
Default Alt Text
ve.ui.MWExtensionPreviewDialog.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment