mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
Emit a transact event on the ve.dm.Document when a transaction occurs
We'll need this to let a MetaList observe a Document and adjust to changes. We should probably also have SurfaceFragment listen to this event instead. Change-Id: I9e811e242969eb44afe0b4fa8153d0fb1b0071cd
This commit is contained in:
parent
031b96dd2a
commit
dadf005a67
|
@ -147,6 +147,14 @@ ve.dm.Document = function VeDmDocument( data, parentDocument ) {
|
|||
|
||||
ve.inheritClass( ve.dm.Document, ve.Document );
|
||||
|
||||
/* Events */
|
||||
|
||||
/**
|
||||
* @event transact
|
||||
* @param {ve.dm.Transaction} tx Transaction that was just processed
|
||||
* @param {boolean} reversed Whether the transaction was processed in reverse
|
||||
*/
|
||||
|
||||
/* Static methods */
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,6 +144,8 @@ ve.dm.TransactionProcessor.prototype.process = function () {
|
|||
}
|
||||
// Mark the transaction as committed or rolled back, as appropriate
|
||||
this.transaction.toggleApplied();
|
||||
// Emit an event on the document
|
||||
this.document.emit( 'transact', this.transaction, this.reversed );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,14 +9,21 @@
|
|||
* Generic document.
|
||||
*
|
||||
* @class
|
||||
* @extends ve.EventEmitter
|
||||
* @constructor
|
||||
* @param {ve.Node} model Model to observe
|
||||
*/
|
||||
ve.Document = function VeDocument( documentNode ) {
|
||||
// Parent constructor
|
||||
ve.EventEmitter.call( this );
|
||||
// Properties
|
||||
this.documentNode = documentNode;
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
ve.inheritClass( ve.Document, ve.EventEmitter );
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue