Create custom blocks programmatically

Yes the block is there and works.
I want to either update the existing image block, which I was incapable.
The only thing I managed was adding blocks, like so:


Kirby::plugin('seriamlo/mh-image-block', [
  'blueprints' => [
    'blocks/mh-image' => __DIR__ . '/blueprints/blocks/mh-image.yml',
    'files/mh-image'  => __DIR__ . '/blueprints/files/mh-block-image.yml',
  ],
  'hooks' => [
    'page.update:after' => function ($newPage, $oldPage) {
      $blocks = $newPage->teaserText()->toBlocks();
      
      $mh = new Kirby\Cms\Block([
        'content' => [
          'text' => '<p>Hug them if you like. They might not appreciate it though.</p><p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum id ligula porta felis euismod semper. Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod.</p>',
        ],
        'type' => 'text',
      ]);

      $blocks = $blocks->add(new Kirby\Cms\Blocks([$mh]));

      $kirby = kirby();
      $kirby->impersonate('kirby');

      $newPage->update([
        'teaserText' => $blocks,
      ]);
    }
  ]
]);

This works fine.
Now I thought, when I am not able to update a block, and I can add blocks, I could add a custom block to include more info.

but when adding a custom block I fail.

      $mh = new Kirby\Cms\Block([
        "content" => [
          "image" => [
            "screenshot-2021-04-14-at-20.41.20.png"
          ],
          "alt" => "alttext",
          "caption" => "acse",
          "link" => ""
        ],
        "type" => "mh-image"
      ]);

This would not create that block.

I then tried to use the factory which bastian proposed:

     $blocks = Kirby\Cms\Blocks::factory([
        [
          'content' => [
            'text' => 'oo Nice heading'
          ],
          'type' => 'heading'
        ],
        [
          "content" => [
            "image" => [
              "screenshot-2021-04-14-at-20.41.20.png"
            ],
            "alt" => "alttext",
            "caption" => "acse",
            "link" => ""
          ],
          "type" => "mh-image"
        ],
        [
          'content' => [
            'text' => 'oo This is some text'
          ],
          'type' => 'text'
        ],
      ]);

Again the heading and the text are created but not my mh-image block…

Your question about layout fields and block fields I cannot answer.
I don’t fully understand what layout fields are. do you mean this: Layout | Kirby CMS
So far I have not used them and read about them the first time now.
So I guess I want to do it in a blocks field:

title: Blog Entry

columns:
  left:
    width: 1/2
    sections:
      content:
        type: fields
        fields:
          date:
            label: Date and start time of show
            type: date
            time: true
          teasertext: // <------------------
            label: Teaser Text
            type: blocks
            fieldsets:
              - heading
              - text
              - list
              - image
              - mh-image

Thanks in advance. I struggled for a whole day now and can’t figure it out ;S.
Cheers