ensure step before formatting is persisted in undo history
							parent
							
								
									8820546f49
								
							
						
					
					
						commit
						9dac91a70d
					
				|  | @ -437,6 +437,7 @@ export default class BasicMessageEditor extends React.Component { | |||
|         if (range.length === 0) { | ||||
|             return; | ||||
|         } | ||||
|         this.historyManager.ensureLastChangesPushed(this.props.model); | ||||
|         switch (action) { | ||||
|             case "bold": | ||||
|                 formatInline(range, "**"); | ||||
|  |  | |||
|  | @ -106,6 +106,12 @@ export default class HistoryManager { | |||
|         return shouldPush; | ||||
|     } | ||||
| 
 | ||||
|     ensureLastChangesPushed(model) { | ||||
|         if (this._changedSinceLastPush) { | ||||
|             this._pushState(model, this._lastCaret); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     canUndo() { | ||||
|         return this._currentIndex >= 1 || this._changedSinceLastPush; | ||||
|     } | ||||
|  | @ -117,9 +123,7 @@ export default class HistoryManager { | |||
|     // returns state that should be applied to model
 | ||||
|     undo(model) { | ||||
|         if (this.canUndo()) { | ||||
|             if (this._changedSinceLastPush) { | ||||
|                 this._pushState(model, this._lastCaret); | ||||
|             } | ||||
|             this.ensureLastChangesPushed(model); | ||||
|             this._currentIndex -= 1; | ||||
|             return this._stack[this._currentIndex]; | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Bruno Windels
						Bruno Windels