{"id":187,"date":"2018-07-24T22:25:12","date_gmt":"2018-07-24T14:25:12","guid":{"rendered":"http:\/\/www.leohe.net.cn\/?p=187"},"modified":"2019-10-18T23:35:55","modified_gmt":"2019-10-18T15:35:55","slug":"ueditor%e7%bc%96%e8%be%91%e5%99%a8bug","status":"publish","type":"post","link":"https:\/\/china-abc.leohe.net.cn\/?p=187","title":{"rendered":"ueditor\u7f16\u8f91\u5668bug"},"content":{"rendered":"<h1 class=\"line\" data-line=\"0\">\u3010\u70b9\u51fb\u9009\u62e9\u56fe\u7247\u3011\u65f6\u65e0\u6cd5\u7acb\u5373\u5f39\u51fa\u9009\u62e9\u6846\uff0c\u800c\u662f\u7b494-7\u79d2\u949f\u624d\u663e\u793a\u51fa\u6765\u7684BUG<\/h1>\n<p>\u4fee\u6539\u8def\u5f84:\/ueditor\/dialogs\/image\/image.js \u4fee\u6539\u4f4d\u7f6e\uff1a367\u884c\u5f00\u59cb\uff08\u6216\u901a\u8fc7 \"accept\" \u6216\u8005\"image\/<em>\" \u627e\u5230\u4e0b\u56fe\u7684\u4f4d\u7f6e\uff09\uff0c\u5c06<br \/>\naccept: {<br \/>\ntitle: 'Images',<br \/>\nextensions: acceptExtensions,<br \/>\nmimeTypes: 'image\/<\/em>'<br \/>\n}<\/p>\n<p>\u6539\u4e3a<br \/>\naccept: {<br \/>\ntitle: 'Images',<br \/>\nextensions: acceptExtensions,<br \/>\nmimeTypes: 'image\/gif,image\/jpeg,image\/png,image\/jpg,image\/bmp'<br \/>\n}<br \/>\n\u5355\u56fe\u4e0a\u4f20\u4e5f\u4f1a\u6709\u8fd9\u4e2a\u95ee\u9898\uff0c\u540c\u6837\u53ea\u9700\u8981\u4fee\u6539 ueditor.all.js (\u5927\u698224431\u884c)\u6216\u8005\u641c\u7d22 accept=\"image\/ \u5728\u8fd9\u4e2a\u65b9\u6cd5\u91cc\u9762\u5c06 image\/* \u66ff\u6362\u6210 image\/gif,image\/jpeg,image\/png,image\/jpg,image\/bmp \u5373\u53ef<\/p>\n<h1 class=\"line\" data-line=\"17\"><a id=\"ueditor_17\"><\/a>ueditor\u6e90\u4ee3\u7801\u91cd\u65b0\u7f16\u8bd1\u524d\u4fee\u6539\u90e8\u5206<\/h1>\n<h3 class=\"line\" data-line=\"18\"><a id=\"_1pngbmp_18\"><\/a>* 1\u3001\u89e3\u51b3png\u3001bmp\u7b49\u56fe\u7247\u4e0d\u538b\u7f29\u95ee\u9898<\/h3>\n<p>\\dist\\utf8-php\\third-party\\webuploader\\webuploader.min.js \u6587\u4ef6\u641c\u7d22~\"image\/jpeg,image\/jpg\"\u6539\u4e3a\"image\/jpeg,image\/jpg,image\/png,image\/bmp\"\u3002<\/p>\n<h3 class=\"line\" data-line=\"21\"><a id=\"2_21\"><\/a>2\u3001\u89e3\u51b3\u70b9\u51fb\u4e0a\u4f20\u56fe\u7247\u5ef6\u65f6\u95ee\u9898<\/h3>\n<p>\\dialogs\\image\\image.js\uff08369\u884c\uff09\u4fee\u6539\u4e3a mimeTypes: 'image\/jpg,image\/jpeg,image\/png,image\/gif,image\/bmp'<\/p>\n<h3 class=\"line\" data-line=\"24\"><a id=\"3_24\"><\/a>3\u3001\u89e3\u51b3\u56fe\u7247\u8fc7\u5c0f\u4e0d\u538b\u7f29\u95ee\u9898<\/h3>\n<p>2\u6587\u4ef6\u4e2dcompress\u5c5e\u6027\u6dfb\u52a0 compressSize:1\u503c<\/p>\n<h3 class=\"line\" data-line=\"28\"><a id=\"4_28\"><\/a>4\u3001\u5c4f\u853d\u62d6\u653e\u4e0a\u4f20\u4e0e\u7c98\u8d34\u677f\u4e0a\u4f20<\/h3>\n<p>_src\\plugins\\autoupload.js \u65b9\u6cd5\u524d\u52a0 return<\/p>\n<h3 class=\"line\" data-line=\"31\"><a id=\"5_31\"><\/a>5\u3001\u5355\u56fe\u4e0a\u4f20\u538b\u7f29\u5b9e\u73b0<\/h3>\n<p>\u8c03\u7528\u7f16\u8f91\u5668\u9700\u8981\u5f15\u5165jquery<br \/>\n_src\\adapter\\editorui.js\u6587\u4ef6\u5c3e\u539f\u5355\u56fe\u4e0a\u4f20\u4ee3\u7801\u4fee\u6539\u4e3a\u5982\u4e0b<br \/>\n\/* \u5355\u56fe\u4e0a\u4f20\u63d2\u4ef6 *\/<br \/>\neditorui[\"simpleupload\"] = function (editor) {<br \/>\nvar name = \"simpleupload\",<br \/>\nui = new editorui.Button({<br \/>\nclassName: \"edui-for-simpleupload\",<br \/>\ntitle:<br \/>\neditor.options.labelMap[name] ||<br \/>\neditor.getLang(\"labelMap.\" + name) ||<br \/>\n\"\",<br \/>\ntheme: editor.options.theme,<br \/>\nshowText: false<br \/>\n});<br \/>\neditorui.buttons[name] = ui;<br \/>\neditor.addListener(\"ready\", function () {<br \/>\nvar b = ui.getDom(\"body\"),<br \/>\niconSpan = b.children[0];<br \/>\nvar that = this;<br \/>\nvar imgUploader = function () {<br \/>\nvar actionUrl = editor.getActionUrl(editor.getOpt('imageActionName')),<br \/>\nacceptExtensions = (editor.getOpt('imageAllowFiles') || []).join('').replace(\/.\/g, ',').replace(\/<sup class=\"footnote-ref\"><a id=\"fnref1\" href=\"https:\/\/www.kancloud.cn\/swordfly\/javascript\/454611#fn1\">[1]<\/a><\/sup>\/, ''),<br \/>\nimageMaxSize = editor.getOpt('imageMaxSize'),<br \/>\nimageCompressBorder = editor.getOpt('imageCompressBorder');<br \/>\nvar uploader1 = WebUploader.create({<br \/>\nswf: '..\/..\/third-party\/webuploader\/Uploader.swf',<br \/>\npick: {id:b,multiple:false},<br \/>\nserver: actionUrl,<br \/>\nfileVal: editor.getOpt('imageFieldName'),<br \/>\nfileSingleSizeLimit: imageMaxSize, \/\/ \u9ed8\u8ba4 2 M<br \/>\naccept: {<br \/>\ntitle: 'Images',<br \/>\nextensions: acceptExtensions,<br \/>\nmimeTypes: 'image\/jpg,image\/jpeg,image\/png,image\/gif,image\/bmp'<br \/>\n},<br \/>\ncompress: editor.getOpt('imageCompressEnable') ? {<br \/>\nwidth: imageCompressBorder,<br \/>\nheight: imageCompressBorder,<br \/>\n\/\/ \u56fe\u7247\u8d28\u91cf\uff0c\u53ea\u6709type\u4e3a<code>image\/jpeg<\/code>\u7684\u65f6\u5019\u624d\u6709\u6548\u3002<br \/>\nquality: 92,<br \/>\n\/\/ \u662f\u5426\u5141\u8bb8\u653e\u5927\uff0c\u5982\u679c\u60f3\u8981\u751f\u6210\u5c0f\u56fe\u7684\u65f6\u5019\u4e0d\u5931\u771f\uff0c\u6b64\u9009\u9879\u5e94\u8be5\u8bbe\u7f6e\u4e3afalse.<br \/>\nallowMagnify: false,<br \/>\n\/\/ \u662f\u5426\u5141\u8bb8\u88c1\u526a\u3002<br \/>\ncrop: false,<br \/>\n\/\/ \u662f\u5426\u4fdd\u7559\u5934\u90e8meta\u4fe1\u606f\u3002<br \/>\npreserveHeaders: true,<br \/>\ncompressSize: 1<br \/>\n} : false,<br \/>\nauto: true<br \/>\n});<br \/>\nuploader1.on('uploadSuccess', function (file, ret) {<br \/>\nif (ret.state === \"SUCCESS\") {<br \/>\nthat.execCommand('inserthtml', \"<img decoding=\"async\" src=\"https:\/\/www.kancloud.cn\/swordfly\/javascript\/%22%20+%20ret.url%20+%20%22\" \/>\");<br \/>\n}<br \/>\n})<br \/>\n}<\/p>\n<pre><code>  setTimeout(imgUploader, <span class=\"hljs-number\">500<\/span>)<span class=\"hljs-comment\">;<\/span>\r\n})<span class=\"hljs-comment\">;<\/span>\r\nreturn ui<span class=\"hljs-comment\">;<\/span>\r\n<\/code><\/pre>\n<p>};<\/p>\n<p>\\themes\\default_css\\editor.css<br \/>\n\u6587\u4ef6\u5c3e\u6dfb\u52a0 .webuploader-container &gt; div:last-child{opacity:0}<\/p>\n<h1 class=\"line\" data-line=\"97\"><a id=\"WebUpload_97\"><\/a>WebUpload\u4e0a\u4f20\u6587\u4ef6\u9ed8\u8ba4\u8c03\u7528\u7cfb\u7edf\u76f8\u673a\uff0c\u800c\u4e0d\u662f\u624b\u673a\u76f8\u518c\u95ee\u9898<\/h1>\n<p>capture=camera,\u7528\u7f16\u8f91\u5668\u6253\u5f00<br \/>\nwebupload.js l.attr(\"capture\",\"camera\") \u5220\u9664\u3002<\/p>\n<h1 class=\"line\" data-line=\"101\"><a id=\"styledivdivp_101\"><\/a>\u7f16\u8f91\u5668\u5c06style\u6807\u8bb0\u8f6c\u6362\u4e3adiv\uff0c\u800c\u5c06div\u7b49\u6807\u7b7e\u4ee5p\u66ff\u4ee3\u89e3\u51b3\u65b9\u6cd5<\/h1>\n<p>\u8be5\u7f16\u8f91\u5668\u5185\u90e8\u8fc7\u6ee4\u673a\u5236\u662f\u5c06style\u6807\u8bb0\u8f6c\u6362\u4e3adiv\uff0c\u800c\u5c06div\u7b49\u6807\u7b7e\u4ee5p\u66ff\u4ee3\u3002\u5982\u4f55\u89e3\u51b3\u5462\uff1f<br \/>\n\u4e4b\u524d\u6709\u5728\u7f51\u4e0a\u67e5\u8fc7\u76f8\u5173\u7684\u8d44\u6599\uff0c\u90fd\u8bf4\u662f\u5728\u914d\u7f6e\u6587\u4ef6\u91cc\u6709\u4e00\u4e2a\u9ed1\u767d\u540d\u5355\uff0c\u7136\u540e\u5c31\u5728\u914d\u7f6e\u6587\u4ef6\u91cc\u627e\u4e86\u4e0b\uff0c\u5728\u6700\u65b0\u7248\u672c\u7684\u811a\u672c\u6587\u4ef6\u91cc\u600e\u4e48\u627e\u4e5f\u6ca1\u627e\u5230\u90a3\u4e2a\u6240\u8c13\u7684\u9ed1\u767d\u540d\u5355\uff0c<br \/>\n\u5f53\u7136\u4e86\uff0c\u6ca1\u6709\u9ed1\u767d\u540d\u5355\u4e5f\u7167\u6837\u53ef\u4ee5\u89e3\u51b3\u95ee\u9898\u7684\u3002<br \/>\n\u9996\u5148\u5728ueditor.all.js\u6587\u4ef6\u5185\u641c\u7d22allowDivTransToP,\u627e\u5230\u5982\u4e0b\u7684\u4ee3\u7801\uff0c\u5c06true\u8bbe\u7f6e\u4e3afalse<br \/>\nme.setOpt('allowDivTransToP',false);<br \/>\n\/\/\u9ed8\u8ba4\u7684\u8fc7\u6ee4\u5904\u7406<br \/>\n\/\/\u8fdb\u5165\u7f16\u8f91\u5668\u7684\u5185\u5bb9\u5904\u7406<br \/>\n\u7136\u540e\u518d\u63a5\u7740\u4e0b\u8fb9\u7684addInputRule\u65b9\u6cd5\u4e2d\u5c06switch\u4ee3\u7801\u6bb5\u4e2d\u7684case style,script\u90fd\u7ed9\u6ce8\u91ca\u6216\u8005\u5220\u6389\u3002<br \/>\nme.addInputRule(function (root) {<br \/>\nvar allowDivTransToP = this.options.allowDivTransToP;<br \/>\nvar val;<br \/>\n\/\/\u8fdb\u884c\u9ed8\u8ba4\u7684\u5904\u7406<br \/>\nroot.traversal(function (node) {<br \/>\nif (node.type == 'element') {<br \/>\nif (!dtd.$cdata[node.tagName] &amp;&amp; me.options.autoClearEmptyNode &amp;&amp; dtd.$inline[node.tagName] &amp;&amp; !dtd.$empty[node.tagName] &amp;&amp; (!node.attrs || utils.isEmptyObject(node.attrs))) {<br \/>\nif (!node.firstChild()) node.parentNode.removeChild(node);<br \/>\nelse if (node.tagName == 'span' &amp;&amp; (!node.attrs || utils.isEmptyObject(node.attrs))) {<br \/>\nnode.parentNode.removeChild(node, true)<br \/>\n}<br \/>\nreturn;<br \/>\n}<\/p>\n<p>\/\/\u5220\u9664switch\u4e0b\u7684case style \u548cscript<br \/>\nswitch (node.tagName) {<br \/>\ncase 'a':<br \/>\nif (val = node.getAttr('href')) {<br \/>\nnode.setAttr('_href', val)<br \/>\n}<br \/>\nbreak;<br \/>\n\u5b8c\u6210\u4ee5\u4e0a\u64cd\u4f5c\u4e4b\u540e\uff0c\u4fdd\u5b58\u5373\u53ef\u3002\u518d\u6b21\u63d2\u5165html\u65f6\uff0c\u6837\u5f0f\u5c31\u53ef\u4ee5\u663e\u793a\u4e86\u3002<br \/>\n\u89e3\u91ca\u4e00\u4e0b\u4ee5\u4e0a\u64cd\u4f5c\u7684\u610f\u4e49\u3002<br \/>\n\u7b2c\u4e00\u6b65\u5c06allowDivTransToP\u8bbe\u7f6e\u4e3afalse\u662f\u56e0\u4e3a\u9ed8\u8ba4\u7684\u8bbe\u7f6e\u662f\u5c06div\u81ea\u52a8\u8f6c\u6362\u4e3ap\uff0c\u8fd9\u6837\u5199\u597d\u7684\u6837\u5f0f\u5c31\u627e\u4e0d\u5230\u76f8\u5e94\u7684div<br \/>\n\u4e86\uff0c\u6240\u4ee5\u624d\u6e32\u67d3\u4e0d\u4e0a\u7684\u3002<br \/>\n\u7b2c\u4e8c\u6b65\u5c06addInputRule\u51fd\u6570\u4e2d\u7684switch \u4ee3\u7801\u6bb5\u4e2d\u7684case style \uff0cscript\u9009\u62e9\u7ed9\u5220\u9664\u6216\u8005\u6ce8\u91ca\uff0c\u662f\u4e3a\u4e86\u907f\u514d\u51fa\u73b0\u7f16\u8f91\u5668\u5c06style\u6216script\u81ea\u52a8\u7684\u8f6c\u6362\u6210\u522b\u7684\u6807\u7b7e\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u5927\u5bb6\u53ef\u4ee5\u8bd5\u4e00\u8bd5\uff0c\u770b\u770b\u6548\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u70b9\u51fb\u9009\u62e9\u56fe\u7247\u3011\u65f6\u65e0\u6cd5\u7acb\u5373\u5f39\u51fa\u9009\u62e9\u6846\uff0c\u800c\u662f\u7b494-7\u79d2\u949f\u624d\u663e\u793a\u51fa\u6765\u7684BUG \u4fee\u6539\u8def\u5f84:\/ueditor\/dial [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/187"}],"collection":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187"}],"version-history":[{"count":1,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":188,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions\/188"}],"wp:attachment":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}