数据从Excel粘贴到CKEditor两次(base64image和text)

时间:2019-05-28 06:59:34

标签: ckeditor4.x

当我尝试将数据从excel复制并粘贴到ckeditor时,它被粘贴为纯文本和base64image两次。我只需要将其粘贴为base64image即可。随附屏幕截图以供参考。enter image description here

1 个答案:

答案 0 :(得分:0)

我已使用以下解决方案解决了问题

var editor = CKEDITOR.replace( 'editor1', {
    extraPlugins : 'pastebase64'
});
editor.on( 'pluginsLoaded', function( event ){
    var excelRegex = RegExp( '(schemas-microsoft-com\:office\:excel)', 'ig' );

    // How to change image, dropped from local folder into CKEditor, from image file to base64 string with the help of CKEditor objects.
    editor.on( 'paste', function( evt ) {
        var testHtml = evt.data.dataTransfer.getData( 'text/html' , true);

        if ( testHtml.search( excelRegex ) >= 0 )
      evt.cancel();
    });
});