Giter VIP home page Giter VIP logo

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

benbahrenburg avatar tuesleep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

leotextview's Issues

Bold & Italic in the same time

HI ! Its possible to have bold & italic in the same time ?
How can i create new style ? Like Super title who is bigger, or others
thanks

Bold & Italic font not set correctly when setting textView.attributedText

Have two LEOTextViews (Non-editable view and editable view).

First subclassed in Storyboard, with the ViewController written in Obj-C.
Second is initiated programmatically, with the ViewController written in Swift.

Write text and set to bold / italic in the second VC (Swift) and segue back to first VC (Obj-C). All formatting copies perfectly. Then try to segue back to the second VC (Swift) to edit again, and bold & italics are reverted back to normal text. Formatting not copied for some reason...although bullet points are copying correctly, just not bold & italic, which is strange since it copied over perfectly the first time to the non-editable view.

In both cases I'm just doing textView.attributedText = otherViewController.textView.attributedText

Bold & Italic (both)

Is there a way to apply both to selected text? Setting InputFontMode will overwrite one or the other

Additional features

Can't believe I've found this. Any plans on adding more features like highlighting, etc?

What is the proper way to initialize LeoTextView if using Storyboard?

nck_textStorage is nil when trying to call

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

given it is initialized in your public init method.

also, only changeCurrentParagraphToOrderedListWithOrderedList is visible publicly

Swift 3.2 or Swift 4.0 Support

Hello,
Are there any plans to support Swift 3.2 or Swift 4.0? I did a quick test upgrade and found the changes to NSAttributedString seems to have an impact. Have you or anyone else had any luck upgrading?

Swift 3 Support

Is a great project. Any thoughts on updating to provide Swift 3 support?

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.