Skip to content

Commit

Permalink
Fixed undo issue (release snapshot)
Browse files Browse the repository at this point in the history
  • Loading branch information
andykirk committed Sep 9, 2014
1 parent 75e4b81 commit ff516db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 5 additions & 7 deletions footnotes/dialogs/footnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ CKEDITOR.dialog.add( 'footnotesDialog', function( editor ) {
config.height = 80;
config.resize_enabled = false;
config.autoGrow_minHeight = 80;
config.removePlugins = 'footnotes';//,elementspath';
config.removePlugins = 'footnotes';

config.on = {
focus: function( evt ){
Expand All @@ -127,27 +127,25 @@ CKEDITOR.dialog.add( 'footnotesDialog', function( editor ) {
var dialog = this;

var footnote_editor = CKEDITOR.instances[dialog.editor_name];
var footnote_id = dialog.getValueOf('tab-basic', 'footnote_id');
var footnote_id = dialog.getValueOf('tab-basic', 'footnote_id'); var footnote_data = footnote_editor.getData(); footnote_editor.destroy();

editor.fire('saveSnapshot');

if (footnote_id == '') {
// No existing id selected, check for new footnote:
var new_footnote = footnote_editor.getData();
if (new_footnote == '') {
if (footnote_data == '') {
// Nothing entered, so quit:
return;
} else {
// Insert new footnote:
editor.plugins.footnotes.build(new_footnote, true, editor);
editor.plugins.footnotes.build(footnote_data, true, editor);
}
} else {
// Insert existing footnote:
editor.plugins.footnotes.build(footnote_id, false, editor);
}
// Destroy the editor so it's rebuilt properly next time:
footnote_editor.destroy();
return;
}
}, onCancel: function() { var dialog = this; var footnote_editor = CKEDITOR.instances[dialog.editor_name]; footnote_editor.destroy(); }
};
});
7 changes: 3 additions & 4 deletions footnotes/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ CKEDITOR.plugins.add( 'footnotes', {
var $this = this;

// Force a reorder on startup to make sure all vars are set: (e.g. footnotes store)
editor.on('instanceReady', function(evt) {
$this.reorderMarkers(editor);
editor.on('instanceReady', function(evt) { $this.reorderMarkers(editor);
});

// Add the reorder change event:
Expand Down Expand Up @@ -207,15 +206,15 @@ CKEDITOR.plugins.add( 'footnotes', {

// Check that there's a footnotes section. If it's been deleted the markers are useless:
if ($contents.find('.footnotes').length == 0) {
$contents.find('sup[data-footnote-id]').remove();
$contents.find('sup[data-footnote-id]').remove(); editor.fire('unlockSnapshot');
return;
}

// Find all the markers in the document:
var $markers = $contents.find('sup[data-footnote-id]');
// If there aren't any, remove the Footnotes container:
if ($markers.length == 0) {
$contents.find('.footnotes').remove();
$contents.find('.footnotes').remove(); editor.fire('unlockSnapshot');
return;
}

Expand Down

0 comments on commit ff516db

Please sign in to comment.