mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Make undo work for changes to MWExtensionNodes
If you changed the contents of an alien tag extension, then tried to use undo, the change wouldn't be undone, but the undo state would toggle. This was because we only kept one copy of the data-mw object for these nodes and modified that one copy. Instead, create a new copy every time we modify it, so we can actually go back to previous states. Change-Id: Ib4d5d460a6fdda9c3b0968f269585d620b47fdd8
This commit is contained in:
parent
5d47562fe8
commit
885c0a5495
|
@ -85,22 +85,22 @@ ve.ui.MWExtensionInspector.prototype.onOpen = function () {
|
|||
* @param {string} action Action that caused the window to be closed
|
||||
*/
|
||||
ve.ui.MWExtensionInspector.prototype.onClose = function ( action ) {
|
||||
var mw,
|
||||
var mwData,
|
||||
surfaceModel = this.surface.getModel();
|
||||
|
||||
// Parent method
|
||||
ve.ui.Inspector.prototype.onClose.call( this, action );
|
||||
|
||||
if ( this.node instanceof this.constructor.static.nodeView ) {
|
||||
mw = this.node.getModel().getAttribute( 'mw' );
|
||||
mw.body.extsrc = this.input.getValue();
|
||||
mwData = ve.copy( this.node.getModel().getAttribute( 'mw' ) );
|
||||
mwData.body.extsrc = this.input.getValue();
|
||||
surfaceModel.change(
|
||||
ve.dm.Transaction.newFromAttributeChanges(
|
||||
surfaceModel.getDocument(), this.node.getOuterRange().start, { 'mw': mw }
|
||||
surfaceModel.getDocument(), this.node.getOuterRange().start, { 'mw': mwData }
|
||||
)
|
||||
);
|
||||
} else {
|
||||
mw = {
|
||||
mwData = {
|
||||
'name': this.constructor.static.nodeModel.static.extensionName,
|
||||
'attrs': {},
|
||||
'body': {
|
||||
|
@ -111,7 +111,7 @@ ve.ui.MWExtensionInspector.prototype.onClose = function ( action ) {
|
|||
{
|
||||
'type': this.constructor.static.nodeModel.static.name,
|
||||
'attributes': {
|
||||
'mw': mw
|
||||
'mw': mwData
|
||||
}
|
||||
},
|
||||
{ 'type': '/' + this.constructor.static.nodeModel.static.name }
|
||||
|
|
Loading…
Reference in a new issue