carlcs / craft-footnote

Footnote plugin for Craft CMS
MIT License
14 stars 4 forks source link

How to use it with CKEditor #9

Closed franck-thorck closed 1 month ago

franck-thorck commented 1 month ago

Hi,

I migrated a project from Craft CMS 4 to 5, and before to upgrade to version 5, I migrated all my redactor fields and configs into CKEditor fields and config.

I already had the Footnote plugin with Redactor and everything worked fine, and now with CKEditor I'm not able to enable the plugin and config in CKEditor config. When I add this following code in my CKEditor config in Craft CMS, the footnote toolbar item not display.

"footnote": { "footnoteAddAfter": "lists" },

carlcs commented 1 month ago

Hello, did you get it to work?

franck-thorck commented 1 month ago

Not to 100% I understand that I needed to add it to the toolbar directly in the config in Craft CMS for CKEditor. So now I have the button in the toolbar, but I'm not able to display it correctly on frontend.

The old code was only: {{ entry.publicationContenu|parseFootnoteMarkers }}

When I checked the documentation I saw that the entry or the block need to have a field for footernotes right ?

carlcs commented 1 month ago

You have to provide your actual footnotes before you can parse text for markers.

There’s a direct setter setFootnoteDefinitions, which works well for structured data like from a table field. Or you parse notes from a text / rich text field using parseFootnoteDefinitions. You then have to make sure you configure the expected syntax in a footnotes.php config file.

franck-thorck commented 1 month ago

Everything is good but I have this error:

carlcs\footnote\services\Footnotes::parseMarkers(): Argument #1 ($str) must be of type string, null given, called in

franck-thorck commented 1 month ago

Finally fix it the CKEditor field returns null if the field is empty, I set by default empty

carlcs commented 1 month ago

Ah! This is something parseMarkers() should probably take care of. I’ve taken a note and will add that in with the next update. Thanks for the feedback!