'editormd-image-file' ]; public $mode = 'full'; public function init() { parent::init(); $this->clientOptions = array_merge([ 'height' => '500', 'dialogLockScreen' => false, 'autoFocus' => false, // 'emoji' => true, 'watch' => false, 'placeholder' => '', 'syncScrolling' => 'single', 'imageUpload' => true, 'imageFormats' => ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], 'imageUploadURL' => \yii\helpers\Url::to($this->imageUploadRoute), 'toolbarIcons' => [ "bold", "del", "italic", "quote", "uppercase", "lowercase", "|", "h1", "h2", "h3", "h4", "h5", "h6", "|", "list-ul", "list-ol", "hr", "|", "link", "image", "code", "preformatted-text", "code-block", "|", "watch", "preview", "fullscreen", "|", "help" ], 'onchange' => new JsExpression(<<clientOptions); if ($this->mode == 'mini') { $this->clientOptions['toolbarIcons'] = ["bold", "list-ul", "list-ol", "link", "image", "code-block", "|", "help"]; $this->clientOptions['height'] = '300'; } } public function run() { echo Html::beginTag('div', ['id' => $this->getId()]); if ($this->hasModel()) { echo Html::activeTextarea($this->model, $this->attribute, ['id' => Html::getInputId($this->model, $this->attribute)]); } else { echo Html::textarea($this->name, $this->value, $this->options); } echo Html::endTag('div'); $this->registerClientScript(); } protected function registerClientScript() { $view = $this->getView(); $editormd = EditormdAsset::register($view); $this->clientOptions['path'] = $editormd->baseUrl . '/lib/'; $clientOptions = Json::encode($this->clientOptions); $js = 'var editor = editormd("' . $this->getId() . '", ' . $clientOptions . ');'; $view->registerJs($js); } }