Skip to content

Commit

Permalink
Merge branch 't/10249b'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Apr 2, 2013
2 parents 8ad32fe + 3332ea4 commit 1c7efa1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
23 changes: 10 additions & 13 deletions core/editor.js
Expand Up @@ -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();
} );

Expand Down Expand Up @@ -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 ] );
}

Expand Down Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions plugins/undo/plugin.js
Expand Up @@ -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', {
Expand Down

0 comments on commit 1c7efa1

Please sign in to comment.