From 280a1a9313088c8650174470ffce5d9dc186460b Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 24 May 2022 14:37:47 +0300 Subject: [PATCH 1/3] cs fix --- client/src/views/fields/wysiwyg.js | 102 +++++++++++++++-------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/client/src/views/fields/wysiwyg.js b/client/src/views/fields/wysiwyg.js index 954e05bd69..b417c2b76b 100644 --- a/client/src/views/fields/wysiwyg.js +++ b/client/src/views/fields/wysiwyg.js @@ -468,21 +468,21 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function attachment.set('file', e.target.result); attachment.set('field', this.name); - attachment.once('sync', () => { - var url = '?entryPoint=attachment&id=' + attachment.id; - this.$summernote.summernote('insertImage', url); + attachment + .save() + .then(() => { + let url = '?entryPoint=attachment&id=' + attachment.id; + this.$summernote.summernote('insertImage', url); - this.notify(false); - }); - - attachment.save(); + Espo.Ui.notify(false); + }); }; fileReader.readAsDataURL(file); }); }, onBlur: () => { - this.trigger('change') + this.trigger('change'); }, }, onCreateLink: function (link) { @@ -527,50 +527,50 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function this.$area.on('paste', (e) => { var items = e.originalEvent.clipboardData.items; - if (items) { - for (var i = 0; i < items.length; i++) { - if (!~items[i].type.indexOf('image')) { - continue; - } + if (!items) { + return; + } - let file = items[i].getAsFile(); - - e.preventDefault(); - e.stopPropagation(); - - let fileReader = new FileReader(); - - fileReader.onload = e => { - this.getModelFactory().create('Attachment', attachment => { - - attachment.set('name', file.name); - attachment.set('type', file.type); - attachment.set('role', 'Inline Attachment'); - attachment.set('global', true); - attachment.set('size', file.size); - - if (this.model.id) { - attachment.set('relatedId', this.model.id); - } - - attachment.set('relatedType', this.model.name); - attachment.set('file', e.target.result); - attachment.set('field', this.name); - - attachment - .save() - .then(() => { - let url = '?entryPoint=attachment&id=' + attachment.id; - this.$summernote.summernote('insertImage', url); - - this.notify(false); - }); - - }); - }; - - fileReader.readAsDataURL(file); + for (var i = 0; i < items.length; i++) { + if (!~items[i].type.indexOf('image')) { + continue; } + + let file = items[i].getAsFile(); + + e.preventDefault(); + e.stopPropagation(); + + let fileReader = new FileReader(); + + fileReader.onload = e => { + this.getModelFactory().create('Attachment', attachment => { + attachment.set('name', file.name); + attachment.set('type', file.type); + attachment.set('role', 'Inline Attachment'); + attachment.set('global', true); + attachment.set('size', file.size); + + if (this.model.id) { + attachment.set('relatedId', this.model.id); + } + + attachment.set('relatedType', this.model.name); + attachment.set('file', e.target.result); + attachment.set('field', this.name); + + attachment + .save() + .then(() => { + let url = '?entryPoint=attachment&id=' + attachment.id; + this.$summernote.summernote('insertImage', url); + + Espo.Ui.notify(false); + }); + }); + }; + + fileReader.readAsDataURL(file); } }); }, @@ -979,11 +979,13 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function this.$window.off('resize.summernote' + self.cid); this.resizeTo({ h: this.$editable.data('orgHeight') }); this.$editable.css('maxHeight', this.$editable.css('orgMaxHeight')); + if (this.isInModal) { this.$modal.css('overflow-y', ''); } else { this.$scrollbar.css('overflow', ''); } + this._isFullscreen = false; } From fe15eeeac71d81ec100b52326e52cfd4251f0271 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 24 May 2022 16:08:48 +0300 Subject: [PATCH 2/3] wysiwyg fix paste upload duplicate --- client/src/views/fields/wysiwyg.js | 100 +++++++++-------------------- 1 file changed, 29 insertions(+), 71 deletions(-) diff --git a/client/src/views/fields/wysiwyg.js b/client/src/views/fields/wysiwyg.js index b417c2b76b..4a06f4212b 100644 --- a/client/src/views/fields/wysiwyg.js +++ b/client/src/views/fields/wysiwyg.js @@ -446,40 +446,17 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function keyMap: keyMap, callbacks: { onImageUpload: (files) => { - var file = files[0]; + let file = files[0]; - this.notify('Uploading...'); + Espo.Ui.notify(this.translate('Uploading...')); - this.getModelFactory().create('Attachment', (attachment) => { - var fileReader = new FileReader(); + this.uploadInlineAttachment(file) + .then(attachment => { + let url = '?entryPoint=attachment&id=' + attachment.id; + this.$summernote.summernote('insertImage', url); - fileReader.onload = (e) => { - attachment.set('name', file.name); - attachment.set('type', file.type); - attachment.set('role', 'Inline Attachment'); - attachment.set('global', true); - attachment.set('size', file.size); - - if (this.model.id) { - attachment.set('relatedId', this.model.id); - } - - attachment.set('relatedType', this.model.name); - attachment.set('file', e.target.result); - attachment.set('field', this.name); - - attachment - .save() - .then(() => { - let url = '?entryPoint=attachment&id=' + attachment.id; - this.$summernote.summernote('insertImage', url); - - Espo.Ui.notify(false); - }); - }; - - fileReader.readAsDataURL(file); - }); + Espo.Ui.notify(false); + }); }, onBlur: () => { this.trigger('change'); @@ -523,55 +500,36 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function this.$toolbar = this.$el.find('.note-toolbar'); this.$area = this.$el.find('.note-editing-area'); + }, - this.$area.on('paste', (e) => { - var items = e.originalEvent.clipboardData.items; - - if (!items) { - return; - } - - for (var i = 0; i < items.length; i++) { - if (!~items[i].type.indexOf('image')) { - continue; - } - - let file = items[i].getAsFile(); - - e.preventDefault(); - e.stopPropagation(); - + uploadInlineAttachment: function (file) { + return new Promise((resolve, reject) => { + this.getModelFactory().create('Attachment', attachment => { let fileReader = new FileReader(); - fileReader.onload = e => { - this.getModelFactory().create('Attachment', attachment => { - attachment.set('name', file.name); - attachment.set('type', file.type); - attachment.set('role', 'Inline Attachment'); - attachment.set('global', true); - attachment.set('size', file.size); + fileReader.onload = (e) => { + attachment.set('name', file.name); + attachment.set('type', file.type); + attachment.set('role', 'Inline Attachment'); + attachment.set('global', true); + attachment.set('size', file.size); - if (this.model.id) { - attachment.set('relatedId', this.model.id); - } + if (this.model.id) { + attachment.set('relatedId', this.model.id); + } - attachment.set('relatedType', this.model.name); - attachment.set('file', e.target.result); - attachment.set('field', this.name); + attachment.set('relatedType', this.model.name); + attachment.set('file', e.target.result); + attachment.set('field', this.name); - attachment - .save() - .then(() => { - let url = '?entryPoint=attachment&id=' + attachment.id; - this.$summernote.summernote('insertImage', url); - - Espo.Ui.notify(false); - }); - }); + attachment + .save() + .then(() => resolve(attachment)) + .catch(() => reject()); }; fileReader.readAsDataURL(file); - } + }); }); }, From bd2204156e075d300ba14f0668e911a6d11ab60c Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 24 May 2022 16:14:19 +0300 Subject: [PATCH 3/3] v --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c458c664a..a7869a4284 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "espocrm", - "version": "7.1.6", + "version": "7.1.7", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 268ff9d43f..63040f3085 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "espocrm", - "version": "7.1.6", + "version": "7.1.7", "description": "Open-source CRM.", "repository": { "type": "git",