2017-05-26 110 views
0

TinyMCE的不Magento的2个工作前端[PHTML]文件Magento的2 TinyMCE的编辑器fronend PHTML文件示例

我试过火狐这个代码

require(["jquery", 'Magento_Theme/js/creamondoModal', "mage/adminhtml/wysiwyg/tiny_mce/setup"], function (jQuery, creamondoModal) { 
    var config, editor; 
    config = { 
     settings: { 
      mode: 'textarea', 
      theme_advanced_buttons1: "bold,italic,justifyleft,justifycenter,justifyright,|," + 
        "fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code", 
      theme_advanced_buttons2: null, 
      theme_advanced_buttons3: null, 
      theme_advanced_buttons4: null, 
      theme_advanced_statusbar_location: null 
     } 
    }; 
    editor = new tinyMceWysiwygSetup('about_course_provider', config); 
    editor.turnOn(); 
    editor = new tinyMceWysiwygSetup('about_vendor', config); 
    editor.turnOn(); 
    editor = new tinyMceWysiwygSetup('vendor_strength', config); 
    editor.turnOn(); 
}); 

此代码正在Chrome,但不和IE-11,Edge。

PLZ提前提示感谢.... :)

回答

0

你应该得到的Magento和配置重新设置他们

protected $wysiwyg; 
public function __construct(
     \Magento\Framework\View\Element\Template\Context $context, 
     \Magento\Cms\Model\Wysiwyg\Config $wysiwyg 
    ){ 
    $this->wysiwyg = $wysiwyg; 
    parent::__construct($context); 
} 

...

public function getWysiwygConfig(){ 
    $config = $this->wysiwyg->getConfig(); 
    $config->setData('add_variables', false); 
    $config->setData('add_widgets', false); 
    $config->addData([ 
     'settings' => [ 
      'mode' => 'textarea', 
      'theme_advanced_buttons1' => "bold,italic,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,|,bullist,numlist,|,code", 
      'theme_advanced_buttons2' => NULL, 
      'theme_advanced_buttons3' => NULL, 
      'theme_advanced_buttons4' => NULL, 
      'theme_advanced_statusbar_location' => NULL 
     ] 
    ]); 
    return $config; 
} 

...

require(["jquery", "mage/adminhtml/wysiwyg/tiny_mce/setup"], function (jQuery) { 
    var editor; 
    editor = new tinyMceWysiwygSetup('text', <?php echo \Zend_Json::encode($this->getWysiwygConfig()); ?>); 
    editor.turnOn(); 
});