X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fundo%2Fplugin.js;h=337c427cd3ad92190756aabb3b86109b65cb4224;hb=e73319a12b56100b29ef456fd74114fe5519e01c;hp=94744eadcf4c8bf36bf7fe76a4da102dafbaf727;hpb=4e90e78dc97789709ee7404359a5517540c27553;p=ckeditor.git diff --git a/_source/plugins/undo/plugin.js b/_source/plugins/undo/plugin.js index 94744ea..337c427 100644 --- a/_source/plugins/undo/plugin.js +++ b/_source/plugins/undo/plugin.js @@ -64,9 +64,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.on( 'afterCommandExec', recordCommand ); // Save snapshots before doing custom changes. - editor.on( 'saveSnapshot', function() + editor.on( 'saveSnapshot', function( evt ) { - undoManager.save(); + undoManager.save( evt.data && evt.data.contentOnly ); }); // Registering keydown on every document recreation.(#3844) @@ -90,7 +90,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Make the undo manager available only in wysiwyg mode. editor.on( 'mode', function() { - undoManager.enabled = editor.mode == 'wysiwyg'; + undoManager.enabled = editor.readOnly ? false : editor.mode == 'wysiwyg'; undoManager.onChange(); }); @@ -116,24 +116,22 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; /** - * Update the undo stacks with any subsequent DOM changes after this call. + * Amend the top of undo stack (last undo image) with the current DOM changes. * @name CKEDITOR.editor#updateUndo * @example * function() * { - * editor.fire( 'updateSnapshot' ); - * ... - * // Ask to include subsequent (in this call stack) DOM changes to be - * // considered as part of the first snapshot. - * editor.fire( 'updateSnapshot' ); + * editor.fire( 'saveSnapshot' ); * editor.document.body.append(...); + * // Make new changes following the last undo snapshot part of it. + * editor.fire( 'updateSnapshot' ); * ... * } */ editor.on( 'updateSnapshot', function() { - if ( undoManager.currentImage && new Image( editor ).equals( undoManager.currentImage ) ) - setTimeout( function() { undoManager.update(); }, 0 ); + if ( undoManager.currentImage ) + undoManager.update(); }); } }); @@ -545,6 +543,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license /** * The number of undo steps to be saved. The higher this setting value the more * memory is used for it. + * @name CKEDITOR.config.undoStackSize * @type Number * @default 20 * @example