Button for "Paste with filter"

Created on 1 April 2024, 9 months ago
Updated 20 June 2024, 7 months ago

Problem/Motivation

This module works great for copy and pasting for word processors... One issue I'm having however is that I don't want filters to be applied when I am editing a document... I'm finding that I copy text with styles applied, paste it elsewhere in the document and my styling is gone.

I'm more than happy for the filter to be this aggressive for Word docs, but I'd prefer my own markup was left alone, which is why I propose a "Filtered Paste" option (which sounds like a tasty drink) and let Ctrl C, Ctrl V behave as normal.

Steps to reproduce

<!-- The steps below are a starting point, customize or add to them as needed. -->

1. Create a text fromat which permits styles which not permitted by the paste filter, with the filter enabled.
2. Create a document with this format, create some text using these non-permitted styles
3. Cut the text
4. Paste it in the same window
5. Note your own styles have been removed

Expected markup result

I would have expected my own text in the same window to be 'compatible with itself' so to speak

Proposed resolution

Instead of filtering anything that is pasted, only filter when clicking a new "Filtered paste" button

Alternatively, for me personally:
I can modify the rules prevent common undesireable removals, but a general solution feels like it would be better. I'm also thinking I could make a separate text format which is just used for pasting... but I think this could have other problems and confuse content editors.

Remaining tasks

unsure

User interface changes

New button

API changes

unsure

Data model changes

unsure

Feature request
Status

Closed: won't fix

Version

1.0

Component

User interface

Created by

🇬🇧United Kingdom jacobupal Leeds

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

Comments & Activities

  • Issue created by @jacobupal
  • 🇬🇧United Kingdom jacobupal Leeds
  • 🇬🇧United Kingdom jacobupal Leeds
  • Status changed to Postponed 9 months ago
  • 🇨🇦Canada star-szr

    Hi @jacobupal! Thanks for writing this up.

    I don't currently have any plans or desire to add this feature. Having a separate "paste from word" style button relies on people remembering it's there and using it. I think your idea of making more specific filter rules for your use case makes the most sense for your use case at this time.

    Depending on the details of your use case, perhaps a global permission to allow users to skip filtering would be a simpler implementation. This has its own issues and complexities (administrators would get this permission by default) so I'm not fully sold on it either. It's just an idea at this point.

    Some other workarounds to mention that should work with the current code, other than customizing rules or using multiple text formats:

    • Drag and drop the content around inside the editor instead (admittedly cut/copy/paste is just better for some cases and perhaps more accessible, but I think it's worth mentioning)
    • Move content around in the source editor instead
  • 🇬🇧United Kingdom jacobupal Leeds

    Thank you for the reply!

    I'll see how far I get with modifying the filters... "Having a separate "paste from word" style button relies on people remembering it's there and using it." -- I can totally see this, for my uses it would be the lesser of two evils though.

    If it was just me using it, this would be fine - though I do generally prefer to the markup myself... However, I predict that our editor, who is not so tech savvy, and will feel the initial benefits of this module, is also going to get very confused if their formatting evaporates whilst editing a piece - I'm then going to be forever tweaking the filter rules for each edge-case that comes up. Hopefully I can can get it right. If I can't, I'll be sad to let go of this module as it is pretty awesome.

    That said if I can't find another way around it, I'm sure I can make some time to look into what the implementation of an optional 'filtered paste' button would require

  • 🇨🇦Canada star-szr

    Another possible approach would be to try to detect the source of the pasted HTML and only filter when certain sources (like MS Word or Google Docs) are detected.

    I know CKEditor 5 itself uses logic like this for its paste from office plugin but it's also very easy to get bad markup from other sources, so I'm not totally sure if I want to implement this. Maybe as an opt-in feature with a warning that it only works for Microsoft Word and Google Docs. https://github.com/ckeditor/ckeditor5/blob/e71971206bb3e7e176692a1b973a4...

  • Status changed to Closed: won't fix 7 months ago
  • 🇨🇦Canada star-szr

    I'm going to close this for now. Not to say "never", but to say "not right now". Thank you for the feature request!

Production build 0.71.5 2024