protected function registerClientScript()
    {
        $js = [];
        $view = $this->getView();
        TinyMceAsset::register($view);
        if ($tinyAssetBundle = TinyMceAsset::register($view)) {
            $xCopy = new xCopy();
            $assetPath = $tinyAssetBundle->basePath;
            // Language pack
            $languagesPack = Yii::getAlias('@dominus77/tinymce/assets/languages_pack');
            $xCopy->copyFolder($languagesPack, $assetPath, true, true);
            // Plugins
            $pluginsPack = Yii::getAlias('@dominus77/tinymce/assets/plugins_pack');
            $xCopy->copyFolder($pluginsPack, $assetPath, true, true);
            // Skins
            $skinsPack = Yii::getAlias('@dominus77/tinymce/assets/skins_pack');
            $xCopy->copyFolder($skinsPack, $assetPath, true, true);
        }
        $id = $this->options['id'] ? $this->options['id'] : $this->getId();
        $this->clientOptions['selector'] = "#{$id}";
        $this->clientOptions['language'] = isset($this->clientOptions['language']) ? $this->clientOptions['language'] : $this->language;

        if ($this->fileManager !== false) {
            /** @var $fm \dominus77\tinymce\components\FileManager */
            $fm = Yii::createObject(array_merge($this->fileManager, [
                'tinyMceSettings' => $this->clientOptions,
                'parentView' => $view]));
            $fm->init();
            $fm->registerAsset();

            $this->clientOptions['file_picker_callback'] = $fm->getFilePickerCallback();
        }

        $options = Json::encode($this->clientOptions);
        $js[] = "tinymce.init({$options});";
        if ($this->triggerSaveOnBeforeValidateForm) {
            $js[] = "$('#{$id}').parents('form').on('beforeValidate', function() { tinymce.triggerSave(); });";
        }
        $view->registerJs(implode("\n", $js));
    }