/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { InspectorControls } from '@wordpress/block-editor'; import { applyFilters } from "@wordpress/hooks"; import { PanelBody, TextControl, Button, ButtonGroup, BaseControl, ToggleControl, SelectControl, TabPanel, Notice, Placeholder } from '@wordpress/components'; import { MediaPlaceholder } from '@wordpress/block-editor'; import upload from '../../../util/upload'; import cross from '../../../util/cross'; import { useEffect } from '@wordpress/element'; import { select, withSelect } from '@wordpress/data'; /** * Internal depencencies */ import objAttributes from "./attributes"; import Select from "react-select"; import FontIconPicker from "@fonticonpicker/react-fonticonpicker"; import faIcons from "../../../util/faIcons"; import { mimmikCssForResBtns, mimmikCssOnPreviewBtnClickWhileBlockSelected, } from "../../../util/helpers"; import { ORDER_BY, ORDER, LAYOUT, GRID_BACKGROUND, COLUMNS, HTML_TAGS, GRID_MARGIN, GRID_PADDING, GRID_BORDER, TITLE_MARGIN, TITLE_PADDING, TITLE_BACKGROUND, TITLE_BORDER, POSTS_ORDER_BY, LAYOUT_MODE, GRID_SPACE, COUNT_SIZE, COUNT_BACKGROUND, COUNT_BORDER, LIST_MARGIN, LIST_PADDING, LIST_BACKGROUND, ICON_SIZE, ICON_WIDTH, ICON_HEIGHT, ICON_MARGIN, BTN_MARGIN, BTN_PADDING, BTN_BACKGROUND, BTN_BORDER, BUTTON_POSITION, WRAPPER_MARGIN, CONTAINER_SECTION_MARGIN, CONTAINER_SECTION_PADDING, CONTAINER_SECTION_BACKGROUND, COUNT_BACKGROUND_LAYOUT_2, COUNT_PADDING_LAYOUT_2, COUNT_MARGIN_LAYOUT_2, TITLE_PADDING_LAYOUT_2, TITLE_MARGIN_LAYOUT_2 } from "./constants"; import { typoPrefix_title, typoPrefix_count, typoPrefix_list, typoPrefix_button, } from "./typographyPrefixConstants"; // util import ResponsiveRangeController from "../../../util/responsive-range-control"; import ResponsiveDimensionsControl from "../../../util/dimensions-control-v2"; import TypographyDropdown from "../../../util/typography-control-v2"; import BackgroundControl from "../../../util/background-control"; import BorderShadowControl from "../../../util/border-shadow-control"; import ColorControl from "../../../util/color-control"; const Inspector = ({ docCategories, categories, attributes, setAttributes, }) => { const { resOption, includeCategories, excludeCategories, postCategories, gridPerPage, orderBy, order, postsPerPage, postsOrderBy, postsOrder, enableNestedSubcategory, enableLazyLoad, postPerSubcategory, subCategoryPerGrid, layout, layoutMode, showHeader, showIcon, showTitle, titleTag, showCount, showList, listIcon, showButton, categoryTitleLink, buttonText, titleColor, titleHoverColor, countColor, countHoverColor, listColor, listHoverColor, iconColor, showButtonIcon, buttonIcon, buttonIconPosition, buttonColor, buttonHoverColor, buttonPosition, listIconImageUrl, prefix, suffix, suffixSingular, tickerBackgroundColor } = attributes; const editorStoreForGettingPreivew = betterdocs_style_handler.editor_type === "edit-site" ? "core/edit-site" : "core/edit-post"; // this useEffect is for setting the resOption attribute to desktop/tab/mobile depending on the added 'eb-res-option-' class only the first time once useEffect(() => { setAttributes({ resOption: select( editorStoreForGettingPreivew ).__experimentalGetPreviewDeviceType(), }); }, []); const resRequiredProps = { setAttributes, resOption, attributes, objAttributes, }; // handle include categories const handleIncludeCategories = (categories) => { setAttributes({ includeCategories: categories ? JSON.stringify(categories) : null, }); }; // handle exclude categories const handleExcludeCategories = (categories) => { setAttributes({ excludeCategories: categories ? JSON.stringify(categories) : null, }); }; // control POSTS_ORDER_BY for pro plugin let posts_order_by = [ ...POSTS_ORDER_BY, { label: __("BetterDocs Order", "betterdocs"), value: "betterdocs_order", }, ]; return (
{(tab) => (
{tab.name === "general" && ( <> <> {applyFilters("selectKnowledgeBase", '', attributes, setAttributes)}

{__("Include", "betterdocs")}

({ value: category.id, label: category.name, })) } isMulti="true" /> { setAttributes({ gridPerPage: parseInt(value), }); }} /> setAttributes({ orderBy: newOrderby, }) } /> {orderBy != 'doc_category_order' && setAttributes({ order: newOrder, }) } />}

{__("Grid List Docs", "betterdocs")}

{ setAttributes({ postsPerPage: parseInt(value), }); }} /> setAttributes({ postsOrderBy: newPostsOrderBy, }) } /> {postsOrderBy != 'betterdocs_order' && setAttributes({ postsOrder: newPostsOrder, }) } />} { setAttributes({ enableNestedSubcategory: !enableNestedSubcategory, }); }} /> { setAttributes({ enableLazyLoad: !enableLazyLoad, }); }} /> {enableNestedSubcategory && ( <> { setAttributes({ subCategoryPerGrid: parseInt(value), }); }} /> { setAttributes({ postPerSubcategory: parseInt(value), }); }} /> )}
<> setAttributes({ layout: newLayout, }) } /> setAttributes({ layoutMode: newLayoutMode, }) } /> {layoutMode === "masonry" && ( <> {__( "Please save and reload the view page to get the effect of column and space on masonry layout", "betterdocs" )}
)} {layoutMode === "masonry" && ( )} { setAttributes({ showHeader: !showHeader, }); }} /> { setAttributes({ showIcon: !showIcon, }); }} /> { setAttributes({ showTitle: !showTitle, }); }} /> setAttributes({ titleTag: newTitleTag, }) } /> { setAttributes({ showCount: !showCount, }); }} /> { setAttributes({ showList: !showList, }); }} /> { setAttributes({ showButton: !showButton, }); }} /> { setAttributes({ categoryTitleLink: !categoryTitleLink, }); }} /> {showButton && ( { setAttributes({ buttonText: value, }); }} /> )} {layout == 'layout-2' && <> setAttributes({ prefix, }) } /> setAttributes({ suffix, }) } /> setAttributes({ suffixSingular, }) } /> }
)} {tab.name === "styles" && ( <>

{__("Background", "betterdocs")}

{__("Border", "betterdocs")}

setAttributes({ titleColor })} /> setAttributes({ titleHoverColor, }) } />

{__("Background", "betterdocs")}

{__("Border", "betterdocs")}

setAttributes({ countColor })} /> setAttributes({ countHoverColor, }) } /> {layout == 'default' && } {layout == 'layout-2' && <> } {layout == 'layout-2' && setAttributes({ tickerBackgroundColor })} />}

{__("Background", "betterdocs")}

{__("Border", "betterdocs")}

setAttributes({ listColor })} /> setAttributes({ listHoverColor, }) } />

{__("Background", "betterdocs")}


{ setAttributes({ listIconImageUrl:image?.url }) }} value={listIconImageUrl} accept="image/*" allowedTypes={["image"]} mediaLibraryButton={({ open }) => { return ( <> ))}
)} {/* {tab.name === "advance" && ( )} */}
)}
); }; export default withSelect((select) => { return { docCategories: select("core").getEntityRecords("taxonomy", "doc_category", { per_page: -1, }), }; })(Inspector);