Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations: Replace store name string with exposed store definition #28156

Merged
merged 2 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/annotations/src/block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import { addFilter } from '@wordpress/hooks';
import { withSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import { STORE_NAME } from '../store/constants';
/**
* Adds annotation className to the block-list-block component.
*
Expand All @@ -13,7 +17,7 @@ import { withSelect } from '@wordpress/data';
const addAnnotationClassName = ( OriginalComponent ) => {
return withSelect( ( select, { clientId, className } ) => {
const annotations = select(
'core/annotations'
STORE_NAME
).__experimentalGetAnnotationsForBlock( clientId );

return {
Expand All @@ -28,8 +32,4 @@ const addAnnotationClassName = ( OriginalComponent ) => {
} )( OriginalComponent );
};

addFilter(
'editor.BlockListBlock',
'core/annotations',
addAnnotationClassName
);
addFilter( 'editor.BlockListBlock', STORE_NAME, addAnnotationClassName );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is probably incidentally the same. It should remain hardcoded since it need to always remain the same fir backward compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long to answer. Shouldn't it be ok, as the change was using the store name (constant) instead of the definition?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it, conceptually those are 2 different things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that this core/annotations reference shouldn't be replaced since it's not related to the store definition?
If that's the case, then I'm sorry. I didn't go further on the function to check whether it was related or not, just replaced it. Sorry :(

5 changes: 4 additions & 1 deletion packages/annotations/src/format/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { applyFormat, removeFormat } from '@wordpress/rich-text';
const FORMAT_NAME = 'core/annotation';

const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';
const STORE_NAME = 'core/annotations';
/**
* Internal dependencies
*/
import { STORE_NAME } from '../store/constants';

/**
* Applies given annotations to the given record.
Expand Down
6 changes: 6 additions & 0 deletions packages/annotations/src/store/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* The identifier for the data store.
*
* @type {string}
*/
export const STORE_NAME = 'core/annotations';
2 changes: 1 addition & 1 deletion packages/annotations/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as actions from './actions';
/**
* Module Constants
*/
const STORE_NAME = 'core/annotations';
import { STORE_NAME } from './constants';

/**
* Store definition for the annotations namespace.
Expand Down