Skip to content
Permalink
Browse files

Merge branch 't/10249b'

  • Loading branch information...
Reinmar committed Apr 2, 2013
2 parents 8ad32fe + 3332ea4 commit 1c7efa18e50a492702ac689a5fe3566024865618
Showing with 18 additions and 16 deletions.
  1. +10 −13 core/editor.js
  2. +8 −3 plugins/undo/plugin.js
@@ -156,14 +156,10 @@
// Make the editor update its command states on mode change.
this.on( 'readOnly', updateCommands );
this.on( 'selectionChange', updateCommandsContext );
this.on( 'mode', updateCommands );

// Handle startup focus.
this.on( 'instanceReady', function() {
updateCommands.call( this );
// First 'mode' event is fired before this 'instanceReady',
// so to avoid updating commands twice, add this listener here.
this.on( 'mode', updateCommands );

this.on( 'instanceReady', function( event ) {
this.config.startupFocus && this.focus();
} );

@@ -191,12 +187,9 @@

function updateCommands() {
var commands = this.commands,
mode = this.mode;

if ( !mode )
return;
name;

for ( var name in commands )
for ( name in commands )
updateCommand( this, commands[ name ] );
}

@@ -600,8 +593,12 @@
commandDefinition.name = commandName.toLowerCase();
var cmd = new CKEDITOR.command( this, commandDefinition );

// Update command when added after editor has been already initialized.
if ( this.status == 'ready' && this.mode )
// Update command when mode is set.
// This guarantees that commands added before first editor#mode
// aren't immediately updated, but waits for editor#mode and that
// commands added later are immediately refreshed, even when added
// before instanceReady. #10103, #10249
if ( this.mode )
updateCommand( this, cmd );

return this.commands[ commandName ] = cmd;
@@ -78,11 +78,16 @@
editor.mode == 'wysiwyg' && undoManager.save( true );
});

// Make the undo manager available only in wysiwyg mode.
editor.on( 'mode', function() {
function toggleUndoManager() {
undoManager.enabled = editor.readOnly ? false : editor.mode == 'wysiwyg';
undoManager.onChange();
});
}

// Make the undo manager available only in wysiwyg mode.
editor.on( 'mode', toggleUndoManager );

// Disable undo manager when in read-only mode.
editor.on( 'readOnly', toggleUndoManager );

if ( editor.ui.addButton ) {
editor.ui.addButton( 'Undo', {

0 comments on commit 1c7efa1

Please sign in to comment.
You can’t perform that action at this time.