Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit fd13540

Browse files
leonex-cs1wesleycho
authored andcommitted
Stop duplicate calls to setContent
Closes #107
1 parent eb9421c commit fd13540

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/tinymce.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ angular.module('ui.tinymce', [])
9090
if (!tinyInstance) {
9191
tinyInstance = tinymce.get(attrs.id);
9292
}
93-
if (tinyInstance) {
93+
94+
var format = options.raw ? 'text' : 'raw';
95+
96+
// tinymce replaces "\r\n" to "\n", so we have to do the same on model value
97+
if (tinyInstance &&
98+
tinyInstance.getContent({format: format}).trim() !== ngModel.$viewValue.replace(/\r\n/g, '\n')
99+
) {
94100
tinyInstance.setContent(ngModel.$viewValue);
95101
}
96102
};

0 commit comments

Comments
 (0)