/**
  * @param ContextInterface $context
  * @param FormFactory $formFactory
  * @param ConfigInterface $wysiwygConfig
  * @param array $components
  * @param array $data
  * @param array $config
  */
 public function __construct(ContextInterface $context, FormFactory $formFactory, ConfigInterface $wysiwygConfig, array $components = [], array $data = [], array $config = [])
 {
     $wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
     $this->form = $formFactory->create();
     $this->editor = $this->form->addField($context->getNamespace() . '_' . $data['name'], 'Magento\\Framework\\Data\\Form\\Element\\Editor', ['force_load' => true, 'rows' => 20, 'name' => $data['name'], 'config' => $wysiwygConfig->getConfig($wysiwygConfigData), 'wysiwyg' => isset($config['wysiwyg']) ? $config['wysiwyg'] : null]);
     $data['config']['content'] = $this->editor->getElementHtml();
     parent::__construct($context, $components, $data);
 }
Exemple #2
0
 /**
  * Wysiwyg constructor.
  * @param ContextInterface $context
  * @param Form $form
  * @param EditorElement $editorElement
  * @param ConfigInterface $wysiwygConfig
  * @param LayoutInterface $layout
  * @param DataHelper $backendHelper
  * @param CategoryAttributeRepositoryInterface $attrRepository
  * @param array $components
  * @param array $data
  * @param array $config
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(ContextInterface $context, Form $form, EditorElement $editorElement, ConfigInterface $wysiwygConfig, LayoutInterface $layout, DataHelper $backendHelper, CategoryAttributeRepositoryInterface $attrRepository, array $components = [], array $data = [], array $config = [])
 {
     $this->layout = $layout;
     $this->backendHelper = $backendHelper;
     $editorElement->setData('wysiwyg', (bool) $attrRepository->get($data['name'])->getIsWysiwygEnabled());
     parent::__construct($context, $form, $editorElement, $wysiwygConfig, $components, $data, $config);
     $this->setData($this->prepareData($this->getData()));
 }
 protected function setUp()
 {
     parent::setUp();
     $this->formFactoryMock = $this->getMockBuilder(FormFactory::class)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->formMock = $this->getMockBuilder(Form::class)->disableOriginalConstructor()->getMock();
     $this->wysiwygConfig = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
     $this->editorMock = $this->getMockBuilder(Editor::class)->disableOriginalConstructor()->getMock();
     $this->formFactoryMock->expects($this->any())->method('create')->willReturn($this->formMock);
     $this->formMock->expects($this->once())->method('addField')->willReturn($this->editorMock);
     $this->editorMock->expects($this->once())->method('getElementHtml');
 }
Exemple #4
0
 /**
  * Wysiwyg constructor.
  * @param ContextInterface $context
  * @param Form $form
  * @param EditorElement $editorElement
  * @param ConfigInterface $wysiwygConfig
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, Form $form, EditorElement $editorElement, ConfigInterface $wysiwygConfig, array $components = [], array $data = [])
 {
     $this->editorElement = $editorElement;
     $this->editorElement->setForm($form);
     $this->editorElement->setData('force_load', true);
     $this->editorElement->setData('rows', 20);
     $this->editorElement->setData('name', $data['name']);
     $this->editorElement->setData('html_id', $data['name'] . 'Editor');
     $this->editorElement->setConfig($wysiwygConfig->getConfig());
     $data['config']['content'] = $editorElement->getElementHtml();
     parent::__construct($context, $components, $data);
 }
 /**
  * Test protected `getTranslatedString` method via public `getElementHtml` method
  */
 public function testGetTranslatedString()
 {
     $this->configMock->expects($this->any())->method('getData')->withConsecutive(['enabled'])->willReturn(true);
     $html = $this->model->getElementHtml();
     $this->assertRegExp('/.*"Insert Image...":"Insert Image...".*/i', $html);
 }
Exemple #6
0
 /**
  * 2016-01-06
  * @used-by \Dfe\Markdown\Plugin\Ui\Component\Form\Element\Wysiwyg::beforePrepare()
  * @param _Editor $editor
  * @param string $html
  * @return string
  */
 public static function wrapIntoContainerSt(_Editor $editor, $html)
 {
     return $editor->_wrapIntoContainer($html);
 }