6e38ccd310
fix: use automaticLayout instead of manually handling window.resize which causes buggy initial states |
||
---|---|---|
GenerateMonacoTypings | ||
MonacoEditorComponent | ||
MonacoEditorTestApp | ||
MonacoEditorTestApp.Shared | ||
MonacoEditorTestApp.UWP | ||
MonacoEditorTestApp.Wasm | ||
build | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.vsts-ci.yml | ||
LICENSE | ||
MonacoEditorComponent.sln | ||
README.md | ||
changelog.md | ||
gitversion.yml | ||
global.json | ||
install-dependencies.ps1 | ||
nuget.config |
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:
- Two-way Text Binding
- Code Language for Syntax Highlighting
- Stand Alone Code Editor Options
- Markers and Decorations (See #35)
- Actions and Commands
- Basic Language Features
- CodeLens (onDidChange not supported)
- Color
- CompletionItem (IntelliSense, Snippets)
- Hover
- Basic ITextModel Support
- KeyDown Events
- Responds Appropriately to Programmatic Focus Events
- Render Aware: Only displays once Loading is complete.
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:
- Keep API names and patterns as closely mapped as possible to enable straight-forward re-usage of existing TypeScript examples.
- 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 theCodeEditor
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 theAsyncInfo.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 correspondingICssStyle
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