2amigos / yii2-tinymce-widget

TinyMCE WYSIWYG widget for Yii2
http://yiiwheels.com
Other
100 stars 48 forks source link

Yii2 "paste_preprocess" and "deny images to save in DB" #28

Closed obladon25 closed 7 years ago

obladon25 commented 7 years ago
<?= $form->field($model, 'description')->widget(TinyMce::className(), [
    'options' => [
        'id' => 'descript_tinyMce',
        'rows' => 15
    ],
    'language' => 'en_CA', 
    'clientOptions' => [
        'plugins' => [
            "advlist autolink lists link charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste",
            "responsivefilemanager filemanager image",
        ],
        'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent | link responsivefilemanager image",
        'external_filemanager_path' => '/web/js/plugins/responsivefilemanager/filemanager/',
        'filemanager_title' => 'Responsive Filemanager',
        'external_plugins' => [
            'filemanager' => '/web/js/plugins/responsivefilemanager/filemanager/plugin.min.js',
            'responsivefilemanager' => '/web/js/plugins/responsivefilemanager/tinymce/plugins/responsivefilemanager/plugin.min.js',
        ],
        'inline_styles' => false,  
        'convert_fonts_to_spans' => true,
        'element_format' => 'html',
        'invalid_elements' => 'em,font', 
        // 'paste_preprocess' => 'MY FUNCTION ???',
    ]
])->label(false);?>

The plugin works very well.

1) How can I write "invalid_elements" function to execute, or How I can initialize a separate JavaScript file where to write the given function ?

2) How can I set the pictures copied from Microsoft Word to upload on the server but not in the database?

Sorry my bad english. Thanks so much for plugin.

tonydspaniard commented 7 years ago
'paste_preprocess' => new JsExpression('function(plugin, args) {
        console.log(args.content);
        args.content += ' preprocess';
    }'); 

There you go