Skip to content

[MonacoEditorReactComp] onLoad() should expose editor refrence  #612

@Stainless2k

Description

@Stainless2k

It would be nice if the onLoad callback would have the editor reference as a parameter
e.g onLoad(editor: IStandaloneCodeEditor)

This would make it more convenient to use addAction, scroll something in to view on load or focus the editor.
Right now you need to get and store the ref yourself, which is fine but unnecessary imo.

const editorRef = useRef<mEditor.IStandaloneCodeEditor>();
return (
  <MonacoEditorReactComp
    ref={(ref) => {
      editorRef.current = ref?.getEditorWrapper().getEditor();
    }}
  />
)

More convenient:

return ( 
  <MonacoEditorReactComp
    onLoad={(editor) => {
      editor.addAction( . . . );
      editor.revealLineInCenter( . . . );
      editor.setSelection( . . . );
      editor.focus( . . . );
    }}
  />
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions