@tldraw/commenting 5.7.0-next.433c23fa9ce6 → 5.7.0-next.60f5dc13db82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/commenting.css +3 -0
  2. package/dist-cjs/canvas/comments-sidebar.js +3 -1
  3. package/dist-cjs/canvas/comments-sidebar.js.map +2 -2
  4. package/dist-cjs/canvas/options.js.map +2 -2
  5. package/dist-cjs/canvas/pending-composer.js +4 -2
  6. package/dist-cjs/canvas/pending-composer.js.map +2 -2
  7. package/dist-cjs/canvas/thread-pin.js +2 -1
  8. package/dist-cjs/canvas/thread-pin.js.map +2 -2
  9. package/dist-cjs/canvas/thread-view.js +30 -3
  10. package/dist-cjs/canvas/thread-view.js.map +2 -2
  11. package/dist-cjs/index.d.ts +29 -3
  12. package/dist-cjs/index.js +1 -1
  13. package/dist-cjs/ui/byline.js +2 -2
  14. package/dist-cjs/ui/byline.js.map +2 -2
  15. package/dist-cjs/ui/comment-card.js +3 -1
  16. package/dist-cjs/ui/comment-card.js.map +2 -2
  17. package/dist-cjs/ui/comments-list.js +2 -1
  18. package/dist-cjs/ui/comments-list.js.map +2 -2
  19. package/dist-esm/canvas/comments-sidebar.mjs +3 -1
  20. package/dist-esm/canvas/comments-sidebar.mjs.map +2 -2
  21. package/dist-esm/canvas/options.mjs.map +2 -2
  22. package/dist-esm/canvas/pending-composer.mjs +4 -2
  23. package/dist-esm/canvas/pending-composer.mjs.map +2 -2
  24. package/dist-esm/canvas/thread-pin.mjs +3 -2
  25. package/dist-esm/canvas/thread-pin.mjs.map +2 -2
  26. package/dist-esm/canvas/thread-view.mjs +30 -3
  27. package/dist-esm/canvas/thread-view.mjs.map +2 -2
  28. package/dist-esm/index.d.mts +29 -3
  29. package/dist-esm/index.mjs +1 -1
  30. package/dist-esm/ui/byline.mjs +2 -2
  31. package/dist-esm/ui/byline.mjs.map +2 -2
  32. package/dist-esm/ui/comment-card.mjs +3 -1
  33. package/dist-esm/ui/comment-card.mjs.map +2 -2
  34. package/dist-esm/ui/comments-list.mjs +2 -1
  35. package/dist-esm/ui/comments-list.mjs.map +2 -2
  36. package/package.json +5 -5
  37. package/src/canvas/canvas.css +3 -0
  38. package/src/canvas/comments-sidebar.tsx +2 -0
  39. package/src/canvas/options.ts +16 -0
  40. package/src/canvas/pending-composer.tsx +6 -2
  41. package/src/canvas/thread-pin.tsx +5 -2
  42. package/src/canvas/thread-view.test.ts +39 -0
  43. package/src/canvas/thread-view.tsx +37 -3
  44. package/src/ui/byline.tsx +5 -2
  45. package/src/ui/comment-card.tsx +7 -1
  46. package/src/ui/comments-list.tsx +4 -1
@@ -6,11 +6,13 @@ function CommentCard({
6
6
  date,
7
7
  you,
8
8
  edited,
9
+ byline,
10
+ renderAvatar,
9
11
  actions,
10
12
  footer
11
13
  }) {
12
14
  return /* @__PURE__ */ jsxs("div", { className: you ? "tlui-cmt-card tlui-cmt-card--you" : "tlui-cmt-card", children: [
13
- /* @__PURE__ */ jsx(Byline, { author, date, edited }),
15
+ byline ?? /* @__PURE__ */ jsx(Byline, { author, date, edited, renderAvatar }),
14
16
  /* @__PURE__ */ jsxs("div", { className: "tlui-cmt-body", children: [
15
17
  body,
16
18
  footer
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/comment-card.tsx"],
4
- "sourcesContent": ["import { type CommentAuthor } from '@tldraw/mentions'\nimport { ReactNode } from 'react'\nimport { Byline } from './byline'\n\n/** @public */\nexport interface CommentCardProps {\n\tauthor: CommentAuthor\n\t/** The rendered comment body. The card doesn't dictate a format \u2014 pass a `<CommentBody>`\n\t * for a comment's rich text, or any node of your own. */\n\tbody: ReactNode\n\t/** ISO datetime; formatted to relative time by the component. */\n\tdate: string\n\tyou: boolean\n\t/** Whether the comment has been edited (shows an \"edited\" marker). */\n\tedited?: boolean\n\t/** Hover-revealed controls at the card's top-right (e.g. an edit affordance). */\n\tactions?: ReactNode\n\t/** Content under the body, aligned with it rather than the avatar (e.g. a `<Reactions>` row). */\n\tfooter?: ReactNode\n}\n\n/** A single comment: Avatar, Byline, and a body slot the consumer renders. @public @react */\nexport function CommentCard({\n\tauthor,\n\tbody,\n\tdate,\n\tyou,\n\tedited,\n\tactions,\n\tfooter,\n}: CommentCardProps) {\n\treturn (\n\t\t<div className={you ? 'tlui-cmt-card tlui-cmt-card--you' : 'tlui-cmt-card'}>\n\t\t\t<Byline author={author} date={date} edited={edited} />\n\t\t\t<div className=\"tlui-cmt-body\">\n\t\t\t\t{body}\n\t\t\t\t{footer}\n\t\t\t</div>\n\t\t\t{actions !== undefined && <div className=\"tlui-cmt-card__actions\">{actions}</div>}\n\t\t</div>\n\t)\n}\n"],
5
- "mappings": "AAiCG,cACA,YADA;AA/BH,SAAS,cAAc;AAoBhB,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAqB;AACpB,SACC,qBAAC,SAAI,WAAW,MAAM,qCAAqC,iBAC1D;AAAA,wBAAC,UAAO,QAAgB,MAAY,QAAgB;AAAA,IACpD,qBAAC,SAAI,WAAU,iBACb;AAAA;AAAA,MACA;AAAA,OACF;AAAA,IACC,YAAY,UAAa,oBAAC,SAAI,WAAU,0BAA0B,mBAAQ;AAAA,KAC5E;AAEF;",
4
+ "sourcesContent": ["import { type CommentAuthor } from '@tldraw/mentions'\nimport { ReactNode } from 'react'\nimport { Byline } from './byline'\n\n/** @public */\nexport interface CommentCardProps {\n\tauthor: CommentAuthor\n\t/** The rendered comment body. The card doesn't dictate a format \u2014 pass a `<CommentBody>`\n\t * for a comment's rich text, or any node of your own. */\n\tbody: ReactNode\n\t/** ISO datetime; formatted to relative time by the component. */\n\tdate: string\n\tyou: boolean\n\t/** Whether the comment has been edited (shows an \"edited\" marker). */\n\tedited?: boolean\n\t/** Replaces the default `<Byline>` built from `author`, `date`, and `edited`. */\n\tbyline?: ReactNode\n\t/** Draws the default byline's avatar. Defaults to `<Avatar>`. */\n\trenderAvatar?(author: CommentAuthor): ReactNode\n\t/** Hover-revealed controls at the card's top-right (e.g. an edit affordance). */\n\tactions?: ReactNode\n\t/** Content under the body, aligned with it rather than the avatar (e.g. a `<Reactions>` row). */\n\tfooter?: ReactNode\n}\n\n/** A single comment: Avatar, Byline, and a body slot the consumer renders. @public @react */\nexport function CommentCard({\n\tauthor,\n\tbody,\n\tdate,\n\tyou,\n\tedited,\n\tbyline,\n\trenderAvatar,\n\tactions,\n\tfooter,\n}: CommentCardProps) {\n\treturn (\n\t\t<div className={you ? 'tlui-cmt-card tlui-cmt-card--you' : 'tlui-cmt-card'}>\n\t\t\t{byline ?? <Byline author={author} date={date} edited={edited} renderAvatar={renderAvatar} />}\n\t\t\t<div className=\"tlui-cmt-body\">\n\t\t\t\t{body}\n\t\t\t\t{footer}\n\t\t\t</div>\n\t\t\t{actions !== undefined && <div className=\"tlui-cmt-card__actions\">{actions}</div>}\n\t\t</div>\n\t)\n}\n"],
5
+ "mappings": "AAuCc,cACX,YADW;AArCd,SAAS,cAAc;AAwBhB,SAAS,YAAY;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAqB;AACpB,SACC,qBAAC,SAAI,WAAW,MAAM,qCAAqC,iBACzD;AAAA,cAAU,oBAAC,UAAO,QAAgB,MAAY,QAAgB,cAA4B;AAAA,IAC3F,qBAAC,SAAI,WAAU,iBACb;AAAA;AAAA,MACA;AAAA,OACF;AAAA,IACC,YAAY,UAAa,oBAAC,SAAI,WAAU,0BAA0B,mBAAQ;AAAA,KAC5E;AAEF;",
6
6
  "names": []
7
7
  }
@@ -37,6 +37,7 @@ function CommentListItem({
37
37
  selected,
38
38
  reactions,
39
39
  href,
40
+ renderAvatar,
40
41
  resolvedLabel = "Resolved",
41
42
  onSelect
42
43
  }) {
@@ -57,7 +58,7 @@ function CommentListItem({
57
58
  "data-resolved": resolved || void 0,
58
59
  onClick: handleClick,
59
60
  children: [
60
- /* @__PURE__ */ jsx(Avatar, { author }),
61
+ renderAvatar ? renderAvatar(author) : /* @__PURE__ */ jsx(Avatar, { author }),
61
62
  /* @__PURE__ */ jsxs("div", { className: "tlui-cmt-list__item-body", children: [
62
63
  /* @__PURE__ */ jsx(Byline, { author, date }),
63
64
  /* @__PURE__ */ jsx("div", { className: "tlui-cmt-list__item-preview", children: preview }),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/comments-list.tsx"],
4
- "sourcesContent": ["import { Avatar, type CommentAuthor } from '@tldraw/mentions'\nimport { Fragment, MouseEvent, ReactNode } from 'react'\nimport { useTranslation } from 'tldraw'\nimport { Byline } from './byline'\nimport { CheckIcon } from './icons'\nimport { Reactions, type ReactionSummary } from './reactions'\nimport { replyCountLabel } from './reply-count'\n\n/** @public */\nexport interface CommentListItemProps {\n\tid: string\n\tauthor: CommentAuthor\n\t/** A short preview of the thread \u2014 e.g. the first comment's body. */\n\tpreview: ReactNode\n\t/** ISO datetime of the thread's first comment. */\n\tdate: string\n\tresolved?: boolean\n\t/** Name of the page the thread lives on, shown as a small label. Omit to hide. */\n\tpage?: string\n\t/** Total comments in the thread. */\n\tcount?: number\n\t/** Whether this thread is the open one. */\n\tselected?: boolean\n\t/** Tallied reactions for the row (a thread's, or a single comment's when the row is one\n\t * comment), shown as inert pills under the preview. Omit to hide. */\n\treactions?: ReactionSummary[]\n\t/**\n\t * Link target for the item. When set, the row renders as an anchor so browser affordances\n\t * (ctrl/cmd-click, middle-click) open it in a new tab; a plain click still calls `onSelect`.\n\t */\n\thref?: string\n}\n\n/**\n * What a row is rendered with: the item, plus the list-level wiring it needs to be interactive.\n * A custom row gets the same props the default `<CommentListItem>` does, so it can wrap the\n * default rather than reimplement it.\n *\n * @public\n */\nexport interface CommentListItemRenderProps extends CommentListItemProps {\n\t/** Label for a resolved thread's marker on its row. */\n\tresolvedLabel?: string\n\t/** Called with the thread id when the row is chosen. */\n\tonSelect?(id: string): void\n}\n\n/** @public */\nexport interface CommentsListProps {\n\titems: CommentListItemProps[]\n\t/** Called with a thread id when an item is chosen. */\n\tonSelect?(id: string): void\n\t/** Shown above the list (e.g. \"Comments\"). Omit for none. */\n\theader?: ReactNode\n\t/** Rendered at the right of the header row \u2014 e.g. a filter menu. */\n\theaderAction?: ReactNode\n\t/** Shown in place of the list when there are no threads. */\n\tempty?: ReactNode\n\t/** Label for a resolved thread's marker on its row. Defaults to \"Resolved\". */\n\tresolvedLabel?: string\n\t/**\n\t * Override how each item renders. Defaults to `<CommentListItem>`, which is exported \u2014 so a\n\t * row that only adds something can spread these props into it rather than start over. The list\n\t * supplies the key, so a custom row doesn't need one.\n\t */\n\trenderItem?(props: CommentListItemRenderProps): ReactNode\n}\n\n/**\n * A scrollable list of comment threads \u2014 each an avatar, byline, and a one-line preview.\n * Presentational: you supply the items (already summarised) and an `onSelect` handler; the canvas\n * `CanvasCommentsSidebar` wires it to the store, but a consumer can build their own list from this.\n * @public @react\n */\nexport function CommentsList({\n\titems,\n\tonSelect,\n\theader,\n\theaderAction,\n\tempty,\n\tresolvedLabel,\n\trenderItem,\n}: CommentsListProps) {\n\treturn (\n\t\t<div className=\"tlui-cmt-list\">\n\t\t\t{(header !== undefined || headerAction) && (\n\t\t\t\t<div className=\"tlui-cmt-list__header\">\n\t\t\t\t\t{header !== undefined && <span className=\"tlui-cmt-list__header-title\">{header}</span>}\n\t\t\t\t\t{headerAction}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{items.length === 0 ? (\n\t\t\t\t<div className=\"tlui-cmt-list__empty\">{empty}</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"tlui-cmt-list__items\">\n\t\t\t\t\t{items.map((item) => {\n\t\t\t\t\t\tconst props: CommentListItemRenderProps = { ...item, resolvedLabel, onSelect }\n\t\t\t\t\t\t// A custom row is wrapped rather than keyed directly: it's the consumer's element,\n\t\t\t\t\t\t// and requiring them to remember a key is the kind of thing that only shows up as a\n\t\t\t\t\t\t// console warning in someone else's app.\n\t\t\t\t\t\treturn renderItem ? (\n\t\t\t\t\t\t\t<Fragment key={item.id}>{renderItem(props)}</Fragment>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<CommentListItem key={item.id} {...props} />\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\n/** One thread's row in a {@link CommentsList}. @public @react */\nexport function CommentListItem({\n\tid,\n\tauthor,\n\tpreview,\n\tdate,\n\tresolved,\n\tpage,\n\tcount,\n\tselected,\n\treactions,\n\thref,\n\tresolvedLabel = 'Resolved',\n\tonSelect,\n}: CommentListItemRenderProps) {\n\tconst msg = useTranslation()\n\tconst handleClick = (e: MouseEvent) => {\n\t\tif (href && isOpenInNewTabClick(e)) return\n\t\te.preventDefault()\n\t\tif (onSelect) onSelect(id)\n\t}\n\tconst Tag = href ? 'a' : 'button'\n\t// `count` is the thread's total comments; a reply is every comment after the opening one.\n\tconst replies = count !== undefined ? replyCountLabel(msg, count - 1) : null\n\treturn (\n\t\t<Tag\n\t\t\t{...(href ? { href } : { type: 'button' })}\n\t\t\tclassName={\n\t\t\t\tselected ? 'tlui-cmt-list__item tlui-cmt-list__item--selected' : 'tlui-cmt-list__item'\n\t\t\t}\n\t\t\tdata-resolved={resolved || undefined}\n\t\t\tonClick={handleClick}\n\t\t>\n\t\t\t<Avatar author={author} />\n\t\t\t<div className=\"tlui-cmt-list__item-body\">\n\t\t\t\t<Byline author={author} date={date} />\n\t\t\t\t<div className=\"tlui-cmt-list__item-preview\">{preview}</div>\n\t\t\t\t{reactions && <Reactions reactions={reactions} canReact={false} enableHoverList={false} />}\n\t\t\t\t{(resolved || page !== undefined || replies) && (\n\t\t\t\t\t<div className=\"tlui-cmt-list__item-meta\">\n\t\t\t\t\t\t{resolved && (\n\t\t\t\t\t\t\t<span className=\"tlui-cmt-list__item-resolved\">\n\t\t\t\t\t\t\t\t<CheckIcon />\n\t\t\t\t\t\t\t\t{resolvedLabel}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{page !== undefined && <span className=\"tlui-cmt-list__item-page\">{page}</span>}\n\t\t\t\t\t\t{replies && <span className=\"tlui-cmt-list__item-replies\">{replies}</span>}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</Tag>\n\t)\n}\n\n/**\n * Whether a click should be left to the browser's link handling (new tab, new window, or download).\n * @public\n */\nexport function isOpenInNewTabClick(e: MouseEvent) {\n\treturn e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0\n}\n"],
5
- "mappings": "AAsFI,SAC0B,KAD1B;AAtFJ,SAAS,cAAkC;AAC3C,SAAS,gBAAuC;AAChD,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,iBAAuC;AAChD,SAAS,uBAAuB;AAoEzB,SAAS,aAAa;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAsB;AACrB,SACC,qBAAC,SAAI,WAAU,iBACZ;AAAA,gBAAW,UAAa,iBACzB,qBAAC,SAAI,WAAU,yBACb;AAAA,iBAAW,UAAa,oBAAC,UAAK,WAAU,+BAA+B,kBAAO;AAAA,MAC9E;AAAA,OACF;AAAA,IAEA,MAAM,WAAW,IACjB,oBAAC,SAAI,WAAU,wBAAwB,iBAAM,IAE7C,oBAAC,SAAI,WAAU,wBACb,gBAAM,IAAI,CAAC,SAAS;AACpB,YAAM,QAAoC,EAAE,GAAG,MAAM,eAAe,SAAS;AAI7E,aAAO,aACN,oBAAC,YAAwB,qBAAW,KAAK,KAA1B,KAAK,EAAuB,IAE3C,oBAAC,mBAA+B,GAAG,SAAb,KAAK,EAAe;AAAA,IAE5C,CAAC,GACF;AAAA,KAEF;AAEF;AAGO,SAAS,gBAAgB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AACD,GAA+B;AAC9B,QAAM,MAAM,eAAe;AAC3B,QAAM,cAAc,CAAC,MAAkB;AACtC,QAAI,QAAQ,oBAAoB,CAAC,EAAG;AACpC,MAAE,eAAe;AACjB,QAAI,SAAU,UAAS,EAAE;AAAA,EAC1B;AACA,QAAM,MAAM,OAAO,MAAM;AAEzB,QAAM,UAAU,UAAU,SAAY,gBAAgB,KAAK,QAAQ,CAAC,IAAI;AACxE,SACC;AAAA,IAAC;AAAA;AAAA,MACC,GAAI,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS;AAAA,MACxC,WACC,WAAW,sDAAsD;AAAA,MAElE,iBAAe,YAAY;AAAA,MAC3B,SAAS;AAAA,MAET;AAAA,4BAAC,UAAO,QAAgB;AAAA,QACxB,qBAAC,SAAI,WAAU,4BACd;AAAA,8BAAC,UAAO,QAAgB,MAAY;AAAA,UACpC,oBAAC,SAAI,WAAU,+BAA+B,mBAAQ;AAAA,UACrD,aAAa,oBAAC,aAAU,WAAsB,UAAU,OAAO,iBAAiB,OAAO;AAAA,WACtF,YAAY,SAAS,UAAa,YACnC,qBAAC,SAAI,WAAU,4BACb;AAAA,wBACA,qBAAC,UAAK,WAAU,gCACf;AAAA,kCAAC,aAAU;AAAA,cACV;AAAA,eACF;AAAA,YAEA,SAAS,UAAa,oBAAC,UAAK,WAAU,4BAA4B,gBAAK;AAAA,YACvE,WAAW,oBAAC,UAAK,WAAU,+BAA+B,mBAAQ;AAAA,aACpE;AAAA,WAEF;AAAA;AAAA;AAAA,EACD;AAEF;AAMO,SAAS,oBAAoB,GAAe;AAClD,SAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW;AACzE;",
4
+ "sourcesContent": ["import { Avatar, type CommentAuthor } from '@tldraw/mentions'\nimport { Fragment, MouseEvent, ReactNode } from 'react'\nimport { useTranslation } from 'tldraw'\nimport { Byline } from './byline'\nimport { CheckIcon } from './icons'\nimport { Reactions, type ReactionSummary } from './reactions'\nimport { replyCountLabel } from './reply-count'\n\n/** @public */\nexport interface CommentListItemProps {\n\tid: string\n\tauthor: CommentAuthor\n\t/** A short preview of the thread \u2014 e.g. the first comment's body. */\n\tpreview: ReactNode\n\t/** ISO datetime of the thread's first comment. */\n\tdate: string\n\tresolved?: boolean\n\t/** Name of the page the thread lives on, shown as a small label. Omit to hide. */\n\tpage?: string\n\t/** Total comments in the thread. */\n\tcount?: number\n\t/** Whether this thread is the open one. */\n\tselected?: boolean\n\t/** Tallied reactions for the row (a thread's, or a single comment's when the row is one\n\t * comment), shown as inert pills under the preview. Omit to hide. */\n\treactions?: ReactionSummary[]\n\t/** Draws the author's avatar. Defaults to `<Avatar>`. */\n\trenderAvatar?(author: CommentAuthor): ReactNode\n\t/**\n\t * Link target for the item. When set, the row renders as an anchor so browser affordances\n\t * (ctrl/cmd-click, middle-click) open it in a new tab; a plain click still calls `onSelect`.\n\t */\n\thref?: string\n}\n\n/**\n * What a row is rendered with: the item, plus the list-level wiring it needs to be interactive.\n * A custom row gets the same props the default `<CommentListItem>` does, so it can wrap the\n * default rather than reimplement it.\n *\n * @public\n */\nexport interface CommentListItemRenderProps extends CommentListItemProps {\n\t/** Label for a resolved thread's marker on its row. */\n\tresolvedLabel?: string\n\t/** Called with the thread id when the row is chosen. */\n\tonSelect?(id: string): void\n}\n\n/** @public */\nexport interface CommentsListProps {\n\titems: CommentListItemProps[]\n\t/** Called with a thread id when an item is chosen. */\n\tonSelect?(id: string): void\n\t/** Shown above the list (e.g. \"Comments\"). Omit for none. */\n\theader?: ReactNode\n\t/** Rendered at the right of the header row \u2014 e.g. a filter menu. */\n\theaderAction?: ReactNode\n\t/** Shown in place of the list when there are no threads. */\n\tempty?: ReactNode\n\t/** Label for a resolved thread's marker on its row. Defaults to \"Resolved\". */\n\tresolvedLabel?: string\n\t/**\n\t * Override how each item renders. Defaults to `<CommentListItem>`, which is exported \u2014 so a\n\t * row that only adds something can spread these props into it rather than start over. The list\n\t * supplies the key, so a custom row doesn't need one.\n\t */\n\trenderItem?(props: CommentListItemRenderProps): ReactNode\n}\n\n/**\n * A scrollable list of comment threads \u2014 each an avatar, byline, and a one-line preview.\n * Presentational: you supply the items (already summarised) and an `onSelect` handler; the canvas\n * `CanvasCommentsSidebar` wires it to the store, but a consumer can build their own list from this.\n * @public @react\n */\nexport function CommentsList({\n\titems,\n\tonSelect,\n\theader,\n\theaderAction,\n\tempty,\n\tresolvedLabel,\n\trenderItem,\n}: CommentsListProps) {\n\treturn (\n\t\t<div className=\"tlui-cmt-list\">\n\t\t\t{(header !== undefined || headerAction) && (\n\t\t\t\t<div className=\"tlui-cmt-list__header\">\n\t\t\t\t\t{header !== undefined && <span className=\"tlui-cmt-list__header-title\">{header}</span>}\n\t\t\t\t\t{headerAction}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{items.length === 0 ? (\n\t\t\t\t<div className=\"tlui-cmt-list__empty\">{empty}</div>\n\t\t\t) : (\n\t\t\t\t<div className=\"tlui-cmt-list__items\">\n\t\t\t\t\t{items.map((item) => {\n\t\t\t\t\t\tconst props: CommentListItemRenderProps = { ...item, resolvedLabel, onSelect }\n\t\t\t\t\t\t// A custom row is wrapped rather than keyed directly: it's the consumer's element,\n\t\t\t\t\t\t// and requiring them to remember a key is the kind of thing that only shows up as a\n\t\t\t\t\t\t// console warning in someone else's app.\n\t\t\t\t\t\treturn renderItem ? (\n\t\t\t\t\t\t\t<Fragment key={item.id}>{renderItem(props)}</Fragment>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<CommentListItem key={item.id} {...props} />\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\n/** One thread's row in a {@link CommentsList}. @public @react */\nexport function CommentListItem({\n\tid,\n\tauthor,\n\tpreview,\n\tdate,\n\tresolved,\n\tpage,\n\tcount,\n\tselected,\n\treactions,\n\thref,\n\trenderAvatar,\n\tresolvedLabel = 'Resolved',\n\tonSelect,\n}: CommentListItemRenderProps) {\n\tconst msg = useTranslation()\n\tconst handleClick = (e: MouseEvent) => {\n\t\tif (href && isOpenInNewTabClick(e)) return\n\t\te.preventDefault()\n\t\tif (onSelect) onSelect(id)\n\t}\n\tconst Tag = href ? 'a' : 'button'\n\t// `count` is the thread's total comments; a reply is every comment after the opening one.\n\tconst replies = count !== undefined ? replyCountLabel(msg, count - 1) : null\n\treturn (\n\t\t<Tag\n\t\t\t{...(href ? { href } : { type: 'button' })}\n\t\t\tclassName={\n\t\t\t\tselected ? 'tlui-cmt-list__item tlui-cmt-list__item--selected' : 'tlui-cmt-list__item'\n\t\t\t}\n\t\t\tdata-resolved={resolved || undefined}\n\t\t\tonClick={handleClick}\n\t\t>\n\t\t\t{renderAvatar ? renderAvatar(author) : <Avatar author={author} />}\n\t\t\t<div className=\"tlui-cmt-list__item-body\">\n\t\t\t\t<Byline author={author} date={date} />\n\t\t\t\t<div className=\"tlui-cmt-list__item-preview\">{preview}</div>\n\t\t\t\t{reactions && <Reactions reactions={reactions} canReact={false} enableHoverList={false} />}\n\t\t\t\t{(resolved || page !== undefined || replies) && (\n\t\t\t\t\t<div className=\"tlui-cmt-list__item-meta\">\n\t\t\t\t\t\t{resolved && (\n\t\t\t\t\t\t\t<span className=\"tlui-cmt-list__item-resolved\">\n\t\t\t\t\t\t\t\t<CheckIcon />\n\t\t\t\t\t\t\t\t{resolvedLabel}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{page !== undefined && <span className=\"tlui-cmt-list__item-page\">{page}</span>}\n\t\t\t\t\t\t{replies && <span className=\"tlui-cmt-list__item-replies\">{replies}</span>}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</Tag>\n\t)\n}\n\n/**\n * Whether a click should be left to the browser's link handling (new tab, new window, or download).\n * @public\n */\nexport function isOpenInNewTabClick(e: MouseEvent) {\n\treturn e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0\n}\n"],
5
+ "mappings": "AAwFI,SAC0B,KAD1B;AAxFJ,SAAS,cAAkC;AAC3C,SAAS,gBAAuC;AAChD,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,iBAAuC;AAChD,SAAS,uBAAuB;AAsEzB,SAAS,aAAa;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAsB;AACrB,SACC,qBAAC,SAAI,WAAU,iBACZ;AAAA,gBAAW,UAAa,iBACzB,qBAAC,SAAI,WAAU,yBACb;AAAA,iBAAW,UAAa,oBAAC,UAAK,WAAU,+BAA+B,kBAAO;AAAA,MAC9E;AAAA,OACF;AAAA,IAEA,MAAM,WAAW,IACjB,oBAAC,SAAI,WAAU,wBAAwB,iBAAM,IAE7C,oBAAC,SAAI,WAAU,wBACb,gBAAM,IAAI,CAAC,SAAS;AACpB,YAAM,QAAoC,EAAE,GAAG,MAAM,eAAe,SAAS;AAI7E,aAAO,aACN,oBAAC,YAAwB,qBAAW,KAAK,KAA1B,KAAK,EAAuB,IAE3C,oBAAC,mBAA+B,GAAG,SAAb,KAAK,EAAe;AAAA,IAE5C,CAAC,GACF;AAAA,KAEF;AAEF;AAGO,SAAS,gBAAgB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AACD,GAA+B;AAC9B,QAAM,MAAM,eAAe;AAC3B,QAAM,cAAc,CAAC,MAAkB;AACtC,QAAI,QAAQ,oBAAoB,CAAC,EAAG;AACpC,MAAE,eAAe;AACjB,QAAI,SAAU,UAAS,EAAE;AAAA,EAC1B;AACA,QAAM,MAAM,OAAO,MAAM;AAEzB,QAAM,UAAU,UAAU,SAAY,gBAAgB,KAAK,QAAQ,CAAC,IAAI;AACxE,SACC;AAAA,IAAC;AAAA;AAAA,MACC,GAAI,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS;AAAA,MACxC,WACC,WAAW,sDAAsD;AAAA,MAElE,iBAAe,YAAY;AAAA,MAC3B,SAAS;AAAA,MAER;AAAA,uBAAe,aAAa,MAAM,IAAI,oBAAC,UAAO,QAAgB;AAAA,QAC/D,qBAAC,SAAI,WAAU,4BACd;AAAA,8BAAC,UAAO,QAAgB,MAAY;AAAA,UACpC,oBAAC,SAAI,WAAU,+BAA+B,mBAAQ;AAAA,UACrD,aAAa,oBAAC,aAAU,WAAsB,UAAU,OAAO,iBAAiB,OAAO;AAAA,WACtF,YAAY,SAAS,UAAa,YACnC,qBAAC,SAAI,WAAU,4BACb;AAAA,wBACA,qBAAC,UAAK,WAAU,gCACf;AAAA,kCAAC,aAAU;AAAA,cACV;AAAA,eACF;AAAA,YAEA,SAAS,UAAa,oBAAC,UAAK,WAAU,4BAA4B,gBAAK;AAAA,YACvE,WAAW,oBAAC,UAAK,WAAU,+BAA+B,mBAAQ;AAAA,aACpE;AAAA,WAEF;AAAA;AAAA;AAAA,EACD;AAEF;AAMO,SAAS,oBAAoB,GAAe;AAClD,SAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW;AACzE;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tldraw/commenting",
3
3
  "description": "tldraw commenting UI components.",
4
- "version": "5.7.0-next.433c23fa9ce6",
4
+ "version": "5.7.0-next.60f5dc13db82",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -32,7 +32,7 @@
32
32
  "src"
33
33
  ],
34
34
  "devDependencies": {
35
- "@tldraw/driver": "5.7.0-next.433c23fa9ce6",
35
+ "@tldraw/driver": "5.7.0-next.60f5dc13db82",
36
36
  "@types/react": "^19.2.7",
37
37
  "@types/react-dom": "^19.2.3",
38
38
  "react": "^19.2.1",
@@ -50,9 +50,9 @@
50
50
  "@tiptap/core": "^3.12.1",
51
51
  "@tiptap/pm": "^3.12.1",
52
52
  "@tiptap/react": "^3.12.1",
53
- "@tldraw/mentions": "5.7.0-next.433c23fa9ce6",
54
- "@tldraw/utils": "5.7.0-next.433c23fa9ce6",
55
- "tldraw": "5.7.0-next.433c23fa9ce6"
53
+ "@tldraw/mentions": "5.7.0-next.60f5dc13db82",
54
+ "@tldraw/utils": "5.7.0-next.60f5dc13db82",
55
+ "tldraw": "5.7.0-next.60f5dc13db82"
56
56
  },
57
57
  "module": "dist-esm/index.mjs",
58
58
  "source": "src/index.ts",
@@ -482,6 +482,9 @@
482
482
  /* The base expanded rule re-pads the right edge for the squarer composer's geometry; here the
483
483
  12px is already symmetric. */
484
484
  padding-right: 12px;
485
+ /* Collapsed, the 26px wrap is centred in the 36px input, 5px below its top. Expanded, the wrap
486
+ starts the first flex line, so without the extra 5px the text jumps up as it starts to wrap. */
487
+ padding-top: 9.5px;
485
488
  }
486
489
  .tlui-cmt-canvas-composer .tlui-cmt-input__placeholder {
487
490
  left: 12px;
@@ -18,6 +18,7 @@ import { useCommentingOptions } from './options'
18
18
  import { richTextToPlaintext } from './rich-text'
19
19
  import { commentsSidebarOpen, openThreadId, sidebarFilters } from './state'
20
20
  import { focusThread } from './thread-state'
21
+ import { avatarRenderer } from './thread-view'
21
22
 
22
23
  const messages = defineMessages({
23
24
  commentsEmpty: { id: 'comments.empty', defaultMessage: 'No comments on this page yet.' },
@@ -127,6 +128,7 @@ export function CanvasCommentsSidebar(props: CanvasCommentsSidebarProps) {
127
128
  count: threadComments.length,
128
129
  selected: openId === thread.id,
129
130
  href: getThreadHref?.(thread.id),
131
+ renderAvatar: avatarRenderer(options.components, thread.createdBy),
130
132
  },
131
133
  lastActivity: (last ?? thread).createdAt,
132
134
  }
@@ -1,3 +1,4 @@
1
+ import { type AvatarProps } from '@tldraw/mentions'
1
2
  import { useMemo, type ComponentType } from 'react'
2
3
  import {
3
4
  type Editor,
@@ -9,6 +10,7 @@ import {
9
10
  useEditor,
10
11
  useValue,
11
12
  } from 'tldraw'
13
+ import { type BylineProps } from '../ui/byline'
12
14
  import { type CommentListItemRenderProps } from '../ui/comments-list'
13
15
  import { isAllowedReactionEmoji, type EmojiPickerProps } from '../ui/emoji-picker'
14
16
  import { type ReactionTooltipProps } from '../ui/reaction'
@@ -60,6 +62,20 @@ export type CommentModificationContext = {
60
62
  export interface CommentingComponents {
61
63
  /** A comment's body. Replaces the default rich-text `<CommentBody>`. */
62
64
  CommentBody?: ComponentType<{ comment: TLComment }>
65
+ /**
66
+ * A comment's byline: the author's avatar and name, the time, and the edited marker. Replaces the
67
+ * default `<Byline>`, which is exported — so a byline that only changes how the author is shown
68
+ * (a badge read from `comment.meta`, say) can spread these props into it with a different
69
+ * `author`. `author` is what `resolveAuthor` returned for the comment's `authorId`.
70
+ */
71
+ CommentByline?: ComponentType<BylineProps & { comment: TLComment }>
72
+ /**
73
+ * An author's avatar, wherever the layer draws one: comment bylines, sidebar rows, the composers,
74
+ * and the default pin content. Replaces the default `<Avatar>`, which is exported — so an avatar
75
+ * that only adds something (a presence ring, a badge) can spread these props into it. `authorId`
76
+ * is the id `author` was resolved from, or `null` in a composer with no signed-in user.
77
+ */
78
+ Avatar?: ComponentType<AvatarProps & { authorId: string | null }>
63
79
  /** A pin's inner content. Replaces the author-initial default. */
64
80
  PinContent?: ComponentType<{ thread: TLCommentThread; comments: TLComment[] }>
65
81
  /** A sidebar row's preview. Replaces the plaintext default. */
@@ -27,6 +27,7 @@ import { type CommentingContext } from './context'
27
27
  import { useIsMobileCommenting, useMobilePlacement } from './mobile-placement'
28
28
  import { useCanComment, useCommentingOptions } from './options'
29
29
  import { pendingComment } from './state'
30
+ import { avatarRenderer } from './thread-view'
30
31
 
31
32
  const messages = defineMessages({
32
33
  commentsSend: { id: 'comments.send', defaultMessage: 'Send' },
@@ -49,13 +50,16 @@ export function PendingComposer({
49
50
  getMentionSuggestions,
50
51
  renderMentionSuggestion,
51
52
  }: CommentingContext & { editor: Editor; pending: PendingComment }) {
52
- const ComposerFallback = useCommentingOptions().components.ComposerFallback
53
+ const { components } = useCommentingOptions()
54
+ const ComposerFallback = components.ComposerFallback
53
55
  const canComment = useCanComment(currentUserId)
54
56
  const me = currentUserId ? resolveAuthor(currentUserId) : undefined
55
57
  // The leading pin previews the pin this draft becomes: a white pin holding the author's avatar.
56
58
  const draftAvatar = (
57
59
  <CommentPin>
58
- <Avatar author={me ?? UNKNOWN_COMMENT_AUTHOR} />
60
+ {avatarRenderer(components, currentUserId)?.(me ?? UNKNOWN_COMMENT_AUTHOR) ?? (
61
+ <Avatar author={me ?? UNKNOWN_COMMENT_AUTHOR} />
62
+ )}
59
63
  </CommentPin>
60
64
  )
61
65
  // Click-away keeps the draft (saved on every change) and the next placement composer
@@ -45,7 +45,7 @@ import {
45
45
  regionWithPinAt,
46
46
  shapeAnchorAt,
47
47
  } from './thread-state'
48
- import { POPOVER_OFFSET, ThreadPopover, ThreadView } from './thread-view'
48
+ import { avatarRenderer, POPOVER_OFFSET, ThreadPopover, ThreadView } from './thread-view'
49
49
 
50
50
  const messages = defineMessages({
51
51
  commentsUnknownAuthor: { id: 'comments.unknown-author', defaultMessage: 'Someone' },
@@ -199,10 +199,13 @@ export const ThreadPin = memo(function ThreadPin({
199
199
 
200
200
  const PinContent = options.components.PinContent
201
201
  const threadAuthor = resolveAuthor(thread.createdBy)
202
+ const pinAuthor = threadAuthor ?? UNKNOWN_COMMENT_AUTHOR
202
203
  const pinContent = PinContent ? (
203
204
  <PinContent thread={thread} comments={comments} />
204
205
  ) : (
205
- <Avatar author={threadAuthor ?? UNKNOWN_COMMENT_AUTHOR} />
206
+ (avatarRenderer(options.components, thread.createdBy)?.(pinAuthor) ?? (
207
+ <Avatar author={pinAuthor} />
208
+ ))
206
209
  )
207
210
  const pinLabel = msg(
208
211
  thread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,
@@ -1,4 +1,5 @@
1
1
  import type { CommentAuthor } from '@tldraw/mentions'
2
+ import { isValidElement, type ReactElement } from 'react'
2
3
  import type { TLComment } from 'tldraw'
3
4
  import { describe, expect, it } from 'vitest'
4
5
  import { absoluteThreadLink, toCardProps } from './thread-view'
@@ -41,6 +42,44 @@ describe('toCardProps', () => {
41
42
  expect(card.you).toBe(false)
42
43
  expect(card.author).not.toBe(AUTHOR)
43
44
  })
45
+
46
+ it('leaves the byline and avatar to the card when no slots are set', () => {
47
+ const card = toCardProps(comment(), context, {}, resolveName)
48
+ expect(card.byline).toBeUndefined()
49
+ expect(card.renderAvatar).toBeUndefined()
50
+ })
51
+
52
+ it('renders the Avatar slot for the author, with the id they were resolved from', () => {
53
+ const Avatar = () => null
54
+ const card = toCardProps(comment(), context, { Avatar }, resolveName)
55
+ const avatar = card.renderAvatar?.(AUTHOR) as ReactElement<Record<string, unknown>>
56
+ expect(avatar.type).toBe(Avatar)
57
+ expect(avatar.props).toEqual({ author: AUTHOR, authorId: 'user:1' })
58
+ })
59
+
60
+ it('renders the CommentByline slot with the byline props and the comment record', () => {
61
+ const CommentByline = () => null
62
+ const record = comment({ editedAt: Date.parse('2026-07-30T13:00:00.000Z') })
63
+ const card = toCardProps(record, context, { CommentByline }, resolveName)
64
+ expect(isValidElement(card.byline)).toBe(true)
65
+ const byline = card.byline as ReactElement<Record<string, unknown>>
66
+ expect(byline.type).toBe(CommentByline)
67
+ expect(byline.props).toEqual({
68
+ author: AUTHOR,
69
+ date: '2026-07-30T12:00:00.000Z',
70
+ edited: true,
71
+ renderAvatar: undefined,
72
+ comment: record,
73
+ })
74
+ })
75
+
76
+ it('hands the CommentByline slot the Avatar slot, so a spread into Byline keeps it', () => {
77
+ const Avatar = () => null
78
+ const CommentByline = () => null
79
+ const card = toCardProps(comment(), context, { Avatar, CommentByline }, resolveName)
80
+ const byline = card.byline as ReactElement<Record<string, unknown>>
81
+ expect(byline.props.renderAvatar).toBe(card.renderAvatar)
82
+ })
44
83
  })
45
84
 
46
85
  describe('absoluteThreadLink', () => {
@@ -1,3 +1,4 @@
1
+ import { type CommentAuthor } from '@tldraw/mentions'
1
2
  import { memo, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
2
3
  import {
3
4
  createComment,
@@ -185,6 +186,19 @@ function useCopyLink(href: string | undefined) {
185
186
  return [copied, copy] as const
186
187
  }
187
188
 
189
+ /**
190
+ * The `Avatar` component slot as a `renderAvatar` callback for the presentational components, bound
191
+ * to the id the avatar stands for. Undefined without an override, so they draw their own default.
192
+ */
193
+ export function avatarRenderer(
194
+ components: CommentingComponents,
195
+ authorId: string | null
196
+ ): ((author: CommentAuthor) => ReactNode) | undefined {
197
+ const Avatar = components.Avatar
198
+ if (!Avatar) return undefined
199
+ return (author) => <Avatar author={author} authorId={authorId} />
200
+ }
201
+
188
202
  export function toCardProps(
189
203
  comment: TLComment,
190
204
  props: Pick<CommentingContext, 'currentUserId' | 'resolveAuthor'>,
@@ -199,12 +213,27 @@ export function toCardProps(
199
213
  ) : (
200
214
  <CommentBody richText={comment.body} resolveName={resolveName} />
201
215
  )
216
+ const author = props.resolveAuthor(comment.authorId) ?? UNKNOWN_COMMENT_AUTHOR
217
+ const date = new Date(comment.createdAt).toISOString()
218
+ const edited = comment.editedAt != null
219
+ const renderAvatar = avatarRenderer(components, comment.authorId)
220
+ const Byline = components.CommentByline
202
221
  return {
203
- author: props.resolveAuthor(comment.authorId) ?? UNKNOWN_COMMENT_AUTHOR,
222
+ author,
204
223
  body,
205
- date: new Date(comment.createdAt).toISOString(),
224
+ date,
206
225
  you: comment.authorId === props.currentUserId,
207
- edited: comment.editedAt != null,
226
+ edited,
227
+ renderAvatar,
228
+ byline: Byline ? (
229
+ <Byline
230
+ author={author}
231
+ date={date}
232
+ edited={edited}
233
+ renderAvatar={renderAvatar}
234
+ comment={comment}
235
+ />
236
+ ) : undefined,
208
237
  }
209
238
  }
210
239
 
@@ -482,6 +511,7 @@ export const ThreadView = memo(function ThreadView({
482
511
  >
483
512
  <CommentComposer
484
513
  author={card.author}
514
+ leading={card.renderAvatar?.(card.author)}
485
515
  placeholder={msg(messages.commentsEditPlaceholder)}
486
516
  value={editText}
487
517
  onChange={setEditText}
@@ -600,6 +630,10 @@ export const ThreadView = memo(function ThreadView({
600
630
  canReply
601
631
  ? {
602
632
  author: me ?? UNKNOWN_COMMENT_AUTHOR,
633
+ leading: avatarRenderer(
634
+ options.components,
635
+ currentUserId
636
+ )?.(me ?? UNKNOWN_COMMENT_AUTHOR),
603
637
  placeholder: msg(messages.commentsReplyPlaceholder),
604
638
  sendLabel: msg(messages.commentsSend),
605
639
  value: reply,
package/src/ui/byline.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Avatar, type CommentAuthor } from '@tldraw/mentions'
2
+ import { type ReactNode } from 'react'
2
3
  import { TldrawUiTooltip, useCurrentTranslation } from 'tldraw'
3
4
  import { formatFullDateTime, formatRelativeTime } from './format-time'
4
5
 
@@ -9,6 +10,8 @@ export interface BylineProps {
9
10
  date: string
10
11
  /** Shows an "edited" marker when the comment has been edited. */
11
12
  edited?: boolean
13
+ /** Draws the author's avatar. Defaults to `<Avatar>`. */
14
+ renderAvatar?(author: CommentAuthor): ReactNode
12
15
  }
13
16
 
14
17
  /**
@@ -16,13 +19,13 @@ export interface BylineProps {
16
19
  * shows the full date and time in a tooltip.
17
20
  * @public @react
18
21
  */
19
- export function Byline({ author, date, edited }: BylineProps) {
22
+ export function Byline({ author, date, edited, renderAvatar }: BylineProps) {
20
23
  // The relative time is the one piece of a byline that isn't the host's data, so it follows the
21
24
  // same translation context as every other string in the UI rather than a prop of its own.
22
25
  const { locale } = useCurrentTranslation()
23
26
  return (
24
27
  <div className="tlui-cmt-head">
25
- <Avatar author={author} />
28
+ {renderAvatar ? renderAvatar(author) : <Avatar author={author} />}
26
29
  <span className="tlui-cmt-author">{author.name}</span>
27
30
  <TldrawUiTooltip content={formatFullDateTime(date, locale)}>
28
31
  <span className="tlui-cmt-time">
@@ -13,6 +13,10 @@ export interface CommentCardProps {
13
13
  you: boolean
14
14
  /** Whether the comment has been edited (shows an "edited" marker). */
15
15
  edited?: boolean
16
+ /** Replaces the default `<Byline>` built from `author`, `date`, and `edited`. */
17
+ byline?: ReactNode
18
+ /** Draws the default byline's avatar. Defaults to `<Avatar>`. */
19
+ renderAvatar?(author: CommentAuthor): ReactNode
16
20
  /** Hover-revealed controls at the card's top-right (e.g. an edit affordance). */
17
21
  actions?: ReactNode
18
22
  /** Content under the body, aligned with it rather than the avatar (e.g. a `<Reactions>` row). */
@@ -26,12 +30,14 @@ export function CommentCard({
26
30
  date,
27
31
  you,
28
32
  edited,
33
+ byline,
34
+ renderAvatar,
29
35
  actions,
30
36
  footer,
31
37
  }: CommentCardProps) {
32
38
  return (
33
39
  <div className={you ? 'tlui-cmt-card tlui-cmt-card--you' : 'tlui-cmt-card'}>
34
- <Byline author={author} date={date} edited={edited} />
40
+ {byline ?? <Byline author={author} date={date} edited={edited} renderAvatar={renderAvatar} />}
35
41
  <div className="tlui-cmt-body">
36
42
  {body}
37
43
  {footer}
@@ -24,6 +24,8 @@ export interface CommentListItemProps {
24
24
  /** Tallied reactions for the row (a thread's, or a single comment's when the row is one
25
25
  * comment), shown as inert pills under the preview. Omit to hide. */
26
26
  reactions?: ReactionSummary[]
27
+ /** Draws the author's avatar. Defaults to `<Avatar>`. */
28
+ renderAvatar?(author: CommentAuthor): ReactNode
27
29
  /**
28
30
  * Link target for the item. When set, the row renders as an anchor so browser affordances
29
31
  * (ctrl/cmd-click, middle-click) open it in a new tab; a plain click still calls `onSelect`.
@@ -122,6 +124,7 @@ export function CommentListItem({
122
124
  selected,
123
125
  reactions,
124
126
  href,
127
+ renderAvatar,
125
128
  resolvedLabel = 'Resolved',
126
129
  onSelect,
127
130
  }: CommentListItemRenderProps) {
@@ -143,7 +146,7 @@ export function CommentListItem({
143
146
  data-resolved={resolved || undefined}
144
147
  onClick={handleClick}
145
148
  >
146
- <Avatar author={author} />
149
+ {renderAvatar ? renderAvatar(author) : <Avatar author={author} />}
147
150
  <div className="tlui-cmt-list__item-body">
148
151
  <Byline author={author} date={date} />
149
152
  <div className="tlui-cmt-list__item-preview">{preview}</div>