Skip to content

Commit

Permalink
Fix rebase conflict issues
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Dec 8, 2023
1 parent cc024a3 commit decc373
Showing 1 changed file with 53 additions and 13 deletions.
66 changes: 53 additions & 13 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import classnames from 'classnames';
*/
import { useRegistry, useSelect, useDispatch } from '@wordpress/data';
import { useRef, useMemo, useEffect } from '@wordpress/element';
import { useEntityProp, useEntityRecord } from '@wordpress/core-data';
import { useEntityRecord, store as coreStore } from '@wordpress/core-data';
import {
Placeholder,
Spinner,
Expand All @@ -28,6 +28,7 @@ import {
BlockControls,
} from '@wordpress/block-editor';
import { getBlockSupport, parse } from '@wordpress/blocks';
import { addQueryArgs } from '@wordpress/url';

/**
* Internal dependencies
Expand Down Expand Up @@ -147,6 +148,7 @@ export default function ReusableBlockEdit( {
attributes: { ref, overrides },
__unstableParentLayout: parentLayout,
clientId: patternClientId,
context: { postId },
} ) {
const registry = useRegistry();
const hasAlreadyRendered = useHasRecursion( ref );
Expand All @@ -164,7 +166,50 @@ export default function ReusableBlockEdit( {
__unstableMarkNextChangeAsNotPersistent,
setBlockEditingMode,
} = useDispatch( blockEditorStore );
const { getBlockEditingMode } = useSelect( blockEditorStore );

const { editUrl, innerBlocks, userCanEdit, getBlockEditingMode } =
useSelect(
( select ) => {
const { canUser } = select( coreStore );
const {
getSettings,
getBlocks,
getBlockEditingMode: editingMode,
} = select( blockEditorStore );

const blocks = getBlocks( patternClientId );
const isBlockTheme = getSettings().__unstableIsBlockBasedTheme;
const canEdit = canUser( 'update', 'blocks', ref );
const defaultUrl = addQueryArgs( 'post.php', {
action: 'edit',
post: ref,
} );
const siteEditorUrl = addQueryArgs( 'site-editor.php', {
postType: 'wp_block',
postId: ref,
categoryType: 'pattern',
canvas: 'edit',
refererId: postId,
} );

// For editing link to the site editor if the theme and user permissions support it.
return {
innerBlocks: blocks,
editUrl:
canUser( 'read', 'templates' ) && isBlockTheme
? siteEditorUrl
: defaultUrl,
userCanEdit: canEdit,
getBlockEditingMode: editingMode,
};
},
[ patternClientId, postId, ref ]
);

useEffect(
() => setBlockEditMode( setBlockEditingMode, innerBlocks ),
[ innerBlocks, setBlockEditingMode ]
);

useEffect( () => {
if ( ! record?.content?.raw ) return;
Expand Down Expand Up @@ -194,17 +239,12 @@ export default function ReusableBlockEdit( {
setBlockEditingMode,
] );

const innerBlocks = useSelect(
( select ) => select( blockEditorStore ).getBlocks( patternClientId ),
[ patternClientId ]
);

const [ title, setTitle ] = useEntityProp(
'postType',
'wp_block',
'title',
ref
);
// const [ title, setTitle ] = useEntityProp(
// 'postType',
// 'wp_block',
// 'title',
// ref
// );

const { alignment, layout } = useInferredLayout(
innerBlocks,
Expand Down

0 comments on commit decc373

Please sign in to comment.