GithubHelp home page GithubHelp logo

dasmihir20 / leotextview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tuesleep/leotextview

0.0 0.0 0.0 24.58 MB

๐ŸฌA high-performance rich editor develop with swift on iOS platform, based on TextKit.

License: MIT License

Swift 97.34% Ruby 2.66%

leotextview's Introduction

LEOTextView

CI Status Version License Platform

LEOTextView is a very high-performance rich editor. Because it's a subclass of UITextView, not UIWebView. All of code by TextKit framework.

Features

  • Bold Text
  • Italic Text
  • Unordered List
  • Ordered List
  • List auto indentation
  • Undo and Redo
  • Rich Text Copy & Paste

Requirements

Xcode 8.3 or newer

Tag Swift
<= 0.4.x 2.2
>= 0.5.0 3.0
>= 0.7.0 4.0

Usage

Not extends any class, not EditorController and so on...

You can embed LEOTextView to anywhere that you want.

// Init TextView
let textView = LEOTextView(frame: self.view.bounds, textContainer: NSTextContainer())

// If you want to use built-in toolbar, call it.
textView.enableToolbar()

// add to View
self.view.addSubview(textView)

Done.

UITextViewDelegate

Some feature I use delegate method, so LEOTextView is delegate self. And provide another delegate property named leo_delegate

public var leo_delegate: UITextViewDelegate?

Public methods

Type transform

public func changeCurrentParagraphTextWithInputFontMode(mode: LEOInputFontMode)
public func changeSelectedTextWithInputFontMode(mode: LEOInputFontMode)

public func changeCurrentParagraphToOrderedList(orderedList isOrderedList: Bool, listPrefix: String)

Text attributes persistent

Get JSON by

public func textAttributesJSON() -> String

This method return a JSON string that contains all attributes needs to reload.

A unordered list

  • A
  • B
  • C

convert to JSON look like:

{
  "text": "- A\n- B\n- C",
  "attributes": [
  {
    "location": 0,
    "length": 11,
    "fontType": "normal",
    "name": "NSFont"
  },
  {
    "location": 0,
    "length": 11,
    "listType": 3,
    "name": "NSParagraphStyle"
  }
  ]
}

Set JSON and display to UITextView by

public func setAttributeTextWithJSONString(jsonString: String)

Or just set attributes only by

public func setAttributesWithJSONString(jsonString: String)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Cocoapods

LEOTextView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "LEOTextView"

Author

Tuesleep, [email protected]

License

LEOTextView is available under the MIT license. See the LICENSE file for more info.

leotextview's People

Contributors

tuesleep avatar benbahrenburg 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.