ZSSRichTextEditor icon indicating copy to clipboard operation
ZSSRichTextEditor copied to clipboard

ZSSRichTextEditorToolbarBold == ZSSRichTextEditorToolbarItalic

Open fabb opened this issue 11 years ago • 11 comments

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.

fabb avatar Nov 26 '14 08:11 fabb

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.

nnhubbard avatar Nov 26 '14 08:11 nnhubbard

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?

fabb avatar Nov 26 '14 08:11 fabb

Oh, you were faster than me, awesome :-)

fabb avatar Nov 26 '14 08:11 fabb

Thanks for your help on bringing up these issues. Trying to find the time to get to them...

nnhubbard avatar Nov 26 '14 08:11 nnhubbard

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.

fabb avatar Nov 26 '14 08:11 fabb

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.

fabb avatar Nov 26 '14 09:11 fabb

Fixed. Please test the project and reopen the issue if you still see issues.

nnhubbard avatar Nov 26 '14 09:11 nnhubbard

Works better now.

I'd recommend 2 things though:

  • Now that there is an array for the activated items, in itemsForToolbar iterate over _enabledToolbarItems. This allows the client to choose the order of the items.
  • Removal of ZSSRichTextEditorToolbarAll and ZSSRichTextEditorToolbarNone, 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 -enableAllToolbarItems or have a method +defaultToolbarItems that returns an array of all items in the default order which a client can set on enabledToolbarItems himself or even edit it afterwards (the library could accept ZSSBarButtonItems in the _enabledToolbarItems array, and build the bar accordingly in itemsForToolbar). For ZSSRichTextEditorToolbarNone IMHO there is no convenience method necessary, as the client can easily set enabledToolbarItems = @[].

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 :-)

fabb avatar Nov 26 '14 10:11 fabb

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

fabb avatar Nov 26 '14 10:11 fabb

@nnhubbard I cannot reopen issues in your project.

fabb avatar Nov 26 '14 11:11 fabb

@fabb I will have a look into this.

willptswan avatar Sep 02 '16 23:09 willptswan