You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
12 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html><html lang="zh_CN"><head><meta charset="utf-8"><title>批量上传图片</title><meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1,maximum-scale=1"><style>body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:14px;line-height:1.5;color:rgba(34,47,62,.7);height:100vh;margin:0}button{font:inherit;line-height:24px;cursor:pointer;outline:0}button:disabled{cursor:not-allowed}.button{color:#222f3e;padding:4px 16px;background-color:#f0f0f0;border:1px solid #f0f0f0;border-radius:3px}.button:hover{color:#222f3e;background-color:#e3e3e3;border-color:#e3e3e3}.button:disabled{color:rgba(34,47,62,.5);background-color:#f0f0f0;border-color:#f0f0f0}.button+.button{margin-left:4px}.primary{color:#fff;background-color:#207ab7;border-color:#207ab7}.primary:hover{color:#fff;background-color:#1c6ca1;border-color:#1c6ca1}.footer,.header{padding:8px 16px;display:flex;justify-content:space-between}.header{border-bottom:1px solid #ccc}.footer{border-top:1px solid #ccc}.tip{margin-left:4px}.main{height:calc(100vh - 102px);overflow-y:auto}.list{list-style:none;padding:8px;margin:0;display:flex;flex-wrap:wrap}.item{width:132px;margin:8px;position:relative}.item:after,.item:hover .remove{width:32px;height:32px;border-radius:32px}.item:after{content:"";position:absolute;top:6px;right:6px;z-index:1}.item[data-state="0"]:after{background:#909399 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKpJREFUeNpi/P//P8NAAiaGAQajDhhwB7BQopmRkRGrODBhcwKp7wMWAkCHgSznI0othdnwP9RCR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rzm9IMN9p065TSilVIaAHpkg8AScwR+EAe9NbAIZofK2GAxPQ/8Gfhn+AR2l8tgeV/Ah38lzl2u30uyEJGOz/6PClOO5GZMNW4Aa8muCXEQtwGPq279EEdyNy05P/GLGF4JcR9zBcKaVK9wVD9QBiLEmZNQAAAABJRU5ErkJggg==) no-repeat 50%}.item[data-state="-1"]:after{background:#f56c6c url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMRJREFUeNrsltENhCAMhunFARiRzc5NHOEcxQ16NfKgpuV+PAgvbUIg2vT/rC1AzBxG2isMNgdwAAcYDjChjkQE+cnGFsV3y+t2GZBgScZnFyiJy7TI/A4VgdGx8mEqxP4sv+PsG5G4NQDRgtDE0Y+DAU5CFwhLvAuAAaGKdwNQIFRxFOCffYCNdWWUZ7/gnHazO3oV4b3VSt3RvA2talchWgOsPwpOa9GmAMkSVyBmNAOE3op7HUbk13IHcAAHGA3wFWAAq3KVr54sfUUAAAAASUVORK5CYII=) no-repeat 50%}.image{width:128px;height:128px;-o-object-fit:scale-down;object-fit:scale-down;padding:1px;border:1px solid #ccc}.name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.remove{position:absolute;top:6px;right:6px;z-index:2;cursor:pointer;display:none}.item:hover .remove{background:#207ab7 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAiklEQVQ4je3U2wnCQBCF4ZRgCVtCOnBLSCdaQkpKJ6YD7eTzRWET12QwDxLIgQPLzM4Ph700za6F0aduW4BwRS4MbWQ44TwzXAK1VAP2lXhR9WsxcyBRhkj0HQHR4l70Hu8T/hU4GVrqHcCvwJPimc3W/702XWBfFwUO4hpWgS9oMv2yak4h2FY9AePc46ITbYMkAAAAAElFTkSuQmCC) no-repeat 50%;display:block}</style></head><body><div class="header"><div class="header-start"><button id="choose" class="button primary">选择图片</button> <span class="tip">支持上传JPG、PNG、GIF格式一次最多上传10张图片</span></div><div class="header-end"><button id="upload" class="button">批量上传</button></div></div><div id="main" class="main"><ul id="list" class="list"></ul></div><div class="footer"><div class="footer-start"></div><div class="footer-end"><button id="cancel" class="button">取消</button> <button id="empty" class="button">清空列表</button> <button id="insert" class="button primary">全部插入</button></div></div><script>"use strict";var _parent$BatchUploadIm=parent.BatchUploadImage,editor=_parent$BatchUploadIm.activeEditor(),dialog=_parent$BatchUploadIm.dialog,uploadHandler=editor.getParam("images_upload_handler",void 0,"function"),fileType=editor.getParam("batch_upload_image_type",["jpg","jpeg","png","gif"],"array"),accept=fileType.map((function(e){return".".concat(e)})).toString(),uploadButton=document.querySelector("#upload"),list=document.querySelector("#list"),images=[];function ext(e){return e.split(".").pop()}function checkImage(e){e.length&&(e=Array.from(e).filter((function(e){return-1<fileType.indexOf(ext(e.name))})).map((function(e){var t=window.URL.createObjectURL(e);return images.push({file:e,blobUrl:t,url:"",state:0}),'<li class="item" data-state="0"><img class="image" src="'.concat(t,'" alt=""><div class="name" title="').concat(e.name,'">').concat(e.name,'</div><span class="remove"></span></li>')})),list.innerHTML+=e.join(""))}function uploadQueue(){var e,t,a=images.findIndex((function(e){return 0===e.state}));-1!==a?((e=list.querySelectorAll("li")[a]).dataset.state="1",a={type:'batch',file:(t=images[a]).file,filename:function(){return t.file.name},blob:function(){return t.file}},uploadHandler(a,(function(a){t.url=a,t.state=2,e.dataset.state="2",uploadQueue()}),(function(){t.state=-1,e.dataset.state="-1",uploadQueue()}))):uploadButton.disabled=!1}document.querySelector("#choose").addEventListener("click",(function(){var e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("multiple","multiple"),e.setAttribute("accept",accept),e.onchange=function(){checkImage(this.files)},e.click()})),uploadButton.addEventListener("click",(function(){var e=0;images.forEach((function(t){""===t.url&&(e++,-1===t.state&&(t.state=0))})),e&&(this.disabled=!0,uploadQueue())})),document.querySelector("#cancel").addEventListener("click",(function(){dialog.close()})),document.querySelector("#empty").addEventListener("click",(function(){document.querySelector("#list").innerHTML="",images.length=0})),document.querySelector("#insert").addEventListener("click",(function(){var e;images.length&&(e="",images.forEach((function(t){t.url&&(e+='<img src="'.concat(t.url,'" alt="" />'))})),editor.insertContent(e),images.length=0),dialog.close()})),document.addEventListener("dragover",(function(e){return e.preventDefault()})),document.querySelector("#main").addEventListener("drop",(function(e){e.preventDefault(),checkImage(e.dataTransfer.files)})),list.addEventListener("click",(function(e){var t=e.target;t.classList.contains("remove")&&(e=Array.from(list.querySelectorAll(".remove")).indexOf(t),list.removeChild(t.parentElement),images.splice(e,1))}));</script></body></html>