eluhr/yii2-jedi-editor

Yii2 asset bundle and input widget for germanbisurgi/jedi

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:JavaScript

Type:yii2-extension

0.1.2 2024-11-06 09:51 UTC

This package is auto-updated.

Last update: 2024-11-06 09:52:41 UTC


README

Yii2 AssetBundle and Input Widget for germanbisurgi/jedi

Installation

The preferred way to install this extension is through composer.

Either run

composer require eluhr/yii2-jedi-editor

or add

"eluhr/yii2-jedi-editor": "*"

to the require section of your composer.json file.

Usage

<?php
/**
 * @var \yii\base\Model $model
 * @var yii\web\View $this
*/

use eluhr\jedi\widgets\JediEditor;
use yii\web\JsExpression;

// Schema can either be of type string, array or stdClass.
$schema1 = '{}';
$schema2 = [];
 
// Without a model
echo JediEditor::widget([
    'id' => 'my-jedi',
    'name' => 'editor',
    'schema' => $schema1,
    // Update theme, see: https://github.com/germanbisurgi/jedi/tree/main?tab=readme-ov-file#theme
    'theme' => JediEditor::THEME_THEME_BOOTSTRAP3,
    'pluginOptions' => [
        // No ref parser
        'refParser' => null
    ]
]);

// Example on how to listen to change event
$this->registerJs(<<<JS
window['my-jedi'].on('change', () => {
    console.log(window['my-jedi'].getValue())
})
JS);

// With a model
echo JediEditor::widget([
    'model' => $model,
    'attribute' => 'attribute_name',
    'schema' => $schema2,
    'pluginOptions' => [
        // You can also set the theme like this
        'theme' => new JsExpression('new Jedi.ThemeBootstrap3()')
    ]
]);

For further informations about the usage of the jedi editor please refer to the docs