docs(ui-kit/ios): rich-text toolbar trailing buttons - #523
shreeyajoshi-cometchat wants to merge 3 commits into
Conversation
Documents set(richTextToolbarActions:), CometChatRichTextToolbarAction and the CometChatComposerInput handle on CometChatCompactMessageComposer, which shipped without docs on any iOS page. Follows the Flutter section's shape (open PR #461): what the API appends and how it differs from replacing the toolbar, a handle member table, a Swift example, and a "Leaving mentions alone" subsection. The iOS API skips mentions by default via skippingMentions, so that subsection documents the opt-out rather than hand-rolled range maths. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
… survive send The first draft warned that attributes are dropped on send without saying that colour is the exception, which left the most likely use case — a colour button — looking impossible when the Kit supports it natively. Text colour has a wire representation (<color=#rrggbb>), serialized by convertToMarkdown and parsed back in the bubble. Reaching it requires the public RichTextFormatterManager.textColorKey alongside .foregroundColor, since .foregroundColor alone is written by six different things and records nothing about who set it. That key was documented nowhere. Adds a "Colour that survives send" subsection, rewrites the Note to separate durable colour from genuinely composer-local attributes, and corrects the mentions example, which used .backgroundColor and so modelled the lossy pattern. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jitvarpatil
left a comment
There was a problem hiding this comment.
Review: iOS compact composer — trailing toolbar actions
Requesting changes / hold. The page is well written and most of it matches the source, but the API isn't in any release yet, and one documented parameter has already been renamed, so the examples that use it won't compile. Checked against the current head of cometchat-team/uikit-ios#980 (ashfaq/eng-38638/merge-aditya @ 66ebac808), not only the commit cited in the description.
🔴 Blockers
1. The API isn't in any release
CometChatRichTextToolbarAction, CometChatComposerInput and textColorKey have 0 hits in release-v5-5.1.22, dev-v5 and master-v5. uikit-ios#980 ("Enterprise Readiness: Tracks 1, 2 and 3 combined") is still open. As the description already suggests, please hold until it ships, then add an "Available since vX" note like the other pin/save/thread pages.
2. skippingMentions: no longer exists — it's now protectingKitRuns:
Renamed in 30bc8955e ("fix(composer): preserve user text colour across code block transitions"). 234a9faf4 had skippingMentions ×11; the branch head has 0. Anyone copying from the member table or Leaving mentions alone gets a compile error on all four mutators:
public func applyAttributes(_:to:protectingKitRuns: Bool = true)
public func removeAttributes(_:from:protectingKitRuns: Bool = true)
public func applyAttributesToSelection(_:protectingKitRuns: Bool = true) -> Bool
public func removeAttributesFromSelection(_:protectingKitRuns: Bool = true) -> BoolThe meaning is also broader: it protects mentions, links, inline code, code blocks and the blockquote bar ("runs the kit paints on its own schedule"), not just mentions. That subsection needs rewording, not only a rename. (Side note for the UI Kit team: the mentionRanges doc comment in CometChatComposerInput.swift still says "the mutating methods skip these by default", which is now stale.)
3. "A colour that cannot be sent is not applied locally either" is wrong for this API
That rule is enforced only for hex strings (RichTextWireFormat.isValidHex). applyAttributes / applyAttributesToSelection don't validate colours, so a UIColor with alpha < 1 is rendered in the composer. On send, wireFormatHex returns nil when alpha < 1 (RichTextWireFormat.swift:199) and the colour is silently dropped — exactly the "renders in the composer, vanishes on send" bug this section sets out to prevent. Suggest: "Use opaque colours. A translucent UIColor renders in the composer but is dropped on send; on the wire only #rgb and #rrggbb are accepted (#rrggbbaa is rejected, since a transparent run would be an invisible message)."
🟠 Should fix
- Commit in the description — it cites
234a9faf4, buttextColorKeydoesn't exist at that commit; it was added later on the branch. Please re-verify against the final merged SHA before merging. - Nit — the "highlight" example actually turns the text red. Rename it (e.g.
id: "red_text") so readers don't expect a background highlight.
✅ Verified correct at branch head
CometChatRichTextToolbarActionfields and init (tint/accessibilityLabeldefaultnil,onClicklast) — the trailing-closure examples compile.set(richTextToolbarActions:)closure signature;trailingActionButtonsispublic private(set);showRichTextFormattingOptions/enableRichTextFormattingnames.CometChatComposerInput:text,attributedText,selectedRange,hasSelection,typingAttributes,mentionRanges,attributes(at:),insertAtCaret,setAttributedText(_:preservingSelection:),setSelectedRange,commit(). Valid only duringonClick(text view held weakly), andcommit()runs automatically afteronClick(CometChatRichTextToolbar.swift:237-238).RichTextFormatterManager.textColorKeyis public with the "write and remove together with.foregroundColor" contract;<color=#rrggbb>wire format;#rgb/#rrggbbaccepted,#rrggbbaarejected.
The member table and "Leaving mentions alone" named the mutators' parameter `skippingMentions`, which does not exist on the shipped branch — it is `protectingKitRuns`. Anyone copying the documented signature got a compile error. The meaning was understated too. The flag protects every run the kit repaints on its own schedule, not just mentions: links (including a URL still being typed), inline code, code blocks, monospaced runs, and fully transparent runs. Reworked the subsection around that and renamed it accordingly; blockquote is deliberately absent, since the composer draws its quote bar as a view rather than as text. Also corrected the colour note: a translucent UIColor is not rejected locally. It renders in the composer and is dropped on send, which is the silent loss the section exists to prevent. Renamed the example from "highlight" to "red_text", which is what it actually does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks — all three blockers confirmed against the branch head, and the parameter rename is now pushed. Fixed in
On the blockquote bar — I left it out of the protected list deliberately. Holding on blocker 1 as you asked. All four symbols are absent from |
Documents the custom composer trailing buttons that shipped on the iOS UI Kit (
ashfaq/eng-38638/merge-aditya, head66ebac808, open as cometchat-team/uikit-ios#980) and had no documentation on any iOS page.What's covered
One new section, Trailing toolbar actions, in
ui-kit/ios/compact-message-composer.mdx, placed afterRichTextToolbarStylewhere the toolbar context already is:set(richTextToolbarActions:)— what it appends, and how it differs from replacing the toolbarCometChatRichTextToolbarAction— property table (id,icon,onClick,tint,accessibilityLabel)CometChatComposerInput— member table for the live read/mutate handleThe API is on
CometChatCompactMessageComposeronly, notCometChatMessageComposer, so this is the only page that changes. The page is already indocs.jsonnav — no nav change needed.Colour, and why it needed its own subsection
The composer serializes to markdown on send, so most attributes applied through
CometChatComposerInputare composer-local and dropped. Text colour is the exception — it has a wire representation,<color=#rrggbb>, serialized byconvertToMarkdownand parsed back in the bubble.Reaching it requires
RichTextFormatterManager.textColorKeyalongside.foregroundColor..foregroundColoralone is written by six different things (mentions, links, inline code, code blocks, ordinary text, the user) and records nothing about who set it, so the serializer keys off the marker instead. Both symbols arepublic, andtextColorKeycarries a usage contract in its doc comment — "Always write and remove it together with.foregroundColor" — yet it appeared in no.mdxfile on any platform.This matters because a colour button is the most obvious thing anyone builds with a trailing-action slot, and the Kit ships no colour button of its own. Documenting the slot without the marker is what produces the silent-loss bug: colour renders in the composer, then vanishes on send with no error. So the docs cover the pairing rule, clearing colour, and why
#rrggbbaais rejected (a fully transparent run is an invisible-message vector).Cross-platform context
Modelled on the Flutter section in #461, which is the closest analogue (both use an action-list rather than a view/template slot). Where iOS genuinely differs, the docs follow the iOS API rather than Flutter's:
protectingKitRuns: true— mentions, links (including a URL still being typed), inline code, code blocks, monospaced runs and fully transparent runs — so the subsection documents the opt-out instead of Flutter's hand-rolled overlap maths, which covers mentions only.lastNonCollapsedSelectionnote is omitted.On colour, iOS is one of three platforms with Kit-side support — and the only one that documents it.
<color=#rrggbb>serialized byRichTextFormatterManager, keyed offtextColorKey. Documented here for the first time.master-v6:rich_text_span.dartwraps coloured ranges in<color=#RRGGBB>…</color>, with tests asserting the output, andmaster_appdrives it from a trailing action viaonToolbarTap. Undocumented —applyInlineStyle/removeInlineStyleappear in no.mdxfile, and docs(flutter): thread subscriptions, pin & save, composer trailing to… #461 documents only text insertion.applyInlineStyle('color', …)/removeInlineStyle, bridged to native on both platforms;StyleRange.colordescribes#rrggbbas "the wire format's only value-carrying style". Undocumented, and RN has no trailing-button section yet.{color=…}regex in consumer code, so the integrator invents the marker and writes the formatter. Documented, but as a build-your-own guide rather than an API reference.ComposerInputControllerexposes no attribute API at all (insertAtCursor,replaceSelection,toggleFormat,mentionRanges()), so colour can't arise from a trailing button.Consequence worth flagging beyond this PR: Flutter's and RN's colour support is undocumented, and the React/Angular guide is not a template for them — copying it would have integrators hand-rolling a
{color=…}marker while the Kit's own<color=#RRGGBB>sits unused, and the two don't interoperate.Trailing-button slot status elsewhere: Android, React and Angular are merged; Flutter is open in #461; React Native has a design-doc branch (
eng-37949-composer-trailing-buttons-dd) but no shipped slot.Verification
<Tabs>/<Tab>/<Note>tags and code fences balancedCometChatRichTextToolbarAction.swift,CometChatComposerInput.swift,RichTextFormatterManager.swift), not paraphrased from another platformRichTextFormatterManagerandtextColorKeyconfirmedpublic, so the documented route is genuinely integrator-reachableconvertToMarkdownenumeratingtextColorKey), not inferred^docs/CI ruleMerge order
This documents API that ships when cometchat-team/uikit-ios#980 merges to
dev-v5and reaches a release. Worth holding until then, so the docs don't describe an API that isn't in a released version yet.Note that #980 has moved during its own life —
protectingKitRunswas renamed fromskippingMentions, andtextColorKeydid not exist at the commit this description originally cited — so the page is worth re-verifying against the final merge commit ondev-v5rather than any interim head,66ebac808included. An "Available since" note goes in once it ships.🤖 Generated with Claude Code