• Stars
    star
    860
  • Rank 50,901 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[iOS] A fully themeable markdown editor with live syntax highlighting.

Version Carthage compatible CocoaPods compatible

Usage

let notepad = Notepad(frame: view.bounds, themeFile: "one-dark")
view.addSubview(notepad)

Notepad is just like any other UITextView, but you need to use the convenience initializer in order to use the themes. To create a new theme, copy one of the existing themes and edit the JSON.

Check out the Xcode project for an example. For full documentation read the code.

Extending an Existing Text View with Notepad Features

If you cannot work with the Notepad subclass directly for some reason, you can set up an existing UITextView or NSTextView on your own.

For iOS, you have to initialize all TextKit components yourself. Take the following as a blueprint where you can swap in custom objects:

class ViewController: UIViewController {
    var textView: UITextView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        let containerSize = CGSize(width: self.view.bounds.width, height: CGFloat.greatestFiniteMagnitude)
        let container = NSTextContainer(size: containerSize)
        container.widthTracksTextView = true

        let layoutManager = NSLayoutManager()
        layoutManager.addTextContainer(container)

        let storage = Storage()
        let theme = Theme("one-dark")
        storage.theme = theme
        storage.addLayoutManager(layoutManager)

        let editor = UITextView(frame: self.view.bounds, textContainer: container)
        editor.backgroundColor = theme.backgroundColor
        editor.tintColor = theme.tintColor
        editor.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    }
}

And for macOS:

class ViewController: NSViewController {
    @IBOutlet var textView: NSTextView!
    let storage = Storage()

    override func viewDidLoad() {
        super.viewDidLoad()

        let theme = Theme("one-dark")
        storage.theme = theme
        textView.backgroundColor = theme.backgroundColor
        textView.insertionPointColor = theme.tintColor
        textView.layoutManager?.replaceTextStorage(storage)
    }
}

Themes

Take a look at all of the themes and swatches when choosing the theme for your Notepad, or as inspiration for a new one.

You can find all of the raw themes in the themes folder, and the file names are case-sensitive.

Custom Regex

Using regex, you can match custom patterns in your Notepad editor by passing a regex attribute in your theme. For example, one that highlights Twitter handles in a teal color:

"handle": {
  "regex": "[@οΌ ][a-zA-Z0-9_]{1,20}",
  "color": "#78ddd5"
}

Installation

Copy the source from the Notepad folder to your project, or add Notepad to your Podfile if you're using CocoaPods.

More Repositories

1

RFKeyboardToolbar

[iOS] Add customized buttons and toolbars to your UITextInputs.
Objective-C
422
star
2

RFMarkdownTextView

[Deprecated, iOS] Use Notepad instead: https://github.com/ruddfawcett/Notepad.
384
star
3

Push4Parse

[Deprecated, iOS] Push4Parse application previously available on the App Store.
Objective-C
65
star
4

RFGravatarImageView

[Deprecated] Simple UIImageView subclass to load Gravatars.
Objective-C
63
star
5

RFRotate

Drop in rotations for your iOS project. Support for blocks.
Objective-C
52
star
6

RFTapEditLabel

UILabel subclass with UIAlertView editing. Support for masked passwords and placeholders.
Objective-C
33
star
7

reposs

Clean and simple repository size badge, courtesy of shields.io.
PHP
26
star
8

EasyDefaultImages

A simple project to quickly generate Default launch images for your iOS applications. Super simple and easy to use.
Objective-C
24
star
9

hanziDB.csv

List of Chinese characters ordered by frequency rank (from most common to least common). Based on Jun Da's Modern Chinese Character Frequency List. Using simplified characters.
Python
19
star
10

Habitica.php

A PHP class for the Habitica API.
PHP
17
star
11

RFMathTextField

A simple validator/equation answerer.
Objective-C
17
star
12

Beamy

[iOS] Send messages from one device to another using Bluetooth LE technology.
Swift
13
star
13

HabitRPG-GitHub

Connect and sync your HabitRPG and GitHub accounts.
PHP
10
star
14

Screentaker-Plugins

A collection of effects (plugins) for the Screentaker app on the Mac App Store.
Objective-C
7
star
15

UIColor-FlatUIColors

Simple UIColor category from flat ui colors found here: http://flatuicolors.com/.
Objective-C
6
star
16

Scrollometer

Simple way to track how far users scroll.
Swift
4
star
17

charticons

A graph and chart themed icon set. Released under a Creative Commons Attribution 4.0 International License.
4
star
18

octodex-scraper

The backend for the unofficial OctodexAPI. This repo is a PHP scraper/api for GitHub's Octodex website, which can be found at http://octodex.github.com.
PHP
4
star
19

lunchr-ios

Suggests random lunch destinations based on Foursquare lists.
Swift
3
star
20

itunestopx

Simple site to show the top x songs from iTunes using the search API.
PHP
2
star
21

PHPush

PHPush: easily push from your project, with simple POSTs
PHP
2
star
22

hoot-ios

Hoot is a simple command line tool to alert you when a Terminal process has finished, with a push notification right to your device! This is the accompanying iOS app.
Objective-C
2
star
23

StatBars

Simple side bars for simple numbers.
PHP
1
star
24

random-gravatar

Changes the OctodexAPI profile's Gravatar every day to a new Octocat using Gravatar's XML-RPC API.
PHP
1
star
25

UIColor-SocialColors

Simple UIColor category from social colors found here: http://www.flatui.net/social-colors/
Objective-C
1
star
26

SPTextFieldCell

Easily use UITextFields in UITableViewCells.
Objective-C
1
star
27

MyPebbleFaces

Code from app I made in ninth grade. Reached #1 free app in Utilities at one point in App Store.
Objective-C
1
star
28

polideo

HTML
1
star
29

DownloadCompressor

Download file to server, compress it, and generate a unique download link.
PHP
1
star
30

octodex.py

A Python wrapper for the Octodex API.
Python
1
star
31

lazarus

For blackout poetry. An aggregate news source API, which pulls articles from various online news outlets.
JavaScript
1
star
32

sandbox

Repository of code that I am learning and/or other snippets I am working on.
Java
1
star
33

peacenow-settlements

Data scraped for CSC630 classmate.
HTML
1
star
34

Swift-Shorthand

An almost ported Swift implementation of Objective-Shorthand.
Objective-C
1
star
35

euler

A collection of Project Euler solutions.
Java
1
star
36

slashcmds

Some publicly available slash commands (e.g. /weather) for Slack. More to come.
JavaScript
1
star
37

octodex.objc

An Objective-C wrapper for the Octodex API.
Objective-C
1
star
38

paschedules-chrome

PASchedules Chrome extension
JavaScript
1
star
39

ios-openapi-gen

Generate iOS client API wrappers from Swagger's OpenAPI spec.
Python
1
star
40

Dictionary.java

A reimplementation of HashMap using ArrayLists.
Java
1
star
41

agenda

A simple todo-list app written in Swift. (Written for a tutorial.)
Swift
1
star
42

hoot

Hoot is a simple command line tool to alert you when a Terminal process has finished, with a push notification right to your device!
Ruby
1
star
43

hedwig

Hedwig is middleware for Hoot, the command line tool that sends push notifications to your phone from the console.
JavaScript
1
star
44

octodex.php

A PHP wrapper for the Octodex API.
PHP
1
star
45

octodex.rb

A Ruby wrapper for the Octodex API.
Ruby
1
star
46

swift

Random projects and experiments written in Swift.
Swift
1
star
47

UITabBarItem-Selected

Easy to use to init tab bar items, esp. helpful when using http://www.glyphish.com.
1
star
48

study-savior

Swift
1
star
49

StickerKit

Sticker share kit from 2020, may not be up to date
Swift
1
star
50

rolodex

Track attendees at meetups!
JavaScript
1
star
51

Gotham

Gotham is a text based console game written in Java. It is currently a WIP.
Java
1
star
52

EmojiKit

Use custom emoji in your app with ease. Currently WIP.
Objective-C
1
star
53

ns-freshman-survey

Early this September, The Phillipian, vol. CXXXIX, and The Exonian, vol. CXXXVIII, collaborated to conduct the first-ever survey of all incoming freshmen at Andover and Exeter.
JavaScript
1
star