Presented at the JavaScript for WordPress Conference, July 2019.
The following are the resources mentioned in the slides, some code “landmarks” to walk through for getting to know the underlying process.
For saving block data…
- gutenberg/packages/blocks/src/api/serializer.js
serializeBlock
given a block, return a string of content (runs save)
- gutenberg/packages/element/src/serialize.js
renderToString
given the result of save, convert this to a string
And for parsing out data from the saved content…
- gutenberg/packages/blocks/src/api/parser.js
getBlockAttribute
parses an attribute out of the block content, based on the attributes configuration
hpq
parser library: https://aduth.github.io/hpq/
The “future” discussions I mentioned about custom sources:
- “Custom Block Attribute Sources” issue, #16282. Sets out the reasoning behind custom sources, and a potential API/schema for how to create these.
- Using a custom source for meta, #16402. Switches from special handling for meta to creating a custom source. Still not usable by plugin devs, but shows a possible API for this.