[FIX] web_editor: fix mail template toolbar in debug mode
Issue
- Install Mail template
- Enable debug mode (normal or assets)
- Create or edit a mail template
- Click in the text editor
The toolbar is not showing up (it does when we're not in debug mode)
Cause
We are doing `splice(-1, 0, ['view', ['codeview']])` on toolbar
which is undefined, the method crashes and the toolbar doesn't
render.
Solution
Checking if the toolbar is defined before doing all that logic.
OPW-2151675
X-original-commit: 0e5ca50d5a8401bb3495e83691eab5c86a97a616
This commit is contained in:
@@ -200,7 +200,8 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
|
||||
tabsize: 0,
|
||||
height: 180,
|
||||
generateOptions: function (options) {
|
||||
var para = _.find(options.toolbar, function (item) {
|
||||
var toolbar = options.toolbar || options.airPopover || {};
|
||||
var para = _.find(toolbar, function (item) {
|
||||
return item[0] === 'para';
|
||||
});
|
||||
if (para && para[1] && para[1].indexOf('checklist') === -1) {
|
||||
@@ -208,7 +209,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
|
||||
}
|
||||
if (config.isDebug()) {
|
||||
options.codeview = true;
|
||||
var view = _.find(options.toolbar, function (item) {
|
||||
var view = _.find(toolbar, function (item) {
|
||||
return item[0] === 'view';
|
||||
});
|
||||
if (view) {
|
||||
@@ -216,7 +217,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
|
||||
view[1].splice(-1, 0, 'codeview');
|
||||
}
|
||||
} else {
|
||||
options.toolbar.splice(-1, 0, ['view', ['codeview']]);
|
||||
toolbar.splice(-1, 0, ['view', ['codeview']]);
|
||||
}
|
||||
}
|
||||
options.prettifyHtml = false;
|
||||
|
||||
Reference in New Issue
Block a user