+
95
-

layedit怎么上传音频和视频?

请问layedit怎么上传音频和视频?

网友回复

+
15
-

改写了一下layedit.js,将下面的代码覆盖掉以前的layedit.js就实现上传音频了

/** layui-v2.5.7 MIT License */; layui.define(["layer", "form"], function(t) {
    "use strict"; var e = layui.$, i = layui.layer, a = layui.form, l = (layui.hint(), layui.device()), n = "layedit", o = "layui-show", r = "layui-disabled", c = function() {
        var t = this; t.index = 0, t.config = {
            tool: ["strong", "italic", "underline", "del", "|", "left", "center", "right", "|", "link", "unlink", "face", "image","sound"], hideTool: [], height: 280
        }}; c.prototype.set = function(t) {
        var i = this; return e.extend(!0, i.config, t), i
    }, c.prototype.on = function(t, e) {
        return layui.onevent(n, t, e)}, c.prototype.build = function(t, i) {
        i = i || {}; var a = this, n = a.config, r = "layui-layedit", c = e("string" == typeof t?"#"+t: t), u = "LAY_layedit_"+ ++a.index, d = c.next("."+r), y = e.extend({}, n, i), f = function() {
            var t = [], e = {}; return layui.each(y.hideTool, function(t, i) {
                e[i]=!0
            }), layui.each(y.tool, function(i, a) {
                C[a]&&!e[a] && t.push(C[a])}), t.join("")}(), m = e(['<div class="'+r+'">', '<div class="layui-unselect layui-layedit-tool">'+f+"</div>", '<div class="layui-layedit-iframe">', '<iframe id="'+u+'" name="'+u+'" textarea="'+t+'" frameborder="0"></iframe>', "</div>", "</div>"].join("")); return l.ie && l.ie < 8?c.removeClass("layui-hide").addClass(o): (d[0] && d.remove(), s.call(a, m, c[0], y), c.addClass("layui-hide").after(m), a.index)}, c.prototype.getContent = function(t) {
        var e = u(t); if (e[0])return d(e[0].document.body.innerHTML)},
    c.prototype.getText = function(t) {
        var i = u(t); if (i[0])return e(i[0].document.body).text()},
    c.prototype.setContent = function(t, i, a) {
        var l = u(t); l[0] && (a?e(l[0].document.body).append(i): e(l[0].document.body).html(i), layedit.sync(t))},
    c.prototype.sync = function(t) {
        var i = u(t); if (i[0]) {
            var a = e("#"+i[1].attr("textarea")); a.val(d(i[0].document.body.innerHTML))}},
    c.prototype.getSelection = function(t) {
        var e = u(t); if (e[0]) {
            var i = m(e[0].document); return document.selection?i.text: i.toString()}}; var s = function(t, i, a) {
        var l = this,
        n = t.find("iframe"); n.css({
            height: a.height
        }).on("load", function() {
            var o = n.contents(), r = n.prop("contentWindow"), c = o.find("head"), s = e(["<style>", "*{margin: 0; padding: 0;}", "body{padding: 10px; line-height: 20px; overflow-x: hidden; word-wrap: break-word; font: 14px Helvetica Neue,Helvetica,PingFang SC,Microsoft YaHei,Tahoma,Arial,sans-serif; -webkit-box-sizing: border-box !important; -moz-box-sizing: border-box !important; box-sizing: border-box !important;}", "a{color:#01AAED; text-decoration:none;}a:hover{color:#c00}", "p{margin-bottom: 10px;}", "img{display: inline-block; border: none; vertical-align: middle;}", "pre{margin: 10px 0; padding: 10px; line-height: 20px; border: 1px solid #ddd; border-left-width: 6px; background-color: #F2F2F2; color: #333; font-family: Courier New; font-size: 12px;}", "</style>"].join("")), u = o.find("body"); c.append(s), u.attr("contenteditable", "true").css({
                "min-height": a.height
            }).html(i.value || ""), y.apply(l, [r, n, i, a]), g.call(l, r, t, a)})},
    u = function(t) {
        var i = e("#LAY_layedit_"+t),
        a = i.prop("contentWindow"); return[a,
            i]},
    d = function(t) {
        return 8 == l.ie && (t = t.replace(/<.+>/g, function(t) {
            return t.toLowerCase()})),
        t
    },
    y = function(t, a, n, o) {
        var r = t.document,
        c = e(r.body); c.on("keydown", function(t) {
            var e = t.keyCode; if (13 === e) {
                var a = m(r),
                l = p(a),
                n = l.parentNode; if ("pre" === n.tagName.toLowerCase()) {
                    if (t.shiftKey)return; return i.msg("请暂时用shift+enter"),
                    !1
                }r.execCommand("formatBlock", !1, "<p>")}}), e(n).parents("form").on("submit",
            function() {
                var t = c.html(); 8 == l.ie && (t = t.replace(/<.+>/g, function(t) {
                    return t.toLowerCase()})),
                n.value = t
            }), c.on("paste",
            function(e) {
                r.execCommand("formatBlock", !1, "<p>"),
                setTimeout(function() {
                    f.call(t, c), n.value = c.html()}, 100)})}, f = function(t) {
        var i = this; i.document; t.find("*[style]").each(function() {
            var t = this.style.textAlign; this.removeAttribute("style"),
            e(this).css({
                "text-align": t || ""
            })}), t.find("table").addClass("layui-table"), t.find("script,link").remove()}, m = function(t) {
        return t.selection?t.selection.createRange(): t.getSelection().getRangeAt(0)}, p = function(t) {
        return t.endContainer || t.parentElement().childNodes[0]},v=function(t,i,a){var l=this.document,n=document.createElement(t);for(var o in i)n.setAttribute(o,i[o]);if(n.removeAttribute("text"),l.selection){var r=a.text||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.pasteHTML(e(n).prop("outerHTML")),a.select()}else{var r=a.toString()||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.deleteContents(),a.insertNode(n)}},h=function(t,i){var a=this.document,l="layedit-tool-active",n=p(m(a)),o=function(e){return t.find(".layedit-tool-"+e)};i&&i[i.hasClass(l)?"removeClass":"addClass"](l),t.find(">i").removeClass(l),o("unlink").addClass(r),e(n).parents().each(function(){var t=this.tagName.toLowerCase(),e=this.style.textAlign;"b"!==t&&"strong"!==t||o("b").addClass(l),"i"!==t&&"em"!==t||o("i").addClass(l),"u"===t&&o("u").addClass(l),"strike"===t&&o("d").addClass(l),"p"===t&&("center"===e?o("center").addClass(l):"right"===e?o("right").addClass(l):o("left").addClass(l)),"a"===t&&(o("link").addClass(l),o("unlink").removeClass(r))})},g=function(t,a,l){var n=t.document,o=e(n.body),c={link:function(i){var a=p(i),l=e(a).parent();b.call(o,{href:l.attr("href"),target:l.attr("target")},function(e){var a=l[0];"A"===a.tagName?a.href=e.url:v.call(t,"a",{target:e.target,hr...

点击查看剩余70%

+
15
-
 layui.use('layedit',
                function() {
                    var layedit = layui.layedit;
                    layedit.set({
                        uploadImage: {
                   ...

点击查看剩余70%

我知道答案,我要回答