File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change 144
144
*
145
145
* See {@link CKEDITOR.plugins.undo.UndoManager#lock} for more details.
146
146
*
147
+ * **Note:** In order to unlock the Undo Manager {@link #unlockSnapshot} has to be fired
148
+ * number of times `lockSnapshot` has been fired.
149
+ *
147
150
* @since 4.0
148
151
* @event lockSnapshot
149
152
* @member CKEDITOR.editor
570
573
*
571
574
* It's mainly used for ensure any DOM operations that shouldn't be recorded (e.g. auto paragraphing).
572
575
*
576
+ * **Note:** For every `lock` call you must call {@link #unlock} once to unlock the Undo Manager.
577
+ *
573
578
* @since 4.0
574
579
*/
575
580
lock : function ( ) {
581
586
// during this period.
582
587
var matchedTip = this . currentImage && snapBefore == this . currentImage . contents ;
583
588
584
- this . locked = { update : matchedTip ? snapBefore : null } ;
589
+ this . locked = { update : matchedTip ? snapBefore : null , level : 1 } ;
585
590
}
591
+ // Increase the level of lock.
592
+ else
593
+ this . locked . level ++ ;
586
594
} ,
587
595
588
596
/**
594
602
*/
595
603
unlock : function ( ) {
596
604
if ( this . locked ) {
597
- var update = this . locked . update ,
598
- snap = this . editor . getSnapshot ( ) ;
605
+ // Decrease level of lock and check if equals 0, what means that undoM is completely unlocked.
606
+ if ( ! -- this . locked . level ) {
607
+ var update = this . locked . update ,
608
+ snap = this . editor . getSnapshot ( ) ;
599
609
600
- this . locked = null ;
610
+ this . locked = null ;
601
611
602
- if ( typeof update == 'string' && snap != update )
603
- this . update ( ) ;
612
+ if ( typeof update == 'string' && snap != update )
613
+ this . update ( ) ;
614
+ }
604
615
}
605
616
}
606
617
} ;
You can’t perform that action at this time.
0 commit comments