PHP code example of maxiao64 / simditor

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

    

maxiao64 / simditor example snippets



'extensions' => [
    'simditor' => [
        // Set to false if you want to disable this extension
        'enable' => true,
        // Editor configuration
        'config' => [
             'upload' => [
                    'qnTokenUrl' => '/' . env('ADMIN_ROUTE_PREFIX') . '/api/getQnToken', // 获取七牛配置项的接口
                    'fileKey' => 'upload_file',
                    'connectionCount' => 3,
                    'leaveConfirm' => 'Uploading is in progress, are you sure to leave this page?'
                ],
            'tabIndent' => true,
            'toolbar' => ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment'],
            'toolbarFloat' => true,
            'toolbarFloatOffset' => 0,
            'toolbarHidden' => false,
            'pasteImage' => true,
            'cleanPaste' => false,
        ]
    ]
]

// in controller 
public function getQnToken()
    {
        $qnConfig = new Config();
        $qnConfig->useHTTPS = env('IS_HTTPS_APP');
        list($uphost, $error) = $qnConfig->getUpHostV2(config('filesystems.disks.qiniu.access_key') , config('filesystems.disks.qiniu.bucket'));
        if($error) {
            return [];
        }
        return [
            'uphost' => $uphost,
            'domain' => config('filesystem.disks.qiniu.domains.default'),
            'uptoken' => Storage::disk('qiniu')->getAdapter()->uploadToken()
        ];
    }
    
// in config/filesystems.php
...
'qiniu' => 
    [
        'driver'  => 'qiniu',
        'domains' => [
            'default'   => 'http://image.mmmx17.cn', //你的七牛域名
            'https'     => 'image.mmmx17.cn',         //你的HTTPS域名
            'custom'    => 'static.abc.com',                //Useless 没啥用,请直接使用上面的 default 项
            ],
        'access_key'=> env('QINIU_AK_KEY'),  //AccessKey
        'secret_key'=> env('QINIU_SK_KEY'),  //SecretKey
        'bucket'    => 'mmmx17cn',  //Bucket名字
        'notify_url'=> '',  //持久化处理回调地址
        'access'    => 'public',  //空间访问控制 public 或 private
        'hotlink_prevention_key' => null, // CDN 时间戳防盗链的 key。 设置为 null 则不启用本功能。
    ],
...

$form->simditor('content');