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

Event listener on paste is not working #618

Open
Shubhamag19 opened this issue May 12, 2024 · 1 comment
Open

Event listener on paste is not working #618

Shubhamag19 opened this issue May 12, 2024 · 1 comment
Labels

Comments

@Shubhamag19
Copy link

Shubhamag19 commented May 12, 2024

Describe the bug

I have used getDomNode to access the DOM node and attached event listener to it. Click event is working but Paste is not.

To Reproduce

I'm attaching code snippet here:

import { useState } from "react";
import Editor from "@monaco-editor/react";

export default function App() {
  const [value, setValue] = useState("");

  const handleMount = (editor) => {
    editor.getDomNode().addEventListener("click", function (e) {
      console.log("clicked");
    });

    editor.getDomNode().addEventListener("paste", function (e) {
      console.log("pasted");
    });
  };

  return (
    <div>
      <Editor
        height="80vh"
        defaultLanguage="html"
        theme="vs-dark"
        onChange={(val) => setValue(val)}
        value={value}
        onMount={handleMount}
        defaultValue={"<div>Hello world</div>"}
      />
    </div>
  );
}

Expected behavior

pasted should have logged just as clicked is getting logged.

Screenshots

image

Additional context

I tried this with react-monaco-editor library and it is working correctly with that.

Copy link

This issue has been marked as stale due to inactivity. It will be closed in 7 days unless further activity occurs.

@github-actions github-actions bot added the Stale label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant