- Issue created by @Mortarion
- 🇮🇩Indonesia gausarts
Thank you.
It is fine at D9 with CKEditor5 and 4.
But I did notice it broken at D10 somehow.What is your Drupal version?
-
gausarts →
committed e3ecf23d on 8.x-2.x
Issue #3427632 by Mortarion: Shortcode compatibility with CKeditor5
-
gausarts →
committed e3ecf23d on 8.x-2.x
- Status changed to Fixed
8 months ago 2:05pm 14 March 2024 - 🇮🇩Indonesia gausarts
You are correct.
D10 looks like more stricter in terms of broken HTML tags, even though I put the HTML corrector at the end of the process, or in between.
If any trouble, please revert your shortcode HTML to the recommended per line, not like your OP with "single-line", so that we still stick to the original convention to avoid editing every single node.Please also see the attachment for working sample or filter orderings.
Ideally the fix was moved to into
\Drupal\blazy\Plugin\Filter\Shortcode::replace()
method.This will do for now till we sort this out any better, and or anyone beat me to it.
Feel free to re-open if still an issue, and or any betterment on this.
Thank you for contribution.
- 🇩🇪Germany Mortarion
Thank you for the code. It didn't worked at the first try and I needed to make some adjustments. So I want to share the changed code with you. I placed inline comments as explanation.
// Might not be available with self-closing [TAG data="BLAH" /]. if (stristr($string, "[$item") !== FALSE) { $string = self::process($string, $item); // @todo remove into self::replace(). // Replacing "<p><$item " alone is not enough, since the shortcodes can be empty. Replace them first $string = str_replace("<p><$item>", "<$item>", $string); $string = str_replace("<p><$item ", "<$item ", $string); $string = str_replace("<p><$item>\n", "<$item>", $string); // Replacing "</$item></p>\n" would mean, that the line break is necessary, but it isn't? It would lead to orphaned tags not properly replaced $string = str_replace("</$item></p>", "</$item>", $string); } $text = self::process($string, $container); // @todo remove into self::replace(). // Comments above apply here, too. $text = str_replace("<p><$container>", "<$container>", $text); $text = str_replace("<p><$container ", "<$container ", $text); $text = str_replace("<p><$container>\n", "<$container>\n", $text); $text = str_replace("</$container></p>", "</$container>", $text); return $text;
Free for discussion
- Status changed to Active
8 months ago 3:15pm 14 March 2024 - 🇮🇩Indonesia gausarts
Makes sense, thank you.
The previous solutions were based on the instructed convention with line breaks.
However expanding use cases like yours is obviously more versatile and a lot better.
If you'd like to patch it, that would be great.
- Status changed to Needs review
8 months ago 3:52pm 14 March 2024 - last update
8 months ago Patch Failed to Apply - 🇮🇩Indonesia gausarts
@Mortarion, you may want to git pull the latest DEV release before creating patches.
Otherwise that would conflict the latest code base. But no biggies for now.OOT, looks like my Drupal permissions were changed.
I can no longer choose Author column to give credit to as seen in the screenshot which is a bit weird since I am the maintainer who should give you credits:
https://www.drupal.org/files/issues/2024-03-16/drupal-author-credit.png →
vs.
https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett... → -
gausarts →
committed b91edbe3 on 8.x-2.x
Issue #3427632 by Mortarion: Shortcode compatibility with CKeditor5
-
gausarts →
committed b91edbe3 on 8.x-2.x
- Status changed to Fixed
8 months ago 10:32am 16 March 2024 - 🇩🇪Germany Mortarion
@gausarts, thank you for your suggestion. I will do it as recommended the next time.
At first I wanted to create an issue fork on drupalcode to create a respective merge request. That would have been easier, but I wasn't able to choose the correct namespace, so I stopped that attempt and instead used the patch that applies on my local machine.
Automatically closed - issue fixed for 2 weeks with no activity.