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

Release: 1.19.0 #328

Merged
merged 198 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
ded2081
add TS support for `useTaxonomy` hook
Sidsector9 Mar 3, 2024
8ab4cf5
add TS support for `PostTitle` component
Sidsector9 Mar 3, 2024
dbca017
use alt approach
Sidsector9 Mar 4, 2024
6860e58
Merge branch 'develop' into upkeep/component-post-title
Sidsector9 Mar 11, 2024
50b7157
Merge branch 'upkeep/component-post-title' of github.com:10up/block-c…
Sidsector9 Mar 11, 2024
24ac36a
add verbosity
Sidsector9 Mar 11, 2024
1feac5f
add TS support for `usePost` hook
Sidsector9 Mar 11, 2024
d71d91b
Merge branch 'develop' into upkeep/hook-use-post
Sidsector9 Mar 11, 2024
2fabd1a
Merge branch 'develop' into upkeep/component-post-title
Sidsector9 Mar 11, 2024
8997d66
try fix large package-lock.json
Sidsector9 Mar 11, 2024
1d2e1d2
Merge branch 'develop' into upkeep/hook-use-taxonomy
Sidsector9 Mar 11, 2024
e2299f2
add TS support for `useIsSupportedTaxonomy` hook
Sidsector9 Mar 11, 2024
8918711
add TS support to `MediaToolbar` component
Sidsector9 Mar 11, 2024
4e6f1e7
add TS support for `PostMeta` component
Sidsector9 Mar 11, 2024
329341e
add undefined type
Sidsector9 Mar 12, 2024
ca61275
Merge branch 'upkeep/hook-use-taxonomy' of github.com:10up/block-comp…
Sidsector9 Mar 12, 2024
c6293bf
improve return value
Sidsector9 Mar 12, 2024
1948237
improve return type
Sidsector9 Mar 12, 2024
1249bbd
Merge branch 'develop' into upkeep/component-media-toolbar
Sidsector9 Mar 12, 2024
59d7019
Merge branch 'develop' into upkeep/component-post-meta
Sidsector9 Mar 12, 2024
6b2b3a4
Merge branch 'develop' into upkeep/hook-use-taxonomy
Sidsector9 Mar 12, 2024
8230cf5
Merge branch 'develop' into upkeep/hook-use-is-supported-taxonomy
Sidsector9 Mar 13, 2024
4251415
Merge branch 'develop' into upkeep/hook-use-post
Sidsector9 Mar 13, 2024
f7199b5
Merge branch 'develop' into upkeep/component-post-title
Sidsector9 Mar 13, 2024
045956e
assign default tagName value
Sidsector9 Apr 1, 2024
b5f8cbe
Merge branch 'upkeep/component-post-title' of github.com:10up/block-c…
Sidsector9 Apr 1, 2024
b806091
Merge branch 'develop' into upkeep/component-post-title
Sidsector9 Apr 1, 2024
66bb257
Merge branch 'develop' into upkeep/hook-use-taxonomy
Sidsector9 Apr 1, 2024
cfead96
Merge branch 'develop' into upkeep/component-post-meta
Sidsector9 Apr 1, 2024
0b5101d
Merge branch 'develop' into upkeep/component-media-toolbar
Sidsector9 Apr 1, 2024
e09222f
Merge branch 'develop' into upkeep/hook-use-is-supported-taxonomy
Sidsector9 Apr 1, 2024
b330bfb
fix delete JS version of component
fabiankaegy Apr 16, 2024
5eed872
Merge branch 'develop' into upkeep/hook-use-taxonomy
fabiankaegy Apr 16, 2024
a7df65a
Merge pull request #309 from 10up/upkeep/component-media-toolbar
fabiankaegy Apr 16, 2024
778f417
Merge pull request #308 from 10up/upkeep/hook-use-is-supported-taxonomy
fabiankaegy Apr 16, 2024
88f68d8
Merge pull request #306 from 10up/upkeep/hook-use-post
fabiankaegy Apr 16, 2024
e7d963a
Merge branch 'develop' into upkeep/component-post-meta
Sidsector9 Apr 17, 2024
d8cd835
Merge branch 'develop' into upkeep/component-post-title
Sidsector9 Apr 17, 2024
a76e382
fix allow additional props
fabiankaegy May 3, 2024
e913656
fix type of number variable
fabiankaegy May 3, 2024
235ddb2
Merge pull request #310 from 10up/upkeep/component-post-meta
fabiankaegy May 3, 2024
8eadb72
Merge branch 'develop' into upkeep/hook-use-taxonomy
fabiankaegy May 3, 2024
b4257aa
Merge pull request #303 from 10up/upkeep/hook-use-taxonomy
fabiankaegy May 3, 2024
657c4f7
Merge branch 'develop' into upkeep/component-post-title
fabiankaegy May 3, 2024
54f3f98
fix remove default props
fabiankaegy May 3, 2024
8e5c592
Merge pull request #301 from 10up/upkeep/component-post-title
fabiankaegy May 3, 2024
bcba4ed
Refactor PostDate component to TS
fabiankaegy May 3, 2024
90e8e64
Merge pull request #316 from 10up/refactor/move-post-date-to-typescript
fabiankaegy May 3, 2024
4d4331e
refactor PostAuthor components to TS
fabiankaegy May 3, 2024
d04376c
fix post date
fabiankaegy May 3, 2024
5374b80
Merge pull request #317 from 10up/refactor/migrate-post-author-compon…
fabiankaegy May 3, 2024
ef0ea01
update node to version 20
fabiankaegy May 3, 2024
805e5df
update dependencies
fabiankaegy May 3, 2024
958a1d2
update node version used in actions
fabiankaegy May 3, 2024
dfb4b84
update snapshot to new format
fabiankaegy May 3, 2024
5e84855
fix spec
fabiankaegy May 3, 2024
31d070e
fix remove all patterns in test environment
fabiankaegy May 3, 2024
d527354
Merge pull request #318 from 10up/maintainance/update-dependencies
fabiankaegy May 3, 2024
d41d175
update main entrypoint to be ts
fabiankaegy May 6, 2024
fc02f94
update hooks entrypoint to ts
fabiankaegy May 6, 2024
7d82d8c
install wp-types package
fabiankaegy May 6, 2024
168d338
refactor useAllTerms hook to ts
fabiankaegy May 6, 2024
7ce2021
refactor useBlockParentAttributes to ts
fabiankaegy May 6, 2024
1d663cc
refactor useHasSelectedInnerBlock hook to ts
fabiankaegy May 6, 2024
803fb8a
refactor useIsSupportedMetaField hook to ts
fabiankaegy May 6, 2024
7ea11d2
refactor useOnClickOutside hook to ts
fabiankaegy May 6, 2024
0fbd4af
refactor usePostMetaValue hook to ts
fabiankaegy May 6, 2024
4b782b5
refactor usePrimaryTerm hook to ts
fabiankaegy May 6, 2024
a504c7c
refactor useSelectedTermIds hook to ts
fabiankaegy May 6, 2024
3de9e17
refactor useSelectedTermsOfSavedPost hook to ts
fabiankaegy May 6, 2024
ad685d1
refactor useSelectedTerms hook to ts
fabiankaegy May 6, 2024
6de0c4a
add type for taxonomy
fabiankaegy May 6, 2024
56fae42
update dependencies
fabiankaegy May 6, 2024
1e96163
re add core data
fabiankaegy May 6, 2024
40c7be7
fix move to dev dependencies
fabiankaegy May 6, 2024
f213d4d
Merge pull request #319 from 10up/refactor/update-hooks-to-ts
fabiankaegy May 6, 2024
ee97861
Refactor color settings component in TS
Souptik2001 May 11, 2024
9c9d05c
Add color settings example block
Souptik2001 May 11, 2024
0334575
Add react window types
Antonio-Laguna May 13, 2024
7e193ba
Converting IconPicker to TypeScript
Antonio-Laguna May 13, 2024
29b4659
Fixing broken paths
Antonio-Laguna May 13, 2024
a0eec76
fix indentation issues
Souptik2001 May 13, 2024
9725a3a
remove passing remaining props to BaseControl component
Souptik2001 May 13, 2024
e90a7cb
Add an example block for counter component
Souptik2001 May 13, 2024
ea2c256
Refactor `styled-components-context` in TS
Souptik2001 May 13, 2024
6cb8786
Refactor counter component in TS
Souptik2001 May 14, 2024
5790465
Fix indentation issue
Souptik2001 May 14, 2024
9c1511c
Merge pull request #320 from Souptik2001/refactor/migrate-color-setti…
fabiankaegy May 14, 2024
f97ca0c
Merge branch 'develop' into refactor/counter-component-to-ts
Souptik2001 May 14, 2024
b3a4cad
Pass Counter rest props down to StyledCounter component
Souptik2001 May 14, 2024
9ed890a
Add readme for Counter component
Souptik2001 May 14, 2024
90075ae
Wrap example components with Fragment
Souptik2001 May 14, 2024
3612e21
Merge pull request #322 from Souptik2001/refactor/counter-component-t…
fabiankaegy May 14, 2024
8a6e871
Merge branch 'develop' into feature/icon-picker-typescript-conversion
fabiankaegy May 15, 2024
da1cb5f
add ts-check to icon block example
fabiankaegy May 15, 2024
2b0c05a
update all example blocks to apiVersion 3
fabiankaegy May 15, 2024
8b0329a
update example blocks to use typescript
fabiankaegy May 15, 2024
186eecc
Merge pull request #323 from 10up/fix/update-block-examples
fabiankaegy May 15, 2024
d931200
Merge branch 'develop' into feature/icon-picker-typescript-conversion
fabiankaegy May 15, 2024
047208a
fix use unknown instead of any for unknown additional props
fabiankaegy May 15, 2024
f0b8f59
Migrate content-search component to TS
Souptik2001 May 15, 2024
e260bc5
Remove redundant console log statements
Souptik2001 May 16, 2024
0eca289
Add inline comments
Souptik2001 May 16, 2024
0eb1bf5
Merge pull request #324 from 10up/fix/type-of-unknown-attributes
fabiankaegy May 16, 2024
ddbddd7
Merge branch 'develop' into feature/icon-picker-typescript-conversion
Antonio-Laguna May 20, 2024
93138c7
Solidifying types
Antonio-Laguna May 20, 2024
a2d8101
Merge pull request #321 from 10up/feature/icon-picker-typescript-conv…
fabiankaegy May 20, 2024
30c3332
Merge branch 'develop' into refactor/content-search-component-to-ts
Souptik2001 May 27, 2024
309227a
install @typescript-eslint/parser
fabiankaegy May 28, 2024
47e5134
configure eslint to use @typescript-eslint/parser
fabiankaegy May 28, 2024
061a464
fix update eslintignore
fabiankaegy May 28, 2024
88abf62
run `npm run lint --fix`
fabiankaegy May 28, 2024
af389e9
fix linting
fabiankaegy May 28, 2024
59890ed
ignore cypress config in eslintignore
fabiankaegy Jun 6, 2024
2083983
Merge pull request #325 from Souptik2001/refactor/content-search-comp…
fabiankaegy Jun 6, 2024
6afd09a
refactor content search to use react query
fabiankaegy Jun 6, 2024
c21d48f
remove unused variables
fabiankaegy Jun 6, 2024
fc9ffe6
remove no longer needed types
fabiankaegy Jun 6, 2024
77ede04
fix ensure all dependencies are listed in query filter
fabiankaegy Jun 6, 2024
2ef2087
do additional clean up work of the content search component
fabiankaegy Jun 7, 2024
eec4b56
fix ensure `useOnClickOutside` hook correctly detects clicks across i…
fabiankaegy Jun 7, 2024
27a3fb0
harden types of content search
fabiankaegy Jun 7, 2024
ddc9a2a
fix clean up SearchItem component
fabiankaegy Jun 7, 2024
cd03b9d
simplify code
fabiankaegy Jun 7, 2024
083d09d
add code comment
fabiankaegy Jun 7, 2024
a6464a2
Merge pull request #327 from 10up/fix/use-on-click-outside-hook-to-wo…
fabiankaegy Jun 7, 2024
3c8659c
fix cr feedback
fabiankaegy Jun 7, 2024
a030de9
Merge branch 'trunk' into develop
fabiankaegy Jun 10, 2024
58fbfca
Merge branch 'develop' into fix/use-proper-eslint-for-ts
fabiankaegy Jun 10, 2024
2ed9356
fix lint warnings
fabiankaegy Jun 10, 2024
5aec93d
Merge pull request #329 from 10up/fix/use-proper-eslint-for-ts
fabiankaegy Jun 10, 2024
c173bb8
Merge branch 'develop' into fix/refactor-content-search-to-react-query
fabiankaegy Jun 10, 2024
cd59191
fix linting
fabiankaegy Jun 10, 2024
5f00408
fix lint
fabiankaegy Jun 10, 2024
bb9ee2b
fix lint
fabiankaegy Jun 10, 2024
3a95ba6
fix linting
fabiankaegy Jun 11, 2024
9c761ec
fix update linting
fabiankaegy Jun 11, 2024
2d97321
Merge pull request #330 from 10up/fix/update-linting
fabiankaegy Jun 11, 2024
fe40048
Merge branch 'develop' into fix/refactor-content-search-to-react-query
fabiankaegy Jun 11, 2024
d517b75
fix refactor Repeater away from prop types
fabiankaegy Jun 11, 2024
2bf3f6e
fix move defaultProps to inline default values in ClipboardButton com…
fabiankaegy Jun 11, 2024
4e268c7
fix remove propTypes & defaultProps from RichTextCharacterLimit compo…
fabiankaegy Jun 11, 2024
49bcc31
fix remove propTypes & defaultProps from ListItem component
fabiankaegy Jun 11, 2024
7d268db
fix remove propTypes & defaultProps from CustomBlockAppender component
fabiankaegy Jun 11, 2024
0eb8729
fix remove defaultProps & propTypes from Image component
fabiankaegy Jun 11, 2024
26967ac
remove defaultProps & propTypes from InnerBlockSlider component
fabiankaegy Jun 11, 2024
b315bcf
remove prop types eslint rule
fabiankaegy Jun 11, 2024
0d0fca1
remove defaultProps & propTypes from PostCategoryList
fabiankaegy Jun 11, 2024
83c8b9e
remove defaultProps & propTypes from Link Component
fabiankaegy Jun 11, 2024
eeb1f48
remove defaultProps & propTypes from PostExcerpt component
fabiankaegy Jun 11, 2024
5fd28fe
remove defaultProps & propTypes from PostContext component
fabiankaegy Jun 11, 2024
397572b
remove defaultProps & propTypes from PostPrimaryCategory
fabiankaegy Jun 11, 2024
3502023
remove defaultProps & propTypes from PostPrimaryTerm component
fabiankaegy Jun 11, 2024
e2db8e1
remove defaultProps & propTypes from ContentPicker component
fabiankaegy Jun 11, 2024
06f02c3
remove defaultProps & propTypes from PickedItem Component
fabiankaegy Jun 11, 2024
9cbdfd3
remove defaultProps & propTypes from SortableList component
fabiankaegy Jun 11, 2024
fdfec62
remove defaultProps & propTypes from PostTermList component
fabiankaegy Jun 11, 2024
d6fdad1
remove no longer needed eslint ignore statements
fabiankaegy Jun 11, 2024
5ba1128
uninstall prop-types
fabiankaegy Jun 11, 2024
a1f134f
Merge pull request #326 from 10up/fix/refactor-content-search-to-reac…
fabiankaegy Jun 11, 2024
7fa9778
Merge pull request #331 from 10up/fix/remove-prop-types-dependency
fabiankaegy Jun 11, 2024
a84ce1e
fix use main ts entrypoint
fabiankaegy Jun 11, 2024
3bff905
1.18.3-next.0
fabiankaegy Jun 11, 2024
8ace3ff
1.18.3-next.1
fabiankaegy Jun 11, 2024
e7b9075
1.19.0
fabiankaegy Jun 11, 2024
ab19f17
1.19.1-next.0
fabiankaegy Jun 11, 2024
cfe1c67
prepare version to 1.19.0
fabiankaegy Jun 11, 2024
1953ba0
fix override react version needed by react-autosize-textarea peer dep…
fabiankaegy Jun 11, 2024
3aa1967
fix formatting of package.json file
fabiankaegy Jun 11, 2024
850be87
fix add clean dist
fabiankaegy Jun 12, 2024
037c181
fix example blocks
fabiankaegy Jun 12, 2024
834a7af
fix increace specificity of styles in editor for content search
fabiankaegy Jun 12, 2024
632cc77
Migrate Content Picker to TypeScript
fabiankaegy Jun 12, 2024
8f1971a
Merge pull request #332 from 10up/ts/content-picker
fabiankaegy Jun 12, 2024
515fa10
version bump
fabiankaegy Jun 12, 2024
87a622a
1.19.0-next.2
fabiankaegy Jun 12, 2024
69a08ee
migrate CustomBlockAppender to TypeScript
fabiankaegy Jun 17, 2024
f4fafec
migrate Image component to TypeScript
fabiankaegy Jun 17, 2024
0d6a7fc
migrate Link component to TypeScript
fabiankaegy Jun 17, 2024
f467e1d
fix refine type setup
fabiankaegy Jun 18, 2024
691dabc
fix remove includes
fabiankaegy Jun 18, 2024
4215904
fix tsconfig output declaration files
fabiankaegy Jun 18, 2024
93de3b0
add output dir to tsconfig
fabiankaegy Jun 18, 2024
7a1cf20
fix use relative export
fabiankaegy Jun 18, 2024
3c2e581
migrate RichTextCharaterLimit to TypeScript
fabiankaegy Jun 18, 2024
3934d98
Merge pull request #333 from 10up/fix/update-custom-block-appender-to-ts
fabiankaegy Jun 18, 2024
feee8df
fix remainding components
fabiankaegy Jun 18, 2024
2e9a898
1.19.0-next.3
fabiankaegy Jun 18, 2024
e8e0099
1.19.0-next.4
fabiankaegy Jun 18, 2024
4a40d5a
try tsconfig changes
fabiankaegy Jun 18, 2024
a75b67b
1.19.0-next.5
fabiankaegy Jun 18, 2024
e311115
try tsconfig
fabiankaegy Jun 18, 2024
ac35f96
1.19.0-next.6
fabiankaegy Jun 18, 2024
3ecc8ac
Update media toolbar component
Firestorm980 Jun 24, 2024
8a164d1
Add example with custom media toolbar labels
Firestorm980 Jun 24, 2024
2510b9d
Update readme
Firestorm980 Jun 24, 2024
aa6e141
Fix for default labels
Firestorm980 Jun 25, 2024
7a6a6ea
Merge pull request #334 from 10up/feature/mediatoolbar-custom-labels
fabiankaegy Jun 25, 2024
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
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
example
cypress
**/*.test.js
**/*.test.js
**/*.test.ts
**/*.test.txs
dist/
cypress.config.js
20 changes: 12 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"extends": ["@10up/eslint-config/react"],
"rules": {
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"react/jsx-props-no-spreading": 0,
"jsdoc/check-tag-names": 0,
"import/extensions": 0
}
"parser": "@typescript-eslint/parser",
"extends": [
"@10up/eslint-config/react"
],
"rules": {
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"react/jsx-props-no-spreading": 0,
"jsdoc/check-tag-names": 0,
"import/extensions": 0,
"react/prop-types": 0
}
}
6 changes: 3 additions & 3 deletions .github/workflows/compressed-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.2.0
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x
- uses: preactjs/compressed-size-action@v2
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Run Cypress E2E Tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: reviewdog/[email protected]
with:
github_token: ${{secrets.GITHUB_TOKEN}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-next-npm-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install all npm packages
run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-npm-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
if: github.ref == 'refs/heads/trunk'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-testing-npm-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
environment: testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install NPM Dependencies
run: npm ci
- name: Run Unit Tests
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
20
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
/* eslint-disable react/prop-types */
/* eslint-disable react/jsx-props-no-spreading */

import { addFilter } from '@wordpress/hooks';
import { createHigherOrderComponent } from '@wordpress/compose';
import classnames from 'classnames';
import { FC } from 'react';

interface BlockEditProps {
name: string;
isSelected: boolean;
attributes: Record<string, any>;
setAttributes: (attributes: Record<string, any>) => void;
className: string;
style: Record<string, any>;
wrapperProps: {
[key: string]: any;
};
[key: string]: unknown;
}

interface BlockOptionOptions {
attributes: Record<string, any>;
classNameGenerator: (attributes: Record<string, unknown>) => string;
inlineStyleGenerator: (attributes: Record<string, unknown>) => Record<string, any>;
Edit: FC<BlockEditProps>;
extensionName: string;
order?: 'before' | 'after';
}

/**
* registerBlockExtension
*
* A helper function that allows you to add custom settings to any block.
* Under the hood it filters the blocks registerBlockType, BlockEdit, BlockListBlock
* and getSaveContent.extraProps filters.
*
* @typedef BlockOptionOptions
* @property {object} attributes object for new attributes that should get added to the block
* @property {Function} classNameGenerator function that gets passed the attributes and should return a string for the classname
* @property {Function} inlineStyleGenerator function that gets passed the attributes and should return an object for the inline styles
* @property {Function} Edit block edit extension function. Will only get rendered when the block is selected
* @property {string} extensionName unique identifier used for the name of the addFilter calls
* @property {string} order the order where the extension should be rendered. Can be 'before' or 'after'. Defaults to 'after'
*
* @param {string|string[]} blockName name of the block or array of block names
* @param {BlockOptionOptions} options configuration options
*/
function registerBlockExtension(
blockName,
{ attributes, classNameGenerator, inlineStyleGenerator, Edit, extensionName, order = 'after' },
) {
blockName: string | string[],
{
attributes,
classNameGenerator,
inlineStyleGenerator,
Edit,
extensionName,
order = 'after',
}: BlockOptionOptions,
): void {
const isMultiBlock = Array.isArray(blockName);

/**
* shouldApplyBlockExtension
*
* @param {string} blockType name of the block
* @returns {boolean} true if the block is the one we want to add the extension to
*/
const shouldApplyBlockExtension = (blockType) => {
const shouldApplyBlockExtension = (blockType: string): boolean => {
if (blockName === '*') {
return true;
}
Expand All @@ -48,20 +51,11 @@ function registerBlockExtension(

const blockNamespace = isMultiBlock ? blockName.join('-') : blockName;

/**
* addAttributesToBlock
*
* @param {object} settings block settings
* @param {string} name block name
* @returns {Array}
*/
const addAttributesToBlock = (settings, name) => {
// return early from the block modification
const addAttributesToBlock = (settings: Record<string, any>, name: string) => {
if (!shouldApplyBlockExtension(name)) {
return settings;
}

// modify block registration object
return {
...settings,
attributes: {
Expand All @@ -77,21 +71,16 @@ function registerBlockExtension(
addAttributesToBlock,
);

/**
* addSettingsToBlock
*/
const addSettingsToBlock = createHigherOrderComponent((BlockEdit) => {
return (props) => {
const addSettingsToBlock = createHigherOrderComponent((BlockEdit: FC<any>) => {
return (props: any) => {
const { name, isSelected } = props;

// return early from the block modification
if (!shouldApplyBlockExtension(name)) {
return <BlockEdit {...props} />;
}

const shouldRenderBefore = order === 'before' && isSelected;
const shouldRenderAfter = order === 'after' && isSelected;

const shouldRenderFallback = !shouldRenderBefore && !shouldRenderAfter && isSelected;

return (
Expand All @@ -111,14 +100,10 @@ function registerBlockExtension(
addSettingsToBlock,
);

/**
* addAdditionalPropertiesInEditor
*/
const addAdditionalPropertiesInEditor = createHigherOrderComponent((BlockList) => {
return (props) => {
const { name, attributes, className, style, wrapperProps } = props;
const addAdditionalPropertiesInEditor = createHigherOrderComponent((BlockList: FC<any>) => {
return (props: BlockEditProps) => {
const { name, attributes, className = '', style = {}, wrapperProps } = props;

// return early from the block modification
if (!shouldApplyBlockExtension(name)) {
return <BlockList {...props} />;
}
Expand Down Expand Up @@ -153,18 +138,13 @@ function registerBlockExtension(
addAdditionalPropertiesInEditor,
);

/**
* addAdditionalPropertiesToSavedMarkup
*
* @param {object} props block props
* @param {object} block block object
* @param {object} attributes block attributes
* @returns {object}
*/
const addAdditionalPropertiesToSavedMarkup = (props, block, attributes) => {
const addAdditionalPropertiesToSavedMarkup = (
props: BlockEditProps,
block: { name: string },
attributes: Record<string, any>,
) => {
const { className, style } = props;

// return early from the block modification
if (!shouldApplyBlockExtension(block.name)) {
return props;
}
Expand Down
3 changes: 2 additions & 1 deletion api/register-icons/index.js → api/register-icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { dispatch } from '@wordpress/data';
import domReady from '@wordpress/dom-ready';

import { iconStore } from '../../stores';
import { IconSet } from '../../stores/icons/types';

export function registerIcons(options) {
export function registerIcons(options: IconSet) {
domReady(() => {
dispatch(iconStore).registerIconSet(options);
});
Expand Down
3 changes: 0 additions & 3 deletions components/author/context.js

This file was deleted.

35 changes: 35 additions & 0 deletions components/author/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createContext, useContext } from '@wordpress/element';

export type Author = {
avatar_urls: Record<string, string>;
description: string;
email: string;
first_name: string;
id: number;
last_name: string;
link: string;
name: string;
nickname: string;
registered_date: string;
slug: string;
url: string;
};

export const AuthorContext = createContext<Author>({
avatar_urls: {},
description: '',
email: '',
first_name: '',
id: 0,
last_name: '',
link: '',
name: '',
nickname: '',
registered_date: '',
slug: '',
url: '',
});

export const useAuthor = () => {
return useContext(AuthorContext);
};
Loading
Loading