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

Fix registerFormatType type #62771

Closed

Conversation

mikeybinns
Copy link
Contributor

@mikeybinns mikeybinns commented Jun 23, 2024

What?

Fixing the type of the registerFormatType function which is currently incorrect due to JSDoc types.

Why?

Currently this function throws a type error if you don't specify the name parameter in the settings parameter, which is incorrect because the name is provided as the first argument.

How?

I have converted the registerFormatType file, the Redux store files and all related test files to TypeScript.
I converted the WPFormat JSDoc type to a TypeScript type and moved it into the ./types file.
I updated the name to be RichTextFormatFull instead of WPFormat. This should really be RichTextFormat however I didn't want to conflict with the JSDoc type of the same name so I've used this temporary name for now, and I've exported it as RichTextFormat as the old type wasn't exported.
I also added some missing / undocumented properties to the RichTextFormatFull and changed the interactive prop to optional.
I have avoided changing the base JS as much as possible to make sure this is only a types improvement, however there's a few minor places where I had to change some JS things, however all tests should still pass, and they are only minor changes which shouldn't affect functionality.

Testing Instructions

Note: these changes are all covered by existing automated tests, but here's how to test manually.

  1. Create a new TypeScript file, import registerFormatType from the public package version.
  2. Register a new format using valid settings, leaving name out of the settings argument.
  3. Note the Error Typescript is now throwing.
  4. Now import the registerFormatType from this PR change and note how the type error is now fixed, and allows a couple new properties such as attributes.

Screenshots or screencast

image

Copy link

github-actions bot commented Jun 23, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @gutenbergplugin.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: gutenbergplugin.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: jffng <jffng@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: costasovo <costasovo@git.wordpress.org>
Co-authored-by: amitraj2203 <amitraj2203@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>
Co-authored-by: airman5573 <rpf5573@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: roygbyte <roygbyte@git.wordpress.org>
Co-authored-by: stokesman <presstoke@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: shail-mehta <shailu25@git.wordpress.org>
Co-authored-by: creativecoder <grantmkin@git.wordpress.org>
Co-authored-by: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
Co-authored-by: mikachan <mikachan@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: bogiii <bogdannikolic@git.wordpress.org>
Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: dhananjaykuber <dhananjaykuber@git.wordpress.org>
Co-authored-by: fluiddot <carlosgprim@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
Co-authored-by: mikeybinns <mikeybinns@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@akasunil akasunil added [Package] Rich text /packages/rich-text [Type] Bug An existing feature does not function as intended labels Jun 23, 2024
@mikeybinns
Copy link
Contributor Author

I've investigated those failed tests, but they seem to be unrelated to my PR, though it's possible I'm missing something. If it's something I can fix, I'd appreciate some advice on how to proceed.

oandregal and others added 18 commits June 26, 2024 16:55
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
)

An escape keypress previously toggled the state between editing and select mode. This returns the behavior to the previous implementation of Escape clearing block focus and returning focus to the wrapping region, if available, showing a blue outline. If no region is available, it will focus the editor iframe or content region.
* CustomSelectControl V2: fix trigger text alignment in RTL languages

* CHANGELOG

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: jffng <jffng@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
…rdPress#62896)

* Remove the const `TOOLSPANEL_DROPDOWNMENU_PROPS` in favour of a hook that returns different popover props depending on the viewport width

* Remove offset completely

* Add to block support panels

* Replace in block library.

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
…ess#62894)

Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
…S is generated (WordPress#62768)

* Render styles after the variation style overrides have been saved to stage.
Getting closer. But the overrides in state need to be merged with incoming revision styles.

* For every current override, update the variation CSS with the incoming config from the revision.

* Rename hook
Destructure in hook so the consumer doesn't have to clone
Only send the override overrides to EditorStyles that need to be overridden.

* Fetching overrides in the hook

* Feedback suggestions from review:
add overrides to dep array in Editor Styles
rename hook

* Return getBlockStyles from the useSelect callback

* Refactor so we don't have to change the EditorStyles props
Register revision overrides with useStyleOverride

* Adding some explanatory comments
Add rudimentary E2E test covering block style partials, applying them, updating them and viewing styles revisions.

* Removed unused style fixture

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
…dPress#61871)

When a `core/group` block has only one variation available, skip the placeholder step and select the variation.

Co-authored-by: costasovo <costasovo@git.wordpress.org>
Co-authored-by: ockham <bernhard-reiter@git.wordpress.org>
* Fix issue of HTML entities rendering in command menu

* Update link to API in block-editor README.md

* Undo previous changes

* Fix issue of HTML entities rendering in command menu

* Add @wordpress/html-entities dependency in packages/core-commands
…#62844)

* Add minimum width to select popover

* CHANGELOG

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
…es (WordPress#62828)

* Remove only supported attributes

* Try alternative approach

* Update comment

* Return early while editing the original pattern

* Move conditional inside conditional

* Add missing check

* Go back to running always bindings

* Use block context to detect presence of parent pattern for overrides (WordPress#62861)

* Use block context to detect presence of parent pattern

* Regenerate fixtures

* Update image block to use context for checking a parent pattern block exists

* Rename context to `pattern/overrides` to be consistent with php code

* Move pattern overrides context shim to pattern overrides hooks

* Remove shim

Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>

* Reduce diff

* Change array order

---------

Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
…#62912)

- Change 'color' to 'colors' in destructured parameter of example code
- Update ensures the example code accurately demonstrates correct usage

Co-authored-by: byeongin <byeongin@shoplic.kr>

Unlinked contributors: byeongin@shoplic.kr.
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
@mikeybinns
Copy link
Contributor Author

Argh! sorry, was just trying to update my branch to the latest trunk version and it's messed up the PR, I will sort this or recreate the PR if needed.

@mikeybinns
Copy link
Contributor Author

Okay, after carefully considering some different options, I think while it's possible I could fix the branch in Git, I think GitHub has now subscribed a lot of people to this PR automatically, so to avoid annoying those people with updates to a PR they didn't subscribe to, I'm going to close this PR and open a new one. Sorry again.

@mikeybinns mikeybinns closed this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment