- Issue created by @DamienMcKenna
- Assigned to DamienMcKenna
- πΊπΈUnited States DamienMcKenna NH, USA
From β¨ Add a CKEditor5 plugin for Drupal 9.3+, Drupal 10 Needs work :
Official Drupal documentation for building a plugin:
https://www.drupal.org/docs/drupal-apis/ckeditor-5-api/overview βOfficial Drupal docs for rewriting a plugin:
https://www.drupal.org/docs/core-modules-and-themes/core-modules/ckedito... βOfficial CKEditor documentation for rewriting a plugin:
https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/...Example module:
https://www.drupal.org/project/ckeditor5_dev βBlog posts on the topic:
https://evolvingweb.com/blog/porting-ckeditor-5-plugin-drupal-10
https://tech.axelerant.com/create-and-integrate-ckeditor-5-plugin-with-d... - Status changed to Needs review
about 1 year ago 9:34pm 25 September 2023 - Status changed to Needs work
about 1 year ago 9:36pm 25 September 2023 - πΊπΈUnited States DamienMcKenna NH, USA
The plugin shows up, can be added, but it doesn't work yet. And #3388923 hasn't been done yet.
- πΊπΈUnited States DamienMcKenna NH, USA
- πΊπΈUnited States DamienMcKenna NH, USA
This corrects the toolbar icon.
- πΊπΈUnited States DamienMcKenna NH, USA
Trying to use the HTML tag "drupal-spoiler" in CKEditor.
- πΊπΈUnited States DamienMcKenna NH, USA
Correction - drupalspoiler not drupal-spoiler.
- πΊπΈUnited States luke.leber Pennsylvania
Some food for thought -- definitely not perfect, but it "techincally" seems to work :-).
The main changes were to the `spoilerediting.js` and `insertspoilercommand.js` files. I'm registering three new models with the schema: `drupalspoiler`, `drupalspoiler_warning`, and `drupalspoiler_content`. The upcast / downcast transform these models back and forth from
<span class="spoiler"> <span class="spoiler-warning">Arbitrary Text Here</span> <span class="spoiler-content">Arbitrary Text Here</span> </span>
- πΊπΈUnited States DamienMcKenna NH, USA
Thank you ever so much!
Just to explain my goal - I basically want this to be like a B, STRONG, I or EM tag that just wraps the text so that it can be inline; it'll use CSS to modify how it looks on the page, but at the ckeditor level there shouldn't be any additional customization.
So the patch is a huge improvement in that it will make the plugin actually work, but I just want it to be like this:
Original text:
<p>Something really funny.</p>
I want to be able to select the words "really funny", click the Spoiler toolbar button and have it wrap the text in the spoiler logic.
Output:
<p>Something <span class="spoiler">really funny</span>.</p>
Model:
<p>Something <drupalspoiler>really funny</drupalspoiler.</p>
If it'd be simpler to do, the extra drupalspoiler layer could be ditched and just use
<span class="spoiler>really funny</span>
on both ends. - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
In Drupal Slack, @Luke.Leber recommended starting from https://ckeditor.com/docs/ckeditor5/latest/tutorials/widgets/implementin.... Seconding that.
And in addition to that: I'd also look at/compare with the
language.TextPartLanguage
pluginβs code, because:ckeditor5_language: ckeditor5: plugins: [language.TextPartLanguage] drupal: β¦ elements: - <span lang dir>
π that can take the selected text and wrap it in
<span lang>
, which is close to what you want!P.S.: It is conceivable somebody has been using
<span class="spoiler">
already. For that reason, if you were to get rid of the<drupalspoiler>
representation, I'd not go for<span class="spoiler">
but<span spoiler>
, to avoid that potential conflict. This module has a corresponding filter anyway, so it'd be trivial to transform it at that point into whatever markup you like :) However, I suspect you're trying to get rid of the filter, and so immediately dataDowncasting to<span class="spoiler">
seems fine too, and would allow you to just close β¨ Provide CKEditor 5-compatible filter Active π