PHP code example of felix33 / yii2-simditor

1. Go to this page and download the library: Download felix33/yii2-simditor 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/ */

    

felix33 / yii2-simditor example snippets


echo \felix33\simditor\Simditor::widget(['name' => 'xxxx']);

echo $form->field($model,'colum')->widget('felix33\simditor\Simditor',[]);

use \felix33\simditor\Simditor;
echo Simditor::widget([
    'name'=> 'simditor',
    'value'=> '初始化内容..',
    'clientOptions' => [
      'placeHolder' => '这里输入内容...',
      'toolbarFloat' => false,
       // 工具栏
      'toolbar' => [ 'title', '|', 'bold', 'italic',
          'underline', 'strikethrough', 'color',
          'fontScale', 'clearhtml', '|', 'ol', 'ul',
          'blockquote', 'code', 'table', '|', 'link',
          'image', 'hr', '|', 'indent', 'outdent',
          'alignment', 'html', 'fullscreen', 'devices'
       ],
        // 编辑器插入图片时使用的默认图片
       'defaultImage' => '/images/image.png',
       'upload' => [
          // 文件上传的接口地址
          'url' => Url::toRoute(['upload']),
          // 键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
          'params' => null,
          // 服务器端获取文件数据的参数名
          'fileKey' => 'fileData',
          'connectionCount' => 3,
          'leaveConfirm' => '正在上传文件'
        ]
    ]);

public function actions()
{
    return [
        'upload' => [
            'class' => 'felix33\simditor\SimditorAction'
        ]
    ];
}

public function actions()
{
    return [
        'upload' => [
            'class' => 'felix33\simditor\SimditorAction',
            'config' => [
                // 文件字段
                "fileKey" => "fileData",
                // 图片访问路径前缀
                "urlPrefix"  => Yii::getAlias('@web'),
                // 上传保存路径
                "uploadRoot" => Yii::getAlias("@webroot"),
                // 上传路径格式化
                "pathFormat" => "/upload/{yyyy}{mm}{dd}/{time}{rand:6}"
            ],
        ]
    ];
}

$ php composer.phar