Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting text containing brackets with Ctrl+Shift+V changes text into an incorrect link / URL instead of pasting "a is" #33347

Closed
pansamolot opened this issue Jul 11, 2021 · 10 comments
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Paste [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... Needs Dev Ready for, and needs developer efforts [Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended

Comments

@pansamolot
Copy link

Description

When you paste a text using Ctrl+Shift+V then it is expected that it will be pasted unconditionally as a plain-text. Yet, when you paste this way a piece of text that contains a lot of square and regular brackets, i.e.:

[N1--13]([N-5,4]-[N-8,2]-[N-11,2])

then you always gets this as an incorrect (not working) URL. There's no way to paste such string into Gutenberg.

Step-by-step reproduction instructions

  1. Start a new post. Create a new Paragraph block
  2. Copy any string similar to [N1--13]([N-5,4]-[N-8,2]-[N-11,2]) from any source
  3. Paste it as plain text using context menu or Ctrl+Shift+V shortcut

Expected behaviour

Text is pasted as-is / as plain text.

Actual behaviour

Text is pasted as incorrect / not working URL.

Screenshots or screen recording (optional)

pasting

WordPress information

  • WordPress version: 5.7.2
  • Gutenberg version: 11.0.0
  • Are all plugins except Gutenberg deactivated? No
  • Are you using a default theme (e.g. Twenty Twenty-One)? No

Device information

  • Device: Intel Dual Core i3-2310M CPU, 8 GB RAM, 64-bit, laptop**
  • Operating system: Windows 10 Pro, 20H2 (19042.1083)
  • Browser: Google Chrome 91.0.4472.124
@getdave
Copy link
Contributor

getdave commented Jul 20, 2021

Thanks for the report. Much appreciated.

I've been able to replicate this and the source of the issue is in

if ( ! /^\s+$/.test( plainText ) ) {
HTML = markdownConverter( HTML );
}

Essentially Gutenberg is trying to convert the plain text to markdown. When it does this the raw text that you provided is seen as the markdown hyperlink syntax which is why your text gets converted into a link.

I'm not entirely sure how best to fix this yet without breaking the existing functionality of auto-markdown conversion.

@getdave getdave added [Feature] Blocks Overall functionality of blocks [Feature] Paste [Package] Blocks /packages/blocks Needs Technical Feedback Needs testing from a developer perspective. labels Jul 20, 2021
@getdave
Copy link
Contributor

getdave commented Jul 20, 2021

Perhaps @ellatrix you would be able to advise here? There's also the possibility it's been incorrectly matched as a shortcode by the paste hander as this is where the AUTO mode is set

if (
mode === 'AUTO' &&
isEmpty( value ) &&
isShortcode( plainText )
) {
mode = 'BLOCKS';
}

@getdave
Copy link
Contributor

getdave commented Jul 20, 2021

Confirmed setting __unstablePastePlainText={ true } on <RichText> disables the faulty behaviour. Could we force to true if the Cmd + Shift + V keyboard combo is active?

@pansamolot
Copy link
Author

@getdave Is there any progress on this? Will there be any pull request / bug-fix to this, since it seems that you have identified the source of the problem quite precisely?

@getdave
Copy link
Contributor

getdave commented Nov 19, 2021

@pansamolot I'm afraid not. There's a number of competing priorities at the moment and so it's still open for anyone to pick up.

That doesn't mean I don't think it's important it's just I've been engaged elsewhere.

I will add to be list to try and get to it as soon as I can. I'll also raise in the next Core Editor chat to see if I can get some eyes on it.

@pansamolot
Copy link
Author

@getdave Thank you! :>

@jordesign jordesign added [Type] Bug An existing feature does not function as intended [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Aug 18, 2023
@mrfoxtalbot
Copy link

mrfoxtalbot commented Aug 31, 2023

This forums thread seems to be a different example of the same underlying issue and provides an interesting "real life" use-case:

In Germany there is a gender neutral writing method that makes use of the asterisk. E.g.: “Mitarbeiter*innen”. So words in a text may contain asterisks, and users should still be able to copy paste texts into Gutenberg that contain such formatted words.

Do we have something like a filter that would deactivate markdown parsing, @getdave? I get that this is not a priority but it could be a setting in the Editor preferences.

@getdave
Copy link
Contributor

getdave commented Aug 31, 2023

Not that I'm aware of sorry.

I think @ellatrix would be well placed to advise on whether we can add an exception for these rules or implement something akin to my previous suggestion.

@ellatrix
Copy link
Member

ellatrix commented Sep 1, 2023

Confirmed setting __unstablePastePlainText={ true } on <RichText> disables the faulty behaviour. Could we force to true if the Cmd + Shift + V keyboard combo is active?

We could try that

@getdave getdave added Needs Dev Ready for, and needs developer efforts and removed Needs Technical Feedback Needs testing from a developer perspective. labels Sep 5, 2023
@getdave
Copy link
Contributor

getdave commented Mar 13, 2024

I tested this with the latest version of the editor and I could no longer replicate the bug describe.

Screen.Capture.on.2024-03-13.at.14-40-51.mp4

@pansamolot just letting you know that I'm going to close this issue but feel free to re-open if you can still replicate this.

@getdave getdave closed this as completed Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Paste [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... Needs Dev Ready for, and needs developer efforts [Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants