Skip to content

MonacoEditor

Embeds the Monaco code editor (the editor that powers VS Code), providing syntax highlighting, code decorations, and hover content for a given programming language. Find more options at https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html

GUI Model

component MonacoEditor(
  ?String entry,

  boolean disabled = false,

  String language = "Java",

  String theme = "Light +",

  boolean glyphMargin = true,
  boolean showLightbulbIconMode = true,
  boolean automaticLayout = true,
  boolean semanticHighlightingEnabled = true,
  boolean showMinimap = true,

  int initialScrollToLine,
  int jumpToLine,
  List<InlineDecoration> highlighting,

  List<HoverContent> hoverContents,

  String width = "100%",
  String height = "100%",

  boolean autoHeight = false,
  int maxLines = 30,

  Event<Object> lineClick
)
Name Type Description Default value
entry ?String Initial source code shown in the editor.
disabled boolean Toggles read only mode. If true, the content cannot be edited. false
language String Programming language used for syntax highlighting. "Java"
theme String Editor color theme. Default dark theme is "vs-dark". The light themes "vs", "vs-light", "Light +" and "hc-light" switch to their dark counterpart while the dark mode of the app is active (see GemDarkModeSwitch). "Light +"
glyphMargin boolean Whether the glyph margin (used e.g. for decorations) is shown. true
showLightbulbIconMode boolean Whether the lightbulb icon for quick fixes/actions is shown. true
automaticLayout boolean Whether the editor automatically resizes when its container changes size. true
semanticHighlightingEnabled boolean Whether semantic highlighting is enabled. true
showMinimap boolean Whether the minimap is shown. true
initialScrollToLine int Line the editor scrolls to when it is initially rendered.
jumpToLine int Line the editor jumps to, e.g. to reveal a specific position.
highlighting List<InlineDecoration> Inline decorations (e.g. highlights, markers) applied to specific lines/ranges.
hoverContents List<HoverContent> Content shown in a hover tooltip for specific lines/ranges.
width String Width of the component in px, %, vh, etc. "100%"
height String Height of the component in px, %, vh, etc. "100%"
autoHeight boolean Whether the editor's height automatically grows with its content, up to maxLines. false
maxLines int Maximum number of lines shown when autoHeight is enabled. 30
lineClick Event<Object> Callback that is executed when a line is clicked.

Types

MonacoEditorTypes

package mc.fenix.editor;
import java.util.List;
import java.util.Optional;

<<pojoCD>>
classdiagram MonacoEditorTypes {

  public class InlineDecoration {
    Range range;
    String cssClass;
  }

  public class HoverContent {
    Range range;
    // Markdown and HTML possible
    List<String> hoverContent;
  }

  public class Range {
    int startLin;
    int startCol;
    int endLin;
    int endCol;
  }

  public class LineClickEvent {
    int lineNumber;
    int column;
  }
}

InlineDecoration

Name Type Description Default value
range Range
cssClass String

HoverContent

Name Type Description Default value
range Range
hoverContent List<String> // Markdown and HTML possible

Range

Name Type Description Default value
startLin int
startCol int
endLin int
endCol int

LineClickEvent

Name Type Description Default value
lineNumber int
column int