Gutenberg: How to create a custom inline-block?

Created on 28 Sep 2018  路  14Comments  路  Source: WordPress/gutenberg

Is there any guide on creating custom inline blocks?

[Package] Format library [Package] Rich text [Type] Documentation

Most helpful comment

This seems to be how the Inline Image is created now https://github.com/WordPress/gutenberg/blob/master/packages/format-library/src/image/index.js

Specifically I can see how they have used insertObject to add an img tag. It's not documented anywhere though.

What I am puzzled about is how to use insertObject with html inside (child tags). Not sure if that is possible.

All 14 comments

I have the same question. I'd like to create an inline image that works with an existing lightbox plugin I have (basically an <img> wrapped by an <a> tag).

Does anybody find help about this question ?
I would like to create inline block to had span element with custom class...

I have the same question.

FYI @ronalfy : You shouldn't be setting state directly outside of the constructor.

https://github.com/ronalfy/metronet-tag-manager/blob/gutenberg/src/js/gutenberg/main.js#L180

@dsifford thanks for the heads up. I overlooked that.

No prob.. Great example use-case nevertheless!

This seems to be how the Inline Image is created now https://github.com/WordPress/gutenberg/blob/master/packages/format-library/src/image/index.js

Specifically I can see how they have used insertObject to add an img tag. It's not documented anywhere though.

What I am puzzled about is how to use insertObject with html inside (child tags). Not sure if that is possible.

Is there is a solution for this?
Some plugins use to have buttons to add shortcodes inside editor. How are these plugins handle in gutenberg inserting custom inline block with a shortcode?

I am also using Gutenberg formats (https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/format-api/3-apply-format/) for inline/formatting stuff.

I believe this is covered by the Format API tutorial shared above.

@nosolosw format API does not provide a way to create inline blocks inside a block. Not sure why this issue is closes

@BenBroide you're right - was confused what this issue was about.

What I am puzzled about is how to use insertObject with html inside (child tags). Not sure if that is possible.

Has anyone tried implementing child tags yet? I can't seem to find a way to do it. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ellatrix picture ellatrix  路  3Comments

spocke picture spocke  路  3Comments

maddisondesigns picture maddisondesigns  路  3Comments

jasmussen picture jasmussen  路  3Comments

mhenrylucero picture mhenrylucero  路  3Comments