/** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration. */ public function init() { $this->_hjs = Yii::$app->assetManager->getBundle(HighlightAsset::className()); $this->_ace = Yii::$app->assetManager->getBundle(AceEditorAsset::className()); $this->_hjs->css = ['dist/styles/' . $this->highlightStyle . '.css']; parent::init(); }
/** * @inheritdoc */ public function init() { parent::init(); AceEditorAsset::register($this->getView()); $editor_id = $this->getId(); $editor_var = 'aceeditor_' . $editor_id; $this->getView()->registerJs("var {$editor_var} = ace.edit(\"{$editor_id}\")"); $this->getView()->registerJs("{$editor_var}.setTheme(\"ace/theme/{$this->theme}\")"); $this->getView()->registerJs("{$editor_var}.getSession().setMode(\"ace/mode/{$this->mode}\")"); $textarea_var = 'acetextarea_' . $editor_id; $this->getView()->registerJs("\n var {$textarea_var} = \$('#{$this->options['id']}').hide();\n {$editor_var}.getSession().setValue({$textarea_var}.val());\n {$editor_var}.getSession().on('change', function(){\n {$textarea_var}.val({$editor_var}.getSession().getValue());\n });\n "); Html::addCssStyle($this->options, 'display: none'); $this->containerOptions['id'] = $editor_id; $this->getView()->registerCss("#{$editor_id}{position:relative}"); }