kirby
kirby copied to clipboard
Change block type: remove HTML tags
If I change the block type in the block editor, e.g. from "Text" to "Heading", the <p>
tag is retained:
<h1><p>I used to be a text block</p></h1>
If the block type is created directly as a heading, the formatting is correct.
[Tested with Kirby 4.1]
I can reproduce the issue but I have no idea how we can fix the issue. May be we need callbacks for the each types, not sure.
I don't think it will feasible to add callbacks/methods for the conversion. Just too many options also with custom blocks. Ideally, the old content would be handed over to the new block type (as is happening now) but then the writer-based blocks would update the content once more from what the writer input output should be (as e.g. the heading writer input should probably strip paragraph tags). But no good idea yet how to make this happen.
@distantnative It seems that the convert operation is generic. It's an automated process according to the block blueprints. It cannot be specific operation for any type.
https://github.com/getkirby/kirby/blob/4.2.0/panel/src/components/Forms/Blocks/Blocks.vue#L274-L326
We cannot process data in block type views. Because they are only triggered by input (@input
), not by a type change. When the type changes, the block data is automatically changed and saved.
I couldn't find a solution yet either.