Additional field for all default blocks

I’m wondering if there is a more convenient way, to add the same new field to all existing blocks. The background is: I need to provide a flag for each block, that the user can toggle on or off.

So I was trying to extend the fieldsets list like this (here as an example with the heading block):

fields:
  pagecontent:
    label: Seiteninhalt
    type: layout
    fieldsets:
      - type: heading
        extends: blocks/heading
        fields:
          flagged:
            label: Markiert
            type: toggle
      - text
      - list
      - quote
      - image
      - button
      - line
      - gallery
      - table
      - video
      - code
      - markdown

Which gives the desired result in the panel:

Now I want this field to be available for text, list, quote, etc. too. So my two questions are:

  1. Is there a better way to add the same field to all blocks, like adding it to a “parent block object” or something?
  2. Is there a way to style all flagged=true blocks in the panel with CSS without touching the panel templates of each block?

Thanks in advance!

No, you would have to add it to every block. But if you need this in multiple places, not only one blueprint, I’d extend the blocks themselves in a block blueprint.

And no, if you want to style a block based on the value of a field, you would have to create custom preview Vue files

  1. I need this in two places, so yes, that’s a great idea to use block blueprints here, thanks.
  2. Ok. How would I do this? I found the docs for customizing core blocks, but unfortunately they only mention how to override the block blueprint and the block snippet (which is fairly easy). Did I miss how to override the preview file here?

Thank you for your quick answers!!

The block previews need to go into a plugin, just like for a custom block type: Blocks | Kirby CMS

Awesome, thank you Sonja! I didn’t know that at this point, a plugin was required. Thanks for making that clear. That solved it for me.