@tldraw/commenting 5.7.0-canary.f873af22bc21 → 5.7.0-canary.fade002097a9

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 (102) hide show
  1. package/commenting.css +280 -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-tool.js +29 -28
  5. package/dist-cjs/canvas/comment-tool.js.map +2 -2
  6. package/dist-cjs/canvas/comments-filter-menu.js +55 -38
  7. package/dist-cjs/canvas/comments-filter-menu.js.map +2 -2
  8. package/dist-cjs/canvas/comments-overflow-menu.js +6 -24
  9. package/dist-cjs/canvas/comments-overflow-menu.js.map +2 -2
  10. package/dist-cjs/canvas/comments-overlay.js +1 -0
  11. package/dist-cjs/canvas/comments-overlay.js.map +2 -2
  12. package/dist-cjs/canvas/comments-sidebar.js +15 -3
  13. package/dist-cjs/canvas/comments-sidebar.js.map +2 -2
  14. package/dist-cjs/canvas/comments-visibility-toggle.js +1 -1
  15. package/dist-cjs/canvas/comments-visibility-toggle.js.map +1 -1
  16. package/dist-cjs/canvas/options.js.map +2 -2
  17. package/dist-cjs/canvas/pending-composer.js +133 -8
  18. package/dist-cjs/canvas/pending-composer.js.map +2 -2
  19. package/dist-cjs/canvas/region-box.js +150 -35
  20. package/dist-cjs/canvas/region-box.js.map +3 -3
  21. package/dist-cjs/canvas/thread-pin.js +20 -4
  22. package/dist-cjs/canvas/thread-pin.js.map +2 -2
  23. package/dist-cjs/canvas/thread-view.js +130 -57
  24. package/dist-cjs/canvas/thread-view.js.map +2 -2
  25. package/dist-cjs/index.d.ts +39 -11
  26. package/dist-cjs/index.js +1 -1
  27. package/dist-cjs/ui/byline.js +2 -2
  28. package/dist-cjs/ui/byline.js.map +2 -2
  29. package/dist-cjs/ui/comment-card.js +3 -1
  30. package/dist-cjs/ui/comment-card.js.map +2 -2
  31. package/dist-cjs/ui/comment-extensions.js +4 -1
  32. package/dist-cjs/ui/comment-extensions.js.map +2 -2
  33. package/dist-cjs/ui/comments-list.js +6 -7
  34. package/dist-cjs/ui/comments-list.js.map +2 -2
  35. package/dist-cjs/ui/icons.js +4 -4
  36. package/dist-cjs/ui/icons.js.map +2 -2
  37. package/dist-cjs/ui/reaction-picker.js +2 -2
  38. package/dist-cjs/ui/reaction-picker.js.map +1 -1
  39. package/dist-cjs/ui/send-button.js.map +1 -1
  40. package/dist-esm/canvas/canvas-events.mjs +25 -1
  41. package/dist-esm/canvas/canvas-events.mjs.map +2 -2
  42. package/dist-esm/canvas/comment-tool.mjs +30 -29
  43. package/dist-esm/canvas/comment-tool.mjs.map +2 -2
  44. package/dist-esm/canvas/comments-filter-menu.mjs +57 -39
  45. package/dist-esm/canvas/comments-filter-menu.mjs.map +2 -2
  46. package/dist-esm/canvas/comments-overflow-menu.mjs +8 -24
  47. package/dist-esm/canvas/comments-overflow-menu.mjs.map +2 -2
  48. package/dist-esm/canvas/comments-overlay.mjs +1 -0
  49. package/dist-esm/canvas/comments-overlay.mjs.map +2 -2
  50. package/dist-esm/canvas/comments-sidebar.mjs +16 -4
  51. package/dist-esm/canvas/comments-sidebar.mjs.map +2 -2
  52. package/dist-esm/canvas/comments-visibility-toggle.mjs +1 -1
  53. package/dist-esm/canvas/comments-visibility-toggle.mjs.map +1 -1
  54. package/dist-esm/canvas/options.mjs.map +2 -2
  55. package/dist-esm/canvas/pending-composer.mjs +143 -9
  56. package/dist-esm/canvas/pending-composer.mjs.map +2 -2
  57. package/dist-esm/canvas/region-box.mjs +161 -38
  58. package/dist-esm/canvas/region-box.mjs.map +3 -3
  59. package/dist-esm/canvas/thread-pin.mjs +22 -6
  60. package/dist-esm/canvas/thread-pin.mjs.map +2 -2
  61. package/dist-esm/canvas/thread-view.mjs +140 -58
  62. package/dist-esm/canvas/thread-view.mjs.map +2 -2
  63. package/dist-esm/index.d.mts +39 -11
  64. package/dist-esm/index.mjs +1 -1
  65. package/dist-esm/ui/byline.mjs +2 -2
  66. package/dist-esm/ui/byline.mjs.map +2 -2
  67. package/dist-esm/ui/comment-card.mjs +3 -1
  68. package/dist-esm/ui/comment-card.mjs.map +2 -2
  69. package/dist-esm/ui/comment-extensions.mjs +11 -2
  70. package/dist-esm/ui/comment-extensions.mjs.map +2 -2
  71. package/dist-esm/ui/comments-list.mjs +6 -7
  72. package/dist-esm/ui/comments-list.mjs.map +2 -2
  73. package/dist-esm/ui/icons.mjs +4 -4
  74. package/dist-esm/ui/icons.mjs.map +2 -2
  75. package/dist-esm/ui/reaction-picker.mjs +2 -2
  76. package/dist-esm/ui/reaction-picker.mjs.map +1 -1
  77. package/dist-esm/ui/send-button.mjs.map +1 -1
  78. package/package.json +5 -5
  79. package/src/canvas/canvas-events.ts +39 -2
  80. package/src/canvas/canvas.css +76 -38
  81. package/src/canvas/comment-render.test.ts +8 -1
  82. package/src/canvas/comment-tool.test.ts +34 -44
  83. package/src/canvas/comment-tool.tsx +51 -55
  84. package/src/canvas/comments-filter-menu.tsx +19 -6
  85. package/src/canvas/comments-overflow-menu.tsx +12 -18
  86. package/src/canvas/comments-overlay.tsx +5 -2
  87. package/src/canvas/comments-sidebar.tsx +20 -5
  88. package/src/canvas/comments-visibility-toggle.tsx +1 -1
  89. package/src/canvas/options.ts +21 -2
  90. package/src/canvas/pending-composer.tsx +182 -17
  91. package/src/canvas/region-box.tsx +192 -42
  92. package/src/canvas/thread-pin.tsx +28 -6
  93. package/src/canvas/thread-view.test.ts +39 -0
  94. package/src/canvas/thread-view.tsx +185 -70
  95. package/src/ui/byline.tsx +5 -2
  96. package/src/ui/comment-card.tsx +7 -1
  97. package/src/ui/comment-extensions.ts +18 -5
  98. package/src/ui/comments-list.tsx +23 -17
  99. package/src/ui/comments.css +175 -201
  100. package/src/ui/icons.tsx +5 -5
  101. package/src/ui/reaction-picker.tsx +2 -2
  102. package/src/ui/send-button.tsx +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/canvas/pending-composer.tsx"],
4
- "sourcesContent": ["import { Avatar, isMentionPickerOpen } from '@tldraw/mentions'\nimport { useEffect, useRef, useState } from 'react'\nimport {\n\tcreateComment,\n\tcreateCommentThread,\n\tdefineMessages,\n\tEditor,\n\tEditorPortal,\n\tTLRichText,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentComposer } from '../ui/comment-composer'\nimport { EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'\nimport { CommentPin } from '../ui/comment-pin'\nimport {\n\tclearCommentDraft,\n\tgetCommentDraft,\n\tNEW_COMMENT_DRAFT,\n\tsaveCommentDraft,\n} from './comment-drafts'\nimport { commitCommentMutation } from './comment-mutations'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { PendingComment } from './comment-tool'\nimport { type CommentingContext } from './context'\nimport { useIsMobileCommenting, useMobilePlacement } from './mobile-placement'\nimport { useCanComment, useCommentingOptions } from './options'\nimport { pendingComment } from './state'\n\nconst messages = defineMessages({\n\tcommentsSend: { id: 'comments.send', defaultMessage: 'Send' },\n\tcommentsAddPlaceholder: { id: 'comments.add-placeholder', defaultMessage: 'Add a comment\u2026' },\n})\n\nconst stop = (e: { stopPropagation(): void }) => e.stopPropagation()\n\n/**\n * The composer for a thread that doesn't exist yet: the comment tool has placed a point (or\n * region) and is waiting on a first comment. Submitting creates the thread and its comment\n * together; clicking away keeps the draft for the next placement.\n */\nexport function PendingComposer({\n\teditor,\n\tpending,\n\tcurrentUserId,\n\tresolveAuthor,\n\tonPostComment,\n\tgetMentionSuggestions,\n\trenderMentionSuggestion,\n}: CommentingContext & { editor: Editor; pending: PendingComment }) {\n\tconst ComposerFallback = useCommentingOptions().components.ComposerFallback\n\tconst canComment = useCanComment(currentUserId)\n\tconst me = currentUserId ? resolveAuthor(currentUserId) : undefined\n\t// The leading pin previews the pin this draft becomes: a white pin holding the author's avatar.\n\tconst draftAvatar = (\n\t\t<CommentPin>\n\t\t\t<Avatar author={me ?? UNKNOWN_COMMENT_AUTHOR} />\n\t\t</CommentPin>\n\t)\n\t// Click-away keeps the draft (saved on every change) and the next placement composer\n\t// restores it \u2014 the flip side of dismissing without a discard warning.\n\tconst [text, setText] = useState<TLRichText>(\n\t\t() => getCommentDraft(NEW_COMMENT_DRAFT) ?? EMPTY_COMMENT\n\t)\n\tconst ref = useRef<HTMLDivElement>(null)\n\tconst msg = useTranslation()\n\t// Over this floating panel, a scroll reaches the canvas (except where it scrolls itself).\n\tusePassThroughWheelEvents(ref)\n\n\tconst point = useValue('composer point', () => editor.pageToViewport(pending.point), [\n\t\teditor,\n\t\tpending.point,\n\t])\n\t// On mobile the composer floats free of the pin so it can clear the software keyboard; desktop\n\t// keeps it pinned to the point.\n\tconst isMobile = useIsMobileCommenting()\n\tconst placed = useMobilePlacement(ref, point, isMobile)\n\n\t// Dismiss on a click anywhere outside the composer (capture-phase, ahead of stopPropagation).\n\tuseEffect(() => {\n\t\tconst onPointerDown = (e: PointerEvent) => {\n\t\t\tconst el = ref.current\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (!el || !target) return\n\t\t\t// A click in the composer, or in the mention picker it spawns (portaled elsewhere), is\n\t\t\t// not \"outside\" \u2014 keep the draft open so the pick can insert.\n\t\t\tif (el.contains(target) || target.closest('.tlui-cmt-mention-popup')) return\n\t\t\t// A press on the canvas is the comment tool's to handle: it ends the placement and returns\n\t\t\t// to select. Clearing here first would let that press re-place the composer instead.\n\t\t\tif (editor.getContainer().querySelector('.tl-canvas')?.contains(target)) return\n\t\t\tpendingComment.set(editor, null)\n\t\t}\n\t\tdocument.addEventListener('pointerdown', onPointerDown, true)\n\t\treturn () => document.removeEventListener('pointerdown', onPointerDown, true)\n\t}, [editor])\n\n\tconst submit = () => {\n\t\tif (isCommentEmpty(text) || !currentUserId) return\n\t\tconst comment = commitCommentMutation(editor, ({ put }) => {\n\t\t\tconst pageId = editor.getCurrentPageId()\n\t\t\tconst thread = createCommentThread({\n\t\t\t\tpageId,\n\t\t\t\tanchor: pending.anchor,\n\t\t\t\tcreatedBy: currentUserId,\n\t\t\t})\n\t\t\tconst comment = createComment({\n\t\t\t\tthreadId: thread.id,\n\t\t\t\tpageId,\n\t\t\t\tauthorId: currentUserId,\n\t\t\t\tbody: text,\n\t\t\t})\n\t\t\tput([thread, comment])\n\t\t\treturn comment\n\t\t})\n\t\tsetText(EMPTY_COMMENT)\n\t\tclearCommentDraft(NEW_COMMENT_DRAFT)\n\t\tpendingComment.set(editor, null)\n\t\t// Posting ends the placement interaction \u2014 hand the comment tool back to select. Only from\n\t\t// the settled idle state: Enter can land while a fresh press is mid-gesture (the composer\n\t\t// trails the pointer), and switching tools under a held pointer would strand the gesture.\n\t\tif (editor.isIn('comment.idle')) editor.setCurrentTool('select')\n\t\t// The host's callback is its own operation, not part of the post's history scope. It runs\n\t\t// last so a throwing host can't strand the composer holding a draft of a posted comment.\n\t\tonPostComment?.(comment)\n\t}\n\n\treturn (\n\t\t<EditorPortal>\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={[\n\t\t\t\t\t'tlui-cmt-canvas-composer',\n\t\t\t\t\tpending.anchor.type === 'region' && 'tlui-cmt-canvas-composer--region',\n\t\t\t\t\t!canComment && 'tlui-cmt-canvas-composer--fallback',\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(' ')}\n\t\t\t\tstyle={{ left: placed.left, top: placed.top }}\n\t\t\t\tonPointerDown={stop}\n\t\t\t\tonContextMenu={stop}\n\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\tif (e.key === 'Escape' && !isMentionPickerOpen()) pendingComment.set(editor, null)\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{canComment ? (\n\t\t\t\t\t<CommentComposer\n\t\t\t\t\t\tauthor={me ?? UNKNOWN_COMMENT_AUTHOR}\n\t\t\t\t\t\tplaceholder={msg(messages.commentsAddPlaceholder)}\n\t\t\t\t\t\tsendLabel={msg(messages.commentsSend)}\n\t\t\t\t\t\tvalue={text}\n\t\t\t\t\t\tonChange={(value) => {\n\t\t\t\t\t\t\tsetText(value)\n\t\t\t\t\t\t\tsaveCommentDraft(NEW_COMMENT_DRAFT, value)\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonSubmit={submit}\n\t\t\t\t\t\t// No user, no author for the record \u2014 dead send button.\n\t\t\t\t\t\tdisabled={isCommentEmpty(text) || !currentUserId}\n\t\t\t\t\t\tgetMentionSuggestions={getMentionSuggestions}\n\t\t\t\t\t\trenderMentionSuggestion={renderMentionSuggestion}\n\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\tleading={draftAvatar}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\tComposerFallback && <ComposerFallback context=\"pending\" />\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</EditorPortal>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyDG;AAzDH,sBAA4C;AAC5C,mBAA4C;AAC5C,oBAUO;AACP,8BAAgC;AAChC,gCAA8C;AAC9C,yBAA2B;AAC3B,4BAKO;AACP,+BAAsC;AACtC,4BAAuC;AAGvC,8BAA0D;AAC1D,qBAAoD;AACpD,mBAA+B;AAE/B,MAAM,eAAW,8BAAe;AAAA,EAC/B,cAAc,EAAE,IAAI,iBAAiB,gBAAgB,OAAO;AAAA,EAC5D,wBAAwB,EAAE,IAAI,4BAA4B,gBAAgB,sBAAiB;AAC5F,CAAC;AAED,MAAM,OAAO,CAAC,MAAmC,EAAE,gBAAgB;AAO5D,SAAS,gBAAgB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAoE;AACnE,QAAM,uBAAmB,qCAAqB,EAAE,WAAW;AAC3D,QAAM,iBAAa,8BAAc,aAAa;AAC9C,QAAM,KAAK,gBAAgB,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;AAAA,QACV,MAAM;AAAA,MACP,CAAC;AACD,UAAI,CAAC,QAAQA,QAAO,CAAC;AACrB,aAAOA;AAAA,IACR,CAAC;AACD,YAAQ,uCAAa;AACrB,iDAAkB,uCAAiB;AACnC,gCAAe,IAAI,QAAQ,IAAI;AAI/B,QAAI,OAAO,KAAK,cAAc,EAAG,QAAO,eAAe,QAAQ;AAG/D,oBAAgB,OAAO;AAAA,EACxB;AAEA,SACC,4CAAC,8BACA;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV;AAAA,QACA,QAAQ,OAAO,SAAS,YAAY;AAAA,QACpC,CAAC,cAAc;AAAA,MAChB,EACE,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MACV,OAAO,EAAE,MAAM,OAAO,MAAM,KAAK,OAAO,IAAI;AAAA,MAC5C,eAAe;AAAA,MACf,eAAe;AAAA,MACf,WAAW,CAAC,MAAM;AACjB,YAAI,EAAE,QAAQ,YAAY,KAAC,qCAAoB,EAAG,6BAAe,IAAI,QAAQ,IAAI;AAAA,MAClF;AAAA,MAEC,uBACA;AAAA,QAAC;AAAA;AAAA,UACA,QAAQ,MAAM;AAAA,UACd,aAAa,IAAI,SAAS,sBAAsB;AAAA,UAChD,WAAW,IAAI,SAAS,YAAY;AAAA,UACpC,OAAO;AAAA,UACP,UAAU,CAAC,UAAU;AACpB,oBAAQ,KAAK;AACb,wDAAiB,yCAAmB,KAAK;AAAA,UAC1C;AAAA,UACA,UAAU;AAAA,UAEV,cAAU,0CAAe,IAAI,KAAK,CAAC;AAAA,UACnC;AAAA,UACA;AAAA,UACA,WAAS;AAAA,UACT,SAAS;AAAA;AAAA,MACV,IAEA,oBAAoB,4CAAC,oBAAiB,SAAQ,WAAU;AAAA;AAAA,EAE1D,GACD;AAEF;",
4
+ "sourcesContent": ["import { Avatar, isMentionPickerOpen } from '@tldraw/mentions'\nimport {\n\ttype MouseEvent as ReactMouseEvent,\n\ttype PointerEvent as ReactPointerEvent,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport {\n\tcreateComment,\n\tcreateCommentThread,\n\tdefineMessages,\n\tEditor,\n\tEditorPortal,\n\tTLCommentAnchor,\n\tTLRichText,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n\tVecLike,\n} from 'tldraw'\nimport { CommentComposer } from '../ui/comment-composer'\nimport { EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'\nimport { CommentPin } from '../ui/comment-pin'\nimport { forwardPointerEventToCanvas, isCanvasPanGesture, startCommentDrag } from './canvas-events'\nimport {\n\tclearCommentDraft,\n\tgetCommentDraft,\n\tNEW_COMMENT_DRAFT,\n\tsaveCommentDraft,\n} from './comment-drafts'\nimport { commitCommentMutation } from './comment-mutations'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { PendingComment, pendingCommentAt } from './comment-tool'\nimport { type CommentingContext } from './context'\nimport { useIsMobileCommenting, useMobilePlacement } from './mobile-placement'\nimport { useCanComment, useCommentingOptions } from './options'\nimport { pendingComment } from './state'\nimport {\n\tcommentTargetShapeAt,\n\tregionAnchorPinCorner,\n\tregionPinPoint,\n\tregionWithPinAt,\n} from './thread-state'\nimport { avatarRenderer } from './thread-view'\n\nconst messages = defineMessages({\n\tcommentsSend: { id: 'comments.send', defaultMessage: 'Send' },\n\tcommentsAddPlaceholder: { id: 'comments.add-placeholder', defaultMessage: 'Add a comment\u2026' },\n})\n\nconst stop = (e: { stopPropagation(): void }) => e.stopPropagation()\n\n/**\n * The composer for a thread that doesn't exist yet: the comment tool has placed a point (or\n * region) and is waiting on a first comment. Submitting creates the thread and its comment\n * together; clicking away keeps the draft for the next placement.\n */\nexport function PendingComposer({\n\teditor,\n\tpending,\n\tcurrentUserId,\n\tresolveAuthor,\n\tonPostComment,\n\tgetMentionSuggestions,\n\trenderMentionSuggestion,\n}: CommentingContext & { editor: Editor; pending: PendingComment }) {\n\tconst { components } = useCommentingOptions()\n\tconst ComposerFallback = components.ComposerFallback\n\tconst canComment = useCanComment(currentUserId)\n\tconst me = currentUserId ? resolveAuthor(currentUserId) : undefined\n\tconst isMobile = useIsMobileCommenting()\n\tconst drag = useDraftDrag(editor, pending)\n\t// The leading pin previews the pin this draft becomes: a white pin holding the author's avatar.\n\tconst draftAvatar = (\n\t\t<div\n\t\t\tclassName=\"tlui-cmt-canvas-composer__handle\"\n\t\t\t// On mobile the composer floats free of its point, so there's no pin to drag.\n\t\t\t{...(isMobile ? {} : drag.handlers)}\n\t\t>\n\t\t\t<CommentPin>\n\t\t\t\t{avatarRenderer(components, currentUserId)?.(me ?? UNKNOWN_COMMENT_AUTHOR) ?? (\n\t\t\t\t\t<Avatar author={me ?? UNKNOWN_COMMENT_AUTHOR} />\n\t\t\t\t)}\n\t\t\t</CommentPin>\n\t\t</div>\n\t)\n\t// Click-away keeps the draft (saved on every change) and the next placement composer\n\t// restores it \u2014 the flip side of dismissing without a discard warning.\n\tconst [text, setText] = useState<TLRichText>(\n\t\t() => getCommentDraft(NEW_COMMENT_DRAFT) ?? EMPTY_COMMENT\n\t)\n\tconst ref = useRef<HTMLDivElement>(null)\n\tconst msg = useTranslation()\n\t// Over this floating panel, a scroll reaches the canvas (except where it scrolls itself).\n\tusePassThroughWheelEvents(ref)\n\n\tconst point = useValue('composer point', () => editor.pageToViewport(pending.point), [\n\t\teditor,\n\t\tpending.point,\n\t])\n\t// On mobile the composer floats free of the pin so it can clear the software keyboard; desktop\n\t// keeps it pinned to the point.\n\tconst placed = useMobilePlacement(ref, point, isMobile)\n\n\t// Handle Escape before it reaches the editor's container so closing the composer doesn't\n\t// also cancel the comment tool.\n\tuseEffect(() => {\n\t\tconst el = ref.current\n\t\tif (!el) return\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key !== 'Escape' || isMentionPickerOpen()) return\n\t\t\te.stopPropagation()\n\t\t\tsetText(EMPTY_COMMENT)\n\t\t\tclearCommentDraft(NEW_COMMENT_DRAFT)\n\t\t\tpendingComment.set(editor, null)\n\t\t\t// Focus would drop to the page with the composer gone, out of reach of the next Escape.\n\t\t\teditor.getContainer().focus()\n\t\t}\n\t\tel.addEventListener('keydown', onKeyDown)\n\t\treturn () => el.removeEventListener('keydown', onKeyDown)\n\t}, [editor])\n\n\t// Dismiss on a click anywhere outside the composer (capture-phase, ahead of stopPropagation).\n\tuseEffect(() => {\n\t\tconst onPointerDown = (e: PointerEvent) => {\n\t\t\tconst el = ref.current\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (!el || !target) return\n\t\t\t// A click in the composer, or in the mention picker it spawns (portaled elsewhere), is\n\t\t\t// not \"outside\" \u2014 keep the draft open so the pick can insert.\n\t\t\tif (el.contains(target) || target.closest('.tlui-cmt-mention-popup')) return\n\t\t\t// Panning the camera to look around while writing isn't leaving the draft.\n\t\t\tif (isCanvasPanGesture(editor, e) || (e as any).isSpecialRedispatchedEvent) return\n\t\t\tpendingComment.set(editor, null)\n\t\t}\n\t\tdocument.addEventListener('pointerdown', onPointerDown, true)\n\t\treturn () => document.removeEventListener('pointerdown', onPointerDown, true)\n\t}, [editor])\n\n\tconst submit = () => {\n\t\tif (isCommentEmpty(text) || !currentUserId) return\n\t\tconst comment = commitCommentMutation(editor, ({ put }) => {\n\t\t\tconst pageId = editor.getCurrentPageId()\n\t\t\tconst thread = createCommentThread({\n\t\t\t\tpageId,\n\t\t\t\tanchor: pending.anchor,\n\t\t\t\tcreatedBy: currentUserId,\n\t\t\t})\n\t\t\tconst comment = createComment({\n\t\t\t\tthreadId: thread.id,\n\t\t\t\tpageId,\n\t\t\t\tauthorId: currentUserId,\n\t\t\t\tbody: text,\n\t\t\t})\n\t\t\tput([thread, comment])\n\t\t\treturn comment\n\t\t})\n\t\tsetText(EMPTY_COMMENT)\n\t\tclearCommentDraft(NEW_COMMENT_DRAFT)\n\t\tpendingComment.set(editor, null)\n\t\t// Removing the focused composer would leave Escape outside the editor's keyboard listener.\n\t\teditor.getContainer().focus()\n\t\t// The host's callback is its own operation, not part of the post's history scope. It runs\n\t\t// last so a throwing host can't strand the composer holding a draft of a posted comment.\n\t\tonPostComment?.(comment)\n\t}\n\n\treturn (\n\t\t<EditorPortal>\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={[\n\t\t\t\t\t'tlui-cmt-canvas-composer',\n\t\t\t\t\tpending.anchor.type === 'region' && 'tlui-cmt-canvas-composer--region',\n\t\t\t\t\tdrag.dragging && 'tlui-cmt-canvas-composer--dragging',\n\t\t\t\t\t!canComment && 'tlui-cmt-canvas-composer--fallback',\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(' ')}\n\t\t\t\tstyle={{ left: placed.left, top: placed.top }}\n\t\t\t\tonPointerDown={stop}\n\t\t\t\tonContextMenu={stop}\n\t\t\t>\n\t\t\t\t{canComment ? (\n\t\t\t\t\t<CommentComposer\n\t\t\t\t\t\tauthor={me ?? UNKNOWN_COMMENT_AUTHOR}\n\t\t\t\t\t\tplaceholder={msg(messages.commentsAddPlaceholder)}\n\t\t\t\t\t\tsendLabel={msg(messages.commentsSend)}\n\t\t\t\t\t\tvalue={text}\n\t\t\t\t\t\tonChange={(value) => {\n\t\t\t\t\t\t\tsetText(value)\n\t\t\t\t\t\t\tsaveCommentDraft(NEW_COMMENT_DRAFT, value)\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonSubmit={submit}\n\t\t\t\t\t\t// No user, no author for the record \u2014 dead send button.\n\t\t\t\t\t\tdisabled={isCommentEmpty(text) || !currentUserId}\n\t\t\t\t\t\tgetMentionSuggestions={getMentionSuggestions}\n\t\t\t\t\t\trenderMentionSuggestion={renderMentionSuggestion}\n\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\tleading={draftAvatar}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\tComposerFallback && <ComposerFallback context=\"pending\" />\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</EditorPortal>\n\t)\n}\n\n/** Drag the draft by its avatar pin, the way a placed pin drags: the composer follows the pointer\n * and, on release, re-anchors to the shape under it (a region translates, keeping its size). */\nfunction useDraftDrag(editor: Editor, pending: PendingComment) {\n\tconst [dragging, setDragging] = useState(false)\n\tconst dragRef = useRef<{\n\t\tstartX: number\n\t\tstartY: number\n\t\tmoved: boolean\n\t\t// The pin's page offset from the grab point, so the pin keeps its place under the pointer.\n\t\toffsetX: number\n\t\toffsetY: number\n\t\tclientX: number\n\t\tclientY: number\n\t\tendDrag?(): void\n\t} | null>(null)\n\t// Unmounting mid-drag (the draft is dismissed) gets no pointer up to end the drag, and the\n\t// drop-target hint is editor-global state that would otherwise stay on the shape.\n\tuseEffect(\n\t\t() => () => {\n\t\t\tif (!dragRef.current) return\n\t\t\tdragRef.current.endDrag?.()\n\t\t\teditor.setHintingShapes([])\n\t\t},\n\t\t[editor]\n\t)\n\n\tconst pagePointFor = (clientX: number, clientY: number) => {\n\t\tconst drag = dragRef.current!\n\t\tconst cursor = editor.screenToPage({ x: clientX, y: clientY })\n\t\treturn { x: cursor.x + drag.offsetX, y: cursor.y + drag.offsetY }\n\t}\n\n\t// A region moves as a whole, its box riding with the pin corner; a point draft moves only its\n\t// composer until the drop, when its anchor resolves against what's under it.\n\tconst moveRegion = (anchor: Extract<TLCommentAnchor, { type: 'region' }>, point: VecLike) => {\n\t\tconst corner = regionAnchorPinCorner(anchor)\n\t\tconst moved = regionWithPinAt(anchor, corner, point)\n\t\tpendingComment.set(editor, { anchor: moved, point: regionPinPoint(moved, corner) })\n\t}\n\n\t// Mid-drag, a point draft hints the shape a drop here would anchor to.\n\tconst previewAt = (point: VecLike) => {\n\t\tconst current = pendingComment.get(editor)\n\t\tif (!current) return\n\t\tif (current.anchor.type === 'region') return moveRegion(current.anchor, point)\n\t\tpendingComment.set(editor, { ...current, point: { x: point.x, y: point.y } })\n\t\tconst hit = commentTargetShapeAt(editor, point)\n\t\teditor.setHintingShapes(hit ? [hit.id] : [])\n\t}\n\n\tconst settleAt = (point: VecLike, altKey: boolean) => {\n\t\tconst current = pendingComment.get(editor)\n\t\tif (!current) return\n\t\tif (current.anchor.type === 'region') return moveRegion(current.anchor, point)\n\t\tpendingComment.set(editor, pendingCommentAt(editor, point, altKey))\n\t}\n\n\tconst takeDrag = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current\n\t\tdragRef.current = null\n\t\tdrag?.endDrag?.()\n\t\teditor.setHintingShapes([])\n\t\tsetDragging(false)\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId)) {\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\t}\n\t\treturn drag\n\t}\n\n\tconst handlers = {\n\t\tonPointerDown: (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\t\t// A middle/right-button or space-held press is a camera pan, not a drag.\n\t\t\tif (isCanvasPanGesture(editor, e)) {\n\t\t\t\tforwardPointerEventToCanvas(editor.getContainer(), e)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst grab = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\t\tdragRef.current = {\n\t\t\t\tstartX: e.clientX,\n\t\t\t\tstartY: e.clientY,\n\t\t\t\tclientX: e.clientX,\n\t\t\t\tclientY: e.clientY,\n\t\t\t\tmoved: false,\n\t\t\t\toffsetX: pending.point.x - grab.x,\n\t\t\t\toffsetY: pending.point.y - grab.y,\n\t\t\t}\n\t\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t\t},\n\t\t// Keep focus in the comment field: grabbing the pin shouldn't blur what's being typed.\n\t\tonMouseDown: (e: ReactMouseEvent) => e.preventDefault(),\n\t\tonPointerMove: (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\t\tconst drag = dragRef.current\n\t\t\tif (!drag) return\n\t\t\tif (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return\n\t\t\tdrag.clientX = e.clientX\n\t\t\tdrag.clientY = e.clientY\n\t\t\tif (!drag.moved) {\n\t\t\t\tdrag.moved = true\n\t\t\t\tdrag.endDrag = startCommentDrag(editor, {\n\t\t\t\t\tcursor: 'move',\n\t\t\t\t\tonCameraMove: () => {\n\t\t\t\t\t\tconst d = dragRef.current\n\t\t\t\t\t\tif (d) previewAt(pagePointFor(d.clientX, d.clientY))\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tsetDragging(true)\n\t\t\t}\n\t\t\tpreviewAt(pagePointFor(e.clientX, e.clientY))\n\t\t},\n\t\tonPointerUp: (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\t\tconst moved = dragRef.current?.moved\n\t\t\tconst point = moved ? pagePointFor(e.clientX, e.clientY) : null\n\t\t\ttakeDrag(e)\n\t\t\tif (point) settleAt(point, e.altKey)\n\t\t},\n\t\t// A cancelled pointer leaves the draft where the drag last put it, with its anchor resolved.\n\t\tonPointerCancel: (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\t\tconst drag = takeDrag(e)\n\t\t\tconst current = pendingComment.get(editor)\n\t\t\tif (drag?.moved && current) settleAt(current.point, editor.inputs.getAltKey())\n\t\t},\n\t}\n\n\treturn { dragging, handlers }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkFK;AAlFL,sBAA4C;AAC5C,mBAMO;AACP,oBAYO;AACP,8BAAgC;AAChC,gCAA8C;AAC9C,yBAA2B;AAC3B,2BAAkF;AAClF,4BAKO;AACP,+BAAsC;AACtC,4BAAuC;AACvC,0BAAiD;AAEjD,8BAA0D;AAC1D,qBAAoD;AACpD,mBAA+B;AAC/B,0BAKO;AACP,yBAA+B;AAE/B,MAAM,eAAW,8BAAe;AAAA,EAC/B,cAAc,EAAE,IAAI,iBAAiB,gBAAgB,OAAO;AAAA,EAC5D,wBAAwB,EAAE,IAAI,4BAA4B,gBAAgB,sBAAiB;AAC5F,CAAC;AAED,MAAM,OAAO,CAAC,MAAmC,EAAE,gBAAgB;AAO5D,SAAS,gBAAgB;AAAA,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O,EAAE,UAAU,SAAS;AAC7B;",
6
6
  "names": ["comment"]
7
7
  }
@@ -22,12 +22,14 @@ __export(region_box_exports, {
22
22
  REGION_HANDLE_MARGIN_PX: () => REGION_HANDLE_MARGIN_PX,
23
23
  RegionBox: () => RegionBox,
24
24
  RegionDraftBox: () => RegionDraftBox,
25
- RegionResizeHandles: () => RegionResizeHandles
25
+ RegionResizeHandles: () => RegionResizeHandles,
26
+ selectionCornerSizing: () => selectionCornerSizing
26
27
  });
27
28
  module.exports = __toCommonJS(region_box_exports);
28
29
  var import_jsx_runtime = require("react/jsx-runtime");
29
30
  var import_react = require("react");
30
31
  var import_tldraw = require("tldraw");
32
+ var import_canvas_events = require("./canvas-events");
31
33
  var import_state = require("./state");
32
34
  function RegionBox({ editor, box }) {
33
35
  const rect = (0, import_tldraw.useValue)(
@@ -39,7 +41,32 @@ function RegionBox({ editor, box }) {
39
41
  },
40
42
  [editor, box.x, box.y, box.w, box.h]
41
43
  );
42
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-cmt-canvas-region", style: rect });
44
+ const { width: w, height: h } = rect;
45
+ const sides = [
46
+ [0, 0, w, 0],
47
+ [w, 0, w, h],
48
+ [w, h, 0, h],
49
+ [0, h, 0, 0]
50
+ ];
51
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-cmt-canvas-region", style: rect, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "tlui-cmt-canvas-region__outline", width: w, height: h, "aria-hidden": "true", children: sides.map(([x1, y1, x2, y2], i) => {
52
+ const { strokeDasharray, strokeDashoffset } = (0, import_tldraw.getPerfectDashProps)(
53
+ Math.hypot(x2 - x1, y2 - y1),
54
+ 1,
55
+ { style: "dashed", lengthRatio: 4 }
56
+ );
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
+ "line",
59
+ {
60
+ x1,
61
+ y1,
62
+ x2,
63
+ y2,
64
+ strokeDasharray,
65
+ strokeDashoffset
66
+ },
67
+ i
68
+ );
69
+ }) }) });
43
70
  }
44
71
  function RegionDraftBox({ editor }) {
45
72
  const box = (0, import_tldraw.useValue)("region draft", () => import_state.regionDraft.get(editor), [editor]);
@@ -54,17 +81,37 @@ const REGION_CORNERS = [
54
81
  ];
55
82
  const REGION_HANDLE_MARGIN_PX = 12;
56
83
  function resizeRegion(box, handle, cursor) {
57
- const controlsX = handle.x !== 0.5;
58
- const controlsY = handle.y !== 0.5;
59
84
  const fixedX = box.x + (1 - handle.x) * box.w;
60
85
  const fixedY = box.y + (1 - handle.y) * box.h;
61
86
  return {
62
- x: controlsX ? Math.min(fixedX, cursor.x) : box.x,
63
- y: controlsY ? Math.min(fixedY, cursor.y) : box.y,
64
- w: controlsX ? Math.abs(cursor.x - fixedX) : box.w,
65
- h: controlsY ? Math.abs(cursor.y - fixedY) : box.h
87
+ x: Math.min(fixedX, cursor.x),
88
+ y: Math.min(fixedY, cursor.y),
89
+ w: Math.abs(cursor.x - fixedX),
90
+ h: Math.abs(cursor.y - fixedY)
66
91
  };
67
92
  }
93
+ function selectionCornerSizing(w, h, isCoarsePointer) {
94
+ const handleSize = 8;
95
+ const mobileHandleMultiplier = isCoarsePointer ? 1.75 : 1;
96
+ const hitTargetSize = 6 * mobileHandleMultiplier;
97
+ const isSmallX = w < handleSize * 4;
98
+ const isSmallY = h < handleSize * 4;
99
+ const hitTargetSizeX = (isSmallX ? hitTargetSize / 2 : hitTargetSize) * (mobileHandleMultiplier * 0.75);
100
+ const hitTargetSizeY = (isSmallY ? hitTargetSize / 2 : hitTargetSize) * (mobileHandleMultiplier * 0.75);
101
+ const isTinyX = w < handleSize * 2;
102
+ const isTinyY = h < handleSize * 2;
103
+ return {
104
+ // The corner hit square's full side: the util's `cornerHitHalfSize`, doubled.
105
+ hitSize: Math.max(hitTargetSizeX, hitTargetSizeY) * 1.5 * 2,
106
+ hideAlternateCorners: isTinyX || isTinyY,
107
+ showOnlyOneCorner: isTinyX && isTinyY
108
+ };
109
+ }
110
+ function isHiddenCorner(h, sizing) {
111
+ if (h.x === 0 && h.y === 0) return false;
112
+ if (h.x === 1 && h.y === 1) return sizing.showOnlyOneCorner;
113
+ return sizing.hideAlternateCorners;
114
+ }
68
115
  function RegionResizeHandles({
69
116
  editor,
70
117
  box,
@@ -72,42 +119,110 @@ function RegionResizeHandles({
72
119
  onPreview,
73
120
  onCommit
74
121
  }) {
75
- const boxRef = (0, import_react.useRef)(null);
76
- const points = (0, import_tldraw.useValue)(
77
- "region handle points",
78
- () => handles.map((h) => {
79
- const p = editor.pageToViewport({ x: box.x + h.x * box.w, y: box.y + h.y * box.h });
80
- return { ...h, key: `${h.x}-${h.y}`, left: p.x, top: p.y };
81
- }),
122
+ const dragRef = (0, import_react.useRef)(null);
123
+ const wheelRef = (0, import_react.useRef)(null);
124
+ (0, import_tldraw.usePassThroughWheelEvents)(wheelRef);
125
+ (0, import_react.useEffect)(() => () => dragRef.current?.endDrag(), []);
126
+ const layout = (0, import_tldraw.useValue)(
127
+ "region handle layout",
128
+ () => {
129
+ const zoom = editor.getZoomLevel();
130
+ const sizing = selectionCornerSizing(
131
+ box.w * zoom,
132
+ box.h * zoom,
133
+ editor.getInstanceState().isCoarsePointer
134
+ );
135
+ const dragged = dragRef.current?.handle;
136
+ const points2 = handles.filter((h) => h.x === dragged?.x && h.y === dragged?.y || !isHiddenCorner(h, sizing)).map((h) => {
137
+ const p = editor.pageToViewport({ x: box.x + h.x * box.w, y: box.y + h.y * box.h });
138
+ return { ...h, key: `${h.x}-${h.y}`, left: p.x, top: p.y };
139
+ });
140
+ const { cursor: cursorColor } = editor.getCurrentTheme().colors[editor.getColorMode()];
141
+ const cursors2 = {
142
+ "nwse-resize": (0, import_tldraw.getCursor)("nwse-resize", 0, cursorColor),
143
+ "nesw-resize": (0, import_tldraw.getCursor)("nesw-resize", 0, cursorColor)
144
+ };
145
+ return { points: points2, hitSize: sizing.hitSize, cursors: cursors2 };
146
+ },
82
147
  [editor, box.x, box.y, box.w, box.h, handles]
83
148
  );
84
- const startResize = (e) => {
149
+ const { points, hitSize, cursors } = layout;
150
+ const resized = () => {
151
+ const drag = dragRef.current;
152
+ return resizeRegion(
153
+ drag.box,
154
+ drag.handle,
155
+ editor.screenToPage({ x: drag.clientX, y: drag.clientY })
156
+ );
157
+ };
158
+ const startResize = (h) => (e) => {
159
+ if ((0, import_canvas_events.isCanvasPanGesture)(editor, e)) {
160
+ (0, import_canvas_events.forwardPointerEventToCanvas)(editor.getContainer(), e);
161
+ return;
162
+ }
85
163
  e.stopPropagation();
86
- boxRef.current = box;
164
+ dragRef.current?.endDrag();
165
+ dragRef.current = {
166
+ box,
167
+ handle: h,
168
+ clientX: e.clientX,
169
+ clientY: e.clientY,
170
+ endDrag: (0, import_canvas_events.startCommentDrag)(editor, {
171
+ cursor: h.cursor,
172
+ onCameraMove: () => {
173
+ if (dragRef.current) onPreview(resized());
174
+ }
175
+ })
176
+ };
87
177
  e.currentTarget.setPointerCapture(e.pointerId);
88
178
  };
89
- const resizedTo = (h, e) => resizeRegion(boxRef.current, h, editor.screenToPage({ x: e.clientX, y: e.clientY }));
90
- const onResize = (h) => (e) => {
91
- if (boxRef.current) onPreview(resizedTo(h, e));
179
+ const onResize = (e) => {
180
+ const drag = dragRef.current;
181
+ if (!drag) return;
182
+ drag.clientX = e.clientX;
183
+ drag.clientY = e.clientY;
184
+ onPreview(resized());
92
185
  };
93
- const endResize = (h) => (e) => {
94
- if (!boxRef.current) return;
95
- const bounds = resizedTo(h, e);
96
- boxRef.current = null;
186
+ const endResize = (e) => {
187
+ const drag = dragRef.current;
188
+ if (!drag) return;
189
+ drag.clientX = e.clientX;
190
+ drag.clientY = e.clientY;
191
+ const bounds = resized();
192
+ dragRef.current = null;
193
+ drag.endDrag();
97
194
  if (e.currentTarget.hasPointerCapture(e.pointerId))
98
195
  e.currentTarget.releasePointerCapture(e.pointerId);
99
196
  onCommit(bounds);
100
197
  };
101
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: points.map((h) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
- "div",
103
- {
104
- className: "tlui-cmt-canvas-region-handle",
105
- style: { left: h.left, top: h.top, cursor: h.cursor },
106
- onPointerDown: startResize,
107
- onPointerMove: onResize(h),
108
- onPointerUp: endResize(h)
109
- },
110
- h.key
111
- )) });
198
+ const cancelResize = () => {
199
+ const drag = dragRef.current;
200
+ if (!drag) return;
201
+ dragRef.current = null;
202
+ drag.endDrag();
203
+ onPreview(null);
204
+ };
205
+ return (
206
+ // A wheel over a handle (even mid-resize) scrolls the canvas, like everywhere else on it.
207
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: wheelRef, className: "tlui-cmt-canvas-region-handles", children: points.map((h) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
208
+ "div",
209
+ {
210
+ className: "tlui-cmt-canvas-region-handle",
211
+ style: {
212
+ left: h.left,
213
+ top: h.top,
214
+ width: hitSize,
215
+ height: hitSize,
216
+ cursor: cursors[h.cursor]
217
+ },
218
+ onPointerDown: startResize(h),
219
+ onPointerMove: onResize,
220
+ onPointerUp: endResize,
221
+ onPointerCancel: cancelResize,
222
+ onLostPointerCapture: cancelResize
223
+ },
224
+ h.key
225
+ )) })
226
+ );
112
227
  }
113
228
  //# sourceMappingURL=region-box.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/canvas/region-box.tsx"],
4
- "sourcesContent": ["import { type PointerEvent as ReactPointerEvent, useRef } from 'react'\nimport { type BoxModel, Editor, useValue, VecLike } from 'tldraw'\nimport { regionDraft } from './state'\n\n/** A region's dashed box. Purely visual \u2014 a region moves by its pin and resizes from its corner\n * handles, so the box itself takes no pointer events. Positioned in viewport space, as a sibling\n * of the pins in the canvas layer. */\nexport function RegionBox({ editor, box }: { editor: Editor; box: BoxModel }) {\n\tconst rect = useValue(\n\t\t'region rect',\n\t\t() => {\n\t\t\t// Position from the page\u2192viewport top-left; screen size scales with zoom, page size doesn't.\n\t\t\tconst topLeft = editor.pageToViewport({ x: box.x, y: box.y })\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\treturn { left: topLeft.x, top: topLeft.y, width: box.w * zoom, height: box.h * zoom }\n\t\t},\n\t\t[editor, box.x, box.y, box.w, box.h]\n\t)\n\treturn <div className=\"tlui-cmt-canvas-region\" style={rect} />\n}\n\n/** The live region being dragged out by the comment tool, or nothing when not dragging. */\nexport function RegionDraftBox({ editor }: { editor: Editor }) {\n\tconst box = useValue('region draft', () => regionDraft.get(editor), [editor])\n\tif (!box) return null\n\treturn <RegionBox editor={editor} box={box} />\n}\n\n// A resize handle's normalized 0\u20131 spot on the box, and its cursor. An axis at 0.5 is *not*\n// controlled by that handle \u2014 the resize math reads the spot rather than special-casing corners.\nexport interface RegionHandle {\n\tx: number\n\ty: number\n\tcursor: string\n}\n\n// The four corners, each resizing both axes.\nexport const REGION_CORNERS: readonly RegionHandle[] = [\n\t{ x: 0, y: 0, cursor: 'nwse-resize' },\n\t{ x: 1, y: 0, cursor: 'nesw-resize' },\n\t{ x: 0, y: 1, cursor: 'nesw-resize' },\n\t{ x: 1, y: 1, cursor: 'nwse-resize' },\n]\n\n// Screen-space slack around a region's bounds within which its box and handles stay revealed, so\n// the handles (which sit on the edge) are comfortably reachable.\nexport const REGION_HANDLE_MARGIN_PX = 12\n\n/** Resize `box` by dragging `handle` to `cursor` (page coords). Each controlled axis spans from the\n * handle's fixed opposite edge to the cursor (normalized, so dragging past it flips); an axis the\n * handle doesn't control (a midpoint, at 0.5) keeps its original position and size. */\nfunction resizeRegion(box: BoxModel, handle: RegionHandle, cursor: VecLike): BoxModel {\n\tconst controlsX = handle.x !== 0.5\n\tconst controlsY = handle.y !== 0.5\n\tconst fixedX = box.x + (1 - handle.x) * box.w\n\tconst fixedY = box.y + (1 - handle.y) * box.h\n\treturn {\n\t\tx: controlsX ? Math.min(fixedX, cursor.x) : box.x,\n\t\ty: controlsY ? Math.min(fixedY, cursor.y) : box.y,\n\t\tw: controlsX ? Math.abs(cursor.x - fixedX) : box.w,\n\t\th: controlsY ? Math.abs(cursor.y - fixedY) : box.h,\n\t}\n}\n\n/** Draggable handles that resize a region \u2014 corners (both axes) or edges (one axis), per the resize\n * option. Previews live, commits on release. */\nexport function RegionResizeHandles({\n\teditor,\n\tbox,\n\thandles,\n\tonPreview,\n\tonCommit,\n}: {\n\teditor: Editor\n\tbox: BoxModel\n\thandles: readonly RegionHandle[]\n\tonPreview(bounds: BoxModel | null): void\n\tonCommit(bounds: BoxModel): void\n}) {\n\t// The box at pointer-down, captured so the box prop reflowing under the live preview doesn't move\n\t// the fixed edges mid-drag.\n\tconst boxRef = useRef<BoxModel | null>(null)\n\tconst points = useValue(\n\t\t'region handle points',\n\t\t() =>\n\t\t\thandles.map((h) => {\n\t\t\t\tconst p = editor.pageToViewport({ x: box.x + h.x * box.w, y: box.y + h.y * box.h })\n\t\t\t\treturn { ...h, key: `${h.x}-${h.y}`, left: p.x, top: p.y }\n\t\t\t}),\n\t\t[editor, box.x, box.y, box.w, box.h, handles]\n\t)\n\tconst startResize = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\te.stopPropagation()\n\t\tboxRef.current = box\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst resizedTo = (h: RegionHandle, e: ReactPointerEvent<HTMLDivElement>): BoxModel =>\n\t\tresizeRegion(boxRef.current!, h, editor.screenToPage({ x: e.clientX, y: e.clientY }))\n\tconst onResize = (h: RegionHandle) => (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tif (boxRef.current) onPreview(resizedTo(h, e))\n\t}\n\tconst endResize = (h: RegionHandle) => (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tif (!boxRef.current) return\n\t\tconst bounds = resizedTo(h, e)\n\t\tboxRef.current = null\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId))\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\tonCommit(bounds)\n\t}\n\treturn (\n\t\t<>\n\t\t\t{points.map((h) => (\n\t\t\t\t<div\n\t\t\t\t\tkey={h.key}\n\t\t\t\t\tclassName=\"tlui-cmt-canvas-region-handle\"\n\t\t\t\t\tstyle={{ left: h.left, top: h.top, cursor: h.cursor }}\n\t\t\t\t\tonPointerDown={startResize}\n\t\t\t\t\tonPointerMove={onResize(h)}\n\t\t\t\t\tonPointerUp={endResize(h)}\n\t\t\t\t/>\n\t\t\t))}\n\t\t</>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBQ;AAlBR,mBAA+D;AAC/D,oBAAyD;AACzD,mBAA4B;AAKrB,SAAS,UAAU,EAAE,QAAQ,IAAI,GAAsC;AAC7E,QAAM,WAAO;AAAA,IACZ;AAAA,IACA,MAAM;AAEL,YAAM,UAAU,OAAO,eAAe,EAAE,GAAG,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;AAC5D,YAAM,OAAO,OAAO,aAAa;AACjC,aAAO,EAAE,MAAM,QAAQ,GAAG,KAAK,QAAQ,GAAG,OAAO,IAAI,IAAI,MAAM,QAAQ,IAAI,IAAI,KAAK;AAAA,IACrF;AAAA,IACA,CAAC,QAAQ,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAAA,EACpC;AACA,SAAO,4CAAC,SAAI,WAAU,0BAAyB,OAAO,MAAM;AAC7D;AAGO,SAAS,eAAe,EAAE,OAAO,GAAuB;AAC9D,QAAM,UAAM,wBAAS,gBAAgB,MAAM,yBAAY,IAAI,MAAM,GAAG,CAAC,MAAM,CAAC;AAC5E,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,4CAAC,aAAU,QAAgB,KAAU;AAC7C;AAWO,MAAM,iBAA0C;AAAA,EACtD,EAAE,GAAG,GAAG,GAAG,GAAG,QAAQ,cAAc;AAAA,EACpC,EAAE,GAAG,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c,CAAC,MAAyC;AAC7D,MAAE,gBAAgB;AAClB,WAAO,UAAU;AACjB,MAAE,cAAc,kBAAkB,EAAE,SAAS;AAAA,EAC9C;AACA,QAAM,YAAY,CAAC,GAAiB,MACnC,aAAa,OAAO,SAAU,GAAG,OAAO,aAAa,EAAE,GAAG,EAAE,SAAS,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrF,QAAM,WAAW,CAAC,MAAoB,CAAC,MAAyC;AAC/E,QAAI,OAAO,QAAS,WAAU,UAAU,GAAG,CAAC,CAAC;AAAA,EAC9C;AACA,QAAM,YAAY,CAAC,MAAoB,CAAC,MAAyC;AAChF,QAAI,CAAC,OAAO,QAAS;AACrB,UAAM,SAAS,UAAU,GAAG,CAAC;AAC7B,WAAO,UAAU;AACjB,QAAI,EAAE,cAAc,kBAAkB,EAAE,SAAS;AAChD,QAAE,cAAc,sBAAsB,EAAE,SAAS;AAClD,aAAS,MAAM;AAAA,EAChB;AACA,SACC,2EACE,iBAAO,IAAI,CAAC,MACZ;AAAA,IAAC;AAAA;AAAA,MAEA,WAAU;AAAA,MACV,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,EAAE,KAAK,QAAQ,EAAE,OAAO;AAAA,MACpD,eAAe;AAAA,MACf,eAAe,SAAS,CAAC;AAAA,MACzB,aAAa,UAAU,CAAC;AAAA;AAAA,IALnB,EAAE;AAAA,EAMR,CACA,GACF;AAEF;",
6
- "names": []
4
+ "sourcesContent": ["import { type PointerEvent as ReactPointerEvent, useEffect, useRef } from 'react'\nimport {\n\ttype BoxModel,\n\tEditor,\n\tgetCursor,\n\tgetPerfectDashProps,\n\tusePassThroughWheelEvents,\n\tuseValue,\n\tVecLike,\n} from 'tldraw'\nimport { forwardPointerEventToCanvas, isCanvasPanGesture, startCommentDrag } from './canvas-events'\nimport { regionDraft } from './state'\n\n/** A region's dashed box. Purely visual \u2014 a region moves by its pin and resizes from its corner\n * handles, so the box itself takes no pointer events. Positioned in viewport space, as a sibling\n * of the pins in the canvas layer. */\nexport function RegionBox({ editor, box }: { editor: Editor; box: BoxModel }) {\n\tconst rect = useValue(\n\t\t'region rect',\n\t\t() => {\n\t\t\t// Position from the page\u2192viewport top-left; screen size scales with zoom, page size doesn't.\n\t\t\tconst topLeft = editor.pageToViewport({ x: box.x, y: box.y })\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\treturn { left: topLeft.x, top: topLeft.y, width: box.w * zoom, height: box.h * zoom }\n\t\t},\n\t\t[editor, box.x, box.y, box.w, box.h]\n\t)\n\tconst { width: w, height: h } = rect\n\t// The group outline's dashes: drawn per side with perfect dashes (so every side starts and ends\n\t// on a dash), at the 1px dash scale and 1.5px stroke the editor's selection outline uses.\n\tconst sides = [\n\t\t[0, 0, w, 0],\n\t\t[w, 0, w, h],\n\t\t[w, h, 0, h],\n\t\t[0, h, 0, 0],\n\t]\n\treturn (\n\t\t<div className=\"tlui-cmt-canvas-region\" style={rect}>\n\t\t\t<svg className=\"tlui-cmt-canvas-region__outline\" width={w} height={h} aria-hidden=\"true\">\n\t\t\t\t{sides.map(([x1, y1, x2, y2], i) => {\n\t\t\t\t\tconst { strokeDasharray, strokeDashoffset } = getPerfectDashProps(\n\t\t\t\t\t\tMath.hypot(x2 - x1, y2 - y1),\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t{ style: 'dashed', lengthRatio: 4 }\n\t\t\t\t\t)\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<line\n\t\t\t\t\t\t\tkey={i}\n\t\t\t\t\t\t\tx1={x1}\n\t\t\t\t\t\t\ty1={y1}\n\t\t\t\t\t\t\tx2={x2}\n\t\t\t\t\t\t\ty2={y2}\n\t\t\t\t\t\t\tstrokeDasharray={strokeDasharray}\n\t\t\t\t\t\t\tstrokeDashoffset={strokeDashoffset}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</svg>\n\t\t</div>\n\t)\n}\n\n/** The live region being dragged out by the comment tool, or nothing when not dragging. */\nexport function RegionDraftBox({ editor }: { editor: Editor }) {\n\tconst box = useValue('region draft', () => regionDraft.get(editor), [editor])\n\tif (!box) return null\n\treturn <RegionBox editor={editor} box={box} />\n}\n\n// A corner resize handle: its normalized 0\u20131 spot on the box, and its cursor.\nexport interface RegionHandle {\n\tx: number\n\ty: number\n\tcursor: 'nwse-resize' | 'nesw-resize'\n}\n\nexport const REGION_CORNERS: readonly RegionHandle[] = [\n\t{ x: 0, y: 0, cursor: 'nwse-resize' },\n\t{ x: 1, y: 0, cursor: 'nesw-resize' },\n\t{ x: 0, y: 1, cursor: 'nesw-resize' },\n\t{ x: 1, y: 1, cursor: 'nwse-resize' },\n]\n\n// Screen-space slack around a region's bounds within which its box and handles stay revealed, so\n// the handles (which sit on the edge) are comfortably reachable.\nexport const REGION_HANDLE_MARGIN_PX = 12\n\n/** Resize `box` by dragging corner `handle` to `cursor` (page coords): the box spans from the\n * opposite corner to the cursor, normalized so dragging past that corner flips it. */\nfunction resizeRegion(box: BoxModel, handle: RegionHandle, cursor: VecLike): BoxModel {\n\tconst fixedX = box.x + (1 - handle.x) * box.w\n\tconst fixedY = box.y + (1 - handle.y) * box.h\n\treturn {\n\t\tx: Math.min(fixedX, cursor.x),\n\t\ty: Math.min(fixedY, cursor.y),\n\t\tw: Math.abs(cursor.x - fixedX),\n\t\th: Math.abs(cursor.y - fixedY),\n\t}\n}\n\n/**\n * The selection's corner-handle sizing (`SelectionForegroundOverlayUtil`), in screen px for a box\n * `w`\u00D7`h` px on screen, so a region's corners look and hit exactly like a shape's resize corners.\n * Keep in step with that util: the constants are its, not tuned here.\n */\nexport function selectionCornerSizing(w: number, h: number, isCoarsePointer: boolean) {\n\tconst handleSize = 8\n\tconst mobileHandleMultiplier = isCoarsePointer ? 1.75 : 1\n\tconst hitTargetSize = 6 * mobileHandleMultiplier\n\tconst isSmallX = w < handleSize * 4\n\tconst isSmallY = h < handleSize * 4\n\tconst hitTargetSizeX =\n\t\t(isSmallX ? hitTargetSize / 2 : hitTargetSize) * (mobileHandleMultiplier * 0.75)\n\tconst hitTargetSizeY =\n\t\t(isSmallY ? hitTargetSize / 2 : hitTargetSize) * (mobileHandleMultiplier * 0.75)\n\tconst isTinyX = w < handleSize * 2\n\tconst isTinyY = h < handleSize * 2\n\treturn {\n\t\t// The corner hit square's full side: the util's `cornerHitHalfSize`, doubled.\n\t\thitSize: Math.max(hitTargetSizeX, hitTargetSizeY) * 1.5 * 2,\n\t\thideAlternateCorners: isTinyX || isTinyY,\n\t\tshowOnlyOneCorner: isTinyX && isTinyY,\n\t}\n}\n\n// The selection hides the top-right and bottom-left corners on a tiny box, and the bottom-right too\n// when it's tiny both ways (top-left always shows).\nfunction isHiddenCorner(\n\th: RegionHandle,\n\tsizing: ReturnType<typeof selectionCornerSizing>\n): boolean {\n\tif (h.x === 0 && h.y === 0) return false\n\tif (h.x === 1 && h.y === 1) return sizing.showOnlyOneCorner\n\treturn sizing.hideAlternateCorners\n}\n\n/** Draggable corner handles that resize a region. Previews live, commits on release. */\nexport function RegionResizeHandles({\n\teditor,\n\tbox,\n\thandles,\n\tonPreview,\n\tonCommit,\n}: {\n\teditor: Editor\n\tbox: BoxModel\n\thandles: readonly RegionHandle[]\n\tonPreview(bounds: BoxModel | null): void\n\tonCommit(bounds: BoxModel): void\n}) {\n\t// The box at pointer-down, captured so the box prop reflowing under the live preview doesn't move\n\t// the fixed edges mid-drag.\n\tconst dragRef = useRef<{\n\t\tbox: BoxModel\n\t\thandle: RegionHandle\n\t\tclientX: number\n\t\tclientY: number\n\t\tendDrag(): void\n\t} | null>(null)\n\tconst wheelRef = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(wheelRef)\n\t// Unmounting mid-resize gets no pointer up to end the drag.\n\tuseEffect(() => () => dragRef.current?.endDrag(), [])\n\tconst layout = useValue(\n\t\t'region handle layout',\n\t\t() => {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tconst sizing = selectionCornerSizing(\n\t\t\t\tbox.w * zoom,\n\t\t\t\tbox.h * zoom,\n\t\t\t\teditor.getInstanceState().isCoarsePointer\n\t\t\t)\n\t\t\tconst dragged = dragRef.current?.handle\n\t\t\tconst points = handles\n\t\t\t\t// The corner being dragged stays, even as the box shrinks to a size that hides it:\n\t\t\t\t// unmounting it would drop its pointer capture and strand the resize.\n\t\t\t\t.filter((h) => (h.x === dragged?.x && h.y === dragged?.y) || !isHiddenCorner(h, sizing))\n\t\t\t\t.map((h) => {\n\t\t\t\t\tconst p = editor.pageToViewport({ x: box.x + h.x * box.w, y: box.y + h.y * box.h })\n\t\t\t\t\treturn { ...h, key: `${h.x}-${h.y}`, left: p.x, top: p.y }\n\t\t\t\t})\n\t\t\t// tldraw's own resize cursors (the editor's, in the theme's cursor colour), not the\n\t\t\t// browser's native ones.\n\t\t\tconst { cursor: cursorColor } = editor.getCurrentTheme().colors[editor.getColorMode()]\n\t\t\tconst cursors = {\n\t\t\t\t'nwse-resize': getCursor('nwse-resize', 0, cursorColor),\n\t\t\t\t'nesw-resize': getCursor('nesw-resize', 0, cursorColor),\n\t\t\t}\n\t\t\treturn { points, hitSize: sizing.hitSize, cursors }\n\t\t},\n\t\t[editor, box.x, box.y, box.w, box.h, handles]\n\t)\n\tconst { points, hitSize, cursors } = layout\n\tconst resized = () => {\n\t\tconst drag = dragRef.current!\n\t\treturn resizeRegion(\n\t\t\tdrag.box,\n\t\t\tdrag.handle,\n\t\t\teditor.screenToPage({ x: drag.clientX, y: drag.clientY })\n\t\t)\n\t}\n\tconst startResize = (h: RegionHandle) => (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\t// A middle/right-button or space-held press is a camera pan, not a resize.\n\t\tif (isCanvasPanGesture(editor, e)) {\n\t\t\tforwardPointerEventToCanvas(editor.getContainer(), e)\n\t\t\treturn\n\t\t}\n\t\te.stopPropagation()\n\t\tdragRef.current?.endDrag()\n\t\tdragRef.current = {\n\t\t\tbox,\n\t\t\thandle: h,\n\t\t\tclientX: e.clientX,\n\t\t\tclientY: e.clientY,\n\t\t\tendDrag: startCommentDrag(editor, {\n\t\t\t\tcursor: h.cursor,\n\t\t\t\tonCameraMove: () => {\n\t\t\t\t\tif (dragRef.current) onPreview(resized())\n\t\t\t\t},\n\t\t\t}),\n\t\t}\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onResize = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\tdrag.clientX = e.clientX\n\t\tdrag.clientY = e.clientY\n\t\tonPreview(resized())\n\t}\n\tconst endResize = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\tdrag.clientX = e.clientX\n\t\tdrag.clientY = e.clientY\n\t\tconst bounds = resized()\n\t\tdragRef.current = null\n\t\tdrag.endDrag()\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId))\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\tonCommit(bounds)\n\t}\n\t// A cancelled pointer abandons the resize: the region snaps back to its stored bounds.\n\tconst cancelResize = () => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\tdragRef.current = null\n\t\tdrag.endDrag()\n\t\tonPreview(null)\n\t}\n\treturn (\n\t\t// A wheel over a handle (even mid-resize) scrolls the canvas, like everywhere else on it.\n\t\t<div ref={wheelRef} className=\"tlui-cmt-canvas-region-handles\">\n\t\t\t{points.map((h) => (\n\t\t\t\t<div\n\t\t\t\t\tkey={h.key}\n\t\t\t\t\tclassName=\"tlui-cmt-canvas-region-handle\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tleft: h.left,\n\t\t\t\t\t\ttop: h.top,\n\t\t\t\t\t\twidth: hitSize,\n\t\t\t\t\t\theight: hitSize,\n\t\t\t\t\t\tcursor: cursors[h.cursor],\n\t\t\t\t\t}}\n\t\t\t\t\tonPointerDown={startResize(h)}\n\t\t\t\t\tonPointerMove={onResize}\n\t\t\t\t\tonPointerUp={endResize}\n\t\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rB,QAAI,CAAC,KAAM;AACX,SAAK,UAAU,EAAE;AACjB,SAAK,UAAU,EAAE;AACjB,cAAU,QAAQ,CAAC;AAAA,EACpB;AACA,QAAM,YAAY,CAAC,MAAyC;AAC3D,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,KAAM;AACX,SAAK,UAAU,EAAE;AACjB,SAAK,UAAU,EAAE;AACjB,UAAM,SAAS,QAAQ;AACvB,YAAQ,UAAU;AAClB,SAAK,QAAQ;AACb,QAAI,EAAE,cAAc,kBAAkB,EAAE,SAAS;AAChD,QAAE,cAAc,sBAAsB,EAAE,SAAS;AAClD,aAAS,MAAM;AAAA,EAChB;AAEA,QAAM,eAAe,MAAM;AAC1B,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,KAAM;AACX,YAAQ,UAAU;AAClB,SAAK,QAAQ;AACb,cAAU,IAAI;AAAA,EACf;AACA;AAAA;AAAA,IAEC,4CAAC,SAAI,KAAK,UAAU,WAAU,kCAC5B,iBAAO,IAAI,CAAC,MACZ;AAAA,MAAC;AAAA;AAAA,QAEA,WAAU;AAAA,QACV,OAAO;AAAA,UACN,MAAM,EAAE;AAAA,UACR,KAAK,EAAE;AAAA,UACP,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,QAAQ,QAAQ,EAAE,MAAM;AAAA,QACzB;AAAA,QACA,eAAe,YAAY,CAAC;AAAA,QAC5B,eAAe;AAAA,QACf,aAAa;AAAA,QACb,iBAAiB;AAAA,QACjB,sBAAsB;AAAA;AAAA,MAbjB,EAAE;AAAA,IAcR,CACA,GACF;AAAA;AAEF;",
6
+ "names": ["points", "cursors"]
7
7
  }
@@ -87,7 +87,9 @@ const ThreadPin = (0, import_react.memo)(function ThreadPin2({
87
87
  (0, import_tldraw.usePassThroughWheelEvents)(markerRef);
88
88
  (0, import_react.useEffect)(() => {
89
89
  return () => {
90
- if (dragRef.current) editor.setHintingShapes([]);
90
+ if (!dragRef.current) return;
91
+ editor.setHintingShapes([]);
92
+ dragRef.current.endDrag?.();
91
93
  };
92
94
  }, [editor]);
93
95
  (0, import_react.useEffect)(() => {
@@ -125,7 +127,8 @@ const ThreadPin = (0, import_react.memo)(function ThreadPin2({
125
127
  const toggleOpen = () => import_state.openThreadId.set(editor, import_state.openThreadId.get(editor) === thread.id ? null : thread.id);
126
128
  const PinContent = options.components.PinContent;
127
129
  const threadAuthor = resolveAuthor(thread.createdBy);
128
- const pinContent = PinContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PinContent, { thread, comments }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mentions.Avatar, { author: threadAuthor ?? import_comment_render.UNKNOWN_COMMENT_AUTHOR });
130
+ const pinAuthor = threadAuthor ?? import_comment_render.UNKNOWN_COMMENT_AUTHOR;
131
+ const pinContent = PinContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PinContent, { thread, comments }) : (0, import_thread_view.avatarRenderer)(options.components, thread.createdBy)?.(pinAuthor) ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mentions.Avatar, { author: pinAuthor });
129
132
  const pinLabel = msg(
130
133
  thread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,
131
134
  {
@@ -150,6 +153,8 @@ const ThreadPin = (0, import_react.memo)(function ThreadPin2({
150
153
  dragRef.current = {
151
154
  startX: e.clientX,
152
155
  startY: e.clientY,
156
+ clientX: e.clientX,
157
+ clientY: e.clientY,
153
158
  moved: false,
154
159
  offsetX: anchorPage ? anchorPage.x - grabPage.x : 0,
155
160
  offsetY: anchorPage ? anchorPage.y - grabPage.y : 0
@@ -161,8 +166,18 @@ const ThreadPin = (0, import_react.memo)(function ThreadPin2({
161
166
  if (!drag) return;
162
167
  if (!canComment) return;
163
168
  if (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return;
164
- drag.moved = true;
165
- const cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY });
169
+ drag.clientX = e.clientX;
170
+ drag.clientY = e.clientY;
171
+ if (!drag.moved) {
172
+ drag.moved = true;
173
+ drag.endDrag = (0, import_canvas_events.startCommentDrag)(editor, { cursor: "move", onCameraMove: dragToPointer });
174
+ }
175
+ dragToPointer();
176
+ };
177
+ const dragToPointer = () => {
178
+ const drag = dragRef.current;
179
+ if (!drag) return;
180
+ const cursorPage = editor.screenToPage({ x: drag.clientX, y: drag.clientY });
166
181
  const pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY };
167
182
  setDragPagePoint(pagePoint);
168
183
  if (!isRegion) {
@@ -173,6 +188,7 @@ const ThreadPin = (0, import_react.memo)(function ThreadPin2({
173
188
  const takeDrag = (e) => {
174
189
  const drag = dragRef.current;
175
190
  dragRef.current = null;
191
+ drag?.endDrag?.();
176
192
  if (e.currentTarget.hasPointerCapture(e.pointerId)) {
177
193
  e.currentTarget.releasePointerCapture(e.pointerId);
178
194
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/canvas/thread-pin.tsx"],
4
- "sourcesContent": ["import { Avatar } from '@tldraw/mentions'\nimport {\n\tmemo,\n\ttype PointerEvent as ReactPointerEvent,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport {\n\tdefineMessages,\n\tEditor,\n\tTLCommentThread,\n\ttype BoxModel,\n\tuseContainer,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentPin } from '../ui/comment-pin'\nimport { forwardPointerEventToCanvas, isCanvasPanGesture } from './canvas-events'\nimport { commitCommentMutation } from './comment-mutations'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { type CommentingContext } from './context'\nimport { useThreadComments } from './hooks'\nimport { getCommentingOptions, useCanComment, useCommentingOptions } from './options'\nimport {\n\tREGION_CORNERS,\n\tREGION_HANDLE_MARGIN_PX,\n\tRegionBox,\n\tRegionResizeHandles,\n} from './region-box'\nimport { openThreadId } from './state'\nimport { ThreadPreview, useMarkerPreview } from './thread-preview'\nimport {\n\tanchorPagePoint,\n\tanchorViewportPoint,\n\tcommentTargetShapeAt,\n\timpreciseShapePinInset,\n\tisBoxInInflatedViewport,\n\tisInInflatedViewport,\n\tREGION_PIN_CORNER,\n\tregionAnchorPinCorner,\n\tregionPinPoint,\n\tregionWithPinAt,\n\tshapeAnchorAt,\n} from './thread-state'\nimport { POPOVER_OFFSET, ThreadPopover, ThreadView } from './thread-view'\n\nconst messages = defineMessages({\n\tcommentsUnknownAuthor: { id: 'comments.unknown-author', defaultMessage: 'Someone' },\n\tcommentsPinLabel: { id: 'comments.pin-label', defaultMessage: 'Comment by {name}' },\n\tcommentsPinLabelResolved: {\n\t\tid: 'comments.pin-label-resolved',\n\t\tdefaultMessage: 'Resolved comment by {name}',\n\t},\n})\n\n/** The opened popover has a header row the hover preview lacks, so it opens this much higher \u2014 the\n * first comment then lands where the preview's sat. Re-measure if the header height or the preview\n * panel padding changes. */\nconst THREAD_HEADER_BLOCK = 36\n\n/**\n * A single thread's pin: the marker at its anchor, the thread popover when it's open, the hover\n * preview, and \u2014 for a region anchor \u2014 the dashed box and its resize handles. Dragging the marker\n * re-anchors the thread.\n *\n * Memoized so a pin skips re-rendering when the layer re-renders for unrelated reasons; camera\n * tracking still works, since the pin subscribes to its own viewport position via signals.\n */\nexport const ThreadPin = memo(function ThreadPin({\n\teditor,\n\tthread,\n\t...props\n}: CommentingContext & {\n\teditor: Editor\n\tthread: TLCommentThread\n}) {\n\tconst { resolveAuthor } = props\n\tconst options = useCommentingOptions()\n\tconst canComment = useCanComment(props.currentUserId)\n\tconst container = useContainer()\n\tconst msg = useTranslation()\n\tconst comments = useThreadComments(editor, thread.id)\n\t// Only one thread's popover is open at a time \u2014 shared across pins via the atom.\n\tconst open = useValue('thread open', () => openThreadId.get(editor) === thread.id, [\n\t\teditor,\n\t\tthread.id,\n\t])\n\t// While dragging the marker, its page point overrides the anchor's; committed on drop.\n\tconst [dragPagePoint, setDragPagePoint] = useState<{ x: number; y: number } | null>(null)\n\tconst [resizeBounds, setResizeBounds] = useState<BoxModel | null>(null)\n\t// Hovering the marker previews the thread's opening comment, on the delay every marker uses.\n\tconst { previewShown, previewHandlers } = useMarkerPreview(editor, `pin:${thread.id}`)\n\tconst previewThreads = useMemo(() => [thread], [thread])\n\t// The 'pointer' reveal mode: is the pointer within the region's bounds (plus a grab margin)?\n\t// Driven by pointer position, not DOM hover, so moving from anywhere in the region out to a corner\n\t// handle never loses the affordance \u2014 the box stays `pointer-events: none`.\n\tconst pointerInRegion = useValue(\n\t\t'pointer in region',\n\t\t() => {\n\t\t\tif (thread.anchor.type !== 'region' || thread.pageId !== editor.getCurrentPageId())\n\t\t\t\treturn false\n\t\t\tconst m = REGION_HANDLE_MARGIN_PX / editor.getZoomLevel()\n\t\t\tconst p = editor.inputs.getCurrentPagePoint()\n\t\t\tconst a = thread.anchor\n\t\t\treturn p.x >= a.x - m && p.x <= a.x + a.w + m && p.y >= a.y - m && p.y <= a.y + a.h + m\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId]\n\t)\n\t// A region's box and handles are revealed while open, mid-resize, or while the pointer is\n\t// within the region.\n\tconst revealed = open || resizeBounds != null || pointerInRegion\n\t// A region thread's pin corner is its own (the corner its creating drag released on), with\n\t// the default as the fallback for older records.\n\tconst pinCorner =\n\t\tthread.anchor.type === 'region' ? regionAnchorPinCorner(thread.anchor) : REGION_PIN_CORNER\n\t// A region resizes from its corners \u2014 every corner but the pin's own, which the pin owns.\n\tconst resizeHandles = useMemo(\n\t\t() => REGION_CORNERS.filter((c) => c.x !== pinCorner.x || c.y !== pinCorner.y),\n\t\t[pinCorner.x, pinCorner.y]\n\t)\n\tconst dragRef = useRef<{\n\t\tstartX: number\n\t\tstartY: number\n\t\tmoved: boolean\n\t\t// The anchor's page-space offset from the grab point, so a drag translates the pin by the\n\t\t// cursor's delta (like RegionBox's move) instead of snapping the anchor to the cursor.\n\t\toffsetX: number\n\t\toffsetY: number\n\t} | null>(null)\n\tconst markerRef = useRef<HTMLButtonElement>(null)\n\t// Wheel pass-through sits on the marker (which is never scrollable), not the layer root \u2014\n\t// see the note on the layer.\n\tusePassThroughWheelEvents(markerRef)\n\n\t// The drop-target hint is editor-global state with no automatic reset. If the pin unmounts\n\t// mid-drag (e.g. Shift+C hides comments), no pointer event will ever reach the drag handlers \u2014\n\t// clear the hint here or it stays on the shape indefinitely.\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (dragRef.current) editor.setHintingShapes([])\n\t\t}\n\t}, [editor])\n\n\t// Clicking outside the open popover closes the thread. Capture phase + a class check rather than\n\t// stopPropagation, since the popover portals elsewhere in the DOM. The marker is excluded so its own\n\t// click-to-toggle handles it instead of this closing and the toggle reopening.\n\tuseEffect(() => {\n\t\tif (!open) return\n\t\tconst onPointerDown = (e: PointerEvent) => {\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (!target) return\n\t\t\tif (target.closest('.tlui-cmt-canvas-popover')) return\n\t\t\tconst marker = markerRef.current\n\t\t\tif (marker && marker.contains(target)) return\n\t\t\t// A press on a region's resize handle edits this thread \u2014 don't dismiss it.\n\t\t\tif (target.closest('.tlui-cmt-canvas-region-handle')) return\n\t\t\t// A click inside a menu/popover layered above us (the sidebar's filter or overflow\n\t\t\t// dropdown, or the composer's mention picker \u2014 all portaled elsewhere) belongs to that\n\t\t\t// layer; defer to its own dismissal instead of closing the thread out from under it.\n\t\t\tif (\n\t\t\t\ttarget.closest('.tlui-menu, [data-radix-popper-content-wrapper], .tlui-cmt-mention-popup')\n\t\t\t)\n\t\t\t\treturn\n\t\t\topenThreadId.set(editor, null)\n\t\t}\n\t\tdocument.addEventListener('pointerdown', onPointerDown, true)\n\t\treturn () => document.removeEventListener('pointerdown', onPointerDown, true)\n\t}, [open, editor])\n\n\t// The pin must not unmount mid-interaction: an open thread's popover hangs off it, and a drag\n\t// or resize holds pointer capture on it \u2014 so those states are exempt from the viewport cull.\n\tconst exemptFromCull = open || dragPagePoint != null || resizeBounds != null\n\tconst point = useValue(\n\t\t'pin point',\n\t\t() => {\n\t\t\tif (thread.pageId !== editor.getCurrentPageId()) return null\n\t\t\tconst point = anchorViewportPoint(editor, thread.anchor)\n\t\t\tif (!point) return null\n\t\t\t// Off-screen pins (plus a pre-mount margin) unmount rather than re-render every camera frame. A\n\t\t\t// region thread stays mounted while any part of its box is on screen, since the box renders here too.\n\t\t\tif (!exemptFromCull) {\n\t\t\t\tconst visible =\n\t\t\t\t\tthread.anchor.type === 'region'\n\t\t\t\t\t\t? isBoxInInflatedViewport(editor, thread.anchor)\n\t\t\t\t\t\t: isInInflatedViewport(editor, point)\n\t\t\t\tif (!visible) return null\n\t\t\t}\n\t\t\treturn point\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId, exemptFromCull]\n\t)\n\tif (!point) return null\n\n\tconst toggleOpen = () =>\n\t\topenThreadId.set(editor, openThreadId.get(editor) === thread.id ? null : thread.id)\n\n\tconst PinContent = options.components.PinContent\n\tconst threadAuthor = resolveAuthor(thread.createdBy)\n\tconst pinContent = PinContent ? (\n\t\t<PinContent thread={thread} comments={comments} />\n\t) : (\n\t\t<Avatar author={threadAuthor ?? UNKNOWN_COMMENT_AUTHOR} />\n\t)\n\tconst pinLabel = msg(\n\t\tthread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,\n\t\t{\n\t\t\tname: threadAuthor?.name ?? msg(messages.commentsUnknownAuthor),\n\t\t}\n\t)\n\n\t// Drag the marker to move the thread: position is overridden locally while dragging, then re-anchored\n\t// on drop. A region translates keeping its size; a barely-moved pointer is a click.\n\tconst isRegion = thread.anchor.type === 'region'\n\t// The marker is a button (so it's keyboard-reachable), so the drag handlers are typed to it.\n\tconst startDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\t// A middle/right-button or space-held press over a pin is a camera pan, not a pin drag \u2014\n\t\t// hand it to the canvas untouched.\n\t\tif (isCanvasPanGesture(editor, e)) {\n\t\t\tforwardPointerEventToCanvas(container, e)\n\t\t\treturn\n\t\t}\n\t\te.stopPropagation()\n\t\tconst grabPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst anchorPage = anchorPagePoint(editor, thread.anchor)\n\t\t// The drag delta is taken from where the pin is drawn, which for an imprecise shape pin\n\t\t// is inset from its anchor point \u2014 without this the pin jumps by the inset on drag start.\n\t\tconst inset = impreciseShapePinInset(editor, thread.anchor)\n\t\tif (anchorPage && inset) {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tanchorPage.x += inset.x / zoom\n\t\t\tanchorPage.y += inset.y / zoom\n\t\t}\n\t\tdragRef.current = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tmoved: false,\n\t\t\toffsetX: anchorPage ? anchorPage.x - grabPage.x : 0,\n\t\t\toffsetY: anchorPage ? anchorPage.y - grabPage.y : 0,\n\t\t}\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\t// Moving a pin re-anchors the thread record \u2014 a commenting write. Without the permission the\n\t\t// press stays a click (`moved` never sets, so release toggles the popover and never commits).\n\t\tif (!canComment) return\n\t\tif (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return\n\t\tdrag.moved = true\n\t\tconst cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(pagePoint)\n\t\t// Hint the shape the pin would re-anchor to on drop \u2014 the same hit-test endDrag resolves\n\t\t// with. Regions translate rather than re-anchor, so they never hint.\n\t\tif (!isRegion) {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\teditor.setHintingShapes(hit ? [hit.id] : [])\n\t\t}\n\t}\n\t// Release capture and take the drag record; null when no drag was in progress.\n\tconst takeDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tdragRef.current = null\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId)) {\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\t}\n\t\treturn drag\n\t}\n\t// A cancelled pointer (touch gesture takeover, browser interruption) aborts the drag outright:\n\t// no re-anchor commit, no click-toggle \u2014 the pin snaps back and the hint clears.\n\tconst cancelDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tif (!takeDrag(e)) return\n\t\tsetDragPagePoint(null)\n\t\teditor.setHintingShapes([])\n\t}\n\tconst endDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = takeDrag(e)\n\t\tif (!drag) return\n\t\teditor.setHintingShapes([])\n\t\tif (!drag.moved) {\n\t\t\ttoggleOpen()\n\t\t\treturn\n\t\t}\n\t\tconst cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(null)\n\t\tlet anchor: TLCommentThread['anchor']\n\t\tif (thread.anchor.type === 'region') {\n\t\t\tanchor = regionWithPinAt(thread.anchor, pinCorner, pagePoint)\n\t\t} else {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\tanchor = hit\n\t\t\t\t? shapeAnchorAt(\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\thit.id,\n\t\t\t\t\t\tpagePoint,\n\t\t\t\t\t\tgetCommentingOptions(editor).shouldBePrecise(editor, {\n\t\t\t\t\t\t\tshapeId: hit.id,\n\t\t\t\t\t\t\tpoint: pagePoint,\n\t\t\t\t\t\t\taltKey: e.altKey,\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t: { type: 'point', x: pagePoint.x, y: pagePoint.y }\n\t\t}\n\t\tcommitCommentMutation(editor, ({ put }) => put([{ ...thread, anchor }]), 'drag')\n\t}\n\n\t// The pin (and its popover) track the live edit: a resize moves it to the region's pin corner, a\n\t// move to the drag point; otherwise it sits at the stored anchor's viewport point.\n\tconst livePinPage = resizeBounds ? regionPinPoint(resizeBounds, pinCorner) : dragPagePoint\n\tconst renderPointBase = livePinPage ? editor.pageToViewport(livePinPage) : point\n\t// A region's pin centres on its corner \u2014 overlapping the box \u2014 rather than hanging off it.\n\t// The marker anchors bottom-left, so step half its 28px size (--tlui-cmt-pin-size) left and\n\t// down (screen px), matching the draft composer's --region centring on the same corner.\n\tconst renderPoint = isRegion\n\t\t? { x: renderPointBase.x - 14, y: renderPointBase.y + 14 }\n\t\t: renderPointBase\n\n\t// A region's live box bounds, by priority: a corner resize, else a pin-drag translation (the pin\n\t// corner tracks the cursor), else the stored anchor. Undefined for non-region threads.\n\tconst regionAnchor = thread.anchor.type === 'region' ? thread.anchor : undefined\n\tconst movedRegion =\n\t\tregionAnchor && dragPagePoint\n\t\t\t? regionWithPinAt(regionAnchor, pinCorner, dragPagePoint)\n\t\t\t: regionAnchor\n\tconst regionBoxBounds = resizeBounds ?? movedRegion\n\tconst commitResize = (bounds: BoxModel) => {\n\t\tsetResizeBounds(null)\n\t\tif (!canComment) return\n\t\t// Same commit path as a pin drag, so the configured `dragHistory` governs both \u2014 going\n\t\t// straight to `editor.run` here would make region resizes silently ignore the option.\n\t\tcommitCommentMutation(\n\t\t\teditor,\n\t\t\t// Spread the existing anchor first so the region's pin corner survives a resize.\n\t\t\t({ put }) => put([{ ...thread, anchor: { ...regionAnchor!, ...bounds } }]),\n\t\t\t'drag'\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{regionBoxBounds && (dragPagePoint || revealed) && (\n\t\t\t\t<RegionBox editor={editor} box={regionBoxBounds} />\n\t\t\t)}\n\t\t\t{regionBoxBounds && revealed && !dragPagePoint && canComment && (\n\t\t\t\t<RegionResizeHandles\n\t\t\t\t\teditor={editor}\n\t\t\t\t\tbox={regionBoxBounds}\n\t\t\t\t\thandles={resizeHandles}\n\t\t\t\t\tonPreview={setResizeBounds}\n\t\t\t\t\tonCommit={commitResize}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={[\n\t\t\t\t\t'tlui-cmt-canvas-pin',\n\t\t\t\t\topen && 'tlui-cmt-canvas-pin--open',\n\t\t\t\t\tdragPagePoint && 'tlui-cmt-canvas-pin--dragging',\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(' ')}\n\t\t\t\tstyle={{ left: renderPoint.x, top: renderPoint.y }}\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tref={markerRef}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclassName=\"tlui-cmt-button tlui-cmt-canvas-pin__marker\"\n\t\t\t\t\taria-label={pinLabel}\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tonPointerDown={startDrag}\n\t\t\t\t\tonPointerMove={onDrag}\n\t\t\t\t\tonPointerUp={endDrag}\n\t\t\t\t\tonPointerCancel={cancelDrag}\n\t\t\t\t\t// Pointer activation is already handled by endDrag (which distinguishes a click\n\t\t\t\t\t// from a drag), so only take keyboard-synthesised clicks here \u2014 those report\n\t\t\t\t\t// `detail === 0` \u2014 or the thread would toggle twice per mouse click.\n\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\tif (e.detail === 0) toggleOpen()\n\t\t\t\t\t}}\n\t\t\t\t\tonPointerEnter={previewHandlers.onPointerEnter}\n\t\t\t\t\tonPointerLeave={previewHandlers.onPointerLeave}\n\t\t\t\t\t// Focus stands in for hover, so tabbing to a marker gets the same preview.\n\t\t\t\t\tonFocus={previewHandlers.onPointerEnter}\n\t\t\t\t\tonBlur={previewHandlers.onPointerLeave}\n\t\t\t\t>\n\t\t\t\t\t<CommentPin resolved={thread.resolved != null} open={open}>\n\t\t\t\t\t\t{pinContent}\n\t\t\t\t\t</CommentPin>\n\t\t\t\t</button>\n\t\t\t\t{/* The popover portals up to the menus layer (above the UI panels) so it isn't clipped;\n\t\t\t the pin itself stays in the canvas-in-front layer, beneath the UI. */}\n\t\t\t\t{open && (\n\t\t\t\t\t<ThreadPopover\n\t\t\t\t\t\tbase={{\n\t\t\t\t\t\t\tx: renderPoint.x + POPOVER_OFFSET.thread.x,\n\t\t\t\t\t\t\ty: renderPoint.y + POPOVER_OFFSET.thread.y - THREAD_HEADER_BLOCK,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ThreadView editor={editor} thread={thread} {...props} />\n\t\t\t\t\t</ThreadPopover>\n\t\t\t\t)}\n\t\t\t\t{/* Not while dragging: the pin is being moved, not read, and a panel trailing the\n\t\t\t\t cursor would obscure the drop target. */}\n\t\t\t\t{previewShown && !dragPagePoint && (\n\t\t\t\t\t<ThreadPreview\n\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\tthreads={previewThreads}\n\t\t\t\t\t\tvariant=\"thread\"\n\t\t\t\t\t\tpoint={renderPoint}\n\t\t\t\t\t\tonSelectThread={() => openThreadId.set(editor, thread.id)}\n\t\t\t\t\t\t{...previewHandlers}\n\t\t\t\t\t\tcurrentUserId={props.currentUserId}\n\t\t\t\t\t\tresolveAuthor={resolveAuthor}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t)\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0ME;AA1MF,sBAAuB;AACvB,mBAOO;AACP,oBASO;AACP,yBAA2B;AAC3B,2BAAgE;AAChE,+BAAsC;AACtC,4BAAuC;AAEvC,mBAAkC;AAClC,qBAA0E;AAC1E,wBAKO;AACP,mBAA6B;AAC7B,4BAAgD;AAChD,0BAYO;AACP,yBAA0D;AAE1D,MAAM,eAAW,8BAAe;AAAA,EAC/B,uBAAuB,EAAE,IAAI,2BAA2B,gBAAgB,UAAU;AAAA,EAClF,kBAAkB,EAAE,IAAI,sBAAsB,gBA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;AAAA,UAIA,gBAAgB,CAAC,iBACjB;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,SAAS;AAAA,cACT,SAAQ;AAAA,cACR,OAAO;AAAA,cACP,gBAAgB,MAAM,0BAAa,IAAI,QAAQ,OAAO,EAAE;AAAA,cACvD,GAAG;AAAA,cACJ,eAAe,MAAM;AAAA,cACrB;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IAEF;AAAA,KACD;AAEF,CAAC;",
4
+ "sourcesContent": ["import { Avatar } from '@tldraw/mentions'\nimport {\n\tmemo,\n\ttype PointerEvent as ReactPointerEvent,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport {\n\tdefineMessages,\n\tEditor,\n\tTLCommentThread,\n\ttype BoxModel,\n\tuseContainer,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentPin } from '../ui/comment-pin'\nimport { forwardPointerEventToCanvas, isCanvasPanGesture, startCommentDrag } from './canvas-events'\nimport { commitCommentMutation } from './comment-mutations'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { type CommentingContext } from './context'\nimport { useThreadComments } from './hooks'\nimport { getCommentingOptions, useCanComment, useCommentingOptions } from './options'\nimport {\n\tREGION_CORNERS,\n\tREGION_HANDLE_MARGIN_PX,\n\tRegionBox,\n\tRegionResizeHandles,\n} from './region-box'\nimport { openThreadId } from './state'\nimport { ThreadPreview, useMarkerPreview } from './thread-preview'\nimport {\n\tanchorPagePoint,\n\tanchorViewportPoint,\n\tcommentTargetShapeAt,\n\timpreciseShapePinInset,\n\tisBoxInInflatedViewport,\n\tisInInflatedViewport,\n\tREGION_PIN_CORNER,\n\tregionAnchorPinCorner,\n\tregionPinPoint,\n\tregionWithPinAt,\n\tshapeAnchorAt,\n} from './thread-state'\nimport { avatarRenderer, POPOVER_OFFSET, ThreadPopover, ThreadView } from './thread-view'\n\nconst messages = defineMessages({\n\tcommentsUnknownAuthor: { id: 'comments.unknown-author', defaultMessage: 'Someone' },\n\tcommentsPinLabel: { id: 'comments.pin-label', defaultMessage: 'Comment by {name}' },\n\tcommentsPinLabelResolved: {\n\t\tid: 'comments.pin-label-resolved',\n\t\tdefaultMessage: 'Resolved comment by {name}',\n\t},\n})\n\n/** The opened popover has a header row the hover preview lacks, so it opens this much higher \u2014 the\n * first comment then lands where the preview's sat. Re-measure if the header height or the preview\n * panel padding changes. */\nconst THREAD_HEADER_BLOCK = 36\n\n/**\n * A single thread's pin: the marker at its anchor, the thread popover when it's open, the hover\n * preview, and \u2014 for a region anchor \u2014 the dashed box and its resize handles. Dragging the marker\n * re-anchors the thread.\n *\n * Memoized so a pin skips re-rendering when the layer re-renders for unrelated reasons; camera\n * tracking still works, since the pin subscribes to its own viewport position via signals.\n */\nexport const ThreadPin = memo(function ThreadPin({\n\teditor,\n\tthread,\n\t...props\n}: CommentingContext & {\n\teditor: Editor\n\tthread: TLCommentThread\n}) {\n\tconst { resolveAuthor } = props\n\tconst options = useCommentingOptions()\n\tconst canComment = useCanComment(props.currentUserId)\n\tconst container = useContainer()\n\tconst msg = useTranslation()\n\tconst comments = useThreadComments(editor, thread.id)\n\t// Only one thread's popover is open at a time \u2014 shared across pins via the atom.\n\tconst open = useValue('thread open', () => openThreadId.get(editor) === thread.id, [\n\t\teditor,\n\t\tthread.id,\n\t])\n\t// While dragging the marker, its page point overrides the anchor's; committed on drop.\n\tconst [dragPagePoint, setDragPagePoint] = useState<{ x: number; y: number } | null>(null)\n\tconst [resizeBounds, setResizeBounds] = useState<BoxModel | null>(null)\n\t// Hovering the marker previews the thread's opening comment, on the delay every marker uses.\n\tconst { previewShown, previewHandlers } = useMarkerPreview(editor, `pin:${thread.id}`)\n\tconst previewThreads = useMemo(() => [thread], [thread])\n\t// The 'pointer' reveal mode: is the pointer within the region's bounds (plus a grab margin)?\n\t// Driven by pointer position, not DOM hover, so moving from anywhere in the region out to a corner\n\t// handle never loses the affordance \u2014 the box stays `pointer-events: none`.\n\tconst pointerInRegion = useValue(\n\t\t'pointer in region',\n\t\t() => {\n\t\t\tif (thread.anchor.type !== 'region' || thread.pageId !== editor.getCurrentPageId())\n\t\t\t\treturn false\n\t\t\tconst m = REGION_HANDLE_MARGIN_PX / editor.getZoomLevel()\n\t\t\tconst p = editor.inputs.getCurrentPagePoint()\n\t\t\tconst a = thread.anchor\n\t\t\treturn p.x >= a.x - m && p.x <= a.x + a.w + m && p.y >= a.y - m && p.y <= a.y + a.h + m\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId]\n\t)\n\t// A region's box and handles are revealed while open, mid-resize, or while the pointer is\n\t// within the region.\n\tconst revealed = open || resizeBounds != null || pointerInRegion\n\t// A region thread's pin corner is its own (the corner its creating drag released on), with\n\t// the default as the fallback for older records.\n\tconst pinCorner =\n\t\tthread.anchor.type === 'region' ? regionAnchorPinCorner(thread.anchor) : REGION_PIN_CORNER\n\t// A region resizes from its corners \u2014 every corner but the pin's own, which the pin owns.\n\tconst resizeHandles = useMemo(\n\t\t() => REGION_CORNERS.filter((c) => c.x !== pinCorner.x || c.y !== pinCorner.y),\n\t\t[pinCorner.x, pinCorner.y]\n\t)\n\tconst dragRef = useRef<{\n\t\tstartX: number\n\t\tstartY: number\n\t\tmoved: boolean\n\t\t// The anchor's page-space offset from the grab point, so a drag translates the pin by the\n\t\t// cursor's delta (like RegionBox's move) instead of snapping the anchor to the cursor.\n\t\toffsetX: number\n\t\toffsetY: number\n\t\tclientX: number\n\t\tclientY: number\n\t\tendDrag?(): void\n\t} | null>(null)\n\tconst markerRef = useRef<HTMLButtonElement>(null)\n\t// Wheel pass-through sits on the marker (which is never scrollable), not the layer root \u2014\n\t// see the note on the layer.\n\tusePassThroughWheelEvents(markerRef)\n\n\t// The drop-target hint is editor-global state with no automatic reset. If the pin unmounts\n\t// mid-drag (e.g. Shift+C hides comments), no pointer event will ever reach the drag handlers \u2014\n\t// clear the hint here or it stays on the shape indefinitely.\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (!dragRef.current) return\n\t\t\teditor.setHintingShapes([])\n\t\t\tdragRef.current.endDrag?.()\n\t\t}\n\t}, [editor])\n\n\t// Clicking outside the open popover closes the thread. Capture phase + a class check rather than\n\t// stopPropagation, since the popover portals elsewhere in the DOM. The marker is excluded so its own\n\t// click-to-toggle handles it instead of this closing and the toggle reopening.\n\tuseEffect(() => {\n\t\tif (!open) return\n\t\tconst onPointerDown = (e: PointerEvent) => {\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (!target) return\n\t\t\tif (target.closest('.tlui-cmt-canvas-popover')) return\n\t\t\tconst marker = markerRef.current\n\t\t\tif (marker && marker.contains(target)) return\n\t\t\t// A press on a region's resize handle edits this thread \u2014 don't dismiss it.\n\t\t\tif (target.closest('.tlui-cmt-canvas-region-handle')) return\n\t\t\t// A click inside a menu/popover layered above us (the sidebar's filter or overflow\n\t\t\t// dropdown, or the composer's mention picker \u2014 all portaled elsewhere) belongs to that\n\t\t\t// layer; defer to its own dismissal instead of closing the thread out from under it.\n\t\t\tif (\n\t\t\t\ttarget.closest('.tlui-menu, [data-radix-popper-content-wrapper], .tlui-cmt-mention-popup')\n\t\t\t)\n\t\t\t\treturn\n\t\t\topenThreadId.set(editor, null)\n\t\t}\n\t\tdocument.addEventListener('pointerdown', onPointerDown, true)\n\t\treturn () => document.removeEventListener('pointerdown', onPointerDown, true)\n\t}, [open, editor])\n\n\t// The pin must not unmount mid-interaction: an open thread's popover hangs off it, and a drag\n\t// or resize holds pointer capture on it \u2014 so those states are exempt from the viewport cull.\n\tconst exemptFromCull = open || dragPagePoint != null || resizeBounds != null\n\tconst point = useValue(\n\t\t'pin point',\n\t\t() => {\n\t\t\tif (thread.pageId !== editor.getCurrentPageId()) return null\n\t\t\tconst point = anchorViewportPoint(editor, thread.anchor)\n\t\t\tif (!point) return null\n\t\t\t// Off-screen pins (plus a pre-mount margin) unmount rather than re-render every camera frame. A\n\t\t\t// region thread stays mounted while any part of its box is on screen, since the box renders here too.\n\t\t\tif (!exemptFromCull) {\n\t\t\t\tconst visible =\n\t\t\t\t\tthread.anchor.type === 'region'\n\t\t\t\t\t\t? isBoxInInflatedViewport(editor, thread.anchor)\n\t\t\t\t\t\t: isInInflatedViewport(editor, point)\n\t\t\t\tif (!visible) return null\n\t\t\t}\n\t\t\treturn point\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId, exemptFromCull]\n\t)\n\tif (!point) return null\n\n\tconst toggleOpen = () =>\n\t\topenThreadId.set(editor, openThreadId.get(editor) === thread.id ? null : thread.id)\n\n\tconst PinContent = options.components.PinContent\n\tconst threadAuthor = resolveAuthor(thread.createdBy)\n\tconst pinAuthor = threadAuthor ?? UNKNOWN_COMMENT_AUTHOR\n\tconst pinContent = PinContent ? (\n\t\t<PinContent thread={thread} comments={comments} />\n\t) : (\n\t\t(avatarRenderer(options.components, thread.createdBy)?.(pinAuthor) ?? (\n\t\t\t<Avatar author={pinAuthor} />\n\t\t))\n\t)\n\tconst pinLabel = msg(\n\t\tthread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,\n\t\t{\n\t\t\tname: threadAuthor?.name ?? msg(messages.commentsUnknownAuthor),\n\t\t}\n\t)\n\n\t// Drag the marker to move the thread: position is overridden locally while dragging, then re-anchored\n\t// on drop. A region translates keeping its size; a barely-moved pointer is a click.\n\tconst isRegion = thread.anchor.type === 'region'\n\t// The marker is a button (so it's keyboard-reachable), so the drag handlers are typed to it.\n\tconst startDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\t// A middle/right-button or space-held press over a pin is a camera pan, not a pin drag \u2014\n\t\t// hand it to the canvas untouched.\n\t\tif (isCanvasPanGesture(editor, e)) {\n\t\t\tforwardPointerEventToCanvas(container, e)\n\t\t\treturn\n\t\t}\n\t\te.stopPropagation()\n\t\tconst grabPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst anchorPage = anchorPagePoint(editor, thread.anchor)\n\t\t// The drag delta is taken from where the pin is drawn, which for an imprecise shape pin\n\t\t// is inset from its anchor point \u2014 without this the pin jumps by the inset on drag start.\n\t\tconst inset = impreciseShapePinInset(editor, thread.anchor)\n\t\tif (anchorPage && inset) {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tanchorPage.x += inset.x / zoom\n\t\t\tanchorPage.y += inset.y / zoom\n\t\t}\n\t\tdragRef.current = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tclientX: e.clientX,\n\t\t\tclientY: e.clientY,\n\t\t\tmoved: false,\n\t\t\toffsetX: anchorPage ? anchorPage.x - grabPage.x : 0,\n\t\t\toffsetY: anchorPage ? anchorPage.y - grabPage.y : 0,\n\t\t}\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\t// Moving a pin re-anchors the thread record \u2014 a commenting write. Without the permission the\n\t\t// press stays a click (`moved` never sets, so release toggles the popover and never commits).\n\t\tif (!canComment) return\n\t\tif (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return\n\t\tdrag.clientX = e.clientX\n\t\tdrag.clientY = e.clientY\n\t\tif (!drag.moved) {\n\t\t\tdrag.moved = true\n\t\t\tdrag.endDrag = startCommentDrag(editor, { cursor: 'move', onCameraMove: dragToPointer })\n\t\t}\n\t\tdragToPointer()\n\t}\n\t// Place the pin under the drag's last pointer position, at the current camera.\n\tconst dragToPointer = () => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\tconst cursorPage = editor.screenToPage({ x: drag.clientX, y: drag.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(pagePoint)\n\t\t// Hint the shape the pin would re-anchor to on drop \u2014 the same hit-test endDrag resolves\n\t\t// with. Regions translate rather than re-anchor, so they never hint.\n\t\tif (!isRegion) {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\teditor.setHintingShapes(hit ? [hit.id] : [])\n\t\t}\n\t}\n\t// Release capture and take the drag record; null when no drag was in progress.\n\tconst takeDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tdragRef.current = null\n\t\tdrag?.endDrag?.()\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId)) {\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\t}\n\t\treturn drag\n\t}\n\t// A cancelled pointer (touch gesture takeover, browser interruption) aborts the drag outright:\n\t// no re-anchor commit, no click-toggle \u2014 the pin snaps back and the hint clears.\n\tconst cancelDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tif (!takeDrag(e)) return\n\t\tsetDragPagePoint(null)\n\t\teditor.setHintingShapes([])\n\t}\n\tconst endDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = takeDrag(e)\n\t\tif (!drag) return\n\t\teditor.setHintingShapes([])\n\t\tif (!drag.moved) {\n\t\t\ttoggleOpen()\n\t\t\treturn\n\t\t}\n\t\tconst cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(null)\n\t\tlet anchor: TLCommentThread['anchor']\n\t\tif (thread.anchor.type === 'region') {\n\t\t\tanchor = regionWithPinAt(thread.anchor, pinCorner, pagePoint)\n\t\t} else {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\tanchor = hit\n\t\t\t\t? shapeAnchorAt(\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\thit.id,\n\t\t\t\t\t\tpagePoint,\n\t\t\t\t\t\tgetCommentingOptions(editor).shouldBePrecise(editor, {\n\t\t\t\t\t\t\tshapeId: hit.id,\n\t\t\t\t\t\t\tpoint: pagePoint,\n\t\t\t\t\t\t\taltKey: e.altKey,\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t: { type: 'point', x: pagePoint.x, y: pagePoint.y }\n\t\t}\n\t\tcommitCommentMutation(editor, ({ put }) => put([{ ...thread, anchor }]), 'drag')\n\t}\n\n\t// The pin (and its popover) track the live edit: a resize moves it to the region's pin corner, a\n\t// move to the drag point; otherwise it sits at the stored anchor's viewport point.\n\tconst livePinPage = resizeBounds ? regionPinPoint(resizeBounds, pinCorner) : dragPagePoint\n\tconst renderPointBase = livePinPage ? editor.pageToViewport(livePinPage) : point\n\t// A region's pin centres on its corner \u2014 overlapping the box \u2014 rather than hanging off it.\n\t// The marker anchors bottom-left, so step half its 28px size (--tlui-cmt-pin-size) left and\n\t// down (screen px), matching the draft composer's --region centring on the same corner.\n\tconst renderPoint = isRegion\n\t\t? { x: renderPointBase.x - 14, y: renderPointBase.y + 14 }\n\t\t: renderPointBase\n\n\t// A region's live box bounds, by priority: a corner resize, else a pin-drag translation (the pin\n\t// corner tracks the cursor), else the stored anchor. Undefined for non-region threads.\n\tconst regionAnchor = thread.anchor.type === 'region' ? thread.anchor : undefined\n\tconst movedRegion =\n\t\tregionAnchor && dragPagePoint\n\t\t\t? regionWithPinAt(regionAnchor, pinCorner, dragPagePoint)\n\t\t\t: regionAnchor\n\tconst regionBoxBounds = resizeBounds ?? movedRegion\n\tconst commitResize = (bounds: BoxModel) => {\n\t\tsetResizeBounds(null)\n\t\tif (!canComment) return\n\t\t// Same commit path as a pin drag, so the configured `dragHistory` governs both \u2014 going\n\t\t// straight to `editor.run` here would make region resizes silently ignore the option.\n\t\tcommitCommentMutation(\n\t\t\teditor,\n\t\t\t// Spread the existing anchor first so the region's pin corner survives a resize.\n\t\t\t({ put }) => put([{ ...thread, anchor: { ...regionAnchor!, ...bounds } }]),\n\t\t\t'drag'\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{regionBoxBounds && (dragPagePoint || revealed) && (\n\t\t\t\t<RegionBox editor={editor} box={regionBoxBounds} />\n\t\t\t)}\n\t\t\t{regionBoxBounds && revealed && !dragPagePoint && canComment && (\n\t\t\t\t<RegionResizeHandles\n\t\t\t\t\teditor={editor}\n\t\t\t\t\tbox={regionBoxBounds}\n\t\t\t\t\thandles={resizeHandles}\n\t\t\t\t\tonPreview={setResizeBounds}\n\t\t\t\t\tonCommit={commitResize}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={[\n\t\t\t\t\t'tlui-cmt-canvas-pin',\n\t\t\t\t\topen && 'tlui-cmt-canvas-pin--open',\n\t\t\t\t\tdragPagePoint && 'tlui-cmt-canvas-pin--dragging',\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(' ')}\n\t\t\t\tstyle={{ left: renderPoint.x, top: renderPoint.y }}\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tref={markerRef}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclassName=\"tlui-cmt-button tlui-cmt-canvas-pin__marker\"\n\t\t\t\t\taria-label={pinLabel}\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tonPointerDown={startDrag}\n\t\t\t\t\tonPointerMove={onDrag}\n\t\t\t\t\tonPointerUp={endDrag}\n\t\t\t\t\tonPointerCancel={cancelDrag}\n\t\t\t\t\t// Pointer activation is already handled by endDrag (which distinguishes a click\n\t\t\t\t\t// from a drag), so only take keyboard-synthesised clicks here \u2014 those report\n\t\t\t\t\t// `detail === 0` \u2014 or the thread would toggle twice per mouse click.\n\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\tif (e.detail === 0) toggleOpen()\n\t\t\t\t\t}}\n\t\t\t\t\tonPointerEnter={previewHandlers.onPointerEnter}\n\t\t\t\t\tonPointerLeave={previewHandlers.onPointerLeave}\n\t\t\t\t\t// Focus stands in for hover, so tabbing to a marker gets the same preview.\n\t\t\t\t\tonFocus={previewHandlers.onPointerEnter}\n\t\t\t\t\tonBlur={previewHandlers.onPointerLeave}\n\t\t\t\t>\n\t\t\t\t\t<CommentPin resolved={thread.resolved != null} open={open}>\n\t\t\t\t\t\t{pinContent}\n\t\t\t\t\t</CommentPin>\n\t\t\t\t</button>\n\t\t\t\t{/* The popover portals up to the menus layer (above the UI panels) so it isn't clipped;\n\t\t\t the pin itself stays in the canvas-in-front layer, beneath the UI. */}\n\t\t\t\t{open && (\n\t\t\t\t\t<ThreadPopover\n\t\t\t\t\t\tbase={{\n\t\t\t\t\t\t\tx: renderPoint.x + POPOVER_OFFSET.thread.x,\n\t\t\t\t\t\t\ty: renderPoint.y + POPOVER_OFFSET.thread.y - THREAD_HEADER_BLOCK,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ThreadView editor={editor} thread={thread} {...props} />\n\t\t\t\t\t</ThreadPopover>\n\t\t\t\t)}\n\t\t\t\t{/* Not while dragging: the pin is being moved, not read, and a panel trailing the\n\t\t\t\t cursor would obscure the drop target. */}\n\t\t\t\t{previewShown && !dragPagePoint && (\n\t\t\t\t\t<ThreadPreview\n\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\tthreads={previewThreads}\n\t\t\t\t\t\tvariant=\"thread\"\n\t\t\t\t\t\tpoint={renderPoint}\n\t\t\t\t\t\tonSelectThread={() => openThreadId.set(editor, thread.id)}\n\t\t\t\t\t\t{...previewHandlers}\n\t\t\t\t\t\tcurrentUserId={props.currentUserId}\n\t\t\t\t\t\tresolveAuthor={resolveAuthor}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t)\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgNE;AAhNF,sBAAuB;AACvB,mBAOO;AACP,oBASO;AACP,yBAA2B;AAC3B,2BAAkF;AAClF,+BAAsC;AACtC,4BAAuC;AAEvC,mBAAkC;AAClC,qBAA0E;AAC1E,wBAKO;AACP,mBAA6B;AAC7B,4BAAgD;AA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