dbursak / yii2-tinymce-widget

为 Yii2 开发的 TinyMCE 小部件。

安装: 72

依赖关系: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放性问题: 0

语言:JavaScript

类型:yii2-extension

1.1 2019-12-03 16:54 UTC

This package is not auto-updated.

Last update: 2024-10-02 16:29:05 UTC


README

渲染一个 TinyMCE WYSIWYG 文本编辑器插件 小部件。

安装

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

运行以下命令之一:

composer require dbursak/yii2-tinymce-widget:1.0

或者

"dbursak/yii2-tinymce-widget" : "1.0"

将其添加到应用程序的 composer.json 文件的 require 部分。

用法


use dosamigos\tinymce\TinyMce;

<?= $form->field($model, 'text')->widget(TinyMce::className(), [
    'options' => ['rows' => 6],
    'language' => 'es',
    'clientOptions' => [
        'plugins' => [
            "advlist autolink lists link charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste"
        ],
        'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    ]
]);?>

关于 ClientOptions

请记住,如果您需要将 JavaScript 添加到 JS 插件的配置中,并且需要使用纯 JS,请使用 JsExpression。这个类是 Yii 为此特定目的制作的。例如

// Having the following scenario
<script> 
    function jsFunctionToBeCalled() {
        // ...
    }
</script>

<?= $form->field($model, 'content')->widget(TinyMce::className(), [
    'options' => ['rows' => 16],
    'language' => 'en_GB',
    'clientOptions' => 
        // ...
        // this will render the function name without quotes on the configuration options of the plugin
        'file_picker_callback' => new JsExpression('jsFunctionToBeCalled'),
        // ...
    ]
]); ?>