无法一次将图像和文本从Microsoft Word粘贴到TinyMCE中

时间:2016-09-27 08:35:52

标签: javascript tinymce base64

我正在使用TinyMCE复制和粘贴来自Microsoft Word和其他Microsoft工具(如outlook)的内容。以下代码正在运行,但是,它需要独立复制图像才能正确格式化为base64然后可以显示在Tinymce文本区域。所以问题就在于,基本上如果我从Microsoft Word中一次选择文本和图像,如果不是本地文件路径,则图像的URL不是base64字符串。我想知道是否有一种方法可以在粘贴之前识别src图像,也可以从我的本地机器读取图像并将其转换为base64字符串。我尝试使用canvas和filereader的一些例子,但我得到了浏览器异常(访问权限)。

 tinyMCE.init({
            // editor_selector: "mceEditor",
            selector: "textarea.mceEditor",
            theme: "modern",
            mode: "textareas",
            height: "180",
            plugins: "paste image textcolor",
            menubar: "edit",
            toolbar: "paste",
            toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
            toolbar2: 'print preview media | forecolor backcolor emoticons | code',
            paste_data_images: true,
            paste_enable_default_filters: false,
            paste_retain_style_properties: "font-size,color",
            theme_advanced_buttons3_add: "pastetext,pasteword,selectall",
            paste_auto_cleanup_on_paste: true,
            paste_strip_class_attributes: "none",
            paste_remove_styles_if_webkit: false,
            paste_word_valid_elements: "b,strong,i,em,h1,h2,p,ol,ul,li,a,img",
            paste_webkit_styles: "color font-size",
            paste_preprocess: function (pl, o) {
                // Content string containing the HTML from the clipboard
                //alert(o.content);
                o.content = o.content;
                alert(o.content);
            },
            paste_postprocess: function (pl, o) {
                // Content DOM node containing the DOM structure of the clipboard
                //alert(o.node.innerHTML);
                o.node.innerHTML = o.node.innerHTML;
            }
        });

0 个答案:

没有答案
相关问题