CodeMirror-Swift is a lightweight wrapper of CodeMirror for macOS and iOS

Overview

GitHub

screenshot

GitHub

CodeMirror-Swift is a lightweight wrapper of CodeMirror for macOS and iOS.

Features

  • 🍭 Lightweight CodeMirror wrapper (build 5.52.2)
  • βœ… 100% Native Swift 5 and modern WKWebView
  • πŸ‘‘ Support iOS & macOS
  • 🎧 Built-in addons
  • πŸ”Ž Customizable (Addon, Themes, Modes...)
  • πŸ“• Dozen built-in themes and syntax highlight modes
  • ⚑️ Ready to go

Apps that uses CodeMirror-Swift

Proxyman screenshot

Modern and Delightful HTTP Debugging Proxy for macOS, iOS and Android ⚑️ β€’ 🌎 https://proxyman.io

Installation

SPM

The easiest way to use this package is to add https://github.com/ProxymanApp/CodeMirror-Swift to your SPM dependency.

Manually

  1. Manually copy CodeMirrorWebView.swift and CodeMirrorView.bundle to your project.
  2. Customize to fit your need on index.html
  3. Set mode and Content
let url = Bundle.main.url(forResource: "data", withExtension: "json")!
let content = try! String(contentsOf: url)
codeMirrorView.setMimeType("application/json")
codeMirrorView.setContent(content)

Example

  • Run ./examples/CodeMirror-Swift-Example.xcodeproj

How to use addons?

  1. Read CodeMirror Documentation
  2. Enable your plugins in index.html

How to add new themes?

  1. Download CodeMirrror themes and put it on the folder Sources/CodeMirrorView.bundle/Contents/Resources/theme
  2. Load your theme in index.html
  3. Change by using codeMirrorView.setThemeName("material.css")

Credit

License

CodeMirror-Swift is copyright 2020 Proxyman and available under MIT license. See the LICENSE file in the project for more information.

You might also like...
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift.
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift.

PrediKit A Swift NSPredicate DSL for iOS & OS X inspired by SnapKit, lovingly written in Swift, and created by that weird dude at KrakenDev. If you're

Swift String Validator. Simple lib for ios to validate string and UITextFields text for some criterias

Swift String validator About Library for easy and fastest string validation based on сciterias. Instalation KKStringValidator is available through Coc

Powerful text framework for iOS to display and edit rich text.
Powerful text framework for iOS to display and edit rich text.

YYText Powerful text framework for iOS to display and edit rich text. (It's a component of YYKit) Features UILabel and UITextView API compatible High

String (and more) validation for iOS

Swift Validators πŸ”Ά String validation for iOS. Contents Installation Walkthrough Usage Available validators License ReactiveSwift + SwiftValidators Wa

A simple and customizable Markdown Parser for Swift
A simple and customizable Markdown Parser for Swift

MarkdownKit MarkdownKit is a customizable and extensible Markdown parser for iOS and macOS. It supports many of the standard Markdown elements through

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

PhoneNumberKit Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Features F

OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR

OysterKit A Swift Framework for Tokenizing, Parsing, and Interpreting Languages OysterKit enables native Swift scanning, lexical analysis, and parsing

A Cross-Platform String and Regular Expression Library written in Swift.

Guitar 🎸 A Cross-Platform String and Regular Expression Library written in Swift. About This library seeks to add common string manipulation function

Fully open source text editor for iOS written in Swift.
Fully open source text editor for iOS written in Swift.

Edhita Fully open source text editor for iOS written in Swift. http://edhita.bornneet.com/ What Edhita means? Edhita (Romaji) == エディタ (Katakana) == Ed

Comments
  • SwiftUI Representable

    SwiftUI Representable

    Hi,

    Any idea how to package this view into a Representable for SwiftUI?

    Here's what I tried

    import Foundation
    import SwiftUI
    
    
    struct CodeView: NSViewRepresentable {
      
      func makeNSView(context: Context) -> CodeMirrorWebView {
        let codeMirrorView = CodeMirrorWebView()
        codeMirrorView.translatesAutoresizingMaskIntoConstraints = false
        return codeMirrorView
      }
      
      func updateNSView(_ codeMirrorView: CodeMirrorWebView, context: Context) {
        let url = Bundle.main.url(forResource: "data", withExtension: "json")!
        let content = try! String(contentsOf: url)
        codeMirrorView.setMimeType("application/json")
        codeMirrorView.setContent(content)
      }
    }
    
    opened by marshallino16 8
  • Error setContent

    Error setContent

    Hi,

    When a String contains certain characters, setContent() doesn't work.

    To test :

    "#Title\n``` test ```"

    or

    "FROM spritsail/alpine-cmake\n\nWORKDIR /home\n\n# Global env\nRUN apk update \\\n apk upgrade \\\n apk add git tmux build-base curl bash\n\n\n# Dpkg\nRUN apk add dpkg pkgconfig\nRUN ls -a /var/lib/dpkg\nRUN touch /var/lib/dpkg/status\n\nRUN apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community --repository http://dl-3.alpinelinux.org/alpine/edge/main\n\nRUN apk add --update alpine-sdk\n\nRUN apk add glib libxml2 \\\n libxslt fftw \\\n gettext gtk+2.0 \\\n python lcms \\\n imagemagick-dev openexr \\\n libwebp orc tiff poppler-glib librsvg libgsf\n\nRUN apk add --virtual vips-dependencies build-base \\\n zlib-dev libxml2-dev glib-dev gobject-introspection-dev \\\n libjpeg-turbo-dev libexif-dev lcms2-dev fftw-dev giflib-dev libpng-dev \\\n libwebp-dev orc-dev tiff-dev poppler-dev librsvg-dev libgsf-dev openexr-dev \\\n py-gobject3-dev flex bison\n\n\n# VIPS\nRUN \\\n mkdir vips &&\\\n pwd &&\\\n ls -a &&\\\n cd vips &&\\\n wget -c https://github.com/jcupitt/libvips/releases/download/v8.5.9/vips-8.5.9.tar.gz &&\\\n tar xzvf vips-8.5.9.tar.gz &&\\\n cd /home/vips/vips-8.5.9 &&\\\n dpkg --configure -a &&\\\n ./configure &&\\\n make &&\\\n make install\n\n\n# PATH\nENV PATH \"${PATH}:/usr/local/lib/\"\n\n\n# FFMEG\nRUN apk add g++ ffmpeg ffmpeg-dev ffmpeg-libs\n\n\n# Tifig\nRUN \\\n cd /home/ &&\\\n git clone --recursive https://github.com/monostream/tifig.git &&\\\n mkdir tifig/build && cd tifig/build &&\\\n cmake .. &&\\\n make\n\nRUN cp /home/tifig/build/tifig /usr/local/bin/tifig\n\n\n\n"

    Result :

    Screen Shot 2020-08-26 at 3 33 22 PM

    opened by marshallino16 5
  • Update CodeMirror Bundle with Proxyman 3.5.2

    Update CodeMirror Bundle with Proxyman 3.5.2

    Changelog

    • Update CodeMirror Bundle with Proxyman 3.5.2

    New features

    • Toggle Search Bar
    • Auto-complete for HTTP Message, Headers
    • Better data serialization (Don't need to serialize to Hex code anymore)
    • Better font size
    opened by NghiaTranUIT 0
  • Make the package installable via SPM

    Make the package installable via SPM

    Add SPM support so you no longer have to drag and drop Bundle manually.

    I decided not to add SwiftUI package since there is already a fork out there that does it.

    opened by khoi 0
Releases(1.0.0)
Owner
Proxyman
Modern and Delightful Web Debugging Proxy for macOS, iOS and Android ⚑️
Proxyman
VEditorKit - Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)

VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want.

David Ha 471 Dec 27, 2022
SZMentionsSwift is a lightweight mentions library for iOS.

SZMentionsSwift is a lightweight mentions library for iOS. This library was built to assist with the adding, removing and editing of a mention within a textview.

Steven Zweier 122 Dec 12, 2022
A comprehensive, lightweight string extension for Swift

SwiftString SwiftString is a lightweight string extension for Swift. This library was motivated by having to search StackOverflow for common string op

Andrew Mayne 1.6k Dec 30, 2022
πŸŽ— Super lightweight ISO8601 Date Formatter in Swift

ISO8601 ❀️ Support my apps ❀️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut mana

Khoa 19 May 12, 2020
Lightweight library to set an Image as text background. Written in swift.

![](https://img.shields.io/badge/Swift 2-compatible-4BC51D.svg?style=flat-square) Simple and light weight UIView that animate text with an image. Demo

Lucas Ortis 552 Sep 9, 2022
A lightweight fuzzy-search library, with zero dependencies

Fuse What is Fuse? Fuse is a super lightweight library which provides a simple way to do fuzzy searching. Usage Example 1 let fuse = Fuse() let result

Kiro Risk 864 Dec 29, 2022
πŸŒβ©πŸ“„ Convert ISO8859 1-16 Encoded Text to String in Swift. Supports iOS, tvOS, watchOS and macOS.

ISO8859 Convert ISO8859 1-16 Encoded Text to String in Swift. Usage let encoding = ISO8859.part1 let string = String([...], iso8859Encoding: encoding)

Devran Cosmo Uenal 18 Jan 2, 2023
A library for formatting strings on iOS and macOS

Sprinter Introduction What? Why? How? Usage Installation Integration Localization Thread Safety Advanced Usage Introduction What? Sprinter is a librar

Nick Lockwood 168 Feb 6, 2022
Simple, keyboard-first, markdown note-taking for MacOS

QuickDown Simple, keyboard-first, markdown note-taking for MacOS Main Features Global Hotkey: ⌘-βŒ₯-N Save Note: ⌘-S Launch on Login (Optional) Addition

Alexis Rondeau 50 Nov 29, 2022
Markdown parsing and rendering for iOS and OS X

CocoaMarkdown Markdown parsing and rendering for iOS and macOS CocoaMarkdown is a cross-platform framework for parsing and rendering Markdown, built o

Indragie Karunaratne 1.2k Dec 12, 2022