yiier/yii2-editor.md

为 Yii2 使用的 editor.md

安装量: 1,055

依赖关系: 2

建议者: 0

安全: 0

星标: 3

关注者: 4

分支: 2

开放问题: 0

类型:yii2-extension

v0.3.0 2021-03-17 04:04 UTC

This package is auto-updated.

Last update: 2024-09-17 11:30:03 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

editor.md for Yii2

安装

安装此扩展的首选方式是通过 composer

运行以下命令:

php composer.phar require --prefer-dist yiier/yii2-editor.md "*"

或者

"yiier/yii2-editor.md": "*"

将以下内容添加到您的 composer.json 文件的 require 部分:

使用方法

扩展安装完成后,只需在您的代码中使用它即可:

<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yiier\editor\EditorMdWidget;

?>
<?= $form->field($model, 'content')->widget(EditorMdWidget::className(), [
        'options'=>[// html attributes
            'id'=>'content'
        ],
        'clientOptions' => [
            'height' => '640',
            // 'previewTheme' => 'dark',
            // 'editorTheme' => 'pastel-on-dark',
            'markdown' => '',
            'codeFold' => true,
            'syncScrolling' => false,
            'saveHTMLToTextarea' => true,    // 保存 HTML 到 Textarea
            'searchReplace' => true,
            // 'watch' => false, // 关闭实时预览
            'htmlDecode' => 'style,script,iframe|on*',            // 开启 HTML 标签解析,为了安全性,默认不开启
            'toolbar ' => false,             //关闭工具栏
            'previewCodeHighlight' => false, // 关闭预览 HTML 的代码块高亮,默认开启
            'emoji' => true,
            'taskList' => true,
            'tocm           ' => true,         // Using [TOCM]
            'tex' => true,    // 开启科学公式TeX语言支持,默认关闭
            'flowChart' => true,             // 开启流程图支持,默认关闭
            'sequenceDiagram' => true,       // 开启时序/序列图支持,默认关闭,
            // 'dialogLockScreen' => false,   // 设置弹出层对话框不锁屏,全局通用,默认为true
            // 'dialogShowMask' => false,     // 设置弹出层对话框显示透明遮罩层,全局通用,默认为true
            // 'dialogDraggable' => false,    // 设置弹出层对话框不可拖动,全局通用,默认为true
            // 'dialogMaskOpacity' => 0.4,    // 设置透明遮罩层的透明度,全局通用,默认值为0.1
            // 'dialogMaskBgColor' => '#000', // 设置透明遮罩层的背景颜色,全局通用,默认为#fff
            'imageUpload' => true,
            'imageFormats' => ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'],
            'imageUploadURL' => '/file/blog-upload?type=default&filekey=editormd-image-file',
        ]
    ]
) ?>