diff --git a/assets/build/block.js b/assets/build/block.js index d0bd3679..44d1a98e 100644 --- a/assets/build/block.js +++ b/assets/build/block.js @@ -1 +1 @@ -(()=>{"use strict";var e,t={418:(e,t,o)=>{var l=o(609),a=Symbol.for("react.element"),r=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),n=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,o){var l,d={},s=null,c=null;for(l in void 0!==o&&(s=""+o),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(c=t.ref),t)r.call(t,l)&&!i.hasOwnProperty(l)&&(d[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===d[l]&&(d[l]=t[l]);return{$$typeof:a,type:e,key:s,ref:c,props:d,_owner:n.current}}},706:(e,t,o)=>{e.exports=o(418)},445:(e,t,o)=>{var l=o(609);const a=window.wp.blocks,r=window.wp.i18n,n=window.wp.primitives;var i=o(706);const d=(0,i.jsx)(n.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(n.Path,{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z"})}),s=(0,i.jsx)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(n.Path,{fillRule:"evenodd",d:"M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",clipRule:"evenodd"})}),c=window.wp.element,u=window.wp.blockEditor,p=window.wp.components,g=({label:e,value:t,unit:o,onValueChange:a,onUnitChange:n})=>(0,l.createElement)(p.Flex,null,(0,l.createElement)(p.FlexBlock,null,(0,l.createElement)(p.TextControl,{label:e,value:parseInt(t),onChange:e=>a(e)})),(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Unit","wedocs"),value:o,options:[{label:"px",value:"px"},{label:"%",value:"%"}],onChange:e=>n(e)}))),m=({selected:e,options:t,onChange:o})=>(0,l.createElement)(p.BaseControl,null,(0,l.createElement)("div",{className:"radio-image-control-options"},t.map((t=>(0,l.createElement)("div",{key:t.value,className:"radio-image-option"},(0,l.createElement)("input",{type:"radio",id:`radio-image-${t.value}`,value:t.value,checked:e===t.value,onChange:e=>o(e.target.value)}),(0,l.createElement)("label",{htmlFor:`radio-image-${t.value}`},t.icon&&(0,l.createElement)("i",{className:`dashicons ${t.icon}`}),t.img&&(0,l.createElement)("img",{src:t.img,alt:t.label}),t?.svg)))))),b={hideSearch:{type:"boolean",default:!1},searchWidth:{type:"number",default:50},widthUnit:{type:"string",default:"%"},placeholder:{type:"string",default:(0,r.__)("Search for a top or question","wedocs")},alignment:{type:"string",default:"right"},bgColor:{type:"string",default:"#FFFFFF"},hoverColor:{type:"string",default:"#FFFFFF"},padding:{type:"object",default:{top:14,left:22,right:22,bottom:14}},margin:{type:"object",default:{top:0,left:0,right:0,bottom:0}},borderColor:{type:"string",default:"#cccccc"},borderType:{type:"string",default:"solid"},borderWidth:{type:"number",default:1},borderRadius:{type:"number",default:30},iconColor:{type:"string",default:"#FFFFFF"},iconBgColor:{type:"string",default:"#3b82f6"},iconHoverColor:{type:"string",default:"#2563eb"},svgHoverColor:{type:"string",default:"#FFFFFF"},btnPadding:{type:"object",default:{top:24,left:26,right:26,bottom:24}},btnPosition:{type:"object",default:{top:0,right:0,bottom:10}},btnRadius:{type:"number",default:30}};(0,a.registerBlockType)("wedocs/wedocs-search",{attributes:b,save:({attributes:e})=>{const{margin:t,bgColor:o,padding:a,btnRadius:r,alignment:n,iconColor:i,widthUnit:d,hoverColor:s,borderType:p,hideSearch:g,btnPadding:m,searchWidth:b,btnPosition:h,placeholder:_,borderColor:v,borderWidth:C,iconBgColor:w,borderRadius:f,svgHoverColor:E,iconHoverColor:x}=e;if(g)return;const y={display:"flex",justifyContent:n},B={border:`${C}px ${p} ${v}`,paddingTop:a?.top,paddingLeft:a?.left,paddingRight:a?.right,borderRadius:`${f}px`,paddingBottom:a?.bottom,"--field-color":o,"--field-bg-color":s},S={top:h?.top,left:h?.left,right:h?.right,bottom:h?.bottom,height:"auto",paddingTop:m?.top,paddingLeft:m?.left,borderRadius:r,paddingRight:m?.right,paddingBottom:m?.bottom,"--field-icon-color":i,"--field-btn-bg-color":w,"--field-icon-hover-color":E,"--field-btn-bg-hover-color":x};return(0,l.createElement)(c.Fragment,null,(0,l.createElement)("form",{method:"get",role:"search",action:weDocsBlockVars?.siteUrl,...u.useBlockProps.save({className:"search-form wedocs-search-form"})},(0,l.createElement)("div",{style:y},(0,l.createElement)("div",{className:"wedocs-search-input",style:{width:b+d,marginTop:t?.top,marginLeft:t?.left,marginRight:t?.right,marginBottom:t?.bottom}},(0,l.createElement)("input",{name:"s",type:"search",style:B,className:"search-field",placeholder:_}),(0,l.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,l.createElement)("button",{type:"submit",style:S,className:"search-submit"},(0,l.createElement)("svg",{width:"15",height:"16",fill:"none"},(0,l.createElement)("path",{fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))))))},edit:({attributes:e,setAttributes:t})=>{const o=(0,u.useBlockProps)(),{margin:a,bgColor:n,padding:i,btnRadius:b,alignment:h,iconColor:_,widthUnit:v,hoverColor:C,borderType:w,hideSearch:f,btnPadding:E,searchWidth:x,btnPosition:y,placeholder:B,borderColor:S,borderWidth:k,iconBgColor:F,borderRadius:P,svgHoverColor:R,iconHoverColor:T}=e;console.log("editor panel:",n);const M=[{value:"left",label:(0,r.__)("Align left","wedocs"),svg:(0,l.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"left"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,l.createElement)("path",{d:"M8 9.462h12m-12 6h6m-10-9v12"}))},{value:"center",label:(0,r.__)("Align center","wedocs"),svg:(0,l.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"center"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,l.createElement)("path",{d:"M18 9.462H6m8.99 6h-6"}),(0,l.createElement)("path",{d:"M12 6.462v12"}))},{value:"right",label:(0,r.__)("Align right","wedocs"),svg:(0,l.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"right"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,l.createElement)("path",{d:"M16 9.462H4m12 6h-6m10-9v12"}))}],[N,D]=(0,c.useState)(!1),[O,$]=(0,c.useState)(!1),[L,A]=(0,c.useState)(!1),H={display:"flex",justifyContent:h},j={border:`${k}px ${w} ${S}`,paddingTop:i?.top,background:N?C:n,paddingLeft:i?.left,paddingRight:i?.right,borderRadius:`${P}px`,paddingBottom:i?.bottom},I={top:y?.top,left:y?.left,right:y?.right,bottom:y?.bottom,height:"auto",background:L?T:F,paddingTop:E?.top,paddingLeft:E?.left,borderRadius:b,paddingRight:E?.right,paddingBottom:E?.bottom},V=[{label:(0,r.__)("Solid","wedocs"),value:"solid"},{label:(0,r.__)("Dotted","wedocs"),value:"dotted"},{label:(0,r.__)("Dashed","wedocs"),value:"dashed"},{label:(0,r.__)("Double","wedocs"),value:"double"},{label:(0,r.__)("Groove","wedocs"),value:"groove"},{label:(0,r.__)("Ridge","wedocs"),value:"ridge"},{label:(0,r.__)("Inset","wedocs"),value:"inset"},{label:(0,r.__)("Outset","wedocs"),value:"outset"},{label:(0,r.__)("None","wedocs"),value:"none"},{label:(0,r.__)("Hidden","wedocs"),value:"hidden"}];return(0,l.createElement)(c.Fragment,null,(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(p.PanelBody,null,(0,l.createElement)(p.ToggleControl,{checked:f,className:"wedocs-search-toggle",label:(0,r.__)("Disable Block","wedocs"),onChange:e=>t({hideSearch:e})})),!f&&(0,l.createElement)(c.Fragment,null,(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Color Settings","wedocs"),icon:d,initialOpen:!1,className:"wedocs-search-color-settings"},(0,l.createElement)(u.PanelColorSettings,{colors:[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}],colorSettings:[{value:n,label:(0,r.__)("Field Background Color","wedocs"),onChange:e=>t({bgColor:e})},{value:C,label:(0,r.__)("Field Hover Color","wedocs"),onChange:e=>t({hoverColor:e})},{value:S,label:(0,r.__)("Border Color","wedocs"),onChange:e=>t({borderColor:e})},{value:_,label:(0,r.__)("Icon Color","wedocs"),onChange:e=>t({iconColor:e})},{value:F,label:(0,r.__)("Button Color","wedocs"),onChange:e=>t({iconBgColor:e})},{value:T,label:(0,r.__)("Button Hover Color","wedocs"),onChange:e=>t({iconHoverColor:e})},{value:R,label:(0,r.__)("Icon Hover Color","wedocs"),onChange:e=>t({svgHoverColor:e})}]})),(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Search Bar Settings","wedocs"),icon:s},(0,l.createElement)(g,{unit:v,value:x,label:(0,r.__)("Field Width","wedocs"),onUnitChange:e=>t({widthUnit:e}),onValueChange:e=>t({searchWidth:e?parseInt(e):0})}),(0,l.createElement)(p.TextControl,{value:B,label:(0,r.__)("Placeholder","wedocs"),placeholder:(0,r.__)("Search bar placeholder","wedocs"),onChange:e=>t({placeholder:e})}),(0,l.createElement)("p",{style:{fontSize:11}},(0,r.__)("POSITION","wedocs")),(0,l.createElement)(m,{selected:h,options:M,onChange:e=>t({alignment:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"14px",left:"22px",right:"22px",bottom:"14px"},values:i,label:(0,r.__)("Field Padding","wedocs"),onChange:e=>t({padding:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"0px",left:"0px",right:"0px",bottom:"0px"},values:a,label:(0,r.__)("Field Margin","wedocs"),onChange:e=>t({margin:e})}),(0,l.createElement)(p.RangeControl,{min:0,max:10,value:k,label:(0,r.__)("Border Width","wedocs"),onChange:e=>t({borderWidth:e})}),(0,l.createElement)(p.RangeControl,{min:0,max:100,value:P,label:(0,r.__)("Border Radius","wedocs"),onChange:e=>t({borderRadius:e})}),(0,l.createElement)(p.SelectControl,{value:w,options:V,label:(0,r.__)("Border Type","wedocs"),onChange:e=>t({borderType:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"24px",left:"26px",right:"26px",bottom:"24px"},values:E,label:(0,r.__)("Button Padding","wedocs"),onChange:e=>t({btnPadding:e})}),(0,l.createElement)(p.__experimentalBoxControl,{resetValues:{top:"0px",right:"0px",bottom:"10px"},values:y,label:(0,r.__)("Button Margin","wedocs"),onChange:e=>t({btnPosition:e})}),(0,l.createElement)(p.RangeControl,{min:0,max:100,value:b,label:(0,r.__)("Button Radius","wedocs"),onChange:e=>t({btnRadius:e})})))),(0,l.createElement)("div",{...o,style:H},(0,l.createElement)("div",{className:"wedocs-editor-search-input",style:{width:x+v,marginTop:a?.top,marginLeft:a?.left,marginRight:a?.right,marginBottom:a?.bottom}},(0,l.createElement)("input",{readOnly:!0,style:j,className:"search-field",placeholder:B,onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1)}),(0,l.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,l.createElement)("button",{type:"submit",style:I,className:"search-submit",onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1)},(0,l.createElement)("svg",{width:"15",height:"16",fill:"none",onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1)},(0,l.createElement)("path",{fill:O?R:_,fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))),f&&(0,l.createElement)("div",{className:"backdrop"})))},icon:(0,l.createElement)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},(0,l.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.91421 1.5H5.5C4.39543 1.5 3.5 2.39543 3.5 3.5V6.91421V9.02779V15.5C3.5 16.6046 4.39543 17.5 5.5 17.5H7.02779C6.07771 16.4385 5.5 15.0367 5.5 13.5C5.5 10.1863 8.18629 7.5 11.5 7.5C13.0367 7.5 14.4385 8.07771 15.5 9.02779V8.5V6.91421C15.5 6.38378 15.2893 5.87507 14.9142 5.5L11.5 2.08579C11.1249 1.71071 10.6162 1.5 10.0858 1.5H8.91421ZM15.5 13.5C15.5 11.2909 13.7091 9.5 11.5 9.5C9.29086 9.5 7.5 11.2909 7.5 13.5C7.5 15.7091 9.29086 17.5 11.5 17.5C12.2414 17.5 12.9364 17.2977 13.5318 16.946L14.7929 18.2071C15.1834 18.5976 15.8166 18.5976 16.2071 18.2071C16.5976 17.8166 16.5976 17.1834 16.2071 16.7929L14.946 15.5318C15.2977 14.9364 15.5 14.2414 15.5 13.5ZM11.5 11.5C12.6046 11.5 13.5 12.3954 13.5 13.5C13.5 14.0526 13.2772 14.5512 12.9142 14.9142C12.5512 15.2772 12.0526 15.5 11.5 15.5C10.3954 15.5 9.5 14.6046 9.5 13.5C9.5 12.3954 10.3954 11.5 11.5 11.5Z",fill:"#111827"})),title:(0,r.__)("weDocs - Searchbar","wedocs"),keywords:["Search","weDocs search bar","Bar"],category:"widgets",description:(0,r.__)("Simple search forms for easy user guidance for your documentation","wedocs")});const h=({attributes:e,setAttributes:t})=>{const o=e=>o=>{t({[e]:o})},a=((0,r.__)("Solid","wedocs"),(0,r.__)("Dashed","wedocs"),(0,r.__)("Dotted","wedocs"),(0,r.__)("None","wedocs"),[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}]);return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Grid Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,l.createElement)("label",null,(0,r.__)("Colors","wedocs")),(0,l.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.docTitleColor,label:(0,r.__)("Doc Title Color","wedocs"),onChange:e=>o("docTitleColor")(e)},{value:e.docChildrenActiveColor,label:(0,r.__)("Doc Children Active Color","wedocs"),onChange:e=>o("docChildrenActiveColor")(e)},{value:e.borderColor,label:(0,r.__)("Border Color","wedocs"),onChange:e=>o("borderColor")(e)}]}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Grid Padding","wedocs"),values:e.gridPadding,onChange:o("gridPadding")}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Grid Margin","wedocs"),values:e.gridMargin,onChange:o("gridMargin")}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Border Type","wedocs"),value:e.borderType,options:[{label:(0,r.__)("Solid","wedocs"),value:"solid"},{label:(0,r.__)("Dashed","wedocs"),value:"dashed"},{label:(0,r.__)("Dotted","wedocs"),value:"dotted"},{label:(0,r.__)("None","wedocs"),value:"none"}],onChange:e=>t({borderType:e})}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Border Width","wedocs"),value:e.borderWidth,options:[{label:"0px",value:"0px"},{label:"1px",value:"1px"},{label:"2px",value:"2px"},{label:"3px",value:"3px"},{label:"4px",value:"4px"},{label:"5px",value:"5px"}],onChange:e=>t({borderWidth:e})}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Border Radius","wedocs"),value:e.borderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({borderRadius:e})})),(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Button Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,l.createElement)("label",null,(0,r.__)("Button Colors","wedocs")),(0,l.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.buttonColor,label:(0,r.__)("Button Color","wedocs"),onChange:e=>o("buttonColor")(e)},{value:e.buttonHoverColor,label:(0,r.__)("Button Hover Color","wedocs"),onChange:e=>o("buttonHoverColor")(e)},{value:e.buttonTextColor,label:(0,r.__)("Button Text Color","wedocs"),onChange:e=>o("buttonTextColor")(e)},{value:e.buttonHoverTextColor,label:(0,r.__)("Button Hover Text Color","wedocs"),onChange:e=>o("buttonHoverTextColor")(e)}]}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Button Padding","wedocs"),values:e.buttonPadding,onChange:o("buttonPadding")}),(0,l.createElement)(p.__experimentalBoxControl,{label:(0,r.__)("Button Margin","wedocs"),values:e.buttonMargin,onChange:o("buttonMargin")}),(0,l.createElement)(p.SelectControl,{label:(0,r.__)("Button Border Radius","wedocs"),value:e.buttonBorderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({buttonBorderRadius:e})}),(0,l.createElement)("div",{className:"wedocs-color-control"},(0,l.createElement)("label",null,(0,r.__)("Button Text","wedocs")),(0,l.createElement)(p.TextControl,{value:e.buttonText,onChange:o("buttonText")}))))},_=JSON.parse('{"UU":"wedocs/wedocs-docs-grid"}');(0,a.registerBlockType)(_.UU,{edit:({attributes:e,setAttributes:t})=>{const o=(0,u.useBlockProps)(),{useSelect:a}=wp.data,[n,i]=(0,c.useState)(1),[d,g]=(0,c.useState)(!1),{hideDocGrid:m,docStyle:b,docsPerPage:_,excludeDocs:v,order:C,orderBy:w,sectionsPerDoc:f,articlesPerSection:E,showDocArticle:x,keepArticlesCollapsed:y,showViewDetails:B,gridPadding:S,gridMargin:k,docTitleColor:F,docChildrenActiveColor:P,borderType:R,borderRadius:T,borderWidth:M,borderColor:N,buttonBorderRadius:D,buttonPadding:O,buttonMargin:$,buttonColor:L,buttonHoverColor:A,buttonTextColor:H,buttonText:j,buttonHoverTextColor:I}=e,V=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],W=[{label:(0,r.__)("weDocs Order","wedocs"),value:"menu_order"},{label:(0,r.__)("ID","wedocs"),value:"id"},{label:(0,r.__)("Name","wedocs"),value:"title"}],z=[{label:(0,r.__)("Ascending","wedocs"),value:"asc"},{label:(0,r.__)("Descending","wedocs"),value:"desc"}],U=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],{pages:G,sections:Y,articles:Z}=a((e=>{const{getEntityRecords:t}=e("core"),o=t("postType","docs",{status:"publish",per_page:-1,parent:0,orderby:w,order:C}),l=o?t("postType","docs",{status:"publish",parent_in:o.map((e=>e.id)),per_page:-1}):null,a=l?t("postType","docs",{status:"publish",parent_in:l.map((e=>e.id)),per_page:-1}):null;return{pages:o,sections:l,articles:a}}),[w,C]),q=(e=>{if("all"===_)return e;const t=parseInt(_),o=(n-1)*t,l=o+t;return e.slice(o,l)})((()=>{if(!G||!Y||!Z)return[];let e=[...G];return v&&v.length>0&&(e=e.filter((e=>!v.includes(e.id.toString())))),e=e.map((e=>{let t=Y.filter((t=>t.parent===e.id));"all"!==f&&(t=t.slice(0,parseInt(f))),t=t.map((e=>{let t=Z.filter((t=>t.parent===e.id));return"all"!==E&&(t=t.slice(0,parseInt(E))),{...e,articles:t}}));const o=t.reduce(((e,t)=>e+t.articles.length),0);return{...e,sections:t,articleCount:o}})),e})()),J=G?G.reduce(((e,t)=>(e[t.id]=t.title.rendered,e)),{}):{},K=(G&&G.map((e=>({value:e.id.toString(),label:e.title.rendered}))),e=>o=>{t({[e]:o})}),Q=v?v.map((e=>J[e]||e)):[];return(0,l.createElement)(c.Fragment,null,(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(p.PanelBody,{title:(0,r.__)("Doc Grid Settings","wedocs"),icon:s,initialOpen:!1},(0,l.createElement)(p.SelectControl,{value:b,options:[{label:"1x1",value:"1x1"},{label:"1x2",value:"1x2"}],label:(0,r.__)("DOCS GRID COLUMN STYLE","wedocs"),onChange:K("docStyle")}),(0,l.createElement)(p.SelectControl,{value:_,options:V,label:(0,r.__)("Docs per page","wedocs"),onChange:K("docsPerPage")}),(0,l.createElement)(p.FormTokenField,{value:Q,suggestions:Object.values(J),label:(0,r.__)("Exclude Docs","wedocs"),onChange:e=>{const o=e.map((e=>{const t=Object.entries(J).find((([t,o])=>o===e));return t?t[0]:e}));t({excludeDocs:o})}}),(0,l.createElement)(p.SelectControl,{value:C,options:z,label:(0,r.__)("Order","wedocs"),onChange:K("order")}),(0,l.createElement)(p.SelectControl,{value:w,options:W,label:(0,r.__)("Order by","wedocs"),onChange:K("orderBy")}),(0,l.createElement)(p.SelectControl,{value:f,options:U,label:(0,r.__)("Sections per doc","wedocs"),onChange:K("sectionsPerDoc")}),(0,l.createElement)(p.SelectControl,{value:E,options:U,label:(0,r.__)("Articles per section","wedocs"),onChange:K("articlesPerSection")}),(0,l.createElement)(p.PanelRow,null,(0,l.createElement)(p.ToggleControl,{checked:x,label:(0,r.__)("Show Doc Article","wedocs"),onChange:K("showDocArticle")})),(0,l.createElement)(p.PanelRow,null,(0,l.createElement)(p.ToggleControl,{checked:y,label:(0,r.__)("Keep Article Collapsed","wedocs"),onChange:K("keepArticlesCollapsed")})),(0,l.createElement)(p.PanelRow,null,(0,l.createElement)(p.ToggleControl,{checked:B,label:(0,r.__)("Show View Details Button","wedocs"),onChange:K("showViewDetails")})))),(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(h,{attributes:e,setAttributes:t})),(0,l.createElement)("div",{...o},m?(0,l.createElement)("div",{className:"backdrop"}):(0,l.createElement)("div",{className:"wedocs-block-wrapper"},(0,l.createElement)("div",{className:`wedocs-docs-grid wedocs-docs-grid--${b}`},d?(0,l.createElement)(Spinner,null):q.map((e=>((e,t)=>(0,l.createElement)("div",{key:e.id,className:"wedocs-docs-grid__item",style:t.item},(0,l.createElement)("h3",{className:"wedocs-docs-grid__title",style:t.title},e.title.rendered),((e,t)=>e.sections?(0,l.createElement)("div",{className:"wedocs-docs-grid__sections "+(y?"is-collapsed":"")},e.sections.map((e=>(0,l.createElement)("div",{key:e.id,className:"wedocs-docs-grid__section"},(0,l.createElement)("h4",{className:"wedocs-docs-grid__section-title",style:{...t.title,display:"flex",justifyContent:"space-between",alignItems:"center"}},(0,l.createElement)("span",null,e.title.rendered),x&&e.articles&&e.articles.length>0&&(0,l.createElement)("svg",{fill:"none",viewBox:"0 0 24 24",width:"16",strokeWidth:"2",stroke:"#acb8c4",className:y?"":"active"},(0,l.createElement)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"}))),x&&!y&&e.articles&&(0,l.createElement)("ul",{className:"wedocs-docs-grid__articles"},e.articles.map((e=>(0,l.createElement)("li",{key:e.id,className:"wedocs-docs-grid__article",style:t.children},e.title.rendered))))))),0===e.sections.length&&(0,l.createElement)("span",{className:"inside"},(0,l.createElement)("svg",{fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},(0,l.createElement)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})),(0,r.__)("This document has no sections yet. Check back later or wait for the author to add content.","wedocs"))):null)(e,t),B&&(0,l.createElement)("div",{className:"wedocs-docs-grid__details"},(0,l.createElement)("span",{className:"wedocs-docs-grid__details-link",style:t.button},t.button.text))))(e,(()=>{const e=S?`${S.top} ${S.right} ${S.bottom} ${S.left}`:"",t=k?`${k.top} ${k.right} ${k.bottom} ${k.left}`:"",o=O?`${O.top} ${O.right} ${O.bottom} ${O.left}`:"",l=D||"8px",a=$?`${$.top} ${$.right} ${$.bottom} ${$.left}`:"";return{item:{padding:e,margin:t,borderStyle:R||"solid",borderWidth:M||"1px",borderColor:N||"rgba(0, 0, 0, 0.1)",borderRadius:T||"8px",backgroundColor:"#fff"},title:{color:F||"#1e1e1e"},children:{color:P||"#0073aa"},button:{padding:o,margin:a,backgroundColor:L||"#0073aa",color:H||"#ffffff",text:j||(0,r.__)("View Details","wedocs"),borderRadius:l||"8px","--hover-bg":A||"#005177","--hover-color":I||"#ffffff"}}})())))))))},save:()=>null})},609:e=>{e.exports=window.React}},o={};function l(e){var a=o[e];if(void 0!==a)return a.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,l),r.exports}l.m=t,e=[],l.O=(t,o,a,r)=>{if(!o){var n=1/0;for(c=0;c=r)&&Object.keys(l.O).every((e=>l.O[e](o[d])))?o.splice(d--,1):(i=!1,r0&&e[c-1][2]>r;c--)e[c]=e[c-1];e[c]=[o,a,r]},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={366:0,337:0};l.O.j=t=>0===e[t];var t=(t,o)=>{var a,r,n=o[0],i=o[1],d=o[2],s=0;if(n.some((t=>0!==e[t]))){for(a in i)l.o(i,a)&&(l.m[a]=i[a]);if(d)var c=d(l)}for(t&&t(o);sl(445)));a=l.O(a)})(); \ No newline at end of file +(()=>{"use strict";var e,t={418:(e,t,l)=>{var o=l(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),r=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,l){var o,d={},c=null,s=null;for(o in void 0!==l&&(c=""+l),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(s=t.ref),t)n.call(t,o)&&!i.hasOwnProperty(o)&&(d[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===d[o]&&(d[o]=t[o]);return{$$typeof:a,type:e,key:c,ref:s,props:d,_owner:r.current}}},706:(e,t,l)=>{e.exports=l(418)},870:(e,t,l)=>{var o=l(609);const a=window.wp.blocks,n=window.wp.i18n,r=window.wp.primitives;var i=l(706);const d=(0,i.jsx)(r.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(r.Path,{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z"})}),c=(0,i.jsx)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(r.Path,{fillRule:"evenodd",d:"M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",clipRule:"evenodd"})}),s=window.wp.element,u=window.wp.blockEditor,m=window.wp.components,p=({label:e,value:t,unit:l,onValueChange:a,onUnitChange:r})=>(0,o.createElement)(m.Flex,null,(0,o.createElement)(m.FlexBlock,null,(0,o.createElement)(m.TextControl,{label:e,value:parseInt(t),onChange:e=>a(e)})),(0,o.createElement)(m.FlexItem,null,(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Unit","wedocs"),value:l,options:[{label:"px",value:"px"},{label:"%",value:"%"}],onChange:e=>r(e)}))),g=({selected:e,options:t,onChange:l})=>(0,o.createElement)(m.BaseControl,null,(0,o.createElement)("div",{className:"radio-image-control-options"},t.map((t=>(0,o.createElement)("div",{key:t.value,className:"radio-image-option"},(0,o.createElement)("input",{type:"radio",id:`radio-image-${t.value}`,value:t.value,checked:e===t.value,onChange:e=>l(e.target.value)}),(0,o.createElement)("label",{htmlFor:`radio-image-${t.value}`},t.icon&&(0,o.createElement)("i",{className:`dashicons ${t.icon}`}),t.img&&(0,o.createElement)("img",{src:t.img,alt:t.label}),t?.svg)))))),b={hideSearch:{type:"boolean",default:!1},searchWidth:{type:"number",default:50},widthUnit:{type:"string",default:"%"},placeholder:{type:"string",default:(0,n.__)("Search for a top or question","wedocs")},alignment:{type:"string",default:"right"},bgColor:{type:"string",default:"#FFFFFF"},hoverColor:{type:"string",default:"#FFFFFF"},padding:{type:"object",default:{top:14,left:22,right:22,bottom:14}},margin:{type:"object",default:{top:0,left:0,right:0,bottom:0}},borderColor:{type:"string",default:"#cccccc"},borderType:{type:"string",default:"solid"},borderWidth:{type:"number",default:1},borderRadius:{type:"number",default:30},iconColor:{type:"string",default:"#FFFFFF"},iconBgColor:{type:"string",default:"#3b82f6"},iconHoverColor:{type:"string",default:"#2563eb"},svgHoverColor:{type:"string",default:"#FFFFFF"},btnPadding:{type:"object",default:{top:24,left:26,right:26,bottom:24}},btnPosition:{type:"object",default:{top:0,right:0,bottom:10}},btnRadius:{type:"number",default:30}};(0,a.registerBlockType)("wedocs/wedocs-search",{attributes:b,save:({attributes:e})=>{const{margin:t,bgColor:l,padding:a,btnRadius:n,alignment:r,iconColor:i,widthUnit:d,hoverColor:c,borderType:m,hideSearch:p,btnPadding:g,searchWidth:b,btnPosition:h,placeholder:_,borderColor:v,borderWidth:C,iconBgColor:w,borderRadius:E,svgHoverColor:x,iconHoverColor:f}=e;if(p)return;const y={display:"flex",justifyContent:r},B={border:`${C}px ${m} ${v}`,paddingTop:a?.top,paddingLeft:a?.left,paddingRight:a?.right,borderRadius:`${E}px`,paddingBottom:a?.bottom,"--field-color":l,"--field-bg-color":c},S={top:h?.top,left:h?.left,right:h?.right,bottom:h?.bottom,height:"auto",paddingTop:g?.top,paddingLeft:g?.left,borderRadius:n,paddingRight:g?.right,paddingBottom:g?.bottom,"--field-icon-color":i,"--field-btn-bg-color":w,"--field-icon-hover-color":x,"--field-btn-bg-hover-color":f};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)("form",{method:"get",role:"search",action:weDocsBlockVars?.siteUrl,...u.useBlockProps.save({className:"search-form wedocs-search-form"})},(0,o.createElement)("div",{style:y},(0,o.createElement)("div",{className:"wedocs-search-input",style:{width:b+d,marginTop:t?.top,marginLeft:t?.left,marginRight:t?.right,marginBottom:t?.bottom}},(0,o.createElement)("input",{name:"s",type:"search",style:B,className:"search-field",placeholder:_}),(0,o.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,o.createElement)("button",{type:"submit",style:S,className:"search-submit"},(0,o.createElement)("svg",{width:"15",height:"16",fill:"none"},(0,o.createElement)("path",{fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))))))},edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{margin:a,bgColor:r,padding:i,btnRadius:b,alignment:h,iconColor:_,widthUnit:v,hoverColor:C,borderType:w,hideSearch:E,btnPadding:x,searchWidth:f,btnPosition:y,placeholder:B,borderColor:S,borderWidth:k,iconBgColor:P,borderRadius:T,svgHoverColor:F,iconHoverColor:R}=e;console.log("editor panel:",r);const $=[{value:"left",label:(0,n.__)("Align left","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"left"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M8 9.462h12m-12 6h6m-10-9v12"}))},{value:"center",label:(0,n.__)("Align center","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"center"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M18 9.462H6m8.99 6h-6"}),(0,o.createElement)("path",{d:"M12 6.462v12"}))},{value:"right",label:(0,n.__)("Align right","wedocs"),svg:(0,o.createElement)("svg",{width:"24",height:"25",fill:"none",strokeWidth:"2",strokeLinecap:"round",stroke:"right"===h?"#007cba":"#939494",strokeLinejoin:"round"},(0,o.createElement)("path",{d:"M16 9.462H4m12 6h-6m10-9v12"}))}],[M,N]=(0,s.useState)(!1),[O,D]=(0,s.useState)(!1),[z,H]=(0,s.useState)(!1),A={display:"flex",justifyContent:h},L={border:`${k}px ${w} ${S}`,paddingTop:i?.top,background:M?C:r,paddingLeft:i?.left,paddingRight:i?.right,borderRadius:`${T}px`,paddingBottom:i?.bottom},W={top:y?.top,left:y?.left,right:y?.right,bottom:y?.bottom,height:"auto",background:z?R:P,paddingTop:x?.top,paddingLeft:x?.left,borderRadius:b,paddingRight:x?.right,paddingBottom:x?.bottom},I=[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Double","wedocs"),value:"double"},{label:(0,n.__)("Groove","wedocs"),value:"groove"},{label:(0,n.__)("Ridge","wedocs"),value:"ridge"},{label:(0,n.__)("Inset","wedocs"),value:"inset"},{label:(0,n.__)("Outset","wedocs"),value:"outset"},{label:(0,n.__)("None","wedocs"),value:"none"},{label:(0,n.__)("Hidden","wedocs"),value:"hidden"}];return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,null,(0,o.createElement)(m.ToggleControl,{checked:E,className:"wedocs-search-toggle",label:(0,n.__)("Disable Block","wedocs"),onChange:e=>t({hideSearch:e})})),!E&&(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Color Settings","wedocs"),icon:d,initialOpen:!1,className:"wedocs-search-color-settings"},(0,o.createElement)(u.PanelColorSettings,{colors:[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}],colorSettings:[{value:r,label:(0,n.__)("Field Background Color","wedocs"),onChange:e=>t({bgColor:e})},{value:C,label:(0,n.__)("Field Hover Color","wedocs"),onChange:e=>t({hoverColor:e})},{value:S,label:(0,n.__)("Border Color","wedocs"),onChange:e=>t({borderColor:e})},{value:_,label:(0,n.__)("Icon Color","wedocs"),onChange:e=>t({iconColor:e})},{value:P,label:(0,n.__)("Button Color","wedocs"),onChange:e=>t({iconBgColor:e})},{value:R,label:(0,n.__)("Button Hover Color","wedocs"),onChange:e=>t({iconHoverColor:e})},{value:F,label:(0,n.__)("Icon Hover Color","wedocs"),onChange:e=>t({svgHoverColor:e})}]})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Search Bar Settings","wedocs"),icon:c},(0,o.createElement)(p,{unit:v,value:f,label:(0,n.__)("Field Width","wedocs"),onUnitChange:e=>t({widthUnit:e}),onValueChange:e=>t({searchWidth:e?parseInt(e):0})}),(0,o.createElement)(m.TextControl,{value:B,label:(0,n.__)("Placeholder","wedocs"),placeholder:(0,n.__)("Search bar placeholder","wedocs"),onChange:e=>t({placeholder:e})}),(0,o.createElement)("p",{style:{fontSize:11}},(0,n.__)("POSITION","wedocs")),(0,o.createElement)(g,{selected:h,options:$,onChange:e=>t({alignment:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"14px",left:"22px",right:"22px",bottom:"14px"},values:i,label:(0,n.__)("Field Padding","wedocs"),onChange:e=>t({padding:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"0px",left:"0px",right:"0px",bottom:"0px"},values:a,label:(0,n.__)("Field Margin","wedocs"),onChange:e=>t({margin:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:10,value:k,label:(0,n.__)("Border Width","wedocs"),onChange:e=>t({borderWidth:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:100,value:T,label:(0,n.__)("Border Radius","wedocs"),onChange:e=>t({borderRadius:e})}),(0,o.createElement)(m.SelectControl,{value:w,options:I,label:(0,n.__)("Border Type","wedocs"),onChange:e=>t({borderType:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"24px",left:"26px",right:"26px",bottom:"24px"},values:x,label:(0,n.__)("Button Padding","wedocs"),onChange:e=>t({btnPadding:e})}),(0,o.createElement)(m.__experimentalBoxControl,{resetValues:{top:"0px",right:"0px",bottom:"10px"},values:y,label:(0,n.__)("Button Margin","wedocs"),onChange:e=>t({btnPosition:e})}),(0,o.createElement)(m.RangeControl,{min:0,max:100,value:b,label:(0,n.__)("Button Radius","wedocs"),onChange:e=>t({btnRadius:e})})))),(0,o.createElement)("div",{...l,style:A},(0,o.createElement)("div",{className:"wedocs-editor-search-input",style:{width:f+v,marginTop:a?.top,marginLeft:a?.left,marginRight:a?.right,marginBottom:a?.bottom}},(0,o.createElement)("input",{readOnly:!0,style:L,className:"search-field",placeholder:B,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1)}),(0,o.createElement)("input",{type:"hidden",name:"post_type",value:"docs"}),(0,o.createElement)("button",{type:"submit",style:W,className:"search-submit",onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},(0,o.createElement)("svg",{width:"15",height:"16",fill:"none",onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1)},(0,o.createElement)("path",{fill:O?F:_,fillRule:"evenodd",d:"M11.856 10.847l2.883 2.883a.89.89 0 0 1 0 1.257c-.173.174-.401.261-.629.261s-.455-.087-.629-.261l-2.883-2.883c-1.144.874-2.532 1.353-3.996 1.353a6.56 6.56 0 0 1-4.671-1.935c-2.576-2.575-2.576-6.765 0-9.341C3.179.934 4.839.247 6.603.247s3.424.687 4.671 1.935a6.56 6.56 0 0 1 1.935 4.67 6.55 6.55 0 0 1-1.353 3.995zM3.189 3.439c-1.882 1.882-1.882 4.945 0 6.827.912.912 2.124 1.414 3.414 1.414s2.502-.502 3.414-1.414 1.414-2.124 1.414-3.413-.502-2.502-1.414-3.413-2.124-1.414-3.414-1.414-2.502.502-3.414 1.414z"})))),E&&(0,o.createElement)("div",{className:"backdrop"})))},icon:(0,o.createElement)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},(0,o.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.91421 1.5H5.5C4.39543 1.5 3.5 2.39543 3.5 3.5V6.91421V9.02779V15.5C3.5 16.6046 4.39543 17.5 5.5 17.5H7.02779C6.07771 16.4385 5.5 15.0367 5.5 13.5C5.5 10.1863 8.18629 7.5 11.5 7.5C13.0367 7.5 14.4385 8.07771 15.5 9.02779V8.5V6.91421C15.5 6.38378 15.2893 5.87507 14.9142 5.5L11.5 2.08579C11.1249 1.71071 10.6162 1.5 10.0858 1.5H8.91421ZM15.5 13.5C15.5 11.2909 13.7091 9.5 11.5 9.5C9.29086 9.5 7.5 11.2909 7.5 13.5C7.5 15.7091 9.29086 17.5 11.5 17.5C12.2414 17.5 12.9364 17.2977 13.5318 16.946L14.7929 18.2071C15.1834 18.5976 15.8166 18.5976 16.2071 18.2071C16.5976 17.8166 16.5976 17.1834 16.2071 16.7929L14.946 15.5318C15.2977 14.9364 15.5 14.2414 15.5 13.5ZM11.5 11.5C12.6046 11.5 13.5 12.3954 13.5 13.5C13.5 14.0526 13.2772 14.5512 12.9142 14.9142C12.5512 15.2772 12.0526 15.5 11.5 15.5C10.3954 15.5 9.5 14.6046 9.5 13.5C9.5 12.3954 10.3954 11.5 11.5 11.5Z",fill:"#111827"})),title:(0,n.__)("weDocs - Searchbar","wedocs"),keywords:["Search","weDocs search bar","Bar"],category:"widgets",description:(0,n.__)("Simple search forms for easy user guidance for your documentation","wedocs")});const h=({attributes:e,setAttributes:t})=>{const l=e=>l=>{t({[e]:l})},a=((0,n.__)("Solid","wedocs"),(0,n.__)("Dashed","wedocs"),(0,n.__)("Dotted","wedocs"),(0,n.__)("None","wedocs"),[{name:"Sweet",color:"#F43F5E"},{name:"Orange",color:"#F97316"},{name:"Yellow",color:"#FACC15"},{name:"Purple",color:"#8B5CF6"},{name:"Light Blue",color:"#3B82F6"},{name:"Light Green",color:"#10B981"}]);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Grid Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,o.createElement)("label",null,(0,n.__)("Colors","wedocs")),(0,o.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.docTitleColor,label:(0,n.__)("Doc Title Color","wedocs"),onChange:e=>l("docTitleColor")(e)},{value:e.docChildrenActiveColor,label:(0,n.__)("Doc Children Active Color","wedocs"),onChange:e=>l("docChildrenActiveColor")(e)},{value:e.borderColor,label:(0,n.__)("Border Color","wedocs"),onChange:e=>l("borderColor")(e)}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Grid Padding","wedocs"),values:e.gridPadding,onChange:l("gridPadding")}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Grid Margin","wedocs"),values:e.gridMargin,onChange:l("gridMargin")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Type","wedocs"),value:e.borderType,options:[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("None","wedocs"),value:"none"}],onChange:e=>t({borderType:e})}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Width","wedocs"),value:e.borderWidth,options:[{label:"0px",value:"0px"},{label:"1px",value:"1px"},{label:"2px",value:"2px"},{label:"3px",value:"3px"},{label:"4px",value:"4px"},{label:"5px",value:"5px"}],onChange:e=>t({borderWidth:e})}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Radius","wedocs"),value:e.borderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({borderRadius:e})})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Button Styles","wedocs"),icon:"admin-appearance",initialOpen:!1},(0,o.createElement)("label",null,(0,n.__)("Button Colors","wedocs")),(0,o.createElement)(u.PanelColorSettings,{colors:a,colorSettings:[{value:e.buttonColor,label:(0,n.__)("Button Color","wedocs"),onChange:e=>l("buttonColor")(e)},{value:e.buttonHoverColor,label:(0,n.__)("Button Hover Color","wedocs"),onChange:e=>l("buttonHoverColor")(e)},{value:e.buttonTextColor,label:(0,n.__)("Button Text Color","wedocs"),onChange:e=>l("buttonTextColor")(e)},{value:e.buttonHoverTextColor,label:(0,n.__)("Button Hover Text Color","wedocs"),onChange:e=>l("buttonHoverTextColor")(e)}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Button Padding","wedocs"),values:e.buttonPadding,onChange:l("buttonPadding")}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Button Margin","wedocs"),values:e.buttonMargin,onChange:l("buttonMargin")}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Button Border Radius","wedocs"),value:e.buttonBorderRadius,options:[{label:"0px",value:"0px"},{label:"4px",value:"4px"},{label:"8px",value:"8px"},{label:"12px",value:"12px"},{label:"16px",value:"16px"},{label:"20px",value:"20px"}],onChange:e=>t({buttonBorderRadius:e})}),(0,o.createElement)("div",{className:"wedocs-color-control"},(0,o.createElement)("label",null,(0,n.__)("Button Text","wedocs")),(0,o.createElement)(m.TextControl,{value:e.buttonText,onChange:l("buttonText")}))))},_=JSON.parse('{"UU":"wedocs/wedocs-docs-grid"}');(0,a.registerBlockType)(_.UU,{edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{useSelect:a}=wp.data,[r,i]=(0,s.useState)(1),[d,p]=(0,s.useState)(!1),{hideDocGrid:g,docStyle:b,docsPerPage:_,excludeDocs:v,order:C,orderBy:w,sectionsPerDoc:E,articlesPerSection:x,showDocArticle:f,keepArticlesCollapsed:y,showViewDetails:B,gridPadding:S,gridMargin:k,docTitleColor:P,docChildrenActiveColor:T,borderType:F,borderRadius:R,borderWidth:$,borderColor:M,buttonBorderRadius:N,buttonPadding:O,buttonMargin:D,buttonColor:z,buttonHoverColor:H,buttonTextColor:A,buttonText:L,buttonHoverTextColor:W}=e,I=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],j=[{label:(0,n.__)("weDocs Order","wedocs"),value:"menu_order"},{label:(0,n.__)("ID","wedocs"),value:"id"},{label:(0,n.__)("Name","wedocs"),value:"title"}],V=[{label:(0,n.__)("Ascending","wedocs"),value:"asc"},{label:(0,n.__)("Descending","wedocs"),value:"desc"}],U=[{label:"All",value:"all"},...Array.from({length:10},((e,t)=>({label:String(t+1),value:String(t+1)})))],{pages:G,sections:Y,articles:Z}=a((e=>{const{getEntityRecords:t}=e("core"),l=t("postType","docs",{status:"publish",per_page:-1,parent:0,orderby:w,order:C}),o=l?t("postType","docs",{status:"publish",parent_in:l.map((e=>e.id)),per_page:-1}):null,a=o?t("postType","docs",{status:"publish",parent_in:o.map((e=>e.id)),per_page:-1}):null;return{pages:l,sections:o,articles:a}}),[w,C]),J=(e=>{if("all"===_)return e;const t=parseInt(_),l=(r-1)*t,o=l+t;return e.slice(l,o)})((()=>{if(!G||!Y||!Z)return[];let e=[...G];return v&&v.length>0&&(e=e.filter((e=>!v.includes(e.id.toString())))),e=e.map((e=>{let t=Y.filter((t=>t.parent===e.id));"all"!==E&&(t=t.slice(0,parseInt(E))),t=t.map((e=>{let t=Z.filter((t=>t.parent===e.id));return"all"!==x&&(t=t.slice(0,parseInt(x))),{...e,articles:t}}));const l=t.reduce(((e,t)=>e+t.articles.length),0);return{...e,sections:t,articleCount:l}})),e})()),q=G?G.reduce(((e,t)=>(e[t.id]=t.title.rendered,e)),{}):{},K=(G&&G.map((e=>({value:e.id.toString(),label:e.title.rendered}))),e=>l=>{t({[e]:l})}),Q=v?v.map((e=>q[e]||e)):[];return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Doc Grid Settings","wedocs"),icon:c,initialOpen:!1},(0,o.createElement)(m.SelectControl,{value:b,options:[{label:"1x1",value:"1x1"},{label:"1x2",value:"1x2"}],label:(0,n.__)("DOCS GRID COLUMN STYLE","wedocs"),onChange:K("docStyle")}),(0,o.createElement)(m.SelectControl,{value:_,options:I,label:(0,n.__)("Docs per page","wedocs"),onChange:K("docsPerPage")}),(0,o.createElement)(m.FormTokenField,{value:Q,suggestions:Object.values(q),label:(0,n.__)("Exclude Docs","wedocs"),onChange:e=>{const l=e.map((e=>{const t=Object.entries(q).find((([t,l])=>l===e));return t?t[0]:e}));t({excludeDocs:l})}}),(0,o.createElement)(m.SelectControl,{value:C,options:V,label:(0,n.__)("Order","wedocs"),onChange:K("order")}),(0,o.createElement)(m.SelectControl,{value:w,options:j,label:(0,n.__)("Order by","wedocs"),onChange:K("orderBy")}),(0,o.createElement)(m.SelectControl,{value:E,options:U,label:(0,n.__)("Sections per doc","wedocs"),onChange:K("sectionsPerDoc")}),(0,o.createElement)(m.SelectControl,{value:x,options:U,label:(0,n.__)("Articles per section","wedocs"),onChange:K("articlesPerSection")}),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:f,label:(0,n.__)("Show Doc Article","wedocs"),onChange:K("showDocArticle")})),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:y,label:(0,n.__)("Keep Article Collapsed","wedocs"),onChange:K("keepArticlesCollapsed")})),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{checked:B,label:(0,n.__)("Show View Details Button","wedocs"),onChange:K("showViewDetails")})))),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(h,{attributes:e,setAttributes:t})),(0,o.createElement)("div",{...l},g?(0,o.createElement)("div",{className:"backdrop"}):(0,o.createElement)("div",{className:"wedocs-block-wrapper"},(0,o.createElement)("div",{className:`wedocs-docs-grid wedocs-docs-grid--${b}`},d?(0,o.createElement)(Spinner,null):J.map((e=>((e,t)=>(0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__item",style:t.item},(0,o.createElement)("h3",{className:"wedocs-docs-grid__title",style:t.title},e.title.rendered),((e,t)=>e.sections?(0,o.createElement)("div",{className:"wedocs-docs-grid__sections "+(y?"is-collapsed":"")},e.sections.map((e=>(0,o.createElement)("div",{key:e.id,className:"wedocs-docs-grid__section"},(0,o.createElement)("h4",{className:"wedocs-docs-grid__section-title",style:{...t.title,display:"flex",justifyContent:"space-between",alignItems:"center"}},(0,o.createElement)("span",null,e.title.rendered),f&&e.articles&&e.articles.length>0&&(0,o.createElement)("svg",{fill:"none",viewBox:"0 0 24 24",width:"16",strokeWidth:"2",stroke:"#acb8c4",className:y?"":"active"},(0,o.createElement)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"}))),f&&!y&&e.articles&&(0,o.createElement)("ul",{className:"wedocs-docs-grid__articles"},e.articles.map((e=>(0,o.createElement)("li",{key:e.id,className:"wedocs-docs-grid__article",style:t.children},e.title.rendered))))))),0===e.sections.length&&(0,o.createElement)("span",{className:"inside"},(0,o.createElement)("svg",{fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor"},(0,o.createElement)("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"})),(0,n.__)("This document has no sections yet. Check back later or wait for the author to add content.","wedocs"))):null)(e,t),B&&(0,o.createElement)("div",{className:"wedocs-docs-grid__details"},(0,o.createElement)("span",{className:"wedocs-docs-grid__details-link",style:t.button},t.button.text))))(e,(()=>{const e=S?`${S.top} ${S.right} ${S.bottom} ${S.left}`:"",t=k?`${k.top} ${k.right} ${k.bottom} ${k.left}`:"",l=O?`${O.top} ${O.right} ${O.bottom} ${O.left}`:"",o=N||"8px",a=D?`${D.top} ${D.right} ${D.bottom} ${D.left}`:"";return{item:{padding:e,margin:t,borderStyle:F||"solid",borderWidth:$||"1px",borderColor:M||"rgba(0, 0, 0, 0.1)",borderRadius:R||"8px",backgroundColor:"#fff"},title:{color:P||"#1e1e1e"},children:{color:T||"#0073aa"},button:{padding:l,margin:a,backgroundColor:z||"#0073aa",color:A||"#ffffff",text:L||(0,n.__)("View Details","wedocs"),borderRadius:o||"8px","--hover-bg":H||"#005177","--hover-color":W||"#ffffff"}}})())))))))},save:()=>null});const v=({attributes:e,setAttributes:t})=>{const{padding:l,margin:a,backgroundColor:r,textColor:i,hoverBackgroundColor:d,hoverTextColor:c,borderRadius:p,borderWidth:g,borderColor:b,borderStyle:h,fontSize:_,fontWeight:v}=e,C=(l,o=null)=>a=>{t(o?{[l]:{...e[l],[o]:a}}:{[l]:a})};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Style Settings","wedocs"),initialOpen:!1},(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Color Settings","wedocs"),initialOpen:!1,colorSettings:[{value:i,onChange:C("textColor"),label:(0,n.__)("Text Color","wedocs")},{value:r,onChange:C("backgroundColor"),label:(0,n.__)("Background Color","wedocs")}]}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Hover Color Settings","wedocs"),initialOpen:!1,colorSettings:[{value:c,onChange:C("hoverTextColor"),label:(0,n.__)("Hover Text Color","wedocs")},{value:d,onChange:C("hoverBackgroundColor"),label:(0,n.__)("Hover Background Color","wedocs")}]})),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Spacing","wedocs"),initialOpen:!1},m.__experimentalBoxControl?(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Padding","wedocs"),values:l,onChange:C("padding"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]}),(0,o.createElement)(m.__experimentalBoxControl,{label:(0,n.__)("Margin","wedocs"),values:a,onChange:C("margin"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]})):(0,o.createElement)(s.Fragment,null,(0,o.createElement)("p",{style:{marginBottom:"16px",color:"#666"}},(0,n.__)("Individual spacing controls (Padding & Margin)","wedocs")),(0,o.createElement)("div",{style:{marginBottom:"16px"}},(0,o.createElement)("strong",null,(0,n.__)("Padding","wedocs"))),(0,o.createElement)("div",{style:{marginBottom:"16px"}},(0,o.createElement)("strong",null,(0,n.__)("Margin","wedocs"))))),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Border & Typography","wedocs"),initialOpen:!1},m.__experimentalUnitControl?(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Border Radius","wedocs"),value:p,onChange:C("borderRadius"),units:[{value:"px",label:"px",default:0},{value:"em",label:"em",default:0},{value:"%",label:"%",default:0}]}),(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Border Width","wedocs"),value:g,onChange:C("borderWidth"),units:[{value:"px",label:"px",default:0}]}),(0,o.createElement)(m.__experimentalUnitControl,{label:(0,n.__)("Font Size","wedocs"),value:_,onChange:C("fontSize"),units:[{value:"px",label:"px",default:16},{value:"em",label:"em",default:1},{value:"rem",label:"rem",default:1}]})):(0,o.createElement)(s.Fragment,null,(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Border Radius (px)","wedocs"),value:parseInt(p),onChange:e=>C("borderRadius")(`${e}px`),min:0,max:50}),(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Border Width (px)","wedocs"),value:parseInt(g),onChange:e=>C("borderWidth")(`${e}px`),min:0,max:10}),(0,o.createElement)(m.RangeControl,{label:(0,n.__)("Font Size (px)","wedocs"),value:parseInt(_),onChange:e=>C("fontSize")(`${e}px`),min:10,max:32})),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Border Style","wedocs"),value:h,options:[{label:(0,n.__)("Solid","wedocs"),value:"solid"},{label:(0,n.__)("Dashed","wedocs"),value:"dashed"},{label:(0,n.__)("Dotted","wedocs"),value:"dotted"},{label:(0,n.__)("None","wedocs"),value:"none"}],onChange:C("borderStyle")}),(0,o.createElement)(u.PanelColorSettings,{title:(0,n.__)("Border Color","wedocs"),initialOpen:!1,colorSettings:[{value:b,onChange:C("borderColor"),label:(0,n.__)("Border Color","wedocs")}]}),(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Font Weight","wedocs"),value:v,options:[{label:(0,n.__)("Normal","wedocs"),value:"normal"},{label:(0,n.__)("Bold","wedocs"),value:"bold"},{label:(0,n.__)("Light","wedocs"),value:"300"},{label:(0,n.__)("Medium","wedocs"),value:"500"},{label:(0,n.__)("Semi Bold","wedocs"),value:"600"},{label:(0,n.__)("Extra Bold","wedocs"),value:"800"}],onChange:C("fontWeight")}))))},C=JSON.parse('{"UU":"wedocs/print-button"}');(0,a.registerBlockType)(C.UU,{edit:({attributes:e,setAttributes:t})=>{const l=(0,u.useBlockProps)(),{layout:a,alignment:r,buttonText:i,showIcon:d,padding:c,margin:p,backgroundColor:g,textColor:b,hoverBackgroundColor:h,hoverTextColor:_,borderRadius:C,borderWidth:w,borderColor:E,borderStyle:x,fontSize:f,fontWeight:y,additionalClasses:B}=e,S={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:d?"8px":"0",padding:`${c.top} ${c.right} ${c.bottom} ${c.left}`,margin:`${p.top} ${p.right} ${p.bottom} ${p.left}`,backgroundColor:g,color:b,border:`${w} ${x} ${E}`,borderRadius:C,fontSize:f,fontWeight:y,textDecoration:"none",cursor:"pointer",transition:"all 0.2s ease-in-out","--hover-bg-color":h,"--hover-text-color":_},k={textAlign:r,width:"100%"};return(0,o.createElement)(s.Fragment,null,(0,o.createElement)(u.BlockControls,null,(0,o.createElement)(u.AlignmentToolbar,{value:r,onChange:e=>t({alignment:e||"left"})})),(0,o.createElement)(u.InspectorControls,null,(0,o.createElement)(m.PanelBody,{title:(0,n.__)("General Settings","wedocs"),initialOpen:!0},(0,o.createElement)(m.SelectControl,{label:(0,n.__)("Layout","wedocs"),value:a,options:[{label:(0,n.__)("Layout 1 - Horizontal","wedocs"),value:"layout1"},{label:(0,n.__)("Layout 2 - Button Style","wedocs"),value:"layout2"},{label:(0,n.__)("Layout 3 - Vertical","wedocs"),value:"layout3"}],onChange:e=>t({layout:e})}),(0,o.createElement)(m.TextControl,{label:(0,n.__)("Button Text","wedocs"),value:i,onChange:e=>t({buttonText:e}),placeholder:(0,n.__)("Print","wedocs")}),(0,o.createElement)(m.PanelRow,null,(0,o.createElement)(m.ToggleControl,{label:(0,n.__)("Show Print Icon","wedocs"),checked:d,onChange:e=>t({showIcon:e})}))),(0,o.createElement)(v,{attributes:e,setAttributes:t}),(0,o.createElement)(m.PanelBody,{title:(0,n.__)("Advanced","wedocs"),initialOpen:!1},(0,o.createElement)(m.TextControl,{label:(0,n.__)("Additional CSS Classes","wedocs"),value:B,onChange:e=>t({additionalClasses:e}),help:(0,n.__)("Add custom CSS classes separated by spaces","wedocs")}))),(0,o.createElement)("div",{...l},(0,o.createElement)("div",{className:"wedocs-print-button-wrapper"},(()=>{switch(a){case"layout2":return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-2 ${B}`,style:S,onClick:e=>e.preventDefault()},d&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",null,i||(0,n.__)("Print","wedocs"))));case"layout3":return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-3 ${B}`,style:{...S,flexDirection:"column",gap:"4px"},onClick:e=>e.preventDefault()},d&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",{style:{fontSize:"12px"}},i||(0,n.__)("Print","wedocs"))));default:return(0,o.createElement)("div",{style:k},(0,o.createElement)("button",{className:`wedocs-print-button layout-1 ${B}`,style:S,onClick:e=>e.preventDefault()},d&&(0,o.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor"},(0,o.createElement)("path",{d:"M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"})),(0,o.createElement)("span",null,i||(0,n.__)("Print","wedocs"))))}})())))}})},609:e=>{e.exports=window.React}},l={};function o(e){var a=l[e];if(void 0!==a)return a.exports;var n=l[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.m=t,e=[],o.O=(t,l,a,n)=>{if(!l){var r=1/0;for(s=0;s=n)&&Object.keys(o.O).every((e=>o.O[e](l[d])))?l.splice(d--,1):(i=!1,n0&&e[s-1][2]>n;s--)e[s]=e[s-1];e[s]=[l,a,n]},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={366:0,337:0};o.O.j=t=>0===e[t];var t=(t,l)=>{var a,n,r=l[0],i=l[1],d=l[2],c=0;if(r.some((t=>0!==e[t]))){for(a in i)o.o(i,a)&&(o.m[a]=i[a]);if(d)var s=d(o)}for(t&&t(l);co(870)));a=o.O(a)})(); \ No newline at end of file diff --git a/assets/build/blocks/PrintButton/block.json b/assets/build/blocks/PrintButton/block.json new file mode 100644 index 00000000..ce5fd623 --- /dev/null +++ b/assets/build/blocks/PrintButton/block.json @@ -0,0 +1,108 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "wedocs/print-button", + "version": "1.0.0", + "title": "weDocs - Print Button", + "icon": "printer", + "category": "wedocs", + "description": "Add a print button to allow users to print the current page", + "keywords": [ + "print", + "button", + "wedocs", + "documentation" + ], + "supports": { + "html": false, + "align": [ + "left", + "center", + "right" + ] + }, + "editorScript": "file:./index.js", + "editorStyle": "file:./index.css", + "style": "file:./style-index.css", + "render": "file:./render.php", + "attributes": { + "layout": { + "type": "string", + "default": "layout1" + }, + "alignment": { + "type": "string", + "default": "left" + }, + "buttonText": { + "type": "string", + "default": "Print" + }, + "showIcon": { + "type": "boolean", + "default": true + }, + "padding": { + "type": "object", + "default": { + "top": "10px", + "right": "15px", + "bottom": "10px", + "left": "15px" + } + }, + "margin": { + "type": "object", + "default": { + "top": "0px", + "right": "0px", + "bottom": "10px", + "left": "0px" + } + }, + "backgroundColor": { + "type": "string", + "default": "#0073aa" + }, + "textColor": { + "type": "string", + "default": "#ffffff" + }, + "hoverBackgroundColor": { + "type": "string", + "default": "#005177" + }, + "hoverTextColor": { + "type": "string", + "default": "#ffffff" + }, + "borderRadius": { + "type": "string", + "default": "4px" + }, + "borderWidth": { + "type": "string", + "default": "1px" + }, + "borderColor": { + "type": "string", + "default": "#0073aa" + }, + "borderStyle": { + "type": "string", + "default": "solid" + }, + "fontSize": { + "type": "string", + "default": "16px" + }, + "fontWeight": { + "type": "string", + "default": "normal" + }, + "additionalClasses": { + "type": "string", + "default": "" + } + } +} \ No newline at end of file diff --git a/assets/build/blocks/PrintButton/render.php b/assets/build/blocks/PrintButton/render.php new file mode 100644 index 00000000..e76695bc --- /dev/null +++ b/assets/build/blocks/PrintButton/render.php @@ -0,0 +1,165 @@ +post_type !== 'docs') { + return ''; +} + +ob_start(); + +// Extract attributes with defaults +$layout = isset($attributes['layout']) ? $attributes['layout'] : 'layout1'; +$alignment = isset($attributes['alignment']) ? $attributes['alignment'] : 'left'; +$button_text = isset($attributes['buttonText']) ? $attributes['buttonText'] : __('Print', 'wedocs'); +$show_icon = isset($attributes['showIcon']) ? $attributes['showIcon'] : true; +$additional_classes = isset($attributes['additionalClasses']) ? $attributes['additionalClasses'] : ''; + +// Spacing attributes with proper defaults for empty values +$padding_defaults = [ + 'top' => '10px', + 'right' => '15px', + 'bottom' => '10px', + 'left' => '15px' +]; + +$margin_defaults = [ + 'top' => '0px', + 'right' => '0px', + 'bottom' => '10px', + 'left' => '0px' +]; + +// Merge with defaults to handle empty/undefined individual properties +$padding = array_merge($padding_defaults, isset($attributes['padding']) ? array_filter($attributes['padding'], function($value) { + return !($value === null || $value === ''); +}) : []); + +$margin = array_merge($margin_defaults, isset($attributes['margin']) ? array_filter($attributes['margin'], function($value) { + return !($value === null || $value === ''); +}) : []); + +// Color and style attributes +$background_color = isset($attributes['backgroundColor']) ? $attributes['backgroundColor'] : '#0073aa'; +$text_color = isset($attributes['textColor']) ? $attributes['textColor'] : '#ffffff'; +$hover_bg_color = isset($attributes['hoverBackgroundColor']) ? $attributes['hoverBackgroundColor'] : '#005177'; +$hover_text_color = isset($attributes['hoverTextColor']) ? $attributes['hoverTextColor'] : '#ffffff'; +$border_radius = isset($attributes['borderRadius']) ? $attributes['borderRadius'] : '4px'; +$border_width = isset($attributes['borderWidth']) ? $attributes['borderWidth'] : '1px'; +$border_color = isset($attributes['borderColor']) ? $attributes['borderColor'] : '#0073aa'; +$border_style = isset($attributes['borderStyle']) ? $attributes['borderStyle'] : 'solid'; +$font_size = isset($attributes['fontSize']) ? $attributes['fontSize'] : '16px'; +$font_weight = isset($attributes['fontWeight']) ? $attributes['fontWeight'] : 'normal'; + +// Generate unique ID for styles +$block_id = 'wedocs-print-btn-' . wp_generate_uuid4(); + +// Container styles based on alignment +$container_styles = sprintf('text-align: %s; width: 100%%;', esc_attr($alignment)); + +// Build CSS classes +$css_classes = sprintf('wedocs-print-article wedocs-print-button %s %s', + esc_attr($layout), + esc_attr($additional_classes) +); + +// Render layout variations +$button_content = ''; + +switch ($layout) { + case 'layout2': + $button_content = sprintf( + ' + %s + %s + ', + esc_attr($block_id), + esc_attr($css_classes), + esc_attr(__('Print this article', 'wedocs')), + $show_icon ? '' : '', + esc_html($button_text) + ); + break; + + case 'layout3': + $button_content = sprintf( + ' + %s + %s + ', + esc_attr($block_id), + esc_attr($css_classes), + esc_attr(__('Print this article', 'wedocs')), + $show_icon ? '' : '', + esc_html($button_text) + ); + break; + + default: // layout1 + $button_content = sprintf( + ' + %s + %s + ', + esc_attr($block_id), + esc_attr($css_classes), + esc_attr(__('Print this article', 'wedocs')), + $show_icon ? '' : '', + esc_html($button_text) + ); + break; +} + +// Output the complete block with custom styles +?> + +
+ +
+ diff --git a/assets/build/style-block.css b/assets/build/style-block.css index 55638f71..82bcf5fa 100644 --- a/assets/build/style-block.css +++ b/assets/build/style-block.css @@ -1,2 +1,3 @@ .wp-block-wedocs-wedocs-search{--field-color: #FFFFFF;--field-bg-color: #FFFFFF;--field-icon-color: #FFFFFF;--field-btn-bg-color: #3B82F6;--field-icon-hover-color: #FFFFFF;--field-btn-bg-hover-color: #2563EB}.wedocs-search-input,.wedocs-editor-search-input{width:50%;display:flex;overflow:hidden;position:relative}.wedocs-search-input .search-field,.wedocs-editor-search-input .search-field{margin:0;width:100%;height:48px;font-size:14px;background:#fff;padding:14px 22px;border-radius:100px;border:1px solid #dbdbdb}.wedocs-search-input .search-field::-moz-placeholder, .wedocs-editor-search-input .search-field::-moz-placeholder{color:#c5c5c5}.wedocs-search-input .search-field::placeholder,.wedocs-editor-search-input .search-field::placeholder{color:#c5c5c5}.wedocs-search-input .search-field:focus,.wedocs-editor-search-input .search-field:focus{outline:none;box-shadow:none;border:1px solid #dbdbdb}.wedocs-search-input .search-submit,.wedocs-editor-search-input .search-submit{top:0;right:0;border:0;margin:0;height:100%;display:flex;cursor:pointer;width:-moz-fit-content;width:fit-content;padding:14px 26px;position:absolute;align-items:center;border-radius:100px}.wedocs-search-input{margin-left:auto;margin-bottom:4%}.wedocs-search-toggle{margin-bottom:0 !important}.wedocs-search-toggle .components-h-stack{flex-direction:row-reverse}.wedocs-search-color-settings .block-editor-panel-color-gradient-settings{border-top:0;padding-left:0;padding-right:0}.wedocs-search-color-settings .block-editor-panel-color-gradient-settings .block-editor-tools-panel-color-gradient-settings__item.first{margin-top:0}.radio-image-control-options{display:flex;flex-direction:row;justify-content:space-between}.radio-image-control-options .radio-image-option{margin-right:10px}.radio-image-control-options .radio-image-option label{cursor:pointer;display:block}.radio-image-control-options .radio-image-option input[type=radio]{display:none}.radio-image-control-options .radio-image-option label i,.radio-image-control-options .radio-image-option label img{width:30px;height:30px;display:block;background-size:cover;background-position:center}.backdrop{top:0;left:0;z-index:0;width:100%;opacity:.5;height:100%;background:#fff;position:absolute}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-field{background-color:var(--field-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-field:hover{background-color:var(--field-bg-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit{background-color:var(--field-btn-bg-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit svg path{fill:var(--field-icon-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit svg path:hover{fill:var(--field-icon-hover-color) !important}.wp-block-wedocs-wedocs-search .wedocs-search-input .search-submit:hover{background-color:var(--field-btn-bg-hover-color) !important}.wp-block-wedocs-wedocs-search:not(.wp-block){display:block} .wedocs-color-control{margin:1em 0}.wedocs-color-control label{display:block;margin-bottom:.5em}.wedocs-docs-pagination{margin:30px 0;text-align:center}.wedocs-docs-pagination ul{display:inline-flex;list-style:none;padding:0;margin:0;gap:5px}.wedocs-docs-pagination li{margin:0}.wedocs-docs-pagination button{display:inline-block;padding:8px 12px;border:1px solid var(--wedocs-pagination-border-color, #ddd);border-radius:var(--wedocs-border-radius, 4px);text-decoration:none;color:var(--wedocs-pagination-text-color, #333);background:var(--wedocs-pagination-background-color, #fff);cursor:pointer;transition:all .2s}.wedocs-docs-pagination button:hover{background:var(--wedocs-pagination-hover-color, #f5f5f5);color:var(--wedocs-pagination-text-hover-color, #0073aa)}.wedocs-docs-pagination button.is-active{background:var(--wedocs-pagination-hover-color, #f5f5f5);border-color:var(--wedocs-pagination-hover-color, #ccc)}.wedocs-block-wrapper{width:100%;max-width:1200px;margin:0 auto;padding:.5rem}.wedocs-preview-title{margin-bottom:1rem;font-size:1.1rem;color:var(--wedocs-text-secondary-color, #757575)}.wedocs-docs-grid{display:grid;gap:1.5rem;width:100%;margin:0;padding:0;list-style:none}.wedocs-docs-grid--1x1{grid-template-columns:1fr}.wedocs-docs-grid--1x2{grid-template-columns:repeat(2, 1fr)}@media(max-width: 768px){.wedocs-docs-grid--1x2{grid-template-columns:1fr}}.wedocs-docs-grid .inside{display:flex;color:#063250;font-size:18px;min-height:240px;list-style:none}.wedocs-docs-grid .inside svg{width:64px;height:24px;margin:2px .5rem 0 0}.wedocs-docs-grid__item{position:relative;background-color:#fff;transition:transform .2s,box-shadow .2s;list-style:none;padding:var(--wedocs-grid-padding, 1.5rem);margin:var(--wedocs-grid-margin, 0);border-width:var(--wedocs-border-width, 1px);border-style:var(--wedocs-border-type, solid);border-color:var(--wedocs-border-color, rgba(0, 0, 0, 0.1));border-radius:var(--wedocs-border-radius, 8px)}.wedocs-docs-grid__title{font-size:1.5rem;font-weight:800;color:var(--wedocs-doc-title-color, #1e1e1e);margin:0 0 .75rem;line-height:1.4}.wedocs-docs-grid__article-count{font-size:.875rem;color:var(--wedocs-text-secondary-color, #757575);margin:0}.wedocs-docs-grid__container{min-height:240px}.wedocs-docs-grid__sections{margin-top:1rem;padding:0}.wedocs-docs-grid__sections.is-collapsed .wedocs-docs-grid__articles{display:none}.wedocs-docs-grid__section-title{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;display:flex;justify-content:space-between;align-items:center}.wedocs-docs-grid__section-title a{pointer-events:auto;text-decoration:none}.wedocs-docs-grid__section-title a:hover{text-decoration:underline}.wedocs-docs-grid__section-title svg{transition:transform .3s ease;cursor:pointer;flex-shrink:0}.wedocs-docs-grid__section-title svg.active{transform:rotate(180deg)}.wedocs-docs-grid__articles{max-height:1000px;overflow:hidden;transition:max-height .3s ease-in-out}.wedocs-docs-grid__articles.collapsed{max-height:0}.wedocs-docs-grid__articles li{opacity:1;transition:opacity .2s ease-in-out}.wedocs-docs-grid__articles.collapsed li{opacity:0}.wedocs-docs-grid__section{margin-bottom:1rem}.wedocs-docs-grid__section-title{font-size:1rem;color:var(--wedocs-doc-title-color, #1e1e1e);margin:.5rem 0}.wedocs-docs-grid__articles{margin:.5rem 0 .5rem 1rem;padding:0}.wedocs-docs-grid__articles li{color:var(--wedocs-doc-children-active-color, #0073aa);font-size:.875rem;margin-bottom:.25rem;margin-left:1rem}.wedocs-docs-grid__articles li ::marker{content:"•";color:var(--wedocs-doc-children-active-color, #0073aa);margin-right:.5rem}.wedocs-docs-grid__details{margin-top:1rem;padding-top:1rem;border-top:1px solid rgba(0,0,0,.1)}.wedocs-docs-grid__details-link{display:inline-block;padding:var(--wedocs-button-padding, 8px 12px);margin:var(--wedocs-button-margin, 0);background-color:var(--wedocs-button-color, #0073aa);color:var(--wedocs-button-text-color, #fff);border-radius:var(--wedocs-border-radius, 4px);font-size:.875rem;cursor:pointer;transition:all .2s;text-decoration:none}.wedocs-docs-grid__details-link:hover{background-color:var(--wedocs-button-hover-color, #005177);color:var(--wedocs-button-hover-text-color, #fff)}.wp-block-wedocs-docs .wedocs-docs-grid__item{cursor:default}[dir=rtl] .wedocs-docs-grid__details-link::after{content:"←"}.wedocs-docs-pagination{margin:30px 0;text-align:center}.wedocs-docs-pagination .page-numbers{display:inline-flex;list-style:none;padding:0;margin:0;gap:5px}.wedocs-docs-pagination .page-numbers li{margin:0;display:inline-block}.wedocs-docs-pagination .page-numbers a,.wedocs-docs-pagination .page-numbers span{display:inline-block;padding:8px 12px;min-width:32px;margin:0 4px;border:1px solid var(--wedocs-pagination-border-color, #ddd);border-radius:var(--wedocs-border-radius, 4px);background-color:var(--wedocs-pagination-background-color, #fff);color:var(--wedocs-pagination-text-color, #333);text-decoration:none;font-family:inherit;font-size:14px;line-height:1.4;text-align:center;transition:all .2s ease;cursor:pointer}.wedocs-docs-pagination .page-numbers a:hover:not(.current),.wedocs-docs-pagination .page-numbers span:hover:not(.current){background-color:var(--wedocs-pagination-hover-color, #f5f5f5);color:var(--wedocs-pagination-text-hover-color, #0073aa);border-color:var(--wedocs-pagination-hover-color, #ccc)}.wedocs-docs-pagination .page-numbers .current{background-color:var(--wedocs-pagination-hover-color, #f5f5f5);border-color:var(--wedocs-pagination-hover-color, #ccc);color:var(--wedocs-pagination-text-hover-color, #0073aa);cursor:default}.wedocs-docs-pagination .page-numbers .dots{border:none;padding:8px;cursor:default}.wedocs-docs-pagination .page-numbers .dots:hover{background:none;color:inherit}.wedocs-docs-pagination__button{display:inline-block;padding:8px 12px;min-width:32px;margin:0 4px;border:1px solid var(--wedocs-pagination-border-color, #ddd);border-radius:var(--wedocs-border-radius, 4px);background-color:var(--wedocs-pagination-background-color, #fff);color:var(--wedocs-pagination-text-color, #333);text-decoration:none;font-family:inherit;font-size:14px;line-height:1.4;text-align:center;transition:all .2s ease;cursor:pointer}.wedocs-docs-pagination__button:hover:not(.is-active){background-color:var(--wedocs-pagination-hover-color, #f5f5f5) !important;color:var(--wedocs-pagination-text-hover-color, #0073aa) !important;border-color:var(--wedocs-pagination-hover-color, #ccc) !important}.wedocs-docs-pagination__button.is-active{background-color:var(--wedocs-pagination-hover-color, #f5f5f5);border-color:var(--wedocs-pagination-hover-color, #ccc);color:var(--wedocs-pagination-text-hover-color, #0073aa);cursor:default} +.wedocs-color-control{margin-bottom:16px}.wedocs-color-control .components-base-control__label{margin-bottom:8px;font-size:12px;font-weight:500;color:#1e1e1e}.wedocs-color-control .components-color-palette{margin:0}.wedocs-color-control .components-circular-option-picker__custom-clear-wrapper{margin-top:0 !important}.wp-block-wedocs-print-button{display:block !important}.wp-block-wedocs-print-button .wedocs-print-button-wrapper{width:100% !important}.wp-block-wedocs-print-button .wedocs-print-button{display:inline-flex !important;align-items:center !important;justify-content:center !important;gap:8px !important;font-family:inherit !important;line-height:1.4 !important;text-align:center !important;text-decoration:none !important;outline:none !important;-webkit-user-select:none !important;-moz-user-select:none !important;user-select:none !important;white-space:nowrap !important;box-sizing:border-box !important}.wp-block-wedocs-print-button .wedocs-print-button:link,.wp-block-wedocs-print-button .wedocs-print-button:visited,.wp-block-wedocs-print-button .wedocs-print-button:hover,.wp-block-wedocs-print-button .wedocs-print-button:active,.wp-block-wedocs-print-button .wedocs-print-button:focus{color:inherit !important;text-decoration:none !important}.wp-block-wedocs-print-button .wedocs-print-button:hover,.wp-block-wedocs-print-button .wedocs-print-button:focus{text-decoration:none;transform:translateY(-1px);box-shadow:0 2px 4px rgba(0,0,0,.1);background-color:var(--hover-bg-color) !important;color:var(--hover-text-color) !important}.wp-block-wedocs-print-button .wedocs-print-button:active{transform:translateY(0)}.wp-block-wedocs-print-button .wedocs-print-button i{font-size:1em;line-height:1}.wp-block-wedocs-print-button .wedocs-print-button.layout-1{flex-direction:row;gap:8px}.wp-block-wedocs-print-button .wedocs-print-button.layout-2{flex-direction:row;gap:8px;border-radius:6px;box-shadow:0 1px 3px rgba(0,0,0,.1)}.wp-block-wedocs-print-button .wedocs-print-button.layout-3{flex-direction:column;gap:4px}.wp-block-wedocs-print-button .wedocs-print-button.layout-3 span{line-height:1.2}.wp-block-wedocs-print-button[style*="text-align: left"]{text-align:left}.wp-block-wedocs-print-button[style*="text-align: center"]{text-align:center}.wp-block-wedocs-print-button[style*="text-align: right"]{text-align:right}.block-editor-block-list__layout .wp-block-wedocs-print-button .wedocs-print-button{pointer-events:none}@media print{.wp-block-wedocs-print-button{display:none}}@media(max-width: 768px){.wp-block-wedocs-print-button .wedocs-print-button.layout-1,.wp-block-wedocs-print-button .wedocs-print-button.layout-2{flex-direction:column;gap:4px}.wp-block-wedocs-print-button .wedocs-print-button.large-size{font-size:16px}}@media(prefers-contrast: high){.wp-block-wedocs-print-button .wedocs-print-button{border-width:2px}.wp-block-wedocs-print-button .wedocs-print-button.ghost{border:2px solid currentColor}}@media(prefers-reduced-motion: reduce){.wp-block-wedocs-print-button .wedocs-print-button{transition:none}.wp-block-wedocs-print-button .wedocs-print-button:hover{transform:none}}@media print{.wp-block-wedocs-print-button,.wp-block-wedocs-print-button *,.wedocs-print-button-wrapper,.wedocs-print-button-wrapper *,.wedocs-print-button,.wedocs-print-button *,.wedocs-print-article,.wedocs-print-article *,a.wedocs-print-article,a.wedocs-print-article *,.wp-block-wedocs-print-button .layout-1,.wp-block-wedocs-print-button .layout-2,.wp-block-wedocs-print-button .layout-3,.wp-block-wedocs-print-button a,.wp-block-wedocs-print-button button,[class*=wedocs-print],[class*=wedocs-print] *,[class*=print-button],[class*=print-button] *,[id*=wedocs-print],[id*=wedocs-print] *,[id^=wedocs-print-btn-],[id^=wedocs-print-btn-] *{display:none !important;visibility:hidden !important;opacity:0 !important;height:0 !important;width:0 !important;margin:0 !important;padding:0 !important;overflow:hidden !important;position:absolute !important;left:-9999px !important;top:-9999px !important}div.wp-block-wedocs-print-button.wedocs-print-button-wrapper{display:none !important}*[title*=Print],*[title*=print],*[aria-label*=Print],*[aria-label*=print]{display:none !important}} diff --git a/assets/js/frontend.js b/assets/js/frontend.js index 3f7fd977..5800126e 100755 --- a/assets/js/frontend.js +++ b/assets/js/frontend.js @@ -87,10 +87,64 @@ mywindow.document.close(); // necessary for IE >= 10 mywindow.focus(); // necessary for IE >= 10 - // setTimeout( function () { - // mywindow.print(); - // mywindow.close(); - // }, 2000 ); + // Event-driven print handling + let printCompleted = false; + let fallbackTimeout = null; + + // Function to handle print completion and cleanup + const handlePrintComplete = function() { + if (printCompleted) return; // Prevent multiple calls + printCompleted = true; + + // Clear fallback timeout if it exists + if (fallbackTimeout) { + clearTimeout(fallbackTimeout); + fallbackTimeout = null; + } + + // Remove event listeners to prevent memory leaks + if (mywindow.removeEventListener) { + mywindow.removeEventListener('afterprint', handlePrintComplete); + } else if (mywindow.detachEvent) { + mywindow.detachEvent('onafterprint', handlePrintComplete); + } + + // Close the window + mywindow.close(); + }; + + // Function to initiate printing + const initiatePrint = function() { + // Attach afterprint event listener before printing + if (mywindow.addEventListener) { + mywindow.addEventListener('afterprint', handlePrintComplete, false); + } else if (mywindow.attachEvent) { + // IE8 and older support + mywindow.attachEvent('onafterprint', handlePrintComplete); + } + + // Set up fallback timeout as last resort (for browsers that don't support afterprint) + fallbackTimeout = setTimeout(function() { + if (!printCompleted) { + console.warn('Print afterprint event not fired, using fallback cleanup'); + handlePrintComplete(); + } + }, 30000); // 30 second fallback timeout + + // Initiate print + mywindow.print(); + }; + + // Wait for window to load before printing + if (mywindow.addEventListener) { + mywindow.addEventListener('load', initiatePrint, false); + } else if (mywindow.attachEvent) { + // IE8 and older support + mywindow.attachEvent('onload', initiatePrint); + } else { + // Fallback for very old browsers + mywindow.onload = initiatePrint; + } return true; }, diff --git a/src/blocks/PrintButton/Inspector.js b/src/blocks/PrintButton/Inspector.js new file mode 100644 index 00000000..00a5e3df --- /dev/null +++ b/src/blocks/PrintButton/Inspector.js @@ -0,0 +1,258 @@ +import { __ } from '@wordpress/i18n'; +import { + PanelBody, + SelectControl, + RangeControl, + __experimentalUnitControl as UnitControl, + __experimentalBoxControl as BoxControl, +} from '@wordpress/components'; +import { + InspectorControls, + PanelColorSettings, +} from '@wordpress/block-editor'; +import { Fragment } from '@wordpress/element'; + +const Inspector = ({ attributes, setAttributes }) => { + const { + padding, + margin, + backgroundColor, + textColor, + hoverBackgroundColor, + hoverTextColor, + borderRadius, + borderWidth, + borderColor, + borderStyle, + fontSize, + fontWeight, + } = attributes; + + // Helper function to update nested objects + const updateAttribute = + (attributeName, property = null) => + (value) => { + if (property) { + setAttributes({ + [attributeName]: { + ...attributes[attributeName], + [property]: value, + }, + }); + } else { + setAttributes({ [attributeName]: value }); + } + }; + + return ( + + + + + + + + + + {BoxControl ? ( + + + + + + ) : ( + +

+ {__( + 'Individual spacing controls (Padding & Margin)', + 'wedocs' + )} +

+ {/* Fallback individual controls if BoxControl is not available */} +
+ {__('Padding', 'wedocs')} +
+
+ {__('Margin', 'wedocs')} +
+
+ )} +
+ + + {UnitControl ? ( + + + + + + + + ) : ( + + + updateAttribute('borderRadius')(`${value}px`) + } + min={0} + max={50} + /> + + + updateAttribute('borderWidth')(`${value}px`) + } + min={0} + max={10} + /> + + + updateAttribute('fontSize')(`${value}px`) + } + min={10} + max={32} + /> + + )} + + + + + + + +
+
+ ); +}; + +export default Inspector; diff --git a/src/blocks/PrintButton/block.json b/src/blocks/PrintButton/block.json new file mode 100644 index 00000000..bbc666c8 --- /dev/null +++ b/src/blocks/PrintButton/block.json @@ -0,0 +1,99 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "wedocs/print-button", + "version": "1.0.0", + "title": "weDocs - Print Button", + "icon": "printer", + "category": "wedocs", + "description": "Add a print button to allow users to print the current page", + "keywords": ["print", "button", "wedocs", "documentation"], + "supports": { + "html": false, + "align": ["left", "center", "right"] + }, + "editorScript": "file:./index.js", + "editorStyle": "file:./index.css", + "style": "file:./style-index.css", + "render": "file:./render.php", + "attributes": { + "layout": { + "type": "string", + "default": "layout1" + }, + "alignment": { + "type": "string", + "default": "left" + }, + "buttonText": { + "type": "string", + "default": "Print" + }, + "showIcon": { + "type": "boolean", + "default": true + }, + "padding": { + "type": "object", + "default": { + "top": "10px", + "right": "15px", + "bottom": "10px", + "left": "15px" + } + }, + "margin": { + "type": "object", + "default": { + "top": "0px", + "right": "0px", + "bottom": "10px", + "left": "0px" + } + }, + "backgroundColor": { + "type": "string", + "default": "#0073aa" + }, + "textColor": { + "type": "string", + "default": "#ffffff" + }, + "hoverBackgroundColor": { + "type": "string", + "default": "#005177" + }, + "hoverTextColor": { + "type": "string", + "default": "#ffffff" + }, + "borderRadius": { + "type": "string", + "default": "4px" + }, + "borderWidth": { + "type": "string", + "default": "1px" + }, + "borderColor": { + "type": "string", + "default": "#0073aa" + }, + "borderStyle": { + "type": "string", + "default": "solid" + }, + "fontSize": { + "type": "string", + "default": "16px" + }, + "fontWeight": { + "type": "string", + "default": "normal" + }, + "additionalClasses": { + "type": "string", + "default": "" + } + } +} diff --git a/src/blocks/PrintButton/edit.js b/src/blocks/PrintButton/edit.js new file mode 100644 index 00000000..f1523cec --- /dev/null +++ b/src/blocks/PrintButton/edit.js @@ -0,0 +1,171 @@ +import { __ } from '@wordpress/i18n'; +import { Fragment } from '@wordpress/element'; +import { useBlockProps, InspectorControls, BlockControls, AlignmentToolbar } from '@wordpress/block-editor'; +import { + PanelBody, + SelectControl, + ToggleControl, + TextControl, + PanelRow +} from '@wordpress/components'; +import Inspector from './Inspector'; + +const Edit = ({ attributes, setAttributes }) => { + const blockProps = useBlockProps(); + + const { + layout, + alignment, + buttonText, + showIcon, + padding, + margin, + backgroundColor, + textColor, + hoverBackgroundColor, + hoverTextColor, + borderRadius, + borderWidth, + borderColor, + borderStyle, + fontSize, + fontWeight, + additionalClasses + } = attributes; + + // Apply inline styles + const buttonInlineStyles = { + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + gap: showIcon ? '8px' : '0', + padding: `${padding.top} ${padding.right} ${padding.bottom} ${padding.left}`, + margin: `${margin.top} ${margin.right} ${margin.bottom} ${margin.left}`, + backgroundColor: backgroundColor, + color: textColor, + border: `${borderWidth} ${borderStyle} ${borderColor}`, + borderRadius: borderRadius, + fontSize: fontSize, + fontWeight: fontWeight, + textDecoration: 'none', + cursor: 'pointer', + transition: 'all 0.2s ease-in-out', + '--hover-bg-color': hoverBackgroundColor, + '--hover-text-color': hoverTextColor + }; + + // Container alignment styles + const containerStyles = { + textAlign: alignment, + width: '100%' + }; + + // Layout variations + const renderLayout = () => { + switch (layout) { + case 'layout2': + return ( +
+ +
+ ); + case 'layout3': + return ( +
+ +
+ ); + default: // layout1 + return ( +
+ +
+ ); + } + }; + + return ( + + + setAttributes({ alignment: newAlignment || 'left' })} + /> + + + + + setAttributes({ layout: value })} + /> + + setAttributes({ buttonText: value })} + placeholder={__('Print', 'wedocs')} + /> + + + setAttributes({ showIcon: value })} + /> + + + + + + + setAttributes({ additionalClasses: value })} + help={__('Add custom CSS classes separated by spaces', 'wedocs')} + /> + + + +
+
+ {renderLayout()} +
+
+
+ ); +}; + +export default Edit; diff --git a/src/blocks/PrintButton/index.js b/src/blocks/PrintButton/index.js new file mode 100644 index 00000000..e43260d4 --- /dev/null +++ b/src/blocks/PrintButton/index.js @@ -0,0 +1,8 @@ +import { registerBlockType } from "@wordpress/blocks"; +import Edit from "./edit"; +import metadata from "./block.json"; +import "./style.scss"; + +registerBlockType(metadata.name, { + edit: Edit, +}); diff --git a/src/blocks/PrintButton/render.php b/src/blocks/PrintButton/render.php new file mode 100644 index 00000000..e76695bc --- /dev/null +++ b/src/blocks/PrintButton/render.php @@ -0,0 +1,165 @@ +post_type !== 'docs') { + return ''; +} + +ob_start(); + +// Extract attributes with defaults +$layout = isset($attributes['layout']) ? $attributes['layout'] : 'layout1'; +$alignment = isset($attributes['alignment']) ? $attributes['alignment'] : 'left'; +$button_text = isset($attributes['buttonText']) ? $attributes['buttonText'] : __('Print', 'wedocs'); +$show_icon = isset($attributes['showIcon']) ? $attributes['showIcon'] : true; +$additional_classes = isset($attributes['additionalClasses']) ? $attributes['additionalClasses'] : ''; + +// Spacing attributes with proper defaults for empty values +$padding_defaults = [ + 'top' => '10px', + 'right' => '15px', + 'bottom' => '10px', + 'left' => '15px' +]; + +$margin_defaults = [ + 'top' => '0px', + 'right' => '0px', + 'bottom' => '10px', + 'left' => '0px' +]; + +// Merge with defaults to handle empty/undefined individual properties +$padding = array_merge($padding_defaults, isset($attributes['padding']) ? array_filter($attributes['padding'], function($value) { + return !($value === null || $value === ''); +}) : []); + +$margin = array_merge($margin_defaults, isset($attributes['margin']) ? array_filter($attributes['margin'], function($value) { + return !($value === null || $value === ''); +}) : []); + +// Color and style attributes +$background_color = isset($attributes['backgroundColor']) ? $attributes['backgroundColor'] : '#0073aa'; +$text_color = isset($attributes['textColor']) ? $attributes['textColor'] : '#ffffff'; +$hover_bg_color = isset($attributes['hoverBackgroundColor']) ? $attributes['hoverBackgroundColor'] : '#005177'; +$hover_text_color = isset($attributes['hoverTextColor']) ? $attributes['hoverTextColor'] : '#ffffff'; +$border_radius = isset($attributes['borderRadius']) ? $attributes['borderRadius'] : '4px'; +$border_width = isset($attributes['borderWidth']) ? $attributes['borderWidth'] : '1px'; +$border_color = isset($attributes['borderColor']) ? $attributes['borderColor'] : '#0073aa'; +$border_style = isset($attributes['borderStyle']) ? $attributes['borderStyle'] : 'solid'; +$font_size = isset($attributes['fontSize']) ? $attributes['fontSize'] : '16px'; +$font_weight = isset($attributes['fontWeight']) ? $attributes['fontWeight'] : 'normal'; + +// Generate unique ID for styles +$block_id = 'wedocs-print-btn-' . wp_generate_uuid4(); + +// Container styles based on alignment +$container_styles = sprintf('text-align: %s; width: 100%%;', esc_attr($alignment)); + +// Build CSS classes +$css_classes = sprintf('wedocs-print-article wedocs-print-button %s %s', + esc_attr($layout), + esc_attr($additional_classes) +); + +// Render layout variations +$button_content = ''; + +switch ($layout) { + case 'layout2': + $button_content = sprintf( + ' + %s + %s + ', + esc_attr($block_id), + esc_attr($css_classes), + esc_attr(__('Print this article', 'wedocs')), + $show_icon ? '' : '', + esc_html($button_text) + ); + break; + + case 'layout3': + $button_content = sprintf( + ' + %s + %s + ', + esc_attr($block_id), + esc_attr($css_classes), + esc_attr(__('Print this article', 'wedocs')), + $show_icon ? '' : '', + esc_html($button_text) + ); + break; + + default: // layout1 + $button_content = sprintf( + ' + %s + %s + ', + esc_attr($block_id), + esc_attr($css_classes), + esc_attr(__('Print this article', 'wedocs')), + $show_icon ? '' : '', + esc_html($button_text) + ); + break; +} + +// Output the complete block with custom styles +?> + +
+ +
+ diff --git a/src/blocks/PrintButton/style.scss b/src/blocks/PrintButton/style.scss new file mode 100644 index 00000000..b6579122 --- /dev/null +++ b/src/blocks/PrintButton/style.scss @@ -0,0 +1,249 @@ +/** + * Print Button Block Styles + */ + +// Simple, clean color control styles for Print Button block +.wedocs-color-control { + margin-bottom: 16px; + + .components-base-control__label { + margin-bottom: 8px; + font-size: 12px; + font-weight: 500; + color: #1e1e1e; + } + + .components-color-palette { + margin: 0; + } + + // Remove unwanted margin from circular option picker clear wrapper + .components-circular-option-picker__custom-clear-wrapper { + margin-top: 0 !important; + } +} + +.wp-block-wedocs-print-button { + display: block !important; + // Remove hardcoded margin - let user control it via render.php inline styles + // margin: 10px 0; + + .wedocs-print-button-wrapper { + width: 100% !important; + } + + .wedocs-print-button { + // High specificity to override theme styles + display: inline-flex !important; + align-items: center !important; + justify-content: center !important; + gap: 8px !important; + font-family: inherit !important; + line-height: 1.4 !important; + text-align: center !important; + text-decoration: none !important; + outline: none !important; + user-select: none !important; + white-space: nowrap !important; + box-sizing: border-box !important; + + // Reset link styles aggressively + &:link, + &:visited, + &:hover, + &:active, + &:focus { + color: inherit !important; + text-decoration: none !important; + } + + // Ensure inline styles take precedence + &[style] { + // This selector has higher specificity when style attribute exists + } + + &:hover, + &:focus { + text-decoration: none; + transform: translateY(-1px); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + + // Use CSS custom properties for hover colors (set via inline styles) + background-color: var(--hover-bg-color) !important; + color: var(--hover-text-color) !important; + } + + &:active { + transform: translateY(0); + } + + // Icon styles + i { + font-size: 1em; + line-height: 1; + } + + // Layout variations + &.layout-1 { + flex-direction: row; + gap: 8px; + } + + &.layout-2 { + flex-direction: row; + gap: 8px; + border-radius: 6px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + } + + &.layout-3 { + flex-direction: column; + gap: 4px; + // Remove default padding - let user control it + // padding: 12px 15px; + + span { + line-height: 1.2; + } + } + + // Size variations - no hardcoded padding, let user control it + // Removed size-based padding to let user settings work + + // Style variations + // Remove hardcoded colors - let inline styles from render.php handle all colors + // This ensures user's custom color settings are not overridden + } + + // Alignment styles + &[style*="text-align: left"] { + text-align: left; + } + + &[style*="text-align: center"] { + text-align: center; + } + + &[style*="text-align: right"] { + text-align: right; + } +} + +// Editor specific styles +.block-editor-block-list__layout { + .wp-block-wedocs-print-button { + .wedocs-print-button { + pointer-events: none; // Prevent clicks in editor + } + } +} + +// Print-specific styles +@media print { + .wp-block-wedocs-print-button { + display: none; + } +} + +// Mobile responsive +@media (max-width: 768px) { + .wp-block-wedocs-print-button { + .wedocs-print-button { + &.layout-1, + &.layout-2 { + flex-direction: column; + gap: 4px; + // Remove hardcoded padding - let user control it via render.php inline styles + // padding: 12px 15px; + } + + &.large-size { + font-size: 16px; + // Remove hardcoded padding - let user control it via render.php inline styles + // padding: 12px 16px; + } + } + } +} + +// High contrast mode +@media (prefers-contrast: high) { + .wp-block-wedocs-print-button { + .wedocs-print-button { + border-width: 2px; + + &.ghost { + border: 2px solid currentColor; + } + } + } +} + +// Reduced motion +@media (prefers-reduced-motion: reduce) { + .wp-block-wedocs-print-button { + .wedocs-print-button { + transition: none; + + &:hover { + transform: none; + } + } + } +} + +// Hide print button completely in print preview and when printing +@media print { + // Maximum specificity selectors to override any theme or plugin styles + .wp-block-wedocs-print-button, + .wp-block-wedocs-print-button *, + .wedocs-print-button-wrapper, + .wedocs-print-button-wrapper *, + .wedocs-print-button, + .wedocs-print-button *, + .wedocs-print-article, + .wedocs-print-article *, + a.wedocs-print-article, + a.wedocs-print-article *, + // Target layout-specific classes + .wp-block-wedocs-print-button .layout-1, + .wp-block-wedocs-print-button .layout-2, + .wp-block-wedocs-print-button .layout-3, + .wp-block-wedocs-print-button a, + .wp-block-wedocs-print-button button, + // Attribute selectors for broader coverage + [class*="wedocs-print"], + [class*="wedocs-print"] *, + [class*="print-button"], + [class*="print-button"] *, + [id*="wedocs-print"], + [id*="wedocs-print"] *, + // Dynamic IDs that might be generated + [id^="wedocs-print-btn-"], + [id^="wedocs-print-btn-"] * { + display: none !important; + visibility: hidden !important; + opacity: 0 !important; + height: 0 !important; + width: 0 !important; + margin: 0 !important; + padding: 0 !important; + overflow: hidden !important; + position: absolute !important; + left: -9999px !important; + top: -9999px !important; + } + + // Also target the block wrapper with higher specificity + div.wp-block-wedocs-print-button.wedocs-print-button-wrapper { + display: none !important; + } + + // Global fallback - hide any element with print-related text or attributes + *[title*="Print"], + *[title*="print"], + *[aria-label*="Print"], + *[aria-label*="print"] { + display: none !important; + } +} diff --git a/src/blocks/index.js b/src/blocks/index.js index a17cad8b..c0f9c2d5 100644 --- a/src/blocks/index.js +++ b/src/blocks/index.js @@ -1,2 +1,3 @@ import './Search'; import './DocsGrid'; +import './PrintButton'; diff --git a/wedocs.php b/wedocs.php index faa2276f..9a17253f 100644 --- a/wedocs.php +++ b/wedocs.php @@ -47,6 +47,7 @@ require_once __DIR__ . '/vendor/autoload.php'; require_once plugin_dir_path(__FILE__) . 'assets/build/blocks/DocsGrid/render.php'; +require_once plugin_dir_path(__FILE__) . 'assets/build/blocks/PrintButton/render.php'; /** * WeDocs class. @@ -169,6 +170,7 @@ public function init_actions() { // Localize our plugin add_action( 'init', [ $this, 'localization_setup' ] ); add_action('init', [$this, 'register_blocks']); + add_action('block_categories_all', [$this, 'register_block_category']); // registeer our widget add_action( 'widgets_init', [ $this, 'register_widget' ] ); @@ -182,6 +184,41 @@ public function register_blocks() { 'render_callback' => 'render_wedocs_docs_grid' ) ); + + // Register the PrintButton block + register_block_type( + plugin_dir_path(__FILE__) . 'assets/build/blocks/PrintButton', + array( + 'render_callback' => 'render_wedocs_print_button' + ) + ); + } + + /** + * Register the weDocs block category. + * + * @param array $categories Existing block categories. + * @return array Modified block categories. + */ + public function register_block_category($categories) { + // Check if weDocs category already exists + foreach ($categories as $category) { + if ($category['slug'] === 'wedocs') { + return $categories; + } + } + + // Add weDocs category at the beginning + return array_merge( + array( + array( + 'slug' => 'wedocs', + 'title' => __('weDocs', 'wedocs'), + 'icon' => null + ) + ), + $categories + ); } /**