-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Validation: Log debugging messages for invalid blocks #3522
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3522 +/- ##
==========================================
+ Coverage 35.15% 35.29% +0.13%
==========================================
Files 267 267
Lines 6724 6744 +20
Branches 1218 1221 +3
==========================================
+ Hits 2364 2380 +16
- Misses 3683 3687 +4
Partials 677 677
Continue to review full report at Codecov.
|
0749426
to
cd212c1
Compare
I enabled logging for all environs which, with global test console assertions, helped identify many legitimate issues both in parser testing, and in the block fixtures. Those have been fixed here. All-environment logging should be helpful for plugin usage to report issues to the original block implementer. |
@aduth where can I read more about the validation API? One of the demo tweet blocks I had built it now renders corrupted. With this log message Whereas I have myself changed the href in Code present here. Looking forward! |
@ahmadawais Validation works by comparing what would be saved when running Looking at the code example, I see you're expecting to find a This is an interesting use-case, since you want access to a string representation of the rich text content to be able to encode in a tweet URL. I might imagine depending on the direction we go with #3048 that we'd want some way to convert from a children value to a string (cc @iseulde, @gziolo). |
@aduth just returning back from vacations and was out of all the Gutenberg dev but want to know if there has been any development in this particular aspect? Any pointers that you have for me to go and read about. As I am sure there's a possibility of having different edit and save interfaces since the saved interface should be clickable whereas Looking forward! |
@ahmadawais Is there any reason the Tweetable text needs to be "rich text" in your case (i.e. supporting italics, bold, etc)? Thinking it might make more sense as plain text, especially since you can't tweet the rich text anyways. In which case you could use a simple text input instead of content: {
type: 'string',
source: 'text',
selector: 'a',
}, |
@aduth No not at all. I was actually trying to make it work without any of that, didn't spend a lot of time on it, but didn't get around producing an editable text block that's not rich text. How does one do that? Also, my guess is that validation won't apply on a case like this with simple text block? I just need the user to write the Tweet's content. |
Instead of https://reactjs.org/docs/forms.html#controlled-components
Not entirely clear what you mean here, but with the plain text input value, it is easy enough to |
@aduth @iseulde I've seen this conundrum with people a few times, where they want the display of editable (no borders, consistent font-size, etc) but don't care about rich text. What about adding a mode to Editable via prop to get plain text (would render just a textarea with not tinymce) instead of styling inputs? |
Another benefit to this is that if people are accustomed to working with Editable, they'd be inclined to use it for all text fields, and at least if we provide them the option to configure it for plain text, it would be fine enough to use. The downside is that |
Closes #2837
This pull request seeks to add logging to the block validator to emit messages when an invalid block is encountered in a development environment.
Testing instructions:
Modify
post-content.js
, removing, adding, or changing attributes or content which would cause a block to become invalid (i.e. serialize differently on the next load).Load the editor and verify that debugging messages are logged in your Developer Tools console.