Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions angular-redactor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(function () {
'use strict';

/**
* usage: <textarea ng-model="content" redactor></textarea>
*
Expand All @@ -16,10 +15,13 @@
link: function (scope, element, attrs, ngModel) {

var updateModel = function updateModel(value) {
scope.$apply(function () {
ngModel.$setViewValue(value);
});
},
/* fix for html code view in redactor v9.2.1+ */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if you did the 9.2.1 work in the angular-redactor-9.x version, the 10.0 version changed quite a bit.

if(element.not(':visible')) {
scope.$apply(function () {
ngModel.$setViewValue(value);
});
}
},
options = {
changeCallback: updateModel
},
Expand All @@ -30,8 +32,7 @@

angular.extend(options, additionalOptions);

// put in timeout to avoid $digest collision. call render() to
// set the initial value.
// put in timeout to avoid $digest collision. call render() to set the initial value.
$timeout(function () {
editor = $_element.redactor(options);
ngModel.$render();
Expand All @@ -41,6 +42,7 @@
if (angular.isDefined(editor)) {
$timeout(function() {
$_element.redactor('set', ngModel.$viewValue || '');
ngForm.$setPristine();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this in for this version, and it'd be nice to add in the 9.2.x file version.

});
}
};
Expand Down