Skip to content

Commit 81de379

Browse files
authored
Merge pull request #5061 from magento-engcom/adobe-stock-integration-fix-3
[Magento Community Engineering] Adobe Stock Integration Bug Fixes
2 parents d9df1c2 + f3f1028 commit 81de379

File tree

5 files changed

+92
-11
lines changed

5 files changed

+92
-11
lines changed

app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ define([
7878
}
7979

8080
tinyMCE3.init(this.getSettings(mode));
81+
varienGlobalEvents.clearEventHandlers('open_browser_callback');
82+
varienGlobalEvents.attachEventHandler('open_browser_callback', tinyMceEditors.get(this.id).openFileBrowser);
8183
},
8284

8385
/**

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55
define([
66
'jquery',
7-
'Magento_Ui/js/grid/columns/column'
8-
], function ($, Column) {
7+
'Magento_Ui/js/grid/columns/column',
8+
'Magento_Ui/js/lib/key-codes'
9+
], function ($, Column, keyCodes) {
910
'use strict';
1011

1112
return Column.extend({
@@ -30,13 +31,26 @@ define([
3031
},
3132
listens: {
3233
'${ $.provider }:params.filters': 'hide',
33-
'${ $.provider }:params.search': 'hide'
34+
'${ $.provider }:params.search': 'hide',
35+
'${ $.provider }:params.paging': 'hide'
3436
},
3537
exports: {
3638
height: '${ $.parentName }.thumbnail_url:previewHeight'
3739
}
3840
},
3941

42+
/**
43+
* Initialize image preview component
44+
*
45+
* @returns {Object}
46+
*/
47+
initialize: function () {
48+
this._super();
49+
$(document).on('keydown', this.handleKeyDown.bind(this));
50+
51+
return this;
52+
},
53+
4054
/**
4155
* Init observable variables
4256
* @return {Object}
@@ -59,8 +73,13 @@ define([
5973
* @param {Object} record
6074
*/
6175
next: function (record) {
62-
var recordToShow = this.getRecord(record._rowIndex + 1);
76+
var recordToShow;
77+
78+
if (record._rowIndex + 1 === this.masonry().rows().length) {
79+
return;
80+
}
6381

82+
recordToShow = this.getRecord(record._rowIndex + 1);
6483
recordToShow.rowNumber = record.lastInRow ? record.rowNumber + 1 : record.rowNumber;
6584
this.show(recordToShow);
6685
},
@@ -71,7 +90,12 @@ define([
7190
* @param {Object} record
7291
*/
7392
prev: function (record) {
74-
var recordToShow = this.getRecord(record._rowIndex - 1);
93+
var recordToShow;
94+
95+
if (record._rowIndex === 0) {
96+
return;
97+
}
98+
recordToShow = this.getRecord(record._rowIndex - 1);
7599

76100
recordToShow.rowNumber = record.firstInRow ? record.rowNumber - 1 : record.rowNumber;
77101
this.show(recordToShow);
@@ -205,6 +229,23 @@ define([
205229
block: 'center',
206230
inline: 'nearest'
207231
});
232+
},
233+
234+
/**
235+
* Handle keyboard navigation for image preview
236+
*
237+
* @param {Object} e
238+
*/
239+
handleKeyDown: function (e) {
240+
var key = keyCodes[e.keyCode];
241+
242+
if (this.visibleRecord() !== null) {
243+
if (key === 'pageLeftKey') {
244+
this.prev(this.displayedRecord());
245+
} else if (key === 'pageRightKey') {
246+
this.next(this.displayedRecord());
247+
}
248+
}
208249
}
209250
});
210251
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'wysiwygAdapter',
8+
'underscore'
9+
], function (wysiwygAdapter, _) {
10+
'use strict';
11+
12+
var obj;
13+
14+
beforeEach(function () {
15+
16+
/**
17+
* Dummy constructor to use for instantiation
18+
* @constructor
19+
*/
20+
var Constr = function () {};
21+
22+
Constr.prototype = wysiwygAdapter;
23+
24+
obj = new Constr();
25+
obj.eventBus = new window.varienEvents();
26+
obj.initialize(1, {
27+
'store_id': 0,
28+
'tinymce4': {
29+
'content_css': ''
30+
},
31+
'files_browser_window_url': 'url'
32+
});
33+
obj.setup();
34+
});
35+
36+
describe('"openFileBrowser" method', function () {
37+
it('Opens file browser to given instance', function () {
38+
expect(_.size(obj.eventBus.arrEvents['open_browser_callback'])).toBe(1);
39+
});
40+
});
41+
});

lib/internal/Magento/Framework/Data/Form/Element/Editor.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ protected function _getPluginButtonsHtml($visible = true)
310310
if (isset($buttonOptions['style'])) {
311311
$configStyle = $buttonOptions['style'];
312312
}
313-
$buttonOptions = array_merge($buttonOptions, ['style' => 'display:none;' . $configStyle]);
313+
$buttonOptions['style'] = 'display:none; ' . $configStyle;
314314
}
315315
$buttonsHtml .= $this->_getButtonHtml($buttonOptions);
316316
}
@@ -409,7 +409,7 @@ protected function _getButtonHtml($data)
409409
protected function _wrapIntoContainer($html)
410410
{
411411
if (!$this->getConfig('use_container')) {
412-
return '<div class="admin__control-wysiwig">' .$html . '</div>';
412+
return '<div class="admin__control-wysiwig">' . $html . '</div>';
413413
}
414414

415415
$html = '<div id="editor' . $this->getHtmlId() . '"'
@@ -533,10 +533,6 @@ protected function getInlineJs($jsSetupObject, $forceLoad)
533533
$jsSetupObject .
534534
'));
535535
varienGlobalEvents.attachEventHandler("formSubmit", editorFormValidationHandler);
536-
varienGlobalEvents.clearEventHandlers("open_browser_callback");
537-
varienGlobalEvents.attachEventHandler("open_browser_callback", ' .
538-
$jsSetupObject .
539-
'.openFileBrowser);
540536
//]]>
541537
});
542538
</script>';

lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ define([
118118
tinyMCE4.init(settings);
119119
this.getPluginButtons().hide();
120120
varienGlobalEvents.clearEventHandlers('open_browser_callback');
121+
this.eventBus.clearEventHandlers('open_browser_callback');
121122
this.eventBus.attachEventHandler('open_browser_callback', tinyMceEditors.get(self.id).openFileBrowser);
122123
}.bind(this));
123124
},

0 commit comments

Comments
 (0)