B4X Store
jdashboardUI / Editors & Developer Tools / MonacoEditorView
Editors & Developer Tools

MonacoEditorView

Offline Monaco editor with multi-document support, search, VBA navigation, snippets and completion

Search all jdashboardUI docs
Source
jdashboardUI.b4xlib · Public API only
Store language: en
Reference view
Inspired by the real Ribbon UI Studio Pro integration; this is not an exact screenshot.
Monaco Editor
customUI14.xml
RibbonCallbacks ●
⌕
Search in document
↑↓0/0
1
2
3
4
5
6
7
8
9
10
Public Sub btnCabecera(control As IRibbonControl)
Call GenerarTitulosCabecera
End Sub
 
Public Sub btnGenerarCode(control As IRibbonControl)
Call ProcesarDatosPruebas
End Sub
 
Public Sub RibbonCargar(ribbon As IRibbonUI)
End Sub
VBA UTF-8 🎨 Theme: Ribbon Editor Theme
Ln 1, Col 1

Platform: B4J / JavaFX WebView. Library verified: jdashboardUI(20261108-154221).b4xlib. Scope: the capabilities implemented by MonacoEditorView itself, not those of other applications.

MonacoEditorView embeds the Monaco code editor in a B4J desktop application. It displays, edits, and manages text and document tabs. The package supplies a local runtime (monaco.zip), themes, language modes, search, editing commands, snippets, some built-in suggestions, and three public methods for loading or executing JavaScript extensions supplied by your application.

Important: the component does not create applications, visual forms, installation wizards, or complete projects. A language ID or an extension mechanism is not a generator. Your B4J application remains responsible for real files, storage, and any external toolchain.

1. Included capabilities versus host responsibilities

Included in the library You implement in your B4J application
Integrated Monaco view Your application's screens and workflows
Text editor, document tabs and text models Reading and writing physical files
Search, selection, undo/redo and editor commands Project, file and folder explorer
Language modes and available runtime highlighting Compilation, execution, debugging and domain-specific analysis
Built-in suggestions and snippets Custom completion providers and application symbols
JavaScript loading and execution bridge The new JavaScript behavior you wish to introduce
Optional document metadata and modification state File paths, external formats and persistence

Editing a type of text does not mean automatically generating that type of file.

2. Basic integration with the Visual Designer

Enable the jdashboardUI library, add a MonacoEditorView CustomView in the B4J Visual Designer, name it Editor1, and save the layout as Main.

The Designer exposes:

Property Library default Purpose
DefaultTheme ribbonEditorTheme Initial visual theme ID, not an application integration
DefaultLanguage xml Initial content language
ShowStatusBar True Display the internal status bar
EditorUiLanguage English Editor labels: English or Spanish

Monaco initializes asynchronously. Wait for Ready:

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Editor1 As MonacoEditorView
    Private DocumentId As String
End Sub

Sub AppStart(Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Main")
    MainForm.Show
End Sub

Private Sub Editor1_Ready
    DocumentId = Editor1.OpenDocument("notes.md", "# Hello from B4J", Editor1.LANG_MARKDOWN)
    Log("Opened ID: " & DocumentId)
End Sub

Private Sub Editor1_DocumentActivated(Id As String, Name As String)
    Log("Active tab: " & Name)
End Sub

Private Sub Editor1_DocumentClosed(Id As String, Name As String)
    Log("Closed tab: " & Name)
End Sub

OpenDocument returns a document ID, not necessarily the tab caption. Use it for later actions.

You may also call Initialize(Me, "Editor1") and AddToParent(Parent, Left, Top, Width, Height) to create the view in code. View creation is not equivalent to Ready.

Before Ready, SetValue queues text and InsertSnippet queues snippets. Other methods are not generally queued: for example, OpenDocument returns an empty ID and LoadJavaScriptFile returns False.

3. Multiple documents and saving

Private Sub Editor1_Ready
    Dim FirstId As String = Editor1.OpenDocument("data.json", "{}", Editor1.LANG_JSON)
    Dim SecondId As String = Editor1.OpenDocument("notes.md", "# My notes", Editor1.LANG_MARKDOWN)

    Editor1.SelectDocument(FirstId)
    Log(Editor1.GetDocumentValue(SecondId)) ' Read another tab without switching
    Editor1.SetDocumentValue(SecondId, "# Updated notes")
End Sub

GetDocuments returns open document information. GetActiveDocumentId and GetActiveDocumentName identify the selected tab. RenameDocument changes its displayed title, not a physical filename. CloseDocument closes a model but does not itself write a file.

Saving is your responsibility. After writing the content with the B4J File API, mark that tab saved:

Private Sub SaveNotes
    Dim Content As String = Editor1.GetDocumentValue(DocumentId)
    File.WriteString(File.DirApp, "notes.md", Content)
    Editor1.MarkDocumentSavedFor(DocumentId)
End Sub

The example assumes DocumentId identifies an open tab and that File.DirApp is writable.

Optional metadata

OpenDocument additionally accepts SourcePath, WorkPath, EntryPath, ModuleName and DocumentType. These are application-defined identity strings. They do not open special formats, extract contents or generate modules. SetDocumentMetadata and GetDocumentMetadata store/read them. DocumentExists checks open-document identity, not physical disk existence.

4. Built-in editing and themes

Editor1.FindText("search")
Editor1.FocusSearch
Editor1.SelectAll
Editor1.CopySelection
Editor1.Undo
Editor1.Redo
Editor1.InsertSnippet("Sub MyMethod" & CRLF & "End Sub")
Editor1.SetTheme("vs-dark")
Editor1.SetEditorUiLanguage("English")

Other commands include CutSelection, PasteSelection, ToggleComment, FormatDocument and FormatSelection. Formatting depends on a formatter registered for the active language and may do nothing for some languages.

SetLanguage changes the content language; SetEditorUiLanguage changes UI labels. They are different. The public identifiers include LANG_JSON, LANG_XML, LANG_B4X, LANG_JAVASCRIPT, LANG_PYTHON and LANG_VBA among others. They do not guarantee the same degree of completion support for every language.

GoToProcedure is specifically designed to locate recognized VBA Sub, Function or Property declarations; it is not a universal symbol navigator.

5. Add your own IntelliSense with an external JavaScript file

The runtime contains some built-in suggestions. To extend them, register a completion provider through Monaco's public API. The application supplies the provider and its suggestions; LoadJavaScriptFile only loads and executes the file.

Add a file named my-suggestions.js to your B4J Files tab:

(function () {
    "use strict";

    if (!window.monaco || !window.editor) return;

    if (window.mySuggestionProvider) window.mySuggestionProvider.dispose();

    window.mySuggestionProvider = monaco.languages.registerCompletionItemProvider("javascript", {
        provideCompletionItems: function (model, position) {
            var word = model.getWordUntilPosition(position);
            var range = new monaco.Range(
                position.lineNumber, word.startColumn,
                position.lineNumber, word.endColumn
            );

            return {
                suggestions: [{
                    label: "showMessage",
                    kind: monaco.languages.CompletionItemKind.Function,
                    insertText: "console.log('Hello');",
                    detail: "Example completion supplied by my application",
                    range: range
                }]
            };
        }
    });
})();

After the editor's Ready event:

Private Sub Editor1_Ready
    Editor1.OpenDocument("example.js", "", Editor1.LANG_JAVASCRIPT)
    Dim Loaded As Boolean = Editor1.LoadJavaScriptFile(File.DirAssets, "my-suggestions.js")
    Log("Extension loaded: " & Loaded)
End Sub

This adds one example suggestion when editing JavaScript. Other languages require their own provider and data. This IntelliSense functionality is implemented in the JavaScript file you supplied, not generated by the library.

Execute JavaScript and read a result

If Editor1.IsReady Then
    Dim Executed As Boolean = Editor1.ExecuteJavaScript("console.log('Ready')")
    Dim Result As Object = Editor1.ExecuteJavaScriptWithResult("1 + 2")
    Log("Executed: " & Executed & ", result: " & Result)
End If

ExecuteJavaScript returns whether execution succeeded, not the value returned by the script. ExecuteJavaScriptWithResult handles synchronous expressions, returning scalar values directly and objects/arrays as JSON text.

All three JavaScript methods require Ready and the JavaFX application thread. LoadJavaScriptFile accepts local .js filenames; repeated loads of the same path in one page instance are skipped. If the WebView is recreated, load the extension again.

6. Real consumer events versus internal bridge methods

Consumer events declared in the source:

  • Editor1_Ready — the embedded editor finished initialization.
  • Editor1_DocumentActivated(DocumentId As String, DocumentName As String) — tab activation.
  • Editor1_DocumentClosed(DocumentId As String, DocumentName As String) — tab closure.

documentChanged is a public method used by the internal JavaScript bridge, not a declared consumer #Event in this version. documentActivated and documentClosed are also bridge entrypoints. The public clipboardGet, clipboardSet and PasteTest are clipboard/diagnostic helpers; normal editing uses CopySelection, CutSelection and PasteSelection.

7. Included language mode and visual theme

  • LANG_setupstudio is a custom language identifier included in the runtime. It selects the editing mode for installation scripts, including the highlighting rules and suggestions available for that mode. It does not build installers or projects.
  • ribbonEditorTheme is an included visual theme identifier. It is the Designer default and can be selected with SetTheme("ribbonEditorTheme"). No other application is required.

8. Troubleshooting

  • The control is visible but actions fail: wait for Ready and check IsReady.
  • LoadJavaScriptFile returns False: check the UI thread, the file's location and the .js extension.
  • Your suggestions do not appear: check the language ID and the registration code in your extension.
  • MarkDocumentSavedFor did not update a file: this method only changes the editor's saved indicator; write to disk first.
  • FormatDocument does nothing: a formatter may not be registered for that language.
  • Your language is editable but no project is generated: editing support is not compilation, project creation or external integration.

9. Complete public API reference

The reference below covers 50 public methods for editing text, managing documents and extending the editor, with signatures checked against the supplied library.

Verified declarations and method-by-method descriptions

Using these examples: add Editor1 as a Designer CustomView, wait for Editor1_Ready, and execute the snippets from a B4J Sub. IdNotas/NotesId stands for a real ID returned by OpenDocument. Button callbacks require matching Designer buttons. File.DirApp is a demo path: in a packaged app use a writable folder and a distinct filename per document.

Initialize

Public Sub Initialize (Callback As Object, EventName As String)

Initializes the object with the event target and callback prefix; the editor is not necessarily ready yet.

DesignerCreateView

Public Sub DesignerCreateView (Base As Pane, Lbl As Label, Props As Map)

B4J Designer integration method; normally invoked by the CustomView infrastructure.

AddToParent

Public Sub AddToParent(Parent As B4XView, Left As Double, Top As Double, Width As Double, Height As Double)

Creates the Monaco view inside a B4XView parent using the supplied position and size.

SetValue

Public Sub SetValue(xml As String)

Sets text in the active editor. Before Ready, the value is queued. The parameter name xml is historical; the value can be ordinary text.

Use case: Place initial text in the active editor.

Editor1.SetValue("First line" & CRLF & "Second line")

Result and caveats: Its parameter is historically called xml, but ordinary text is supported.

GetValue

Public Sub GetValue As String

Gets the active document text; returns an empty string before Ready.

Use case: Read current text for processing or saving.

Dim Content As String = Editor1.GetValue
Log(Content)

Result and caveats: Returns text; it does not open or write a physical file.

GetDocumentValue

Public Sub GetDocumentValue(DocumentId As String) As String

Reads a document model by DocumentId without changing the active tab.

Use case: Read another tab without activating it.

Dim Content As String = Editor1.GetDocumentValue(NotesId)
Log(Content)

Result and caveats: NotesId is an ID previously returned by OpenDocument or NewDocument.

SetDocumentValue

Public Sub SetDocumentValue(DocumentId As String, Content As String) As Boolean

Replaces the text of a document identified by DocumentId without activating its tab; returns success.

Use case: Replace text in a tab identified by its ID.

Dim Ok As Boolean = Editor1.SetDocumentValue(NotesId, "# Updated text")
Log(Ok)

Result and caveats: You do not need to activate that tab. Check the Boolean for an invalid ID.

MarkDocumentDirty

Public Sub MarkDocumentDirty(DocumentId As String)

Marks a document as modified; useful when the host app changes content through another control.

Use case: Flag unsaved changes when another part of your UI updates a document.

Dim Id As String = Editor1.GetActiveDocumentId
If Id <> "" Then Editor1.MarkDocumentDirty(Id)

Result and caveats: Updates modification state only; does not change text or write files.

NewDocument

Public Sub NewDocument(DocumentName As String) As String

Opens a new empty document with the supplied caption and default language; returns its ID.

Use case: Create an empty tab for new content.

Dim NewId As String = Editor1.NewDocument("Untitled")
Log("Document ID: " & NewId)

Result and caveats: Store the ID so you can work with the tab even if its caption changes.

OpenDocument

Public Sub OpenDocument(DocumentName As String, Content As String, Language As String, SourcePath As String = "", WorkPath As String = "", EntryPath As String = "", ModuleName As String = "", DocumentType As String = "") As String

Opens a tab with name, content and language and returns a DocumentId. Five optional host metadata fields do not create physical files.

Use case: Open an existing JSON file in an editor tab.

Dim Content As String = File.ReadString(File.DirApp, "data.json")
Dim Id As String = Editor1.OpenDocument("data.json", Content, Editor1.LANG_JSON)
Log("ID: " & Id)

Result and caveats: The file must exist. File.ReadString reads it from disk; OpenDocument displays the supplied text in a tab.

OpenDocumentEx

Public Sub OpenDocumentEx(DocumentName As String, Content As String, Language As String, SourcePath As String, WorkPath As String, EntryPath As String, ModuleName As String, DocumentType As String) As String

Deprecated compatibility alias. Use OpenDocument for new code.

SetDocumentMetadata

Public Sub SetDocumentMetadata(DocumentId As String, SourcePath As String, WorkPath As String, EntryPath As String, ModuleName As String, DocumentType As String) As Boolean

Attaches application-defined metadata to an existing tab; does not write to disk.

Use case: Associate a logical source path and category with a tab.

Dim Ok As Boolean = Editor1.SetDocumentMetadata(NotesId, "notes.md", "", "", "", "text")
Log("Metadata: " & Ok)

Result and caveats: Does not modify text or save files; these are host-supplied identity fields.

GetDocumentMetadata

Public Sub GetDocumentMetadata(DocumentId As String) As Map

Returns a Map of known metadata and state for a DocumentId.

Use case: Inspect metadata associated with a document.

Dim Info As Map = Editor1.GetDocumentMetadata(NotesId)
Log(Info)

Result and caveats: Inspect the returned Map before relying on its keys; this is tab metadata, not an automatic file open.

GetActiveDocument

Public Sub GetActiveDocument As Map

Returns the active document metadata Map.

Use case: Display active-tab information in a properties panel.

Dim Info As Map = Editor1.GetActiveDocument
Log(Info)

Result and caveats: Returns a Map describing the selected document.

DocumentExists

Public Sub DocumentExists(SourcePath As String, EntryPath As String, ModuleName As String, DocumentType As String) As Boolean

Checks whether an open tab matches four host identity fields; it is not a disk file-existence check.

Use case: Avoid opening a duplicate tab with an existing identity.

Dim AlreadyOpen As Boolean = Editor1.DocumentExists("notes.md", "", "", "text")
Log("Tab exists: " & AlreadyOpen)

Result and caveats: Matches identity fields of tabs registered by your app. Use File.Exists for physical disk files.

SelectDocument

Public Sub SelectDocument(DocumentId As String)

Activates the tab identified by DocumentId.

Use case: Select a known tab independently of its caption.

Editor1.SelectDocument(NotesId)

Result and caveats: Use the ID returned when opening the document.

CloseDocument

Public Sub CloseDocument(DocumentId As String) As Boolean

Requests tab closure and returns True on success. Handle any required save in the host application first.

Use case: Close a document after saving it, to avoid accidentally losing its content.

Dim Id As String = Editor1.GetActiveDocumentId
If Id <> "" Then
    Try
        File.WriteString(File.DirApp, "document.txt", Editor1.GetDocumentValue(Id))
        Editor1.MarkDocumentSavedFor(Id)
        Dim Closed As Boolean = Editor1.CloseDocument(Id)
        Log("Closed: " & Closed)
    Catch
        Log(LastException)
    End Try
End If

Result and caveats: This is a fixed demo filename. In production, save to the path assigned to each tab and confirm before discarding edits.

RenameDocument

Public Sub RenameDocument(DocumentId As String, DocumentName As String) As Boolean

Changes the visible tab caption; does not rename disk files.

Use case: Update a tab caption when a document has a new title.

Dim Ok As Boolean = Editor1.RenameDocument(NotesId, "Revised notes.md")
Log(Ok)

Result and caveats: Renames the tab, not a physical file.

GetActiveDocumentId

Public Sub GetActiveDocumentId As String

Returns the currently active tab identifier.

Use case: Find which document a Save or Close command should target.

Dim Id As String = Editor1.GetActiveDocumentId
If Id = "" Then Return
Log("Active document: " & Id)

Result and caveats: An empty ID means there is no active tab.

GetActiveDocumentName

Public Sub GetActiveDocumentName As String

Returns the visible name of the active document.

Use case: Show the active tab title in a status area.

Log("Editing: " & Editor1.GetActiveDocumentName)

Result and caveats: The caption is not necessarily a physical file path.

GetDocuments

Public Sub GetDocuments As List

Returns the document list including IDs, names, states and metadata.

Use case: List open tabs in the Log.

Dim Documents As List = Editor1.GetDocuments
Log("Open tabs: " & Documents.Size)
For Each Doc As Object In Documents
    Log(Doc)
Next

Result and caveats: You may build a custom document switcher based on this list; inspect its returned entries before assuming particular keys.

MarkDocumentSaved

Public Sub MarkDocumentSaved

Marks the active tab as saved; does not write a file.

Use case: Save the active tab and clear its unsaved indicator only after a successful disk write.

Private Sub btnSave_Click
    If Editor1.IsReady = False Then Return
    If Editor1.GetActiveDocumentId = "" Then Return
    Try
        File.WriteString(File.DirApp, "notes.txt", Editor1.GetValue)
        Editor1.MarkDocumentSaved
        Log("Saved successfully")
    Catch
        Log("Error: " & LastException)
    End Try
End Sub

Result and caveats: The demo file is written first; then the active tab is marked saved. MarkDocumentSaved never writes files. Add a Designer button named btnSave for this event.

MarkDocumentSavedFor

Public Sub MarkDocumentSavedFor(DocumentId As String)

Marks a specific DocumentId as saved; call only after the host app actually saves it.

Use case: Save a specific tab without switching to it, useful for multi-document editors.

Private Sub SaveNotes(NotesId As String)
    If Editor1.IsReady = False Or NotesId = "" Then Return
    Try
        File.WriteString(File.DirApp, "notes.md", Editor1.GetDocumentValue(NotesId))
        Editor1.MarkDocumentSavedFor(NotesId)
    Catch
        Log("Not saved: " & LastException)
    End Try
End Sub

Result and caveats: Unlike MarkDocumentSaved, it marks the specified ID as saved. Use a distinct actual file path for each tab.

documentActivated

Public Sub documentActivated(DocumentId As String, DocumentName As String)

Public callback used by the internal JavaScript bridge to sync tab selection and forward DocumentActivated; normally not called by consumer code.

documentChanged

Public Sub documentChanged(DocumentId As String, DocumentName As String, Dirty As Boolean)

Internal public bridge callback updating cached document state; this version does not declare a consumer #Event named DocumentChanged.

documentClosed

Public Sub documentClosed(DocumentId As String, DocumentName As String)

Internal public bridge callback that updates the cache and forwards DocumentClosed; normally not called from B4J.

InsertSnippet

Public Sub InsertSnippet(snippet As String)

Inserts a text snippet at the cursor; it is queued if the editor is not yet ready.

Use case: Insert an editable source template.

Editor1.InsertSnippet("Sub MyMethod" & CRLF & "    Log(""Hello"")" & CRLF & "End Sub")

Result and caveats: Code is inserted at the cursor; no project file is generated.

Undo

Public Sub Undo

Undoes the last editing operation in the active document.

Use case: Wire your toolbar's Undo button.

Private Sub btnUndo_Click
    Editor1.Undo
End Sub

Result and caveats: Undoes the previous edit in the active document.

Redo

Public Sub Redo

Redoes the last undone editing operation.

Use case: Restore an edit after using Undo.

Private Sub btnRedo_Click
    Editor1.Redo
End Sub

Result and caveats: The Designer button should be named btnRedo for this event.

SelectAll

Public Sub SelectAll

Selects the entire active document.

Use case: Provide a Select All menu command.

Editor1.SelectAll

Result and caveats: Selects the active document's text, not every tab.

ToggleComment

Public Sub ToggleComment

Toggles comments using the active language's configured comment rules.

Use case: Comment or uncomment selected code.

Editor1.ToggleComment

Result and caveats: Works according to the active language's comment syntax.

CopySelection

Public Sub CopySelection

Copies the selection through the JavaFX clipboard bridge.

Use case: Implement an Edit > Copy menu item.

Editor1.CopySelection

Result and caveats: Uses JavaFX clipboard handling; copies the selection, not all tabs.

CutSelection

Public Sub CutSelection

Cuts the selection using the JavaFX clipboard.

Use case: Implement an Edit > Cut menu item.

Editor1.CutSelection

Result and caveats: Removes selected text and sends it to the clipboard.

PasteSelection

Public Sub PasteSelection

Pastes available text from the JavaFX clipboard.

Use case: Implement an Edit > Paste menu item.

Editor1.PasteSelection

Result and caveats: Inserts clipboard text at the editor's current position.

FormatDocument

Public Sub FormatDocument

Requests document formatting; requires an available formatter for the active language.

Use case: Offer a Format action in your toolbar.

Editor1.FormatDocument

Result and caveats: Changes require an available formatter for the selected language.

FormatSelection

Public Sub FormatSelection

Requests selection formatting; availability depends on the registered provider.

Use case: Add a Format Selection command.

Editor1.FormatSelection

Result and caveats: Requires a range formatter for the active language; it may do nothing otherwise.

FocusSearch

Public Sub FocusSearch

Opens or focuses Monaco's integrated search UI.

Use case: Open the built-in search UI from a button.

Private Sub btnFind_Click
    Editor1.FocusSearch
End Sub

Result and caveats: Connect the handler to a Designer button named btnFind.

SetEditorUiLanguage

Public Sub SetEditorUiLanguage(Language As String)

Sets built-in editor UI labels to English or Spanish; does not change the document language.

Use case: Use English labels in the editor UI.

Editor1.SetEditorUiLanguage("English")

Result and caveats: Does not translate user code or change LANG_JSON, LANG_VBA, etc.

FindText

Public Sub FindText(Query As String)

Searches for text in the active document and selects the first match.

Use case: Find a word without implementing a search engine.

Editor1.FindText("configuration")

Result and caveats: Selects the first match in the active document.

GoToProcedure

Public Sub GoToProcedure(ProcedureName As String) As Boolean

Navigates to a VBA Sub, Function or Property when the bundled parser recognizes the name; returns whether found.

Use case: Navigate to an existing VBA procedure.

Dim Found As Boolean = Editor1.GoToProcedure("CalculateTotal")
Log("Found: " & Found)

Result and caveats: Does not generate procedures; requires recognizable VBA source.

clipboardGet

Public Sub clipboardGet As String

Reads text from the JavaFX clipboard; a public method also used by the bridge.

clipboardSet

Public Sub clipboardSet(text As String) As Boolean

Writes text to the JavaFX clipboard and verifies it; public bridge helper.

PasteTest

Public Sub PasteTest As String

Diagnostic helper returning clipboard text; it does not insert content.

SetTheme

Public Sub SetTheme(themeName As String)

Applies a theme registered in the Monaco runtime; the theme name must exist.

Use case: Switch between a dark theme and the included default theme.

Editor1.SetTheme("vs-dark")
' Also available:
Editor1.SetTheme("ribbonEditorTheme")

Result and caveats: ribbonEditorTheme is a visual editor theme, not a feature of another application.

SetLanguage

Public Sub SetLanguage(language As String)

Changes the language ID of the active model; it does not guarantee full IntelliSense for every language.

Use case: Select the active document's language mode.

Editor1.SetLanguage(Editor1.LANG_JSON)
' Additional bundled mode:
Editor1.SetLanguage(Editor1.LANG_setupstudio)

Result and caveats: Language mode selection does not generate projects or provide a compiler.

IsReady

Public Sub IsReady As Boolean

Returns True when the embedded Monaco page has completed initialization.

Use case: Avoid calling editor actions before the WebView has loaded.

If Editor1.IsReady = False Then
    Log("Editor not ready")
    Return
End If

Result and caveats: Especially important before opening tabs or loading JavaScript.

LoadJavaScriptFile

Public Sub LoadJavaScriptFile(Dir As String, FileName As String) As Boolean

Reads and executes a local .js extension after Ready; avoids reloading the same path in one page instance and returns True or False.

Use case: Load an application-owned completion provider from Files.

Private Sub Editor1_Ready
    Dim Ok As Boolean = Editor1.LoadJavaScriptFile(File.DirAssets, "my-suggestions.js")
    Log("Loaded: " & Ok)
End Sub

Result and caveats: The JavaScript file must exist and implement the provider; merely loading it does not generate its logic.

ExecuteJavaScript

Public Sub ExecuteJavaScript(Script As String) As Boolean

Executes JavaScript in the loaded page; returns a Boolean for execution without an exception, not the script's own result.

Use case: Run embedded or externally loaded JavaScript.

Dim Ok As Boolean = Editor1.ExecuteJavaScript("console.log('Hello')")
Log(Ok)

Result and caveats: The Boolean indicates execution without an exception, not the script's return value.

ExecuteJavaScriptWithResult

Public Sub ExecuteJavaScriptWithResult(Script As String) As Object

Evaluates a synchronous JavaScript expression, returning scalars or JSON text for objects and arrays; returns Null before Ready.

Use case: Read a value from a synchronous JavaScript expression.

Dim Value As Object = Editor1.ExecuteJavaScriptWithResult("2 + 3")
Log(Value)

Result and caveats: Result is 5. Complex objects and arrays come back as JSON text.

GetBase

Public Sub GetBase As Pane

Returns the base Pane containing the view.

Use case: Inspect the actual editor container dimensions.

Dim P As Pane = Editor1.GetBase
Log(P.Width & " x " & P.Height)

Result and caveats: Useful for layout troubleshooting or positioning adjacent controls, without editing text.

Public constants and compatibility settings

This version declares these language IDs: LANG_XML, LANG_VBA, LANG_VBNET, LANG_B4X, LANG_JAVASCRIPT, LANG_PYTHON, LANG_SQL, LANG_JSON, LANG_HTML, LANG_CSS, LANG_MARKDOWN, LANG_TYPESCRIPT, LANG_CSHARP, LANG_JAVA, LANG_CPP and LANG_setupstudio. The public UI language IDs are UI_LANGUAGE_ENGLISH and UI_LANGUAGE_SPANISH. These names are part of the public source API; they do not include external application features.

The only declared consumer #Event callbacks are Ready, DocumentActivated and DocumentClosed.

Summary: MonacoEditorView is the editor component. Your host supplies files, formats, application logic and advanced extensions.