{"id":15717676,"url":"https://github.com/deadpikle/macos-rich-text-editor","last_synced_at":"2025-05-12T20:52:32.805Z","repository":{"id":44470423,"uuid":"69060161","full_name":"Deadpikle/macOS-Rich-Text-Editor","owner":"Deadpikle","description":"A macOS Rich Text Editor that subclasses NSTextView for many rich text capabilities","archived":false,"fork":false,"pushed_at":"2020-12-08T14:32:26.000Z","size":1550,"stargazers_count":26,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-02T13:05:54.416Z","etag":null,"topics":["mac-osx","macos","nstextview","rich-text","rich-text-editor","text-editor"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Deadpikle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-23T20:56:56.000Z","updated_at":"2024-09-08T09:33:55.000Z","dependencies_parsed_at":"2022-09-24T13:25:32.226Z","dependency_job_id":null,"html_url":"https://github.com/Deadpikle/macOS-Rich-Text-Editor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpikle%2FmacOS-Rich-Text-Editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpikle%2FmacOS-Rich-Text-Editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpikle%2FmacOS-Rich-Text-Editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Deadpikle%2FmacOS-Rich-Text-Editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Deadpikle","download_url":"https://codeload.github.com/Deadpikle/macOS-Rich-Text-Editor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222716187,"owners_count":17027697,"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":["mac-osx","macos","nstextview","rich-text","rich-text-editor","text-editor"],"created_at":"2024-10-03T21:50:58.158Z","updated_at":"2024-11-02T13:06:00.350Z","avatar_url":"https://github.com/Deadpikle.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"macOS Rich Text Editor\n==================\n\nThe macOS Rich Text Editor library allows for rich text editing via a native `NSTextView`. You will need to implement much of the UI yourself (buttons, handling selection changes via the delegate protocol, etc.). The RTE just handles the bold/italic/bulleted lists/etc. formatting for you. The sample should give you some guidance on how this could be accomplished.\n\nTo use this library, you only need eight files:\n\n\t- RichTextEditor.h/m\n\t- NSFont+RichTextEditor.h/m\n\t- NSAttributedString+RichTextEditor.h/m\n\t- WZProtocolInterceptor.h/m\n    \nYou can copy these files directly into your project, or you can choose to build and use the `.framework` output. Remember to open the `.xcworkspace` file when exploring this project.\n\nThis library is based upon Deadpikle's [iOS Rich Text Editor](https://github.com/Deadpikle/iOS-Rich-Text-Editor), which was edited from the [original iOS rich text editor](https://github.com/aryaxt/iOS-Rich-Text-Editor) by [aryaxt](https://github.com/aryaxt).\n\n### Features:\n\n- Bold\n- Italic\n- Underline\n- Font\n- Font size\n- Text background color\n- Text foreground color\n- Text alignment\n- Paragraph indent/outdent\n- Bulleted lists\n\n### Compatibility\n\nThe rich text editor is compatible with macOS 10.10+. It might work on older versions, but this has not been tested.\n\n#### Keyboard Shortcuts\n\n| Shortcut  | Action |\n| ------------- | ------------- |\n| ⌘ + B  | Toggle bold  |\n| ⌘ + I  | Toggle italic  |\n| ⌘ + U  | Toggle underline  |\n| ⌘ + ⇧ + \u003e  | Increase font size |\n| ⌘ + ⇧ + \u003c  | Decrease font size |\n| ⌘ + ⇧ + L  | Toggle bulleted list |\n| ⌘ + ⇧ + N  | If in bulleted list, leave bulleted list |\n| ⌘ + ⇧ + T  | Decrease indent |\n| ⌘ + T  | Increase indent |\n\nBy default, all keyboard shortcuts are enabled. If you want to selectively enable some keyboard shortcuts, implement the `RichTextEditorDataSource` method `- (RichTextEditorShortcut)enabledKeyboardShortcuts`. If you want to do this, don't forget to set the `rteDataSource`!\n\n#### Scaling Text [TODO: move to Wiki]\n\nIf you want to scale text, you can use code similar to the following (based on http://stackoverflow.com/a/14113905/3938401):\n```\n// http://stackoverflow.com/a/14113905/3938401\n@interface ...\n@property CGFloat scaleFactor;\n@end\n\n@implementation ...\n\n-(void)viewDidLoad {\n    self.scaleFactor = 1.0f;\n    ...\n}\n\n- (void)setScaleFactor:(CGFloat)newScaleFactor adjustPopup:(BOOL)flag {\n    CGFloat oldScaleFactor = self.scaleFactor;\n    if (self.scaleFactor != newScaleFactor) {\n        NSSize curDocFrameSize, newDocBoundsSize;\n        NSView *clipView = [self.notesTextView superview];\n        self.scaleFactor = newScaleFactor;\n        // Get the frame. The frame must stay the same.\n        curDocFrameSize = [clipView frame].size;\n        // The new bounds will be frame divided by scale factor\n        newDocBoundsSize.width = curDocFrameSize.width / self.scaleFactor;\n        newDocBoundsSize.height = curDocFrameSize.height / self.scaleFactor;\n    }\n    self.scaleFactor = newScaleFactor;\n    [self scaleChanged:oldScaleFactor newScale:newScaleFactor];\n}\n\n- (void)scaleChanged:(CGFloat)oldScale newScale:(CGFloat)newScale {\n    CGFloat scaler = newScale / oldScale;\n    [self.notesTextView scaleUnitSquareToSize:NSMakeSize(scaler, scaler)];\n    // For some reason, even after ensuring the layout and displaying, the wrapping doesn't update until text is messed\n    // with. This workaround \"fixes\" that. Since we need it anyway, I removed the ensureLayoutForTextContainer:\n    // (from the SO post) and the documentation-implied [self.notesTextView display] calls.\n    [[self.notesTextView textStorage] appendAttributedString:[[NSAttributedString alloc] initWithString:@\"\"]];\n}\n\n@end\n```\n\n\nCredits\n-------------------------\n\nOriginal Rich Text Editor code by [aryaxt](https://github.com/aryaxt) at the [iOS Rich Text Editor repo](https://github.com/aryaxt/iOS-Rich-Text-Editor). `WZProtocolInterceptor` is from [this SO post](http://stackoverflow.com/a/18777565/3938401).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadpikle%2Fmacos-rich-text-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadpikle%2Fmacos-rich-text-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadpikle%2Fmacos-rich-text-editor/lists"}