@tldraw/commenting 5.7.0-canary.fb3426ffa934 → 5.7.0-internal.5fe8922939ec

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 (111) hide show
  1. package/commenting.css +277 -275
  2. package/dist-cjs/canvas/canvas-events.js +25 -1
  3. package/dist-cjs/canvas/canvas-events.js.map +2 -2
  4. package/dist-cjs/canvas/comment-mutations.js +5 -0
  5. package/dist-cjs/canvas/comment-mutations.js.map +2 -2
  6. package/dist-cjs/canvas/comment-tool.js +29 -28
  7. package/dist-cjs/canvas/comment-tool.js.map +2 -2
  8. package/dist-cjs/canvas/comments-filter-menu.js +55 -38
  9. package/dist-cjs/canvas/comments-filter-menu.js.map +2 -2
  10. package/dist-cjs/canvas/comments-overflow-menu.js +6 -24
  11. package/dist-cjs/canvas/comments-overflow-menu.js.map +2 -2
  12. package/dist-cjs/canvas/comments-overlay.js +1 -0
  13. package/dist-cjs/canvas/comments-overlay.js.map +2 -2
  14. package/dist-cjs/canvas/comments-sidebar.js +15 -3
  15. package/dist-cjs/canvas/comments-sidebar.js.map +2 -2
  16. package/dist-cjs/canvas/comments-visibility-toggle.js +1 -1
  17. package/dist-cjs/canvas/comments-visibility-toggle.js.map +1 -1
  18. package/dist-cjs/canvas/options.js +12 -0
  19. package/dist-cjs/canvas/options.js.map +2 -2
  20. package/dist-cjs/canvas/pending-composer.js +139 -9
  21. package/dist-cjs/canvas/pending-composer.js.map +2 -2
  22. package/dist-cjs/canvas/region-box.js +150 -35
  23. package/dist-cjs/canvas/region-box.js.map +3 -3
  24. package/dist-cjs/canvas/thread-pin.js +20 -4
  25. package/dist-cjs/canvas/thread-pin.js.map +2 -2
  26. package/dist-cjs/canvas/thread-view.js +134 -58
  27. package/dist-cjs/canvas/thread-view.js.map +2 -2
  28. package/dist-cjs/index.d.ts +46 -12
  29. package/dist-cjs/index.js +1 -1
  30. package/dist-cjs/ui/byline.js +2 -2
  31. package/dist-cjs/ui/byline.js.map +2 -2
  32. package/dist-cjs/ui/comment-card.js +3 -1
  33. package/dist-cjs/ui/comment-card.js.map +2 -2
  34. package/dist-cjs/ui/comment-extensions.js +4 -1
  35. package/dist-cjs/ui/comment-extensions.js.map +2 -2
  36. package/dist-cjs/ui/comments-list.js +6 -7
  37. package/dist-cjs/ui/comments-list.js.map +2 -2
  38. package/dist-cjs/ui/icons.js +4 -4
  39. package/dist-cjs/ui/icons.js.map +2 -2
  40. package/dist-cjs/ui/reaction-picker.js +2 -2
  41. package/dist-cjs/ui/reaction-picker.js.map +1 -1
  42. package/dist-cjs/ui/send-button.js.map +1 -1
  43. package/dist-esm/canvas/canvas-events.mjs +25 -1
  44. package/dist-esm/canvas/canvas-events.mjs.map +2 -2
  45. package/dist-esm/canvas/comment-mutations.mjs +5 -0
  46. package/dist-esm/canvas/comment-mutations.mjs.map +2 -2
  47. package/dist-esm/canvas/comment-tool.mjs +30 -29
  48. package/dist-esm/canvas/comment-tool.mjs.map +2 -2
  49. package/dist-esm/canvas/comments-filter-menu.mjs +57 -39
  50. package/dist-esm/canvas/comments-filter-menu.mjs.map +2 -2
  51. package/dist-esm/canvas/comments-overflow-menu.mjs +8 -24
  52. package/dist-esm/canvas/comments-overflow-menu.mjs.map +2 -2
  53. package/dist-esm/canvas/comments-overlay.mjs +1 -0
  54. package/dist-esm/canvas/comments-overlay.mjs.map +2 -2
  55. package/dist-esm/canvas/comments-sidebar.mjs +16 -4
  56. package/dist-esm/canvas/comments-sidebar.mjs.map +2 -2
  57. package/dist-esm/canvas/comments-visibility-toggle.mjs +1 -1
  58. package/dist-esm/canvas/comments-visibility-toggle.mjs.map +1 -1
  59. package/dist-esm/canvas/options.mjs +12 -0
  60. package/dist-esm/canvas/options.mjs.map +2 -2
  61. package/dist-esm/canvas/pending-composer.mjs +150 -11
  62. package/dist-esm/canvas/pending-composer.mjs.map +2 -2
  63. package/dist-esm/canvas/region-box.mjs +161 -38
  64. package/dist-esm/canvas/region-box.mjs.map +3 -3
  65. package/dist-esm/canvas/thread-pin.mjs +22 -6
  66. package/dist-esm/canvas/thread-pin.mjs.map +2 -2
  67. package/dist-esm/canvas/thread-view.mjs +145 -60
  68. package/dist-esm/canvas/thread-view.mjs.map +2 -2
  69. package/dist-esm/index.d.mts +46 -12
  70. package/dist-esm/index.mjs +1 -1
  71. package/dist-esm/ui/byline.mjs +2 -2
  72. package/dist-esm/ui/byline.mjs.map +2 -2
  73. package/dist-esm/ui/comment-card.mjs +3 -1
  74. package/dist-esm/ui/comment-card.mjs.map +2 -2
  75. package/dist-esm/ui/comment-extensions.mjs +11 -2
  76. package/dist-esm/ui/comment-extensions.mjs.map +2 -2
  77. package/dist-esm/ui/comments-list.mjs +6 -7
  78. package/dist-esm/ui/comments-list.mjs.map +2 -2
  79. package/dist-esm/ui/icons.mjs +4 -4
  80. package/dist-esm/ui/icons.mjs.map +2 -2
  81. package/dist-esm/ui/reaction-picker.mjs +2 -2
  82. package/dist-esm/ui/reaction-picker.mjs.map +1 -1
  83. package/dist-esm/ui/send-button.mjs.map +1 -1
  84. package/package.json +5 -5
  85. package/src/canvas/canvas-events.ts +39 -2
  86. package/src/canvas/canvas.css +73 -38
  87. package/src/canvas/comment-mutations.test.ts +51 -0
  88. package/src/canvas/comment-mutations.ts +14 -0
  89. package/src/canvas/comment-render.test.ts +8 -1
  90. package/src/canvas/comment-tool.test.ts +34 -44
  91. package/src/canvas/comment-tool.tsx +51 -55
  92. package/src/canvas/comments-filter-menu.tsx +19 -6
  93. package/src/canvas/comments-overflow-menu.tsx +12 -18
  94. package/src/canvas/comments-overlay.tsx +5 -2
  95. package/src/canvas/comments-sidebar.tsx +20 -5
  96. package/src/canvas/comments-visibility-toggle.tsx +1 -1
  97. package/src/canvas/options.test.ts +23 -1
  98. package/src/canvas/options.ts +41 -3
  99. package/src/canvas/pending-composer.tsx +190 -19
  100. package/src/canvas/region-box.tsx +192 -42
  101. package/src/canvas/thread-pin.tsx +28 -6
  102. package/src/canvas/thread-view.test.ts +39 -0
  103. package/src/canvas/thread-view.tsx +192 -72
  104. package/src/ui/byline.tsx +5 -2
  105. package/src/ui/comment-card.tsx +7 -1
  106. package/src/ui/comment-extensions.ts +18 -5
  107. package/src/ui/comments-list.tsx +23 -17
  108. package/src/ui/comments.css +175 -201
  109. package/src/ui/icons.tsx +5 -5
  110. package/src/ui/reaction-picker.tsx +2 -2
  111. package/src/ui/send-button.tsx +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/icons.tsx"],
4
- "sourcesContent": ["/* The commenting UI's inline icons, kept together so the set is visible in one place.\n *\n * Anything with an equivalent in tldraw's icon assets goes through `TldrawUiIcon` instead (the \u22EF\n * menu, the dismiss cross, the resolve button's check). What's left lives here because the asset\n * set has no counterpart \u2014 a smiley, a send arrow, a filter \u2014 or because the asset reads wrong at\n * the size it's needed, which is the case for both resolved checks below. The eye pair mirrors\n * tldraw's presence glyphs: the open state is the `follow` icon \u2014 the almond eye whose pupil\n * tracks presence \u2014 and the closed state the `closed` icon, its shut-lid companion. Both are in\n * the asset set, but they're inlined because the package renders without an `AssetUrlsProvider`,\n * so `TldrawUiIcon` can't reach them. Inline also means they render without the consumer serving\n * files.\n *\n * All internal \u2014 none are exported from the package. */\n\n/** The check inside a resolved comment pin. A drawn check, not the '\u2713' glyph \u2014 that character sits\n * off-baseline and varies by font. Heavier and rounder than `CheckIcon`: it has to hold its weight\n * against the pin's 28px filled face, where the asset check reads too light. */\nexport function PinCheckIcon() {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\twidth=\"15\"\n\t\t\theight=\"15\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<path d=\"M4 12.5l5 5L20 6.5\" />\n\t\t</svg>\n\t)\n}\n\n/** The check beside the \"Resolved\" label on a comments list row. Thinner than `PinCheckIcon` \u2014 it\n * sits next to text at 12px, so it's drawn to match the label's weight rather than shout. */\nexport function CheckIcon() {\n\treturn (\n\t\t<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M2.5 6.2 4.7 8.4 9.5 3.6\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** The reaction picker's trigger. */\nexport function SmileyIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M7.49991 0.876892C3.84222 0.876892 0.877075 3.84204 0.877075 7.49972C0.877075 11.1574 3.84222 14.1226 7.49991 14.1226C11.1576 14.1226 14.1227 11.1574 14.1227 7.49972C14.1227 3.84204 11.1576 0.876892 7.49991 0.876892ZM1.82708 7.49972C1.82708 4.36671 4.36689 1.82689 7.49991 1.82689C10.6329 1.82689 13.1727 4.36671 13.1727 7.49972C13.1727 10.6327 10.6329 13.1726 7.49991 13.1726C4.36689 13.1726 1.82708 10.6327 1.82708 7.49972ZM5.03747 9.21395C4.87949 8.98746 4.56782 8.93193 4.34133 9.08991C4.11484 9.24789 4.05931 9.55956 4.21729 9.78605C4.93926 10.8211 6.14033 11.5 7.50004 11.5C8.85974 11.5 10.0608 10.8211 10.7828 9.78605C10.9408 9.55956 10.8852 9.24789 10.6587 9.08991C10.4323 8.93193 10.1206 8.98746 9.9626 9.21395C9.41963 9.99238 8.51907 10.5 7.50004 10.5C6.481 10.5 5.58044 9.99238 5.03747 9.21395ZM5.37503 6.84998C5.85828 6.84998 6.25003 6.45815 6.25003 5.97498C6.25003 5.4918 5.85828 5.09998 5.37503 5.09998C4.89179 5.09998 4.50003 5.4918 4.50003 5.97498C4.50003 6.45815 4.89179 6.84998 5.37503 6.84998ZM10.5 5.97498C10.5 6.45815 10.1083 6.84998 9.62503 6.84998C9.14179 6.84998 8.75003 6.45815 8.75003 5.97498C8.75003 5.4918 9.14179 5.09998 9.62503 5.09998C10.1083 5.09998 10.5 5.4918 10.5 5.97498Z\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t\tclipRule=\"evenodd\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** The composer's post button \u2014 an up arrow. */\nexport function SendIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t\tclipRule=\"evenodd\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** Comment pins are showing. tldraw's `follow` glyph (icons/icon/follow.svg) inlined at its native\n * weight \u2014 the almond eye with a centred pupil. Pairs with `EyeClosedIcon`; the two must stay the\n * same family. */\nexport function EyeOpenIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path fill=\"currentColor\" d=\"M19 15a4 4 0 1 1-8 0 4 4 0 0 1 8 0\" />\n\t\t\t<path\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\td=\"M26 15c0 1.77-1.077 3.496-3.07 4.825C20.946 21.149 18.145 22 15 22s-5.945-.851-7.93-2.175C5.076 18.496 4 16.77 4 15c0-1.77 1.077-3.496 3.07-4.825C9.054 8.851 11.855 8 15 8s5.945.851 7.93 2.175C24.924 11.504 26 13.23 26 15Z\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** Comment pins are hidden. tldraw's `closed` eye glyph (icons/icon/closed.svg) \u2014 a shut lower lid\n * with lashes, the design pair to `follow`. Inlined like the open eye: the package renders without\n * an `AssetUrlsProvider`. Lash dots are `r=1.5` (vs the asset's `r=1`) because at the 15px header\n * size the asset's finer lashes fall below a pixel; the lid keeps `follow`'s native stroke. */\nexport function EyeClosedIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\td=\"M27 15C27 19.4183 21.6274 23 15 23C8.37258 23 3 19.4183 3 15\"\n\t\t\t/>\n\t\t\t<circle cx=\"4\" cy=\"20\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"9\" cy=\"23\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"15\" cy=\"24\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"21\" cy=\"23\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"26\" cy=\"20\" r=\"1.5\" fill=\"currentColor\" />\n\t\t</svg>\n\t)\n}\n\n/** The sidebar's comment-menu trigger \u2014 tldraw's `dots-vertical` glyph (icons/icon/dots-vertical.svg)\n * inlined, a vertical kebab. Inlined like the eye pair because the package renders without an\n * `AssetUrlsProvider`. */\nexport function MoreMenuIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\td=\"M15 9.48975C14.3167 9.48975 13.7292 9.24747 13.2375 8.76293C12.7458 8.27003 12.5 7.67688 12.5 6.98348C12.5 6.29843 12.7458 5.71364 13.2375 5.22909C13.7292 4.73619 14.3167 4.48975 15 4.48975C15.6833 4.48975 16.2708 4.73619 16.7625 5.22909C17.2542 5.71364 17.5 6.29843 17.5 6.98348C17.5 7.44296 17.3833 7.86485 17.15 8.24914C16.925 8.62508 16.625 8.92583 16.25 9.1514C15.875 9.37696 15.4583 9.48975 15 9.48975Z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\td=\"M15 17.5C14.3167 17.5 13.7292 17.2577 13.2375 16.7732C12.7458 16.2803 12.5 15.6871 12.5 14.9937C12.5 14.3087 12.7458 13.7239 13.2375 13.2393C13.7292 12.7464 14.3167 12.5 15 12.5C15.6833 12.5 16.2708 12.7464 16.7625 13.2393C17.2542 13.7239 17.5 14.3087 17.5 14.9937C17.5 15.4532 17.3833 15.8751 17.15 16.2594C16.925 16.6353 16.625 16.9361 16.25 17.1617C15.875 17.3872 15.4583 17.5 15 17.5Z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\td=\"M15 25.5103C14.3167 25.5103 13.7292 25.268 13.2375 24.7834C12.7458 24.2905 12.5 23.6974 12.5 23.004C12.5 22.319 12.7458 21.7342 13.2375 21.2496C13.7292 20.7567 14.3167 20.5103 15 20.5103C15.6833 20.5103 16.2708 20.7567 16.7625 21.2496C17.2542 21.7342 17.5 22.319 17.5 23.004C17.5 23.4635 17.3833 23.8854 17.15 24.2697C16.925 24.6456 16.625 24.9463 16.25 25.1719C15.875 25.3975 15.4583 25.5103 15 25.5103Z\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n"],
5
- "mappings": "AA8BG,cAsDD,YAtDC;AAbI,SAAS,eAAe;AAC9B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,QAAO;AAAA,MACP,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACf,eAAY;AAAA,MAEZ,8BAAC,UAAK,GAAE,sBAAqB;AAAA;AAAA,EAC9B;AAEF;AAIO,SAAS,YAAY;AAC3B,SACC,oBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA;AAAA,EAChB,GACD;AAEF;AAGO,SAAS,aAAa;AAC5B,SACC,oBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,MAAK;AAAA,MACL,UAAS;AAAA,MACT,UAAS;AAAA;AAAA,EACV,GACD;AAEF;AAGO,SAAS,WAAW;AAC1B,SACC,oBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,MAAK;AAAA,MACL,UAAS;AAAA,MACT,UAAS;AAAA;AAAA,EACV,GACD;AAEF;AAKO,SAAS,cAAc;AAC7B,SACC,qBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,wBAAC,UAAK,MAAK,gBAAe,GAAE,sCAAqC;AAAA,IACjE;AAAA,MAAC;AAAA;AAAA,QACA,QAAO;AAAA,QACP,aAAY;AAAA,QACZ,GAAE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;AAMO,SAAS,gBAAgB;AAC/B,SACC,qBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,QAAO;AAAA,QACP,aAAY;AAAA,QACZ,eAAc;AAAA,QACd,GAAE;AAAA;AAAA,IACH;AAAA,IACA,oBAAC,YAAO,IAAG,KAAI,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACnD,oBAAC,YAAO,IAAG,KAAI,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACnD,oBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACpD,oBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACpD,oBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,KACrD;AAEF;AAKO,SAAS,eAAe;AAC9B,SACC,qBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,GAAE;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,GAAE;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,GAAE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/* The commenting UI's inline icons, kept together so the set is visible in one place.\n *\n * Anything with an equivalent in tldraw's icon assets goes through `TldrawUiIcon` instead (the \u22EF\n * menu, the dismiss cross, the resolve button's check). What's left lives here because the asset\n * set has no counterpart \u2014 a smiley, a send arrow, a filter \u2014 or because the asset reads wrong at\n * the size it's needed, which is the case for both resolved checks below. The eye pair mirrors\n * tldraw's presence glyphs: the open state is the `follow` icon \u2014 the almond eye whose pupil\n * tracks presence \u2014 and the closed state the `closed` icon, its shut-lid companion. Both are in\n * the asset set, but they're inlined because the package renders without an `AssetUrlsProvider`,\n * so `TldrawUiIcon` can't reach them. Inline also means they render without the consumer serving\n * files.\n *\n * All internal \u2014 none are exported from the package. */\n\n/** The check inside a resolved comment pin. A drawn check, not the '\u2713' glyph \u2014 that character sits\n * off-baseline and varies by font. Heavier and rounder than `CheckIcon`: it has to hold its weight\n * against the pin's 28px filled face, where the asset check reads too light. */\nexport function PinCheckIcon() {\n\treturn (\n\t\t<svg\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\twidth=\"15\"\n\t\t\theight=\"15\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<path d=\"M4 12.5l5 5L20 6.5\" />\n\t\t</svg>\n\t)\n}\n\n/** The check beside the \"Resolved\" label on a comments list row. Thinner than `PinCheckIcon` \u2014 it\n * sits next to text at 12px, so it's drawn to match the label's weight rather than shout. */\nexport function CheckIcon() {\n\treturn (\n\t\t<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M2.5 6.2 4.7 8.4 9.5 3.6\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** The reaction picker's trigger. */\nexport function SmileyIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M7.49991 0.876892C3.84222 0.876892 0.877075 3.84204 0.877075 7.49972C0.877075 11.1574 3.84222 14.1226 7.49991 14.1226C11.1576 14.1226 14.1227 11.1574 14.1227 7.49972C14.1227 3.84204 11.1576 0.876892 7.49991 0.876892ZM1.82708 7.49972C1.82708 4.36671 4.36689 1.82689 7.49991 1.82689C10.6329 1.82689 13.1727 4.36671 13.1727 7.49972C13.1727 10.6327 10.6329 13.1726 7.49991 13.1726C4.36689 13.1726 1.82708 10.6327 1.82708 7.49972ZM5.03747 9.21395C4.87949 8.98746 4.56782 8.93193 4.34133 9.08991C4.11484 9.24789 4.05931 9.55956 4.21729 9.78605C4.93926 10.8211 6.14033 11.5 7.50004 11.5C8.85974 11.5 10.0608 10.8211 10.7828 9.78605C10.9408 9.55956 10.8852 9.24789 10.6587 9.08991C10.4323 8.93193 10.1206 8.98746 9.9626 9.21395C9.41963 9.99238 8.51907 10.5 7.50004 10.5C6.481 10.5 5.58044 9.99238 5.03747 9.21395ZM5.37503 6.84998C5.85828 6.84998 6.25003 6.45815 6.25003 5.97498C6.25003 5.4918 5.85828 5.09998 5.37503 5.09998C4.89179 5.09998 4.50003 5.4918 4.50003 5.97498C4.50003 6.45815 4.89179 6.84998 5.37503 6.84998ZM10.5 5.97498C10.5 6.45815 10.1083 6.84998 9.62503 6.84998C9.14179 6.84998 8.75003 6.45815 8.75003 5.97498C8.75003 5.4918 9.14179 5.09998 9.62503 5.09998C10.1083 5.09998 10.5 5.4918 10.5 5.97498Z\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t\tclipRule=\"evenodd\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** The composer's post button \u2014 a return arrow (\u21B5), since Enter is what posts. */\nexport function SendIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M12 3V8C12 8.55228 11.5523 9 11 9H3.5M6 6.5L3.5 9L6 11.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** Comment pins are showing. tldraw's `follow` glyph (icons/icon/follow.svg) inlined at its native\n * weight \u2014 the almond eye with a centred pupil. Pairs with `EyeClosedIcon`; the two must stay the\n * same family. */\nexport function EyeOpenIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path fill=\"currentColor\" d=\"M19 15a4 4 0 1 1-8 0 4 4 0 0 1 8 0\" />\n\t\t\t<path\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\td=\"M26 15c0 1.77-1.077 3.496-3.07 4.825C20.946 21.149 18.145 22 15 22s-5.945-.851-7.93-2.175C5.076 18.496 4 16.77 4 15c0-1.77 1.077-3.496 3.07-4.825C9.054 8.851 11.855 8 15 8s5.945.851 7.93 2.175C24.924 11.504 26 13.23 26 15Z\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\n/** Comment pins are hidden. tldraw's `closed` eye glyph (icons/icon/closed.svg) \u2014 a shut lower lid\n * with lashes, the design pair to `follow`. Inlined like the open eye: the package renders without\n * an `AssetUrlsProvider`. Lash dots are `r=1.5` (vs the asset's `r=1`) because at the 15px header\n * size the asset's finer lashes fall below a pixel; the lid keeps `follow`'s native stroke. */\nexport function EyeClosedIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\td=\"M27 15C27 19.4183 21.6274 23 15 23C8.37258 23 3 19.4183 3 15\"\n\t\t\t/>\n\t\t\t<circle cx=\"4\" cy=\"20\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"9\" cy=\"23\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"15\" cy=\"24\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"21\" cy=\"23\" r=\"1.5\" fill=\"currentColor\" />\n\t\t\t<circle cx=\"26\" cy=\"20\" r=\"1.5\" fill=\"currentColor\" />\n\t\t</svg>\n\t)\n}\n\n/** The sidebar's comment-menu trigger \u2014 tldraw's `dots-vertical` glyph (icons/icon/dots-vertical.svg)\n * inlined, a vertical kebab. Inlined like the eye pair because the package renders without an\n * `AssetUrlsProvider`. */\nexport function MoreMenuIcon() {\n\treturn (\n\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\td=\"M15 9.48975C14.3167 9.48975 13.7292 9.24747 13.2375 8.76293C12.7458 8.27003 12.5 7.67688 12.5 6.98348C12.5 6.29843 12.7458 5.71364 13.2375 5.22909C13.7292 4.73619 14.3167 4.48975 15 4.48975C15.6833 4.48975 16.2708 4.73619 16.7625 5.22909C17.2542 5.71364 17.5 6.29843 17.5 6.98348C17.5 7.44296 17.3833 7.86485 17.15 8.24914C16.925 8.62508 16.625 8.92583 16.25 9.1514C15.875 9.37696 15.4583 9.48975 15 9.48975Z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\td=\"M15 17.5C14.3167 17.5 13.7292 17.2577 13.2375 16.7732C12.7458 16.2803 12.5 15.6871 12.5 14.9937C12.5 14.3087 12.7458 13.7239 13.2375 13.2393C13.7292 12.7464 14.3167 12.5 15 12.5C15.6833 12.5 16.2708 12.7464 16.7625 13.2393C17.2542 13.7239 17.5 14.3087 17.5 14.9937C17.5 15.4532 17.3833 15.8751 17.15 16.2594C16.925 16.6353 16.625 16.9361 16.25 17.1617C15.875 17.3872 15.4583 17.5 15 17.5Z\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\td=\"M15 25.5103C14.3167 25.5103 13.7292 25.268 13.2375 24.7834C12.7458 24.2905 12.5 23.6974 12.5 23.004C12.5 22.319 12.7458 21.7342 13.2375 21.2496C13.7292 20.7567 14.3167 20.5103 15 20.5103C15.6833 20.5103 16.2708 20.7567 16.7625 21.2496C17.2542 21.7342 17.5 22.319 17.5 23.004C17.5 23.4635 17.3833 23.8854 17.15 24.2697C16.925 24.6456 16.625 24.9463 16.25 25.1719C15.875 25.3975 15.4583 25.5103 15 25.5103Z\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n"],
5
+ "mappings": "AA8BG,cAsDD,YAtDC;AAbI,SAAS,eAAe;AAC9B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAQ;AAAA,MACR,OAAM;AAAA,MACN,QAAO;AAAA,MACP,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACf,eAAY;AAAA,MAEZ,8BAAC,UAAK,GAAE,sBAAqB;AAAA;AAAA,EAC9B;AAEF;AAIO,SAAS,YAAY;AAC3B,SACC,oBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA;AAAA,EAChB,GACD;AAEF;AAGO,SAAS,aAAa;AAC5B,SACC,oBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,MAAK;AAAA,MACL,UAAS;AAAA,MACT,UAAS;AAAA;AAAA,EACV,GACD;AAEF;AAGO,SAAS,WAAW;AAC1B,SACC,oBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,QAAO;AAAA,MACP,eAAc;AAAA,MACd,gBAAe;AAAA;AAAA,EAChB,GACD;AAEF;AAKO,SAAS,cAAc;AAC7B,SACC,qBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,wBAAC,UAAK,MAAK,gBAAe,GAAE,sCAAqC;AAAA,IACjE;AAAA,MAAC;AAAA;AAAA,QACA,QAAO;AAAA,QACP,aAAY;AAAA,QACZ,GAAE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;AAMO,SAAS,gBAAgB;AAC/B,SACC,qBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,QAAO;AAAA,QACP,aAAY;AAAA,QACZ,eAAc;AAAA,QACd,GAAE;AAAA;AAAA,IACH;AAAA,IACA,oBAAC,YAAO,IAAG,KAAI,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACnD,oBAAC,YAAO,IAAG,KAAI,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACnD,oBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACpD,oBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,IACpD,oBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,OAAM,MAAK,gBAAe;AAAA,KACrD;AAEF;AAKO,SAAS,eAAe;AAC9B,SACC,qBAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,GAAE;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,GAAE;AAAA;AAAA,IACH;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,GAAE;AAAA;AAAA,IACH;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -25,7 +25,7 @@ function ReactionPicker({
25
25
  renderReaction,
26
26
  palette: Palette = EmojiPicker,
27
27
  menuId,
28
- className = "tlui-cmt-thread__action"
28
+ className = "tlui-cmt-icon-btn"
29
29
  }) {
30
30
  const msg = useTranslation();
31
31
  const editor = useMaybeEditor();
@@ -51,7 +51,7 @@ function ReactionPicker({
51
51
  children: /* @__PURE__ */ jsx(SmileyIcon, {})
52
52
  }
53
53
  ) }),
54
- /* @__PURE__ */ jsx(TldrawUiDropdownMenuContent, { side: "bottom", align: "start", alignOffset: 0, sideOffset: 4, children: /* @__PURE__ */ jsx(
54
+ /* @__PURE__ */ jsx(TldrawUiDropdownMenuContent, { side: "bottom", align: "start", alignOffset: 0, sideOffset: 0, children: /* @__PURE__ */ jsx(
55
55
  Palette,
56
56
  {
57
57
  emoji,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/reaction-picker.tsx"],
4
- "sourcesContent": ["import { useCallback, useId, type ComponentType, type KeyboardEvent, type MouseEvent } from 'react'\nimport {\n\tdefineMessages,\n\tTldrawUiButton,\n\tTldrawUiDropdownMenuContent,\n\tTldrawUiDropdownMenuRoot,\n\tTldrawUiDropdownMenuTrigger,\n\ttlmenus,\n\tuseMaybeEditor,\n\tuseTranslation,\n} from 'tldraw'\nimport { EmojiPicker, type EmojiPickerProps } from './emoji-picker'\nimport { SmileyIcon } from './icons'\nimport { RenderReaction } from './reaction'\n\nconst messages = defineMessages({\n\tcommentsAddReaction: { id: 'comments.add-reaction', defaultMessage: 'Add reaction' },\n})\n\n/** @public */\nexport interface ReactionPickerProps {\n\t/** The emoji to offer. Defaults to `DEFAULT_REACTION_EMOJI`. */\n\temoji?: string[]\n\t/** Emoji the current user has already reacted with; shown as pressed in the grid. */\n\tselected?: string[]\n\t/** Called when an emoji is chosen. */\n\tonSelect?(emoji: string): void\n\t/** How to draw each emoji token. Defaults to the token string (OS emoji font). */\n\trenderReaction?: RenderReaction\n\t/**\n\t * What the button opens \u2014 the thing that produces a token. Defaults to `EmojiPicker`, the grid of\n\t * emoji. Swap it for any component taking the same props to offer something else entirely (the\n\t * drawn reactions example replaces it with a canvas you draw in); the props are passed straight\n\t * through either way.\n\t */\n\tpalette?: ComponentType<EmojiPickerProps>\n\t/**\n\t * Identifies the menu in tldraw's global menu registry, which keys open/closed state by id.\n\t * A thread renders one picker per comment, so this must differ per comment \u2014 sharing an id\n\t * makes every picker in the thread open at once. Defaults to a per-instance generated id;\n\t * pass one only for a stabler, more debuggable value.\n\t */\n\tmenuId?: string\n\t/** Class for the trigger button. Defaults to the card-action style, matching the \u22EF button. */\n\tclassName?: string\n}\n\n/**\n * Whether a palette pick asked to keep the palette open (shift held) for multi-select.\n * @internal\n */\nexport function isMultiSelectPick(event?: MouseEvent | KeyboardEvent): boolean {\n\treturn !!event?.shiftKey\n}\n\n/**\n * The add-reaction affordance: a smiley button that opens an emoji grid.\n *\n * Anchored to its own button rather than to the reactions row, so the menu keeps its position as\n * reactions are added and the row reflows.\n *\n * Picking an emoji dismisses the grid \u2014 adding and removing alike, since either way the picker has\n * done its job \u2014 and hands focus back to the trigger. Shift-picking keeps the grid open, for\n * choosing several reactions in a row.\n * @public @react\n */\nexport function ReactionPicker({\n\temoji,\n\tselected,\n\tonSelect,\n\trenderReaction,\n\tpalette: Palette = EmojiPicker,\n\tmenuId,\n\tclassName = 'tlui-cmt-thread__action',\n}: ReactionPickerProps) {\n\tconst msg = useTranslation()\n\tconst editor = useMaybeEditor()\n\t// Unique per mounted picker unless the host supplies something stabler \u2014 see `menuId`.\n\tconst generatedId = useId()\n\tconst id = menuId ?? `comment-reactions-${generatedId}`\n\n\t// The dropdown's open state lives in tldraw's global menu registry, so dropping the entry is\n\t// what closes it. The palette's tokens are plain buttons \u2014 a swappable component, not radix\n\t// menu items \u2014 so nothing dismisses the menu on its own.\n\tconst handleSelect = useCallback(\n\t\t(value: string, event?: MouseEvent | KeyboardEvent) => {\n\t\t\tonSelect?.(value)\n\t\t\tif (!isMultiSelectPick(event)) {\n\t\t\t\ttlmenus.deleteOpenMenu(id, editor?.contextId)\n\t\t\t}\n\t\t},\n\t\t[onSelect, id, editor]\n\t)\n\n\treturn (\n\t\t<TldrawUiDropdownMenuRoot id={id}>\n\t\t\t<TldrawUiDropdownMenuTrigger>\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttooltip={msg(messages.commentsAddReaction)}\n\t\t\t\t\ttitle={msg(messages.commentsAddReaction)}\n\t\t\t\t\tclassName={className}\n\t\t\t\t>\n\t\t\t\t\t<SmileyIcon />\n\t\t\t\t</TldrawUiButton>\n\t\t\t</TldrawUiDropdownMenuTrigger>\n\t\t\t{/* left-aligned under the trigger, so the grid opens rightward off the card's edge */}\n\t\t\t<TldrawUiDropdownMenuContent side=\"bottom\" align=\"start\" alignOffset={0} sideOffset={4}>\n\t\t\t\t<Palette\n\t\t\t\t\temoji={emoji}\n\t\t\t\t\tselected={selected}\n\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\trenderReaction={renderReaction}\n\t\t\t\t/>\n\t\t\t</TldrawUiDropdownMenuContent>\n\t\t</TldrawUiDropdownMenuRoot>\n\t)\n}\n"],
4
+ "sourcesContent": ["import { useCallback, useId, type ComponentType, type KeyboardEvent, type MouseEvent } from 'react'\nimport {\n\tdefineMessages,\n\tTldrawUiButton,\n\tTldrawUiDropdownMenuContent,\n\tTldrawUiDropdownMenuRoot,\n\tTldrawUiDropdownMenuTrigger,\n\ttlmenus,\n\tuseMaybeEditor,\n\tuseTranslation,\n} from 'tldraw'\nimport { EmojiPicker, type EmojiPickerProps } from './emoji-picker'\nimport { SmileyIcon } from './icons'\nimport { RenderReaction } from './reaction'\n\nconst messages = defineMessages({\n\tcommentsAddReaction: { id: 'comments.add-reaction', defaultMessage: 'Add reaction' },\n})\n\n/** @public */\nexport interface ReactionPickerProps {\n\t/** The emoji to offer. Defaults to `DEFAULT_REACTION_EMOJI`. */\n\temoji?: string[]\n\t/** Emoji the current user has already reacted with; shown as pressed in the grid. */\n\tselected?: string[]\n\t/** Called when an emoji is chosen. */\n\tonSelect?(emoji: string): void\n\t/** How to draw each emoji token. Defaults to the token string (OS emoji font). */\n\trenderReaction?: RenderReaction\n\t/**\n\t * What the button opens \u2014 the thing that produces a token. Defaults to `EmojiPicker`, the grid of\n\t * emoji. Swap it for any component taking the same props to offer something else entirely (the\n\t * drawn reactions example replaces it with a canvas you draw in); the props are passed straight\n\t * through either way.\n\t */\n\tpalette?: ComponentType<EmojiPickerProps>\n\t/**\n\t * Identifies the menu in tldraw's global menu registry, which keys open/closed state by id.\n\t * A thread renders one picker per comment, so this must differ per comment \u2014 sharing an id\n\t * makes every picker in the thread open at once. Defaults to a per-instance generated id;\n\t * pass one only for a stabler, more debuggable value.\n\t */\n\tmenuId?: string\n\t/** Class for the trigger button. Defaults to the card-action style, matching the \u22EF button. */\n\tclassName?: string\n}\n\n/**\n * Whether a palette pick asked to keep the palette open (shift held) for multi-select.\n * @internal\n */\nexport function isMultiSelectPick(event?: MouseEvent | KeyboardEvent): boolean {\n\treturn !!event?.shiftKey\n}\n\n/**\n * The add-reaction affordance: a smiley button that opens an emoji grid.\n *\n * Anchored to its own button rather than to the reactions row, so the menu keeps its position as\n * reactions are added and the row reflows.\n *\n * Picking an emoji dismisses the grid \u2014 adding and removing alike, since either way the picker has\n * done its job \u2014 and hands focus back to the trigger. Shift-picking keeps the grid open, for\n * choosing several reactions in a row.\n * @public @react\n */\nexport function ReactionPicker({\n\temoji,\n\tselected,\n\tonSelect,\n\trenderReaction,\n\tpalette: Palette = EmojiPicker,\n\tmenuId,\n\tclassName = 'tlui-cmt-icon-btn',\n}: ReactionPickerProps) {\n\tconst msg = useTranslation()\n\tconst editor = useMaybeEditor()\n\t// Unique per mounted picker unless the host supplies something stabler \u2014 see `menuId`.\n\tconst generatedId = useId()\n\tconst id = menuId ?? `comment-reactions-${generatedId}`\n\n\t// The dropdown's open state lives in tldraw's global menu registry, so dropping the entry is\n\t// what closes it. The palette's tokens are plain buttons \u2014 a swappable component, not radix\n\t// menu items \u2014 so nothing dismisses the menu on its own.\n\tconst handleSelect = useCallback(\n\t\t(value: string, event?: MouseEvent | KeyboardEvent) => {\n\t\t\tonSelect?.(value)\n\t\t\tif (!isMultiSelectPick(event)) {\n\t\t\t\ttlmenus.deleteOpenMenu(id, editor?.contextId)\n\t\t\t}\n\t\t},\n\t\t[onSelect, id, editor]\n\t)\n\n\treturn (\n\t\t<TldrawUiDropdownMenuRoot id={id}>\n\t\t\t<TldrawUiDropdownMenuTrigger>\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttooltip={msg(messages.commentsAddReaction)}\n\t\t\t\t\ttitle={msg(messages.commentsAddReaction)}\n\t\t\t\t\tclassName={className}\n\t\t\t\t>\n\t\t\t\t\t<SmileyIcon />\n\t\t\t\t</TldrawUiButton>\n\t\t\t</TldrawUiDropdownMenuTrigger>\n\t\t\t{/* left-aligned under the trigger, so the grid opens rightward off the card's edge */}\n\t\t\t<TldrawUiDropdownMenuContent side=\"bottom\" align=\"start\" alignOffset={0} sideOffset={0}>\n\t\t\t\t<Palette\n\t\t\t\t\temoji={emoji}\n\t\t\t\t\tselected={selected}\n\t\t\t\t\tonSelect={handleSelect}\n\t\t\t\t\trenderReaction={renderReaction}\n\t\t\t\t/>\n\t\t\t</TldrawUiDropdownMenuContent>\n\t\t</TldrawUiDropdownMenuRoot>\n\t)\n}\n"],
5
5
  "mappings": "AA+FE,SAQG,KARH;AA/FF,SAAS,aAAa,aAAsE;AAC5F;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAA0C;AACnD,SAAS,kBAAkB;AAG3B,MAAM,WAAW,eAAe;AAAA,EAC/B,qBAAqB,EAAE,IAAI,yBAAyB,gBAAgB,eAAe;AACpF,CAAC;AAkCM,SAAS,kBAAkB,OAA6C;AAC9E,SAAO,CAAC,CAAC,OAAO;AACjB;AAaO,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,UAAU;AAAA,EACnB;AAAA,EACA,YAAY;AACb,GAAwB;AACvB,QAAM,MAAM,eAAe;AAC3B,QAAM,SAAS,eAAe;AAE9B,QAAM,cAAc,MAAM;AAC1B,QAAM,KAAK,UAAU,qBAAqB,WAAW;AAKrD,QAAM,eAAe;AAAA,IACpB,CAAC,OAAe,UAAuC;AACtD,iBAAW,KAAK;AAChB,UAAI,CAAC,kBAAkB,KAAK,GAAG;AAC9B,gBAAQ,eAAe,IAAI,QAAQ,SAAS;AAAA,MAC7C;AAAA,IACD;AAAA,IACA,CAAC,UAAU,IAAI,MAAM;AAAA,EACtB;AAEA,SACC,qBAAC,4BAAyB,IACzB;AAAA,wBAAC,+BACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,SAAS,IAAI,SAAS,mBAAmB;AAAA,QACzC,OAAO,IAAI,SAAS,mBAAmB;AAAA,QACvC;AAAA,QAEA,8BAAC,cAAW;AAAA;AAAA,IACb,GACD;AAAA,IAEA,oBAAC,+BAA4B,MAAK,UAAS,OAAM,SAAQ,aAAa,GAAG,YAAY,GACpF;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV;AAAA;AAAA,IACD,GACD;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/send-button.tsx"],
4
- "sourcesContent": ["import { SendIcon } from './icons'\n\n/** @public */\nexport interface SendButtonProps {\n\t/** The button's accessible name (e.g. \"Send\"). Shown as an up-arrow icon, so this is its label. */\n\tlabel: string\n\tdisabled?: boolean\n\tonClick?(): void\n}\n\n/** The button that posts a comment \u2014 an up arrow. @public @react */\nexport function SendButton({ label, disabled, onClick }: SendButtonProps) {\n\treturn (\n\t\t<button\n\t\t\tclassName=\"tlui-cmt-send\"\n\t\t\ttype=\"button\"\n\t\t\tdisabled={disabled}\n\t\t\tonClick={onClick}\n\t\t\taria-label={label}\n\t\t\ttitle={label}\n\t\t>\n\t\t\t<SendIcon />\n\t\t</button>\n\t)\n}\n"],
4
+ "sourcesContent": ["import { SendIcon } from './icons'\n\n/** @public */\nexport interface SendButtonProps {\n\t/** The button's accessible name (e.g. \"Send\"). Shown as a return-arrow icon, so this is its label. */\n\tlabel: string\n\tdisabled?: boolean\n\tonClick?(): void\n}\n\n/** The button that posts a comment \u2014 a return arrow. @public @react */\nexport function SendButton({ label, disabled, onClick }: SendButtonProps) {\n\treturn (\n\t\t<button\n\t\t\tclassName=\"tlui-cmt-send\"\n\t\t\ttype=\"button\"\n\t\t\tdisabled={disabled}\n\t\t\tonClick={onClick}\n\t\t\taria-label={label}\n\t\t\ttitle={label}\n\t\t>\n\t\t\t<SendIcon />\n\t\t</button>\n\t)\n}\n"],
5
5
  "mappings": "AAqBG;AArBH,SAAS,gBAAgB;AAWlB,SAAS,WAAW,EAAE,OAAO,UAAU,QAAQ,GAAoB;AACzE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,MAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,cAAY;AAAA,MACZ,OAAO;AAAA,MAEP,8BAAC,YAAS;AAAA;AAAA,EACX;AAEF;",
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-canary.fb3426ffa934",
4
+ "version": "5.7.0-internal.5fe8922939ec",
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-canary.fb3426ffa934",
35
+ "@tldraw/driver": "5.7.0-internal.5fe8922939ec",
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-canary.fb3426ffa934",
54
- "@tldraw/utils": "5.7.0-canary.fb3426ffa934",
55
- "tldraw": "5.7.0-canary.fb3426ffa934"
53
+ "@tldraw/mentions": "5.7.0-internal.5fe8922939ec",
54
+ "@tldraw/utils": "5.7.0-internal.5fe8922939ec",
55
+ "tldraw": "5.7.0-internal.5fe8922939ec"
56
56
  },
57
57
  "module": "dist-esm/index.mjs",
58
58
  "source": "src/index.ts",
@@ -1,9 +1,9 @@
1
1
  import { type PointerEvent as ReactPointerEvent } from 'react'
2
- import { Editor } from 'tldraw'
2
+ import { Editor, react, TLCursorType, unsafe__withoutCapture } from 'tldraw'
3
3
 
4
4
  /** A pointer-down that belongs to the camera, not the comment UI: any non-primary button
5
5
  * (middle/right-button pans), or a primary press with the spacebar pan key held. */
6
- export function isCanvasPanGesture(editor: Editor, e: ReactPointerEvent) {
6
+ export function isCanvasPanGesture(editor: Editor, e: { button: number }) {
7
7
  return e.button !== 0 || editor.inputs.keys.has('Space')
8
8
  }
9
9
 
@@ -16,3 +16,40 @@ export function forwardPointerEventToCanvas(container: HTMLElement, e: ReactPoin
16
16
  ;(newEvent as any).isSpecialRedispatchedEvent = true
17
17
  cvs.dispatchEvent(newEvent)
18
18
  }
19
+
20
+ /**
21
+ * Start a comment drag (pin move or region resize) run by the comment UI's own pointer handlers
22
+ * rather than a tool state. Shows `cursor` for the whole drag and re-runs `onCameraMove` when the
23
+ * camera moves, from the drag's last pointer position, so a mid-drag scroll keeps the dragged thing
24
+ * under the pointer as a shape drag does. Returns the cleanup.
25
+ *
26
+ * The drag's pointer moves still reach the editor (its inputs and the presence cursor others see
27
+ * must keep tracking), so the active tool's hover handling may set its own cursor on each one; the
28
+ * drag's cursor is put back whenever that happens.
29
+ */
30
+ export function startCommentDrag(
31
+ editor: Editor,
32
+ { cursor, onCameraMove }: { cursor: TLCursorType; onCameraMove(): void }
33
+ ): () => void {
34
+ const prevCursor = { ...editor.getInstanceState().cursor }
35
+ const stopCursor = react('comment drag cursor', () => {
36
+ if (editor.getInstanceState().cursor.type !== cursor) {
37
+ editor.setCursor({ type: cursor, rotation: 0 })
38
+ }
39
+ })
40
+ let started = false
41
+ const stopCamera = react('comment drag follows camera', () => {
42
+ editor.getCamera()
43
+ if (!started) {
44
+ started = true
45
+ return
46
+ }
47
+ // Untracked: the callback writes state it may also read.
48
+ unsafe__withoutCapture(onCameraMove)
49
+ })
50
+ return () => {
51
+ stopCamera()
52
+ stopCursor()
53
+ editor.setCursor(prevCursor)
54
+ }
55
+ }
@@ -61,10 +61,6 @@
61
61
  outline: 2px solid var(--tl-color-selected);
62
62
  outline-offset: 2px;
63
63
  }
64
- /* Focus should read like hover, so the pin lifts the same way when tabbed to. */
65
- .tlui-cmt-canvas-pin__marker:focus-visible .tlui-cmt-marker {
66
- transform: scale(var(--tlui-cmt-marker-hover-scale));
67
- }
68
64
 
69
65
  .tlui-cmt-cluster-fade {
70
66
  opacity: 1;
@@ -99,6 +95,10 @@
99
95
  .tlui-cmt-canvas-pin--open {
100
96
  z-index: 1;
101
97
  }
98
+ /* A pin being dragged rides over everything it passes, the open thread's pin included. */
99
+ .tlui-cmt-canvas-pin--dragging {
100
+ z-index: 2;
101
+ }
102
102
 
103
103
  /* The count badge standing in for a stack of coincident pins — same face as a cluster badge,
104
104
  but clicking opens the stack's thread list rather than zooming (no zoom can separate them).
@@ -119,7 +119,6 @@
119
119
  .tlui-cmt-canvas-stack-badge:focus-visible .tlui-cmt-marker {
120
120
  outline: 2px solid var(--tl-color-selected);
121
121
  outline-offset: 2px;
122
- transform: scale(var(--tlui-cmt-marker-hover-scale));
123
122
  }
124
123
 
125
124
  /* The stack's popover content: one card per thread, the expanded thread inline among them. */
@@ -273,31 +272,39 @@
273
272
  cursor: pointer;
274
273
  }
275
274
 
276
- /* Every card surface that tints on hover — a collapsed thread in a stack list, a preview card, and
277
- the single-comment preview panel. One rule, because they're the same object to the eye.
278
-
279
- The opaque low-surface token, not a translucent muted one: these float directly over the canvas,
280
- where a translucent fill would let shapes show through.
281
-
282
- The second line is why this isn't a one-liner. `--tl-shadow-3` ends with a 1px *inset* ring in
283
- `--tl-color-panel-contrast` — pure white in light mode — and an inset shadow paints over the
284
- background. At rest that's invisible (the panel is 99% white under a 100% white ring), but tint
285
- the background to grey and the ring stays white, hugging the edge as a pale outline. Re-tinting
286
- `--tl-color-panel-contrast` here wouldn't reach it: `--tl-shadow-3` is declared on the container,
287
- so its var() was already substituted there and the white is baked into what we inherit. Instead
288
- lay a ring of the new surface over the old one — first shadow in the list paints on top. */
275
+ /* Every card surface that highlights on hover — a collapsed thread in a stack list, a preview
276
+ card, and the single-comment preview panel. One rule, because they're the same object to the eye.
277
+ The highlight is an inset, rounded wash like a menu item's, not a tint of the whole surface: the
278
+ card stays panel-white and a wash sits 4px inside its edge, its corners following the card's.
279
+ It paints behind the content (`isolation` keeps the -1 z-index above the card's own fill). */
280
+ .tlui-cmt-stack-list__card,
281
+ .tlui-cmt-preview-card--selectable,
282
+ .tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable {
283
+ position: relative;
284
+ isolation: isolate;
285
+ }
286
+ .tlui-cmt-stack-list__card::after,
287
+ .tlui-cmt-preview-card--selectable::after,
288
+ .tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable::after {
289
+ content: '';
290
+ position: absolute;
291
+ inset: 4px;
292
+ z-index: -1;
293
+ /* The cards' 12px radius, less the inset. */
294
+ border-radius: 8px;
295
+ pointer-events: none;
296
+ }
297
+ .tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable::after {
298
+ border-radius: calc(var(--tl-radius-4) - 4px);
299
+ }
300
+ .tlui-cmt-stack-list__card:hover::after,
301
+ .tlui-cmt-preview-card--selectable:hover::after,
302
+ .tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable:hover::after {
303
+ background: var(--tl-color-muted-2);
304
+ }
289
305
  .tlui-cmt-stack-list__card:hover,
290
306
  .tlui-cmt-preview-card--selectable:hover,
291
307
  .tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable:hover {
292
- --tlui-cmt-preview-hover-surface: color-mix(
293
- in srgb,
294
- var(--tl-color-low) 50%,
295
- var(--tl-color-panel)
296
- );
297
- background: var(--tlui-cmt-preview-hover-surface);
298
- box-shadow:
299
- inset 0 0 0 1px var(--tlui-cmt-preview-hover-surface),
300
- var(--tl-shadow-3);
301
308
  cursor: pointer;
302
309
  }
303
310
 
@@ -341,23 +348,45 @@
341
348
  .tlui-cmt-canvas-region {
342
349
  position: absolute;
343
350
  pointer-events: none;
344
- border: 2px dashed var(--tl-color-selected);
345
- border-radius: 6px;
346
351
  background: color-mix(in srgb, var(--tl-color-selected) 10%, transparent);
347
352
  }
353
+ .tlui-cmt-canvas-region__outline {
354
+ position: absolute;
355
+ inset: 0;
356
+ overflow: visible;
357
+ fill: none;
358
+ stroke: var(--tl-color-selection-stroke);
359
+ stroke-width: 1.5px;
360
+ stroke-linecap: round;
361
+ }
362
+
363
+ .tlui-cmt-canvas-region-handles {
364
+ display: contents;
365
+ }
348
366
 
349
- /* Corner resize handles on a region box (three corners; the pin corner is the move handle). */
367
+ /* Corner resize handles on a region box (three corners; the pin corner is the move handle). The
368
+ element is the hit square, sized from the selection's corner hit area (see
369
+ `selectionCornerSizing`); the visible square is drawn like a selection corner: an 8px fill with a
370
+ 1.5px stroke centred on its edge. */
350
371
  .tlui-cmt-canvas-region-handle {
351
372
  position: absolute;
352
- width: 9px;
353
- height: 9px;
354
373
  transform: translate(-50%, -50%);
355
- background: var(--tl-color-panel);
356
- border: 1.5px solid var(--tl-color-selected);
357
- border-radius: 2px;
358
374
  pointer-events: auto;
359
375
  touch-action: none;
360
376
  }
377
+ .tlui-cmt-canvas-region-handle::before {
378
+ content: '';
379
+ position: absolute;
380
+ left: 50%;
381
+ top: 50%;
382
+ /* Not covered by the container's `*` border-box rule, which doesn't match pseudo-elements. */
383
+ box-sizing: border-box;
384
+ width: 9.5px;
385
+ height: 9.5px;
386
+ transform: translate(-50%, -50%);
387
+ background: var(--tl-color-background);
388
+ border: 1.5px solid var(--tl-color-selection-stroke);
389
+ }
361
390
 
362
391
  /* Anchor the pin by its bottom-left corner, so the marker's one sharp corner (the pin shape's
363
392
  3px bottom-left) points at the exact anchor point. */
@@ -489,14 +518,20 @@
489
518
  .tlui-cmt-canvas-composer .tlui-cmt-input__placeholder {
490
519
  left: 12px;
491
520
  }
492
- /* The draft avatar previews the pin it becomes — a white 28px pin holding the author's 22px avatar
493
- circle — sharing the composer's lift. Not interactive: it drops the pin's pointer cursor and
494
- hover affordances (scale + shadow bump), but keeps a 40×40 hit area (the ::after below). */
521
+ /* The draft avatar previews the pin it becomes and is the draft's drag handle. It keeps a 40×40 hit
522
+ area (the ::after below). */
495
523
  .tlui-cmt-canvas-composer .tlui-cmt-pin {
496
524
  position: relative;
497
525
  box-shadow: var(--tl-shadow-2);
498
526
  cursor: default;
499
527
  }
528
+ .tlui-cmt-canvas-composer__handle {
529
+ touch-action: none;
530
+ }
531
+ .tlui-cmt-canvas-composer--dragging .tlui-cmt-canvas-composer__handle,
532
+ .tlui-cmt-canvas-composer--dragging .tlui-cmt-pin {
533
+ cursor: var(--tl-cursor-move);
534
+ }
500
535
  .tlui-cmt-canvas-composer .tlui-cmt-pin::after {
501
536
  content: '';
502
537
  position: absolute;
@@ -16,6 +16,7 @@ import {
16
16
  import { afterEach, describe, expect, it } from 'vitest'
17
17
  import {
18
18
  commitCommentMutation,
19
+ commitCommentPost,
19
20
  deleteComment,
20
21
  deleteThread,
21
22
  editComment,
@@ -450,3 +451,53 @@ describe('getLiveComments and getLiveCommentThreads', () => {
450
451
  expect(getLiveCommentThreads(editor)).toEqual([readThread(editor, thread)])
451
452
  })
452
453
  })
454
+
455
+ describe('commitCommentPost', () => {
456
+ function makeRefusingEditor() {
457
+ const editor = new Editor({
458
+ store: createTLStore({
459
+ schema: createTLSchema({ records: commentSchemaRecords }),
460
+ authorize: {
461
+ write: (changes) =>
462
+ changes.some((c) => (c.next?.typeName as string) === 'comment')
463
+ ? { reason: 'no comments' }
464
+ : null,
465
+ },
466
+ }),
467
+ shapeUtils: defaultShapeUtils,
468
+ bindingUtils: defaultBindingUtils,
469
+ tools: defaultTools,
470
+ getContainer: () => document.body,
471
+ })
472
+ editors.push(editor)
473
+ return editor
474
+ }
475
+ const post = (editor: Editor) =>
476
+ commitCommentPost(editor, ({ put }) => {
477
+ const thread = createCommentThread({
478
+ pageId: editor.getCurrentPageId(),
479
+ anchor: { type: 'point', x: 0, y: 0 },
480
+ createdBy: 'me',
481
+ })
482
+ const comment = tlCreateComment({
483
+ threadId: thread.id,
484
+ pageId: thread.pageId,
485
+ authorId: 'me',
486
+ body: toRichText('hi'),
487
+ })
488
+ put([thread, comment])
489
+ return comment
490
+ })
491
+
492
+ it('returns the comment once it is stored', () => {
493
+ const editor = makeEditor()
494
+ const comment = post(editor)
495
+ expect(comment && getCommentRecord(editor, comment.id)).toEqual(comment)
496
+ })
497
+
498
+ it("returns null when the editor's authorize.write refused it", () => {
499
+ const editor = makeRefusingEditor()
500
+ expect(post(editor)).toBeNull()
501
+ expect(getComments(editor)).toEqual([])
502
+ })
503
+ })
@@ -130,6 +130,20 @@ export function commitCommentMutation<T>(
130
130
  }
131
131
  }
132
132
 
133
+ /**
134
+ * Post a comment through {@link commitCommentMutation}, and return it only if it was stored. The
135
+ * editor's `authorize.write` can refuse the post, which reverts it without throwing, so a composer
136
+ * that took the return value as success would drop the draft of a comment that was never posted.
137
+ * @internal
138
+ */
139
+ export function commitCommentPost(
140
+ editor: Editor,
141
+ fn: (writer: CommentMutationWriter) => TLComment
142
+ ): TLComment | null {
143
+ const comment = commitCommentMutation(editor, fn)
144
+ return getCommentRecord(editor, comment.id) ? comment : null
145
+ }
146
+
133
147
  /**
134
148
  * Write comment records to the store, under the configured {@link CommentingOptions.history}
135
149
  * behavior. Defaults to `'ignore'`.
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import { EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'
2
+ import { commentTipTapExtensions, EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'
3
3
  import { renderCommentHtml, renderCommentPlaintext } from './comment-render'
4
4
 
5
5
  const doc = (...content: any[]) => ({ type: 'doc', content }) as any
@@ -26,6 +26,13 @@ describe('renderCommentHtml', () => {
26
26
  expect(list).toContain('one')
27
27
  })
28
28
 
29
+ it('leaves task lists out of the limited set', () => {
30
+ // A posted comment is static HTML, so its checkboxes would toggle and never write back.
31
+ expect(commentTipTapExtensions.map((extension) => extension.name)).not.toEqual(
32
+ expect.arrayContaining([expect.stringMatching(/^task/)])
33
+ )
34
+ })
35
+
29
36
  it('renders a heading node as a paragraph, never a heading', () => {
30
37
  const html = renderCommentHtml(
31
38
  doc({ type: 'heading', attrs: { level: 1 }, content: [text('Title')] })
@@ -15,7 +15,7 @@ import {
15
15
  } from 'tldraw'
16
16
  import { afterEach, beforeEach, describe, expect, it } from 'vitest'
17
17
  import { CommentTool, commentToolOverrides, startCommentAt } from './comment-tool'
18
- import { commentsSidebarOpen, pendingComment, regionDraft } from './state'
18
+ import { pendingComment, regionDraft } from './state'
19
19
 
20
20
  /**
21
21
  * Pointer-driven tests for the comment tool's placement affordances. These need a real editor
@@ -110,8 +110,6 @@ describe('comment tool placement lifecycle', () => {
110
110
  editor.setCurrentTool('comment')
111
111
  driver.pointerDown(400, 300)
112
112
  driver.pointerUp(400, 300)
113
- // Placement opens the composer but the interaction isn't over — the tool holds on until
114
- // the comment is posted or dismissed, so the surrounding UI stays stable.
115
113
  expect(editor.isIn('comment.idle')).toBe(true)
116
114
  expect(pendingComment.get(editor)).toEqual({
117
115
  anchor: { type: 'point', x: 400, y: 300 },
@@ -119,63 +117,63 @@ describe('comment tool placement lifecycle', () => {
119
117
  })
120
118
  })
121
119
 
122
- it('cancels the placement and returns to select on a second click', () => {
120
+ it('keeps the composer open when the tool is left', () => {
123
121
  editor.setCurrentTool('comment')
124
122
  driver.pointerDown(400, 300)
125
123
  driver.pointerUp(400, 300)
126
- driver.pointerDown(200, 200)
127
- driver.pointerUp(200, 200)
128
- expect(editor.isIn('select.idle')).toBe(true)
129
- expect(pendingComment.get(editor)).toBeNull()
124
+ editor.setCurrentTool('hand')
125
+ expect(pendingComment.get(editor)).not.toBeNull()
130
126
  })
131
127
 
132
- it('drops the pending composer when the tool exits', () => {
128
+ it('hides the cursor on press, shows move once dragging, then the comment cursor on release', () => {
133
129
  editor.setCurrentTool('comment')
130
+ expect(editor.getInstanceState().cursor.type).toBe('comment')
134
131
  driver.pointerDown(400, 300)
135
- driver.pointerUp(400, 300)
136
- expect(pendingComment.get(editor)).not.toBeNull()
132
+ expect(editor.getInstanceState().cursor.type).toBe('none')
133
+ driver.pointerMove(450, 350)
134
+ expect(editor.isIn('comment.pointing')).toBe(true)
135
+ expect(editor.getInstanceState().cursor.type).toBe('move')
136
+ driver.pointerUp(450, 350)
137
+ expect(editor.getInstanceState().cursor.type).toBe('comment')
138
+ })
137
139
 
138
- // A direct tool switch (toolbar, shortcut) abandons the draft composer — it belongs to
139
- // the tool. The text itself survives in the comment draft store.
140
- editor.setCurrentTool('select')
140
+ it('escape mid-placement leaves the tool for select and drops the draft', () => {
141
+ editor.setCurrentTool('comment')
142
+ driver.pointerDown(400, 300)
143
+ editor.cancel()
144
+ expect(editor.isIn('select')).toBe(true)
141
145
  expect(pendingComment.get(editor)).toBeNull()
142
146
  })
143
147
 
144
- it('closes the comments sidebar for the whole interaction', () => {
145
- commentsSidebarOpen.set(editor, true)
148
+ it('escape before placing leaves the tool for select', () => {
146
149
  editor.setCurrentTool('comment')
147
- expect(commentsSidebarOpen.get(editor)).toBe(false)
148
-
149
- // ...and placing doesn't reopen it: the tool (and the closed sidebar) hold through the
150
- // composer. Reopening is the host's button, never a side effect of leaving the tool.
151
- driver.pointerDown(400, 300)
152
- driver.pointerUp(400, 300)
153
- expect(editor.isIn('comment.idle')).toBe(true)
154
- expect(commentsSidebarOpen.get(editor)).toBe(false)
150
+ editor.cancel()
151
+ expect(editor.isIn('select')).toBe(true)
155
152
  })
156
153
 
157
- it('escape leaves the tool for select and drops the draft', () => {
154
+ it('escape closes an open composer and stays in the tool, then a second escape leaves for select', () => {
155
+ editor.setCurrentTool('hand')
158
156
  editor.setCurrentTool('comment')
159
157
  driver.pointerDown(400, 300)
160
158
  driver.pointerUp(400, 300)
161
159
  editor.cancel()
162
- expect(editor.isIn('select')).toBe(true)
163
160
  expect(pendingComment.get(editor)).toBeNull()
161
+ expect(editor.isIn('comment.idle')).toBe(true)
162
+ // Select, not the tool that was active before the comment tool.
163
+ editor.cancel()
164
+ expect(editor.isIn('select')).toBe(true)
164
165
  })
165
166
  })
166
167
 
167
168
  describe('startCommentAt', () => {
168
- let driver: Driver
169
-
170
169
  beforeEach(() => {
171
- driver = makeEditor()
170
+ makeEditor()
172
171
  })
173
172
 
174
- it('enters the tool and opens the composer at a bare point on empty canvas', () => {
175
- commentsSidebarOpen.set(editor, true)
173
+ it('opens the composer at a bare point on empty canvas, with select active', () => {
174
+ editor.setCurrentTool('comment')
176
175
  startCommentAt(editor, { x: 400, y: 300 })
177
- expect(editor.isIn('comment.idle')).toBe(true)
178
- expect(commentsSidebarOpen.get(editor)).toBe(false)
176
+ expect(editor.isIn('select.idle')).toBe(true)
179
177
  expect(pendingComment.get(editor)).toEqual({
180
178
  anchor: { type: 'point', x: 400, y: 300 },
181
179
  point: { x: 400, y: 300 },
@@ -187,16 +185,6 @@ describe('startCommentAt', () => {
187
185
  startCommentAt(editor, { x: 150, y: 125 })
188
186
  expect(pendingComment.get(editor)?.anchor).toMatchObject({ type: 'shape', shapeId: id })
189
187
  })
190
-
191
- it('hints the anchored shape, not the one under the live pointer', () => {
192
- const anchored = makeShape()
193
- const underPointer = makeShape(400, 100)
194
- driver.pointerMove(450, 125)
195
- editor.setCurrentTool('comment')
196
- expect(editor.getHintingShapeIds()).toEqual([underPointer])
197
- startCommentAt(editor, { x: 150, y: 125 })
198
- expect(editor.getHintingShapeIds()).toEqual([anchored])
199
- })
200
188
  })
201
189
 
202
190
  describe('commentToolOverrides', () => {
@@ -219,7 +207,7 @@ describe('commentToolOverrides', () => {
219
207
  driver.pointerDown(400, 300).pointerUp(400, 300)
220
208
  driver.pointerMove(600, 500)
221
209
  getCommentTool().onSelect('context-menu')
222
- expect(editor.isIn('comment.idle')).toBe(true)
210
+ expect(editor.isIn('select.idle')).toBe(true)
223
211
  expect(pendingComment.get(editor)?.point).toEqual({ x: 400, y: 300 })
224
212
  })
225
213
 
@@ -262,6 +250,8 @@ describe('comment tool placement hints with regions enabled', () => {
262
250
  it('does not hint a shape under the pin corner of a placed region', () => {
263
251
  const driver = makeEditor(CommentTool.configure({ enableRegions: true }))
264
252
  makeShape(100, 100)
253
+ // The comment tool stays active with the region composer open, so its idle hover is what
254
+ // could re-hint the shape.
265
255
  editor.setCurrentTool('comment')
266
256
  // Release on top of the shape: a region anchors to its rectangle, so the outline that
267
257
  // normally previews a shape anchor would be a lie here.