Skip to content

Commit

Permalink
Pass block context through rich text
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 28, 2024
1 parent c9d3784 commit 9bfc757
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
useCallback,
forwardRef,
createContext,
useContext,
} from '@wordpress/element';
import { useDispatch, useRegistry, useSelect } from '@wordpress/data';
import { useMergeRefs, useInstanceId } from '@wordpress/compose';
Expand Down Expand Up @@ -39,6 +40,7 @@ import { Content, valueToHTMLString } from './content';
import { withDeprecations } from './with-deprecations';
import { unlock } from '../../lock-unlock';
import { canBindBlock } from '../../hooks/use-bindings-attributes';
import BlockContext from '../block-context';

export const keyboardShortcutContext = createContext();
export const inputEventContext = createContext();
Expand Down Expand Up @@ -121,6 +123,7 @@ export function RichTextWrapper(
const context = useBlockEditContext();
const { clientId, isSelected: isBlockSelected, name: blockName } = context;
const blockBindings = context[ blockBindingsKey ];
const blockContext = useContext( BlockContext );
const selector = ( select ) => {
// Avoid subscribing to the block editor store if the block is not
// selected.
Expand Down Expand Up @@ -187,10 +190,7 @@ export function RichTextWrapper(
if (
! blockBindingsSource?.canUserEditValue( {
select,
context:
select( blockEditorStore ).getBlockContext(
clientId
),
context: blockContext,
args: binding.args,
} )
) {
Expand Down

0 comments on commit 9bfc757

Please sign in to comment.