ZSSRichTextEditorToolbarBold == ZSSRichTextEditorToolbarItalic
ZSSRichTextEditorToolbarBold and ZSSRichTextEditorToolbarItalic are represented by the same bit:
ZSSRichTextEditorToolbarBold = 1,
ZSSRichTextEditorToolbarItalic = 1 << 0,
https://github.com/nnhubbard/ZSSRichTextEditor/blob/8235107b2b96b8e8de0235da91516fa1527a5e4d/ZSSRichTextEditor/ZSSRichTextEditor.h#L17
Seems like we're out of bits for an 32 bit integer.
I guess ZSSRichTextEditorToolbarAll and ZSSRichTextEditorToolbarNone should not be represented by a bit, but by the whole integer number. ZSSRichTextEditorToolbarAll would be NSUIntegerMax (or OR the single enums together) and ZSSRichTextEditorToolbarNone would be 0.
Compare to the UIRectEdge enum.
Note that ZSSRichTextEditorToolbarAll and ZSSRichTextEditorToolbarNone would not be able to be ORed anymore, they would need to be directly assigned. Note that this would be more clean, but it would also break backwards compatibility for clients.
I have a new version that I hope to push out soon that no longer uses enums but uses an NSArray instead. Works much better.
Maybe the toolbar items should not be represented by a bitmask at all? A downside of the bitmask is that one cannot influence the order of buttons in the toolbar. Maybe rather use an array?
Oh, you were faster than me, awesome :-)
Thanks for your help on bringing up these issues. Trying to find the time to get to them...
Sure. We evaluate this library for our upcoming iOS app, and it seems the best alternative for rich text editing out there. Great stuff Nic!
Unfortunately the UIWebView and also WKWebView have some quirks with keyboard handling, but that topic is part of another issue.
Uuuh, I noted that no toolbar items will show at all when ZSSRichTextEditorToolbarParagraph is active. Somehow _enabledToolbarItems & ZSSRichTextEditorToolbarNone evaluates to YES in this case. This will surely also be fixed by your new version.
Fixed. Please test the project and reopen the issue if you still see issues.
Works better now.
I'd recommend 2 things though:
- Now that there is an array for the activated items, in
itemsForToolbariterate over_enabledToolbarItems. This allows the client to choose the order of the items. - Removal of
ZSSRichTextEditorToolbarAllandZSSRichTextEditorToolbarNone, as they are no items. As unfortunately it is not possible to have a global NSArray variable, I'd recommend to either have a method-enableAllToolbarItemsor have a method+defaultToolbarItemsthat returns an array of all items in the default order which a client can set onenabledToolbarItemshimself or even edit it afterwards (the library could acceptZSSBarButtonItems in the_enabledToolbarItemsarray, and build the bar accordingly initemsForToolbar). ForZSSRichTextEditorToolbarNoneIMHO there is no convenience method necessary, as the client can easily setenabledToolbarItems = @[].
BTW you have left NSLog calls in there.
Shouldn't the library version at least increment the minor version? According to http://semver.org/ it should even be the major version, but I guess that's a bit harsh. Does Cocoapods work with 4 digit versions? Sorry for my pickyness :-)
Ok one new issue in the new version: The keyboard appears, disappears and appears again when tapping into the text area the first time. I'll make a new issue for this. See #70
@nnhubbard I cannot reopen issues in your project.
@fabb I will have a look into this.