diff --git a/Resources/public/js/alloyeditor/plugins/yui3.js b/Resources/public/js/alloyeditor/plugins/yui3.js index b902c9ed1..40581273b 100644 --- a/Resources/public/js/alloyeditor/plugins/yui3.js +++ b/Resources/public/js/alloyeditor/plugins/yui3.js @@ -11,12 +11,14 @@ YUI.add('ez-alloyeditor-plugin-yui3', function (Y) { } function cleanUpIds(editor) { + editor.undoManager.lock(); Array.prototype.forEach.call( editor.element.$.querySelectorAll('[id]'), function (element) { element.removeAttribute('id'); } ); + editor.undoManager.unlock(); } /** diff --git a/Tests/js/alloyeditor/plugins/assets/ez-alloyeditor-plugin-yui3-tests.js b/Tests/js/alloyeditor/plugins/assets/ez-alloyeditor-plugin-yui3-tests.js index 444d7559f..7a12a0b1b 100644 --- a/Tests/js/alloyeditor/plugins/assets/ez-alloyeditor-plugin-yui3-tests.js +++ b/Tests/js/alloyeditor/plugins/assets/ez-alloyeditor-plugin-yui3-tests.js @@ -68,6 +68,21 @@ YUI.add('ez-alloyeditor-plugin-yui3-tests', function (Y) { "The id should have been removed" ); }, + + "Should lock and unlock the undo manager": function () { + var nativeEditor = this.editor.get('nativeEditor'); + + nativeEditor.undoManager = new Mock(nativeEditor.undoManager); + Mock.expect(nativeEditor.undoManager, { + method: 'lock', + }); + Mock.expect(nativeEditor.undoManager, { + method: 'unlock', + }); + nativeEditor.execCommand('bold'); + + Mock.verify(nativeEditor.undoManager); + }, }); Y.Test.Runner.setName("eZ AlloyEditor yui3 plugin tests");