Add Inline Images and Inline Blocks API#6959
Conversation
edit-post/index.js
Outdated
There was a problem hiding this comment.
I think we should just move these blocks in the core-block folder, even though the API would be slightly different.
There was a problem hiding this comment.
What about grouping with RichText?
There was a problem hiding this comment.
Actually I was thinking of removing this separate folder and putting it in core-blocks, so it would all be registered together. These would have inline as the category. How does that sound?
There was a problem hiding this comment.
Mmm, not sure we should group these with blocks as they are different entities. To me, they are more like utilities for RichText, which is in turn a component.
There was a problem hiding this comment.
I moved some stuff around. Still polishing.
12b8c87 to
3897c89
Compare
|
|
||
| category: 'inline', | ||
|
|
||
| edit( { onSave } ) { |
There was a problem hiding this comment.
I like how you added edit and save functions to provide an interface similar to regular blocks. I wonder if it will be possible to have the edit toolbar in #5794 (comment) be part of this edit function as well? Not sure if this is possible though, since I think the React element returned from the save function will be rendered to string before using the edit toolbar.
There was a problem hiding this comment.
Probably will have to be some different method. We can name these differently based on what it's for. Maybe insert, edit/select, and save or similar.
| /> | ||
| } | ||
| { type && | ||
| <type.edit onSave={ this.onSave( type ) } /> |
There was a problem hiding this comment.
Nice how you moved the Media Library logic out of this component by defining an edit function for inline blocks and moving the MediaUpload component to the edit function of the inline image.
|
Cool how you have inline blocks working with the new Inserter design! Just noting there was previous discussion in #5794 (comment) about how at this point we may want to also show regular blocks in the menu at the same time, and there is a new mockup that is being discussed in #6998 (comment) for this. CC @jasmussen |
073a661 to
795f82b
Compare
795f82b to
c93b778
Compare
4bb9ee5 to
8c1b8ec
Compare
|
@jasmussen Question: if we show both inline and block items in the inserter at the same time, how doe we show insertion points? |
|
Should we do it again on hover as it used to be? |
8c1b8ec to
6fdfc20
Compare
7527cb2 to
316104a
Compare
components/slot-fill/slot.js
Outdated
There was a problem hiding this comment.
I made this change to allow null values.
There was a problem hiding this comment.
We're changing existing functionality, though, right? We're no longer injecting fillKey in "regular" cases (function-as-child).
There was a problem hiding this comment.
I don't think I follow the purpose of this change.
There was a problem hiding this comment.
How so? There's still a key added. This change is needed because you can't return null when using the function. See https://github.com/WordPress/gutenberg/pull/6959/files#diff-8c9cd11f122f43914bc769f4ad5c36d9R21.
316104a to
ea92dea
Compare
0fabb77 to
0054f04
Compare
102e17f to
ebc5d75
Compare
|
@mcsf did you supply username, password, and/or base URL if it's different? |
|
So the problem seems to appear at |
No, as my local test site is the one set up by default by our scripts. |
|
So my tests pass locally headless and with-head. Travis only has this error with the media modal, unsure what's causing it. The first time selecting in the media modal works, the second time it does not. |
12cf0ed to
ebc5d75
Compare
|
Yay |
|
H O L Y G U A C A M O L E 🎉 |
|
@iseulde thanks! :) |
| await page.click( '.media-modal button.media-button-select' ); | ||
|
|
||
| // Check the content. | ||
| const regex = new RegExp( '<!-- wp:paragraph -->\\s*<p>a\\u00A0<img class="wp-image-\\d+" style="width:10px" src="[^"]+\\/' + filename + '\\.png" alt="" \\/><\\/p>\\s*<!-- \\/wp:paragraph -->' ); |
There was a problem hiding this comment.
Do we really expect the \u00A0 character here? Why not just a plain space?
|
Is there a way I can de-register inline blocks? It is not apparent from the code to me. I would like to have the ability to switch off the inline images block. I can use unregisterBlockType for blocks, but not for components and inline image. |
|
Where is the developer documentation reference for inline blocks? |
|
@hegerpkd any updates on documentation ? I would really like to know how to register my custom inline block (token). I had some luck with registerToken function but without documentation it's useless. |
|
@tomislavp83 comments on closed pull requests sometimes won't get seen easily. Would you mind opening a new issue for that? |
Description
This PR builds on #5794. Fixes #2043.
Summary, comparison to previous PR:
RichTextcomponent.RichTextfield has focus.How has this been tested?
Place the caret in a
RichTextarea. Open the inserter. "Inline image" should appear under "Inline blocks". On click the media modal opens. Select an image, and it should be inserted in the input field.Checklist: