-
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
Add Inline Images and Inline Blocks API #6959
Conversation
edit-post/index.js
Outdated
@@ -67,6 +68,7 @@ export function initializeEditor( id, post, settings ) { | |||
const reboot = reinitializeEditor.bind( null, target, settings ); | |||
|
|||
registerCoreBlocks(); | |||
registerCoreInlineBlocks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about grouping with RichText
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved some stuff around. Still polishing.
12b8c87
to
3897c89
Compare
|
||
category: 'inline', | ||
|
||
edit( { onSave } ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -54,13 +54,9 @@ class Slot extends Component { | |||
|
|||
const fills = map( getFills( name ), ( fill ) => { | |||
const fillKey = fill.occurrence; | |||
const fillChildren = isFunction( fill.props.children ) ? fill.props.children( fillProps ) : fill.props.children; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change to allow null
values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I follow the purpose of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this in 👍
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
RichText
component.RichText
field has focus.How has this been tested?
Place the caret in a
RichText
area. 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: