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

Ignore formatting when pasting code into the Brython test console #2491

Open
alextretyak opened this issue Sep 13, 2024 · 1 comment
Open

Comments

@alextretyak
Copy link

alextretyak commented Sep 13, 2024

When I copy-paste code from GitHub into the Brython test console, it turns out to be almost invisible:
Скриншот 13-09-2024 125425

I can work around this by using the Ctrl+Shift+V hotkey, but it would be nice if just Ctrl+V would work as well.

Here is the code I tried to paste:

import re
re.sub(r'/\*[\s\S]*?\*/', '', 'a/*b c*/')
@denis-migdal
Copy link
Contributor

It seems a possible solution would be something like:

editor.addEventListener("paste", function(ev) {
    // cancel paste
    ev.preventDefault();

    // get text representation of clipboard
    var text = ev.clipboardData.getData('text/plain');

    // insert text manually
    editor.textContent += text;
});

from https://stackoverflow.com/questions/12027137/javascript-trick-for-paste-as-plain-text-in-execcommand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants