vova07 / yii2-imperavi-widget

Imperavi Redactor widget for Yii 2
Other
248 stars 99 forks source link

CodeMirror implementation for source #167

Open NickGoodwind opened 2 years ago

NickGoodwind commented 2 years ago

Hi, I've been trying to add Codemirror to the widget by implementing the instruction provided both on Imperavi website and Redactor Manual v10 but to no avail.

This is the code included in the widget:

<?= $form->field($model, 'description')->widget(Widget::class, [ 'settings' => [ 'codemirror' => true ] ])

This is the result obtained:

https://user-images.githubusercontent.com/87220094/170595898-2418a439-bb82-4fdb-9c1b-21aee69a9636.mov

No changes to the editor at all, not even a new textArea or similar.

This are my files View:

/* @var $this yii\web\View */
/* @var $model $this->module->productClass */
/* @var $form yii\widgets\ActiveForm */

CodemirrorAsset::register($this);

$form = ActiveForm::begin([
  "id" => "product-form",
]); ?>

<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'description')->widget(Widget::class, [
    'settings' => [
        'codemirror' => true
    ]
]) ?>

CodemirrorAsset:

/**
 * Codemirror asset bundle.
 *
 * @author NickGoodwind <nickgoodwind@gmail.com>
 */
class CodemirrorAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';

    public $js = [
        'js/codemirror/codemirror.js',
        'js/codemirror/mode/htmlmixed/htmlmixed.js',
    ];

    public $css = [
        'css/codemirror.css'
    ];

    public $depends = [
        'app\modules\admin\assets\AdminAppAsset'
    ];
}

By reviewing further into the extension code, it seems that no new CodeMirror editor instance is created anywhere inside the redactor.js file. Are there some missing steps I am not looking?