Skip to content

Commit 6c7d879

Browse files
authored
Merge pull request #119 from magento-trigger/team3-delivery
[Trigger] Editing Text Content Block from the Stage with TinyMCE 4 turned on
2 parents 1cc1119 + d70ba60 commit 6c7d879

File tree

89 files changed

+2558
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2558
-357
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Block;
10+
11+
use Magento\Framework\View\Element\Template;
12+
use Magento\Framework\DataObject;
13+
14+
/**
15+
* @api
16+
*/
17+
class WysiwygSetup extends Template
18+
{
19+
/**
20+
* @var \Magento\Ui\Component\Wysiwyg\ConfigInterface
21+
*/
22+
private $config;
23+
24+
/**
25+
* @param Template\Context $context
26+
* @param \Magento\Ui\Component\Wysiwyg\ConfigInterface $config
27+
* @param array $data
28+
*/
29+
public function __construct(
30+
\Magento\Framework\View\Element\Template\Context $context,
31+
\Magento\Ui\Component\Wysiwyg\ConfigInterface $config,
32+
array $data = []
33+
) {
34+
$this->config = $config;
35+
parent::__construct($context, $data);
36+
}
37+
38+
/**
39+
* Get config for wysiwyg initialization
40+
*
41+
* @return string
42+
*/
43+
public function getConfigJson() : string
44+
{
45+
$config = $this->config->getConfig();
46+
47+
if (is_array($config)) {
48+
$config = new DataObject($config);
49+
}
50+
51+
return $config->toJson();
52+
}
53+
}

app/code/Magento/PageBuilder/Controller/Adminhtml/ContentType/Image/Upload.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class Upload extends \Magento\Backend\App\Action
3636
*/
3737
private $storeManager;
3838

39+
/**
40+
* @var \Magento\Cms\Helper\Wysiwyg\Images
41+
*/
42+
private $cmsWysiwygImages;
43+
3944
/**
4045
* Constructor
4146
*
@@ -44,19 +49,22 @@ class Upload extends \Magento\Backend\App\Action
4449
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
4550
* @param \Magento\Framework\File\UploaderFactory $uploaderFactory
4651
* @param \Magento\Framework\Filesystem\DirectoryList $directoryList
52+
* @param \Magento\Cms\Helper\Wysiwyg\Images $cmsWysiwygImages
4753
*/
4854
public function __construct(
4955
\Magento\Backend\App\Action\Context $context,
5056
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
5157
\Magento\Store\Model\StoreManagerInterface $storeManager,
5258
\Magento\Framework\File\UploaderFactory $uploaderFactory,
53-
\Magento\Framework\Filesystem\DirectoryList $directoryList
59+
\Magento\Framework\Filesystem\DirectoryList $directoryList,
60+
\Magento\Cms\Helper\Wysiwyg\Images $cmsWysiwygImages
5461
) {
5562
parent::__construct($context);
5663
$this->resultJsonFactory = $resultJsonFactory;
5764
$this->storeManager = $storeManager;
5865
$this->uploaderFactory = $uploaderFactory;
5966
$this->directoryList = $directoryList;
67+
$this->cmsWysiwygImages = $cmsWysiwygImages;
6068
}
6169

6270
/**
@@ -89,6 +97,7 @@ public function execute()
8997
try {
9098
$result = $fileUploader->save($this->getUploadDir());
9199
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
100+
$result['id'] = $this->cmsWysiwygImages->idEncode($result['file']);
92101
$result['url'] = $baseUrl . $this->getFilePath(self::UPLOAD_DIR, $result['file']);
93102
} catch (\Exception $e) {
94103
$result = [
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Wysiwyg;
9+
10+
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
11+
12+
/**
13+
* Returns adapter config based on active editor path
14+
*/
15+
class Config implements ProviderInterface
16+
{
17+
/**
18+
* @var \Magento\Cms\Model\Wysiwyg\Config
19+
*/
20+
private $wysiwygConfig;
21+
22+
/**
23+
* @var \Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList
24+
*/
25+
private $inlineEditingChecker;
26+
27+
/**
28+
* @var \Magento\Ui\Block\Wysiwyg\ActiveEditor
29+
*/
30+
private $activeEditor;
31+
32+
/**
33+
* @var array
34+
*/
35+
private $additionalConfig;
36+
37+
/**
38+
* Config constructor.
39+
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
40+
* @param \Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker
41+
* @param \Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor
42+
* @param array $additionalConfig
43+
*/
44+
public function __construct(
45+
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
46+
\Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker,
47+
\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor,
48+
$additionalConfig = []
49+
) {
50+
$this->wysiwygConfig = $wysiwygConfig;
51+
$this->inlineEditingChecker = $inlineEditingChecker;
52+
$this->activeEditor = $activeEditor;
53+
$this->additionalConfig = $additionalConfig;
54+
}
55+
56+
/**
57+
* @inheritdoc
58+
*/
59+
public function getData(string $itemName) : array
60+
{
61+
$config = [];
62+
$activeEditorPath = $this->activeEditor->getWysiwygAdapterPath();
63+
if ($this->inlineEditingChecker->isSupported($activeEditorPath)) {
64+
$config['adapter'] = $this->wysiwygConfig->getConfig()->getData();
65+
if (isset($this->additionalConfig[$activeEditorPath])) {
66+
$config['additional'] = $this->additionalConfig[$activeEditorPath];
67+
}
68+
}
69+
return [$itemName => $config,];
70+
}
71+
}

app/code/Magento/PageBuilder/Model/Stage/Config.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ class Config
5858
*/
5959
private $scopeConfig;
6060

61+
/**
62+
* @var \Magento\Ui\Block\Wysiwyg\ActiveEditor
63+
*/
64+
private $activeEditor;
65+
66+
/**
67+
* @var \Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList
68+
*/
69+
private $inlineEditingChecker;
70+
6171
/**
6272
* Config constructor.
6373
* @param \Magento\PageBuilder\Model\ConfigInterface $config
@@ -66,6 +76,8 @@ class Config
6676
* @param \Magento\Framework\Url $frontendUrlBuilder
6777
* @param \Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Parser $additionalDataParser
6878
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
79+
* @param \Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor
80+
* @param \Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker
6981
* @param array $data
7082
*/
7183
public function __construct(
@@ -75,6 +87,8 @@ public function __construct(
7587
\Magento\Framework\Url $frontendUrlBuilder,
7688
\Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Parser $additionalDataParser,
7789
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
90+
\Magento\Ui\Block\Wysiwyg\ActiveEditor $activeEditor,
91+
\Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker,
7892
array $data = []
7993
) {
8094
$this->config = $config;
@@ -83,6 +97,8 @@ public function __construct(
8397
$this->frontendUrlBuilder = $frontendUrlBuilder;
8498
$this->additionalDataParser = $additionalDataParser;
8599
$this->scopeConfig = $scopeConfig;
100+
$this->activeEditor = $activeEditor;
101+
$this->inlineEditingChecker = $inlineEditingChecker;
86102
$this->data = $data;
87103
}
88104

@@ -101,6 +117,7 @@ public function getConfig()
101117
'preview_url' => $this->frontendUrlBuilder->getUrl('pagebuilder/contenttype/preview'),
102118
'column_grid_default' => $this->scopeConfig->getValue(self::XML_PATH_COLUMN_GRID_DEFAULT),
103119
'column_grid_max' => $this->scopeConfig->getValue(self::XML_PATH_COLUMN_GRID_MAX),
120+
'can_use_inline_editing_on_stage' => $this->isWysiwygProvisionedForEditingOnStage()
104121
];
105122
}
106123

@@ -170,4 +187,16 @@ private function flattenContentTypeData($name, $contentType)
170187
'is_visible' => isset($contentType['is_visible']) && $contentType['is_visible'] === 'false' ? false : true
171188
];
172189
}
190+
191+
/**
192+
* Determine if active editor is configured to support inline editing mode
193+
*
194+
* @return bool
195+
*/
196+
private function isWysiwygProvisionedForEditingOnStage()
197+
{
198+
$activeEditorPath = $this->activeEditor->getWysiwygAdapterPath();
199+
200+
return $this->inlineEditingChecker->isSupported($activeEditorPath);
201+
}
173202
}

app/code/Magento/PageBuilder/Model/Wysiwyg/DefaultConfigProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66
declare(strict_types=1);
7+
78
namespace Magento\PageBuilder\Model\Wysiwyg;
89

910
/**
@@ -38,8 +39,8 @@ public function getConfig(\Magento\Framework\DataObject $config): \Magento\Frame
3839
$config->addData([
3940
'tinymce4' => [
4041
'toolbar' => 'undo redo | styleselect | fontsizeselect | forecolor backcolor | bold italic underline' .
41-
' | alignleft aligncenter alignright | numlist bullist | link image table charmap' .
42-
' | widgets variables',
42+
' | alignleft aligncenter alignright | numlist bullist | link image table charmap',
43+
4344
'plugins' => implode(
4445
' ',
4546
[
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Model\Wysiwyg;
9+
10+
/**
11+
* Returns information if inline editing available by adapter path
12+
*/
13+
class InlineEditingSupportedAdapterList
14+
{
15+
/**
16+
* @var \Magento\Cms\Model\Wysiwyg\Config
17+
*/
18+
private $wysiwygConfig;
19+
20+
/**
21+
* @var array
22+
*/
23+
private $wysiwygAdaptersSupportingInlineEditing;
24+
25+
/**
26+
* InlineEditing constructor.
27+
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
28+
* @param array $wysiwygAdaptersSupportingInlineEditing
29+
*/
30+
public function __construct(
31+
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
32+
array $wysiwygAdaptersSupportingInlineEditing
33+
) {
34+
$this->wysiwygConfig = $wysiwygConfig;
35+
$this->wysiwygAdaptersSupportingInlineEditing = $wysiwygAdaptersSupportingInlineEditing;
36+
}
37+
38+
/**
39+
* Check if inline editing available for current adapter
40+
* @param string $editorPath
41+
* @return bool
42+
*/
43+
public function isSupported(string $editorPath) : bool
44+
{
45+
46+
return $this->wysiwygAdaptersSupportingInlineEditing[$editorPath] && $this->wysiwygConfig->isEnabled() ?? false;
47+
}
48+
}

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/ContentTypeImageActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<arguments>
3434
<argument name="property"/>
3535
</arguments>
36-
<comment userInput="Verify image A display on preview of slide-out" stepKey="commentVerifyImage"/>
36+
<comment userInput="Verify image display on preview of slide-out" stepKey="commentVerifyImage"/>
3737
<waitForElementVisible selector="{{ImageOnConfigurationPanel.imageName(property.value)}}" stepKey="seeImageNameOnPreview"/>
3838
<waitForElementVisible selector="{{ImageOnConfigurationPanel.imageSource(property.fileName)}}" stepKey="seeMainImageSource"/>
3939
</actionGroup>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/DragAndDropActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<argument name="offsetXCoordinate" defaultValue="null" type="string"/>
4949
<argument name="offsetYCoordinate" defaultValue="null" type="string"/>
5050
</arguments>
51+
<click selector="{{PageBuilderPanel.searchPanel}}" stepKey="lostFocus"/>
5152
<waitForElementVisible time="30" selector="{{PageBuilderPanel.draggableContentTypeInPanel(contentType.name)}}" stepKey="waitForContentTypeInPanel"/>
5253
<dragAndDrop selector1="{{PageBuilderPanel.draggableContentTypeInPanel(contentType.name)}}" selector2="{{PageBuilderStage.contentTypeContainer(containerTargetType.role, containerTargetIndex)}}" x="{{offsetXCoordinate}}" y="{{offsetYCoordinate}}" stepKey="dropContentTypeIntoStage"/>
5354
<waitForPageLoad stepKey="waitForAnimation" time="30"/>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/StageActionGroup.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,25 @@
5757
<waitForElementVisible time="30" selector="{{PageBuilderStage.contentTypeInStageByIndex(containerTargetType.role, containerTargetIndex)}}" stepKey="waitForContentTypeStage"/>
5858
<dontSeeElementInDOM selector="{{PageBuilderStage.contentTypeInsideContainerStage(containerTargetType.role, containerTargetIndex, positionInContainer, contentType.role, contentTypeIndex)}}" stepKey="dontSeeContentTypeInContainer"/>
5959
</actionGroup>
60+
<actionGroup name="goToMediaStorageFromStage">
61+
<arguments>
62+
<argument name="contentType"/>
63+
<argument name="section"/>
64+
<argument name="offsetXCoordinate" defaultValue="null" type="string"/>
65+
<argument name="offsetYCoordinate" defaultValue="null" type="string"/>
66+
</arguments>
67+
<comment userInput="Hover over content type in stage and click Select From Gallery button" stepKey="commentHover"/>
68+
<moveMouseOver selector="{{PageBuilderStage.contentTypeInStage(contentType.role)}}" x="{{offsetXCoordinate}}" y="{{offsetYCoordinate}}" stepKey="onMouseOverImageContentTypeStage"/>
69+
<waitForElementVisible selector="{{section.selectFromGalleryImageBtn}}" stepKey="seeSelectFromGalleryBtn2" />
70+
<click selector="{{section.selectFromGalleryImageBtn}}" stepKey="clickSelectFromGalleryBtn1" />
71+
<waitForPageLoad stepKey="waitForPageLoad"/>
72+
</actionGroup>
73+
<actionGroup name="uploadImageToContentTypeFromStage">
74+
<arguments>
75+
<argument name="property"/>
76+
</arguments>
77+
<attachFile userInput="{{property.value}}" selector="{{PageBuilderStage.uploadLocalImageBtn}}" stepKey="attachImageFromLocalToStage"/>
78+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/>
79+
<waitForElementVisible selector="{{PageBuilderStage.imageSource(property.fileName)}}" stepKey="waitForMainImageSource1"/>
80+
</actionGroup>
6081
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/WYSIWYGActionGroup.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
<waitForElementVisible selector="{{VariableSection.InsertWidget}}" stepKey="waitForInsertVariable2"/>
3636
<click selector="{{VariableSection.InsertWidget}}" stepKey="clickInsertVariable2"/>
3737
<waitForElementNotVisible selector="{{VariableSection.InsertWidget}}" stepKey="waitForVariableModalToClose"/>
38-
<switchToIFrame selector="{{TextOnConfiguration.tinyMCEIFrame}}" stepKey="switchToIFrame"/>
39-
<waitForElementVisible selector="{{TextOnConfiguration.tinyMCEVariable(variable.editPanelValue, '1')}}" stepKey="waitForVariable2"/>
40-
<switchToIFrame stepKey="exitIFrame"/>
4138
</actionGroup>
4239
<actionGroup name="addPageLinkVariableWYSIWYGDisabled">
4340
<arguments>
@@ -84,9 +81,6 @@
8481
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidget2"/>
8582
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear5"/>
8683
<waitForElementNotVisible selector="{{WidgetSection.InsertWidget}}" stepKey="waitForInsertWidgetModalToClose"/>
87-
<switchToIFrame selector="{{TextOnConfiguration.tinyMCEIFrame}}" stepKey="switchToIFrame"/>
88-
<waitForElementVisible selector="{{TextOnConfiguration.tinyMCEWidget(widget.editPanelValue, '1')}}" stepKey="waitForWidget"/>
89-
<switchToIFrame stepKey="exitIFrame"/>
9084
</actionGroup>
9185
<actionGroup name="addPageLinkWidgetWYSIWYGDisabled">
9286
<arguments>

0 commit comments

Comments
 (0)