Skip to content

Instantly share code, notes, and snippets.

View 0verscore's full-sized avatar
🏃‍♂️
Keep on running

Sebastian Buchwald 0verscore

🏃‍♂️
Keep on running
  • Lead Developer @ conversionmedia GmbH & Co. KG
  • Germany, NRW, Dinslaken
View GitHub Profile
@0verscore
0verscore / save-workflow.md
Last active May 27, 2023 15:40
WP / Gutenberg - Change Block Attributes before they got saved in serialized html comments

Description

I am currently working on a 3rd party style system, that basically works on the new gutenberg style engine.

A cornerstone of this system is that I need to filter the block attributes for the HTML comment attribute rendering process. I have searched in the /packages/blocks/src/api/serializer.js for an applyFilters hook that I can use, but to no avail.

The basis for my style management is a datastore called "my/store". It provides additional operations for handling style attributes and a backup system, which you will read about below. Its stored objects are clientId-based, so don't wonder why there are clientIds in the store method.

Solution

I first filter the save block process as usually.