Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const isAppender = index === undefined;
return (
);
}
}
export default compose(
withDispatch( ( dispatch, ownProps ) => {
const {
insertBlocks,
updateBlockAttributes,
moveBlockToPosition,
} = dispatch( 'core/editor' );
return {
insertBlocks( blocks, insertIndex ) {
const { rootUID, layout } = ownProps;
if ( layout ) {
// A block's transform function may return a single
// transformed block or an array of blocks, so ensure
// to first coerce to an array before mapping to inject
// the layout attribute.
* managing block movement.
*
* @param {string} type Action type to dispatch.
* @param {Function} dispatch Store dispatch.
* @param {Object} ownProps The wrapped component's own props.
*
* @return {Function} Prop dispatcher callback.
*/
function createOnMove( type, dispatch, ownProps ) {
return () => {
const { uids, rootUID } = ownProps;
dispatch( { type, uids, rootUID } );
};
}
export default compose(
connect(
( state, ownProps ) => {
const { uids, rootUID } = ownProps;
const block = getBlock( state, first( uids ) );
return ( {
firstIndex: getBlockIndex( state, first( uids ), rootUID ),
blockType: block ? getBlockType( block.name ) : null,
} );
},
( ...args ) => ( {
onMoveDown: createOnMove( 'MOVE_BLOCKS_DOWN', ...args ),
onMoveUp: createOnMove( 'MOVE_BLOCKS_UP', ...args ),
} )
),
withContext( 'editor' )( ( settings ) => {
{ publishSidebarOpened && (
) }
{ editorSidebarOpened && }
{ pluginSidebarOpened && }
);
}
export default compose(
withSelect( ( select ) => ( {
mode: select( 'core/edit-post' ).getEditorMode(),
editorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(),
pluginSidebarOpened: select( 'core/edit-post' ).isPluginSidebarOpened(),
sidebarName: select( 'core/edit-post' ).getActiveGeneralSidebarName(),
publishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ),
metaBoxes: select( 'core/edit-post' ).getMetaBoxes(),
hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
} ) ),
withDispatch( ( dispatch ) => ( {
closePublishSidebar: dispatch( 'core/edit-post' ).closePublishSidebar,
} ) ),
navigateRegions
)( Layout );
return {
postType: getPostType( getEditedPostAttribute( 'type' ) ),
isOpened: isEditorSidebarPanelOpened( PANEL_NAME ),
};
} );
const applyWithDispatch = withDispatch( ( dispatch ) => {
const { toggleGeneralSidebarEditorPanel } = dispatch( 'core/edit-post' );
return {
onTogglePanel: partial( toggleGeneralSidebarEditorPanel, PANEL_NAME ),
};
} );
export default compose(
applyWithSelect,
applyWithDispatch,
)( FeaturedImage );
} = dispatch( 'core/editor' );
return {
onEnterPress() {
insertDefaultBlock( undefined, undefined, 0 );
},
onUpdate( title ) {
editPost( { title } );
},
onUndo: undo,
onRedo: redo,
clearSelectedBlock,
};
} );
export default compose(
applyWithSelect,
applyWithDispatch,
withInstanceId,
withFocusOutside
)( PostTitle );
onChange={ this.onChange }
onInputChange={ this.searchTerms }
maxSuggestions={ MAX_TERMS_SUGGESTIONS }
disabled={ loading }
placeholder={ newTermPlaceholderLabel }
messages={ {
added: termAddedLabel,
removed: termRemovedLabel,
remove: removeTermLabel,
} }
/>
);
}
}
export default compose(
withAPIData( ( props ) => {
const { slug } = props;
return {
taxonomy: `/wp/v2/taxonomies/${ slug }?context=edit`,
};
} ),
withSelect( ( select, ownProps ) => {
const { getCurrentPost } = select( 'core/editor' );
return {
hasCreateAction: get( getCurrentPost(), [ '_links', 'wp:action-create-' + ownProps.restBase ], false ),
hasAssignAction: get( getCurrentPost(), [ '_links', 'wp:action-assign-' + ownProps.restBase ], false ),
terms: select( 'core/editor' ).getEditedPostAttribute( ownProps.restBase ),
};
} ),
withDispatch( ( dispatch ) => {
return {
{ itemsWithoutDefaultBlock.map( ( item ) => (
onInsert( item ) }
label={ sprintf( __( 'Add %s' ), item.title ) }
icon={ (
) }
/>
) ) }
);
}
export default compose(
withEditorSettings( ( settings ) => {
const { templateLock, allowedBlockTypes } = settings;
return {
isLocked: !! templateLock,
allowedBlockTypes,
};
} ),
withSelect( ( select, { allowedBlockTypes } ) => ( {
items: select( 'core/editor' ).getFrecentInserterItems( allowedBlockTypes, 4 ),
} ) ),
withDispatch( ( dispatch, ownProps ) => {
const { uid, rootUID, layout } = ownProps;
return {
onInsert( { name, initialAttributes } ) {
aria-label={ __( 'Document settings' ) }
>
{ __( 'Document' ) }
<button aria-label="{">
{ sprintf( _n( 'Block', '%d Blocks', count ), count ) }
</button>
);
};
export default compose(
withSelect( ( select ) => ( {
count: select( 'core/editor' ).getSelectedBlockCount(),
} ) ),
withDispatch( ( dispatch ) => {
const { openGeneralSidebar } = dispatch( 'core/edit-post' );
const { clearSelectedBlock } = dispatch( 'core/editor' );
return {
openDocumentSettings() {
openGeneralSidebar( 'edit-post/document' );
clearSelectedBlock();
},
openBlockSettings() {
openGeneralSidebar( 'edit-post/block' );
},
};
} ),
<div>
<h3>{ title }</h3>
</div>
<div>
{ render() }
</div>
);
}
export default compose(
withSelect( ( select ) => ( {
pluginSidebar: getSidebarSettings( select( 'core/edit-post' ).getActiveGeneralSidebarName() ),
} ) ),
withDispatch( ( dispatch ) => ( {
onClose: dispatch( 'core/edit-post' ).closeGeneralSidebar,
} ) ),
withFocusReturn,
)( PluginsPanel );
{ ( fillProps ) => (
<menuitem>
{ children }
</menuitem>
) }