How to disallow paste

User
i want to disallow paste in codemirror editor in v6.
i thought that we can do it we can do it this code, but we can’t do it error that is “Type ‘() => boolean’ is not assignable to type ‘string’”.


const view = new EditorView({
  state: EditorState.create({
    extensions: [
      EditorView.contentAttributes.of({
        onpaste: (): Boolean => false
      }),
      ...extensions
    ],
    
  }),
  parent: ref.current,
});

Do we have any solution?

You’ll want to use domEventHandlers, rather than contentAttributes, to register event handlers. Adding one for paste that calls event.preventDefault() should work.

(Though, generally, disabling paste is an annoying, user-hostile thing to do and you should consider whether it is really a good idea.)

thanks!
I could do what I want.
By the way, if i want to onclick event, use EditorView.updateListener right?
Could you tell me different?