mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-04 11:27:02 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddc90a05d9 | ||
|
|
bbbadb1c32 | ||
|
|
8995835d8e | ||
|
|
df3c119f5f |
@@ -164,8 +164,8 @@
|
||||
},
|
||||
"body": {
|
||||
"type": "wysiwyg",
|
||||
"seeMoreDisabled": true,
|
||||
"view": "views/email/fields/body"
|
||||
"view": "views/email/fields/body",
|
||||
"attachmentField": "attachments"
|
||||
},
|
||||
"isHtml": {
|
||||
"type": "bool",
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
{
|
||||
"name":"readOnly",
|
||||
"type":"bool"
|
||||
},
|
||||
{
|
||||
"name": "attachmentField",
|
||||
"type": "varchar",
|
||||
"hidden": true
|
||||
}
|
||||
],
|
||||
"filter": true,
|
||||
|
||||
@@ -68,7 +68,7 @@ Espo.define('views/email/record/compose', ['views/record/edit', 'views/email/rec
|
||||
}
|
||||
|
||||
this.listenTo(this.model, 'insert-template', function (data) {
|
||||
var body = this.model.get('body');
|
||||
var body = this.model.get('body') || '';
|
||||
|
||||
var bodyPlain = body.replace(/<br\s*\/?>/mg, '');
|
||||
bodyPlain = bodyPlain.replace(/<\/p\s*\/?>/mg, '');
|
||||
|
||||
@@ -64,6 +64,29 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
['misc',['codeview', 'fullscreen']]
|
||||
];
|
||||
|
||||
this.buttons = {};
|
||||
|
||||
if (!this.params.toolbar) {
|
||||
if (this.params.attachmentField) {
|
||||
this.toolbar.push([
|
||||
'attachment',
|
||||
['attachment']
|
||||
]);
|
||||
var AttachmentButton = function (context) {
|
||||
var ui = $.summernote.ui;
|
||||
var button = ui.button({
|
||||
contents: '<i class="glyphicon glyphicon-paperclip"></i>',
|
||||
tooltip: this.translate('Attach File'),
|
||||
click: function () {
|
||||
this.attachFile();
|
||||
}.bind(this)
|
||||
});
|
||||
return button.render();
|
||||
}.bind(this);
|
||||
this.buttons['attachment'] = AttachmentButton;
|
||||
}
|
||||
}
|
||||
|
||||
this.listenTo(this.model, 'change:isHtml', function (model) {
|
||||
if (this.mode == 'edit') {
|
||||
if (this.isRendered()) {
|
||||
@@ -99,6 +122,9 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
|
||||
this.once('remove', function () {
|
||||
$(window).off('resize.' + this.cid);
|
||||
if (this.$scrollable) {
|
||||
this.$scrollable.off('scroll.' + this.cid + '-edit');
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -305,11 +331,22 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
this.trigger('change')
|
||||
}.bind(this),
|
||||
},
|
||||
toolbar: this.toolbar
|
||||
toolbar: this.toolbar,
|
||||
buttons: this.buttons
|
||||
};
|
||||
|
||||
if (this.height) {
|
||||
options.height = this.height;
|
||||
} else {
|
||||
var $scrollable = this.$el.closest('.modal-body');
|
||||
if (!$scrollable.size()) {
|
||||
$scrollable = $(window);
|
||||
}
|
||||
this.$scrollable = $scrollable;
|
||||
$scrollable.off('scroll.' + this.cid + '-edit');
|
||||
$scrollable.on('scroll.' + this.cid + '-edit', function (e) {
|
||||
this.onScrollEdit(e);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
if (this.minHeight) {
|
||||
@@ -317,6 +354,9 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
}
|
||||
|
||||
this.$summernote.summernote(options);
|
||||
|
||||
this.$toolbar = this.$el.find('.note-toolbar');
|
||||
this.$area = this.$el.find('.note-editing-area');
|
||||
},
|
||||
|
||||
plainToHtml: function (html) {
|
||||
@@ -346,6 +386,10 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
this.$summernote.addClass('hidden');
|
||||
}
|
||||
this.$element.removeClass('hidden');
|
||||
|
||||
if (this.$scrollable) {
|
||||
this.$scrollable.off('scroll.' + this.cid + '-edit');
|
||||
}
|
||||
},
|
||||
|
||||
fetch: function () {
|
||||
@@ -364,7 +408,58 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
onScrollEdit: function (e) {
|
||||
var $target = $(e.target);
|
||||
var toolbarHeight = this.$toolbar.height();
|
||||
var top;
|
||||
if ($target.get(0) === window.document) {
|
||||
var $buttonContainer = $target.find('.detail-button-container:not(.hidden)');
|
||||
var offset = $buttonContainer.offset();
|
||||
if (offset) {
|
||||
var edgeTop = offset.top + $buttonContainer.height();
|
||||
var edgeTopAbsolute = edgeTop - $(window).scrollTop();
|
||||
}
|
||||
} else {
|
||||
var offset = $target.offset();
|
||||
if (offset) {
|
||||
var edgeTop = offset.top;
|
||||
var edgeTopAbsolute = edgeTop;
|
||||
}
|
||||
}
|
||||
|
||||
var top = this.$el.offset().top;
|
||||
var bottom = top + this.$el.height() - toolbarHeight;
|
||||
|
||||
var toStick = false;
|
||||
if (edgeTop > top && bottom > edgeTop) {
|
||||
toStick = true;
|
||||
}
|
||||
|
||||
if (toStick) {
|
||||
this.$toolbar.css({
|
||||
top: edgeTopAbsolute + 'px'
|
||||
});
|
||||
this.$toolbar.addClass('sticked');
|
||||
this.$area.css({
|
||||
marginTop: toolbarHeight + 'px',
|
||||
backgroundColor: ''
|
||||
});
|
||||
} else {
|
||||
this.$toolbar.css({
|
||||
top: ''
|
||||
});
|
||||
this.$toolbar.removeClass('sticked');
|
||||
this.$area.css({
|
||||
marginTop: ''
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
attachFile: function () {
|
||||
var $form = this.$el.closest('.record');
|
||||
$form.find('.field[data-name="'+this.params.attachmentField+'"] input.file').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1970,6 +1970,12 @@ pre > code {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.note-editor .note-toolbar.sticked {
|
||||
z-index: 1;
|
||||
position: fixed;
|
||||
background-color: @white-color;
|
||||
}
|
||||
|
||||
@media screen and (min-width: @screen-sm-min) {
|
||||
#global-search-panel {
|
||||
margin-top: 5px;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "5.2.1",
|
||||
"version": "5.2.2",
|
||||
"description": "",
|
||||
"main": "index.php",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user