Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
ckeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vanilla ckeditor-3.6.3
[ckeditor.git]
/
_source
/
plugins
/
undo
/
plugin.js
diff --git
a/_source/plugins/undo/plugin.js
b/_source/plugins/undo/plugin.js
index
94744ea
..
f4ad1a3
100644
(file)
--- a/
_source/plugins/undo/plugin.js
+++ b/
_source/plugins/undo/plugin.js
@@
-1,5
+1,5
@@
/*
\r
/*
\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
\r
For licensing, see LICENSE.html or http://ckeditor.com/license
\r
*/
\r
\r
For licensing, see LICENSE.html or http://ckeditor.com/license
\r
*/
\r
\r
@@
-64,9
+64,9
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
editor.on( 'afterCommandExec', recordCommand );
\r
\r
// Save snapshots before doing custom changes.
\r
editor.on( 'afterCommandExec', recordCommand );
\r
\r
// Save snapshots before doing custom changes.
\r
- editor.on( 'saveSnapshot', function()
\r
+ editor.on( 'saveSnapshot', function( evt )
\r
{
\r
{
\r
- undoManager.save();
\r
+ undoManager.save( evt.data && evt.data.contentOnly );
\r
});
\r
\r
// Registering keydown on every document recreation.(#3844)
\r
});
\r
\r
// Registering keydown on every document recreation.(#3844)
\r
@@
-90,7
+90,7
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
// Make the undo manager available only in wysiwyg mode.
\r
editor.on( 'mode', function()
\r
{
\r
// Make the undo manager available only in wysiwyg mode.
\r
editor.on( 'mode', function()
\r
{
\r
- undoManager.enabled = editor.mode == 'wysiwyg';
\r
+ undoManager.enabled = editor.readOnly ? false : editor.mode == 'wysiwyg';
\r
undoManager.onChange();
\r
});
\r
\r
undoManager.onChange();
\r
});
\r
\r
@@
-116,24
+116,22
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
};
\r
\r
/**
\r
};
\r
\r
/**
\r
- * Update the undo stacks with any subsequent DOM changes after this call.
\r
+ * Amend the top of undo stack (last undo image) with the current DOM changes.
\r
* @name CKEDITOR.editor#updateUndo
\r
* @example
\r
* function()
\r
* {
\r
* @name CKEDITOR.editor#updateUndo
\r
* @example
\r
* function()
\r
* {
\r
- * editor.fire( 'updateSnapshot' );
\r
- * ...
\r
- * // Ask to include subsequent (in this call stack) DOM changes to be
\r
- * // considered as part of the first snapshot.
\r
- * editor.fire( 'updateSnapshot' );
\r
+ * editor.fire( 'saveSnapshot' );
\r
* editor.document.body.append(...);
\r
* editor.document.body.append(...);
\r
+ * // Make new changes following the last undo snapshot part of it.
\r
+ * editor.fire( 'updateSnapshot' );
\r
* ...
\r
* }
\r
*/
\r
editor.on( 'updateSnapshot', function()
\r
{
\r
* ...
\r
* }
\r
*/
\r
editor.on( 'updateSnapshot', function()
\r
{
\r
- if ( undoManager.currentImage && new Image( editor ).equals( undoManager.currentImage ) )
\r
- setTimeout( function() { undoManager.update(); }, 0 );
\r
+ if ( undoManager.currentImage )
\r
+ undoManager.update();
\r
});
\r
}
\r
});
\r
});
\r
}
\r
});
\r
@@
-262,7
+260,8
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
\r
if ( startedTyping || modifierSnapshot )
\r
{
\r
\r
if ( startedTyping || modifierSnapshot )
\r
{
\r
- var beforeTypeImage = new Image( this.editor );
\r
+ var beforeTypeImage = new Image( this.editor ),
\r
+ beforeTypeCount = this.snapshots.length;
\r
\r
// Use setTimeout, so we give the necessary time to the
\r
// browser to insert the character into the DOM.
\r
\r
// Use setTimeout, so we give the necessary time to the
\r
// browser to insert the character into the DOM.
\r
@@
-274,7
+273,10
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
if ( CKEDITOR.env.ie )
\r
currentSnapshot = currentSnapshot.replace( /\s+data-cke-expando=".*?"/g, '' );
\r
\r
if ( CKEDITOR.env.ie )
\r
currentSnapshot = currentSnapshot.replace( /\s+data-cke-expando=".*?"/g, '' );
\r
\r
- if ( beforeTypeImage.contents != currentSnapshot )
\r
+ // If changes have taken place, while not been captured yet (#8459),
\r
+ // compensate the snapshot.
\r
+ if ( beforeTypeImage.contents != currentSnapshot &&
\r
+ beforeTypeCount == this.snapshots.length )
\r
{
\r
// It's safe to now indicate typing state.
\r
this.typing = true;
\r
{
\r
// It's safe to now indicate typing state.
\r
this.typing = true;
\r
@@
-412,10
+414,21
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
\r
restoreImage : function( image )
\r
{
\r
\r
restoreImage : function( image )
\r
{
\r
+ // Bring editor focused to restore selection.
\r
+ var editor = this.editor,
\r
+ sel;
\r
+
\r
+ if ( image.bookmarks )
\r
+ {
\r
+ editor.focus();
\r
+ // Retrieve the selection beforehand. (#8324)
\r
+ sel = editor.getSelection();
\r
+ }
\r
+
\r
this.editor.loadSnapshot( image.contents );
\r
\r
if ( image.bookmarks )
\r
this.editor.loadSnapshot( image.contents );
\r
\r
if ( image.bookmarks )
\r
- this.editor.getSelection().selectBookmarks( image.bookmarks );
\r
+ sel.selectBookmarks( image.bookmarks );
\r
else if ( CKEDITOR.env.ie )
\r
{
\r
// IE BUG: If I don't set the selection to *somewhere* after setting
\r
else if ( CKEDITOR.env.ie )
\r
{
\r
// IE BUG: If I don't set the selection to *somewhere* after setting
\r
@@
-545,6
+558,7
@@
For licensing, see LICENSE.html or http://ckeditor.com/license
/**
\r
* The number of undo steps to be saved. The higher this setting value the more
\r
* memory is used for it.
\r
/**
\r
* The number of undo steps to be saved. The higher this setting value the more
\r
* memory is used for it.
\r
+ * @name CKEDITOR.config.undoStackSize
\r
* @type Number
\r
* @default 20
\r
* @example
\r
* @type Number
\r
* @default 20
\r
* @example
\r