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

Commit 4f6b0f6

Browse files
douglasg14bdeeg
authored andcommitted
enhancement: allows disabling of debouncing
Debouncing can be disabled by passing a false value to the debounce option. Defaults to true. Also protects a digest call. Closes #256 Closes #257 Closes #248
1 parent 0f1c5a8 commit 4f6b0f6

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ In addition, it supports these additional optional options
100100
- `format` Format to get content as, i.e. 'raw' for raw HTML, or 'text' for text only. Defaults to 'html'. Documentation [here](http://www.tinymce.com/wiki.php/api4:method.tinymce.Editor.getContent)
101101
- `trusted` When `true`, all TinyMCE content that is set to `ngModel` will be whitelisted by `$sce`
102102
- `baseURL` This will set [baseURL property on the EditorManager](https://www.tinymce.com/docs/api/class/tinymce.editormanager/)
103+
- `debounce` This will debounce the model update which helps with performance of editors with large text. Defaults to true.
103104

104105
This option is only supported when present on the `uiTinymceConfig` global injectable - this injectable needs to be an object.
105106

dist/tinymce.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tinymce.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ angular.module('ui.tinymce', [])
2222
var ngModel = ctrls[0],
2323
form = ctrls[1] || null;
2424

25-
var expression, options = {}, tinyInstance,
25+
var expression, options = {
26+
debounce: true
27+
}, tinyInstance,
2628
updateView = function(editor) {
2729
var content = editor.getContent({format: options.format}).trim();
2830
content = $sce.trustAsHtml(content);
@@ -79,7 +81,7 @@ angular.module('ui.tinymce', [])
7981
ed.on('init', function() {
8082
ngModel.$render();
8183
ngModel.$setPristine();
82-
ngModel.$setUntouched();
84+
ngModel.$setUntouched();
8385
if (form) {
8486
form.$setPristine();
8587
}
@@ -91,13 +93,20 @@ angular.module('ui.tinymce', [])
9193
// - the node has changed [NodeChange]
9294
// - an object has been resized (table, image) [ObjectResized]
9395
ed.on('ExecCommand change NodeChange ObjectResized', function() {
96+
if (!options.debounce) {
97+
ed.save();
98+
updateView(ed);
99+
return;
100+
}
94101
debouncedUpdate(ed);
95102
});
96103

97104
ed.on('blur', function() {
98105
element[0].blur();
99106
ngModel.$setTouched();
100-
scope.$digest();
107+
if (!$rootScope.$$phase) {
108+
scope.$digest();
109+
}
101110
});
102111

103112
ed.on('remove', function() {

0 commit comments

Comments
 (0)