difficulty filtering footnotes

Created on 25 September 2023, about 1 year ago
Updated 1 July 2024, 5 months ago

Problem/Motivation

The need:
1. When content is copied from a Microsoft Word file and pasted into CKEditor5, footnote reference numbers need to continue to be present. This gives a visual reference for users to see where the site-formatted footnote reference needs to be placed.
2. Also, the footnotes content pasted in at the end of the article should have the footnote number.

Steps to reproduce

Drupal core 10.1.4 using CKEditor5 and CKEditor 5 Paste Filter with default filters set.
paste attached zipped word docx file into CKEditor body text.

For the first footnote, we are seeing:
<a href="#sdendnote1sym">&nbsp;</a>

which is stripping out the footnote number leaving a non-breaking space which should be:
<a href="#sdendnote1sym">1</a>

Proposed resolution

It may be that we just need help adding our own custom filter but we're not sure exactly what
it should look like. Any help would be appreciated.

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

1.0

Component

Miscellaneous

Created by

🇺🇸United States will_frank

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @will_frank
  • Status changed to Postponed: needs info about 1 year ago
  • 🇨🇦Canada star-szr

    Hi there, please test the behaviour without filtering enabled. What do the footnotes look like in that case?

    Also, can you give an example of what happens to the actual footnotes at the end of the document? I think the markup examples only show the link to the footnote.

  • 🇺🇸United States will_frank

    Hi @star-szr,

    Thanks for the quick response!
    I tested with the "Filter Pasted Content" unchecked.
    The result was the same during pasting. I.e. the footnote number 1 was
    removed from the a href tag. Note that if I then typed it back in while the
    editor was in source mode and toggled back and forth in and out of source
    mode the footnote number stays. The same when I save a draft of the article.
    So the problem is only during the paste operation.

    As for the actual footnotes at the end, for our purposes we aren't worried about
    them. This whole initial pasting of an article for us is just so our content editors
    can create footnotes a different way that we have created. I won't bore you with
    the details except to say that our footnotes work across multiple paragraph articles.f
    So if we could get your module to preserve that footnote number inside the a href tag
    that would be great for us.

  • 🇨🇦Canada star-szr

    If the footnote linking to 2 has a href attribute of “sdendnote2sym” and so on, then it should be possible with a filter to add back the missing number.

    If not, it may not be feasible since based on your description Word is actually removing the numbers. When “Filter Pasted Content” is unchecked this module isn’t doing anything to the pasted content.

    Untested, but you can try something like the following.

    Search expression:
    <a href="#sdendnote([0-9]+)sym">&nbsp;<\/a>

    Replacement:
    <a href="#sdendnote$1sym">$1</a>

  • Status changed to Fixed 12 months ago
  • 🇨🇦Canada star-szr

    Marking as fixed as I believe I have addressed the support request and there have been no further questions or follow-up. Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 5 months ago
Production build 0.71.5 2024