Skip to content

Commit

Permalink
fix(core): Notify sgCkeditor component when clicking the send button …
Browse files Browse the repository at this point in the history
…to update content. Fixes #5952.
  • Loading branch information
WoodySlum committed Apr 29, 2024
1 parent 9b5a8cb commit c2d9050
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
19 changes: 6 additions & 13 deletions UI/WebServerResources/js/Common/sgCkeditor.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
var editorChangedTimerValue = 2000;
var editorChangedTimer = null;


this.$onInit = function () {
vm.ngModelCtrl.$render = function () {
content = vm.ngModelCtrl.$viewValue;
Expand Down Expand Up @@ -280,18 +279,12 @@

// Add Emoticons
editor.plugins.get('SpecialCharacters').addItems('Emoji', emojis, { label: 'Emoticons' });

// if (vm.ckMargin) {
// // Set the margin of the iframe editable content
// vm.editor.editing.view.domRoots.get("main").style.marginTop = vm.ckMargin;
// vm.editor.editing.view.domRoots.get("main").style.marginLeft = vm.ckMargin;
// vm.editor.editing.view.domRoots.get("main").style.marginRight = vm.ckMargin;
// }

vm.editor.model.document.on('pasteState', function () { onEditorChange(false); });
vm.editor.model.document.on('change:data', function () { onEditorChange(false); });
vm.editor.model.document.on('paste', function () { onEditorChange(false); });
editor.editing.view.document.on('blur', function () { onEditorChange(true); });
vm.editor.model.document.on('pasteState', function () { vm.onEditorChange(false); });
vm.editor.model.document.on('change:data', function () { vm.onEditorChange(false); });
vm.editor.model.document.on('paste', function () { vm.onEditorChange(false); });
vm.editor.editing.view.document.on('blur', function () { vm.onEditorChange(true); });
vm.editor.component = this;

onInstanceReady();

Expand Down Expand Up @@ -341,7 +334,7 @@
vm.editor.destroy(noUpdate);
}

function onEditorChange(force) {
this.onEditorChange = function(force) {
if (editorChangedTimer)
clearTimeout(editorChangedTimer);

Expand Down
5 changes: 5 additions & 0 deletions UI/WebServerResources/js/Mailer/MessageEditorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
this.sendState = false;
this.toggleFullscreen = toggleFullscreen;
this.firstFocus = true;
this.editor = null;

_initFileUploader();

Expand Down Expand Up @@ -251,6 +252,9 @@
};

this.send = function () {
if (this.editor && this.editor.component)
this.editor.component.onEditorChange(true); // Call onEditorChange on sgCkEditor component

this.sendState = 'sending';
if (this.autosave)
$timeout.cancel(this.autosave);
Expand Down Expand Up @@ -527,6 +531,7 @@

this.onHTMLReady = function ($editor) {
if (!this.isNew()) {
this.editor = $editor;
onCompletePromise().then(function() {
$editor.focus();
});
Expand Down

0 comments on commit c2d9050

Please sign in to comment.