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

Commit a459764

Browse files
alexbowerswesleycho
authored andcommitted
Allow the retrieval of raw content (non-html formatted) when configured with raw option
Closes #130
1 parent 51ab591 commit a459764

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/tinymce.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ angular.module('ui.tinymce', [])
1515
}
1616

1717
var expression, options, tinyInstance,
18-
updateView = function() {
19-
ngModel.$setViewValue(element.val());
18+
updateView = function (editor) {
19+
if(typeof options.raw !== 'undefined' && options.raw == true) {
20+
ngModel.$setViewValue(editor.getContent({format: 'text'}).trim());
21+
} else {
22+
ngModel.$setViewValue(elm.val());
23+
}
2024
if (!$rootScope.$$phase) {
2125
scope.$apply();
2226
}
@@ -48,18 +52,18 @@ angular.module('ui.tinymce', [])
4852
// Update model on button click
4953
ed.on('ExecCommand', function(e) {
5054
ed.save();
51-
updateView();
55+
updateView(ed);
5256
});
5357
// Update model on keypress
5458
ed.on('KeyUp', function(e) {
5559
ed.save();
56-
updateView();
60+
updateView(ed);
5761
});
5862
// Update model on change, i.e. copy/pasted text, plugins altering content
5963
ed.on('SetContent', function(e) {
6064
if (!e.initial && ngModel.$viewValue !== e.content) {
6165
ed.save();
62-
updateView();
66+
updateView(ed);
6367
}
6468
});
6569
ed.on('blur', function(e) {
@@ -68,7 +72,7 @@ angular.module('ui.tinymce', [])
6872
// Update model when an object has been resized (table, image)
6973
ed.on('ObjectResized', function(e) {
7074
ed.save();
71-
updateView();
75+
updateView(ed);
7276
});
7377
if (configSetup) {
7478
configSetup(ed);

0 commit comments

Comments
 (0)