Changeset 2025296
- Timestamp:
- 02/05/2019 03:08:16 PM (7 years ago)
- Location:
- cloud-blocks
- Files:
-
- 1 deleted
- 8 edited
- 43 copied
-
tags/1.1.5 (copied) (copied from cloud-blocks/trunk)
-
tags/1.1.5/README.md (copied) (copied from cloud-blocks/trunk/README.md) (1 diff)
-
tags/1.1.5/assets (copied) (copied from cloud-blocks/trunk/assets)
-
tags/1.1.5/assets/css/style.css (copied) (copied from cloud-blocks/trunk/assets/css/style.css)
-
tags/1.1.5/assets/js/script.js (copied) (copied from cloud-blocks/trunk/assets/js/script.js) (2 diffs)
-
tags/1.1.5/assets/js/script.min.js (copied) (copied from cloud-blocks/trunk/assets/js/script.min.js) (1 diff)
-
tags/1.1.5/assets/source/js/block-component.js (copied) (copied from cloud-blocks/trunk/assets/source/js/block-component.js) (1 diff)
-
tags/1.1.5/assets/source/js/block-details.js (copied) (copied from cloud-blocks/trunk/assets/source/js/block-details.js)
-
tags/1.1.5/assets/source/js/explorer-filter.js (copied) (copied from cloud-blocks/trunk/assets/source/js/explorer-filter.js)
-
tags/1.1.5/assets/source/js/script.js (copied) (copied from cloud-blocks/trunk/assets/source/js/script.js) (8 diffs)
-
tags/1.1.5/assets/source/scss/style.css (copied) (copied from cloud-blocks/trunk/assets/source/scss/style.css)
-
tags/1.1.5/assets/source/scss/style.scss (copied) (copied from cloud-blocks/trunk/assets/source/scss/style.scss)
-
tags/1.1.5/assets/thumbnail.png (copied) (copied from cloud-blocks/trunk/assets/thumbnail.png)
-
tags/1.1.5/cloud-blocks.php (copied) (copied from cloud-blocks/trunk/cloud-blocks.php) (2 diffs)
-
tags/1.1.5/composer.json (copied) (copied from cloud-blocks/trunk/composer.json)
-
tags/1.1.5/composer.lock (copied) (copied from cloud-blocks/trunk/composer.lock)
-
tags/1.1.5/core (copied) (copied from cloud-blocks/trunk/core)
-
tags/1.1.5/core/Activator.php (copied) (copied from cloud-blocks/trunk/core/Activator.php)
-
tags/1.1.5/core/Blocks/Blocks.php (copied) (copied from cloud-blocks/trunk/core/Blocks/Blocks.php)
-
tags/1.1.5/core/Blocks/Explore.php (copied) (copied from cloud-blocks/trunk/core/Blocks/Explore.php)
-
tags/1.1.5/core/Blocks/Options.php (copied) (copied from cloud-blocks/trunk/core/Blocks/Options.php)
-
tags/1.1.5/core/CloudBlocks.php (copied) (copied from cloud-blocks/trunk/core/CloudBlocks.php)
-
tags/1.1.5/core/Settings/Tools.php (copied) (copied from cloud-blocks/trunk/core/Settings/Tools.php)
-
tags/1.1.5/core/Settings/Translations.php (copied) (copied from cloud-blocks/trunk/core/Settings/Translations.php)
-
tags/1.1.5/docs (copied) (copied from cloud-blocks/trunk/docs)
-
tags/1.1.5/docs/changelog.md (copied) (copied from cloud-blocks/trunk/docs/changelog.md) (1 diff)
-
tags/1.1.5/docs/create-block.md (copied) (copied from cloud-blocks/trunk/docs/create-block.md)
-
tags/1.1.5/docs/hooks.md (copied) (copied from cloud-blocks/trunk/docs/hooks.md)
-
tags/1.1.5/docs/migrate-block.md (copied) (copied from cloud-blocks/trunk/docs/migrate-block.md)
-
tags/1.1.5/docs/private-blocks.md (copied) (copied from cloud-blocks/trunk/docs/private-blocks.md)
-
tags/1.1.5/languages (copied) (copied from cloud-blocks/trunk/languages)
-
tags/1.1.5/languages/cloud-blocks-it_IT.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-it_IT.mo)
-
tags/1.1.5/languages/cloud-blocks-it_IT.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-it_IT.po)
-
tags/1.1.5/languages/cloud-blocks-nb_NO.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-nb_NO.mo)
-
tags/1.1.5/languages/cloud-blocks-nb_NO.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-nb_NO.po)
-
tags/1.1.5/languages/cloud-blocks-pl_PL.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pl_PL.mo)
-
tags/1.1.5/languages/cloud-blocks-pl_PL.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pl_PL.po)
-
tags/1.1.5/languages/cloud-blocks-pt.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt.mo)
-
tags/1.1.5/languages/cloud-blocks-pt.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt.po)
-
tags/1.1.5/languages/cloud-blocks-pt_PT.mo (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt_PT.mo)
-
tags/1.1.5/languages/cloud-blocks-pt_PT.po (copied) (copied from cloud-blocks/trunk/languages/cloud-blocks-pt_PT.po)
-
tags/1.1.5/readme.txt (copied) (copied from cloud-blocks/trunk/readme.txt) (3 diffs)
-
tags/1.1.5/vendor (copied) (copied from cloud-blocks/trunk/vendor)
-
tags/1.1.5/vendor/bin (deleted)
-
trunk/README.md (modified) (1 diff)
-
trunk/assets/js/script.js (modified) (2 diffs)
-
trunk/assets/js/script.min.js (modified) (1 diff)
-
trunk/assets/source/js/block-component.js (modified) (1 diff)
-
trunk/assets/source/js/script.js (modified) (8 diffs)
-
trunk/cloud-blocks.php (modified) (2 diffs)
-
trunk/docs/changelog.md (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cloud-blocks/tags/1.1.5/README.md
r2020434 r2025296 20 20 21 21 ### How it works under the hood 22 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using unpkg.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud.22 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using jsdelivr.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud. 23 23 24 24 Code once, use everywhere: Since the blocks are JS/CSS only, they are CMS agnostic. This means you can develop a block for a Drupal site, and reuse it later on a WordPress blog. -
cloud-blocks/tags/1.1.5/assets/js/script.js
r2025157 r2025296 107 107 let block = res 108 108 const theBlock = {} 109 theBlock.jsUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.js}`110 theBlock.cssUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.css}`111 theBlock.editorCss = block.config.editor ? `https:// unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null109 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 110 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 111 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 112 112 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 113 theBlock.imageUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.screenshot}`113 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 114 114 theBlock.name = block.config.name 115 115 theBlock.blockManifest = JSON.stringify(block.package) … … 781 781 for (const block of res.rows) { 782 782 const theBlock = {} 783 theBlock.jsUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.js}`784 theBlock.cssUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.css}`785 theBlock.editorCss = block.config.editor ? `https:// unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null783 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 784 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 785 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 786 786 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 787 theBlock.imageUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.screenshot}`787 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 788 788 theBlock.name = block.config.name 789 789 theBlock.blockManifest = JSON.stringify(block.package) -
cloud-blocks/tags/1.1.5/assets/js/script.min.js
r2025157 r2025296 1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https:// unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,b.version&&c.block_version<b.version&&(a.updateAvailable=!0,e.availVersion=d.version),a.fromCloud=e,a.updateAvailable&&a.setAvalVersion()}})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},setAvalVersion:function b(){var a=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_version",data:a}}).done(function(a){console.log("Available new version ",a.data)}).fail(function(a){console.log("There is some issues: ",a)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}});1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,b.version&&c.block_version<b.version&&(a.updateAvailable=!0,e.availVersion=d.version),a.fromCloud=e,a.updateAvailable&&a.setAvalVersion()}})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},setAvalVersion:function b(){var a=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_version",data:a}}).done(function(a){console.log("Available new version ",a.data)}).fail(function(a){console.log("There is some issues: ",a)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}}); -
cloud-blocks/tags/1.1.5/assets/source/js/block-component.js
r2025157 r2025296 67 67 let block = res 68 68 const theBlock = {} 69 theBlock.jsUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.js}`70 theBlock.cssUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.css}`71 theBlock.editorCss = block.config.editor ? `https:// unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null69 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 70 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 71 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 72 72 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 73 theBlock.imageUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.screenshot}`73 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 74 74 theBlock.name = block.config.name 75 75 theBlock.blockManifest = JSON.stringify(block.package) -
cloud-blocks/tags/1.1.5/assets/source/js/script.js
r1973633 r2025296 6 6 searchQuery: null, 7 7 opendOverlay: null, 8 blocksCount: 0 8 blocksCount: 0, 9 refetchBlocks: false 9 10 }, 10 11 mutations: { … … 26 27 setBlocksCount(state, payload) { 27 28 state.blocksCount = payload 29 }, 30 setRefetchBlocks(state, payload) { 31 state.refetchBlocks = payload 28 32 } 29 33 }, … … 57 61 created() { 58 62 window.store.dispatch('getInstalledBlocks') 59 },60 mounted() {61 63 const currentBrowseState = this.getUrlParams('browse') ? this.getUrlParams('browse') : 'installed' 62 64 const q = this.getUrlParams('q') ? this.getUrlParams('q') : '' … … 67 69 this.getBlocks(query) 68 70 window.store.commit('setBrowseState', currentBrowseState) 71 }, 72 mounted() { 69 73 window.addEventListener('popstate', this.fetchBlocks) 70 74 }, … … 93 97 this.blocks = this.blocks.filter(block => newBlocksList.some(bl => bl.package_name == block.packageName)) 94 98 } 99 }, 100 refetchBlocks() { 101 const currentBrowseState = this.getUrlParams('browse') ? this.getUrlParams('browse') : 'installed' 102 let query = { 103 state: currentBrowseState 104 } 105 this.getBlocks(query) 95 106 } 96 107 }, … … 112 123 queryString += `&order=${query.state}` 113 124 } 114 jQuery.get(`https://api.gutenbergcloud.org/blocks?${queryString}`, (res) => { 115 if (res.count) { 116 window.store.commit('setBlocksCount', res.count) 117 } 118 for (const block of res.rows) { 119 const theBlock = {} 120 theBlock.jsUrl = `https://unpkg.com/${block.name}@${block.version}/${block.config.js}` 121 theBlock.cssUrl = `https://unpkg.com/${block.name}@${block.version}/${block.config.css}` 122 theBlock.editorCss = block.config.editor ? `https://unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null 123 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 124 theBlock.imageUrl = `https://unpkg.com/${block.name}@${block.version}/${block.config.screenshot}` 125 theBlock.name = block.config.name 126 theBlock.blockManifest = JSON.stringify(block.package) 127 theBlock.version = block.version 128 theBlock.packageName = block.name 129 if (query.state == null || query.state == 'installed') { 130 if (this.installedBlocks.length && this.installedBlocks.filter(b => b.package_name == theBlock.packageName).length) { 125 if (query.state == null || query.state == 'installed') { 126 if (this.installedBlocks.length) { 127 for (const block of this.installedBlocks) { 128 const theBlock = {} 129 theBlock.jsUrl = block.js_url 130 theBlock.cssUrl = block.css_url 131 theBlock.editorCss = block.editor_css 132 theBlock.infoUrl = block.info_url 133 theBlock.imageUrl = block.thumbnail 134 theBlock.name = block.block_name 135 theBlock.blockManifest = '\"' + block.block_manifest + '\"' 136 theBlock.version = block.block_version 137 theBlock.packageName = block.package_name 138 139 if ((query.q && query.q !== null && (theBlock.name.toLowerCase().indexOf(query.q.toLowerCase()) > -1 || theBlock.packageName.toLowerCase().indexOf(query.q.toLowerCase()) > -1)) || !query.q ) { 131 140 blocks.push(theBlock) 132 141 } 133 } else {134 blocks.push(theBlock)135 142 } 136 143 } 137 }) 144 } else if (query.state == 'local') { 145 this.localBlocks(query) 146 } else { 147 jQuery.get(`https://api.gutenbergcloud.org/blocks?${queryString}`, (res) => { 148 if (res.count) { 149 window.store.commit('setBlocksCount', res.count) 150 } 151 for (const block of res.rows) { 152 const theBlock = {} 153 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 154 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 155 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 156 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 157 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 158 theBlock.name = block.config.name 159 theBlock.blockManifest = JSON.stringify(block.package) 160 theBlock.version = block.version 161 theBlock.packageName = block.name 162 if (query.state == null || query.state == 'installed') { 163 if (this.installedBlocks.length && this.installedBlocks.filter(b => b.package_name == theBlock.packageName).length) { 164 blocks.push(theBlock) 165 } 166 } else { 167 blocks.push(theBlock) 168 } 169 } 170 }) 171 } 138 172 this.blocks = blocks 139 173 }, … … 149 183 showUploader() { 150 184 document.body.classList.toggle('show-upload-view') 151 } 185 }, 186 localBlocks(query) { 187 jQuery.ajax({ 188 type: 'POST', 189 url: fgcData.ajaxUrl, 190 data: { 191 action: "fgc_local_blocks" 192 } 193 }) 194 .done(res => { 195 if (res.data.length) { 196 window.store.commit('setBlocksCount', res.data.length) 197 window.store.commit('setRefetchBlocks', false) 198 } else { 199 window.store.commit('setBlocksCount', 0) 200 } 201 if (query.q && query.q !== null) { 202 this.blocks = res.data.filter(block => block.name.toLowerCase().indexOf(query.q.toLowerCase()) > -1 || block.packageName.toLowerCase().indexOf(query.q.toLowerCase()) > -1) 203 } else { 204 this.blocks = res.data 205 } 206 }) 207 .fail(error => { 208 console.log('There is some issues getting local blocks: ', error); 209 }) 210 }, 152 211 }, 153 212 computed: { … … 163 222 openOverlay() { 164 223 return window.store.state.opendOverlay 224 }, 225 refetchBlocks() { 226 return window.store.state.refetchBlocks 165 227 } 166 228 } -
cloud-blocks/tags/1.1.5/cloud-blocks.php
r2025157 r2025296 2 2 /* 3 3 Plugin Name: Cloud Blocks 4 Version: 1.1. 44 Version: 1.1.5 5 5 Description: Your library of Gutenberg blocks in the cloud 6 6 Author: Frontkom … … 30 30 // Plugin version . 31 31 if ( ! defined( 'FGC_VERSION' ) ) { 32 define( 'FGC_VERSION', '1.1. 4' );32 define( 'FGC_VERSION', '1.1.5' ); 33 33 } 34 34 -
cloud-blocks/tags/1.1.5/docs/changelog.md
r2025157 r2025296 1 1 ## Changelog 2 3 #### 1.1.5 4 * **Change**: Replace unpkg.com CDN in favor of jsdelivr.com 2 5 3 6 #### 1.1.4 -
cloud-blocks/tags/1.1.5/readme.txt
r2025157 r2025296 6 6 Tested up to: 5.0 7 7 Requires PHP: 5.4 8 Stable tag: 1.1. 48 Stable tag: 1.1.5 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 31 31 32 32 ## How it works under the hood 33 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using unpkg.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud.33 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using jsdelivr.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud. 34 34 35 35 Code once, use everywhere: Since the blocks are JS/CSS only, they are CMS agnostic. This means you can develop a block for a Drupal site, and reuse it later on a WordPress blog. … … 75 75 76 76 == Changelog == 77 78 = 1.1.5 = 79 * Change: Replace unpkg.com CDN in favor of jsdelivr.com 77 80 78 81 = 1.1.4 = -
cloud-blocks/trunk/README.md
r2020434 r2025296 20 20 21 21 ### How it works under the hood 22 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using unpkg.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud.22 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using jsdelivr.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud. 23 23 24 24 Code once, use everywhere: Since the blocks are JS/CSS only, they are CMS agnostic. This means you can develop a block for a Drupal site, and reuse it later on a WordPress blog. -
cloud-blocks/trunk/assets/js/script.js
r2025157 r2025296 107 107 let block = res 108 108 const theBlock = {} 109 theBlock.jsUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.js}`110 theBlock.cssUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.css}`111 theBlock.editorCss = block.config.editor ? `https:// unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null109 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 110 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 111 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 112 112 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 113 theBlock.imageUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.screenshot}`113 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 114 114 theBlock.name = block.config.name 115 115 theBlock.blockManifest = JSON.stringify(block.package) … … 781 781 for (const block of res.rows) { 782 782 const theBlock = {} 783 theBlock.jsUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.js}`784 theBlock.cssUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.css}`785 theBlock.editorCss = block.config.editor ? `https:// unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null783 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 784 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 785 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 786 786 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 787 theBlock.imageUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.screenshot}`787 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 788 788 theBlock.name = block.config.name 789 789 theBlock.blockManifest = JSON.stringify(block.package) -
cloud-blocks/trunk/assets/js/script.min.js
r2025157 r2025296 1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https:// unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,b.version&&c.block_version<b.version&&(a.updateAvailable=!0,e.availVersion=d.version),a.fromCloud=e,a.updateAvailable&&a.setAvalVersion()}})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},setAvalVersion:function b(){var a=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_version",data:a}}).done(function(a){console.log("Available new version ",a.data)}).fail(function(a){console.log("There is some issues: ",a)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://unpkg.com/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}});1 "use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Vue.component("admin-notice",{data:function a(){return{activeTimeout:-1}},template:"\n <div\n :class=\"['fgc-notification', notification.class]\"\n v-cloak>\n <p v-html=\"notification.text\"></p>\n </div>\n ",watch:{isActive:function a(){this.showingTimeout()}},mounted:function a(){this.showingTimeout()},methods:{showingTimeout:function b(){var a=this;window.clearTimeout(this.activeTimeout),this.activeTimeout=window.setTimeout(function(){window.store.state.notification.class="",a.isShowing=!1},4e3)}},computed:{isActive:function a(){return window.store.state.notification.text},notification:function a(){return window.store.state.notification}}}),Vue.component("block-card",{props:["block"],data:function a(){return{installing:!1,alreadyInstaleld:!1,updateAvailable:!1,currentVersion:null,fromCloud:null}},template:"\n <div class=\"theme\">\n <div class=\"theme-screenshot\" @click=\"openMoreDetails\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"installing\"></div>\n </div>\n\n <div v-if=\"currentBrowseState != 'installed' && alreadyInstaleld\" class=\"notice inline notice-success notice-alt\"><p>{{fgcData.strings.installed}}</p></div>\n\n <div v-if=\"currentBrowseState == 'installed' && isLocalBlock\" class=\"notice inline notice-info notice-alt\"><p>{{fgcData.strings.local_block}}</p></div>\n\n <div v-if=\"updateAvailable\" class=\"update-message notice inline notice-warning notice-alt\">\n <p>{{fgcData.strings.update_available}} <button class=\"button-link\" type=\"button\" @click=\"updateBlock\">{{fgcData.strings.update_now}}</button></p>\n </div>\n\n <span class=\"more-details\" @click=\"openMoreDetails\">{{fgcData.strings.show_more_details}}</span>\n\n <div class=\"theme-id-container\">\n <h3 class=\"theme-name\">{{ block.name }}</h3>\n <span v-if=\"blockManifest && blockManifest.author\" class=\"block-author\">{{fgcData.strings.by}}: \n <span v-if=\"typeof blockManifest.author == 'object'\">\n {{ blockManifest.author.name }}\n </span>\n <span v-if=\"typeof blockManifest.author == 'string'\">\n {{ blockManifest.author }}\n </span>\n </span>\n <span v-else class=\"block-version\">{{fgcData.strings.version}}: {{ currentVersion }}</span>\n\n <div class=\"theme-actions\">\n <button class=\"button button-primary theme-install install-block-btn\"\n v-if=\"currentBrowseState != 'installed' && !alreadyInstaleld\"\n @click.prevent=\"installBlock\">\n {{fgcData.strings.install}}\n </button>\n <button class=\"button theme-install install-block-btn\"\n v-else\n @click.prevent=\"uninstallBlock\">\n {{fgcData.strings.uninstall}}\n </button>\n <a class=\"button button-primary\" :href=\"blockUrl\" target=\"_blank\">{{fgcData.strings.homepage}}</a>\n </div>\n </div>\n\n </div>\n ",mounted:function b(){var a=this;this.currentVersion=this.block.version,!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld="installed"!=this.currentBrowseState,"installed"==this.currentBrowseState&&(window.store.state.installedBlocks.map(function(c){c.package_name!=a.block.packageName||a.isLocalBlock||jQuery.get("https://api.gutenbergcloud.org/blocks/".concat(c.package_name),function(b){if(b){var d=b,e={};e.jsUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,b.version&&c.block_version<b.version&&(a.updateAvailable=!0,e.availVersion=d.version),a.fromCloud=e,a.updateAvailable&&a.setAvalVersion()}})}),this.currentVersion=window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName})[0].block_version))},methods:{installBlock:function c(){var a=this;this.installing=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!0,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this;this.installing=!0;var b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.installing=!1,a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},updateBlock:function c(){var a=this;this.installing=!0;var b=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_block",data:b}}).done(function(b){a.installing=!1,a.updateAvailable=!1,a.currentVersion=a.block.version,window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_updated),class:"show success"}),console.log("Block Updated ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues updating block: ",b)})},setAvalVersion:function b(){var a=this.fromCloud;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_update_version",data:a}}).done(function(a){console.log("Available new version ",a.data)}).fail(function(a){console.log("There is some issues: ",a)})},incrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"POST",data:{increment:-1},url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},openMoreDetails:function a(){window.store.commit("openOverlay",this.block)}},computed:{currentBrowseState:function a(){return window.store.state.browseState},blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)}}}),Vue.component("block-details",{props:["block"],data:function a(){return{alreadyInstaleld:!1,spinnerLoaded:!1}},template:"\n <div class=\"theme-overlay\" tabindex=\"0\" role=\"dialog\"><div class=\"theme-overlay\">\n <div class=\"theme-backdrop\"></div>\n <div class=\"theme-wrap wp-clearfix\" role=\"document\">\n <div class=\"theme-header\">\n <button class=\"close dashicons dashicons-no\" @click=\"closeOverlay\"></button>\n </div>\n\n <div class=\"theme-about wp-clearfix\">\n <div class=\"theme-screenshots\">\n <div class=\"screenshot\">\n <img :src=\"block.imageUrl || fgcData.defaultThumbnail\" :alt=\"block.name\">\n <div class=\"spinner installing-block\" v-if=\"spinnerLoaded\"></div>\n </div>\n </div>\n\n <div class=\"theme-info\">\n <h2 class=\"theme-name\">\n {{ block.name }}\n <span class=\"theme-version\">{{fgcData.strings.version}}: {{ block.version }}</span>\n </h2>\n <p v-if=\"blockAuthor && authorUrl\" class=\"theme-author\">{{fgcData.strings.by}} <a :href=\"authorUrl\" target=\"_blank\">{{ blockAuthor }} </a></p>\n <p v-else-if=\"blockAuthor\" class=\"theme-author\">{{fgcData.strings.by}} {{ blockAuthor }}</p>\n\n \n <p class=\"theme-description\">\n {{ blockManifest.description }}\n </p>\n\n <p class=\"theme-tags\">\n <span>{{fgcData.strings.tags}}:</span>{{ blockTags }}\n </p>\n \n </div>\n </div>\n\n <div class=\"theme-actions\">\n <div class=\"inactive-theme\">\n <a v-if=\"alreadyInstaleld\" @click.prevent=\"uninstallBlock\" class=\"button activate\">{{fgcData.strings.uninstall}}</a>\n <a v-else @click.prevent=\"installBlock\" class=\"button activate\">{{fgcData.strings.install}}</a>\n <a :href=\"blockUrl\" target=\"_blank\" class=\"button button-primary load-customize hide-if-no-customize\">{{fgcData.strings.visit_homepage}}</a>\n <a v-if=\"isLocalBlock\" class=\"button install-block-btn button-delete load-customize hide-if-no-customize\" @click.prevent=\"deleteBlock\">{{fgcData.strings.delete_block}}</a>\n </div>\n </div>\n </div>\n </div>\n </div>",mounted:function b(){var a=this;window.addEventListener("keyup",this.keypressEvent),!window.store.state.installedBlocks.filter(function(c){return c.package_name==a.block.packageName}).length||(this.alreadyInstaleld=!0)},computed:{blockManifest:function b(){var a=JSON.parse(this.block.blockManifest);return"string"==typeof a&&""!=a?JSON.parse(a):a},isLocalBlock:function a(){return this.blockManifest&&this.blockManifest.isLocal||!1},blockUrl:function a(){return this.blockManifest.homepage?this.blockManifest.homepage:this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:"https://www.npmjs.com/package/".concat(this.block.packageName)},authorUrl:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.url?this.blockManifest.author.url:this.blockManifest.homepage?this.blockManifest.homepage:"https://www.npmjs.com/package/".concat(this.block.packageName)},blockAuthor:function a(){return this.blockManifest.author&&"object"==_typeof(this.blockManifest.author)&&this.blockManifest.author.name?this.blockManifest.author.name:this.blockManifest.author&&"string"==typeof this.blockManifest.author?this.blockManifest.author:null},blockTags:function a(){return this.blockManifest?this.blockManifest.keywords.join(", "):""}},methods:{keypressEvent:function b(a){27===a.keyCode&&this.closeOverlay()},closeOverlay:function a(){window.store.commit("openOverlay",null)},installBlock:function c(){var a=this;this.spinnerLoaded=!0;var b=this.block;console.log("Install block",b),jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_install_block",data:b}}).done(function(b){a.alreadyInstaleld=!0,a.spinnerLoaded=!1,a.isLocalBlock||a.incrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_installed),class:"show success"}),console.log("Block installed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},deleteBlock:function c(){var a=this;this.spinnerLoaded=!0,this.alreadyInstaleld&&this.uninstallBlock();var b={block:this.block,nonce:fgcData.ajaxNonce};jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_delete_block",data:b}}).done(function(b){window.store.commit("setNotification",{text:"".concat(fgcData.strings.the_block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_deleted),class:"show success"}),window.store.commit("setRefetchBlocks",!0),a.closeOverlay(),a.spinnerLoaded=!1,window.store.dispatch("getInstalledBlocks"),console.log("Block removed ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues installing block: ",b)})},uninstallBlock:function c(){var a=this,b=this.block;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_uninstall_block",data:b}}).done(function(b){a.alreadyInstaleld=!1,a.isLocalBlock||a.decrementInstalls(a.block.packageName),window.store.dispatch("getInstalledBlocks"),window.store.commit("setNotification",{text:"".concat(fgcData.strings.block," <b>").concat(a.block.name,"</b> ").concat(fgcData.strings.block_uninstalled),class:"show success"}),console.log("Block uninstalled ",b.data)}).fail(function(b){a.installing=!1,console.log("There is some issues uninstalling block: ",b)})},incrementInstalls:function b(a){jQuery.ajax({type:"PUT",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter increased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})},decrementInstalls:function b(a){jQuery.ajax({type:"DELETE",url:"https://api.gutenbergcloud.org/blocks/".concat(a)}).done(function(){console.log("Installation counter decreased ")}).fail(function(a){console.log("Some errors occured white increasing number of installs: ",a)})}}}),Vue.component("explorer-filter",{componenets:["filter-drawer"],data:function a(){return{drawerFilterOpen:!1,searchQuery:null,filterLinks:[{name:fgcData.strings.installed,slug:"installed"},{name:fgcData.strings.popular,slug:"popular"},{name:fgcData.strings.latest,slug:"latest"},{name:fgcData.strings.local,slug:"local"}]}},template:"\n <div class=\"wp-filter g-blocks-filter hide-if-no-js\">\n <div class=\"filter-count\">\n <span class=\"count theme-count\">{{ blocksCount }}</span>\n </div>\n\n <ul class=\"filter-links\">\n <li><a v-for=\"filter in filterLinks\" :key=\"filter.slug\" @click=\"filterLink(filter.slug)\" :class=\"currentFilter(filter.slug)\">{{ filter.name }}</a></li>\n </ul>\n\n <button type=\"button\" v-if=\"false\" id=\"searchFilter\" class=\"button drawer-toggle\" :aria-expanded=\"drawerFilterOpen\" @click=\"drawerFilterOpen = !drawerFilterOpen\">{{fgcData.strings.filter}}</button>\n\n <form class=\"search-form\" @submit.prevent=\"searchForBlock\"><label class=\"screen-reader-text\" for=\"wp-filter-search-input\">{{fgcData.strings.search_for_blocks}}</label><input :placeholder=\"fgcData.strings.search_blocks\" v-model=\"searchQuery\" type=\"search\" id=\"wp-filter-search-input\" class=\"wp-filter-search\"></form>\n\n <filter-drawer :style=\"{display: drawerFilterOpen ? 'block' : 'none'}\"></filter-drawer>\n </div>\n ",mounted:function a(){window.store.state.installedBlocks.length||"local"==window.store.state.browseState||this.filterLink("popular")},methods:{filterLink:function c(a){var b=window.location.search.replace(/\&browse[=a-z]*/,"");history.pushState({state:a},null,"".concat(b,"&browse=").concat(a)),window.store.commit("setBrowseState",a)},currentFilter:function b(a){return window.store.state.browseState==a?"current":""},searchForBlock:function c(){var a=window.location.search.replace(/\&q[=a-z\-]*/,""),b=this.searchQuery.replace(/\s+/g,"-").toLowerCase();history.pushState({state:b},null,"".concat(a,"&q=").concat(b)),window.store.commit("setSearchQuery",b)}},computed:{blocksCount:function a(){return"installed"===window.store.state.browseState?window.store.state.installedBlocks.length:window.store.state.blocksCount}}}),Vue.component("filter-drawer",{template:"\n <div class=\"filter-drawer\">\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n <fieldset class=\"filter-group\">\n <legend>Subject</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-blog\" value=\"blog\">\n <label for=\"filter-id-blog\">Blog</label>\n <input type=\"checkbox\" id=\"filter-id-e-commerce\" value=\"e-commerce\">\n <label for=\"filter-id-e-commerce\">E-Commerce</label>\n <input type=\"checkbox\" id=\"filter-id-education\" value=\"education\">\n <label for=\"filter-id-education\">Education</label>\n <input type=\"checkbox\" id=\"filter-id-entertainment\" value=\"entertainment\">\n <label for=\"filter-id-entertainment\">News</label>\n </div>\n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Features</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-accessibility-ready\" value=\"accessibility-ready\">\n <label for=\"filter-id-accessibility-ready\">Custom Colors</label>\n <input type=\"checkbox\" id=\"filter-id-custom-background\" value=\"custom-background\">\n <label for=\"filter-id-custom-background\">Editor style</label>\n <input type=\"checkbox\" id=\"filter-id-custom-colors\" value=\"custom-colors\">\n <label for=\"filter-id-custom-colors\">Full Width Template</label>\n </div> \n </fieldset>\n <fieldset class=\"filter-group\">\n <legend>Layout</legend>\n <div class=\"filter-group-feature\">\n <input type=\"checkbox\" id=\"filter-id-grid-layout\" value=\"grid-layout\">\n <label for=\"filter-id-grid-layout\">Grid-layout</label>\n <input type=\"checkbox\" id=\"filter-id-one-column\" value=\"one-column\">\n <label for=\"filter-id-one-column\">One Column</label>\n <input type=\"checkbox\" id=\"filter-id-two-columns\" value=\"two-columns\">\n <label for=\"filter-id-two-columns\">Two Column</label>\n <input type=\"checkbox\" id=\"filter-id-three-columns\" value=\"three-columns\">\n <label for=\"filter-id-three-columns\">Responsive</label>\n </div>\n </fieldset>\n <div class=\"buttons\">\n <button type=\"button\" class=\"apply-filters button\">Apply Filters<span></span></button>\n <button type=\"button\" class=\"clear-filters button\" aria-label=\"Clear all filters\">Clear</button>\n </div>\n\n </div>\n "});var store=new Vuex.Store({state:{notification:{},browseState:null,installedBlocks:fgcData.installedBlocks,searchQuery:null,opendOverlay:null,blocksCount:0,refetchBlocks:!1},mutations:{setNotification:function c(a,b){a.notification=b},setBrowseState:function c(a,b){a.browseState=b},setInstalledBlocks:function c(a,b){a.installedBlocks=b},setSearchQuery:function c(a,b){a.searchQuery=b},openOverlay:function c(a,b){a.opendOverlay=b},setBlocksCount:function c(a,b){a.blocksCount=b},setRefetchBlocks:function c(a,b){a.refetchBlocks=b}},actions:{getInstalledBlocks:function b(a){jQuery.ajax({type:"GET",url:fgcData.ajaxUrl,data:{action:"fgc_get_all_blocks"}}).done(function(b){a.commit("setInstalledBlocks",b.data)}).fail(function(a){console.log("There is some issues installing block: ",a)})}}}),app=new Vue({el:"#blockExplorer",data:function a(){return{blocks:[]}},created:function c(){window.store.dispatch("getInstalledBlocks");var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed",b=this.getUrlParams("q")?this.getUrlParams("q"):"";this.getBlocks({state:a,q:b}),window.store.commit("setBrowseState",a)},mounted:function a(){window.addEventListener("popstate",this.fetchBlocks)},watch:{currentBrowseFilter:function c(a){var b=this.getUrlParams("q")?this.getUrlParams("q"):"";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:a,q:b})},currentSearchQuery:function c(a){var b=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";window.store.dispatch("getInstalledBlocks");this.getBlocks({state:b,q:a})},installedBlocks:function d(a,b){var c=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";a.length!=b.length&&"installed"==c&&(this.blocks=this.blocks.filter(function(b){return a.some(function(a){return a.package_name==b.packageName})}))},refetchBlocks:function b(){var a=this.getUrlParams("browse")?this.getUrlParams("browse"):"installed";this.getBlocks({state:a})}},methods:{fetchBlocks:function c(a){var b=null;a.state&&(b=a.state.state),this.getBlocks(b)},getBlocks:function l(a){var b=this,c=[],d="";if(a.q&&null!==a.q&&(d="q=".concat(a.q)),null!==a.state&&(d+="&order=".concat(a.state)),null!=a.state&&"installed"!=a.state)"local"==a.state?this.localBlocks(a):jQuery.get("https://api.gutenbergcloud.org/blocks?".concat(d),function(d){d.count&&window.store.commit("setBlocksCount",d.count);var e=!0,f=!1,g=void 0;try{for(var h,i=function(){var d=h.value,e={};e.jsUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.js),e.cssUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.css),e.editorCss=d.config.editor?"https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.editor):null,e.infoUrl="https://www.npmjs.com/package/".concat(d.name),e.imageUrl="https://cdn.jsdelivr.net/npm/".concat(d.name,"@").concat(d.version,"/").concat(d.config.screenshot),e.name=d.config.name,e.blockManifest=JSON.stringify(d.package),e.version=d.version,e.packageName=d.name,null==a.state||"installed"==a.state?b.installedBlocks.length&&b.installedBlocks.filter(function(a){return a.package_name==e.packageName}).length&&c.push(e):c.push(e)},j=d.rows[Symbol.iterator]();!(e=(h=j.next()).done);e=!0)i()}catch(a){f=!0,g=a}finally{try{e||null==j.return||j.return()}finally{if(f)throw g}}});else if(this.installedBlocks.length){var e=!0,f=!1,g=void 0;try{for(var h,i=this.installedBlocks[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k={};k.jsUrl=j.js_url,k.cssUrl=j.css_url,k.editorCss=j.editor_css,k.infoUrl=j.info_url,k.imageUrl=j.thumbnail,k.name=j.block_name,k.blockManifest="\""+j.block_manifest+"\"",k.version=j.block_version,k.packageName=j.package_name,(a.q&&null!==a.q&&(-1<k.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<k.packageName.toLowerCase().indexOf(a.q.toLowerCase()))||!a.q)&&c.push(k)}}catch(a){f=!0,g=a}finally{try{e||null==i.return||i.return()}finally{if(f)throw g}}}this.blocks=c},getUrlParams:function e(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},showUploader:function a(){document.body.classList.toggle("show-upload-view")},localBlocks:function c(a){var b=this;jQuery.ajax({type:"POST",url:fgcData.ajaxUrl,data:{action:"fgc_local_blocks"}}).done(function(c){c.data.length?(window.store.commit("setBlocksCount",c.data.length),window.store.commit("setRefetchBlocks",!1)):window.store.commit("setBlocksCount",0),b.blocks=a.q&&null!==a.q?c.data.filter(function(b){return-1<b.name.toLowerCase().indexOf(a.q.toLowerCase())||-1<b.packageName.toLowerCase().indexOf(a.q.toLowerCase())}):c.data}).fail(function(a){console.log("There is some issues getting local blocks: ",a)})}},computed:{currentBrowseFilter:function a(){return window.store.state.browseState},currentSearchQuery:function a(){return window.store.state.searchQuery},installedBlocks:function a(){return window.store.state.installedBlocks},openOverlay:function a(){return window.store.state.opendOverlay},refetchBlocks:function a(){return window.store.state.refetchBlocks}}}); -
cloud-blocks/trunk/assets/source/js/block-component.js
r2025157 r2025296 67 67 let block = res 68 68 const theBlock = {} 69 theBlock.jsUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.js}`70 theBlock.cssUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.css}`71 theBlock.editorCss = block.config.editor ? `https:// unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null69 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 70 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 71 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 72 72 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 73 theBlock.imageUrl = `https:// unpkg.com/${block.name}@${block.version}/${block.config.screenshot}`73 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 74 74 theBlock.name = block.config.name 75 75 theBlock.blockManifest = JSON.stringify(block.package) -
cloud-blocks/trunk/assets/source/js/script.js
r1973633 r2025296 6 6 searchQuery: null, 7 7 opendOverlay: null, 8 blocksCount: 0 8 blocksCount: 0, 9 refetchBlocks: false 9 10 }, 10 11 mutations: { … … 26 27 setBlocksCount(state, payload) { 27 28 state.blocksCount = payload 29 }, 30 setRefetchBlocks(state, payload) { 31 state.refetchBlocks = payload 28 32 } 29 33 }, … … 57 61 created() { 58 62 window.store.dispatch('getInstalledBlocks') 59 },60 mounted() {61 63 const currentBrowseState = this.getUrlParams('browse') ? this.getUrlParams('browse') : 'installed' 62 64 const q = this.getUrlParams('q') ? this.getUrlParams('q') : '' … … 67 69 this.getBlocks(query) 68 70 window.store.commit('setBrowseState', currentBrowseState) 71 }, 72 mounted() { 69 73 window.addEventListener('popstate', this.fetchBlocks) 70 74 }, … … 93 97 this.blocks = this.blocks.filter(block => newBlocksList.some(bl => bl.package_name == block.packageName)) 94 98 } 99 }, 100 refetchBlocks() { 101 const currentBrowseState = this.getUrlParams('browse') ? this.getUrlParams('browse') : 'installed' 102 let query = { 103 state: currentBrowseState 104 } 105 this.getBlocks(query) 95 106 } 96 107 }, … … 112 123 queryString += `&order=${query.state}` 113 124 } 114 jQuery.get(`https://api.gutenbergcloud.org/blocks?${queryString}`, (res) => { 115 if (res.count) { 116 window.store.commit('setBlocksCount', res.count) 117 } 118 for (const block of res.rows) { 119 const theBlock = {} 120 theBlock.jsUrl = `https://unpkg.com/${block.name}@${block.version}/${block.config.js}` 121 theBlock.cssUrl = `https://unpkg.com/${block.name}@${block.version}/${block.config.css}` 122 theBlock.editorCss = block.config.editor ? `https://unpkg.com/${block.name}@${block.version}/${block.config.editor}` : null 123 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 124 theBlock.imageUrl = `https://unpkg.com/${block.name}@${block.version}/${block.config.screenshot}` 125 theBlock.name = block.config.name 126 theBlock.blockManifest = JSON.stringify(block.package) 127 theBlock.version = block.version 128 theBlock.packageName = block.name 129 if (query.state == null || query.state == 'installed') { 130 if (this.installedBlocks.length && this.installedBlocks.filter(b => b.package_name == theBlock.packageName).length) { 125 if (query.state == null || query.state == 'installed') { 126 if (this.installedBlocks.length) { 127 for (const block of this.installedBlocks) { 128 const theBlock = {} 129 theBlock.jsUrl = block.js_url 130 theBlock.cssUrl = block.css_url 131 theBlock.editorCss = block.editor_css 132 theBlock.infoUrl = block.info_url 133 theBlock.imageUrl = block.thumbnail 134 theBlock.name = block.block_name 135 theBlock.blockManifest = '\"' + block.block_manifest + '\"' 136 theBlock.version = block.block_version 137 theBlock.packageName = block.package_name 138 139 if ((query.q && query.q !== null && (theBlock.name.toLowerCase().indexOf(query.q.toLowerCase()) > -1 || theBlock.packageName.toLowerCase().indexOf(query.q.toLowerCase()) > -1)) || !query.q ) { 131 140 blocks.push(theBlock) 132 141 } 133 } else {134 blocks.push(theBlock)135 142 } 136 143 } 137 }) 144 } else if (query.state == 'local') { 145 this.localBlocks(query) 146 } else { 147 jQuery.get(`https://api.gutenbergcloud.org/blocks?${queryString}`, (res) => { 148 if (res.count) { 149 window.store.commit('setBlocksCount', res.count) 150 } 151 for (const block of res.rows) { 152 const theBlock = {} 153 theBlock.jsUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.js}` 154 theBlock.cssUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.css}` 155 theBlock.editorCss = block.config.editor ? `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.editor}` : null 156 theBlock.infoUrl = `https://www.npmjs.com/package/${block.name}` 157 theBlock.imageUrl = `https://cdn.jsdelivr.net/npm/${block.name}@${block.version}/${block.config.screenshot}` 158 theBlock.name = block.config.name 159 theBlock.blockManifest = JSON.stringify(block.package) 160 theBlock.version = block.version 161 theBlock.packageName = block.name 162 if (query.state == null || query.state == 'installed') { 163 if (this.installedBlocks.length && this.installedBlocks.filter(b => b.package_name == theBlock.packageName).length) { 164 blocks.push(theBlock) 165 } 166 } else { 167 blocks.push(theBlock) 168 } 169 } 170 }) 171 } 138 172 this.blocks = blocks 139 173 }, … … 149 183 showUploader() { 150 184 document.body.classList.toggle('show-upload-view') 151 } 185 }, 186 localBlocks(query) { 187 jQuery.ajax({ 188 type: 'POST', 189 url: fgcData.ajaxUrl, 190 data: { 191 action: "fgc_local_blocks" 192 } 193 }) 194 .done(res => { 195 if (res.data.length) { 196 window.store.commit('setBlocksCount', res.data.length) 197 window.store.commit('setRefetchBlocks', false) 198 } else { 199 window.store.commit('setBlocksCount', 0) 200 } 201 if (query.q && query.q !== null) { 202 this.blocks = res.data.filter(block => block.name.toLowerCase().indexOf(query.q.toLowerCase()) > -1 || block.packageName.toLowerCase().indexOf(query.q.toLowerCase()) > -1) 203 } else { 204 this.blocks = res.data 205 } 206 }) 207 .fail(error => { 208 console.log('There is some issues getting local blocks: ', error); 209 }) 210 }, 152 211 }, 153 212 computed: { … … 163 222 openOverlay() { 164 223 return window.store.state.opendOverlay 224 }, 225 refetchBlocks() { 226 return window.store.state.refetchBlocks 165 227 } 166 228 } -
cloud-blocks/trunk/cloud-blocks.php
r2025157 r2025296 2 2 /* 3 3 Plugin Name: Cloud Blocks 4 Version: 1.1. 44 Version: 1.1.5 5 5 Description: Your library of Gutenberg blocks in the cloud 6 6 Author: Frontkom … … 30 30 // Plugin version . 31 31 if ( ! defined( 'FGC_VERSION' ) ) { 32 define( 'FGC_VERSION', '1.1. 4' );32 define( 'FGC_VERSION', '1.1.5' ); 33 33 } 34 34 -
cloud-blocks/trunk/docs/changelog.md
r2025157 r2025296 1 1 ## Changelog 2 3 #### 1.1.5 4 * **Change**: Replace unpkg.com CDN in favor of jsdelivr.com 2 5 3 6 #### 1.1.4 -
cloud-blocks/trunk/readme.txt
r2025157 r2025296 6 6 Tested up to: 5.0 7 7 Requires PHP: 5.4 8 Stable tag: 1.1. 48 Stable tag: 1.1.5 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 31 31 32 32 ## How it works under the hood 33 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using unpkg.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud.33 Gutenberg Cloud is a service that fetches Open Source Gutenberg blocks hosted on NPM. The assets from these are served from CloudFlare using jsdelivr.com. The Cloud Blocks plugin provides an interface in WordPress for Gutenberg Cloud. 34 34 35 35 Code once, use everywhere: Since the blocks are JS/CSS only, they are CMS agnostic. This means you can develop a block for a Drupal site, and reuse it later on a WordPress blog. … … 75 75 76 76 == Changelog == 77 78 = 1.1.5 = 79 * Change: Replace unpkg.com CDN in favor of jsdelivr.com 77 80 78 81 = 1.1.4 =
Note: See TracChangeset
for help on using the changeset viewer.