39 parent::__construct($factoryElement, $factoryCollection, $escaper,
$data);
43 $this->setExtType(
'wysiwyg');
46 $this->setExtType(
'textarea');
57 $buttonTranslations = [
58 'Insert Image...' => $this->
translate(
'Insert Image...'),
59 'Insert Media...' => $this->
translate(
'Insert Media...'),
60 'Insert File...' => $this->
translate(
'Insert File...'),
63 return $buttonTranslations;
75 return $this->serializer->serialize(
89 if (!is_array($this->
getConfig(
'plugins'))) {
95 $pluginArrIndex = array_search($pluginName, array_column($plugins,
'name'));
97 if ($pluginArrIndex ===
false || !isset($plugins[$pluginArrIndex][
'options'])) {
101 $pluginOptions = $plugins[$pluginArrIndex][
'options'];
104 return isset($pluginOptions[$key]) ? $pluginOptions[$key] :
null;
106 return $pluginOptions;
117 <script type="text/javascript"> 119 openEditorPopup = function(url, name, specs, parent) { 120 if ((typeof popups == "undefined") || popups[name] == undefined || popups[name].closed) { 121 if (typeof popups == "undefined") { 122 popups = new Array(); 124 var opener = (parent != undefined ? parent : window); 125 popups[name] = opener.open(url, name, specs); 127 popups[name].focus(); 132 closeEditorPopup = function(name) { 133 if ((typeof popups != "undefined") && popups[name] != undefined && !popups[name].closed) { 134 popups[name].close(); 141 $jsSetupObject =
'wysiwyg' . $this->
getHtmlId();
145 if ($this->getForceLoad()) {
146 $forceLoad = $jsSetupObject .
'.setup("exact");';
148 $forceLoad =
'jQuery(window).on("load", ' .
175 $js . $this->
getInlineJs($jsSetupObject, $forceLoad);
185 $html .=
'<script type="text/javascript"> 187 require(["jquery", "mage/translate", "mage/adminhtml/wysiwyg/widget"], function(jQuery){ 198 return parent::getElementHtml();
207 if (!$this->
hasData(
'theme')) {
221 $buttonsHtml =
'<div id="buttons' . $this->
getHtmlId() .
'" class="buttons-set">';
228 $buttonsHtml .=
'</div>';
243 'title' => $this->
translate(
'Show / Hide Editor'),
244 'class' =>
'action-show-hide',
245 'style' => $visible ?
'' :
'display:none',
268 'title' => $this->
translate(
'Insert Widget...'),
269 'onclick' =>
"widgetTools.openDialog('" 271 .
"widget_target_id/" . $this->
getHtmlId() .
"/')",
272 'class' =>
'action-add-widget plugin',
273 'style' => $visible ?
'' :
'display:none',
282 'title' => $this->
translate(
'Insert Image...'),
283 'onclick' =>
"MediabrowserUtility.openDialog('" 284 . $this->
getConfig(
'files_browser_window_url')
285 .
"target_element_id/" . $this->
getHtmlId() .
"/" 286 . (
null !== $this->
getConfig(
'store_id') ?
'store/' 287 . $this->
getConfig(
'store_id') .
'/' :
'')
289 'class' =>
'action-add-image plugin',
290 'style' => $visible ?
'' :
'display:none',
295 if (is_array($this->
getConfig(
'plugins'))) {
296 foreach ($this->
getConfig(
'plugins') as $plugin) {
301 if (isset($buttonOptions[
'style'])) {
302 $configStyle = $buttonOptions[
'style'];
304 $buttonOptions = array_merge($buttonOptions, [
'style' =>
'display:none;' . $configStyle]);
323 $buttonOptions[
'class'] =
'plugin';
328 return $buttonOptions;
339 if (!isset($pluginOptions[
'title'])) {
354 $preparedOptions = [];
357 $subject =
$value[
'subject'];
358 foreach (
$value[
'search'] as $part) {
359 $subject = str_replace(
'{{' . $part .
'}}', $this->
getDataUsingMethod($part), $subject);
361 $preparedOptions[
$name] = $subject;
366 return $preparedOptions;
378 $html =
'<button type="button"';
379 $html .=
' class="scalable ' . (isset(
$data[
'class']) ?
$data[
'class'] :
'') .
'"';
380 $html .= isset(
$data[
'onclick']) ?
' onclick="' .
$data[
'onclick'] .
'"' :
'';
381 $html .= isset(
$data[
'style']) ?
' style="' .
$data[
'style'] .
'"' :
'';
382 $html .= isset(
$data[
'id']) ?
' id="' .
$data[
'id'] .
'"' :
'';
384 $html .= isset(
$data[
'title']) ?
'<span><span><span>' .
$data[
'title'] .
'</span></span></span>' :
'';
385 $html .=
'</button>';
399 if (!$this->
getConfig(
'use_container')) {
400 return '<div class="admin__control-wysiwig">' .$html .
'</div>';
403 $html =
'<div id="editor' . $this->
getHtmlId() .
'"' 404 . ($this->
getConfig(
'no_display') ?
' style="display:none;"' :
'')
405 . ($this->
getConfig(
'container_class') ?
' class="admin__control-wysiwig ' 406 . $this->
getConfig(
'container_class') .
'"' :
'')
407 .
'>' . $html .
'</div>';
421 $config = new \Magento\Framework\DataObject();
425 return $this->
_getData(
'config')->getData($key);
438 return (
string)new \Magento\Framework\Phrase($string);
470 return !$this->
getConfig()->hasData(
'toggle_button') || $this->
getConfig(
'toggle_button');
483 <script type="text/javascript"> 485 window.tinyMCE_GZ = window.tinyMCE_GZ || {}; 486 window.tinyMCE_GZ.loaded = true; 490 "mage/adminhtml/events", 491 "mage/adminhtml/wysiwyg/tiny_mce/setup", 492 "mage/adminhtml/wysiwyg/widget" 493 ], function(jQuery){' .
495 ' (function($) {$.mage.translate.add(' .
496 $this->serializer->serialize(
502 ' = new wysiwygSetup("' .
509 editorFormValidationHandler = ' .
511 '.onFormValidation.bind(' .
514 Event.observe("toggle' .
521 varienGlobalEvents.attachEventHandler("formSubmit", editorFormValidationHandler); 522 varienGlobalEvents.clearEventHandlers("open_browser_callback"); 523 varienGlobalEvents.attachEventHandler("open_browser_callback", ' .
getDataUsingMethod($key, $args=null)
if(!isset($_GET['name'])) $name