|
|
|
@ -1,9 +1,10 @@ |
|
|
|
layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
|
|
|
|
var e = layui.$, i = layui.layer, a = layui.form, l = (layui.hint(), layui.device()), n = "layedit", |
|
|
|
o = "layui-show", r = "layui-disabled", layedit=layui.layedit, c = function () { |
|
|
|
var t = this; |
|
|
|
t.index = 0, t.config = { |
|
|
|
tool: ["strong", "italic", "underline", "del", "|", "left", "center", "right", "|", "link", "unlink", "face", "image"], |
|
|
|
tool: ["strong", "italic", "underline", "del", "|", "left", "center", "right", "|", "link", "unlink", "face", "image","video"], |
|
|
|
hideTool: [], |
|
|
|
height: 500 |
|
|
|
} |
|
|
|
@ -47,6 +48,7 @@ layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
} |
|
|
|
}, c.prototype.getSelection = function (t) { |
|
|
|
var e = u(t); |
|
|
|
console.log("e::",e[0]) |
|
|
|
if (e[0]) { |
|
|
|
var i = m(e[0].document); |
|
|
|
return document.selection ? i.text : i.toString() |
|
|
|
@ -133,13 +135,15 @@ layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
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) { |
|
|
|
b.call(o, {href: l.attr("href"), target: l.attr("target"),tag:l.attr("tag")}, function (e) { |
|
|
|
var a = l[0]; |
|
|
|
"A" === a.tagName ? a.href = e.url : v.call(t, "a", {target: e.target, href: e.url, text: e.url}, i) |
|
|
|
console.log(1212,a) |
|
|
|
( a.tag===undefined || a.tag==='link' ? v.call(t, "a", {target: e.target, href: e.url, text: e.url}, i):v.call(t, "video", { src: e.url, text: e.url}, i)) |
|
|
|
}) |
|
|
|
}, unlink: function (t) { |
|
|
|
n.execCommand("unlink") |
|
|
|
}, face: function (e) { |
|
|
|
}, |
|
|
|
face: function (e) { |
|
|
|
x.call(this, function (i) { |
|
|
|
v.call(t, "img", {src: i.src, alt: i.alt}, e) |
|
|
|
}) |
|
|
|
@ -157,7 +161,23 @@ layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
v.call(t, "img", {src: "/" + uri}, a); |
|
|
|
layer.close(windows) |
|
|
|
} |
|
|
|
}, code: function (e) { |
|
|
|
}, |
|
|
|
video: function (a) { |
|
|
|
var n = this; |
|
|
|
var uploadVideo = l.uploadVideo; |
|
|
|
var windows = layer.open({type: 2, title: "上传视频", content: uploadVideo.url, area: ["90%", "90%"]}); |
|
|
|
window.callback = function (uri) { |
|
|
|
console.log(uri,1112222) |
|
|
|
uri.forEach(function (item) { |
|
|
|
v.call(t, "video", {src: item}, a) |
|
|
|
}); |
|
|
|
}; |
|
|
|
window.callbackSetUri = function (uri) { |
|
|
|
v.call(t, "video", {src: "/" + uri}, a); |
|
|
|
layer.close(windows) |
|
|
|
} |
|
|
|
}, |
|
|
|
code: function (e) { |
|
|
|
k.call(o, function (i) { |
|
|
|
v.call(t, "pre", {text: i.code, "lay-lang": i.lang}, e) |
|
|
|
}) |
|
|
|
@ -185,12 +205,20 @@ layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
}, d = /image/; |
|
|
|
s.find(">i").on("mousedown", function () { |
|
|
|
var t = e(this), i = t.attr("layedit-event"); |
|
|
|
d.test(i) || u.call(this) |
|
|
|
d.test(i) || /video/.test(i) || u.call(this) |
|
|
|
}).on("click", function () { |
|
|
|
var t = e(this), i = t.attr("layedit-event"); |
|
|
|
d.test(i) && u.call(this) |
|
|
|
( d.test(i) || /video/.test(i) ) && u.call(this) |
|
|
|
}), o.on("click", function () { |
|
|
|
h.call(t, s), i.close(x.index) |
|
|
|
}), |
|
|
|
o.on("paste", function () { |
|
|
|
iframeDOM.execCommand('formatBlock', false, '<p>'); |
|
|
|
setTimeout(function(){ |
|
|
|
filter.call(iframeWin, o); |
|
|
|
o.find('img').not('.layedit-face').addClass('layedit-img');//粘贴的添加类名layedit-img
|
|
|
|
textArea.value = o.html(); |
|
|
|
}, 100); |
|
|
|
}) |
|
|
|
}, b = function (t, e) { |
|
|
|
var l = this, n = i.open({ |
|
|
|
@ -204,11 +232,15 @@ layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
skin: "layui-layer-msg", |
|
|
|
content: ['<ul class="layui-form" style="margin: 15px;">', '<li class="layui-form-item">', '<label class="layui-form-label" style="width: 60px;">URL</label>', '<div class="layui-input-block" style="margin-left: 90px">', '<input name="url" lay-verify="url" value="' + (t.href || "") + '" autofocus="true" autocomplete="off" class="layui-input">', "</div>", "</li>", '<li class="layui-form-item">', '<label class="layui-form-label" style="width: 60px;">打开方式</label>', '<div class="layui-input-block" style="margin-left: 90px">', '<input type="radio" name="target" value="_self" class="layui-input" title="当前窗口"' + ("_self" !== t.target && t.target ? "" : "checked") + ">", '<input type="radio" name="target" value="_blank" class="layui-input" title="新窗口" ' + ("_blank" === t.target ? "checked" : "") + ">", "</div>", "</li>", '<li class="layui-form-item" style="text-align: center;">', '<button type="button" lay-submit lay-filter="layedit-link-yes" class="layui-btn"> 确定 </button>', '<button style="margin-left: 20px;" type="button" class="layui-btn layui-btn-primary"> 取消 </button>', "</li>", "</ul>"].join(""), |
|
|
|
success: function (t, n) { |
|
|
|
|
|
|
|
var o = "submit(layedit-link-yes)"; |
|
|
|
a.render("radio"), t.find(".layui-btn-primary").on("click", function () { |
|
|
|
i.close(n), l.focus() |
|
|
|
}), a.on(o, function (t) { |
|
|
|
i.close(b.index), e && e(t.field) |
|
|
|
console.log("1111",t) |
|
|
|
console.log("22",e) |
|
|
|
i.close(b.index) , e && e(t.field) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
@ -271,7 +303,9 @@ layui.define(["layer", "form", "layedit"], function (t) { |
|
|
|
face: '<i class="layui-icon layedit-tool-face" title="表情" layedit-event="face""></i>', |
|
|
|
image: '<i class="layui-icon layedit-tool-image" title="图片" layedit-event="image"></i>', |
|
|
|
code: '<i class="layui-icon layedit-tool-code" title="插入代码" layedit-event="code"></i>', |
|
|
|
help: '<i class="layui-icon layedit-tool-help" title="帮助" layedit-event="help"></i>' |
|
|
|
help: '<i class="layui-icon layedit-tool-help" title="帮助" layedit-event="help"></i>', |
|
|
|
video: '<i class="layui-icon layedit-tool-image" title="视频" layedit-event="video"></i>' |
|
|
|
}, w = new c; |
|
|
|
|
|
|
|
t("likeedit", w) |
|
|
|
}); |