wp_back/wp-content/plugins/visual-portfolio/build/gutenberg/layouts-editor.js
2024-05-20 15:37:46 +03:00

1 line
8.8 KiB
JavaScript

!function(){"use strict";var t,e={7366:function(t,e,o){var r={};o.r(r),o.d(r,{apiFetch:function(){return l},setBlockData:function(){return s},updateBlockData:function(){return c}});var n={};o.r(n),o.d(n,{API_FETCH:function(){return d}});var a={};o.r(a),o.d(a,{getBlockData:function(){return v}});var i=window.wp.data;function l(t){return{type:"API_FETCH",request:t}}function s(t){return{type:"SET_BLOCK_DATA",data:t}}function c(t){return{type:"UPDATE_BLOCK_DATA",data:t}}const{apiFetch:u}=wp;function d({request:t}){return u(t).then((t=>!!(t&&t.success&&t.response)&&t.response))}const{VPSavedLayoutVariables:p}=window;const{VPSavedLayoutVariables:f}=window;function v(t){return t.data||f.data}const h=(0,i.createReduxStore)("visual-portfolio/saved-layout-data",{reducer:function(t={data:p.data},e={}){switch(e.type){case"SET_BLOCK_DATA":if(e.data)return t?{...t,data:e.data}:e;break;case"UPDATE_BLOCK_DATA":if(e.data&&t)return{...t,data:{...t.data,...e.data}}}return t},selectors:a,actions:r,controls:n});(0,i.register)(h);var m=window.wp.element,k=window.wp.blockEditor,g=window.wp.blocks,w=window.wp.components,E=window.wp.hooks,y=window.wp.i18n;const{navigator:_}=window;let b;function S(t){const[e,o]=(0,m.useState)(!1);return(0,m.createElement)("div",{className:"vpf-layout-shortcode-copy"},(0,m.createElement)("strong",null,t.label,":"),(0,m.createElement)("div",null,(0,m.createElement)("pre",null,t.content),(0,m.createElement)(w.Button,{isSmall:!0,onClick:()=>{_.clipboard.writeText(t.content).then((()=>{o(!0),clearTimeout(b),b=setTimeout((()=>{o(!1)}),450)}))}},(0,m.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},(0,m.createElement)("path",{d:"M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"}),(0,m.createElement)("path",{d:"M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"})),e?(0,m.createElement)("div",{className:"vpf-layout-shortcode-copied"},(0,y.__)("Copied!","visual-portfolio")):null)))}(0,g.registerBlockType)("visual-portfolio/saved-editor",{icon:{foreground:"#2540CC",src:(0,m.createElement)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,m.createElement)("mask",{id:"mask0","mask-type":"alpha",maskUnits:"userSpaceOnUse",x:"9",y:"8",width:"5",height:"6"},(0,m.createElement)("path",{d:"M11.1409 14L13.0565 8.49994H11.2789L9.55397 14H11.1409Z",fill:"url(#paint0_linear)"})),(0,m.createElement)("g",{mask:"url(#mask0)"},(0,m.createElement)("path",{d:"M11.1409 14L13.0565 8.49994H11.2789L9.55397 14H11.1409Z",fill:"currentColor"})),(0,m.createElement)("path",{d:"M8.90795 14L6.9923 8.49994H8.76989L10.4948 14H8.90795Z",fill:"currentColor"}),(0,m.createElement)("path",{d:"M19 16.2222C19 16.6937 18.8104 17.1459 18.4728 17.4793C18.1352 17.8127 17.6774 18 17.2 18H2.8C2.32261 18 1.86477 17.8127 1.52721 17.4793C1.18964 17.1459 1 16.6937 1 16.2222V3.77778C1 3.30628 1.18964 2.8541 1.52721 2.5207C1.86477 2.1873 2.32261 2 2.8 2H7.3L9.1 4.66667H17.2C17.6774 4.66667 18.1352 4.85397 18.4728 5.18737C18.8104 5.52076 19 5.97295 19 6.44444V16.2222Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"transparent"}),(0,m.createElement)("defs",null,(0,m.createElement)("linearGradient",{id:"paint0_linear",x1:"12.191",y1:"8.49994",x2:"7.44436",y2:"15.1301",gradientUnits:"userSpaceOnUse"},(0,m.createElement)("stop",null),(0,m.createElement)("stop",{offset:"1",stopOpacity:"0"}))))},edit:function(t){const{clientId:e}=t,[o,r]=(0,m.useState)(!1),{postId:n,blockData:a,VisualPortfolioBlockEdit:l}=(0,i.useSelect)((t=>{const{getBlockData:e}=t("visual-portfolio/saved-layout-data"),{getCurrentPostId:o}=t("core/editor"),{getBlockType:r}=t("core/blocks");return{postId:o(),blockData:e(),VisualPortfolioBlockEdit:r("visual-portfolio/block")?.edit||(()=>null)}})),{updateBlockData:s}=(0,i.useDispatch)("visual-portfolio/saved-layout-data");let c=[{label:(0,y.__)("This Saved Layout","visual-portfolio"),content:`[visual_portfolio id="${n}"]`},{label:(0,y.__)("Filter","visual-portfolio"),content:`[visual_portfolio_filter id="${n}" type="minimal" align="center" show_count="false" text_all="All"]`,isOptional:!0},{label:(0,y.__)("Sort","visual-portfolio"),content:`[visual_portfolio_sort id="${n}" type="minimal" align="center"]`,isOptional:!0}];return c=(0,E.applyFilters)("vpf.layouts-editor.shortcodes-list",c,{props:t,postId:n,blockData:a,updateBlockData:s,VisualPortfolioBlockEdit:l}),(0,m.createElement)(m.Fragment,null,(0,m.createElement)(k.InspectorControls,null,(0,m.createElement)(w.PanelBody,{title:(0,y.__)("Shortcodes","visual-portfolio"),scrollAfterOpen:!0},(0,m.createElement)("p",null,(0,y.__)("To output this saved layout and its components you can use the following shortcodes:")),c.map((t=>t.isOptional?null:(0,m.createElement)(S,{key:`shortcode-${t.label}`,...t}))),o?(0,m.createElement)(m.Fragment,null,c.map((t=>t.isOptional?(0,m.createElement)(S,{key:`shortcode-${t.label}`,...t}):null)),(0,E.applyFilters)("vpf.layouts-editor.shortcodes","",this)):(0,m.createElement)(w.Button,{isLink:!0,onClick:()=>{r(!o)}},(0,y.__)("Show Additional Shortcodes","visual-portfolio")))),(0,m.createElement)(l,{attributes:{...a,block_id:a.id||e},setAttributes:t=>{s(t)},clientId:e}))},save(){return null}});var O=window.wp.apiFetch,B=o.n(O);(0,window.wp.plugins.registerPlugin)("vpf-saved-layouts-editor",{render:function(){const{isSavingPost:t,isAutosavingPost:e,selectedBlock:o,editorSettings:r,editorMode:n,blocks:a,postId:l,blockData:s}=(0,i.useSelect)((t=>{const{isSavingPost:e,isAutosavingPost:o,getCurrentPostId:r,getEditorSettings:n}=t("core/editor"),{getSelectedBlock:a,getBlocks:i}=t("core/block-editor"),{getEditorMode:l}=t("core/edit-post"),{getBlockData:s}=t("visual-portfolio/saved-layout-data");return{isSavingPost:e(),isAutosavingPost:o(),selectedBlock:a(),editorSettings:n(),editorMode:l(),blocks:i(),postId:r(),blockData:s()}}),[]),{selectBlock:c,insertBlocks:u,resetBlocks:d}=(0,i.useDispatch)("core/block-editor"),{editPost:p}=(0,i.useDispatch)("core/editor"),{switchEditorMode:f}=(0,i.useDispatch)("core/edit-post");(0,m.useEffect)((()=>{r.richEditingEnabled&&"text"===n&&f()}),[r,n,f]);const v=(0,m.useRef)(!1);(0,m.useEffect)((()=>{v.current||1===a.length&&a[0]&&"visual-portfolio/saved-editor"===a[0].name||(v.current=!0,d([]),u((0,g.createBlock)("visual-portfolio/saved-editor")),v.current=!1)}),[a,v,d,u]);const h=(0,m.useRef)(!1);(0,m.useEffect)((()=>{if(h.current)return;if(o&&"visual-portfolio/saved-editor"===o.name)return void(h.current=!0);if(document.querySelector(".editor-post-title__block.is-selected, .editor-post-title.is-selected"))return;let t="";a.forEach((e=>{"visual-portfolio/saved-editor"===e.name&&(t=e.clientId)})),t&&c(t)}),[o,a,c]);const k=(0,m.useRef)(!1),w=(0,m.useRef)(!1);(0,m.useEffect)((()=>{s&&Object.keys(s).length&&(t||e||!k.current?k.current=JSON.stringify(s):(clearTimeout(w.current),w.current=setTimeout((()=>{k.current!==JSON.stringify(s)&&p({edited:new Date})}),150)))}),[t,e,s,p]);const E=(0,m.useRef)(!1),y=(0,m.useRef)(!1);return(0,m.useEffect)((()=>{const o=E.current&&!t&&!y.current;if(E.current=t,y.current=e,o){const t={};Object.keys(s).forEach((e=>{t[`vp_${e}`]=s[e]})),B()({path:"/visual-portfolio/v1/update_layout/",method:"POST",data:{data:t,post_id:l}}).catch((t=>{console.log(t)}))}}),[t,e,l,s]),null}})}},o={};function r(t){var n=o[t];if(void 0!==n)return n.exports;var a=o[t]={exports:{}};return e[t](a,a.exports,r),a.exports}r.m=e,t=[],r.O=function(e,o,n,a){if(!o){var i=1/0;for(u=0;u<t.length;u++){o=t[u][0],n=t[u][1],a=t[u][2];for(var l=!0,s=0;s<o.length;s++)(!1&a||i>=a)&&Object.keys(r.O).every((function(t){return r.O[t](o[s])}))?o.splice(s--,1):(l=!1,a<i&&(i=a));if(l){t.splice(u--,1);var c=n();void 0!==c&&(e=c)}}return e}a=a||0;for(var u=t.length;u>0&&t[u-1][2]>a;u--)t[u]=t[u-1];t[u]=[o,n,a]},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t={3997:0,4274:0};r.O.j=function(e){return 0===t[e]};var e=function(e,o){var n,a,i=o[0],l=o[1],s=o[2],c=0;if(i.some((function(e){return 0!==t[e]}))){for(n in l)r.o(l,n)&&(r.m[n]=l[n]);if(s)var u=s(r)}for(e&&e(o);c<i.length;c++)a=i[c],r.o(t,a)&&t[a]&&t[a][0](),t[a]=0;return r.O(u)},o=self.webpackChunkvisual_portfolio=self.webpackChunkvisual_portfolio||[];o.forEach(e.bind(null,0)),o.push=e.bind(null,o.push.bind(o))}();var n=r.O(void 0,[4274],(function(){return r(7366)}));n=r.O(n)}();