{"id":13461958,"url":"https://github.com/will-lumley/RichEditor","last_synced_at":"2025-03-24T23:32:01.639Z","repository":{"id":52214334,"uuid":"237337545","full_name":"will-lumley/RichEditor","owner":"will-lumley","description":"The macOS RichEditor library allows you to turn a native NSTextView into a full blown WYSIWYG editor.","archived":false,"fork":false,"pushed_at":"2024-11-22T11:39:45.000Z","size":70121,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-23T15:46:20.351Z","etag":null,"topics":["macos","nstextview","rich-text-editor","richeditor","spm","swift","wysiwy"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/will-lumley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["will-lumley"]}},"created_at":"2020-01-31T01:11:27.000Z","updated_at":"2024-12-04T03:24:58.000Z","dependencies_parsed_at":"2024-01-21T22:49:49.416Z","dependency_job_id":"acf13d8b-dc85-4c36-9335-d471a89b827b","html_url":"https://github.com/will-lumley/RichEditor","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.24528301886792447","last_synced_commit":"09c1b9e9a2cdf178ea40c70d847c4335dacbb561"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will-lumley%2FRichEditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will-lumley%2FRichEditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will-lumley%2FRichEditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will-lumley%2FRichEditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/will-lumley","download_url":"https://codeload.github.com/will-lumley/RichEditor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245372193,"owners_count":20604487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macos","nstextview","rich-text-editor","richeditor","spm","swift","wysiwy"],"created_at":"2024-07-31T12:00:36.193Z","updated_at":"2025-03-24T23:32:01.633Z","avatar_url":"https://github.com/will-lumley.png","language":"Swift","funding_links":["https://github.com/sponsors/will-lumley"],"categories":["UI","Swift"],"sub_categories":[],"readme":"![RichEditor: Customisable NSTextview WYSIWYG Editor](https://raw.githubusercontent.com/will-lumley/RichEditor/main/RichEditor.png)\n\n# RichEditor\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/will-lumley/RichEditor/actions/workflows/BuildTests.yml/badge.svg?branch=main\" alt=\"macOS - CI Status\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/apple/swift-package-manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat\" alt=\"SPM Compatible\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Swift-5.5-orange.svg\" alt=\"Swift 5.5\"\u003e\n  \u003ca href=\"https://bsky.app/profile/will-lumley.bsky.social\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Bluesky-0285FF?logo=bluesky\u0026logoColor=fff\u0026label=will-lumley\" alt=\"Bluesky\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nRichEditor is a WYSIWYG editor written in pure Swift. RichEditor is a direct subclass of `NSTextView` so you'll feel perfectly comfortable using it.\n\nIf you are developing a macOS application that uses an `NSTextView` and you want your users to be able to format their text, you are forced to use the `usesInspectorBar` property, which adds a formatting toolbar to your `NSTextView`.\n\nHowever if you want to modify the UI or modify functionality at all, you'll soon find a dead-end. This is where `RichEditor` comes in.\n\nJust drag `RichEditor` into your UI, and you can use RichEditors functionality to easily programatically control which parts of your text are formatted and how. From bolding and underlining to text alignment and text colour, you have control over your text view. You can create your own UI the way you want and connect your UI to the `RichEditor` functionality.\n\nHowever if you want to use a template UI, RichEditor has one last trick up its sleeve for you. Simply call the `configureToolbar()` from your instance of `RichEditor` and you will have our pre-made toolbar ready to go! \n\nRichEditor also handles the difficult logic of handling text formatting when a user has already highlighted a piece of text, or when you want to export the text with HTML formatting.\n\nRichEditor allows you to control:\n- [x] Bolding\n- [x] Italics\n- [x] Underlining\n- [x] Font Selection\n- [x] Font Size Selection\n- [x] Text Alignment (Left, Centre, Right, Justified)\n- [x] Text Colour\n- [x] Text Highlight Colour\n- [x] Link Insertion\n- [x] Bullet Points\n- [x] Text Strikethrough\n- [x] Attachment Insertion\n\nTo do:\n- [ ] Implement better bullet point formatting\n\nYou can see the provided `RichEditorToolbar` in action, as well as the export functionality in the screenshots below.\nThese screenshots are taken from the Example project that you can use in the repository in the Example directory.\n\n\u003cimg width=\"1045\" alt=\"Screen Shot 2022-01-25 at 4 00 14 pm\" src=\"https://user-images.githubusercontent.com/14086082/150914017-0fa9ce77-8861-4bfe-be6c-079410481bb1.png\"\u003e\n\u003cimg width=\"1047\" alt=\"Screen Shot 2022-01-25 at 4 00 23 pm\" src=\"https://user-images.githubusercontent.com/14086082/150914032-bae590e7-6586-4446-ae29-6ddfbb5e62f0.png\"\u003e\n\n\n## Usage\n\nRichEditor is a direct subclass of `NSTextView` and as such, you can drag `NSTextView` into your storyboard and subclass it there, or you can directly instantiate `RichEditor` directly in your code using the initialisers from `NSTextView`. \n\n### Exporting\n\nRichEditor allows you to export the content of the `RichEditor` as a HTML. You can do this as follows.\n```swift\nlet html = try richEditor.html()\n```\n\n`html()` returns an optional `String` type, and will `throw` in the event of an error.\n\n### Format Types\n\nBelow is a walkthrough of formatting that RichEditor allows you to use. \n\n----\n\n**Bold**\n\n`richEditor.toggleBold()`\n\n----\n\n**Italic**\n\n`richEditor.toggleItalic()`\n\n----\n\n**Underline**\n\n`richEditor.toggleUnderline(.single)`\n\n`toggleUnderline(_)` takes `NSUnderlineStyle` as an argument, so you can specify which underline style should be applied.\n\n----\n\n**Strikethrough**\n\n`richEditor.toggleStrikethrough(.single)`\n\n`toggleStrikethrough(_)` takes `NSUnderlineStyle` as an argument, so you can specify which underline style should be applied with your strikethrough.\n\n----\n\n**Text Colour**\n\n`richEditor.applyColour(textColour: .green)`\n\n`applyColour(textColour:)` takes `NSColor` as an argument, so you can specify which colour should be applied.\n\n----\n\n**Text Highlighy Colour**\n\n`richEditor.applyColour(highlightColour: .green)`\n\n`applyColour(highlightColour:)` takes `NSColor` as an argument, so you can specify which colour should be applied.\n\n----\n\n**Font**\n\n`richEditor.apply(font: .systemFont(ofSize: 12))`\n\n`applyColour(font:)` takes `NSFont` as an argument, so you can specify which font should be applied.\n\n----\n\n**Text Alignment**\n\n`richEditor.apply(alignment: .left)`\n\n`applyColour(alignment:)` takes `NSTextAlignment` as an argument, so you can specify which alignment should be applied.\n\n----\n\n**Links**\n\n`richEditor.insert(link: url, with: name)`\n\n`insert(link:, with:, at:)` takes a `URL` as an argument, so you can specify which alignment should be applied. \n\nA `String` is also taken for how you want this link to appear to the user. \n\nAn optional `Int` argument can also be supplied which indicates what index of the `NSTextView`s string the link should be insert at. If nil, the link will be appended to the end of the string.\n\n----\n\n## Example Project\n\nTo run the example project, clone the repo, and open the example Xcode Project in RichEditorExample.\n\n## Requirements\n\nRichEditor supports iOS 10.0 and above \u0026 macOS 10.10 and above.\n\n## Installation\n\n### Swift Package Manager\nRichEditor is available through [Swift Package Manager](https://github.com/apple/swift-package-manager). \nTo install it, simply add the dependency to your Package.Swift file:\n\n```swift\n...\ndependencies: [\n    .package(url: \"https://github.com/will-lumley/RichEditor.git\", from: \"1.2.0\"),\n],\ntargets: [\n    .target( name: \"YourTarget\", dependencies: [\"RichEditor\"]),\n]\n...\n```\n\n### Cocoapods and Carthage\nRichEditor was previously available through CocoaPods and Carthage, however making the library available to all three Cocoapods, \nCarthage, and SPM (and functional to all three) was becoming troublesome. This, combined with the fact that SPM has seen a serious\nup-tick in adoption \u0026 functionality, has led me to remove support for CocoaPods and Carthage.\n\n## Author\n\n[William Lumley](https://lumley.io/), will@lumley.io\n\n## License\n\nRichEditor is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwill-lumley%2FRichEditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwill-lumley%2FRichEditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwill-lumley%2FRichEditor/lists"}