kirby icon indicating copy to clipboard operation
kirby copied to clipboard

Change block type: remove HTML tags

Open gbdesign2023 opened this issue 1 year ago • 5 comments

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]

gbdesign2023 avatar Feb 21 '24 07:02 gbdesign2023

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.

afbora avatar Mar 16 '24 08:03 afbora

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 avatar Mar 23 '24 16:03 distantnative

@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.

afbora avatar May 22 '24 11:05 afbora