diff --git a/public/tinymce/plugins/paste/classes/Clipboard.js b/public/tinymce/plugins/paste/classes/Clipboard.js index 6e77690..bfb5064 100644 --- a/public/tinymce/plugins/paste/classes/Clipboard.js +++ b/public/tinymce/plugins/paste/classes/Clipboard.js @@ -281,7 +281,6 @@ define("tinymce/pasteplugin/Clipboard", [ } // load image if there is a pasted image if (blob) { - log(blob); var reader = new FileReader(); reader.onload = function(event) { // 上传之 @@ -323,10 +322,14 @@ define("tinymce/pasteplugin/Clipboard", [ }); }; reader.readAsDataURL(blob); + return true; } + return false; } editor.on('paste', function(e) { + + var clipboardContent = getClipboardContent(e); var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 100; var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState; @@ -378,13 +381,18 @@ define("tinymce/pasteplugin/Clipboard", [ pasteHtml(html, clipboardContent['text/plain']); } }, 0); + + //----------- + // paste image + try { + if(pasteImage(e)) { + return; + } + } catch(e) {}; + }); - //----------- - // paste image - try { - pasteImage(e); - } catch(e) {}; + self.pasteHtml = pasteHtml; self.pasteText = pasteText; diff --git a/public/tinymce/plugins/paste/plugin.dev.js b/public/tinymce/plugins/paste/plugin.dev.js index 6e85652..3c0ca0a 100644 --- a/public/tinymce/plugins/paste/plugin.dev.js +++ b/public/tinymce/plugins/paste/plugin.dev.js @@ -117,4 +117,4 @@ writeScripts(); })(this); -// $hash: 5b06d9e98fb338fd1b0ff7ee116ca480 \ No newline at end of file +// $hash: cbcf61872b3ecc41bd22dcf691e2e4dd \ No newline at end of file diff --git a/public/tinymce/plugins/paste/plugin.js b/public/tinymce/plugins/paste/plugin.js index a93a4ca..83f5b81 100644 --- a/public/tinymce/plugins/paste/plugin.js +++ b/public/tinymce/plugins/paste/plugin.js @@ -466,7 +466,6 @@ define("tinymce/pasteplugin/Clipboard", [ } // load image if there is a pasted image if (blob) { - log(blob); var reader = new FileReader(); reader.onload = function(event) { // 上传之 @@ -508,10 +507,14 @@ define("tinymce/pasteplugin/Clipboard", [ }); }; reader.readAsDataURL(blob); + return true; } + return false; } editor.on('paste', function(e) { + + var clipboardContent = getClipboardContent(e); var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp < 100; var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState; @@ -563,13 +566,18 @@ define("tinymce/pasteplugin/Clipboard", [ pasteHtml(html, clipboardContent['text/plain']); } }, 0); + + //----------- + // paste image + try { + if(pasteImage(e)) { + return; + } + } catch(e) {}; + }); - //----------- - // paste image - try { - pasteImage(e); - } catch(e) {}; + self.pasteHtml = pasteHtml; self.pasteText = pasteText; diff --git a/public/tinymce/plugins/paste/plugin.min.js b/public/tinymce/plugins/paste/plugin.min.js index 8916f11..bfb827b 100644 --- a/public/tinymce/plugins/paste/plugin.min.js +++ b/public/tinymce/plugins/paste/plugin.min.js @@ -1 +1 @@ -!function(e,t){"use strict";function n(e,t){for(var n,i=[],a=0;a]+src=\"data:image[^>]+>/g,"")),n=i.fire("BeforePastePreProcess",{content:e}),n=i.fire("PastePreProcess",n),e=n.content,!n.isDefaultPrevented()){if(i.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var r=a.add(i.getBody(),"div",{style:"display:none"},e);n=i.fire("PastePostProcess",{node:r}),a.remove(r),e=n.node.innerHTML}if(!n.isDefaultPrevented()){var o=i.selection.getNode();if("PRE"==o.nodeName){if(!t)try{t=$(e).text()}catch(s){}t=t.replace(//g,">"),i.insertRawContent(t)}else i.insertContent(e)}}}function r(e){var t=e;e=i.dom.encode(e).replace(/\r\n/g,"\n");var r=i.dom.getParent(i.selection.getStart(),i.dom.isBlock),o=i.settings.forced_root_block,s;o&&(s=i.dom.createHTML(o,i.settings.forced_root_block_attrs),s=s.substr(0,s.length-3)+">"),r&&/^(PRE|DIV)$/.test(r.nodeName)||!o?e=n.filter(e,[[/\n/g,"
"]]):(e=n.filter(e,[[/\n\n/g,"

"+s],[/^(.*<\/p>)(

)$/,s+"$1"],[/\n/g,"
"]]),-1!=e.indexOf("

")&&(e=s+e)),a(e,t)}function o(){var e=i.dom,t=i.getBody(),n=i.dom.getViewPort(i.getWin()),a=i.inline?t.scrollTop:n.y,r=i.inline?t.clientHeight:n.h;s(),f=e.add(i.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(a+20)+"px;width: 10px; height: "+(r-40)+"px; overflow: hidden; opacity: 0"},v),e.setStyle(f,"left","rtl"==e.getStyle(t,"direction",!0)?65535:-65535),e.bind(f,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),g=i.selection.getRng(),f.focus(),i.selection.select(f,!0)}function s(){f&&(i.dom.unbind(f),i.dom.remove(f),g&&i.selection.setRng(g)),h=!1,f=g=null}function l(){return f?f.innerHTML:v}function c(e){var t={},n=e.clipboardData||i.getDoc().dataTransfer;if(n&&n.types){t["text/plain"]=n.getData("Text");for(var a=0;a600&&(t.width=600),r.width=t.width,a.setAttrib(o,"width",r.width)),a.setAttrib(o,"src",e.Id)}),void a.setAttrib(o,"id",null)):void a.remove(o)})},a.readAsDataURL(n)}}var u=this,f,g,m=0,v="%MCEPASTEBIN%",h;i.on("keydown",function(n){if(!n.isDefaultPrevented()&&(t.metaKeyPressed(n)&&86==n.keyCode||n.shiftKey&&45==n.keyCode)){if(h=n.shiftKey&&86==n.keyCode,n.stopImmediatePropagation(),m=(new Date).getTime(),e.ie&&h)return n.preventDefault(),void i.fire("paste",{ieFake:!0});o()}}),i.on("paste",function(t){var d=c(t),p=(new Date).getTime()-m<100,g="text"==u.pasteFormat||h;p||t.preventDefault(),!e.ie||p&&!t.ieFake||(o(),i.dom.bind(f,"paste",function(e){e.stopPropagation()}),i.getDoc().execCommand("Paste",!1,null),d["text/html"]=l(),s()),setTimeout(function(){var e=l();return f&&f.firstChild&&"mcepastebin"===f.firstChild.id&&(g=!0),s(),e!=v&&p||(e=d["text/html"]||d["text/plain"]||v,e!=v)?void(g?r(d["text/plain"]||n.innerText(e)):a(e,d["text/plain"])):void(p||i.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."))},0)});try{p(y)}catch(y){}u.pasteHtml=a,u.pasteText=r}}),i(m,[c,d,p,v,h,l],function(e,t,n,i,a,r){function o(e){return/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(e)}function s(s){var l=s.settings;s.on("BeforePastePreProcess",function(c){function d(e){function t(e,t,o,s){var l=e._listLevel||r;l!=r&&(r>l?n&&(n=n.parent.parent):(i=n,n=null)),n&&n.name==o?n.append(e):(i=i||n,n=new a(o,1),s>1&&n.attr("start",""+s),e.wrap(n)),e.name="li",t.value="";var c=t.next;c&&3==c.type&&(c.value=c.value.replace(/^\u00a0+/,"")),l>r&&i&&i.lastChild.append(n),r=l}for(var n,i,r=1,o=e.getAll("p"),s=0;s/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/([\s\u00a0]*)<\/span>/gi,function(e,t){return t.length>0?t.replace(/./," ").slice(Math.floor(t.length/2)).split("").join("\xa0"):""}]]);var m=l.paste_word_valid_elements;m||(m="@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br");var v=new n({valid_elements:m}),h=new t({},v);h.addAttributeFilter("style",function(e){for(var t=e.length,n;t--;)n=e[t],n.attr("style",p(n,n.attr("style"))),"span"!=n.name||n.attributes.length||n.unwrap()});var y=h.parse(u);d(y),c.content=new i({},v).serialize(y)}})}return s.isWordContent=o,s}),i(y,[f,c,m,l],function(e,t,n,i){return function(a){function r(e){a.on("BeforePastePreProcess",function(t){t.content=e(t.content)})}function o(e){return e=i.filter(e,[/^[\s\S]*|[\s\S]*$/g,[/\u00a0<\/span>/g,"\xa0"],/
$/])}function s(e){if(!n.isWordContent(e))return e;var r=[];t.each(a.schema.getBlockElements(),function(e,t){r.push(t)});var o=new RegExp("(?:
 [\\s\\r\\n]+|
)*(<\\/?("+r.join("|")+")[^>]*>)(?:
 [\\s\\r\\n]+|
)*","g");return e=i.filter(e,[[o,"$1"]]),e=i.filter(e,[[/

/g,"

"],[/
/g," "],[/

/g,"
"]])}function l(e){return(a.settings.paste_remove_styles||a.settings.paste_remove_styles_if_webkit!==!1)&&(e=e.replace(/ style=\"[^\"]+\"/g,"")),e}e.webkit&&(r(l),r(o)),e.ie&&r(s)}}),i(b,[w,u,m,y],function(e,t,n,i){var a;e.add("paste",function(e){function r(){"text"==s.pasteFormat?(this.active(!1),s.pasteFormat="html"):(s.pasteFormat="text",this.active(!0),a||(e.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),a=!0))}var o=this,s,l=e.settings;o.clipboard=s=new t(e),o.quirks=new i(e),o.wordFilter=new n(e),e.settings.paste_as_text&&(o.clipboard.pasteFormat="text"),l.paste_preprocess&&e.on("PastePreProcess",function(e){l.paste_preprocess.call(o,o,e)}),l.paste_postprocess&&e.on("PastePostProcess",function(e){l.paste_postprocess.call(o,o,e)}),e.addCommand("mceInsertClipboardContent",function(e,t){t.content&&o.clipboard.pasteHtml(t.content),t.text&&o.clipboard.pasteText(t.text)}),e.paste_block_drop&&e.on("dragend dragover draggesture dragdrop drop drag",function(e){e.preventDefault(),e.stopPropagation()}),e.settings.paste_data_images||e.on("drop",function(e){var t=e.dataTransfer;t&&t.files&&t.files.length>0&&e.preventDefault()}),e.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:r,active:"text"==o.clipboard.pasteFormat}),e.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:s.pasteFormat,onclick:r})})}),o([l,u,m,y,b])}(this); \ No newline at end of file +!function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r]+src=\"data:image[^>]+>/g,"")),n=i.fire("BeforePastePreProcess",{content:e}),n=i.fire("PastePreProcess",n),e=n.content,!n.isDefaultPrevented()){if(i.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var a=r.add(i.getBody(),"div",{style:"display:none"},e);n=i.fire("PastePostProcess",{node:a}),r.remove(a),e=n.node.innerHTML}if(!n.isDefaultPrevented()){var o=i.selection.getNode();if("PRE"==o.nodeName){if(!t)try{t=$(e).text()}catch(s){}t=t.replace(//g,">"),i.insertRawContent(t)}else i.insertContent(e)}}}function a(e){var t=e;e=i.dom.encode(e).replace(/\r\n/g,"\n");var a=i.dom.getParent(i.selection.getStart(),i.dom.isBlock),o=i.settings.forced_root_block,s;o&&(s=i.dom.createHTML(o,i.settings.forced_root_block_attrs),s=s.substr(0,s.length-3)+">"),a&&/^(PRE|DIV)$/.test(a.nodeName)||!o?e=n.filter(e,[[/\n/g,"
"]]):(e=n.filter(e,[[/\n\n/g,"

"+s],[/^(.*<\/p>)(

)$/,s+"$1"],[/\n/g,"
"]]),-1!=e.indexOf("

")&&(e=s+e)),r(e,t)}function o(){var e=i.dom,t=i.getBody(),n=i.dom.getViewPort(i.getWin()),r=i.inline?t.scrollTop:n.y,a=i.inline?t.clientHeight:n.h;s(),f=e.add(i.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(r+20)+"px;width: 10px; height: "+(a-40)+"px; overflow: hidden; opacity: 0"},v),e.setStyle(f,"left","rtl"==e.getStyle(t,"direction",!0)?65535:-65535),e.bind(f,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),g=i.selection.getRng(),f.focus(),i.selection.select(f,!0)}function s(){f&&(i.dom.unbind(f),i.dom.remove(f),g&&i.selection.setRng(g)),h=!1,f=g=null}function l(){return f?f.innerHTML:v}function c(e){var t={},n=e.clipboardData||i.getDoc().dataTransfer;if(n&&n.types){t["text/plain"]=n.getData("Text");for(var r=0;r600&&(t.width=600),a.width=t.width,r.setAttrib(o,"width",a.width)),r.setAttrib(o,"src",e.Id)}),void r.setAttrib(o,"id",null)):void r.remove(o)})},r.readAsDataURL(n),!0}return!1}var u=this,f,g,m=0,v="%MCEPASTEBIN%",h;i.on("keydown",function(n){if(!n.isDefaultPrevented()&&(t.metaKeyPressed(n)&&86==n.keyCode||n.shiftKey&&45==n.keyCode)){if(h=n.shiftKey&&86==n.keyCode,n.stopImmediatePropagation(),m=(new Date).getTime(),e.ie&&h)return n.preventDefault(),void i.fire("paste",{ieFake:!0});o()}}),i.on("paste",function(t){var d=c(t),g=(new Date).getTime()-m<100,y="text"==u.pasteFormat||h;g||t.preventDefault(),!e.ie||g&&!t.ieFake||(o(),i.dom.bind(f,"paste",function(e){e.stopPropagation()}),i.getDoc().execCommand("Paste",!1,null),d["text/html"]=l(),s()),setTimeout(function(){var e=l();return f&&f.firstChild&&"mcepastebin"===f.firstChild.id&&(y=!0),s(),e!=v&&g||(e=d["text/html"]||d["text/plain"]||v,e!=v)?void(y?a(d["text/plain"]||n.innerText(e)):r(e,d["text/plain"])):void(g||i.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."))},0);try{if(p(t))return}catch(t){}}),u.pasteHtml=r,u.pasteText=a}}),i(m,[c,d,p,v,h,l],function(e,t,n,i,r,a){function o(e){return/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(e)}function s(s){var l=s.settings;s.on("BeforePastePreProcess",function(c){function d(e){function t(e,t,o,s){var l=e._listLevel||a;l!=a&&(a>l?n&&(n=n.parent.parent):(i=n,n=null)),n&&n.name==o?n.append(e):(i=i||n,n=new r(o,1),s>1&&n.attr("start",""+s),e.wrap(n)),e.name="li",t.value="";var c=t.next;c&&3==c.type&&(c.value=c.value.replace(/^\u00a0+/,"")),l>a&&i&&i.lastChild.append(n),a=l}for(var n,i,a=1,o=e.getAll("p"),s=0;s/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/([\s\u00a0]*)<\/span>/gi,function(e,t){return t.length>0?t.replace(/./," ").slice(Math.floor(t.length/2)).split("").join("\xa0"):""}]]);var m=l.paste_word_valid_elements;m||(m="@[style],-strong/b,-em/i,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[!href],sub,sup,strike,br");var v=new n({valid_elements:m}),h=new t({},v);h.addAttributeFilter("style",function(e){for(var t=e.length,n;t--;)n=e[t],n.attr("style",p(n,n.attr("style"))),"span"!=n.name||n.attributes.length||n.unwrap()});var y=h.parse(u);d(y),c.content=new i({},v).serialize(y)}})}return s.isWordContent=o,s}),i(y,[f,c,m,l],function(e,t,n,i){return function(r){function a(e){r.on("BeforePastePreProcess",function(t){t.content=e(t.content)})}function o(e){return e=i.filter(e,[/^[\s\S]*|[\s\S]*$/g,[/\u00a0<\/span>/g,"\xa0"],/
$/])}function s(e){if(!n.isWordContent(e))return e;var a=[];t.each(r.schema.getBlockElements(),function(e,t){a.push(t)});var o=new RegExp("(?:
 [\\s\\r\\n]+|
)*(<\\/?("+a.join("|")+")[^>]*>)(?:
 [\\s\\r\\n]+|
)*","g");return e=i.filter(e,[[o,"$1"]]),e=i.filter(e,[[/

/g,"

"],[/
/g," "],[/

/g,"
"]])}function l(e){return(r.settings.paste_remove_styles||r.settings.paste_remove_styles_if_webkit!==!1)&&(e=e.replace(/ style=\"[^\"]+\"/g,"")),e}e.webkit&&(a(l),a(o)),e.ie&&a(s)}}),i(b,[w,u,m,y],function(e,t,n,i){var r;e.add("paste",function(e){function a(){"text"==s.pasteFormat?(this.active(!1),s.pasteFormat="html"):(s.pasteFormat="text",this.active(!0),r||(e.windowManager.alert("Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off."),r=!0))}var o=this,s,l=e.settings;o.clipboard=s=new t(e),o.quirks=new i(e),o.wordFilter=new n(e),e.settings.paste_as_text&&(o.clipboard.pasteFormat="text"),l.paste_preprocess&&e.on("PastePreProcess",function(e){l.paste_preprocess.call(o,o,e)}),l.paste_postprocess&&e.on("PastePostProcess",function(e){l.paste_postprocess.call(o,o,e)}),e.addCommand("mceInsertClipboardContent",function(e,t){t.content&&o.clipboard.pasteHtml(t.content),t.text&&o.clipboard.pasteText(t.text)}),e.paste_block_drop&&e.on("dragend dragover draggesture dragdrop drop drag",function(e){e.preventDefault(),e.stopPropagation()}),e.settings.paste_data_images||e.on("drop",function(e){var t=e.dataTransfer;t&&t.files&&t.files.length>0&&e.preventDefault()}),e.addButton("pastetext",{icon:"pastetext",tooltip:"Paste as text",onclick:a,active:"text"==o.clipboard.pasteFormat}),e.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:s.pasteFormat,onclick:a})})}),o([l,u,m,y,b])}(this); \ No newline at end of file