BlazorMonaco icon indicating copy to clipboard operation
BlazorMonaco copied to clipboard

How should I add JS custom class hints?

Open Jauhuei opened this issue 2 years ago • 3 comments

@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 avatar Sep 05 '23 04:09 Jauhuei

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

GenerateJSDeclareString() is string, like:

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

Jauhuei avatar Sep 05 '23 10:09 Jauhuei

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.

serdarciplak avatar Jan 14 '24 23:01 serdarciplak

@serdarciplak Is there any plan to support this feature?

Int32Overflow avatar Jul 06 '24 07:07 Int32Overflow