/CodeViewer

A custom code editor SwiftUI view

Primary LanguageJavaScriptMIT LicenseMIT

CodeViewer

platform

CodeViewer is a custom code editor SwiftUI view, which wrap around the ace editor.

image image

Features

  • Darkmode, lightmode adopt automatically
  • Syntax highlighting for over 110 languages (TextMate/Sublime Text.tmlanguage files can be imported)
  • Over 20 themes (TextMate/Sublime Text .tmtheme files can be imported)
  • Support SwiftUI

Usage

import SwiftUI
import CodeViewer

struct ContentView: View {
    @State private var json = ""
    
    var body: some View {
        CodeViewer(
            content: $json,
            mode: .json,
            darkTheme: .solarized_dark,
            lightTheme: .solarized_light,
            isReadOnly: true,
            fontSize: 54
        )
        .onAppear {
            json = """
            {
                "hello": "world"
            }
            """
        }
    }
}

Requirement

  • iOS >= v13
  • macOS >= v10.15