create-block-theme icon indicating copy to clipboard operation
create-block-theme copied to clipboard

Remove environment-specific attributes from block markup

Open mikachan opened this issue 3 years ago • 4 comments

Currently, an exported theme includes attributes such as ref and id for certain blocks, but these have no context outside of the environment where the theme was built. They can also break some blocks (a ref in a nav block that doesn't exist on a different WordPress instance will currently cause the nav block to break).

Here are the cases I can think of, but there may be more:

  • [ ] Remove ref attributes from the Navigation block
  • [ ] Remove id attributes from Image and Cover blocks
  • [ ] Remove wp-image-[id] classes from Image and Cover blocks
  • [ ] Remove category IDs from query blocks
  • [ ] Remove taxQuery attribute from query blocks
  • [x] ~Remove queryId attributes from Query block~ I don't think this needs removing, see https://github.com/WordPress/gutenberg/issues/42730#issuecomment-1428524380 for more details.

mikachan avatar Dec 15 '22 14:12 mikachan

I think this could be a gutenberg PR, since this plugin is already using the export functions, it makes sense that what gets exported is usable outside of the context where it was exported from. Do you agree @scruffian ?

MaggieCabrera avatar Dec 15 '22 14:12 MaggieCabrera

I agree!

scruffian avatar Dec 15 '22 15:12 scruffian

Makes sense! I'll replicate the issue over there.

mikachan avatar Dec 15 '22 17:12 mikachan

Already exists 😁 https://github.com/WordPress/gutenberg/issues/42730

mikachan avatar Dec 15 '22 17:12 mikachan