A Windows Runtime Component wrapper around the web-based Monaco Editor.
Перейти к файлу
Jérôme Laban 6e38ccd310
Merge pull request #27 from ramezgerges/automaticlayout
fix: use automaticLayout instead of manually handling window.resize which causes buggy initial states
2024-07-19 08:26:42 -04:00
GenerateMonacoTypings Update TypedocConverter reference 2020-04-03 11:38:12 -07:00
MonacoEditorComponent fix: use automaticLayout instead of manually handling window.resize which causes buggy initial states 2024-07-17 13:33:21 +03:00
MonacoEditorTestApp chore: Bump to uno 5 dev 2023-06-27 13:47:34 -04:00
MonacoEditorTestApp.Shared feat!: Move to WinUI, add Uno 5 support 2023-06-27 13:47:34 -04:00
MonacoEditorTestApp.UWP chore: Bump to uno 5 dev 2023-06-27 13:47:34 -04:00
MonacoEditorTestApp.Wasm chore: Update to uno 5 stable 2023-10-31 15:29:32 -04:00
build ci: Adjust net runtime 2023-05-17 14:57:52 -04:00
.editorconfig Suppress XML Comment Warnings 2020-03-28 15:55:24 -07:00
.gitattributes Add .gitignore and .gitattributes. 2017-07-21 21:25:06 -07:00
.gitignore Fixes #34 Add scripts to auto-generate type definitions via TypedocConverter tool 2020-03-31 00:52:34 -07:00
.vsts-ci.yml chore: Bump to uno 5 dev 2023-06-27 13:47:34 -04:00
LICENSE Retrieve Languages Supported 2017-07-22 23:01:23 -07:00
MonacoEditorComponent.sln feat!: Move to WinUI, add Uno 5 support 2023-06-27 13:47:34 -04:00
README.md Resolves #38 Add CodeLens Providers 2020-04-06 01:29:26 -07:00
changelog.md Change CommandHandler to accept parameters 2020-04-05 18:56:32 -07:00
gitversion.yml feat!: Move to WinUI, add Uno 5 support 2023-06-27 13:47:34 -04:00
global.json chore: Update MSBuild SDK Extras 2020-11-02 13:58:49 -05:00
install-dependencies.ps1 upgrade to monaco 0.20.0 2020-02-12 22:03:01 +08:00
nuget.config chore: Bump to uno 5 dev 2023-06-27 13:47:34 -04:00

README.md

Monaco Editor UWP

A Windows Runtime Component wrapper around the web-based Monaco Editor. This allows the Monaco Editor to be more easily consumed directly in XAML for C# UWP based projects.

This project is not affiliated with the Monaco team and is provided for convenience. Please direct issues related to the use of this control wrapper to this repository.

This control is still in an early alpha state. Currently, every minor version change may signal breaking changes.

Supported Features

The following Monaco Editor features are currently supported by this component bridge:

Usage

A NuGet Package is provided:

Install-Package Monaco.Editor -Version 0.9.0-beta

Look at the TestApp for current usage and basic examples. See changelog for more info.

Monaco API Notes

This project maintains two tenants with regards to the core web-based Monaco API:

  1. Keep API names and patterns as closely mapped as possible to enable straight-forward re-usage of existing TypeScript examples.
  2. Swap types to existing C#/WinRT based ones for easier interop with the calling application.

Effectively, we want this project to be as easy to integrate with existing C#/WinRT skills/knowledge as possible as well as providing a similar enough API that it's easy to still utilize any existing knowledge bases for the Monaco API.

There are some common caveats though called out here:

  • Pretty much all functions are asynchronous and end with the C# Async naming suffix convention.

  • The Monaco.Languages namespace is mapped through the CodeEditor instance, so call <Editor Instance>.Languages.* for any of those APIs. E.g.

    // JavaScript
    monaco.languages.registerColorProvider("colorLanguage", ...
    
    // C#
    var MonacoEditor = new CodeEditor(); // Either done through XAML or elsewhere once.
    ...
    MonacoEditor.Languages.RegisterColorProviderAsync("colorLanguage", ...
    

    This is required due to need to execute the code within a particular WebView instance hosting the Monaco control, there is no global execution context. Therefore, you must register any language providers individually to each CodeEditor instance.

  • Returns using IAsyncOperation<T> usually need to use the AsyncInfo.Run system interop helper. See Issue #45.

  • Uri class is not mapped yet to a built-in C# type. See Issue #33.

  • Keyboard Events can't use the built-in system KeyRoutedEventArgs class as it is sealed.

  • Decorations use CSS class names in Monaco, this has been ported to be a strongly-typed abstraction per type of styled element required for use of decorations. Each style type has a set or properties using common WinRT types associated with styling UI elements like SolidColorBrush, TextDecoration, FontStyle, etc... If a property is missing that you require, please open an issue or PR to modify the corresponding ICssStyle implementations.

Build Notes

Built using Visual Studio 2019 for Windows 10 16299 and above.

The released complete Monaco v0.20.0 build is used as a reference, this is not included in this repository and can be downloaded from the Monaco site. The contents of its uncompressed 'package' directory should be placed in the MonacoEditorComponent/monaco-editor directory. The install-dependencies.ps1 PowerShell script can install this for you automatically.

In order to re-generate C# typings from a version of Monaco, see the GenerateMonacoTypings Node.js project readme here.

License

MIT