# codoc/0.1/dist/blocks.build.js

codoc, version 0.1. 1 lines.

- Page: https://pluginprobe.com/plugins/codoc/0.1/code/dist/blocks.build.js
- Raw: https://pluginprobe.com/plugins/codoc/0.1/raw/dist/blocks.build.js
- Modified: 2019-08-19T01:21:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/codoc/0.1/code/dist/blocks.build.js#L10-L20`.

```javascript
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,n){"use strict";function r(e,t){if("string"!==typeof e)throw new TypeError("argument str must be a string");for(var n={},r=t||{},o=e.split(s),c=r.decode||a,l=0;l<o.length;l++){var u=o[l],p=u.indexOf("=");if(!(p<0)){var f=u.substr(0,p).trim(),m=u.substr(++p,u.length).trim();'"'==m[0]&&(m=m.slice(1,-1)),void 0==n[f]&&(n[f]=i(m,c))}}return n}function o(e,t,n){var r=n||{},o=r.encode||c;if("function"!==typeof o)throw new TypeError("option encode is invalid");if(!l.test(e))throw new TypeError("argument name is invalid");var i=o(t);if(i&&!l.test(i))throw new TypeError("argument val is invalid");var a=e+"="+i;if(null!=r.maxAge){var s=r.maxAge-0;if(isNaN(s))throw new Error("maxAge should be a Number");a+="; Max-Age="+Math.floor(s)}if(r.domain){if(!l.test(r.domain))throw new TypeError("option domain is invalid");a+="; Domain="+r.domain}if(r.path){if(!l.test(r.path))throw new TypeError("option path is invalid");a+="; Path="+r.path}if(r.expires){if("function"!==typeof r.expires.toUTCString)throw new TypeError("option expires is invalid");a+="; Expires="+r.expires.toUTCString()}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite){switch("string"===typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;default:throw new TypeError("option sameSite is invalid")}}return a}function i(e,t){try{return t(e)}catch(t){return e}}t.parse=r,t.serialize=o;var a=decodeURIComponent,c=encodeURIComponent,s=/; */,l=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(2)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==typeof t&&"function"!==typeof t?e:t}function i(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=n(3),c=(n.n(a),n(4)),s=(n.n(c),n(5)),l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),__=wp.i18n.__,u=wp.element.Component,p=wp.blocks.registerBlockType,f=wp.editor,m=f.InspectorControls,h=f.RichText,d=wp.components,y=d.SelectControl,b=d.PanelBody,g="https://codoc.jp",v=new s.a,w=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),l(t,[{key:"fetchEntries",value:function(e,t){var n=this.props,r=n.setAttributes,o=n.attributes;o.entries;if(!o.fetching){r({fetching:!0});var i=g+"/api/v1/paywall/"+e+"/entries";t&&(i=i+"/"+t),fetch(i).then(function(e){return e.json()}).then(function(e){var t=[],n=[];if(e.status&&e.entries)for(var o=0;o<e.entries.length;o++){var i={value:e.entries[o].code,label:e.entries[o].title};t[o]=i,n[e.entries[o].code]=e.entries[o].image_url}t.length&&(r({entries:t}),r({entryCode:t[0].value}),r({entryLabel:t[0].label}),r({entryImgSrc:n[t[0].value]}),r({eyecatchMap:n})),r({fetching:!1})})}}},{key:"getEntryLabel",value:function(e){for(var t=this.props.attributes.entries,n=0;n<t.length;n++)if(t[n].value===e)return t[n].label}},{key:"render",value:function(){var e=this,t=this.props,n=t.setAttributes,r=t.attributes,o=r.userCode,i=r.entryCode,a=r.entryLabel,c=r.entries,s=r.eyecatchMap,l=c;if(o&&i&&a&&!c&&(l=[{value:i,label:a}],n({entries:l})),!o){var u=v.get("codocUserCode");u&&(n({userCode:u}),this.fetchEntries(u))}if(!l){var p=[{value:"-",label:__("\u30e6\u30fc\u30b6\u30fc\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044")}];n({entries:p}),n({entryLabel:"\u30d6\u30ed\u30c3\u30af\u8a2d\u5b9a\u3092\u958b\u3044\u3066\u30e6\u30fc\u30b6\u30fc\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044"})}return wp.element.createElement(m,{key:"CodocControls"},wp.element.createElement(b,null,wp.element.createElement("label",null,"\u30e6\u30fc\u30b6\u30fc\u30b3\u30fc\u30c9"),wp.element.createElement("label",null,wp.element.createElement("a",{href:g+"/me/account?from_wp=1",target:"_blank"},"\u78ba\u8a8d\u2197\ufe0f")),wp.element.createElement(h,{tagName:"div",placeholder:__("\u3053\u3053\u306b\u30b3\u30d4\u30fc\u3057\u3066\u8cbc\u4ed8\u3051"),value:o,key:"usercodeform",unstableOnSplit:function(){return!1},onChange:function(t){n({userCode:t});var r=new Date;r.setMonth(r.getMonth()+12),v.set("codocUserCode",t,{path:"/",expires:r}),e.fetchEntries(t)}}),wp.element.createElement("br",null),wp.element.createElement("label",null,"\u8a18\u4e8b\u30b3\u30fc\u30c9"),wp.element.createElement(h,{tagName:"div",placeholder:__(""),key:"usercodeform",value:i,unstableOnSplit:function(){return!1},onChange:function(t){e.fetchEntries(v.get("codocUserCode"),t)}}),wp.element.createElement("br",null),wp.element.createElement(y,{label:__("\u8a18\u4e8b\u4e00\u89a7"),description:__("\u8cbc\u308a\u4ed8\u3051\u308b\u8a18\u4e8b\u3092\u9078\u3093\u3067\u304f\u3060\u3055\u3044"),options:l,value:i,onChange:function(t){n({entryCode:t}),n({entryLabel:e.getEntryLabel(t)}),n({entryImgSrc:s[t]})}}),wp.element.createElement("button",{onClick:function(t){e.fetchEntries(o)}},"\u8a18\u4e8b\u4e00\u89a7\u3092\u518d\u53d6\u5f97")),wp.element.createElement("a",{href:g+"/me/entries/create?from_wp=1",target:"_blank"},"\u8a18\u4e8b\u3092\u4f5c\u6210\u2197\ufe0f"))}}]),t}(u),E=function(e){function t(){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),l(t,[{key:"render",value:function(){var e=this.props,t=e.attributes,n=(t.id,t.text),r=(t.userCode,t.entryCode),o=t.entryLabel,i=t.entryImgSrc,a=e.setAttributes;return[wp.element.createElement(w,Object.assign({setAttributes:a},this.props)),wp.element.createElement("div",{className:"codoc-block"},wp.element.createElement("div",null,wp.element.createElement("div",null,wp.element.createElement("img",{width:"50%",height:"50%",src:i})),wp.element.createElement("span",null,o),wp.element.createElement("span",null,wp.element.createElement("a",{href:g+"/me/entries/"+r+"/edit",target:"_blank"},"\u3010\u7de8\u96c6\u2197\ufe0f\u3011"))),wp.element.createElement(h,{tagName:"div",placeholder:__("\u3053\u306e\u7d9a\u304d\u306fcodoc\u3067\u8cfc\u8aad"),keepPlaceholderOnFocus:!0,className:"codoc-block-link",value:n,onChange:function(e){return a({text:e})}}))]}}]),t}(u);p("codoc/codoc-block",{title:__("codoc Block"),icon:"book",category:"common",keywords:[__("codoc Block"),__("plugin for codoc"),__("codoc-block")],attributes:{entryCode:{type:"string",default:""},entryLabel:{type:"string",default:""},userCode:{type:"string",default:""},entryImgSrc:{type:"string",default:""},text:{type:"string",default:""}},edit:E,save:function(e){var t=(e.setAttributes,e.attributes),n=t.text,r=(t.userCode,t.entryCode);t.entryLabel,t.entryImgSrc;return wp.element.createElement("div",null,wp.element.createElement("span",{id:"codoc-entry-"+r,className:"codoc-entries"},n&&!!n.length&&wp.element.createElement(h.Content,{value:n})))}})},function(e,t){},function(e,t){},function(e,t,n){"use strict";var r=n(6);t.a=r.a},function(e,t,n){"use strict";var r=n(0),o=(n.n(r),n(7)),i=n(8),a=function(){function e(e){this.changeListeners=[],this.cookies=Object(o.b)(e),this.HAS_DOCUMENT_COOKIE=Object(o.a)()}return e.prototype._updateBrowserValues=function(){this.HAS_DOCUMENT_COOKIE&&(this.cookies=r.parse(document.cookie))},e.prototype._emitChange=function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)},e.prototype.get=function(e,t){return void 0===t&&(t={}),this._updateBrowserValues(),Object(o.c)(this.cookies[e],t)},e.prototype.getAll=function(e){void 0===e&&(e={}),this._updateBrowserValues();var t={};for(var n in this.cookies)t[n]=Object(o.c)(this.cookies[n],e);return t},e.prototype.set=function(e,t,n){var o;"object"===typeof t&&(t=JSON.stringify(t)),this.cookies=i({},this.cookies,(o={},o[e]=t,o)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=r.serialize(e,t,n)),this._emitChange({name:e,value:t,options:n})},e.prototype.remove=function(e,t){var n=t=i({},t,{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=i({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=r.serialize(e,"",n)),this._emitChange({name:e,value:void 0,options:t})},e.prototype.addChangeListener=function(e){this.changeListeners.push(e)},e.prototype.removeChangeListener=function(e){var t=this.changeListeners.indexOf(e);t>=0&&this.changeListeners.splice(t,1)},e}();t.a=a},function(e,t,n){"use strict";function r(){return"object"===typeof document&&"string"===typeof document.cookie}function o(e){return"string"===typeof e?s.parse(e):"object"===typeof e&&null!==e?e:{}}function i(e,t){return"undefined"===typeof t&&(t=!e||"{"!==e[0]&&"["!==e[0]&&'"'!==e[0]),!t}function a(e,t){void 0===t&&(t={});var n=c(e);if(i(n,t.doNotParse))try{return JSON.parse(n)}catch(e){}return e}function c(e){return e&&"j"===e[0]&&":"===e[1]?e.substr(2):e}t.a=r,t.b=o,t.c=a;var s=n(0);n.n(s)},function(e,t,n){"use strict";function r(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,c,s=r(e),l=1;l<arguments.length;l++){n=Object(arguments[l]);for(var u in n)i.call(n,u)&&(s[u]=n[u]);if(o){c=o(n);for(var p=0;p<c.length;p++)a.call(n,c[p])&&(s[c[p]]=n[c[p]])}}return s}}]);
```
