google / playground-elements

Serverless coding environments for the web.
BSD 3-Clause "New" or "Revised" License
533 stars 52 forks source link

strange code copy behavior #393

Open nnaydenow opened 6 months ago

nnaydenow commented 6 months ago

My editor has file which has following html code as source.

<!-- playground-hide -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sample</title>
</head>

<body>
    <!-- playground-hide-end -->
    <button>Some visible content>
    <!-- playground-hide -->
    <script type="module" src="main.js"></script>
</body>

</html>
<!-- playground-hide-end -->

If I do cmd + a, then cmd+v the whole page content is pasted even if only the <button>Some visible content> is the only displayed content inside the editor.

jlukic commented 3 months ago

I've noticed this as well folded or hidden content is included in the pasteable content when selecting all in the codemirror instance.

Perhaps there's a way to hook into CodeMirror's paste event to filter out the hidden content.