public function run()
{
$options = $this->options;
if (isset($options['id'])) {
$id = $options['id'];
} else {
$id = 'editor';
}
if (isset($options['name'])) {
$name = $options['name'];
} elseif ($this->hasModel()) {
$name = BaseHtml::getInputName($this->model, $this->attribute);
} else {
$name = $this->name;
}
if (isset($options['value'])) {
$value = $options['value'];
} elseif ($this->hasModel()) {
$value = BaseHtml::getAttributeValue($this->model, $this->attribute);
} else {
$value = $this->value;
}
echo Html::beginTag('script', ['id' => $id, 'type' => 'text/plain', 'name' => $name, 'style' => "height:{$this->height}"]);
echo $value;
echo Html::endTag('script');
if (!isset($options['config'])) {
$options['config'] = [];
}
$ueditorConfig = ArrayHelper::merge(['serverUrl' => Url::to(['ueditor/controller'])], $options['config']);
$config = Json::encode($ueditorConfig);
$view = $this->getView();
UEditorAsset::register($view);
$view->registerJs("var ue = UE.getEditor('{$id}', {$config});");
}