79 Commits

Author SHA1 Message Date
Michael Babienco cf2da5d359 Update sample for tab key 2020-12-08 09:32:16 -05:00
Michael Babienco 19b63ff242 Add tabKeyAlwaysIndentsOutdents property 2020-12-08 09:28:48 -05:00
Michael Babienco a5b3731db0 Small syntax adjustments 2020-11-13 10:26:50 -05:00
Michael Babienco c60559bb6c Fix handling of system font grabbing 2020-08-03 17:07:07 -04:00
Michael Babienco 1cacbec617 Fix delegate receptor handling 2019-12-31 14:54:04 -05:00
Michael Babienco 1fbf470d24 Fix some possible null refs 2019-09-05 12:34:24 -04:00
Michael Babienco 846aeb292e Fix crash with selection out of range 2019-08-27 15:16:01 -04:00
Michael Babienco 43b1acd9ca Update to Xcode 10 2019-08-27 09:27:16 -04:00
Deadpikle e694418c73 Fix bullet bug where deleting newlines didn't clear bullets 2018-05-16 15:36:58 -04:00
Deadpikle 39592a4bfc Bullet issue fixes; closes #6 & #7 2018-05-16 15:09:37 -04:00
Deadpikle f438543ec4 Update README.md 2018-05-16 14:32:51 -04:00
Deadpikle cb57d0f1e2 Update to Xcode 9.3 2018-05-16 14:30:23 -04:00
Deadpikle fcd80f389b Update gitignore 2018-05-16 14:30:13 -04:00
Deadpikle 42c85ccad2 Make backwards compatible to 10.10 2018-05-16 13:28:25 -04:00
Deadpikle 0a2e10993f Merge pull request #5 from Spider2man3/bullet-point
Made bullet point functionality work a bit more like Word/Pages.
2018-05-11 11:35:07 -04:00
Thomas Manu 82cae6e3c5 Fix wrap-around bug 2018-05-10 17:00:44 -04:00
Thomas Manu 0cada178a2 Remove addition overhead 2018-05-10 16:29:32 -04:00
Thomas Manu 36949138d8 Selecting bullet point only fixes bug of extra character 2018-05-10 15:48:43 -04:00
Thomas Manu 5dc4407f01 Add bug fix to select bullet string from different paragraph 2018-05-10 14:50:32 -04:00
Thomas Manu c9eeb307ef Change name from mouse to isMouseClick 2018-05-10 10:52:17 -04:00
Thomas Manu bd4a7e3760 Change method name to adjustSelectedRangeForBullets 2018-05-09 16:56:56 -04:00
Thomas Manu bffa2250f5 Update documentation and remove unnecessary changes 2018-05-09 16:50:29 -04:00
Thomas Manu 6b1de5c06b Fix bug with hitting left arrow twice and selecting bullet with mouse 2018-05-09 16:08:37 -04:00
Deadpikle d97c7bf74f Fix possible null ref in changeToFont 2018-05-03 15:08:46 -04:00
Thomas Manu f2df27010c Fix issue with flickering cursor and problem with highlighting. 2018-04-10 12:19:10 -04:00
Thomas Manu 9becb802cd Fix bug with having to press left arrow twice to move to a different bullet 2018-04-05 14:03:32 -04:00
Thomas Manu 9bacbb2197 Add function to move cursor around bullet point 2018-04-04 17:17:52 -04:00
Deadpikle 0a895c8673 Update to Xcode 9.3 2018-03-30 09:56:35 -04:00
Deadpikle b26a19dfde Fix incorrect text view changed call in bullet list 2018-03-29 18:58:34 -04:00
Deadpikle a76dc416a6 Add function to change all text to specific font while retaining traits 2018-03-29 16:35:58 -04:00
Deadpikle 6708e23dad Update README.md 2018-03-29 15:52:09 -04:00
Deadpikle 4c4e0264ef Allow user to selectively enable keyboard shortcuts 2018-03-29 15:48:57 -04:00
Deadpikle 140142ec12 Fix bug with bullet list not being indented properly 2018-03-28 17:20:09 -04:00
Deadpikle 075ec588ec Remove some dead comments 2018-03-28 17:12:36 -04:00
Deadpikle 6d8388d263 Improve RTE documentation 2018-03-28 15:01:50 -04:00
Deadpikle 0838210bec Remove unnecessary textObserver property and documentation 2018-03-28 14:47:18 -04:00
Deadpikle 00d20fd3b4 Fix yet another typo in the readme 2018-03-28 14:38:26 -04:00
Deadpikle 05e14bceae Update readme 2018-03-28 14:37:36 -04:00
Deadpikle 7270b0e188 Fix URL in readme 2018-03-28 14:35:47 -04:00
Deadpikle 911e3171b4 Remove TODO from readme in lieu of GitHub issues 2018-03-28 14:33:30 -04:00
Deadpikle 8dacb8b52f Update readme 2018-03-28 14:30:54 -04:00
Deadpikle 747337013d Move files around; update README.md 2018-03-28 14:29:57 -04:00
Deadpikle ed2cc35aa9 Update top code comments 2018-03-28 14:22:09 -04:00
Deadpikle 418a21c4bb Update sample 2018-03-28 14:20:01 -04:00
Deadpikle 187b2811b1 Add SO link for image tinting 2018-03-28 13:56:24 -04:00
Deadpikle a7aef03123 Update README.md 2018-03-28 13:55:36 -04:00
Deadpikle 0261bc1c28 Add basic sample 2018-03-28 13:09:40 -04:00
Deadpikle 877aaca6e3 Update license 2018-03-28 13:06:55 -04:00
Deadpikle e3cb870d16 Make font size related properties public 2018-03-28 13:03:26 -04:00
Deadpikle 012eb54863 Update umbrella header 2018-03-28 12:50:50 -04:00
Deadpikle 783a6c9900 Remove unneeded data source methods 2018-03-28 12:28:21 -04:00
Deadpikle 5d16808ebe Add sample project to workspace 2018-03-28 12:14:54 -04:00
Deadpikle 9267595477 Add workspace and framework output 2018-03-28 12:13:35 -04:00
Deadpikle 53c04bee43 Update README.md 2018-03-27 09:52:04 -04:00
Deadpikle 1f7d91e3d1 Update README.md 2018-03-27 09:50:20 -04:00
Deadpikle bc959a5c0e Remove page break (it was for a proprietary project) 2018-03-27 09:45:09 -04:00
Deadpikle 6eabf61dfe Don't clear selection on text color changed (matches MS Word) 2018-03-02 09:16:43 -05:00
Deadpikle 2e4bab88c3 Comment out some NSLogs 2018-02-22 15:21:27 -05:00
Deadpikle 29c5155a00 For highlight/font color, now ends selection in proper direction 2018-02-14 12:12:32 -05:00
Deadpikle 3fdfe7df62 Update README.md 2018-02-14 11:59:45 -05:00
Deadpikle 0816737aef Fix code style consistancy 2018-02-14 11:58:41 -05:00
Deadpikle bdebd76399 Fix bad preview type -> string conversion 2017-11-29 17:18:09 -05:00
Deadpikle bf00632b25 Allow for retrieval of BULLET_STRING 2017-11-19 14:43:24 -05:00
Deadpikle 9cb29fa75d Add preview change for find & replace
Not actually used by the editor itself, but can be used by clients if needed
2017-11-17 10:41:05 -05:00
Deadpikle be658404dd Don't say that a key was pressed right after a click 2017-05-09 13:11:22 -04:00
Deadpikle 4359c4a153 Fix incorrect if/else chain in keyDown: 2017-05-03 12:10:23 -04:00
Deadpikle 8bb5568179 Remember last key pressed
Lets you do things like know which arrow key was hit last
2017-04-09 19:27:17 -04:00
Deadpikle e1519e03f1 Fix a bug related to backspace and caret placement after bulleted lists 2017-02-08 12:45:37 -05:00
Deadpikle f1379f5a80 Some small code cleanup 2017-02-07 12:14:47 -05:00
Deadpikle 4c46886db2 Add comment regarding bullet unicode # 2017-01-25 16:50:55 -05:00
Deadpikle ac2ce6d7e3 Don't swallow keyboard shortcuts inappropriately with shift down 2017-01-10 13:37:49 -05:00
Deadpikle 4395f51913 Add conversion function from change type to NSString 2016-10-12 13:58:47 -04:00
Deadpikle 001490dc6c Bulleted lists have only 1 non-breaking space after them intead of 2 2016-09-26 12:53:40 -04:00
Deadpikle 1e12b7023b Follow Objective-C style guidelines slightly more 2016-09-25 13:44:01 -04:00
Deadpikle 2261e3d48c Update README.md 2016-09-25 09:52:33 -04:00
Deadpikle a5565e6875 Merge branch 'master' of https://github.com/Deadpikle/macOS-Rich-Text-Editor 2016-09-25 09:51:00 -04:00
Deadpikle 2c2e5d9441 Update top-of-file comments 2016-09-25 09:50:55 -04:00
Deadpikle b3cf8cd4bd Update README.md 2016-09-25 09:18:36 -04:00
Deadpikle 9851f0d834 Update README.md 2016-09-23 17:04:10 -04:00
68 changed files with 4046 additions and 706 deletions
+32
View File
@@ -1 +1,33 @@
*.DS_Store
# Created by https://www.gitignore.io/api/xcode
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
# End of https://www.gitignore.io/api/xcode
macOSRichTextEditor.xcworkspace/xcshareddata/
@@ -0,0 +1,479 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
342F59DF206BF5D00045E75A /* macOSRichTextEditor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 342F59D5206BF5D00045E75A /* macOSRichTextEditor.framework */; };
342F59E4206BF5D00045E75A /* macOSRichTextEditorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F59E3206BF5D00045E75A /* macOSRichTextEditorTests.m */; };
342F59E6206BF5D00045E75A /* macOSRichTextEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 342F59D8206BF5D00045E75A /* macOSRichTextEditor.h */; settings = {ATTRIBUTES = (Public, ); }; };
342F59F9206BF5FC0045E75A /* RichTextEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F59F0206BF5FC0045E75A /* RichTextEditor.m */; };
342F59FA206BF5FC0045E75A /* WZProtocolInterceptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 342F59F1206BF5FC0045E75A /* WZProtocolInterceptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
342F59FB206BF5FC0045E75A /* RichTextEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 342F59F2206BF5FC0045E75A /* RichTextEditor.h */; settings = {ATTRIBUTES = (Public, ); }; };
342F59FC206BF5FC0045E75A /* NSFont+RichTextEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F59F4206BF5FC0045E75A /* NSFont+RichTextEditor.m */; };
342F59FD206BF5FC0045E75A /* NSAttributedString+RichTextEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F59F5206BF5FC0045E75A /* NSAttributedString+RichTextEditor.m */; };
342F59FE206BF5FC0045E75A /* NSAttributedString+RichTextEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 342F59F6206BF5FC0045E75A /* NSAttributedString+RichTextEditor.h */; settings = {ATTRIBUTES = (Public, ); }; };
342F59FF206BF5FC0045E75A /* NSFont+RichTextEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 342F59F7206BF5FC0045E75A /* NSFont+RichTextEditor.h */; settings = {ATTRIBUTES = (Public, ); }; };
342F5A00206BF5FC0045E75A /* WZProtocolInterceptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F59F8206BF5FC0045E75A /* WZProtocolInterceptor.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
342F59E0206BF5D00045E75A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 342F59CC206BF5D00045E75A /* Project object */;
proxyType = 1;
remoteGlobalIDString = 342F59D4206BF5D00045E75A;
remoteInfo = macOSRichTextEditor;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
342F59D5206BF5D00045E75A /* macOSRichTextEditor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = macOSRichTextEditor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
342F59D8206BF5D00045E75A /* macOSRichTextEditor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = macOSRichTextEditor.h; sourceTree = "<group>"; };
342F59D9206BF5D00045E75A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
342F59DE206BF5D00045E75A /* macOSRichTextEditorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = macOSRichTextEditorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
342F59E3206BF5D00045E75A /* macOSRichTextEditorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = macOSRichTextEditorTests.m; sourceTree = "<group>"; };
342F59E5206BF5D00045E75A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
342F59F0206BF5FC0045E75A /* RichTextEditor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RichTextEditor.m; sourceTree = "<group>"; };
342F59F1206BF5FC0045E75A /* WZProtocolInterceptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WZProtocolInterceptor.h; sourceTree = "<group>"; };
342F59F2206BF5FC0045E75A /* RichTextEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RichTextEditor.h; sourceTree = "<group>"; };
342F59F4206BF5FC0045E75A /* NSFont+RichTextEditor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFont+RichTextEditor.m"; sourceTree = "<group>"; };
342F59F5206BF5FC0045E75A /* NSAttributedString+RichTextEditor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+RichTextEditor.m"; sourceTree = "<group>"; };
342F59F6206BF5FC0045E75A /* NSAttributedString+RichTextEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+RichTextEditor.h"; sourceTree = "<group>"; };
342F59F7206BF5FC0045E75A /* NSFont+RichTextEditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFont+RichTextEditor.h"; sourceTree = "<group>"; };
342F59F8206BF5FC0045E75A /* WZProtocolInterceptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WZProtocolInterceptor.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
342F59D1206BF5D00045E75A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
342F59DB206BF5D00045E75A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
342F59DF206BF5D00045E75A /* macOSRichTextEditor.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
342F59CB206BF5D00045E75A = {
isa = PBXGroup;
children = (
342F59D7206BF5D00045E75A /* macOSRichTextEditor */,
342F59E2206BF5D00045E75A /* macOSRichTextEditorTests */,
342F59D6206BF5D00045E75A /* Products */,
);
sourceTree = "<group>";
};
342F59D6206BF5D00045E75A /* Products */ = {
isa = PBXGroup;
children = (
342F59D5206BF5D00045E75A /* macOSRichTextEditor.framework */,
342F59DE206BF5D00045E75A /* macOSRichTextEditorTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
342F59D7206BF5D00045E75A /* macOSRichTextEditor */ = {
isa = PBXGroup;
children = (
342F5A01206BF6840045E75A /* Source */,
342F59D8206BF5D00045E75A /* macOSRichTextEditor.h */,
342F59D9206BF5D00045E75A /* Info.plist */,
);
path = macOSRichTextEditor;
sourceTree = "<group>";
};
342F59E2206BF5D00045E75A /* macOSRichTextEditorTests */ = {
isa = PBXGroup;
children = (
342F59E3206BF5D00045E75A /* macOSRichTextEditorTests.m */,
342F59E5206BF5D00045E75A /* Info.plist */,
);
path = macOSRichTextEditorTests;
sourceTree = "<group>";
};
342F59F3206BF5FC0045E75A /* Categories */ = {
isa = PBXGroup;
children = (
342F59F7206BF5FC0045E75A /* NSFont+RichTextEditor.h */,
342F59F4206BF5FC0045E75A /* NSFont+RichTextEditor.m */,
342F59F6206BF5FC0045E75A /* NSAttributedString+RichTextEditor.h */,
342F59F5206BF5FC0045E75A /* NSAttributedString+RichTextEditor.m */,
);
path = Categories;
sourceTree = "<group>";
};
342F5A01206BF6840045E75A /* Source */ = {
isa = PBXGroup;
children = (
342F59F3206BF5FC0045E75A /* Categories */,
342F59F2206BF5FC0045E75A /* RichTextEditor.h */,
342F59F0206BF5FC0045E75A /* RichTextEditor.m */,
342F59F1206BF5FC0045E75A /* WZProtocolInterceptor.h */,
342F59F8206BF5FC0045E75A /* WZProtocolInterceptor.m */,
);
path = Source;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
342F59D2206BF5D00045E75A /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
342F59E6206BF5D00045E75A /* macOSRichTextEditor.h in Headers */,
342F59FF206BF5FC0045E75A /* NSFont+RichTextEditor.h in Headers */,
342F59FB206BF5FC0045E75A /* RichTextEditor.h in Headers */,
342F59FE206BF5FC0045E75A /* NSAttributedString+RichTextEditor.h in Headers */,
342F59FA206BF5FC0045E75A /* WZProtocolInterceptor.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
342F59D4206BF5D00045E75A /* macOSRichTextEditor */ = {
isa = PBXNativeTarget;
buildConfigurationList = 342F59E9206BF5D00045E75A /* Build configuration list for PBXNativeTarget "macOSRichTextEditor" */;
buildPhases = (
342F59D0206BF5D00045E75A /* Sources */,
342F59D1206BF5D00045E75A /* Frameworks */,
342F59D2206BF5D00045E75A /* Headers */,
342F59D3206BF5D00045E75A /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = macOSRichTextEditor;
productName = macOSRichTextEditor;
productReference = 342F59D5206BF5D00045E75A /* macOSRichTextEditor.framework */;
productType = "com.apple.product-type.framework";
};
342F59DD206BF5D00045E75A /* macOSRichTextEditorTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 342F59EC206BF5D00045E75A /* Build configuration list for PBXNativeTarget "macOSRichTextEditorTests" */;
buildPhases = (
342F59DA206BF5D00045E75A /* Sources */,
342F59DB206BF5D00045E75A /* Frameworks */,
342F59DC206BF5D00045E75A /* Resources */,
);
buildRules = (
);
dependencies = (
342F59E1206BF5D00045E75A /* PBXTargetDependency */,
);
name = macOSRichTextEditorTests;
productName = macOSRichTextEditorTests;
productReference = 342F59DE206BF5D00045E75A /* macOSRichTextEditorTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
342F59CC206BF5D00045E75A /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Pikle Productions";
TargetAttributes = {
342F59D4206BF5D00045E75A = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
342F59DD206BF5D00045E75A = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 342F59CF206BF5D00045E75A /* Build configuration list for PBXProject "macOSRichTextEditor" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 342F59CB206BF5D00045E75A;
productRefGroup = 342F59D6206BF5D00045E75A /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
342F59D4206BF5D00045E75A /* macOSRichTextEditor */,
342F59DD206BF5D00045E75A /* macOSRichTextEditorTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
342F59D3206BF5D00045E75A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
342F59DC206BF5D00045E75A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
342F59D0206BF5D00045E75A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
342F5A00206BF5FC0045E75A /* WZProtocolInterceptor.m in Sources */,
342F59F9206BF5FC0045E75A /* RichTextEditor.m in Sources */,
342F59FC206BF5FC0045E75A /* NSFont+RichTextEditor.m in Sources */,
342F59FD206BF5FC0045E75A /* NSAttributedString+RichTextEditor.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
342F59DA206BF5D00045E75A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
342F59E4206BF5D00045E75A /* macOSRichTextEditorTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
342F59E1206BF5D00045E75A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 342F59D4206BF5D00045E75A /* macOSRichTextEditor */;
targetProxy = 342F59E0206BF5D00045E75A /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
342F59E7206BF5D00045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
342F59E8206BF5D00045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
342F59EA206BF5D00045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = macOSRichTextEditor/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRichTextEditor;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
};
name = Debug;
};
342F59EB206BF5D00045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = macOSRichTextEditor/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRichTextEditor;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
};
name = Release;
};
342F59ED206BF5D00045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRichTextEditorTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRichTextEditorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
342F59EE206BF5D00045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRichTextEditorTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRichTextEditorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
342F59CF206BF5D00045E75A /* Build configuration list for PBXProject "macOSRichTextEditor" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F59E7206BF5D00045E75A /* Debug */,
342F59E8206BF5D00045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
342F59E9206BF5D00045E75A /* Build configuration list for PBXNativeTarget "macOSRichTextEditor" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F59EA206BF5D00045E75A /* Debug */,
342F59EB206BF5D00045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
342F59EC206BF5D00045E75A /* Build configuration list for PBXNativeTarget "macOSRichTextEditorTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F59ED206BF5D00045E75A /* Debug */,
342F59EE206BF5D00045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 342F59CC206BF5D00045E75A /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Pikle Productions. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
@@ -4,9 +4,11 @@
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor
// https://github.com/Deadpikle/iOS-and-Mac-OS-X-Rich-Text-Editor
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -4,10 +4,11 @@
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor
// https://github.com/Deadpikle/iOS-and-Mac-OS-X-Rich-Text-Editor
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@@ -32,10 +33,10 @@
#pragma mark - Public Methods -
- (NSRange)firstParagraphRangeFromTextRange:(NSRange)range
{
if (self.string.length == 0 || self.string.length < range.location)
- (NSRange)firstParagraphRangeFromTextRange:(NSRange)range {
if (self.string.length == 0 || self.string.length < range.location) {
return NSMakeRange(0, 0);
}
NSInteger start = -1;
NSInteger end = -1;
@@ -45,11 +46,9 @@
range.location-1 :
range.location;
for (NSInteger i=startingRange ; i>=0 ; i--)
{
for (NSInteger i = startingRange; i >= 0; i--) {
char c = [self.string characterAtIndex:i];
if (c == '\n')
{
if (c == '\n') {
start = i+1;
break;
}
@@ -59,8 +58,7 @@
NSInteger moveForwardIndex = (range.location > start) ? range.location : start;
for (NSInteger i=moveForwardIndex; i<= self.string.length-1 ; i++)
{
for (NSInteger i = moveForwardIndex; i <= self.string.length - 1; i++) {
char c = [self.string characterAtIndex:i];
if (c == '\n')
{
@@ -75,33 +73,30 @@
return NSMakeRange(start, length);
}
- (NSArray *)rangeOfParagraphsFromTextRange:(NSRange)textRange
{
- (NSArray *)rangeOfParagraphsFromTextRange:(NSRange)textRange {
NSMutableArray *paragraphRanges = [NSMutableArray array];
NSInteger rangeStartIndex = textRange.location;
while (true)
{
while (true) {
NSRange range = [self firstParagraphRangeFromTextRange:NSMakeRange(rangeStartIndex, 0)];
rangeStartIndex = range.location + range.length + 1;
[paragraphRanges addObject:[NSValue valueWithRange:range]];
if (range.location + range.length >= textRange.location + textRange.length)
if (range.location + range.length >= textRange.location + textRange.length) {
break;
}
}
return paragraphRanges;
}
- (NSString *)htmlString
{
- (NSString *)htmlString {
NSMutableString *htmlString = [NSMutableString string];
NSArray *paragraphRanges = [self rangeOfParagraphsFromTextRange:NSMakeRange(0, self.string.length-1)];
for (int i=0 ; i<paragraphRanges.count ; i++)
{
NSValue *value = [paragraphRanges objectAtIndex:i];
for (int i = 0; i < paragraphRanges.count; i++) {
NSValue *value = paragraphRanges[i];
NSRange range = [value rangeValue];
NSDictionary *paragraphDictionary = [self attributesAtIndex:range.location effectiveRange:nil];
NSParagraphStyle *paragraphStyle = [paragraphDictionary objectForKey:NSParagraphStyleAttributeName];
@@ -109,16 +104,19 @@
[htmlString appendString:@"<p "];
if (textAlignmentString)
if (textAlignmentString) {
[htmlString appendFormat:@"align=\"%@\" ", textAlignmentString];
}
[htmlString appendFormat:@"style=\""];
if (paragraphStyle.firstLineHeadIndent > 0)
if (paragraphStyle.firstLineHeadIndent > 0) {
[htmlString appendFormat:@"text-indent:%.0fpx; ", paragraphStyle.firstLineHeadIndent - paragraphStyle.headIndent];
}
if (paragraphStyle.headIndent > 0)
if (paragraphStyle.headIndent > 0) {
[htmlString appendFormat:@"margin-left:%.0fpx; ", paragraphStyle.headIndent];
}
[htmlString appendString:@" \">"];
@@ -144,11 +142,13 @@
[fontString appendFormat:@"font-size:%.0fpx; ", font.pointSize];
if (foregroundColor && [foregroundColor isKindOfClass:[NSColor class]])
if (foregroundColor && [foregroundColor isKindOfClass:[NSColor class]]) {
[fontString appendFormat:@"color:%@; ", [self htmlRgbColor:foregroundColor]];
}
if (backGroundColor && [backGroundColor isKindOfClass:[NSColor class]])
if (backGroundColor && [backGroundColor isKindOfClass:[NSColor class]]) {
[fontString appendFormat:@"background-color:%@; ", [self htmlRgbColor:backGroundColor]];
}
[fontString appendString:@"\" "];
// End Style
@@ -156,35 +156,28 @@
[fontString appendString:@">"];
[fontString appendString:[[self.string substringFromIndex:range.location] substringToIndex:range.length]];
[fontString appendString:@"</font>"];
if ([font isBold])
{
if ([font isBold]) {
[fontString insertString:@"<b>" atIndex:0];
[fontString insertString:@"</b>" atIndex:fontString.length];
}
if ([font isItalic])
{
if ([font isItalic]) {
[fontString insertString:@"<i>" atIndex:0];
[fontString insertString:@"</i>" atIndex:fontString.length];
}
if (hasUnderline)
{
if (hasUnderline) {
[fontString insertString:@"<u>" atIndex:0];
[fontString insertString:@"</u>" atIndex:fontString.length];
}
if (hasStrikeThrough)
{
if (hasStrikeThrough) {
[fontString insertString:@"<strike>" atIndex:0];
[fontString insertString:@"</strike>" atIndex:fontString.length];
}
[htmlString appendString:fontString];
}];
[htmlString appendString:@"</p>"];
}
@@ -193,29 +186,22 @@
#pragma mark - Helper Methods -
- (NSString *)htmlTextAlignmentString:(NSTextAlignment)textAlignment
{
switch (textAlignment)
{
- (NSString *)htmlTextAlignmentString:(NSTextAlignment)textAlignment {
switch (textAlignment) {
case NSLeftTextAlignment:
return @"left";
case NSCenterTextAlignment:
return @"center";
case NSRightTextAlignment:
return @"right";
case NSJustifiedTextAlignment:
return @"justify";
default:
return nil;
}
}
- (NSString *)htmlRgbColor:(NSColor *)color
{
- (NSString *)htmlRgbColor:(NSColor *)color {
CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
[color getRed:&red green:&green blue:&blue alpha:&alpha];
return [NSString stringWithFormat:@"rgb(%d,%d,%d)",(int)(red*255.0), (int)(green*255.0), (int)(blue*255.0)];
@@ -4,9 +4,11 @@
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor
// https://github.com/Deadpikle/iOS-and-Mac-OS-X-Rich-Text-Editor
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -4,9 +4,11 @@
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor
// https://github.com/Deadpikle/iOS-and-Mac-OS-X-Rich-Text-Editor
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -30,40 +32,56 @@
@implementation NSFont (RichTextEditor)
+ (NSString *)postscriptNameFromFullName:(NSString *)fullName
{
NSFont *font = [NSFont fontWithName:fullName size:1];
+ (NSString *)postscriptNameFromFullName:(NSString *)fullName {
// avoid error with "All system UI font access should be through proper APIs..."
// by bailing early if the user gets here with a system font
if ([fullName containsString:@"SFNS"]) {
return fullName;
}
NSFont *font = [NSFont fontWithName:fullName size:1];
return (__bridge NSString *)(CTFontCopyPostScriptName((__bridge CTFontRef)(font)));
}
+ (NSFont *)fontWithName:(NSString *)name size:(CGFloat)size boldTrait:(BOOL)isBold italicTrait:(BOOL)isItalic
{
NSString *postScriptName = [NSFont postscriptNameFromFullName:name];
CTFontSymbolicTraits traits = 0;
CTFontRef newFontRef;
+ (NSFont *)fontWithName:(NSString *)name size:(CGFloat)size boldTrait:(BOOL)isBold italicTrait:(BOOL)isItalic {
// avoid error with "All system UI font access should be through proper APIs..."
// by bailing early if the user gets here with a system font
if ([name containsString:@"SFNS"]) {
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSFont *sysFont = [NSFont systemFontOfSize:size];
if (isItalic) {
sysFont = [fontManager convertFont:sysFont toHaveTrait:NSFontItalicTrait];
}
if (isBold) {
sysFont = [fontManager convertFont:sysFont toHaveTrait:NSFontBoldTrait];
}
return sysFont;
}
NSString *postScriptName = [NSFont postscriptNameFromFullName:name];
CTFontRef fontWithoutTrait = CTFontCreateWithName((__bridge CFStringRef)(postScriptName), size, NULL);
CTFontSymbolicTraits traits = 0;
CTFontRef newFontRef;
if (isItalic) {
traits |= kCTFontItalicTrait;
}
if (isItalic)
traits |= kCTFontItalicTrait;
if (isBold)
if (isBold) {
traits |= kCTFontBoldTrait;
}
if (traits == 0)
{
newFontRef= CTFontCreateCopyWithAttributes(fontWithoutTrait, 0.0, NULL, NULL);
if (traits == 0) {
newFontRef = CTFontCreateCopyWithAttributes(fontWithoutTrait, 0.0, NULL, NULL);
}
else
{
else {
newFontRef = CTFontCreateCopyWithSymbolicTraits(fontWithoutTrait, 0.0, NULL, traits, traits);
}
if (fontWithoutTrait)
if (fontWithoutTrait) {
CFRelease(fontWithoutTrait);
}
if (newFontRef)
{
if (newFontRef) {
NSString *fontNameKey = (__bridge NSString *)(CTFontCopyName(newFontRef, kCTFontPostScriptNameKey));
CGFloat size = CTFontGetSize(newFontRef);
CFRelease(newFontRef);
@@ -73,35 +91,31 @@
return nil;
}
- (NSFont *)fontWithBoldTrait:(BOOL)bold italicTrait:(BOOL)italic andSize:(CGFloat)size
{
- (NSFont *)fontWithBoldTrait:(BOOL)bold italicTrait:(BOOL)italic andSize:(CGFloat)size {
CTFontRef fontRef = (__bridge CTFontRef)self;
NSString *familyName = (__bridge NSString *)(CTFontCopyName(fontRef, kCTFontFamilyNameKey));
NSString *postScriptName = [NSFont postscriptNameFromFullName:familyName];
return [[self class] fontWithName:postScriptName size:size boldTrait:bold italicTrait:italic];
}
- (NSFont *)fontWithBoldTrait:(BOOL)bold andItalicTrait:(BOOL)italic
{
- (NSFont *)fontWithBoldTrait:(BOOL)bold andItalicTrait:(BOOL)italic {
return [self fontWithBoldTrait:bold italicTrait:italic andSize:self.pointSize];
}
- (BOOL)isBold
{
- (BOOL)isBold {
CTFontSymbolicTraits trait = CTFontGetSymbolicTraits((__bridge CTFontRef)self);
if ((trait & kCTFontTraitBold) == kCTFontTraitBold)
if ((trait & kCTFontTraitBold) == kCTFontTraitBold) {
return YES;
}
return NO;
}
- (BOOL)isItalic
{
- (BOOL)isItalic {
CTFontSymbolicTraits trait = CTFontGetSymbolicTraits((__bridge CTFontRef)self);
if ((trait & kCTFontTraitItalic) == kCTFontTraitItalic)
if ((trait & kCTFontTraitItalic) == kCTFontTraitItalic) {
return YES;
}
return NO;
}
+230
View File
@@ -0,0 +1,230 @@
//
// RichTextEditor.h
// RichTextEdtor
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// TODO: better documentation
// TODO: Clean up, clean up, everybody do your share!
#import <Cocoa/Cocoa.h>
@class RichTextEditor;
// These values will always start from 0 and go up. If you want to add your own
// preview changes via a subclass, start from 9999 and go down (or similar) and
// override convertPreviewChangeTypeToString:withNonSpecialChangeText:
typedef NS_ENUM(NSInteger, RichTextEditorPreviewChange) {
RichTextEditorPreviewChangeBold = 0,
RichTextEditorPreviewChangeItalic = 1,
RichTextEditorPreviewChangeUnderline = 2,
RichTextEditorPreviewChangeFontResize = 3,
RichTextEditorPreviewChangeHighlight = 4,
RichTextEditorPreviewChangeFontSize = 5,
RichTextEditorPreviewChangeFontColor = 6,
RichTextEditorPreviewChangeIndentIncrease = 7,
RichTextEditorPreviewChangeIndentDecrease = 8,
RichTextEditorPreviewChangeCut = 9,
RichTextEditorPreviewChangePaste = 10,
RichTextEditorPreviewChangeSpace = 11,
RichTextEditorPreviewChangeEnter = 12,
RichTextEditorPreviewChangeBullet = 13,
RichTextEditorPreviewChangeMouseDown = 14,
RichTextEditorPreviewChangeArrowKey = 15,
RichTextEditorPreviewChangeKeyDown = 16,
RichTextEditorPreviewChangeDelete = 17,
RichTextEditorPreviewChangeFindReplace = 18
};
typedef NS_OPTIONS(NSUInteger, RichTextEditorShortcut) {
RichTextEditorShortcutAll = 0,
RichTextEditorShortcutBold = 1 << 0,
RichTextEditorShortcutItalic = 1 << 1,
RichTextEditorShortcutUnderline = 1 << 2,
RichTextEditorShortcutIncreaseFontSize = 1 << 3,
RichTextEditorShortcutDecreaseFontSize = 1 << 4,
RichTextEditorShortcutBulletedList = 1 << 6,
RichTextEditorShortcutLeaveBulletedList = 1 << 7,
RichTextEditorShortcutDecreaseIndent = 1 << 8,
RichTextEditorShortcutIncreaseIndent = 1 << 9
};
@protocol RichTextEditorDataSource <NSObject>
@optional
- (NSUInteger)levelsOfUndo;
/// If you do not want to enable all keyboard shortcuts (e.g. if you don't want users to resize font ever),
/// then you can use this data source callback to selectively enable keyboard shortcuts.
- (RichTextEditorShortcut)enabledKeyboardShortcuts;
@end
@protocol RichTextEditorDelegate <NSObject>
@required
-(void)selectionForEditor:(RichTextEditor*)editor changedTo:(NSRange)range isBold:(BOOL)isBold isItalic:(BOOL)isItalic isUnderline:(BOOL)isUnderline isInBulletedList:(BOOL)isInBulletedList textBackgroundColor:(NSColor*)textBackgroundColor textColor:(NSColor*)textColor;
@optional
- (BOOL)richTextEditor:(RichTextEditor*)editor keyDownEvent:(NSEvent*)event; // return YES if handled by delegate, NO if RTE should process it
- (BOOL)handlesUndoRedoForText;
- (void)userPerformedUndo; // TODO: remove?
- (void)userPerformedRedo; // TODO: remove?
- (void)richTextEditor:(RichTextEditor*)editor changeAboutToOccurOfType:(RichTextEditorPreviewChange)type;
@end
@interface RichTextEditor : NSTextView
@property (assign) IBOutlet id <RichTextEditorDataSource> rteDataSource;
@property (assign) IBOutlet id <RichTextEditorDelegate> rteDelegate;
@property (nonatomic, assign) CGFloat defaultIndentationSize;
@property (nonatomic, readonly) unichar lastSingleKeyPressed;
/// If YES, only pastes text as rich text if the copy operation came from this class.
/// Note: not this *object* -- this class (so other RichTextEditor boxes can paste
/// between each other). If the text did not come from a RichTextEditor box, then
/// pastes as plain text.
/// If NO, performs the default paste: operation.
/// Defaults to YES.
@property BOOL allowsRichTextPasteOnlyFromThisClass;
/// Amount to change font size on each increase/decrease font size call.
/// Defaults to 10.0f
@property CGFloat fontSizeChangeAmount;
/// Maximum font size. Defaults to 128.0f.
@property CGFloat maxFontSize;
/// Minimum font size. Defaults to 10.0f.
@property CGFloat minFontSize;
/// true if tab should always indent and shift+tab should always outdent the current paragraph(s);
/// false to let the tab key be used as normal
@property BOOL tabKeyAlwaysIndentsOutdents;
/// Pasteboard type string used when copying text from this NSTextView.
+(NSString*)pasteboardDataType;
/// Call the following methods when the user does the given action (clicks bold button, etc.)
/// Toggle bold.
- (void)userSelectedBold;
/// Toggle italic.
- (void)userSelectedItalic;
/// Toggle underline.
- (void)userSelectedUnderline;
/// Toggle bulleted list.
- (void)userSelectedBullet;
/// Increase the total indentation of the current paragraph.
- (void)userSelectedIncreaseIndent;
/// Decrease the total indentation of the current paragraph.
- (void)userSelectedDecreaseIndent;
/// Change the text background (highlight) color for the currently selected text.
- (void)userSelectedTextBackgroundColor:(NSColor*)color;
/// Change the text color for the currently selected text.
- (void)userSelectedTextColor:(NSColor*)color;
/// Perform an undo operation if one is available.
- (void)undo;
/// Perform a redo operation if one is available.
- (void)redo;
/// Convert the font for all text to the given font while keeping bold/italic attributes
- (void)changeToFont:(NSFont*)font;
/// Change the currently selected text to the given font name.
- (void)userChangedToFontName:(NSString*)fontName;
/// Change the currently selected text to the specified font size.
- (void)userChangedToFontSize:(NSNumber*)fontSize;
/// Increases the font size of the currently selected text by self.fontSizeChangeAmount.
- (void)increaseFontSize;
/// Decreases the font size of the currently selected text by self.fontSizeChangeAmount.
- (void)decreaseFontSize;
/// Toggles whether or not the paragraphs in the currently selected text have a first
/// line head indent value of self.defaultIndentationSize.
- (void)userSelectedParagraphFirstLineHeadIndent;
/// Change the text alignment for the paragraphs in the currently selected text.
- (void)userSelectedTextAlignment:(NSTextAlignment)textAlignment;
/// Convenience method; YES if user has something selected (selection length > 0).
- (BOOL)hasSelection;
/// Changes the editor's contents to the given attributed string.
- (void)changeToAttributedString:(NSAttributedString*)string;
/// Convenience method to set the editor's border color.
- (void)setBorderColor:(NSColor*)borderColor;
/// Convenience method to set the editor's border width.
- (void)setBorderWidth:(CGFloat)borderWidth;
/// Converts the current NSAttributedString to an HTML string.
- (NSString *)htmlString;
/// Converts the provided htmlString into an NSAttributedString and then
/// sets the editor's text to the attributed string.
- (void)setHtmlString:(NSString *)htmlString;
/// Grabs the NSString used as the bulleted list prefix.
- (NSString*)bulletString;
/// Converts the provided NSAttributedString into an HTML string.
+ (NSString *)htmlStringFromAttributedText:(NSAttributedString*)text;
/// Converts the given HTML string into an NSAttributedString.
+ (NSAttributedString*)attributedStringFromHTMLString:(NSString *)htmlString;
/// Converts a given RichTextEditorPreviewChange to a human-readable string
+ (NSString *)convertPreviewChangeTypeToString:(RichTextEditorPreviewChange)changeType withNonSpecialChangeText:(BOOL)shouldReturnStringForNonSpecialType;
// // // // // // // // // // // // // // // // // // // //
// I'm not sure why you'd call these externally, but subclasses can make use of this for custom toolbar items or what have you.
// It's just easier to put these in the public header than to have a protected/subclasses-only header.
-(void)sendDelegatePreviewChangeOfType:(RichTextEditorPreviewChange)type;
-(void)sendDelegateTVChanged;
@end
File diff suppressed because it is too large Load Diff
@@ -11,32 +11,33 @@
static inline BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol);
@implementation WZProtocolInterceptor
- (id)forwardingTargetForSelector:(SEL)aSelector
{
if ([self.middleMan respondsToSelector:aSelector] &&
[self isSelectorContainedInInterceptedProtocols:aSelector])
- (id)forwardingTargetForSelector:(SEL)aSelector {
if (self.middleMan && [self.middleMan respondsToSelector:aSelector] &&
[self isSelectorContainedInInterceptedProtocols:aSelector]) {
return self.middleMan;
}
if ([self.receiver respondsToSelector:aSelector])
if ([self.receiver respondsToSelector:aSelector]) {
return self.receiver;
}
return [super forwardingTargetForSelector:aSelector];
}
- (BOOL)respondsToSelector:(SEL)aSelector
{
if ([self.middleMan respondsToSelector:aSelector] &&
[self isSelectorContainedInInterceptedProtocols:aSelector])
- (BOOL)respondsToSelector:(SEL)aSelector {
if (self.middleMan && [self.middleMan respondsToSelector:aSelector] &&
[self isSelectorContainedInInterceptedProtocols:aSelector]) {
return YES;
}
if ([self.receiver respondsToSelector:aSelector])
if (self.receiver && [self.receiver respondsToSelector:aSelector]) {
return YES;
}
return [super respondsToSelector:aSelector];
}
- (instancetype)initWithInterceptedProtocol:(Protocol *)interceptedProtocol
{
- (instancetype)initWithInterceptedProtocol:(Protocol *)interceptedProtocol {
self = [super init];
if (self) {
_interceptedProtocols = @[interceptedProtocol];
@@ -44,15 +45,13 @@ static inline BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol)
return self;
}
- (instancetype)initWithInterceptedProtocols:(Protocol *)firstInterceptedProtocol, ...;
{
- (instancetype)initWithInterceptedProtocols:(Protocol *)firstInterceptedProtocol, ...; {
self = [super init];
if (self) {
NSMutableArray * mutableProtocols = [NSMutableArray array];
Protocol * eachInterceptedProtocol;
va_list argumentList;
if (firstInterceptedProtocol)
{
if (firstInterceptedProtocol) {
[mutableProtocols addObject:firstInterceptedProtocol];
va_start(argumentList, firstInterceptedProtocol);
while ((eachInterceptedProtocol = va_arg(argumentList, id))) {
@@ -65,8 +64,7 @@ static inline BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol)
return self;
}
- (instancetype)initWithArrayOfInterceptedProtocols:(NSArray *)arrayOfInterceptedProtocols
{
- (instancetype)initWithArrayOfInterceptedProtocols:(NSArray *)arrayOfInterceptedProtocols {
self = [super init];
if (self) {
_interceptedProtocols = [arrayOfInterceptedProtocols copy];
@@ -74,13 +72,11 @@ static inline BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol)
return self;
}
- (void)dealloc
{
- (void)dealloc {
_interceptedProtocols = nil;
}
- (BOOL)isSelectorContainedInInterceptedProtocols:(SEL)aSelector
{
- (BOOL)isSelectorContainedInInterceptedProtocols:(SEL)aSelector{
__block BOOL isSelectorContainedInInterceptedProtocols = NO;
[self.interceptedProtocols enumerateObjectsUsingBlock:^(Protocol * protocol, NSUInteger idx, BOOL *stop) {
isSelectorContainedInInterceptedProtocols = selector_belongsToProtocol(aSelector, protocol);
@@ -91,8 +87,7 @@ static inline BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol)
@end
BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol)
{
BOOL selector_belongsToProtocol(SEL selector, Protocol * protocol) {
// Reference: https://gist.github.com/numist/3838169
for (int optionbits = 0; optionbits < (1 << 2); optionbits++) {
BOOL required = optionbits & 1;
@@ -0,0 +1,21 @@
//
// macOSRichTextEditor.h
// macOSRichTextEditor
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//! Project version number for macOSRichTextEditor.
FOUNDATION_EXPORT double macOSRichTextEditorVersionNumber;
//! Project version string for macOSRichTextEditor.
FOUNDATION_EXPORT const unsigned char macOSRichTextEditorVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <macOSRichTextEditor/PublicHeader.h>
#include <macOSRichTextEditor/RichTextEditor.h>
#include <macOSRichTextEditor/NSFont+RichTextEditor.h>
#include <macOSRichTextEditor/NSAttributedString+RichTextEditor.h>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
@@ -0,0 +1,39 @@
//
// macOSRichTextEditorTests.m
// macOSRichTextEditorTests
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface macOSRichTextEditorTests : XCTestCase
@end
@implementation macOSRichTextEditorTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end
+2 -20
View File
@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Modified by Deadpikle for bullet functionality and a few other fixes/improvements
https://github.com/Deadpikle/iOS-Rich-Text-Editor
https://github.com/Deadpikle/macOS-Rich-Text-Editor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@@ -344,22 +344,4 @@ to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the public
licenses.
Creative Commons may be contacted at creativecommons.org.
PSPDFTextView:
The MIT License (MIT)
Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Creative Commons may be contacted at creativecommons.org.
+43 -115
View File
@@ -1,20 +1,53 @@
RichTextEditor -- Mac OS X
macOS Rich Text Editor
==================
**NOTE: This repo is in real need of some help. Code needs cleaned up, it doesn't support numbered lists, and the implementation for bulleted lists could be reworked (although the current implementation appears to be working OK overall). I haven't gotten the chance to do this myself. Please help!**
MAC NOTES:
-The Mac version has no toolbar or things like that. 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. for you. Some day, in a perfect world, I'll update this with a proper example. Rest assured, however, that I (Deadpikle) am using this code in a presentation software package for speaker notes rich text editing, and it works rather well.
-You only need 6 files:
The 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.
To use this library, you only need eight files:
- RichTextEditor.h/m
- NSFont+RichTextEditor.h/m
- NSAttributedString+RichTextEditor.h/m
- WZProtocolInterceptor.h/m
You 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.
-The Mac version is improved over the iOS version. It uses NSTextStorage instead of replacing the entire attributed string, which fixes several problems and also increases performance. It also has more features overall. Eventually, these updates should propagate to the iOS version (someone want to make a pull request and perform those updates? We'd have to drop < iOS 6 support...).
This 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).
-Forked by Deadpikle for additional fixes and features. Readme updates TODO. There have been many enhancements and improvements. Please bug me for an updated README if I forget, which I probably will. The code is by no means perfectly clean, but it does function! Be wary of using the stock undo/redo with bulleted lists —- it often fails. Also, I have no idea how CocoaPods updates with forks work, so if someone needs me to do that, please point me in the right direction…-
### Features:
Scaling Text [TODO: move to Wiki]
- Bold
- Italic
- Underline
- Font
- Font size
- Text background color
- Text foreground color
- Text alignment
- Paragraph indent/outdent
- Bulleted lists
### Compatibility
The rich text editor is compatible with macOS 10.10+. It might work on older versions, but this has not been tested.
#### Keyboard Shortcuts
| Shortcut | Action |
| ------------- | ------------- |
| ⌘ + B | Toggle bold |
| ⌘ + I | Toggle italic |
| ⌘ + U | Toggle underline |
| ⌘ + ⇧ + > | Increase font size |
| ⌘ + ⇧ + < | Decrease font size |
| ⌘ + ⇧ + L | Toggle bulleted list |
| ⌘ + ⇧ + N | If in bulleted list, leave bulleted list |
| ⌘ + ⇧ + T | Decrease indent |
| ⌘ + T | Increase indent |
By 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`!
#### Scaling Text [TODO: move to Wiki]
If you want to scale text, you can use code similar to the following (based on http://stackoverflow.com/a/14113905/3938401):
```
@@ -59,112 +92,7 @@ If you want to scale text, you can use code similar to the following (based on h
```
RichTextEditor for iPhone &amp; iPad
Features:
- Bold
- Italic
- Underline
- StrikeThrough
- Font
- Font size
- Text background color
- Text foregroud color
- Text alignment
- Paragraph Indent/Outdent
![alt tag](https://raw.github.com/aryaxt/iOS-Rich-Text-Editor/master/ipadScreenShot.png)
![alt tag](https://raw.github.com/aryaxt/iOS-Rich-Text-Editor/master/iphoneScreenshot.png)
Custom Font Size Selection
-------------------------
Font size selection can be customized by implementing the following data source method
```objective-c
- (NSArray *)fontSizeSelectionForRichTextEditor:(RichTextEditor *)richTextEditor
{
// pas an array of NSNumbers
return @[@5, @10, @20, @30];
}
```
Custom Font Family Selection
-------------------------
Font family selection can be customized by implementing the following data source method
```objective-c
- (NSArray *)fontFamilySelectionForRichTextEditor:(RichTextEditor *)richTextEditor
{
// pas an array of Strings
// Can be taken from [UIFont familyNames]
return @[@"Helvetica", @"Arial", @"Marion", @"Papyrus"];
}
```
Presentation Style
-------------------------
You can switch between popover, or modal (presenting font-picker, font-size-picker, color-picker dialogs) by implementing the following data source method
```objective-c
- (RichTextEditorToolbarPresentationStyle)presentarionStyleForRichTextEditor:(RichTextEditor *)richTextEditor
{
// RichTextEditorToolbarPresentationStyleModal Or RichTextEditorToolbarPresentationStylePopover
return RichTextEditorToolbarPresentationStyleModal;
}
```
Modal Presentation Style
-------------------------
When presentarionStyleForRichTextEditor is a modal, modal-transition-style & modal-presentation-style can be configured
```objective-c
- (UIModalPresentationStyle)modalPresentationStyleForRichTextEditor:(RichTextEditor *)richTextEditor
{
return UIModalPresentationFormSheet;
}
- (UIModalTransitionStyle)modalTransitionStyleForRichTextEditor:(RichTextEditor *)richTextEditor
{
return UIModalTransitionStyleFlipHorizontal;
}
```
Customizing Features
-------------------------
Features can be turned on/off by iplementing the following data source method
```objective-c
- (RichTextEditorFeature)featuresEnabledForRichTextEditor:(RichTextEditor *)richTextEditor
{
return RichTextEditorFeatureFont |
RichTextEditorFeatureFontSize |
RichTextEditorFeatureBold |
RichTextEditorFeatureParagraphIndentation;
}
```
Enable/Disable RichText Toolbar
-------------------------
You can hide the rich text toolbar by implementing the following method. This method gets called everytime textView becomes first responder.
This can be usefull when you don't want the toolbar, instead you want to use the basic features (bold, italic, underline, strikeThrough), thoguht the UIMeMenuController
```objective-c
- (BOOL)shouldDisplayToolbarForRichTextEditor:(RichTextEditor *)richTextEditor
{
return YES;
}
```
Enable/Disable UIMenuController Options
-------------------------
On default the UIMenuController options (bold, italic, underline, strikeThrough) are turned off. You can implement the follwing method if you want these features to be available through the UIMenuController along with copy/paste/selectAll etc.
```objective-c
- (BOOL)shouldDisplayRichTextOptionsInMenuControllerForRichTextrEditor:(RichTextEditor *)richTextEdiotor
{
return YES;
}
```
Credits
-------------------------
iPhone popover by werner77
https://github.com/werner77/WEPopover
Original 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).
Binary file not shown.
@@ -0,0 +1,566 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
342F5A10206BF6DA0045E75A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F5A0F206BF6DA0045E75A /* AppDelegate.m */; };
342F5A13206BF6DA0045E75A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F5A12206BF6DA0045E75A /* ViewController.m */; };
342F5A15206BF6DA0045E75A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 342F5A14206BF6DA0045E75A /* Assets.xcassets */; };
342F5A18206BF6DA0045E75A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 342F5A16206BF6DA0045E75A /* Main.storyboard */; };
342F5A1B206BF6DA0045E75A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F5A1A206BF6DA0045E75A /* main.m */; };
342F5A26206BF6DA0045E75A /* macOSRTESampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F5A25206BF6DA0045E75A /* macOSRTESampleTests.m */; };
342F5A31206BF6DA0045E75A /* macOSRTESampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F5A30206BF6DA0045E75A /* macOSRTESampleUITests.m */; };
342F5A3F206BF6E40045E75A /* macOSRichTextEditor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 342F5A3E206BF6E40045E75A /* macOSRichTextEditor.framework */; };
342F5A40206BF6E40045E75A /* macOSRichTextEditor.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 342F5A3E206BF6E40045E75A /* macOSRichTextEditor.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
342F5A22206BF6DA0045E75A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 342F5A03206BF6DA0045E75A /* Project object */;
proxyType = 1;
remoteGlobalIDString = 342F5A0A206BF6DA0045E75A;
remoteInfo = macOSRTESample;
};
342F5A2D206BF6DA0045E75A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 342F5A03206BF6DA0045E75A /* Project object */;
proxyType = 1;
remoteGlobalIDString = 342F5A0A206BF6DA0045E75A;
remoteInfo = macOSRTESample;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
342F5A41206BF6E40045E75A /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
342F5A40206BF6E40045E75A /* macOSRichTextEditor.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
342F5A0B206BF6DA0045E75A /* macOSRTESample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = macOSRTESample.app; sourceTree = BUILT_PRODUCTS_DIR; };
342F5A0E206BF6DA0045E75A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
342F5A0F206BF6DA0045E75A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
342F5A11206BF6DA0045E75A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
342F5A12206BF6DA0045E75A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
342F5A14206BF6DA0045E75A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
342F5A17206BF6DA0045E75A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
342F5A19206BF6DA0045E75A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
342F5A1A206BF6DA0045E75A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
342F5A1C206BF6DA0045E75A /* macOSRTESample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = macOSRTESample.entitlements; sourceTree = "<group>"; };
342F5A21206BF6DA0045E75A /* macOSRTESampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = macOSRTESampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
342F5A25206BF6DA0045E75A /* macOSRTESampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = macOSRTESampleTests.m; sourceTree = "<group>"; };
342F5A27206BF6DA0045E75A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
342F5A2C206BF6DA0045E75A /* macOSRTESampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = macOSRTESampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
342F5A30206BF6DA0045E75A /* macOSRTESampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = macOSRTESampleUITests.m; sourceTree = "<group>"; };
342F5A32206BF6DA0045E75A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
342F5A3E206BF6E40045E75A /* macOSRichTextEditor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = macOSRichTextEditor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
342F5A08206BF6DA0045E75A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
342F5A3F206BF6E40045E75A /* macOSRichTextEditor.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
342F5A1E206BF6DA0045E75A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
342F5A29206BF6DA0045E75A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
342F5A02206BF6DA0045E75A = {
isa = PBXGroup;
children = (
342F5A3E206BF6E40045E75A /* macOSRichTextEditor.framework */,
342F5A0D206BF6DA0045E75A /* macOSRTESample */,
342F5A24206BF6DA0045E75A /* macOSRTESampleTests */,
342F5A2F206BF6DA0045E75A /* macOSRTESampleUITests */,
342F5A0C206BF6DA0045E75A /* Products */,
);
sourceTree = "<group>";
};
342F5A0C206BF6DA0045E75A /* Products */ = {
isa = PBXGroup;
children = (
342F5A0B206BF6DA0045E75A /* macOSRTESample.app */,
342F5A21206BF6DA0045E75A /* macOSRTESampleTests.xctest */,
342F5A2C206BF6DA0045E75A /* macOSRTESampleUITests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
342F5A0D206BF6DA0045E75A /* macOSRTESample */ = {
isa = PBXGroup;
children = (
342F5A0E206BF6DA0045E75A /* AppDelegate.h */,
342F5A0F206BF6DA0045E75A /* AppDelegate.m */,
342F5A11206BF6DA0045E75A /* ViewController.h */,
342F5A12206BF6DA0045E75A /* ViewController.m */,
342F5A14206BF6DA0045E75A /* Assets.xcassets */,
342F5A16206BF6DA0045E75A /* Main.storyboard */,
342F5A19206BF6DA0045E75A /* Info.plist */,
342F5A1A206BF6DA0045E75A /* main.m */,
342F5A1C206BF6DA0045E75A /* macOSRTESample.entitlements */,
);
path = macOSRTESample;
sourceTree = "<group>";
};
342F5A24206BF6DA0045E75A /* macOSRTESampleTests */ = {
isa = PBXGroup;
children = (
342F5A25206BF6DA0045E75A /* macOSRTESampleTests.m */,
342F5A27206BF6DA0045E75A /* Info.plist */,
);
path = macOSRTESampleTests;
sourceTree = "<group>";
};
342F5A2F206BF6DA0045E75A /* macOSRTESampleUITests */ = {
isa = PBXGroup;
children = (
342F5A30206BF6DA0045E75A /* macOSRTESampleUITests.m */,
342F5A32206BF6DA0045E75A /* Info.plist */,
);
path = macOSRTESampleUITests;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
342F5A0A206BF6DA0045E75A /* macOSRTESample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 342F5A35206BF6DA0045E75A /* Build configuration list for PBXNativeTarget "macOSRTESample" */;
buildPhases = (
342F5A07206BF6DA0045E75A /* Sources */,
342F5A08206BF6DA0045E75A /* Frameworks */,
342F5A09206BF6DA0045E75A /* Resources */,
342F5A41206BF6E40045E75A /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = macOSRTESample;
productName = macOSRTESample;
productReference = 342F5A0B206BF6DA0045E75A /* macOSRTESample.app */;
productType = "com.apple.product-type.application";
};
342F5A20206BF6DA0045E75A /* macOSRTESampleTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 342F5A38206BF6DA0045E75A /* Build configuration list for PBXNativeTarget "macOSRTESampleTests" */;
buildPhases = (
342F5A1D206BF6DA0045E75A /* Sources */,
342F5A1E206BF6DA0045E75A /* Frameworks */,
342F5A1F206BF6DA0045E75A /* Resources */,
);
buildRules = (
);
dependencies = (
342F5A23206BF6DA0045E75A /* PBXTargetDependency */,
);
name = macOSRTESampleTests;
productName = macOSRTESampleTests;
productReference = 342F5A21206BF6DA0045E75A /* macOSRTESampleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
342F5A2B206BF6DA0045E75A /* macOSRTESampleUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 342F5A3B206BF6DA0045E75A /* Build configuration list for PBXNativeTarget "macOSRTESampleUITests" */;
buildPhases = (
342F5A28206BF6DA0045E75A /* Sources */,
342F5A29206BF6DA0045E75A /* Frameworks */,
342F5A2A206BF6DA0045E75A /* Resources */,
);
buildRules = (
);
dependencies = (
342F5A2E206BF6DA0045E75A /* PBXTargetDependency */,
);
name = macOSRTESampleUITests;
productName = macOSRTESampleUITests;
productReference = 342F5A2C206BF6DA0045E75A /* macOSRTESampleUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
342F5A03206BF6DA0045E75A /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Pikle Productions";
TargetAttributes = {
342F5A0A206BF6DA0045E75A = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
342F5A20206BF6DA0045E75A = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
TestTargetID = 342F5A0A206BF6DA0045E75A;
};
342F5A2B206BF6DA0045E75A = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
TestTargetID = 342F5A0A206BF6DA0045E75A;
};
};
};
buildConfigurationList = 342F5A06206BF6DA0045E75A /* Build configuration list for PBXProject "macOSRTESample" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 342F5A02206BF6DA0045E75A;
productRefGroup = 342F5A0C206BF6DA0045E75A /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
342F5A0A206BF6DA0045E75A /* macOSRTESample */,
342F5A20206BF6DA0045E75A /* macOSRTESampleTests */,
342F5A2B206BF6DA0045E75A /* macOSRTESampleUITests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
342F5A09206BF6DA0045E75A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
342F5A15206BF6DA0045E75A /* Assets.xcassets in Resources */,
342F5A18206BF6DA0045E75A /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
342F5A1F206BF6DA0045E75A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
342F5A2A206BF6DA0045E75A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
342F5A07206BF6DA0045E75A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
342F5A13206BF6DA0045E75A /* ViewController.m in Sources */,
342F5A1B206BF6DA0045E75A /* main.m in Sources */,
342F5A10206BF6DA0045E75A /* AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
342F5A1D206BF6DA0045E75A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
342F5A26206BF6DA0045E75A /* macOSRTESampleTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
342F5A28206BF6DA0045E75A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
342F5A31206BF6DA0045E75A /* macOSRTESampleUITests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
342F5A23206BF6DA0045E75A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 342F5A0A206BF6DA0045E75A /* macOSRTESample */;
targetProxy = 342F5A22206BF6DA0045E75A /* PBXContainerItemProxy */;
};
342F5A2E206BF6DA0045E75A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 342F5A0A206BF6DA0045E75A /* macOSRTESample */;
targetProxy = 342F5A2D206BF6DA0045E75A /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
342F5A16206BF6DA0045E75A /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
342F5A17206BF6DA0045E75A /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
342F5A33206BF6DA0045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
342F5A34206BF6DA0045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
342F5A36206BF6DA0045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = macOSRTESample/macOSRTESample.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRTESample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRTESample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
342F5A37206BF6DA0045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = macOSRTESample/macOSRTESample.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRTESample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRTESample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
342F5A39206BF6DA0045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRTESampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRTESampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/macOSRTESample.app/Contents/MacOS/macOSRTESample";
};
name = Debug;
};
342F5A3A206BF6DA0045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRTESampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRTESampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/macOSRTESample.app/Contents/MacOS/macOSRTESample";
};
name = Release;
};
342F5A3C206BF6DA0045E75A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRTESampleUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRTESampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_TARGET_NAME = macOSRTESample;
};
name = Debug;
};
342F5A3D206BF6DA0045E75A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = macOSRTESampleUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pikleproductions.macOSRTESampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_TARGET_NAME = macOSRTESample;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
342F5A06206BF6DA0045E75A /* Build configuration list for PBXProject "macOSRTESample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F5A33206BF6DA0045E75A /* Debug */,
342F5A34206BF6DA0045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
342F5A35206BF6DA0045E75A /* Build configuration list for PBXNativeTarget "macOSRTESample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F5A36206BF6DA0045E75A /* Debug */,
342F5A37206BF6DA0045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
342F5A38206BF6DA0045E75A /* Build configuration list for PBXNativeTarget "macOSRTESampleTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F5A39206BF6DA0045E75A /* Debug */,
342F5A3A206BF6DA0045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
342F5A3B206BF6DA0045E75A /* Build configuration list for PBXNativeTarget "macOSRTESampleUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
342F5A3C206BF6DA0045E75A /* Debug */,
342F5A3D206BF6DA0045E75A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 342F5A03206BF6DA0045E75A /* Project object */;
}
+15
View File
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// macOSRTESample
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@end
+30
View File
@@ -0,0 +1,30 @@
//
// AppDelegate.m
// macOSRTESample
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
return YES;
}
@end
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "format-bold.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "format-bold-48.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "format-list-bulleted-24.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "format-list-bulleted-48.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "format-indent-decrease-24.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "format-indent-decrease-48.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "format-indent-increase-24.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "format-indent-increase-48.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "format-italic-24.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "format-italic-48.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "format-underline-24.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "format-underline-48.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Pikle Productions. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
+15
View File
@@ -0,0 +1,15 @@
//
// ViewController.h
// macOSRTESample
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface ViewController : NSViewController
@end
+151
View File
@@ -0,0 +1,151 @@
//
// ViewController.m
// macOSRTESample
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import "ViewController.h"
#import <macOSRichTextEditor/RichTextEditor.h>
@interface NSImage (Tint)
- (NSImage *)imageTintedWithColor:(NSColor *)tint;
@end
@implementation NSImage (Tint)
// https://stackoverflow.com/a/16138027/3938401
- (NSImage *)imageTintedWithColor:(NSColor *)tint {
NSImage *image = [self copy];
if (tint) {
[image lockFocus];
[tint set];
NSRect imageRect = {NSZeroPoint, [image size]};
NSRectFillUsingOperation(imageRect, NSCompositingOperationSourceAtop);
[image unlockFocus];
}
return image;
}
@end
@interface ViewController () <RichTextEditorDelegate>
@property (unsafe_unretained) IBOutlet RichTextEditor *richTextEditor;
@property (weak) IBOutlet NSButton *boldButton;
@property (weak) IBOutlet NSButton *italicButton;
@property (weak) IBOutlet NSButton *underlineButton;
@property (weak) IBOutlet NSButton *bulletedListButton;
@property (weak) IBOutlet NSButton *decreaseIndentButton;
@property (weak) IBOutlet NSButton *increaseIndentButton;
@property (weak) IBOutlet NSColorWell *fontColorWell;
@property (weak) IBOutlet NSColorWell *highlightColorWell;
@property (weak) IBOutlet NSButton *tabKeyAlwaysIndentsButton;
-(IBAction)toggleBold:(id)sender;
-(IBAction)toggleItalic:(id)sender;
-(IBAction)toggleUnderline:(id)sender;
-(IBAction)toggleBulletedList:(id)sender;
-(IBAction)decreaseIndent:(id)sender;
-(IBAction)increaseIndent:(id)sender;
-(IBAction)decreaseFontSize:(id)sender;
-(IBAction)increaseFontSize:(id)sender;
- (IBAction)fontColorChanged:(id)sender;
- (IBAction)highlightColorChanged:(id)sender;
- (IBAction)tabAlwaysIndentsChecked:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.richTextEditor.rteDelegate = self;
}
-(IBAction)toggleBold:(id)sender {
[self.richTextEditor userSelectedBold];
}
-(IBAction)toggleItalic:(id)sender {
[self.richTextEditor userSelectedItalic];
}
-(IBAction)toggleUnderline:(id)sender {
[self.richTextEditor userSelectedUnderline];
}
-(IBAction)toggleBulletedList:(id)sender {
[self.richTextEditor userSelectedBullet];
}
-(IBAction)decreaseIndent:(id)sender {
[self.richTextEditor userSelectedDecreaseIndent];
}
-(IBAction)increaseIndent:(id)sender {
[self.richTextEditor userSelectedIncreaseIndent];
}
-(IBAction)decreaseFontSize:(id)sender {
[self.richTextEditor decreaseFontSize];
}
-(IBAction)increaseFontSize:(id)sender {
[self.richTextEditor increaseFontSize];
}
- (IBAction)fontColorChanged:(id)sender {
[self.richTextEditor userSelectedTextColor:self.fontColorWell.color];
}
- (IBAction)highlightColorChanged:(id)sender {
[self.richTextEditor userSelectedTextBackgroundColor:self.highlightColorWell.color];
}
- (void)richTextEditor:(RichTextEditor*)editor changeAboutToOccurOfType:(RichTextEditorPreviewChange)type {
NSLog(@"User just edited the RTE by performing this operation: %@", [RichTextEditor convertPreviewChangeTypeToString:type withNonSpecialChangeText:YES]);
}
-(void)selectionForEditor:(RichTextEditor*)editor changedTo:(NSRange)range isBold:(BOOL)isBold isItalic:(BOOL)isItalic isUnderline:(BOOL)isUnderline isInBulletedList:(BOOL)isInBulletedList textBackgroundColor:(NSColor*)textBackgroundColor textColor:(NSColor*)textColor {
if (isBold) {
self.boldButton.image = [[NSImage imageNamed:@"bold"] imageTintedWithColor:NSColor.blueColor];
}
else {
self.boldButton.image = [[NSImage imageNamed:@"bold"] imageTintedWithColor:NSColor.blackColor];
}
if (isItalic) {
self.italicButton.image = [[NSImage imageNamed:@"italic"] imageTintedWithColor:NSColor.blueColor];
}
else {
self.italicButton.image = [[NSImage imageNamed:@"italic"] imageTintedWithColor:NSColor.blackColor];
}
if (isUnderline) {
self.underlineButton.image = [[NSImage imageNamed:@"underline"] imageTintedWithColor:NSColor.blueColor];
}
else {
self.underlineButton.image = [[NSImage imageNamed:@"underline"] imageTintedWithColor:NSColor.blackColor];
}
if (isInBulletedList) {
self.bulletedListButton.image = [[NSImage imageNamed:@"bulleted-list"] imageTintedWithColor:NSColor.blueColor];
}
else {
self.bulletedListButton.image = [[NSImage imageNamed:@"bulleted-list"] imageTintedWithColor:NSColor.blackColor];
}
self.fontColorWell.color = textColor;
}
- (IBAction)tabAlwaysIndentsChecked:(id)sender {
self.richTextEditor.tabKeyAlwaysIndentsOutdents = self.tabKeyAlwaysIndentsButton.state == NSOnState;
}
@end
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
@@ -0,0 +1 @@
Versions/Current/Headers
@@ -0,0 +1 @@
Versions/Current/Modules
@@ -0,0 +1 @@
Versions/Current/PrivateHeaders
@@ -0,0 +1 @@
Versions/Current/Resources
@@ -0,0 +1,40 @@
//
// NSAttributedString+RichTextEditor.h
// RichTextEdtor
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import "NSFont+RichTextEditor.h"
@interface NSAttributedString (RichTextEditor)
- (NSRange)firstParagraphRangeFromTextRange:(NSRange)range;
- (NSArray *)rangeOfParagraphsFromTextRange:(NSRange)textRange;
- (NSString *)htmlString;
@end
@@ -0,0 +1,43 @@
//
// UIFont+RichTextEditor.h
// RichTextEdtor
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Cocoa/Cocoa.h>
#import <CoreText/CoreText.h>
@interface NSFont (RichTextEditor)
+ (NSString *)postscriptNameFromFullName:(NSString *)fullName;
+ (NSFont *)fontWithName:(NSString *)name size:(CGFloat)size boldTrait:(BOOL)isBold italicTrait:(BOOL)isItalic;
- (NSFont *)fontWithBoldTrait:(BOOL)bold italicTrait:(BOOL)italic andSize:(CGFloat)size;
- (NSFont *)fontWithBoldTrait:(BOOL)bold andItalicTrait:(BOOL)italic;
- (BOOL)isBold;
- (BOOL)isItalic;
@end
@@ -4,11 +4,11 @@
//
// Created by Aryan Gh on 7/21/13.
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
// Heavily modified for iOS and OS X by Deadpikle
// Heavily modified for macOS by Deadpikle
// Copyright (c) 2016 Deadpikle. All rights reserved.
//
// https://github.com/aryaxt/iOS-Rich-Text-Editor -- Original
// https://github.com/Deadpikle/iOS-and-Mac-OS-X-Rich-Text-Editor -- Fork
// https://github.com/Deadpikle/macOS-Rich-Text-Editor -- Fork
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -45,27 +45,29 @@
- (NSUInteger)levelsOfUndo;
@end
// These values will always start from 0 and go up. If you want to add your own
// preview changes via a subclass, start from 9999 and go down (or similar) and
// override convertPreviewChangeTypeToString:withNonSpecialChangeText:
typedef NS_ENUM(NSInteger, RichTextEditorPreviewChange) {
RichTextEditorPreviewChangeBold,
RichTextEditorPreviewChangeItalic,
RichTextEditorPreviewChangeUnderline,
RichTextEditorPreviewChangeFontResize,
RichTextEditorPreviewChangeHighlight,
RichTextEditorPreviewChangeFontSize,
RichTextEditorPreviewChangeFontColor,
RichTextEditorPreviewChangeIndentIncrease,
RichTextEditorPreviewChangeIndentDecrease,
RichTextEditorPreviewChangeCut,
RichTextEditorPreviewChangePaste,
RichTextEditorPreviewChangePageBreak,
RichTextEditorPreviewChangeSpace,
RichTextEditorPreviewChangeEnter,
RichTextEditorPreviewChangeBullet,
RichTextEditorPreviewChangeMouseDown,
RichTextEditorPreviewChangeArrowKey,
RichTextEditorPreviewChangeKeyDown,
RichTextEditorPreviewChangeDelete
RichTextEditorPreviewChangeBold = 0,
RichTextEditorPreviewChangeItalic = 1,
RichTextEditorPreviewChangeUnderline = 2,
RichTextEditorPreviewChangeFontResize = 3,
RichTextEditorPreviewChangeHighlight = 4,
RichTextEditorPreviewChangeFontSize = 5,
RichTextEditorPreviewChangeFontColor = 6,
RichTextEditorPreviewChangeIndentIncrease = 7,
RichTextEditorPreviewChangeIndentDecrease = 8,
RichTextEditorPreviewChangeCut = 9,
RichTextEditorPreviewChangePaste = 10,
RichTextEditorPreviewChangeSpace = 11,
RichTextEditorPreviewChangeEnter = 12,
RichTextEditorPreviewChangeBullet = 13,
RichTextEditorPreviewChangeMouseDown = 14,
RichTextEditorPreviewChangeArrowKey = 15,
RichTextEditorPreviewChangeKeyDown = 16,
RichTextEditorPreviewChangeDelete = 17,
RichTextEditorPreviewChangeFindReplace = 18
};
@protocol RichTextEditorDelegate <NSObject>
@@ -96,6 +98,7 @@ typedef NS_ENUM(NSInteger, ParagraphIndentation) {
@property (assign) IBOutlet id <RichTextEditorDataSource> rteDataSource;
@property (assign) IBOutlet id <RichTextEditorDelegate> rteDelegate;
@property (nonatomic, assign) CGFloat defaultIndentationSize;
@property (nonatomic, readonly) unichar lastSingleKeyPressed;
// If YES, only pastes text as rich text if the copy operation came from this class.
// Note: not this *object* -- this class (so other RichTextEditor boxes can paste
@@ -136,11 +139,19 @@ typedef NS_ENUM(NSInteger, ParagraphIndentation) {
- (void)setBorderColor:(NSColor*)borderColor;
- (void)setBorderWidth:(CGFloat)borderWidth;
- (void)userSelectedPageBreak:(NSString*)pageBreakString;
- (NSString *)htmlString;
- (void)setHtmlString:(NSString *)htmlString;
- (NSString*)bulletString;
+ (NSString *)htmlStringFromAttributedText:(NSAttributedString*)text;
+ (NSAttributedString*)attributedStringFromHTMLString:(NSString *)htmlString;
+ (NSString *)convertPreviewChangeTypeToString:(RichTextEditorPreviewChange)changeType withNonSpecialChangeText:(BOOL)shouldReturnStringForNonSpecialType;
// I'm not sure why you'd call these externally, but subclasses can make use of this for custom toolbar items or what have you.
// It's just easier to put these in the public header than to have a protected/subclasses-only header.
-(void)sendDelegatePreviewChangeOfType:(RichTextEditorPreviewChange)type;
-(void)sendDelegateTVChanged;
@end
@@ -0,0 +1,21 @@
//
// macOSRichTextEditor.h
// macOSRichTextEditor
//
// Created by School of Computing Macbook on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//! Project version number for macOSRichTextEditor.
FOUNDATION_EXPORT double macOSRichTextEditorVersionNumber;
//! Project version string for macOSRichTextEditor.
FOUNDATION_EXPORT const unsigned char macOSRichTextEditorVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <macOSRichTextEditor/PublicHeader.h>
#include <macOSRichTextEditor/RichTextEditor.h>
#include <macOSRichTextEditor/NSFont+RichTextEditor.h>
#include <macOSRichTextEditor/NSAttributedString+RichTextEditor.h>
@@ -0,0 +1,6 @@
framework module macOSRichTextEditor {
umbrella header "macOSRichTextEditor.h"
export *
module * { export * }
}
@@ -0,0 +1,20 @@
//
// WZProtocolInterceptor.h
//
// Created by WeZZard on 10/13/13.
// Copyright © 2013 WeZZard. All rights reserved.
// http://stackoverflow.com/a/18777565/3938401
#import <Foundation/Foundation.h>
@interface WZProtocolInterceptor : NSObject
@property (nonatomic, readonly, copy) NSArray * interceptedProtocols;
@property (unsafe_unretained) id receiver;
@property (unsafe_unretained) id middleMan;
- (instancetype)initWithInterceptedProtocol:(Protocol *)interceptedProtocol;
- (instancetype)initWithInterceptedProtocols:(Protocol *)firstInterceptedProtocol, ... NS_REQUIRES_NIL_TERMINATION;
- (instancetype)initWithArrayOfInterceptedProtocols:(NSArray *)arrayOfInterceptedProtocols;
@end
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>17D102</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>macOSRichTextEditor</string>
<key>CFBundleIdentifier</key>
<string>com.pikleproductions.macOSRichTextEditor</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>macOSRichTextEditor</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>9C40b</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>17C76</string>
<key>DTSDKName</key>
<string>macosx10.13</string>
<key>DTXcode</key>
<string>0920</string>
<key>DTXcodeBuild</key>
<string>9C40b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Pikle Productions. All rights reserved.</string>
</dict>
</plist>
@@ -0,0 +1 @@
A
@@ -0,0 +1 @@
Versions/Current/macOSRichTextEditor
+13
View File
@@ -0,0 +1,13 @@
//
// main.m
// macOSRTESample
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
}
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
@@ -0,0 +1,39 @@
//
// macOSRTESampleTests.m
// macOSRTESampleTests
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface macOSRTESampleTests : XCTestCase
@end
@implementation macOSRTESampleTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
@@ -0,0 +1,40 @@
//
// macOSRTESampleUITests.m
// macOSRTESampleUITests
//
// Created by Deadpikle on 3/28/18.
// Copyright © 2018 Pikle Productions. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface macOSRTESampleUITests : XCTestCase
@end
@implementation macOSRTESampleUITests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
self.continueAfterFailure = NO;
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
[[[XCUIApplication alloc] init] launch];
// In UI tests its important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
@end
-18
View File
@@ -1,18 +0,0 @@
Pod::Spec.new do |s|
s.name = 'iOS-Rich-Text-Editor'
s.version = '0.0.1'
s.summary = 'A RichTextEditor for iPhone & iPad.'
s.homepage = 'https://github.com/aryaxt/iOS-Rich-Text-Editor'
s.dependency 'WEPopover', '~> 1.0.0'
s.license = {
:type => 'MIT',
:file => 'License.txt'
}
s.author = {'Aryan Gh' => 'https://github.com/aryaxt/iOS-Rich-Text-Editor'}
s.source = {:git => 'https://github.com/aryaxt/iOS-Rich-Text-Editor.git', :tag => '0.0.1'}
s.platform = :ios, '6.0'
s.source_files = 'RichTextEditor/Source/*.{h,m}','RichTextEditor/Source/Categories/*.{h,m}'
s.resources = ['RichTextEditor/Source/Assets/**/*']
s.framework = 'Foundation', 'UIKit'
s.requires_arc = true
end
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Sample/macOSRTESample.xcodeproj">
</FileRef>
<FileRef
location = "group:Library/macOSRichTextEditor.xcodeproj">
</FileRef>
<FileRef
location = "group:README.md">
</FileRef>
</Workspace>