Code Monkey home page Code Monkey logo

blazaco's Introduction

Patched Blazaco

I built this after writing my own ShareX (image / code / link) API in Blazor, just seeing what all it's capable of, and was looking for a way to style the code page. Found the BlazorBits but noticed it wasn't on Nuget anymore and was outdated, so decided to build an updated version. Any feedback would greatly be appreciated.

Blazaco dependencies

  • Visual Studio 16.1.0 Preview 3
  • .NET Core 3.0.100-preview5-011568

Demo

Installation

  • Add the NuGet package to your Blazor Client project
dotnet add package Blazaco

// or

Install-Package Blazaco

Usage

  • Add the following to your root _ViewImports.cshtml file, or any file you want to use the Monaco Editor
@using Blazaco
@using Blazaco.Editor
@using Blazaco.Editor.Options // Only needed if you want to change defaults
  • Add the MonacoEditor Component anywhere in your file
<MonacoEditor class="editor-class" ref="_editor" Model="@_editorModel" />
  • Add your MonacoEditor and EditorModel fields to your @functions
private EditorModel _editorModel { get; set; }
private MonacoEditor _editor;
  • Configure Blazaco settings in your OnInit or OnInitAsync
_editorModel = new EditorModel(); // Uses defaults

// or

var options = new EditorOptions()
{
    Value = "// Your Code Here!",
    Language = "csharp",
    Theme = "vs-dark"
};

_editorModel = new EditorModel(options);

// or

var options = new EditorOptions()
{
	Value = "// Your Code Here!",
	Language = "csharp",
	Theme = "vs-dark",
	Minimap = new MinimapOptions()
	{
		Enabled = false
	}
};

_editorModel = new EditorModel(options);

// or

_editorModel = new EditorModel(new EditorOptions()
{
	Value = "// Your Code Here!",
	Language = "csharp",
	Theme = "vs-dark",
	Minimap = new MinimapOptions()
	{
		Enabled = false
	}
});

Note: You can configure the Constructor Options based on these options

  • Add the monaco-editor folder and link the Javascript and CSS files in your index.html file
<head>
    <link rel="stylesheet" data-name="vs/editor/editor.main" href="monaco-editor/min/vs/editor/editor.main.css">
</head>
<body>
    <app></app>
    ...
    <script>var require = { paths: { 'vs': 'monaco-editor/min/vs' } };</script>
    <script src="monaco-editor/min/vs/loader.js"></script>
    <script src="monaco-editor/min/vs/editor/editor.main.nls.js"></script>
    <script src="monaco-editor/min/vs/editor/editor.main.js"></script>
    <script type="blazor-boot">
    </script>
	...
</body>

Interop

Currently I've only created a handful of Methods for Interop, as that's all I really need for my purposes. Current plans are to expand the Interop to allow more integration of the Monaco Editor API and make it more fleshed out.

  • InitializeEditor
    • Internal Method to Initialize the Monaco Editor with default or set settings
  • GetValue
    • Gets the Value from the Monaco Editor
  • SetValue
    • Sets the Value for the Monaco Editor to display
  • SetTheme
    • Sets the Theme for the Monaco Editor
  • Layout
    • Instructs the editor to remeasure its container. This method should be called when the container of the editor gets resized

Change log

Copyright

Copyright (c) 2019 Kyle Undefined under the MIT License.

Note

This is just a patched Version of https://github.com/Kyle-Undefined/Blazaco with all Merge Request merged and maybe other improvements. Enjoy!

blazaco's People

Contributors

danielabbatt avatar derekchasse avatar k0dep avatar kyle-undefined avatar sirjson avatar stefangordon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.