Okay, das Problem liegt bei
editor.undoManager.transact(). Selbst wenn ich diesen Code ändere zu:
Code: Select all
editor.undoManager.transact(function() {});
glaubt der Firefox eine Änderung gefunden zu haben. Die
Doku zu transact() sagt aber:
Executes the specified mutator function as an undo transaction. The selection before the modification will be stored to the undo stack and if the DOM changes it will add a new undo level. Any logic within the translation that adds undo levels will be ignored. So a translation can include calls to execCommand or editor.insertContent.
Da in diesem Fall keine Änderung am DOM erfolgt, dürfte auch kein neuer Undo-Level hinzugefügt werden – das riecht nach einem Bug in TinyMCE. Da du den Bug gefunden hast, darfst du ihn auch behalten.
Allerdings, sehe ich zunächst auch keinen triftigen Grund, diesen Code beim ersten mal als rückgängigmachbare Änderung laufen zu lassen. Man könnte also die
gesamte Routine ändern zu:
Code: Select all
editor.on('SetContent', function() {
function processUnprocessedCodeSamples(unprocessedCodeSamples) {
unprocessedCodeSamples.each(function(idx, elm) {
$(elm).find('br').each(function(idx, elm) {
elm.parentNode.replaceChild(editor.getDoc().createTextNode('\n'), elm);
});
elm.contentEditable = false;
elm.innerHTML = editor.dom.encode(elm.textContent);
elm.className = $.trim(elm.className);
});
}
var unprocessedCodeSamples = $('pre').filter(trimArg(Utils.isCodeSample)).filter(function(idx, elm) {
return elm.contentEditable !== "false";
});
if (unprocessedCodeSamples.length) {
if (initialSetContent) {
processUnprocessedCodeSamples(unprocessedCodeSamples);
initialSetContent = false;
} else {
editor.undoManager.transact(function() {
processUnprocessedCodeSamples(unprocessedCodeSamples);
});
}
}
});