From 46165a393a35b878d5f8a619ad34d16adeeb36bc Mon Sep 17 00:00:00 2001 From: hailt Date: Wed, 4 Dec 2019 16:58:34 +0700 Subject: [PATCH] fix authenticate token upload file --- vendor/assets/javascripts/redactor-rails/redactor.js | 2 ++ vendor/assets/javascripts/redactor-rails/redactor.min.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vendor/assets/javascripts/redactor-rails/redactor.js b/vendor/assets/javascripts/redactor-rails/redactor.js index fce9bc7..77faf27 100755 --- a/vendor/assets/javascripts/redactor-rails/redactor.js +++ b/vendor/assets/javascripts/redactor-rails/redactor.js @@ -9136,7 +9136,9 @@ REDACTOR = {version: "10.2.5", instances: {}, params: {}}; } var xhr = new XMLHttpRequest(); + var csrf_token = $('meta[name=csrf-token]').attr('content'); xhr.open('POST', this.upload.url); + xhr.setRequestHeader('X-CSRF-Token', csrf_token); xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); // complete diff --git a/vendor/assets/javascripts/redactor-rails/redactor.min.js b/vendor/assets/javascripts/redactor-rails/redactor.min.js index a107d48..28f854a 100755 --- a/vendor/assets/javascripts/redactor-rails/redactor.min.js +++ b/vendor/assets/javascripts/redactor-rails/redactor.min.js @@ -9,4 +9,4 @@ Usage: $('#content').redactor(); */ -REDACTOR={version:"10.2.5",instances:{},params:{}},function(t){"use strict";function e(t,i){return new e.prototype.init(t,i)}Function.prototype.bind||(Function.prototype.bind=function(t){var e=this;return function(){return e.apply(t)}});var i=0;t.fn.redactor=function(i){var s=[],r=Array.prototype.slice.call(arguments,1);return"string"==typeof i?this.each(function(){var e,o=t.data(this,"redactor");if("-1"!=i.search(/\./)?void 0!==o[(e=i.split("."))[0]]&&(e=o[e[0]][e[1]]):e=o[i],void 0!==o&&t.isFunction(e)){var a=e.apply(o,r);void 0!==a&&a!==o&&s.push(a)}else t.error('No such method "'+i+'" for Redactor')}):this.each(function(){t.data(this,"redactor",{}),t.data(this,"redactor",e(this,i))}),0===s.length?this:1===s.length?s[0]:s},t.Redactor=e,t.Redactor.VERSION="10.2.5",t.Redactor.modules=["alignment","autosave","block","buffer","build","button","caret","clean","code","core","dropdown","file","focus","image","indent","inline","insert","keydown","keyup","lang","line","link","linkify","list","modal","observe","paragraphize","paste","placeholder","progress","selection","shortcuts","tabifier","tidy","toolbar","upload","utils"],t.Redactor.opts={lang:"en",direction:"ltr",plugins:!1,focus:!1,focusEnd:!1,placeholder:!1,visual:!0,tabindex:!1,minHeight:!1,maxHeight:!1,linebreaks:!1,replaceDivs:!0,paragraphize:!0,cleanStyleOnEnter:!1,enterKey:!0,cleanOnPaste:!0,cleanSpaces:!0,pastePlainText:!1,autosave:!1,autosaveName:!1,autosaveInterval:60,autosaveOnChange:!1,autosaveFields:!1,linkTooltip:!0,linkProtocol:"http",linkNofollow:!1,linkSize:50,imageEditable:!0,imageLink:!0,imagePosition:!0,imageFloatMargin:"10px",imageResizable:!0,imageUpload:null,imageUploadParam:"file",uploadImageField:!1,dragImageUpload:!0,fileUpload:null,fileUploadParam:"file",dragFileUpload:!0,s3:!1,convertLinks:!0,convertUrlLinks:!0,convertImageLinks:!0,convertVideoLinks:!0,preSpaces:4,tabAsSpaces:!1,tabKey:!0,scrollTarget:!1,toolbar:!0,toolbarFixed:!0,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarExternal:!1,toolbarOverflow:!1,source:!0,buttons:["html","formatting","bold","italic","deleted","unorderedlist","orderedlist","outdent","indent","image","file","link","alignment","horizontalrule"],buttonsHide:[],buttonsHideOnMobile:[],formatting:["p","blockquote","pre","h1","h2","h3","h4","h5","h6"],formattingAdd:!1,tabifier:!0,deniedTags:["script","style"],allowedTags:!1,paragraphizeBlocks:["table","div","pre","form","ul","ol","h1","h2","h3","h4","h5","h6","dl","blockquote","figcaption","address","section","header","footer","aside","article","object","style","script","iframe","select","input","textarea","button","option","map","area","math","hr","fieldset","legend","hgroup","nav","figure","details","menu","summary","p"],removeComments:!1,replaceTags:[["strike","del"],["b","strong"]],replaceStyles:[["font-weight:\\s?bold","strong"],["font-style:\\s?italic","em"],["text-decoration:\\s?underline","u"],["text-decoration:\\s?line-through","del"]],removeDataAttr:!1,removeAttr:!1,allowedAttr:!1,removeWithoutAttr:["span"],removeEmpty:["p"],activeButtons:["deleted","italic","bold","underline","unorderedlist","orderedlist","alignleft","aligncenter","alignright","justify"],activeButtonsStates:{b:"bold",strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted",ul:"unorderedlist",ol:"orderedlist",u:"underline"},shortcuts:{"ctrl+shift+m, meta+shift+m":{func:"inline.removeFormat"},"ctrl+b, meta+b":{func:"inline.format",params:["bold"]},"ctrl+i, meta+i":{func:"inline.format",params:["italic"]},"ctrl+h, meta+h":{func:"inline.format",params:["superscript"]},"ctrl+l, meta+l":{func:"inline.format",params:["subscript"]},"ctrl+k, meta+k":{func:"link.show"},"ctrl+shift+7":{func:"list.toggle",params:["orderedlist"]},"ctrl+shift+8":{func:"list.toggle",params:["unorderedlist"]}},shortcutsAdd:!1,buffer:[],rebuffer:[],emptyHtml:"

",invisibleSpace:"​",imageTypes:["image/png","image/jpeg","image/gif"],indentValue:20,verifiedTags:["a","img","b","strong","sub","sup","i","em","u","small","strike","del","cite","ul","ol","li"],inlineTags:["strong","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small"],alignmentTags:["P","H1","H2","H3","H4","H5","H6","DL","DT","DD","DIV","TD","BLOCKQUOTE","OUTPUT","FIGCAPTION","ADDRESS","SECTION","HEADER","FOOTER","ASIDE","ARTICLE"],blockLevelElements:["PRE","UL","OL","LI"],highContrast:!1,observe:{dropdowns:[]},langs:{en:{html:"HTML",video:"Insert Video",image:"Insert Image",table:"Table",link:"Link",link_insert:"Insert link",link_edit:"Edit link",unlink:"Unlink",formatting:"Formatting",paragraph:"Normal text",quote:"Quote",code:"Code",header1:"Header 1",header2:"Header 2",header3:"Header 3",header4:"Header 4",header5:"Header 5",bold:"Bold",italic:"Italic",fontcolor:"Font Color",backcolor:"Back Color",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",cancel:"Cancel",insert:"Insert",save:"Save",_delete:"Delete",insert_table:"Insert Table",insert_row_above:"Add Row Above",insert_row_below:"Add Row Below",insert_column_left:"Add Column Left",insert_column_right:"Add Column Right",delete_column:"Delete Column",delete_row:"Delete Row",delete_table:"Delete Table",rows:"Rows",columns:"Columns",add_head:"Add Head",delete_head:"Delete Head",title:"Title",image_position:"Position",none:"None",left:"Left",right:"Right",center:"Center",image_web_link:"Image Web Link",text:"Text",mailto:"Email",web:"URL",video_html_code:"Video Embed Code or Youtube/Vimeo Link",file:"Insert File",upload:"Upload",download:"Download",choose:"Choose",or_choose:"Or choose",drop_file_here:"Drop file here",align_left:"Align text to the left",align_center:"Center text",align_right:"Align text to the right",align_justify:"Justify text",horizontalrule:"Insert Horizontal Rule",deleted:"Deleted",anchor:"Anchor",link_new_tab:"Open link in new tab",underline:"Underline",alignment:"Alignment",filename:"Name (optional)",edit:"Edit",upload_label:"Drop file here or "}},linkify:{regexps:{youtube:/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/gi,vimeo:/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/,image:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi}},codemirror:!1,urlPdfView:null,urlPdfViewPhone:null,usePdfViewer:null,downloadDefaultPdf:null,attachmentsPath:null,isInsertTemplate:!1},e.fn=t.Redactor.prototype={keyCode:{BACKSPACE:8,DELETE:46,UP:38,DOWN:40,ENTER:13,SPACE:32,ESC:27,TAB:9,CTRL:17,META:91,SHIFT:16,ALT:18,RIGHT:39,LEFT:37,LEFT_WIN:91},init:function(e,s){if(this.$element=t(e),this.uuid=i++,this.rtePaste=!1,this.$pasteBox=!1,this.loadOptions(s),this.loadModules(),this.formatting={},t.merge(this.opts.blockLevelElements,this.opts.alignmentTags),this.reIsBlock=new RegExp("^("+this.opts.blockLevelElements.join("|")+")$","i"),this.tidy.setupAllowed(),!1!==this.opts.deniedTags)for(var r=["html","head","link","body","meta","applet"],o=0;o"),s=this.selection.getBlock(),this.block.toggle(t(s));else if(s.tagName.toLowerCase()!=e)if(this.opts.linebreaks&&"p"==e)t(s).append("
"),this.utils.replaceWithContents(s);else{var r=this.utils.replaceToTag(s,e);this.block.toggle(r),"p"!=e&&"blockquote"!=e&&r.find("img").remove(),this.block.isRemoveInline&&this.utils.removeInlineTags(r),("p"==e||this.block.headTag)&&r.find("p").contents().unwrap(),this.block.formatTableWrapping(r)}else if("blockquote"==e&&s.tagName.toLowerCase()==e)if(this.opts.linebreaks)t(s).append("
"),this.utils.replaceWithContents(s);else{var o=this.utils.replaceToTag(s,"p");this.block.toggle(o)}else s.tagName.toLowerCase()==e&&this.block.toggle(t(s));void 0===this.block.type&&void 0===this.block.value&&t(s).removeAttr("class").removeAttr("style")}else{if("blockquote"!=e)return;this.block.formatListToBlockquote()}},setMultiple:function(e){var i=this.block.blocks[0],s="TD"==this.block.containerTag||"TH"==this.block.containerTag;if(!1!==i&&1===this.block.blocksSize)if(i.tagName.toLowerCase()==e&&"blockquote"==e)if(this.opts.linebreaks)t(i).append("
"),this.utils.replaceWithContents(i);else{var r=this.utils.replaceToTag(i,"p");this.block.toggle(r)}else if("LI"==i.tagName){if("blockquote"!=e)return;this.block.formatListToBlockquote()}else if("BLOCKQUOTE"==this.block.containerTag)this.block.formatBlockquote(e);else if(this.opts.linebreaks&&(s||this.range.commonAncestorContainer!=i))this.block.formatWrap(e);else if(this.opts.linebreaks&&"p"==e)t(i).prepend("
").append("
"),this.utils.replaceWithContents(i);else if("TD"===i.tagName)this.block.formatWrap(e);else{var o=this.utils.replaceToTag(i,e);this.block.toggle(o),this.block.isRemoveInline&&this.utils.removeInlineTags(o),("p"==e||this.block.headTag)&&o.find("p").contents().unwrap()}else if(this.opts.linebreaks||"p"!=e){if("blockquote"==e){for(var a=0,n=0;n").append("
"),s=this.utils.replaceWithContents(i)):s=this.utils.replaceToTag(i,"p"),s&&void 0===this.block.type&&void 0===this.block.value&&s.removeAttr("class").removeAttr("style")},this))}this.block.formatWrap(e)}else{var l=0,c=!1;"class"==this.block.type&&(c="toggle",l=t(this.block.blocks).filter("."+this.block.value).length,this.block.blocksSize==l?c="toggle":this.block.blocksSize>l?c="set":0===l&&(c="set"));var h=["ul","ol","li","td","th","dl","dt","dd"];t.each(this.block.blocks,t.proxy(function(i,s){if(-1==t.inArray(s.tagName.toLowerCase(),h)){var r=this.utils.replaceToTag(s,e);c?"toggle"==c?this.block.toggle(r):"remove"==c?this.block.remove(r):"set"==c&&this.block.setForce(r):this.block.toggle(r),"p"!=e&&"blockquote"!=e&&r.find("img").remove(),this.block.isRemoveInline&&this.utils.removeInlineTags(r),("p"==e||this.block.headTag)&&r.find("p").contents().unwrap(),void 0===this.block.type&&void 0===this.block.value&&r.removeAttr("class").removeAttr("style")}},this))}},setForce:function(t){this.block.clearStyle&&t.removeAttr("class").removeAttr("style"),"class"!=this.block.type?"attr"!=this.block.type&&"data"!=this.block.type||t.attr(this.block.value.name,this.block.value.value):t.addClass(this.block.value)},toggle:function(t){return this.block.clearStyle&&t.removeAttr("class").removeAttr("style"),"class"==this.block.type?void t.toggleClass(this.block.value):"attr"==this.block.type||"data"==this.block.type?void(t.attr(this.block.value.name)==this.block.value.value?t.removeAttr(this.block.value.name):t.attr(this.block.value.name,this.block.value.value)):void t.removeAttr("style class")},remove:function(t){t.removeClass(this.block.value)},formatListToBlockquote:function(){var e=t(this.block.blocks[0]).closest("ul, ol",this.$editor[0]);t(e).find("ul, ol").contents().unwrap(),t(e).find("li").append(t("
")).contents().unwrap();var i=this.utils.replaceToTag(e,"blockquote");this.block.toggle(i)},formatBlockquote:function(e){document.execCommand("outdent"),document.execCommand("formatblock",!1,e),this.clean.clearUnverified(),this.$editor.find("p:empty").remove();var i=this.selection.getBlock();"p"!=e&&t(i).find("img").remove(),this.opts.linebreaks||this.block.toggle(t(i)),this.$editor.find("ul, ol, tr, blockquote, p").each(t.proxy(this.utils.removeEmpty,this)),this.opts.linebreaks&&"p"==e&&this.utils.replaceWithContents(i)},formatWrap:function(e){if("UL"==this.block.containerTag||"OL"==this.block.containerTag){if("blockquote"!=e)return;this.block.formatListToBlockquote()}var i=this.selection.wrap(e);if(!1!==i){var s=t(i);if(this.block.formatTableWrapping(s),s.find(this.opts.blockLevelElements.join(",")+", td, table, thead, tbody, tfoot, th, tr").contents().unwrap(),"p"!=e&&"blockquote"!=e&&s.find("img").remove(),t.each(this.block.blocks,t.proxy(this.utils.removeEmpty,this)),s.append(this.selection.getMarker(2)),this.opts.linebreaks||this.block.toggle(s),this.$editor.find("ul, ol, tr, blockquote, p").each(t.proxy(this.utils.removeEmpty,this)),s.find("blockquote:empty").remove(),this.block.isRemoveInline&&this.utils.removeInlineTags(s),this.opts.linebreaks&&"p"==e&&this.utils.replaceWithContents(s),this.opts.linebreaks){var r=s.next().next();0!=r.size()&&"BR"===r[0].tagName&&r.remove()}}},formatTableWrapping:function(t){0!==t.closest("table",this.$editor[0]).length&&(0===t.closest("tr",this.$editor[0]).length&&t.wrap(""),0===t.closest("td",this.$editor[0]).length&&0===t.closest("th").length&&t.wrap(""))},removeData:function(e,i){var s=this.selection.getBlocks();t(s).removeAttr("data-"+e),this.code.sync()},setData:function(e,i){var s=this.selection.getBlocks();t(s).attr("data-"+e,i),this.code.sync()},toggleData:function(e,i){var s=this.selection.getBlocks();t.each(s,function(){t(this).attr("data-"+e)?t(this).removeAttr("data-"+e):t(this).attr("data-"+e,i)})},removeAttr:function(e,i){var s=this.selection.getBlocks();t(s).removeAttr(e),this.code.sync()},setAttr:function(e,i){var s=this.selection.getBlocks();t(s).attr(e,i),this.code.sync()},toggleAttr:function(e,i){var s=this.selection.getBlocks();t.each(s,function(){t(this).attr(name)?t(this).removeAttr(name):t(this).attr(name,i)})},removeClass:function(e){var i=this.selection.getBlocks();t(i).removeClass(e),this.utils.removeEmptyAttr(i,"class"),this.code.sync()},setClass:function(e){var i=this.selection.getBlocks();t(i).addClass(e),this.code.sync()},toggleClass:function(e){var i=this.selection.getBlocks();t(i).toggleClass(e),this.code.sync()}}},buffer:function(){return{set:function(t){void 0===t||"undo"==t?this.buffer.setUndo():this.buffer.setRedo()},setUndo:function(){this.selection.save(),this.opts.buffer.push(this.$editor.html()),this.selection.restore()},setRedo:function(){this.selection.save(),this.opts.rebuffer.push(this.$editor.html()),this.selection.restore()},getUndo:function(){this.$editor.html(this.opts.buffer.pop())},getRedo:function(){this.$editor.html(this.opts.rebuffer.pop())},add:function(){this.opts.buffer.push(this.$editor.html())},undo:function(){0!==this.opts.buffer.length&&(this.buffer.set("redo"),this.buffer.getUndo(),this.selection.restore(),setTimeout(t.proxy(this.observe.load,this),50))},redo:function(){0!==this.opts.rebuffer.length&&(this.buffer.set("undo"),this.buffer.getRedo(),this.selection.restore(),setTimeout(t.proxy(this.observe.load,this),50))}}},build:function(){return{focused:!1,blured:!0,run:function(){this.build.createContainerBox(),this.build.loadContent(),this.build.loadEditor(),this.build.enableEditor(),this.build.setCodeAndCall()},isTextarea:function(){return"TEXTAREA"===this.$element[0].tagName},createContainerBox:function(){this.$box=t('
')},createTextarea:function(){this.$textarea=t("