0

I need to develop a CKEditor 5 plugin which which when a list items has class x added, it will add class y to the wrapper or element.

So basically in the model I am expecting the following:-

<paragraph htmlLiAttributes="{classes:['x']}" listType="bulleted">item 1</paragraph>

Which all I need to do before the downcast happens is to alter it to the following

<paragraph htmlAttibutes="{classes:['y']}" htmlLiAttributes="{classes:['x']}" listType="bulleted">item 1</paragraph>

I have tried to add a dispatcher on the dataDowncast to the watch for the htmlAttibutes and then check for the htmlLiAttibutes to check for the presence of class x and then add class y to the htmlAttibutes.

I have tried create a dispatcher to monitor the htmlAttibutes, but this will only get called when the attribute exists.

I also tried watch the listType attribute but then I have not been able to find out a good method of checking the existing attributes without having to loop through all the items on the data.item and adding the additional attribute.

I feel at this stage I am too late.

gordonh
  • 1
  • 1
  • I have been looking at some other examples and found that the answer to [#70888177](https://stackoverflow.com/questions/70883867/ckeditor-5-downcast-converter-for-paragraph-to-wrap-text-in-span/70888177#70888177) is more or less what I need to do. However the following ``` if (!conversionApi.consumable.consume(data.item, 'insert')) { return; } ``` never returns true so it never runs the rest of the process. I did see in some other examples that the consume() is just run and the output is never checked. – gordonh Mar 16 '23 at 00:08

0 Answers0