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

Bug? CodemirrorComponent undefined in ts File(Angular 16 with Codemirror 5) #324

Open
Lavicola opened this issue Nov 6, 2023 · 1 comment

Comments

@Lavicola
Copy link

Lavicola commented Nov 6, 2023

Greetings,
I am trying to use the fullScreen Plugin, but I have some troubles.
My Component is:

    <ngx-codemirror #codeMirror
     [(ngModel)]="stream"
      [options]="{
    lineNumbers: true,
    theme: 'material',
    mode: 'text/javascript',
    fullScreen:false,
    EditorConfiguration:true,
    extraKeys: { F11: setFullScreen }
    }"
    ></ngx-codemirror>

In my ts file I want to add the event, however this is always undefined

@ViewChild('codeMirror') codeMirrorCmpt: CodemirrorComponent;
   [....]
  public setFullScreen(){
    
    console.log(this.codeMirrorCmpt)
    this.codeMirrorCmpt.codeMirror?.setOption("fullScreen",true);
    console.log("called")
  }

The other Issue is not helping: #318)

Another Issue (#310) is interesting and I tried it myself:
If I have a button my Component is not undefined, but if I use F11 in my Codeeditor it is again undefined even if I press the Button first and later F11 in my Codeeditor

@Lavicola
Copy link
Author

Lavicola commented Nov 6, 2023

I randomly got it working, but I still think the solution above should work.

In ts File:

  public closeFullScreen(cm:any) {
    cm.setOption("fullScreen",false);
  }

  public setFullScreen(cm:any){
    cm.setOption("fullScreen",true);
  }

In HTML:
extraKeys: { F11: setFullScreen, Esc: closeFullScreen }

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

1 participant