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

[RFR] rewrite RichTextInput to TypeScript #4223

Merged
merged 2 commits into from
Feb 7, 2020

Conversation

tlaziuk
Copy link
Contributor

@tlaziuk tlaziuk commented Dec 27, 2019

Hi, I found that you need help with rewriting the project to TypeScript.

I'm not sure about removing the prop-types dependency, but the TypeScript is here so IMO it is not needed anymore, leave a comment if you have opposite opinion so I'll restore it.

Instead of default values in object spread I've added defaultProps, also - the full object of props is passed to useStyles hook.

From minor things - I had to cast the styles (*Stylsheet file) object to any because apparently the object is of invalid type (eg. numeric string is used instead of number) - but changing that may be considered as a breaking change because treating the values depends on used JSS engine.

Copy link

@ThieryMichel ThieryMichel left a comment

Choose a reason for hiding this comment

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

Thanks for the great work.
Just remove the any from the stylesheet, and convert numeric string to number, and this will be all good.

packages/ra-input-rich-text/src/QuillBubbleStylesheet.ts Outdated Show resolved Hide resolved
packages/ra-input-rich-text/src/QuillSnowStylesheet.ts Outdated Show resolved Hide resolved
@tlaziuk
Copy link
Contributor Author

tlaziuk commented Jan 3, 2020

@ThieryMichel done

@fzaninotto
Copy link
Member

Thanks! I forgot to ask that you PR against the next branch rather than master. master is only for bug fixes and we want to minimize the changes of compatibility breakage there.

@tlaziuk tlaziuk changed the base branch from master to next January 16, 2020 20:07
@@ -123,20 +157,13 @@ const RichTextInput = ({
);
};

RichTextInput.propTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

need to keep the propTypes. Compile-time type validation doesn't replace runtime type checking (unfortunately). Would you mind adding these back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

]),
fullWidth: PropTypes.bool,
configureQuill: PropTypes.func,
RichTextInput.defaultProps = {
Copy link
Member

Choose a reason for hiding this comment

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

Please keep these as default values for the props instead, React is deprecating defaultProps for function components (facebook/react#16210).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -125,14 +160,6 @@ RichTextInput.propTypes = {
label: PropTypes.string,
options: PropTypes.object,
source: PropTypes.string,
toolbar: PropTypes.oneOfType([
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed that because Quill should validate it's options itself, IMO it's a good practice because leaving that breaks the composition.

@fzaninotto fzaninotto merged commit 00aab81 into marmelab:next Feb 7, 2020
@fzaninotto
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants