SwiftyMonaco is a wrapper for Monaco Editor from Microsoft.
There is a simple example of how to use SwiftyMonaco
import SwiftUI
struct EditorView: View {
@State var text: String
var body: some View {
SwiftyMonaco(text: $text)
}
}
Also you can use SwiftyMonaco
with syntax highlighting by passing SyntaxHighlight
rule:
import SwiftUI
struct EditorView: View {
@State var text: String
var body: some View {
SwiftyMonaco(text: $text)
.syntaxHighlight(.systemVerilog)
}
}
SyntaxHighlight
sSyntaxHighlight |
Language |
---|---|
.swift |
Swift |
.cpp |
C++ |
.systemVerilog |
Verilog/SystemVerilog |
SyntaxHighlight
?To create your own SyntaxHighlight
you can use available initializers:
// With JS file containing syntax definition for Monarch
let syntax = SyntaxHighlight(title: "My custom language", fileURL: Bundle.module.url(forResource: "lang", withExtension: "js", subdirectory: "Languages")!)
// With a String containing syntax definition for Monarch
let syntax = SyntaxHighlight(title: "My custom language", configuration: "...")
You can create your own syntax at Monaco Editor Monarch website
SwiftyMonaco
automatically detects interface theme changes and updates Monaco Editor theme according to it without dropping the current state of the editor.
link |
Stars: 1 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco