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

How should I add JS custom class hints? #105

Open
Jauhuei opened this issue Sep 5, 2023 · 3 comments
Open

How should I add JS custom class hints? #105

Jauhuei opened this issue Sep 5, 2023 · 3 comments

Comments

@Jauhuei
Copy link

Jauhuei commented Sep 5, 2023

@using MudBlazor;
@using WorkflowCore.Activities;
@using WorkflowCore.Attributes;
@using WorkflowCore.Models;
@using WorkflowCore.Workflows;
@using BlazorMonaco;

<MonacoEditor @ref="@Editor" ModelMarkers="" ConstructionOptions="@EditorConstructionOptions" OnDidChangeModelContent="@OnDidChangeModelContent" />

private StandaloneEditorConstructionOptions EditorConstructionOptions(MonacoEditor codeEditor)
  {
      return new StandaloneEditorConstructionOptions
          {
              Language = Language,
              Value = Code,
              Minimap = new EditorMinimapOptions() { Enabled = false },
          };
  }

I can create the editor and it works fine, but I want to add custom classes, custom global variables.
However, no relevant resources were found, including asking about GPT, but there was still no answer.

@Jauhuei
Copy link
Author

Jauhuei commented Sep 5, 2023

await JSRuntime.InvokeVoidAsync("monaco.languages.typescript.javascriptDefaults.addExtraLib", GenerateJSDeclareString(), null);

GenerateJSDeclareString() is string, like:

/**
 * XXXX
 */
declare class ConditionModel {
    /**
     * XXXX
     */
    Condition:boolean 
}

@serdarciplak
Copy link
Owner

This is not yet supported by BlazorMonaco but you can have your custom javascript file and make that call in javascript instead. You can access the js editor instance using the window.blazorMonaco.editor.getEditor(id) javascript method.

@Int32Overflow
Copy link

@serdarciplak Is there any plan to support this feature?

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

3 participants