Created on 10 May 2023, over 1 year ago
Updated 1 July 2024, 5 months ago

Problem/Motivation

No effect at all, when pasting RichText.

Steps to reproduce

Drupal 9.5.8
PHP 8.1.14
The module installed with Composer
'Enabled' checkbox in the 'paste filter' tab of the text filter enabled.
Default settings of the module

πŸ› Bug report
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine zegmant

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

Comments & Activities

  • Issue created by @zegmant
  • πŸ‡ΊπŸ‡¦Ukraine zegmant

    Adding new filters (e.g. for

    ) -- also no effect
  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡¨πŸ‡¦Canada star-szr

    Hi, thanks for the report. We have automated tests running that show the core functionality works as expected: https://www.drupal.org/pift-ci-job/2659054 β†’

    Can you please confirm that you're pasting into the visual editor, not the source editing view? Right now that's the only thing I can think of that would cause this behaviour.

    Can you also check the JavaScript console in your browser after pasting to see if it reports any errors?

    Do you have any other CKEditor 5 modules installed?

  • πŸ‡¨πŸ‡¦Canada star-szr

    If you can also please share the browser and browser version you are using that may be helpful.

  • πŸ‡«πŸ‡·France jossensei

    Hi,
    Tested on Drupal 10, and I had the same result on Firefox.
    Another test is Chromium was a success so I think it's an issue with the way Firefox handle paste.

  • πŸ‡¨πŸ‡¦Canada star-szr

    This module was developed almost exclusively using Firefox so it should work fine there. If the same module configuration is not working consistently across browsers I would need browser version information, and specific reproduction steps so that I can see the bug happening.

    If the paste filtering is not working, please upload your exported config YAML for the text format, or screenshot your filter settings (or at least the custom parts), and provide sample text which did not have any filtering applied after pasting?

    Finally, CKEditor 5 won’t work without JavaScript enabled, but it is somewhat possible that the JS from this module is being blocked, perhaps a browser extension is interfering in Firefox in @jossensei’s case.

  • Status changed to Active over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    I can sadly also confirm this issue. Just installed the module and tested pasting some rich text from Word or Thunderbird and it's still added with style="xxx" tags, like
    <p class="MsoNormal" style="text-autospace:none;">

    I only tried in Firefox 115.0.1 (64-Bit) on Windows 11.
    The project uses Drupal 10.1.1

    Can you please confirm that you're pasting into the visual editor, not the source editing view?

    I can also confirm this.

  • Status changed to Needs work over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Okay I think I found the reason.

    const r = this.editor.config.get("pasteFilter");
    console.log(r);
    if (!r) {
        console.warn('HIT!');
        return;
    }
    

    HIT! is in the console when pasting code and console.log(r); results in false, so the cleanup is never executed.

    pasteFilter is missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Setting priority to Major as it's proven by the console output that the module doesn't have any effect currently, at least in latest FF.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • πŸ‡¨πŸ‡¦Canada star-szr

    @Anybody, can you please confirm that you configured and enabled paste filtering in your text format, similarly to what can be seen on the module's project page? A screenshot would be appreciated too. I know you were looking at the configuration form in another issue but in your reproduction steps you don't indicate that you have enabled the functionality from the text format form.

    So far, I have not been able to reproduce this bug. As mentioned we have automated tests (running on Drupal 10.1.x) that prove that the module works. The only explanation I can think of at this point is that folks are not enabling the plugin on the text format config form.

    If anyone can please provide detailed numbered steps to reproduce from a clean install of D9 or D10 that would be hugely appreciated, then I can hopefully get to the bottom of this and fix it.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks for your quick reply @star-szr. Indeed I saw the tests and was wondering, what might be wrong. Perhaps it's a conflict with another module or ckeditor plugin?
    The affected project is quite large. I'll try the module at simplytest.me tomorrow and compare results.

    Yes, it's definitely enabled, even though the option can easily be overlooked, I think, see πŸ› Hide filter fields when plugin not enabled Fixed

    I think we'll find the reason, but if it's a conflict within ckeditor, it might be hard for me, because I don't know it very well.

  • πŸ‡¨πŸ‡¦Canada star-szr

    Thanks! That error you pasted earlier may be coming from another CKEditor 5 contrib, so it could be their bug causing this module to not work. I know CKEditor 5 has had a number of breaking changes and some contrib modules have had to release different versions for different core branches to maintain compatibility across multiple CKEditor 5 versions.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks @star-szr,

    now after re-saving, clearing all caches etc., I can see this pasteFilter array in the console:
    ​

    pasteFilter: Array(14) [ {…}, {…}, {…}, … ]​​​
    0: Object { enabled: true, weight: -10, search: "<o:p><\\/o:p>", … }​​​
    1: Object { enabled: true, weight: -9, search: '(<[^>]*) (style="[^"]*")', … }​​​
    2: Object { enabled: true, weight: -8, search: '(<[^>]*) (face="[^"]*")', … }​​​
    3: Object { enabled: true, weight: -7, search: '(<[^>]*) (class="[^"]*")', … }
    ​​​4: Object { enabled: true, weight: -6, search: '(<[^>]*) (valign="[^"]*")', … }​​​
    5: Object { enabled: true, weight: -5, search: "<font[^>]*>", … }​​​
    6: Object { enabled: true, weight: -4, search: "<\\/font>", … }​​​
    7: Object { enabled: true, weight: -3, search: "<span[^>]*>", … }​​​
    8: Object { enabled: true, weight: -2, search: "<\\/span>", … }​​​
    9: Object { enabled: true, weight: -1, search: "<p>&nbsp;<\\/p>", … }​​​
    10: Object { enabled: true, weight: 0, search: "<p><\\/p>", … }​​​
    11: Object { enabled: true, weight: 1, search: "<b><\\/b>", … }
    ​​​12: Object { enabled: true, weight: 2, search: "<i><\\/i>", … }​​​
    13: Object { enabled: true, weight: 3, search: '<a name="OLE_LINK[^"]*">(.*?)<\\/a>', … }​​​
    length: 14
    ​​​<prototype>: Array []

    And the loop runs! And it WORKS!

    I didn't uninstall or update any module, so this is really strange. I guess in most cases it's the UX that people forget to enable the setting. And perhaps that combined with browser or Drupal caching...

    So let's close this works as designed. I'll reopen, if it should happen again or in another project.

Production build 0.71.5 2024