PHP code example of borales / yii2-medium-editor

1. Go to this page and download the library: Download borales/yii2-medium-editor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

borales / yii2-medium-editor example snippets


return [
    // ... other settings
    'components' => [
        // ... other settings
        'assetManager' => [
            'bundles' => [
                'borales\medium\Asset' => [
                    // set `bootstrap` theme for Medium Editor widget as a default one
                    'theme' => 'bootstrap',
                    // switch Medium Editor sources from the "latest" to the specific version
                    'useLatest' => false,
                    // use specific version of Medium Editor plugin with "useLatest=false"
                    'cdnVersion' => '5.22.1',
                ],
            ]
        ],
    ]
]

return [
    // ... other settings
    'components' => [
        // ... other settings
        'assetManager' => [
            'bundles' => [
                'borales\medium\Asset' => [
                    // use Medium Editor plugin sources from this path
                    'sourcePath' => '@bower/medium-editor/dist',
                ],
            ]
        ],
    ]
]

echo \borales\medium\Widget::widget([
    'model' => $model,
    'attribute' => 'text',
]);

echo \borales\medium\Widget::widget([
    'name' => 'my_custom_var',
    'value' => '<p>Some custom text!</p>',
]);

echo \borales\medium\Widget::widget([
    'model' => $model,
    'attribute' => 'text',
    'theme' => 'tim', // Set a theme for this specific widget
    'settings' => [
        'toolbar' => [
            'buttons' => ['bold', 'italic', 'quote'],
        ]
    ],
]);

echo $form->field($model, 'text')->widget(\borales\medium\Widget::className());

echo $form->field($model, 'text')->widget(\borales\medium\Widget::className(), [
    'theme' => 'mani',
    'settings' => [
        'toolbar' => [
            'buttons' => ['bold', 'italic', 'quote'],
        ]
    ],
]);

namespace app\components;

class ActiveField extends \yii\widgets\ActiveField
{
    use \borales\medium\MediumEditorTrait;
}

echo $form->field($model, 'text')->mediumEditor()

echo $form->field($model, 'text')->widget(\borales\medium\Widget::className(), [
    'plugins' => [
        'mediumInsert' => '$(selector).mediumInsert({editor: editor});',
    ],
]);
bash
$ php composer.phar