Skip to content

Commit 25d174d

Browse files
committed
Merge branch 't/10131'
2 parents 2be86aa + ff348cf commit 25d174d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

plugins/undo/plugin.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@
144144
*
145145
* See {@link CKEDITOR.plugins.undo.UndoManager#lock} for more details.
146146
*
147+
* **Note:** In order to unlock the Undo Manager {@link #unlockSnapshot} has to be fired
148+
* number of times `lockSnapshot` has been fired.
149+
*
147150
* @since 4.0
148151
* @event lockSnapshot
149152
* @member CKEDITOR.editor
@@ -570,6 +573,8 @@
570573
*
571574
* It's mainly used for ensure any DOM operations that shouldn't be recorded (e.g. auto paragraphing).
572575
*
576+
* **Note:** For every `lock` call you must call {@link #unlock} once to unlock the Undo Manager.
577+
*
573578
* @since 4.0
574579
*/
575580
lock: function() {
@@ -581,8 +586,11 @@
581586
// during this period.
582587
var matchedTip = this.currentImage && snapBefore == this.currentImage.contents;
583588

584-
this.locked = { update: matchedTip ? snapBefore : null };
589+
this.locked = { update: matchedTip ? snapBefore : null, level: 1 };
585590
}
591+
// Increase the level of lock.
592+
else
593+
this.locked.level++;
586594
},
587595

588596
/**
@@ -594,13 +602,16 @@
594602
*/
595603
unlock: function() {
596604
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();
599609

600-
this.locked = null;
610+
this.locked = null;
601611

602-
if ( typeof update == 'string' && snap != update )
603-
this.update();
612+
if ( typeof update == 'string' && snap != update )
613+
this.update();
614+
}
604615
}
605616
}
606617
};

0 commit comments

Comments
 (0)