芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/blocksy-companion/static/js/editor/blocks/query/Edit.js
import { useState, createElement, useRef, useEffect } from '@wordpress/element' import { __ } from 'ct-i18n' import { TextControl, ToolbarGroup, ToolbarButton } from '@wordpress/components' import { dispatch, useSelect, useDispatch } from '@wordpress/data' import { InspectorControls, useBlockProps, BlockControls, withColors, useInnerBlocksProps, store as blockEditorStore, __experimentalUseBorderProps as useBorderProps, } from '@wordpress/block-editor' import Preview from './Preview' import ColorsPanel from '../../components/ColorsPanel' import { OptionsPanel } from 'blocksy-options' import { PanelBody } from '@wordpress/components' import { useUniqueId } from '../../hooks/use-unique-id' import PostsPlaceholder from './edit/PostsPlaceholder' import PostsInspectorControls from './edit/PostsInspectorControls' import PatternSelectionModal from './edit/PatternSelectionModal' import { usePostTypes } from './edit/utils/utils' const Edit = ({ clientId, className, attributes, setAttributes, context, }) => { const innerBlocksProps = useInnerBlocksProps({}, {}) const hasInnerBlocks = useSelect( (select) => !!select(blockEditorStore).getBlocks(clientId).length, [clientId] ) const isOnboarding = !hasInnerBlocks && attributes.design !== 'default' const { postTypesSelectOptions } = usePostTypes({ hasPages: hasInnerBlocks, }) const { uniqueId, props: wrapperProps } = useUniqueId({ attributes, setAttributes, clientId, }) const { postId, postType } = context const navRef = useRef() const borderProps = useBorderProps(attributes) const blockProps = useBlockProps({ ref: navRef, className, style: { ...borderProps.style, }, }) const [isPatternSelectionModalOpen, setIsPatternSelectionModalOpen] = useState(false) return ( <> {isPatternSelectionModalOpen && (
)} {!isOnboarding ? (
{attributes.design === 'default' && (
)} {hasInnerBlocks &&
}
) : (
)}
{ if (hasInnerBlocks) { dispatch( 'core/block-editor' ).replaceInnerBlocks(clientId, [], false) } else { dispatch( 'core/block-editor' ).updateBlockAttributes(clientId, { design: '', }) } }} />
{!isOnboarding && ( <>
{ setAttributes({ [optionId]: optionValue, ...(optionId === 'post_type' ? { include_term_ids: {}, exclude_term_ids: {}, include_post_ids: { ids: [], current_post: false, }, exclude_post_ids: { ids: [], current_post: false, }, } : {}), }) }} options={{ post_type: { type: 'ct-select', label: __('Post Type', 'blocksy-companion'), value: '', defaultToFirstItem: false, choices: postTypesSelectOptions, purpose: 'default', }, limit: { type: 'ct-number', label: __('Limit', 'blocksy-companion'), value: '', min: 1, max: 100, }, has_pagination: { type: 'ct-switch', label: __('Pagination', 'blocksy-companion'), value: '', }, }} value={attributes} hasRevertButton={false} />
> )}
{}} onFocus={(e) => { e.target.select() }} help={__( 'Please look at the documentation for more information on why this is useful.', 'blocksy-companion' )} />
> ) } export default Edit