From 1e44ff4fb6398b15139c9f13548a71ab8a6ce6ee Mon Sep 17 00:00:00 2001 From: Paulius R Date: Mon, 4 Jul 2016 12:57:53 +0300 Subject: [PATCH] Added option updateOnBlurOnly to update ngmodel only on editor blur --- src/tinymce.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/tinymce.js b/src/tinymce.js index 1ce5c6e..2d90cf7 100644 --- a/src/tinymce.js +++ b/src/tinymce.js @@ -87,19 +87,21 @@ angular.module('ui.tinymce', []) } }); - // Update model when: - // - a button has been clicked [ExecCommand] - // - the editor content has been modified [change] - // - the node has changed [NodeChange] - // - an object has been resized (table, image) [ObjectResized] - ed.on('ExecCommand change NodeChange ObjectResized', function() { - if (!options.debounce) { - ed.save(); - updateView(ed); - return; - } - debouncedUpdate(ed); - }); + if (!options.updateOnBlurOnly) { + // Update model when: + // - a button has been clicked [ExecCommand] + // - the editor content has been modified [change] + // - the node has changed [NodeChange] + // - an object has been resized (table, image) [ObjectResized] + ed.on('ExecCommand change NodeChange ObjectResized', function() { + if (!options.debounce) { + ed.save(); + updateView(ed); + return; + } + debouncedUpdate(ed); + }); + } ed.on('blur', function() { element[0].blur();