A rich-text editor for iOS

Overview

DTRichTextEditor

This project aims to provide a replacement for Apple's severely limited UITextView and to allow for editing attributed strings. It consists of the following parts:

  • DTLoupe - showing a magnifying glass that closesly resembles Apple's built-in original
  • DTWebArchive - this is the way how rich text is represented on the UIPasteboard
  • DTCoreText - parsing HTML, generating NSAttributedString instances, displaying attributed strings, creating HTML
  • DTFoundation - several helper methods

Documentation

View the Change Log about what was recently changed and the Known Issues to learn about current limitations of DTRichTextEditor.

Documentation for DTRichTextEditor can be browsed online or installed in your Xcode Organizer via the Atom Feed URL.

Documentation for DTWebArchive can be browsed online or installed in your Xcode Organizer via the Atom Feed URL.

Documentation for DTFoundation can be browsed online or installed in your Xcode Organizer via the Atom Feed URL.

Follow @cocoanetics on Twitter or subscribe to the Cocoanetics Blog for news and updates.

License

It is open source and covered by a standard 2-clause BSD license. That means you have to mention Cocoanetics as the original author of this code and reproduce the LICENSE text inside your app.

You can purchase a Non-Attribution-License for 150 Euros for not having to include the LICENSE text.

We also accept sponsorship for specific enhancements which you might need. Please contact us via email for inquiries.

Comments
  • unable to compile on Xcode 7

    unable to compile on Xcode 7

    As usual, new Xcode, new issues! Anyway, the following line in DTRichTextEditorView.m is preventing compilation:

    #pragma mark Text Input Delegate and Text Input Tokenizer
    @synthesize inputDelegate;
    

    The error it is producing is:

    The current deployment target does not support automated __weak references
    

    I have attempted this on both an existing project which use to compile fine, and on a completely new project. I have all targets set to iOS 8.0. I have also tried 6.0 and 7.1.

    Do you have any thoughts?

    opened by rdmeyers 13
  • Crash on iOS 9

    Crash on iOS 9

    Long-press for selection is crashing the control with the following message:

    Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'sublayer with non-finite position [inf inf]'
    

    The crash appears to be coming from:

    file: DTLoupeView.m
    method: refreshViewContent
    line: [_targetRootView.layer renderInContext:ctx];
    

    Double tap for selection is not a problem, so the above loupe scenario seems logical.

    This same build works fine on iOS 8.x devices.

    opened by rdmeyers 12
  • iOS voice dictation does not work as expected in DTRichTextEditor - either crashing the app or inserting the spoken text multiple times

    iOS voice dictation does not work as expected in DTRichTextEditor - either crashing the app or inserting the spoken text multiple times

    Hi,

    I am using the rich text editor (DTRichTextEditor) in our project and are experiencing an issue with the use of the voice dictation feature available on the iOS keyboard. The problem results in either a crash or the spoken text being inserted multiple times.

    Here are the repro steps:

    • Embed the rich text editor into a skeleton app that contains a view that holds the DTRichTextEditor component. You can find our example project that does this here.
    • Start the app. Start the voice dictation, but do not saying anything for 3 or 4 seconds. Press done. ** The app crashes with these details: DTRichTextEditorView.m line 2263 -[replaceRange:withText:] DTRichTextEditorView+Manipulation.m line 886 -[replaceRange:withAttachment:inParagraph:] DTRichTextEditorView+Dictation.m line 63 -[dictationRecordingDidEnd]
    • Start the app again. Start the voice dictation and say a few sentences. Hit done. The text inserted is what was said, but repeated multiple times or just partially inserted. It seems quite random.

    We are testing on iOS 8. xcode 6.3 with iOS sdk 8.3

    I'd would like to offer $200 USD to the person who can produce a fix to get voice dictation working properly. Transfer of payment on a successful code review from Oliver and subject to final testing within my project.

    Many thanks, Simon.

    bug $$$ BOUNTY $$$ 
    opened by slm-2015 10
  • Use of the Loupe within the DTRichTextEditor causes a crash

    Use of the Loupe within the DTRichTextEditor causes a crash

    Hi,

    I am using the rich text editor (DTRichTextEditor) in our project and are experiencing an issue with the use of the magnifying glass loupe (i.e. cursor positioning function) that is causing our app to crash.

    Here are the repro steps:

    • Embed the rich text editor into a skeleton app that contains a view that holds the DTRichTextEditor component. You can find our example project that does this here.
    • Start the app. Do not type any letters, just press and hold for a few seconds to bring out the loupe for cursor positioning.
    • Lift your finger press to make the loupe disappear
    • Press and hold again for a few seconds to bring out the loupe again.
    • Bug: This makes the project crash at: [DTLoupeView refreshLoupeContent] / [DTLoupeLayerDelegate displayLayer:]

    The problem can appear on other occasions, but the steps above are the most reliable to reproduce the issue. We are testing on iOS 8. xcode 6.3 with iOS sdk 8.3

    I'd would like to offer $200 USD to the person who can produce a fix for this issue. If the fix requires a reimplementation the magnification using the modern snapshotting methods, I'd understand that this would need more work and would pay $800 USD instead of $200 USD. Transfer of payment on a successful code review from Oliver and subject to final testing within my project.

    Many thanks, Simon.

    bug $$$ BOUNTY $$$ 
    opened by slm-2015 4
  • Text seems not to be rendered in iPhone 14 Pro, iOS 16.

    Text seems not to be rendered in iPhone 14 Pro, iOS 16.

    Text seems not to be rendered in iPhone 14 Pro, iOS 16.

    Here are some details:

    • Works well in iPhone 14 and older devices, only appears in iPhone 14 Pro and later devices.
    • Input some text, turns out that it seems not to be rendered.
    • Switch the app to the background, and open it again, it renders well, but breaks again if you continue inputing.

    What‘s in my mind?

    Seems like DTCoreText did not render properly. If you long press the editorView and DTLoupeView pops out, the text will be rendered well again.

    What I have tried?

    • setNeedsLayout and setNeedsDisplay when editorView did change
    • relayoutText when editorView did change

    Any suggestions will be highly appreciated, thanks for your effort!

    opened by RandomNameForGithub 1
  • Couldn't display after inserting an image

    Couldn't display after inserting an image

    Here is a bug.

    NSAttachmentAttributeName is the variable of system.

    Rewriting DTAttachmentAttributeName leads to the issue that couldn't display after inserting an image with iPhone devices.

    opened by ChiHoc 1
  • fix Demo crash on launch: dyld: Symbol not found: _NSBaseURLDocumentO…

    fix Demo crash on launch: dyld: Symbol not found: _NSBaseURLDocumentO…

    fix Demo crash on launch:

    dyld: Symbol not found: _NSBaseURLDocumentOption Referenced from: /private/var/mobile/Containers/Bundle/Application/5CDC8174-E882-4D78-B020-43FEEA91D699/RTEDemoApp.app/Frameworks/DTRichTextEditor.framework/DTRichTextEditor Expected in: /System/Library/Frameworks/UIKit.framework/UIKit in /private/var/mobile/Containers/Bundle/Application/5CDC8174-E882-4D78-B020-43FEEA91D699/RTEDemoApp.app/Frameworks/DTRichTextEditor.framework/DTRichTextEditor

    opened by cntrump 0
  • Loupe does not orient correctly with editor on iOS 9

    Loupe does not orient correctly with editor on iOS 9

    Rotating the iPad to any direction other than Portrait results in the loupe displaying incorrectly for that orientation. It appears that the Loupe is always in Portrait mode, thus when the device is in Landscape orientation the Loupe displays sideways. (Try selecting some text, that is fun!) Again, the Loupe itself, and the text displayed within it, is always oriented towards the device's Home button.

    opened by rdmeyers 0
  • Changed how the dictation placeholder is managed.

    Changed how the dictation placeholder is managed.

    Previously there was a conflict between the custom placeholder and UIKit's default placeholder. By implementing the UITextInput protocol methods insertDictationResultPlaceholder and removeDictationResultPlaceholder, this conflict should be resolved.

    opened by blundgren 0
  • Crash on <= iOS 5.1.1

    Crash on <= iOS 5.1.1

    The following line crashes the editor on iOS 5.1.1 and older:

    [attributes removeObjectForKey:NSUnderlineStyleAttributeName];

    It is found in the following method:

    - (void)replaceRange:(DTTextRange *)range withText:(id)text

    In the following file:

    DTRichTextEditorView.m

    bug 
    opened by odrobnik 0
  • When we open app first time, view is not going to become first responder, and no keyboard appears even on tap inside view

    When we open app first time, view is not going to become first responder, and no keyboard appears even on tap inside view

    when I open keyboard by taping other defaults textfields and then go to richtextview its works. Even if I close app and open it again then its also works, So issue is keyboard not open first time.

    opened by usman104 0
  • Image size is not correctly handled in DTRichTextEditor

    Image size is not correctly handled in DTRichTextEditor

    Repro steps:

    1. Copy rich text content from a web page with text and image (image should be wider than DTRichTextEditor width).
    2. Paste it to DTRichTextEditor (Parse the copied "Apple Web Archive pasteboard type" with DTWebArchieve, then create NSAttributeString with DTWebArchieve).

    Expected: The image should fit in DTRichTextEditor

    Actual: The image is not property resized, part of the image is cut by DTRichTextEditor bounds.

    opened by ftkghost 0
  • Mentions and hashtags support

    Mentions and hashtags support

    Are you planning to support mentions and hashtags? I mean fire event when user start typing word starting @ or # symbol or change caret position to such word and ability to replace(or insert) autocompleted mention or tag

    opened by yaroslavYS 1
Releases(1.6.12)
  • 1.6.12(Nov 19, 2015)

    • FIXED: Invalid Geometry Crash fix
    • FIXED: Orientation problems under iOS 9

    Announcement: https://www.cocoanetics.com/2015/11/dtrichtexteditor-1-6-12-dtloupe-1-5-8/

    Source code(tar.gz)
    Source code(zip)
  • 1.6.11(Jul 27, 2015)

    • FIXED: Problems with dictation placeholder leading to crash or double text insertion
    • CHANGED: Updated DTLoupe to 1.5.7 - to support bundle in iOS framework

    Announcement: http://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-11/

    Source code(tar.gz)
    Source code(zip)
  • 1.6.10(Jul 7, 2015)

    • FIXED: Crash in DTLoupe
    • FIXED: Crash on iOS <= 5.1.1
    • ADDED: iOS Framework
    • ADDED: Support for CocoaPods frameworks and Modules

    Announcement: https://www.cocoanetics.com/2015/07/dtrichtexteditor-1-6-10/

    Source code(tar.gz)
    Source code(zip)
  • 1.6.9(Jul 7, 2015)

    • FIXED: Dictation failure would lead to subsequent crash
    • FIXED: Loss of attachment attributes causes retina attachments to double in size
    • FIXED: Scroll indicator inset should be zero for left and right sides
    • FIXED: Static Framework missing DTCoreTextMacros.h
    • FIXED: Rotation of editor view controller causes too big bottom content inset
    • FIXED: Content inset was incorrect with hidden keyboard but input view still showing (i.e. hardware keyboard)
    • CHANGED: Updated DTCoreText to 1.6.15
    Source code(tar.gz)
    Source code(zip)
  • 1.6.8(Jul 7, 2015)

  • 1.6.7(Jul 7, 2015)

    • ADDED: Support for tintColor on >= iOS 7
    • FIXED: iOS 8 crash
    • FIXED: Image text attachments missing from HTML output
    • CHANGED: Updated DTCoreText to 1.6.13
    Source code(tar.gz)
    Source code(zip)
  • 1.6.6(Jul 7, 2015)

  • 1.6.5(Jul 7, 2015)

    • ADDED: support for arm64
    • FIXED: Hyperlink would continue to be extended when typing right of it
    • FIXED: Text get corrupted during Dictation on iOS 7
    • FIXED: Setting the attributed text to nil would not remove selection
    • CHANGED: Updated DTCoreText to 1.6.9
    • CHANGED: Updated DTFoundation to 1.6.0
    Source code(tar.gz)
    Source code(zip)
  • 1.6.4(Jul 7, 2015)

    • FIXED: Backwards deleting of list prefixes broken due to a change in iOS 7
    • FIXED: A crash might occur if editing text while drawing of tiles was still going on
    • ADDED: Adjust bottom contentInset to avoid cutting of autocorrect prompt
    • CHANGED: Updated DTCoreText to 1.6.8
    Source code(tar.gz)
    Source code(zip)
  • 1.6.3(Jul 7, 2015)

  • 1.6.2(Jul 7, 2015)

    • FIXED: Removed unnecessary test that would prevent redrawing for "empty" contents
    • FIXED: Tapping on editor would cause incorrect scrolling on long documents if the editor was not first reponder
    • CHANGED: Updated DTCoreText to 1.6.3
    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Jul 7, 2015)

    • FIXED: Pasted plain text missing typing attributes
    • ADDED: DTProcessCustomHTMLAttributes in Demo App parsing options
    • CHANGED: Processing of Custom HTML Attributes is now optional and defaults to off.
    • CHANGED: Updated DTCoreText to 1.6.1
    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Jul 7, 2015)

    • FIXED: Multi-stage text input had issues with input delegate messaging
    • ADDED: Support for custom HTML attributes
    • ADDED: Delegate method for finer control over pasted content.
    • ADDED: More formatting options in Demo app
    • CHANGED: Updated DTCoreText to 1.6.0
    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(Jul 7, 2015)

    • FIXED: Crash on hitting enter key on empty list item right after parsing
    • FIXED: Scroll Indicator inset incorrectly
    • FIXED: Changing typing attributes inside a list would not be preserved on Enter key
    • FIXED: Pasting an image attribute now uses registered DTTextAttachment subclass for IMG tag
    • ADDED: Support for Define context menu option to show dictionary
    • CHANGED: Updated DTCoreText to 1.5.3
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Jul 7, 2015)

    • ADDED: Implemented Support for Ordered and Unordered Lists, editable 1 level
    • CHANGED: Improved handling of nested lists
    • ADDED: Method to set text color for range
    • ADDED: Method to set strikethrough style for range
    • ADDED: HTMLStringWithOptions methods
    • ADDED: Ability to animate between input views (custom keyboards)
    • FIXED: style information would not obey custom CSS stylesheet in textDefaults
    • CHANGED: editing delegate now uses editorView:shouldChangeTextInRange:replacementText: for image pasting
    • ADDED: [DEMO] Formatting View Controller, shown as popover on iPad and input view on iPhone
    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Jul 7, 2015)

    • FIXED: Editor delegate set an out of bounds range when deleting backwards with a selection which starts from position 0.
    • UPDATED: DTCoreText to 1.4.3
    • FIXED: Synthesizing italics for fonts that don't have italic face. e.g. American Typewriter
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Jul 7, 2015)

    • ADDED: A delegation protocol that gives it feature parity with UITextView.
    • FIXED: override typing attributes (like setting bold with no selection) would be reset on a new line
    • FIXED: Autocorrection was broken due to removal of input delegate notification
    • FIXED: Some problems with Undo
    • FIXED: In some circumstances Editor view would scroll horizontally
    • FIXED: Apps using multiple instances of Editor would have Undo problems
    • UPDATED: DTCoreText to 1.4
    Source code(tar.gz)
    Source code(zip)
Owner
Cocoanetics
Cocoanetics
A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view

ZSSRichTextEditor The Editor ZSSRichTextEditor is a beautiful Rich Text WYSIWYG Editor for iOS. It includes all of the standard editor tools one would

Nic Hubbard 3.7k Dec 31, 2022
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

null 8.8k Jan 4, 2023
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing.

RichEditorView RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. Written in Swift 4 Supports iOS 8+ through Cocoapod

Caesar Wirth 1.8k Dec 24, 2022
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

Tatsuya Tobioka 1.2k Jan 1, 2023
A lightning fast, native SwiftUI scratchpad/text editor.

Sedit A lightning fast, native SwiftUI scratchpad/text editor. Sedit (Swift Edit, as in the language and as in fast) is a lightning fast basic text ed

null 5 Jan 28, 2022
Rich Markdown editing control for iOS

MarkdownTextView Rich Markdown Editing for iOS MarkdownTextView is an iOS framework for adding rich Markdown editing capabilities. Support for Markdow

Indragie Karunaratne 676 Dec 7, 2022
An iOS app to turn typed text into images of handwritten text in your own handwriting style.

Text-to-Handwritting © 2021 by Daniel Christopher Long An iOS app to turn typed text into images of handwritten text in your own handwriting style. ht

Daniel Long 11 Dec 29, 2022
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.

twitter-text This repository is a collection of libraries and conformance tests to standardize parsing of Tweet text. It synchronizes development, tes

Twitter 2.9k Dec 27, 2022
Notepad - A fully themeable iOS markdown editor with live syntax highlighting.

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.

Rudd Fawcett 802 Dec 31, 2022
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
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

Kostya 17 Dec 21, 2019
🌍⏩📄 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
Like a SwiftUI ViewBuilder, but for Text

TextBuilder Introduction Text composition in SwiftUI can often be cumbersome, especially when there's logic affecting its format and content. TextBuil

David Roman 180 Dec 26, 2022
Get any text on your screen into your clipboard.

macOCR macOCR is a command line app that enables you to turn any text on your screen into text on your clipboard. When you envoke the ocr command, a "

Marcus S 1.9k Dec 29, 2022
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.

Atributika is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or

Pavel Sharanda 1.1k Jan 8, 2023
Automatic summarizer text in Swift

Overview Reductio is a tool used to extract keywords and phrases using an implementation of the algorithm TextRank. Installation Swift Package Manager

Sergio Fernández 438 Dec 9, 2022
Magnifying glass for text fields

Loupe Magnifying glass for text fields. Apple removed the maginifying glass when selecting texts since iOS 13, this tweak will brings it back. Compati

null 9 Dec 24, 2022
More powerful label, attributed string builder and text parser.

DDText More powerful label, attributed string builder and text parser. DDLabel More powerful label than UILabel, using TextKit. It supports features b

Daniel 16 Nov 8, 2022
Acčento is an easy-to-use tool for adding Czech diacritics to copied text.

Acčento is an easy-to-use tool for adding Czech diacritics to copied text. The app lives in the menu bar and is activated using a global hot key.

Matty Cross 3 Sep 16, 2021