Fixed: U4-4485 Unsaved changes prompt not appearing for RTE

This commit is contained in:
per ploug
2014-08-04 15:27:01 +02:00
parent a0bf366c85
commit 173d4c9655

View File

@@ -4,6 +4,22 @@ angular.module("umbraco")
$scope.isLoading = true;
var alreadyDirty = false;
function syncContent(editor){
editor.save();
angularHelper.safeApply($scope, function () {
$scope.model.value = editor.getContent();
});
if (!alreadyDirty) {
//make the form dirty manually so that the track changes works, setting our model doesn't trigger
// the angular bits because tinymce replaces the textarea.
var currForm = angularHelper.getCurrentForm($scope);
currForm.$setDirty();
alreadyDirty = true;
}
}
tinyMceService.configuration().then(function (tinyMceConfig) {
//config value from general tinymce.config file
@@ -147,27 +163,18 @@ angular.module("umbraco")
//when buttons modify content
editor.on('ExecCommand', function (e) {
editor.save();
angularHelper.safeApply($scope, function () {
$scope.model.value = editor.getContent();
});
syncContent(editor);
});
// Update model on keypress
editor.on('KeyUp', function (e) {
editor.save();
angularHelper.safeApply($scope, function () {
$scope.model.value = editor.getContent();
});
syncContent(editor);
});
// Update model on change, i.e. copy/pasted text, plugins altering content
editor.on('SetContent', function (e) {
if (!e.initial) {
editor.save();
angularHelper.safeApply($scope, function () {
$scope.model.value = editor.getContent();
});
syncContent(editor);
}
});
@@ -177,6 +184,8 @@ angular.module("umbraco")
var srcAttr = $(e.target).attr("src");
var path = srcAttr.split("?")[0];
$(e.target).attr("data-mce-src", path + qs);
syncContent(editor);
});