如何解决百度富文本在线视屏不能预览

298 阅读2分钟

ueditor版本1.4.3.3  网上参考案例 www.cnblogs.com/koreyoshi/a…

1.找到dialogs/video/video.js文件,搜索function createPreviewVideo(url) 找到conUrl = utils.unhtmlForUrl(conUrl)下方代码片段

$G("preview").innerHTML = '<div class="previewMsg"><span>'+lang.urlError+'</span></div>'+
        '<embed class="previewVideo" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
            ' src="' + conUrl + '"' +
            ' width="' + 420  + '"' +
            ' height="' + 280  + '"' +
            ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >' +
        '</embed>';

替换成

$G("preview").innerHTML = '<video class="previewVideo" controls="controls" src="' + conUrl + '" ></video>';

image.png

2.ueditor.all.js文件搜索me.commands[“insertvideo”] 如果for循环下面是

html.push(creatInsertStr( vi.url, vi.width || 420,  vi.height || 280, id + i, null, cl, 'image'));

替换成

html.push(creatInsertStr(vi.url, vi.width || 420, vi.height || 280, id + i, null, cl, 'embed'));

image.png 3.ueditor.config.js白名单配置,搜索whitList,替换img配置

 img: ['src', 'alt', 'title', 'width', 'height', 'id', '_src', '_url', 'loadingclass', 'class', 'data-latex', 'style', 'word_img', 'name', 'anchorname'],

再另外加三个

source: ['src', 'type'],
embed: ['type', 'class', 'pluginspage', 'src', 'width', 'height', 'align', 'style', 'wmode', 'play', 'autoplay', 'loop', 'menu', 'allowscriptaccess', 'allowfullscreen', 'controls', 'preload'],
 iframe: ['src', 'class', 'height', 'width', 'max-width', 'max-height', 'align', 'frameborder', 'allowfullscreen']

image.png 完整的白名单

whitList: {
            iframe: ['frameborder', 'border', 'marginwidth', 'marginheight', 'width', 'height', 'src', 'id'], 
            a: ['target', 'href', 'title', 'class', 'style'],
            abbr: ['title', 'class', 'style'],
            address: ['class', 'style'],
            area: ['shape', 'coords', 'href', 'alt', 'style'],
            article: ['class', 'style'],
            aside: ['class', 'style'],
            audio: ['autoplay', 'controls', 'loop', 'preload', 'src', 'class', 'style'],
            b: ['class', 'style'],
            bdi: ['dir', 'style'],
            bdo: ['dir', 'style'],
            big: ['class', 'style'],
            blockquote: ['cite', 'class', 'style'],
            br: ['class', 'style'],
            caption: ['class', 'style'],
            center: ['class', 'style'],
            cite: ['class', 'style'],
            code: ['class', 'style'],
            col: ['align', 'valign', 'span', 'width', 'class', 'style'],
            colgroup: ['align', 'valign', 'span', 'width', 'class', 'style'],
            dd: ['class', 'style'],
            del: ['datetime', 'style'],
            details: ['open', 'style'],
            div: ['class', 'style'],
            dl: ['class', 'style'],
            dt: ['class', 'style'],
            em: ['class', 'style'],
            font: ['color', 'size', 'face'],
            footer: ['class', 'style'],
            h1: ['class', 'style'],
            h2: ['class', 'style'],
            h3: ['class', 'style'],
            h4: ['class', 'style'],
            h5: ['class', 'style'],
            h6: ['class', 'style'],
            header: ['class', 'style'],
            hr: ['class', 'style'],
            i: ['class', 'style'],
            img: ['src', 'alt', 'title', 'width', 'height', 'id', '_src', '_url', 'loadingclass', 'class', 'data-latex', 'style', 'word_img', 'name', 'anchorname'],
            ins: ['datetime', 'style'],
            li: ['class', 'style'],
            mark: ['class', 'style'],
            nav: ['class', 'style'],
            ol: ['class', 'style'],
            p: ['class', 'style'],
            pre: ['class', 'style'],
            s: ['class', 'style'],
            section: ['class', 'style'],
            small: ['class', 'style'],
            span: ['class', 'style'],
            sub: ['class', 'style'],
            sup: ['class', 'style'],
            strong: ['class', 'style'],
            table: ['width', 'border', 'align', 'valign', 'class', 'style'],
            tbody: ['align', 'valign', 'class', 'style'],
            td: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
            tfoot: ['align', 'valign', 'class', 'style'],
            th: ['width', 'rowspan', 'colspan', 'align', 'valign', 'class', 'style'],
            thead: ['align', 'valign', 'class', 'style'],
            tr: ['rowspan', 'align', 'valign', 'class', 'style'],
            tt: ['class', 'style'],
            u: ['class', 'style'],
            ul: ['class', 'style'],
            video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width', 'class', 'style'],
            source: ['src', 'type'],
            embed: ['type', 'class', 'pluginspage', 'src', 'width', 'height', 'align', 'style', 'wmode', 'play', 'autoplay', 'loop', 'menu', 'allowscriptaccess', 'allowfullscreen', 'controls', 'preload'],
            iframe: ['src', 'class', 'height', 'width', 'max-width', 'max-height', 'align', 'frameborder', 'allowfullscreen']
        }
    };