@tldraw/commenting 0.0.0-bootstrap → 5.3.0-canary.04044ed9e96d
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.
- package/README.md +0 -2
- package/commenting.css +1152 -350
- package/dist-cjs/canvas/anchor-lifecycle.js +148 -0
- package/dist-cjs/canvas/anchor-lifecycle.js.map +7 -0
- package/dist-cjs/{ui/avatar.js → canvas/canvas-events.js} +14 -22
- package/dist-cjs/canvas/canvas-events.js.map +7 -0
- package/dist-cjs/canvas/cluster-badge.js +121 -0
- package/dist-cjs/canvas/cluster-badge.js.map +7 -0
- package/dist-cjs/canvas/cluster-fade.js +85 -0
- package/dist-cjs/canvas/cluster-fade.js.map +7 -0
- package/dist-cjs/canvas/cluster-input.js +53 -3
- package/dist-cjs/canvas/cluster-input.js.map +2 -2
- package/dist-cjs/canvas/cluster-model.js +252 -0
- package/dist-cjs/canvas/cluster-model.js.map +7 -0
- package/dist-cjs/canvas/comment-body.js +1 -1
- package/dist-cjs/canvas/comment-body.js.map +2 -2
- package/dist-cjs/canvas/comment-drafts.js +54 -0
- package/dist-cjs/canvas/comment-drafts.js.map +7 -0
- package/dist-cjs/canvas/comment-mutations.js +152 -0
- package/dist-cjs/canvas/comment-mutations.js.map +7 -0
- package/dist-cjs/canvas/comment-reactions.js +160 -0
- package/dist-cjs/canvas/comment-reactions.js.map +7 -0
- package/dist-cjs/canvas/comment-render.js +9 -6
- package/dist-cjs/canvas/comment-render.js.map +2 -2
- package/dist-cjs/canvas/comment-store.js +19 -9
- package/dist-cjs/canvas/comment-store.js.map +2 -2
- package/dist-cjs/canvas/comment-tool.js +63 -14
- package/dist-cjs/canvas/comment-tool.js.map +2 -2
- package/dist-cjs/canvas/comments-filter-menu.js +17 -37
- package/dist-cjs/canvas/comments-filter-menu.js.map +2 -2
- package/dist-cjs/canvas/comments-overflow-menu.js +25 -22
- package/dist-cjs/canvas/comments-overflow-menu.js.map +2 -2
- package/dist-cjs/canvas/comments-overlay.js +151 -989
- package/dist-cjs/canvas/comments-overlay.js.map +3 -3
- package/dist-cjs/canvas/comments-sidebar.js +49 -41
- package/dist-cjs/canvas/comments-sidebar.js.map +2 -2
- package/dist-cjs/canvas/comments-visibility-toggle.js +45 -0
- package/dist-cjs/canvas/comments-visibility-toggle.js.map +7 -0
- package/dist-cjs/canvas/context.js +17 -0
- package/dist-cjs/canvas/context.js.map +7 -0
- package/dist-cjs/canvas/hooks.js +28 -3
- package/dist-cjs/canvas/hooks.js.map +2 -2
- package/dist-cjs/canvas/license.js.map +1 -1
- package/dist-cjs/canvas/mobile-placement.js +91 -0
- package/dist-cjs/canvas/mobile-placement.js.map +7 -0
- package/dist-cjs/canvas/options.js +57 -2
- package/dist-cjs/canvas/options.js.map +2 -2
- package/dist-cjs/canvas/pending-composer.js +134 -0
- package/dist-cjs/canvas/pending-composer.js.map +7 -0
- package/dist-cjs/canvas/pin-stacking.js +81 -0
- package/dist-cjs/canvas/pin-stacking.js.map +7 -0
- package/dist-cjs/canvas/region-box.js +113 -0
- package/dist-cjs/canvas/region-box.js.map +7 -0
- package/dist-cjs/canvas/sidebar-filters.js +2 -2
- package/dist-cjs/canvas/sidebar-filters.js.map +2 -2
- package/dist-cjs/canvas/state.js +28 -14
- package/dist-cjs/canvas/state.js.map +2 -2
- package/dist-cjs/canvas/thread-pin.js +304 -0
- package/dist-cjs/canvas/thread-pin.js.map +7 -0
- package/dist-cjs/canvas/thread-preview.js +177 -0
- package/dist-cjs/canvas/thread-preview.js.map +7 -0
- package/dist-cjs/canvas/thread-stack.js +199 -0
- package/dist-cjs/canvas/thread-stack.js.map +7 -0
- package/dist-cjs/canvas/thread-state.js +82 -21
- package/dist-cjs/canvas/thread-state.js.map +2 -2
- package/dist-cjs/canvas/thread-view.js +450 -0
- package/dist-cjs/canvas/thread-view.js.map +7 -0
- package/dist-cjs/clustering/computeClusterTable.js +6 -6
- package/dist-cjs/clustering/computeClusterTable.js.map +2 -2
- package/dist-cjs/clustering/replay.js +89 -22
- package/dist-cjs/clustering/replay.js.map +3 -3
- package/dist-cjs/clustering/runtime.js +126 -7
- package/dist-cjs/clustering/runtime.js.map +2 -2
- package/dist-cjs/clustering/types.js.map +1 -1
- package/dist-cjs/index.d.ts +904 -353
- package/dist-cjs/index.js +52 -28
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/ui/byline.js +10 -6
- package/dist-cjs/ui/byline.js.map +2 -2
- package/dist-cjs/ui/comment-card.js +15 -8
- package/dist-cjs/ui/comment-card.js.map +2 -2
- package/dist-cjs/ui/comment-composer.js +124 -39
- package/dist-cjs/ui/comment-composer.js.map +2 -2
- package/dist-cjs/ui/comment-pin.js +11 -2
- package/dist-cjs/ui/comment-pin.js.map +2 -2
- package/dist-cjs/ui/comment-thread.js +9 -7
- package/dist-cjs/ui/comment-thread.js.map +2 -2
- package/dist-cjs/ui/comments-list.js +39 -40
- package/dist-cjs/ui/comments-list.js.map +2 -2
- package/dist-cjs/ui/count-badge.js +3 -2
- package/dist-cjs/ui/count-badge.js.map +2 -2
- package/dist-cjs/ui/emoji-picker.js +54 -0
- package/dist-cjs/ui/emoji-picker.js.map +7 -0
- package/dist-cjs/ui/empty-state.js +3 -3
- package/dist-cjs/ui/empty-state.js.map +2 -2
- package/dist-cjs/ui/format-time.js +16 -1
- package/dist-cjs/ui/format-time.js.map +2 -2
- package/dist-cjs/ui/icons.js +115 -0
- package/dist-cjs/ui/icons.js.map +7 -0
- package/dist-cjs/ui/reaction-picker.js +71 -0
- package/dist-cjs/ui/reaction-picker.js.map +7 -0
- package/dist-cjs/ui/reaction.js +58 -6
- package/dist-cjs/ui/reaction.js.map +2 -2
- package/dist-cjs/ui/reactions.js +20 -7
- package/dist-cjs/ui/reactions.js.map +2 -2
- package/dist-cjs/ui/{mention.js → reply-count.js} +9 -11
- package/dist-cjs/ui/reply-count.js.map +7 -0
- package/dist-cjs/ui/send-button.js +13 -1
- package/dist-cjs/ui/send-button.js.map +2 -2
- package/dist-cjs/ui/{comment-text.js → visual-viewport.js} +12 -9
- package/dist-cjs/ui/visual-viewport.js.map +7 -0
- package/dist-esm/canvas/anchor-lifecycle.mjs +128 -0
- package/dist-esm/canvas/anchor-lifecycle.mjs.map +7 -0
- package/dist-esm/canvas/canvas-events.mjs +15 -0
- package/dist-esm/canvas/canvas-events.mjs.map +7 -0
- package/dist-esm/canvas/cluster-badge.mjs +106 -0
- package/dist-esm/canvas/cluster-badge.mjs.map +7 -0
- package/dist-esm/canvas/cluster-fade.mjs +65 -0
- package/dist-esm/canvas/cluster-fade.mjs.map +7 -0
- package/dist-esm/canvas/cluster-input.mjs +54 -4
- package/dist-esm/canvas/cluster-input.mjs.map +2 -2
- package/dist-esm/canvas/cluster-model.mjs +236 -0
- package/dist-esm/canvas/cluster-model.mjs.map +7 -0
- package/dist-esm/canvas/comment-body.mjs +1 -1
- package/dist-esm/canvas/comment-body.mjs.map +2 -2
- package/dist-esm/canvas/comment-drafts.mjs +34 -0
- package/dist-esm/canvas/comment-drafts.mjs.map +7 -0
- package/dist-esm/canvas/comment-mutations.mjs +132 -0
- package/dist-esm/canvas/comment-mutations.mjs.map +7 -0
- package/dist-esm/canvas/comment-reactions.mjs +145 -0
- package/dist-esm/canvas/comment-reactions.mjs.map +7 -0
- package/dist-esm/canvas/comment-render.mjs +10 -7
- package/dist-esm/canvas/comment-render.mjs.map +2 -2
- package/dist-esm/canvas/comment-store.mjs +19 -9
- package/dist-esm/canvas/comment-store.mjs.map +2 -2
- package/dist-esm/canvas/comment-tool.mjs +66 -17
- package/dist-esm/canvas/comment-tool.mjs.map +2 -2
- package/dist-esm/canvas/comments-filter-menu.mjs +17 -36
- package/dist-esm/canvas/comments-filter-menu.mjs.map +2 -2
- package/dist-esm/canvas/comments-overflow-menu.mjs +27 -22
- package/dist-esm/canvas/comments-overflow-menu.mjs.map +2 -2
- package/dist-esm/canvas/comments-overlay.mjs +157 -1010
- package/dist-esm/canvas/comments-overlay.mjs.map +3 -3
- package/dist-esm/canvas/comments-sidebar.mjs +53 -46
- package/dist-esm/canvas/comments-sidebar.mjs.map +2 -2
- package/dist-esm/canvas/comments-visibility-toggle.mjs +25 -0
- package/dist-esm/canvas/comments-visibility-toggle.mjs.map +7 -0
- package/dist-esm/canvas/context.mjs +1 -0
- package/dist-esm/canvas/context.mjs.map +7 -0
- package/dist-esm/canvas/hooks.mjs +35 -5
- package/dist-esm/canvas/hooks.mjs.map +2 -2
- package/dist-esm/canvas/license.mjs.map +1 -1
- package/dist-esm/canvas/mobile-placement.mjs +71 -0
- package/dist-esm/canvas/mobile-placement.mjs.map +7 -0
- package/dist-esm/canvas/options.mjs +59 -3
- package/dist-esm/canvas/options.mjs.map +2 -2
- package/dist-esm/canvas/pending-composer.mjs +126 -0
- package/dist-esm/canvas/pending-composer.mjs.map +7 -0
- package/dist-esm/canvas/pin-stacking.mjs +61 -0
- package/dist-esm/canvas/pin-stacking.mjs.map +7 -0
- package/dist-esm/canvas/region-box.mjs +93 -0
- package/dist-esm/canvas/region-box.mjs.map +7 -0
- package/dist-esm/canvas/sidebar-filters.mjs +2 -2
- package/dist-esm/canvas/sidebar-filters.mjs.map +2 -2
- package/dist-esm/canvas/state.mjs +29 -19
- package/dist-esm/canvas/state.mjs.map +2 -2
- package/dist-esm/canvas/thread-pin.mjs +310 -0
- package/dist-esm/canvas/thread-pin.mjs.map +7 -0
- package/dist-esm/canvas/thread-preview.mjs +163 -0
- package/dist-esm/canvas/thread-preview.mjs.map +7 -0
- package/dist-esm/canvas/thread-stack.mjs +189 -0
- package/dist-esm/canvas/thread-stack.mjs.map +7 -0
- package/dist-esm/canvas/thread-state.mjs +86 -22
- package/dist-esm/canvas/thread-state.mjs.map +2 -2
- package/dist-esm/canvas/thread-view.mjs +461 -0
- package/dist-esm/canvas/thread-view.mjs.map +7 -0
- package/dist-esm/clustering/computeClusterTable.mjs +6 -6
- package/dist-esm/clustering/computeClusterTable.mjs.map +2 -2
- package/dist-esm/clustering/replay.mjs +89 -22
- package/dist-esm/clustering/replay.mjs.map +3 -3
- package/dist-esm/clustering/runtime.mjs +126 -7
- package/dist-esm/clustering/runtime.mjs.map +2 -2
- package/dist-esm/index.d.mts +904 -353
- package/dist-esm/index.mjs +102 -43
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/ui/byline.mjs +11 -7
- package/dist-esm/ui/byline.mjs.map +2 -2
- package/dist-esm/ui/comment-card.mjs +15 -8
- package/dist-esm/ui/comment-card.mjs.map +2 -2
- package/dist-esm/ui/comment-composer.mjs +135 -39
- package/dist-esm/ui/comment-composer.mjs.map +2 -2
- package/dist-esm/ui/comment-pin.mjs +11 -2
- package/dist-esm/ui/comment-pin.mjs.map +2 -2
- package/dist-esm/ui/comment-thread.mjs +9 -7
- package/dist-esm/ui/comment-thread.mjs.map +2 -2
- package/dist-esm/ui/comments-list.mjs +51 -50
- package/dist-esm/ui/comments-list.mjs.map +2 -2
- package/dist-esm/ui/count-badge.mjs +3 -2
- package/dist-esm/ui/count-badge.mjs.map +2 -2
- package/dist-esm/ui/emoji-picker.mjs +34 -0
- package/dist-esm/ui/emoji-picker.mjs.map +7 -0
- package/dist-esm/ui/empty-state.mjs +3 -3
- package/dist-esm/ui/empty-state.mjs.map +2 -2
- package/dist-esm/ui/format-time.mjs +16 -1
- package/dist-esm/ui/format-time.mjs.map +2 -2
- package/dist-esm/ui/icons.mjs +95 -0
- package/dist-esm/ui/icons.mjs.map +7 -0
- package/dist-esm/ui/reaction-picker.mjs +59 -0
- package/dist-esm/ui/reaction-picker.mjs.map +7 -0
- package/dist-esm/ui/reaction.mjs +59 -7
- package/dist-esm/ui/reaction.mjs.map +2 -2
- package/dist-esm/ui/reactions.mjs +21 -8
- package/dist-esm/ui/reactions.mjs.map +2 -2
- package/dist-esm/ui/reply-count.mjs +9 -0
- package/dist-esm/ui/reply-count.mjs.map +7 -0
- package/dist-esm/ui/send-button.mjs +13 -1
- package/dist-esm/ui/send-button.mjs.map +2 -2
- package/dist-esm/ui/visual-viewport.mjs +12 -0
- package/dist-esm/ui/visual-viewport.mjs.map +7 -0
- package/package.json +6 -6
- package/src/canvas/anchor-lifecycle.test.ts +290 -0
- package/src/canvas/anchor-lifecycle.ts +191 -0
- package/src/canvas/canvas-events.ts +18 -0
- package/src/canvas/canvas.css +464 -55
- package/src/canvas/cluster-badge.tsx +133 -0
- package/src/canvas/cluster-fade.ts +102 -0
- package/src/canvas/cluster-input.test.ts +178 -36
- package/src/canvas/cluster-input.ts +95 -9
- package/src/canvas/cluster-model.ts +378 -0
- package/src/canvas/comment-body.tsx +1 -1
- package/src/canvas/comment-drafts.test.ts +55 -0
- package/src/canvas/comment-drafts.ts +46 -0
- package/src/canvas/comment-mutations.test.ts +452 -0
- package/src/canvas/comment-mutations.ts +299 -0
- package/src/canvas/comment-reactions.test.ts +154 -0
- package/src/canvas/comment-reactions.tsx +246 -0
- package/src/canvas/comment-render.test.ts +1 -1
- package/src/canvas/comment-render.ts +17 -13
- package/src/canvas/comment-store.ts +68 -33
- package/src/canvas/comment-tool.test.ts +162 -0
- package/src/canvas/comment-tool.tsx +103 -25
- package/src/canvas/comments-filter-menu.tsx +20 -36
- package/src/canvas/comments-overflow-menu.tsx +17 -19
- package/src/canvas/comments-overlay.tsx +252 -1369
- package/src/canvas/comments-sidebar.test.ts +45 -0
- package/src/canvas/comments-sidebar.tsx +112 -73
- package/src/canvas/comments-visibility-toggle.tsx +25 -0
- package/src/canvas/context.ts +48 -0
- package/src/canvas/hooks.test.ts +94 -0
- package/src/canvas/hooks.ts +66 -11
- package/src/canvas/license.ts +1 -1
- package/src/canvas/mobile-placement.ts +115 -0
- package/src/canvas/options.test.ts +176 -4
- package/src/canvas/options.ts +276 -18
- package/src/canvas/pending-composer.tsx +157 -0
- package/src/canvas/pin-stacking.test.ts +224 -0
- package/src/canvas/pin-stacking.ts +103 -0
- package/src/canvas/region-box.tsx +124 -0
- package/src/canvas/sidebar-filters.ts +4 -3
- package/src/canvas/state.ts +88 -39
- package/src/canvas/thread-pin.tsx +418 -0
- package/src/canvas/thread-preview.test.ts +91 -0
- package/src/canvas/thread-preview.tsx +294 -0
- package/src/canvas/thread-stack.tsx +242 -0
- package/src/canvas/thread-state.test.ts +260 -0
- package/src/canvas/thread-state.ts +171 -37
- package/src/canvas/thread-view.test.ts +72 -0
- package/src/canvas/thread-view.tsx +614 -0
- package/src/clustering/computeClusterTable.test.ts +24 -23
- package/src/clustering/computeClusterTable.ts +17 -8
- package/src/clustering/replay.test.ts +0 -7
- package/src/clustering/replay.ts +131 -32
- package/src/clustering/runtime.test.ts +267 -13
- package/src/clustering/runtime.ts +176 -19
- package/src/clustering/schedule.test.ts +0 -6
- package/src/clustering/screen-offsets.test.ts +171 -0
- package/src/clustering/types.ts +19 -9
- package/src/index.ts +91 -42
- package/src/ui/byline.tsx +21 -9
- package/src/ui/comment-card.tsx +20 -10
- package/src/ui/comment-composer.tsx +178 -56
- package/src/ui/comment-pin.tsx +13 -2
- package/src/ui/comment-thread.tsx +13 -6
- package/src/ui/comments-list.test.ts +31 -0
- package/src/ui/comments-list.tsx +82 -47
- package/src/ui/comments.css +577 -294
- package/src/ui/count-badge.tsx +9 -2
- package/src/ui/emoji-picker.test.ts +25 -0
- package/src/ui/emoji-picker.tsx +76 -0
- package/src/ui/empty-state.tsx +3 -3
- package/src/ui/format-time.test.ts +69 -0
- package/src/ui/format-time.ts +27 -2
- package/src/ui/icons.tsx +116 -0
- package/src/ui/reaction-picker.tsx +102 -0
- package/src/ui/reaction.tsx +125 -6
- package/src/ui/reactions.tsx +69 -10
- package/src/ui/reply-count.ts +16 -0
- package/src/ui/send-button.tsx +13 -3
- package/src/ui/visual-viewport.test.ts +36 -0
- package/src/ui/visual-viewport.ts +27 -0
- package/dist-cjs/canvas/region-options.js +0 -49
- package/dist-cjs/canvas/region-options.js.map +0 -7
- package/dist-cjs/ui/avatar.js.map +0 -7
- package/dist-cjs/ui/comment-mention.js +0 -42
- package/dist-cjs/ui/comment-mention.js.map +0 -7
- package/dist-cjs/ui/comment-text.js.map +0 -7
- package/dist-cjs/ui/mention-list.js +0 -70
- package/dist-cjs/ui/mention-list.js.map +0 -7
- package/dist-cjs/ui/mention-suggestion.js +0 -206
- package/dist-cjs/ui/mention-suggestion.js.map +0 -7
- package/dist-cjs/ui/mention.js.map +0 -7
- package/dist-cjs/ui/render-markdown.js +0 -63
- package/dist-cjs/ui/render-markdown.js.map +0 -7
- package/dist-esm/canvas/region-options.mjs +0 -29
- package/dist-esm/canvas/region-options.mjs.map +0 -7
- package/dist-esm/ui/avatar.mjs +0 -23
- package/dist-esm/ui/avatar.mjs.map +0 -7
- package/dist-esm/ui/comment-mention.mjs +0 -22
- package/dist-esm/ui/comment-mention.mjs.map +0 -7
- package/dist-esm/ui/comment-text.mjs +0 -9
- package/dist-esm/ui/comment-text.mjs.map +0 -7
- package/dist-esm/ui/mention-list.mjs +0 -50
- package/dist-esm/ui/mention-list.mjs.map +0 -7
- package/dist-esm/ui/mention-suggestion.mjs +0 -186
- package/dist-esm/ui/mention-suggestion.mjs.map +0 -7
- package/dist-esm/ui/mention.mjs +0 -11
- package/dist-esm/ui/mention.mjs.map +0 -7
- package/dist-esm/ui/render-markdown.mjs +0 -45
- package/dist-esm/ui/render-markdown.mjs.map +0 -7
- package/src/canvas/region-options.ts +0 -57
- package/src/ui/avatar.tsx +0 -31
- package/src/ui/comment-mention.ts +0 -47
- package/src/ui/comment-text.tsx +0 -12
- package/src/ui/mention-list.tsx +0 -106
- package/src/ui/mention-suggestion.test.ts +0 -18
- package/src/ui/mention-suggestion.tsx +0 -285
- package/src/ui/mention.tsx +0 -9
- package/src/ui/render-markdown.tsx +0 -72
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/canvas/comments-overlay.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tmemo,\n\ttype CSSProperties,\n\ttype PointerEvent as ReactPointerEvent,\n\tReactNode,\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport {\n\ttype BoxModel,\n\tcreateComment,\n\tcreateCommentThread,\n\tEditor,\n\tgetFirstCharacter,\n\treact,\n\tTLComment,\n\tTLCommentId,\n\tTLCommentThread,\n\tTLRichText,\n\tTldrawUiIcon,\n\tuseContainer,\n\tuseEditor,\n\tusePassThroughMouseOverEvents,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n\tVecLike,\n} from 'tldraw'\nimport { computeClusterTable } from '../clustering/computeClusterTable'\nimport { type ClusterRuntime, createClusterRuntime } from '../clustering/runtime'\nimport type { ClusterNode, ClusterTable, MergeEvent } from '../clustering/types'\nimport { CommentCard, CommentCardProps } from '../ui/comment-card'\nimport { CommentComposer } from '../ui/comment-composer'\nimport { EMPTY_COMMENT, isCommentEmpty } from '../ui/comment-extensions'\nimport { CommentPin } from '../ui/comment-pin'\nimport { CommentThread } from '../ui/comment-thread'\nimport { CountBadge } from '../ui/count-badge'\nimport { MentionMember } from '../ui/mention-list'\nimport { isMentionPickerOpen } from '../ui/mention-suggestion'\nimport { collectClusterLeaves } from './cluster-input'\nimport { CommentBody } from './comment-body'\nimport { UNKNOWN_AUTHOR } from './comment-render'\nimport { getCommentRecord, putCommentRecords, removeCommentRecords } from './comment-store'\nimport { PendingComment } from './comment-tool'\nimport { useCommentThreads, useThreadComments } from './hooks'\nimport { useCommentingEnabled } from './license'\nimport {\n\ttype CommentingComponents,\n\ttype CommentingOptions,\n\tgetCommentingOptions,\n\tuseCommentingOptions,\n} from './options'\nimport {\n\tDEFAULT_REGION_COMMENT_OPTIONS,\n\tRegionCommentOptions,\n\tsetRegionCommentOptions,\n} from './region-options'\nimport {\n\tcommentsHidden,\n\tcommitCommentMutation,\n\topenThreadId,\n\tpendingComment,\n\tregionDraft,\n\ttoggleCommentsHidden,\n\tusePendingComment,\n} from './state'\nimport { anchorPagePoint, regionPinPoint, shapeAnchorAt } from './thread-state'\n\n/**\n * A ready-to-use comments layer for a tldraw canvas: pins each thread at its anchor, opens a\n * thread popover (with a reply composer) on click, and shows a composer where the comment tool\n * placed a new thread. Reads/writes comment records straight from `editor.store`.\n *\n * It's meant as the batteries-included default \u2014 every visible piece is a lever (the `CommentBody`\n * and `PinContent` slots on `CommentTool.configure({ components })`), and the pieces it composes\n * (`CommentPin`, `CommentThread`, `CommentComposer`, the hooks, the tool) are all exported, so a\n * consumer can rebuild this from parts instead.\n * @public\n */\nexport interface CanvasCommentsProps {\n\t/** The signed-in user's id, or null for a read-only viewer. Only a signed-in user composes. */\n\tcurrentUserId: string | null\n\t/** Map an author id to a display name, or `undefined` when the id can't be named. */\n\tresolveName(id: string): string | undefined\n\t/** Called after any comment (a new thread's first comment, or a reply) is posted. */\n\tonPostComment?(comment: TLComment): void\n\t/** Whether a comment is unread for the current user (return true for unread). */\n\tisCommentUnread?(commentId: TLCommentId): boolean\n\t/**\n\t * Called for each unread comment shown to the user in an open thread popover, so hosts can\n\t * record a read receipt. Needs `isCommentUnread` to know what's unread.\n\t */\n\tonCommentRead?(commentId: TLCommentId): void\n\t/** Resolve the members matching an `@`-query in the composers (sync or async). */\n\tgetMentionSuggestions?(query: string): MentionMember[] | Promise<MentionMember[]>\n\t/** Override a mention-picker row's content. */\n\trenderMentionSuggestion?(member: MentionMember): ReactNode\n\t/** Where imprecise shape pins sit \u2014 a normalized (0\u20131) spot within the shape. Default top-right. */\n\timpreciseShapeAnchor?: { x: number; y: number }\n\t/** Region comment behaviour. Region is off by default \u2014 omit this for click-only point/shape\n\t * comments. Anything unset falls back to {@link DEFAULT_REGION_COMMENT_OPTIONS}. */\n\tregionOptions?: Partial<RegionCommentOptions>\n}\n\nconst stop = (e: { stopPropagation(): void }) => e.stopPropagation()\n\nconst initialOf = (name: string): string => (getFirstCharacter(name.trim()) || '?').toUpperCase()\nconst CLUSTER_FADE_MS = 150\n/** Duration of the click-a-badge zoom-to-split animation. */\nconst CLUSTER_EXPAND_ZOOM_MS = 450\n\n/** The leading element for the placement composer \u2014 the comment pin's shape, but a pencil\n * instead of an initial, marking an unsent draft. */\nconst draftAvatar = (\n\t<CommentPin>\n\t\t<svg\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\twidth=\"15\"\n\t\t\theight=\"15\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<path d=\"M12 20h9\" />\n\t\t\t<path d=\"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z\" />\n\t\t</svg>\n\t</CommentPin>\n)\n\nfunction toCardProps(\n\tcomment: TLComment,\n\tprops: CanvasCommentsProps,\n\tcomponents: CommentingComponents\n): CommentCardProps {\n\tconst Body = components.CommentBody\n\t// The `CommentBody` component slot overrides the built-in rich-text default (which resolves\n\t// mention ids to names).\n\tconst body = Body ? (\n\t\t<Body comment={comment} />\n\t) : (\n\t\t<CommentBody richText={comment.body} resolveName={props.resolveName} />\n\t)\n\treturn {\n\t\tauthor: props.resolveName(comment.authorId) ?? UNKNOWN_AUTHOR,\n\t\tbody,\n\t\tdate: new Date(comment.createdAt).toISOString(),\n\t\tyou: comment.authorId === props.currentUserId,\n\t\tedited: comment.editedAt != null,\n\t}\n}\n\n/** @public @react */\nexport function CanvasComments(props: CanvasCommentsProps) {\n\t// Gate the whole layer on the license before doing any work. The inner component holds all the\n\t// other hooks, so mounting/unmounting it as the license resolves keeps hook order stable here.\n\tconst commentingEnabled = useCommentingEnabled()\n\tif (!commentingEnabled) return null\n\treturn <CanvasCommentsLayer {...props} />\n}\n\nfunction CanvasCommentsLayer(props: CanvasCommentsProps) {\n\tconst editor = useEditor()\n\tconst options = useCommentingOptions()\n\tconst container = useContainer()\n\t// Merge the consumer's region options over the disabled defaults and publish them for this editor,\n\t// so the comment tool (which has no props) reads the same per-instance config.\n\tconst regionOptions = useMemo(\n\t\t() => ({ ...DEFAULT_REGION_COMMENT_OPTIONS, ...props.regionOptions }),\n\t\t[props.regionOptions]\n\t)\n\tuseEffect(() => setRegionCommentOptions(editor, regionOptions), [editor, regionOptions])\n\tconst layerRef = useRef<HTMLDivElement>(null)\n\t// Over the pins and cluster badges, wheel and hover pass through to the canvas beneath (these\n\t// events bubble up from the pointer-interactive markers to this layer root).\n\tusePassThroughWheelEvents(layerRef)\n\tusePassThroughMouseOverEvents(layerRef)\n\tconst deepLinkHandled = useRef(false)\n\tconst threads = useCommentThreads(editor)\n\tconst pending = usePendingComment()\n\tconst openId = useValue('open thread id', () => openThreadId.get(editor), [editor])\n\tconst impreciseShapeAnchor = props.impreciseShapeAnchor ?? options.impreciseShapeAnchor\n\t// Threads whose anchor has moved (by any means \u2014 drag, nudge, align, undo, a collaborator)\n\t// since the rendered clustering was built. They pop out of clustering and render as live pins,\n\t// and only rejoin at the next zoom event, when everything re-clusters anyway.\n\tconst [movedThreadIds, setMovedThreadIds] = useState<ReadonlySet<string>>(EMPTY_SET)\n\tconst adoptOnRebuild = useRef(false)\n\tconst clusterLeaves = useValue(\n\t\t'comment cluster leaves',\n\t\t() =>\n\t\t\tcollectClusterLeaves(\n\t\t\t\teditor,\n\t\t\t\tthreads.filter((thread) => !movedThreadIds.has(thread.id)),\n\t\t\t\topenThreadId.get(editor),\n\t\t\t\timpreciseShapeAnchor\n\t\t\t),\n\t\t[editor, threads, impreciseShapeAnchor, movedThreadIds]\n\t)\n\tconst clusterZoomBounds = useValue(\n\t\t'comment cluster zoom bounds',\n\t\t() => getClusterZoomBounds(editor),\n\t\t[editor]\n\t)\n\tconst latestModel = useMemo(() => {\n\t\tconst table = computeClusterTable(clusterLeaves, clusterZoomBounds)\n\t\tconst runtime = createClusterRuntime(table)\n\t\truntime.seed(editor.getZoomLevel())\n\t\treturn { runtime, table }\n\t}, [clusterLeaves, clusterZoomBounds, editor])\n\t// Re-clustering only applies while zooming: a rebuilt model (thread added, moved, or closed)\n\t// is held as `latestModel` and adopted on the next zoom change, so pins never re-flow into\n\t// clusters under a static camera. Until adoption, threads the rendered model doesn't know\n\t// about show as plain unclustered pins (`orphanThreads`). Exception: a rebuild that *removed*\n\t// leaves (thread deleted or opened, page changed) is adopted immediately, so stale pins and\n\t// badge counts never linger.\n\tconst [renderedModel, setRenderedModel] = useState(latestModel)\n\tlet clusterModel = renderedModel\n\tif (\n\t\trenderedModel !== latestModel &&\n\t\t(adoptOnRebuild.current || hasRemovedLeaves(renderedModel.table, latestModel.table))\n\t) {\n\t\tadoptOnRebuild.current = false\n\t\t// Carryover seed: events inside their hysteresis band inherit the outgoing partition's\n\t\t// merged/unmerged state instead of the geometric-mean tiebreak, so untouched pins never\n\t\t// snap together (or apart) just because the model was swapped. Idempotent, so safe to\n\t\t// run during render.\n\t\tlatestModel.runtime.seedFrom(editor.getZoomLevel(), renderedModel.runtime.getVisible())\n\t\tsetRenderedModel(latestModel)\n\t\tclusterModel = latestModel\n\t}\n\t// Pop-out detection: a leaf folded inside a badge can't follow its anchor (the badge position\n\t// is baked into the model), so when its live position drifts from the baked one it ghosts.\n\t// Marking it moved excludes it from the cluster input, which reads as a removal above and\n\t// re-clusters the rest of its pile immediately; the pin itself renders live below.\n\tconst newlyMovedIds = findMovedClusteredLeafIds(clusterModel, latestModel)\n\tif (newlyMovedIds.length > 0) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.debug(`[comments] pins popped out of clustering: ${newlyMovedIds.join(', ')}`)\n\t\tconst next = new Set(movedThreadIds)\n\t\tfor (const id of newlyMovedIds) next.add(id)\n\t\tsetMovedThreadIds(next)\n\t}\n\t// Moved pins rejoin clustering on the next zoom-out motion: clear the set (so the rebuild\n\t// includes them again) and adopt that rebuild immediately instead of deferring it. Zooming in\n\t// never folds pins into clusters \u2014 merging is a zoom-out-only move, matching the runtime.\n\tuseEffect(() => {\n\t\tif (movedThreadIds.size === 0) return\n\t\tlet lastZoom = editor.getZoomLevel()\n\t\treturn react('rejoin moved comment pins on zoom out', () => {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tconst prevZoom = lastZoom\n\t\t\tlastZoom = zoom\n\t\t\tif (zoom >= prevZoom) return\n\t\t\tadoptOnRebuild.current = true\n\t\t\tsetMovedThreadIds(EMPTY_SET)\n\t\t})\n\t}, [movedThreadIds, editor])\n\t// Adopt a pending rebuild only on zoom-out motion: folding deferred additions into clusters is\n\t// a merge, and merging only happens while zooming out. While zooming in, the stale table still\n\t// splits correctly on its own (split thresholds are direction-safe by the hysteresis invariant).\n\tuseEffect(() => {\n\t\tif (clusterModel === latestModel) return\n\t\tlet lastZoom = editor.getZoomLevel()\n\t\treturn react('adopt pending cluster model on zoom out', () => {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tconst prevZoom = lastZoom\n\t\t\tlastZoom = zoom\n\t\t\tif (zoom >= prevZoom) return\n\t\t\tlatestModel.runtime.seedFrom(zoom, clusterModel.runtime.getVisible())\n\t\t\tsetRenderedModel(latestModel)\n\t\t})\n\t}, [clusterModel, latestModel, editor])\n\tconst orphanThreads = useMemo(() => {\n\t\tif (clusterModel === latestModel) return []\n\t\tconst renderedIds = new Set(clusterModel.table.leaves.map((leaf) => leaf.id))\n\t\tconst latestIds = new Set(latestModel.table.leaves.map((leaf) => leaf.id))\n\t\treturn threads.filter((thread) => latestIds.has(thread.id) && !renderedIds.has(thread.id))\n\t}, [clusterModel, latestModel, threads])\n\tconst movedThreads = useMemo(\n\t\t() => threads.filter((thread) => movedThreadIds.has(thread.id) && thread.id !== openId),\n\t\t[threads, movedThreadIds, openId]\n\t)\n\t// Subscribe to the runtime cursor, not the raw zoom: onCamera runs on every zoom tick (two\n\t// O(1) threshold checks against the event table) but returns the same integer until a merge\n\t// or split event actually fires \u2014 so this component only re-renders on cluster changes, not\n\t// on every camera frame.\n\tconst clusterCursor = useValue(\n\t\t'comment cluster cursor',\n\t\t() => {\n\t\t\tclusterModel.runtime.onCamera(editor.getZoomLevel())\n\t\t\treturn clusterModel.runtime.k\n\t\t},\n\t\t[clusterModel, editor]\n\t)\n\tconst visibleNodes = useMemo(() => {\n\t\tconst nodes = Array.from(clusterModel.runtime.getVisible().values())\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.debug(\n\t\t\t`[comments] cluster cursor k=${clusterCursor} \u2192 re-rendering ${nodes.length} visible nodes`\n\t\t)\n\t\treturn nodes\n\t}, [clusterModel, clusterCursor])\n\tconst fadeNodes = useFadeVisibleNodes(visibleNodes, clusterModel)\n\tconst threadsById = useMemo(\n\t\t() => new Map<string, TLCommentThread>(threads.map((thread) => [thread.id, thread])),\n\t\t[threads]\n\t)\n\tconst openThread = openId ? threadsById.get(openId) : null\n\tconst hidden = useValue('comments hidden', () => commentsHidden.get(editor), [editor])\n\n\t// Reset the transient UI state (open thread, half-placed comment) when this unmounts.\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\topenThreadId.set(editor, null)\n\t\t\tpendingComment.set(editor, null)\n\t\t}\n\t}, [editor])\n\n\t// Open the thread named by a deep link (?comment=<thread or comment id>). If the thread is\n\t// currently inside a cluster, zoom to the first split that reveals it before opening.\n\tuseEffect(() => {\n\t\tif (deepLinkHandled.current) return\n\t\tconst id = new URLSearchParams(window.location.search).get('comment')\n\t\tif (!id) {\n\t\t\tdeepLinkHandled.current = true\n\t\t\treturn\n\t\t}\n\n\t\tconst record = getCommentRecord(editor, id)\n\t\tif (!record) return\n\n\t\tlet thread: TLCommentThread | undefined\n\t\tif (record.typeName === 'comment') {\n\t\t\tthread = threadsById.get(record.threadId)\n\t\t} else {\n\t\t\tthread = record\n\t\t}\n\t\tif (!thread) return\n\n\t\tdeepLinkHandled.current = true\n\t\trevealDeepLinkedThread(\n\t\t\teditor,\n\t\t\tthread,\n\t\t\tclusterModel.table,\n\t\t\tclusterZoomBounds,\n\t\t\toptions,\n\t\t\timpreciseShapeAnchor\n\t\t)\n\t\topenThreadId.set(editor, thread.id)\n\t}, [clusterModel.table, clusterZoomBounds, editor, threadsById, impreciseShapeAnchor, options])\n\n\t// Clicking a badge zooms to just past the zoom at which that cluster first unclusters,\n\t// centered on its centroid. The event that created a visible cluster is the event that splits\n\t// it, and (by the table's sort + monotone thresholds) it has the smallest zSplit of everything\n\t// applied inside it \u2014 so its zSplit is exactly the first split within those comments. The\n\t// animated zoom-in then drives the runtime cursor like any manual zoom, so the badge splits\n\t// (and can be drilled into further) with no extra bookkeeping.\n\tconst zoomToClusterSplit = useCallback(\n\t\t(node: ClusterNode) => {\n\t\t\tconst event = clusterModel.table.events.find((e) => e.result.id === node.id)\n\t\t\tif (!event || !Number.isFinite(event.zSplit)) return\n\t\t\tconst zoom = clamp(\n\t\t\t\tevent.zSplit * options.clusterSplitZoomFactor,\n\t\t\t\tclusterZoomBounds.minZoom,\n\t\t\t\tclusterZoomBounds.maxZoom\n\t\t\t)\n\t\t\tcenterOnPointAtZoom(editor, node.centroid, zoom, CLUSTER_EXPAND_ZOOM_MS)\n\t\t},\n\t\t[clusterModel, clusterZoomBounds, editor, options]\n\t)\n\n\t// Escape collapses the open thread. Capture-phase + stopPropagation so it runs ahead of the\n\t// editor (which would otherwise cancel the current tool or clear the selection). If a comment is\n\t// being edited, let its own Escape handler exit edit mode first, keeping the thread open.\n\tuseEffect(() => {\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key !== 'Escape' || openThreadId.get(editor) === null) return\n\t\t\t// The mention picker owns Escape while it's open \u2014 let it dismiss the roster alone.\n\t\t\tif (isMentionPickerOpen()) return\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (target && target.closest('.cmt-editing')) return\n\t\t\topenThreadId.set(editor, null)\n\t\t\te.preventDefault()\n\t\t\te.stopPropagation()\n\t\t}\n\t\tdocument.addEventListener('keydown', onKeyDown, true)\n\t\treturn () => document.removeEventListener('keydown', onKeyDown, true)\n\t}, [editor])\n\n\t// Shift+C toggles comment-pin visibility on the canvas (matching Figma). Skipped while typing so\n\t// it never fires from inside a composer. Physical `KeyC` (layout-independent) with shift only.\n\tuseEffect(() => {\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.code !== 'KeyC' || !e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) return\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (target && target.closest('input, textarea, [contenteditable=\"true\"]')) return\n\t\t\ttoggleCommentsHidden(editor)\n\t\t\te.preventDefault()\n\t\t}\n\t\tdocument.addEventListener('keydown', onKeyDown, true)\n\t\treturn () => document.removeEventListener('keydown', onKeyDown, true)\n\t}, [editor])\n\n\t// Hidden: the whole canvas layer (pins, open popover, pending composer) is withheld. The signal\n\t// is read above so this component stays mounted and its shortcut/Escape effects keep running.\n\tif (hidden) return null\n\n\t// Render into the container (above the panels' stacking context) so the pins and popovers\n\t// live in the UI layer rather than being clipped by the canvas layer.\n\treturn createPortal(\n\t\t<div ref={layerRef} className=\"cmt-canvas-layer\">\n\t\t\t{options.enableClustering ? (\n\t\t\t\t<>\n\t\t\t\t\t{fadeNodes.map(({ node, phase }) => {\n\t\t\t\t\t\tlet content: ReactNode\n\t\t\t\t\t\tif (node.count === 1) {\n\t\t\t\t\t\t\tconst thread = threadsById.get(node.id)\n\t\t\t\t\t\t\tif (!thread) return null\n\t\t\t\t\t\t\tcontent = (\n\t\t\t\t\t\t\t\t<ThreadPin\n\t\t\t\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\t\t\t\tthread={thread}\n\t\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\t\tregionOptions={regionOptions}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontent = <ClusterBadge editor={editor} node={node} onExpand={zoomToClusterSplit} />\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div key={`cluster-fade:${node.id}`} className={clusterFadeClassName(phase)}>\n\t\t\t\t\t\t\t\t{content}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t\t{orphanThreads.map((thread) => (\n\t\t\t\t\t\t<ThreadPin\n\t\t\t\t\t\t\tkey={thread.id}\n\t\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\t\tthread={thread}\n\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\tregionOptions={regionOptions}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t\t{movedThreads.map((thread) => (\n\t\t\t\t\t\t<ThreadPin\n\t\t\t\t\t\t\tkey={thread.id}\n\t\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\t\tthread={thread}\n\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\tregionOptions={regionOptions}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t// Clustering off: every thread renders as its own live pin (each returns null when it's\n\t\t\t\t// not on the current page or its anchor is missing). The open thread is excluded here and\n\t\t\t\t// rendered once below, mirroring how the clustering path keeps it out of the cluster leaves \u2014\n\t\t\t\t// otherwise it would mount a second, stacked pin.\n\t\t\t\tthreads\n\t\t\t\t\t.filter((thread) => thread.id !== openId)\n\t\t\t\t\t.map((thread) => (\n\t\t\t\t\t\t<ThreadPin\n\t\t\t\t\t\t\tkey={thread.id}\n\t\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\t\tthread={thread}\n\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\tregionOptions={regionOptions}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))\n\t\t\t)}\n\t\t\t{openThread && (\n\t\t\t\t<ThreadPin\n\t\t\t\t\tkey={`open:${openThread.id}`}\n\t\t\t\t\teditor={editor}\n\t\t\t\t\tthread={openThread}\n\t\t\t\t\t{...props}\n\t\t\t\t\tregionOptions={regionOptions}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<RegionDraftBox editor={editor} />\n\t\t\t{/* Keep the region visible while composing \u2014 the drag draft is gone by now, and no thread\n\t\t\t exists yet, so the pending anchor is what shows the area under the open composer. */}\n\t\t\t{pending?.anchor.type === 'region' && <RegionBox editor={editor} box={pending.anchor} />}\n\t\t\t{pending && props.currentUserId && (\n\t\t\t\t<PendingComposer editor={editor} pending={pending} {...props} />\n\t\t\t)}\n\t\t</div>,\n\t\tcontainer\n\t)\n}\n\nconst EMPTY_SET: ReadonlySet<string> = new Set()\nconst MOVED_LEAF_EPSILON = 1e-6\ntype ClusterFadePhase = 'entering' | 'present' | 'exiting'\n\ninterface ClusterFadeNode {\n\tnode: ClusterNode\n\tphase: ClusterFadePhase\n}\n\nfunction useFadeVisibleNodes(\n\tnodes: readonly ClusterNode[],\n\tresetKey: { runtime: ClusterRuntime; table: ClusterTable }\n): ClusterFadeNode[] {\n\tconst resetKeyRef = useRef(resetKey)\n\tconst didReset = resetKeyRef.current !== resetKey\n\tif (didReset) {\n\t\tresetKeyRef.current = resetKey\n\t}\n\n\tconst [fadeNodes, setFadeNodes] = useState<ClusterFadeNode[]>(() => toPresentFadeNodes(nodes))\n\tconst renderedNodes = didReset ? toPresentFadeNodes(nodes) : fadeNodes\n\n\tuseEffect(() => {\n\t\tsetFadeNodes(toPresentFadeNodes(nodes))\n\t\t// Resets only on a new model (resetKey); node-list changes within the same model are\n\t\t// handled by the reconcile effect below, which fades entries in/out instead of snapping.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [resetKey])\n\n\tuseEffect(() => {\n\t\tif (didReset) return\n\t\tsetFadeNodes((previous) => reconcileFadeNodes(previous, nodes))\n\t}, [didReset, nodes])\n\n\tconst hasEntering = renderedNodes.some((item) => item.phase === 'entering')\n\tuseEffect(() => {\n\t\tif (!hasEntering) return\n\t\tconst frame = requestClusterFadeFrame(() => {\n\t\t\tsetFadeNodes((previous) =>\n\t\t\t\tprevious.map((item) => (item.phase === 'entering' ? { ...item, phase: 'present' } : item))\n\t\t\t)\n\t\t})\n\t\treturn () => cancelClusterFadeFrame(frame)\n\t}, [hasEntering, renderedNodes])\n\n\tconst hasExiting = renderedNodes.some((item) => item.phase === 'exiting')\n\tuseEffect(() => {\n\t\tif (!hasExiting) return\n\t\tconst timeout = window.setTimeout(() => {\n\t\t\tsetFadeNodes((previous) => previous.filter((item) => item.phase !== 'exiting'))\n\t\t}, CLUSTER_FADE_MS)\n\t\treturn () => window.clearTimeout(timeout)\n\t}, [hasExiting, renderedNodes])\n\n\treturn renderedNodes\n}\n\nfunction toPresentFadeNodes(nodes: readonly ClusterNode[]): ClusterFadeNode[] {\n\treturn nodes.map((node) => ({ node, phase: 'present' }))\n}\n\nfunction reconcileFadeNodes(\n\tprevious: readonly ClusterFadeNode[],\n\tnextNodes: readonly ClusterNode[]\n): ClusterFadeNode[] {\n\tconst previousById = new Map(previous.map((item) => [item.node.id, item]))\n\tconst nextIds = new Set(nextNodes.map((node) => node.id))\n\tconst next: ClusterFadeNode[] = []\n\n\tfor (const node of nextNodes) {\n\t\tconst previousItem = previousById.get(node.id)\n\t\tnext.push({\n\t\t\tnode,\n\t\t\tphase:\n\t\t\t\tpreviousItem && previousItem.phase !== 'exiting'\n\t\t\t\t\t? previousItem.phase\n\t\t\t\t\t: previousItem\n\t\t\t\t\t\t? 'present'\n\t\t\t\t\t\t: 'entering',\n\t\t})\n\t}\n\n\tfor (const item of previous) {\n\t\tif (nextIds.has(item.node.id)) continue\n\t\tnext.push(item.phase === 'exiting' ? item : { ...item, phase: 'exiting' })\n\t}\n\n\treturn next\n}\n\nfunction requestClusterFadeFrame(callback: FrameRequestCallback): number {\n\tif (typeof requestAnimationFrame === 'function') return requestAnimationFrame(callback)\n\treturn window.setTimeout(() => callback(0), 16)\n}\n\nfunction cancelClusterFadeFrame(frame: number) {\n\tif (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame)\n\telse window.clearTimeout(frame)\n}\n\nfunction clusterFadeClassName(phase: ClusterFadePhase): string {\n\treturn `cmt-cluster-fade cmt-cluster-fade--${phase}`\n}\n\n/**\n * Leaves folded inside a badge whose live anchor no longer matches the position the rendered\n * model was built with. Visible (unclustered) leaf pins track their anchor live, so they can\n * stay deferred; a badge can't follow a member, so these must pop out of clustering.\n */\nfunction findMovedClusteredLeafIds(\n\trendered: { runtime: ClusterRuntime; table: ClusterTable },\n\tlatest: { table: ClusterTable }\n): string[] {\n\tif (rendered.table === latest.table) return []\n\tconst visible = rendered.runtime.getVisible()\n\tconst latestById = new Map(latest.table.leaves.map((leaf) => [leaf.id, leaf]))\n\tconst moved: string[] = []\n\tfor (const leaf of rendered.table.leaves) {\n\t\tif (visible.has(leaf.id)) continue\n\t\tconst current = latestById.get(leaf.id)\n\t\tif (!current) continue\n\t\tif (\n\t\t\tMath.abs(current.centroid.x - leaf.centroid.x) > MOVED_LEAF_EPSILON ||\n\t\t\tMath.abs(current.centroid.y - leaf.centroid.y) > MOVED_LEAF_EPSILON\n\t\t) {\n\t\t\tmoved.push(leaf.id)\n\t\t}\n\t}\n\treturn moved\n}\n\nfunction hasRemovedLeaves(rendered: ClusterTable, latest: ClusterTable): boolean {\n\tif (rendered.leaves.length === 0) return false\n\tconst latestIds = new Set(latest.leaves.map((leaf) => leaf.id))\n\treturn rendered.leaves.some((leaf) => !latestIds.has(leaf.id))\n}\n\nfunction getClusterZoomBounds(editor: Editor): { minZoom: number; maxZoom: number } {\n\tconst cameraOptions = editor.getCameraOptions()\n\tconst baseZoom = cameraOptions.constraints ? editor.getBaseZoom() : 1\n\tconst zoomSteps = cameraOptions.zoomSteps\n\treturn {\n\t\tminZoom: zoomSteps[0] * baseZoom,\n\t\tmaxZoom: zoomSteps[zoomSteps.length - 1] * baseZoom,\n\t}\n}\n\nfunction revealDeepLinkedThread(\n\teditor: Editor,\n\tthread: TLCommentThread,\n\ttable: ClusterTable,\n\tzoomBounds: { minZoom: number; maxZoom: number },\n\toptions: CommentingOptions,\n\timpreciseShapeAnchor: { x: number; y: number }\n) {\n\tif (thread.pageId !== editor.getCurrentPageId()) {\n\t\teditor.setCurrentPage(thread.pageId as any)\n\t}\n\n\t// Match where the rendered pin sits (resolved prop-or-option), so the camera centers on the pin.\n\tconst point = anchorPagePoint(editor, thread.anchor, impreciseShapeAnchor)\n\tif (!point) return\n\n\t// With clustering off the pin always renders individually, so skip the zoom-to-split (its cluster\n\t// badge never exists) and just center on the pin.\n\tif (options.enableClustering) {\n\t\tconst parentEvent = findDirectParentEvent(table, thread.id)\n\t\tif (\n\t\t\tparentEvent &&\n\t\t\tNumber.isFinite(parentEvent.zSplit) &&\n\t\t\tparentEvent.zSplit <= zoomBounds.maxZoom\n\t\t) {\n\t\t\tconst zoom = clamp(\n\t\t\t\tparentEvent.zSplit * options.clusterSplitZoomFactor,\n\t\t\t\tzoomBounds.minZoom,\n\t\t\t\tzoomBounds.maxZoom\n\t\t\t)\n\t\t\tcenterOnPointAtZoom(editor, point, zoom)\n\t\t\treturn\n\t\t}\n\t}\n\n\teditor.centerOnPoint(point, { animation: { duration: 200 } })\n}\n\nfunction findDirectParentEvent(table: ClusterTable, threadId: string): MergeEvent | undefined {\n\treturn table.events.find((event) => event.children.some((child) => child.id === threadId))\n}\n\nfunction centerOnPointAtZoom(\n\teditor: Editor,\n\tpoint: { x: number; y: number },\n\tzoom: number,\n\tduration = 200\n) {\n\tconst viewport = editor.getViewportScreenBounds()\n\teditor.setCamera(\n\t\t{\n\t\t\tx: viewport.w / (2 * zoom) - point.x,\n\t\t\ty: viewport.h / (2 * zoom) - point.y,\n\t\t\tz: zoom,\n\t\t},\n\t\t{ animation: { duration } }\n\t)\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n\treturn Math.max(min, Math.min(max, value))\n}\n\n// Memoized: cluster nodes and thread records are identity-stable while unchanged, so pins and\n// badges skip re-rendering when the parent re-renders for reasons that don't concern them\n// (leaf recomputes during shape drags, partition changes elsewhere). Camera tracking still\n// works \u2014 each component subscribes to its own viewport position via signals, not via props.\nconst ClusterBadge = memo(function ClusterBadge({\n\teditor,\n\tnode,\n\tonExpand,\n}: {\n\teditor: Editor\n\tnode: ClusterNode\n\tonExpand(node: ClusterNode): void\n}) {\n\tconst point = useValue(\n\t\t'cluster badge point',\n\t\t() => {\n\t\t\tconst pagePoint = editor.pageToViewport(node.centroid)\n\t\t\tif (!isInInflatedViewport(editor, pagePoint)) return null\n\t\t\treturn pagePoint\n\t\t},\n\t\t[editor, node]\n\t)\n\n\tif (!point) return null\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"cmt-canvas-cluster\"\n\t\t\tstyle={{ left: point.x, top: point.y }}\n\t\t\tonPointerDown={stop}\n\t\t\tonClick={(e) => {\n\t\t\t\te.stopPropagation()\n\t\t\t\tonExpand(node)\n\t\t\t}}\n\t\t>\n\t\t\t<CountBadge count={node.count} />\n\t\t</div>\n\t)\n})\n\nfunction isInInflatedViewport(editor: Editor, point: { x: number; y: number }): boolean {\n\tconst viewport = editor.getViewportScreenBounds()\n\tconst margin = getCommentingOptions(editor).clusterCullMargin\n\treturn (\n\t\tpoint.x >= -margin &&\n\t\tpoint.y >= -margin &&\n\t\tpoint.x <= viewport.w + margin &&\n\t\tpoint.y <= viewport.h + margin\n\t)\n}\n\n/** The open thread's popover, portaled above the UI panels. Over it, wheel and hover events pass\n * through to the canvas (unless the popover is scrolling its own content), like tldraw's panels. */\nfunction ThreadPopover({\n\tcontainer,\n\tstyle,\n\tchildren,\n}: {\n\tcontainer: HTMLElement\n\tstyle: CSSProperties\n\tchildren: ReactNode\n}) {\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\tusePassThroughMouseOverEvents(ref)\n\treturn createPortal(\n\t\t<div ref={ref} className=\"cmt-canvas-popover\" style={style} onPointerDown={stop}>\n\t\t\t{children}\n\t\t</div>,\n\t\tcontainer\n\t)\n}\n\n/** A dashed rectangle over a region anchor's bounds, in viewport space. Sits in the canvas layer as\n * a sibling of the pins. `pointer-events` stays off (canvas interaction passes through) unless\n * `movable`, in which case dragging the body translates the region \u2014 previews live, commits on drop. */\nfunction RegionBox({\n\teditor,\n\tbox,\n\tmovable,\n\tonPreview,\n\tonCommit,\n}: {\n\teditor: Editor\n\tbox: BoxModel\n\tmovable?: boolean\n\tonPreview?(bounds: BoxModel | null): void\n\tonCommit?(bounds: BoxModel): void\n}) {\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\t// The grab point and the box at grab time, captured so the drag translates by a stable delta even\n\t// as the box prop reflows under the live preview.\n\tconst grabRef = useRef<{ page: VecLike; box: BoxModel } | null>(null)\n\tconst translated = (e: ReactPointerEvent<HTMLDivElement>): BoxModel => {\n\t\tconst g = grabRef.current!\n\t\tconst p = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\treturn { ...g.box, x: g.box.x + (p.x - g.page.x), y: g.box.y + (p.y - g.page.y) }\n\t}\n\tconst startMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\te.stopPropagation()\n\t\tgrabRef.current = { page: editor.screenToPage({ x: e.clientX, y: e.clientY }), box }\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tif (grabRef.current) onPreview?.(translated(e))\n\t}\n\tconst endMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tif (!grabRef.current) return\n\t\tconst bounds = translated(e)\n\t\tgrabRef.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<div\n\t\t\tclassName={movable ? 'cmt-canvas-region cmt-canvas-region--movable' : 'cmt-canvas-region'}\n\t\t\tstyle={rect}\n\t\t\tonPointerDown={movable ? startMove : undefined}\n\t\t\tonPointerMove={movable ? onMove : undefined}\n\t\t\tonPointerUp={movable ? endMove : undefined}\n\t\t/>\n\t)\n}\n\n/** The live region being dragged out by the comment tool, or nothing when not dragging. */\nfunction 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 (a side midpoint)\n// is *not* controlled by that handle: corners resize both axes, edges resize only their own.\ninterface RegionHandle {\n\tx: number\n\ty: number\n\tcursor: string\n}\n\n// The four corners (both axes) and the four side midpoints (one axis each).\nconst 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]\nconst REGION_EDGES: readonly RegionHandle[] = [\n\t{ x: 0.5, y: 0, cursor: 'ns-resize' },\n\t{ x: 1, y: 0.5, cursor: 'ew-resize' },\n\t{ x: 0.5, y: 1, cursor: 'ns-resize' },\n\t{ x: 0, y: 0.5, cursor: 'ew-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.\nconst 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. */\nfunction 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=\"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\nconst ThreadPin = memo(function ThreadPin({\n\teditor,\n\tthread,\n\tregionOptions,\n\t...props\n}: Omit<CanvasCommentsProps, 'regionOptions'> & {\n\teditor: Editor\n\tthread: TLCommentThread\n\tregionOptions: RegionCommentOptions\n}) {\n\tconst {\n\t\tcurrentUserId,\n\t\tresolveName,\n\t\tonPostComment,\n\t\tisCommentUnread,\n\t\tonCommentRead,\n\t\tgetMentionSuggestions,\n\t\trenderMentionSuggestion,\n\t} = props\n\tconst options = useCommentingOptions()\n\tconst impreciseShapeAnchor = props.impreciseShapeAnchor ?? options.impreciseShapeAnchor\n\tconst container = useContainer()\n\tconst comments = useThreadComments(editor, thread.id)\n\tconst msg = useTranslation()\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\tconst [reply, setReply] = useState<TLRichText>(EMPTY_COMMENT)\n\tconst [editingId, setEditingId] = useState<string | null>(null)\n\tconst [editText, setEditText] = useState<TLRichText>(EMPTY_COMMENT)\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\t// The live bounds while a corner handle is resizing the region, else null.\n\tconst [resizeBounds, setResizeBounds] = useState<BoxModel | null>(null)\n\t// Whether the pin marker is hovered \u2014 only consulted by the 'pin-hover' reveal mode.\n\tconst [pinHovered, setPinHovered] = useState(false)\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 or mid-resize, plus \u2014 per the reveal mode \u2014\n\t// while the pointer is within the region ('pointer') or the pin is hovered ('pin-hover').\n\tconst revealed =\n\t\topen ||\n\t\tresizeBounds != null ||\n\t\t(regionOptions.reveal === 'pointer' && pointerInRegion) ||\n\t\t(regionOptions.reveal === 'pin-hover' && pinHovered)\n\t// The resize handles: side midpoints ('edges'), or the corners other than the pin's ('corners').\n\tconst resizeHandles = useMemo(\n\t\t() =>\n\t\t\tregionOptions.resize === 'edges'\n\t\t\t\t? REGION_EDGES\n\t\t\t\t: REGION_CORNERS.filter(\n\t\t\t\t\t\t(c) => c.x !== regionOptions.pinCorner.x || c.y !== regionOptions.pinCorner.y\n\t\t\t\t\t),\n\t\t[regionOptions.resize, regionOptions.pinCorner]\n\t)\n\tconst dragRef = useRef<{ startX: number; startY: number; moved: boolean } | null>(null)\n\tconst markerRef = useRef<HTMLDivElement>(null)\n\n\t// Clicking outside the open popover (and off its own pin) closes the thread \u2014 mirrors the\n\t// pending composer's dismiss. Capture phase + a class check rather than stopPropagation, since the\n\t// popover portals elsewhere in the DOM. The pin marker is excluded so its own click-to-toggle\n\t// handles it instead of this closing then 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('.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 or movable body edits this thread \u2014 don't dismiss it.\n\t\t\tif (target.closest('.cmt-canvas-region-handle, .cmt-canvas-region--movable')) 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 (target.closest('.tlui-menu, [data-radix-popper-content-wrapper], .cmt-mention-popup'))\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\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 pagePoint = anchorPagePoint(editor, thread.anchor, impreciseShapeAnchor)\n\t\t\treturn pagePoint ? editor.pageToViewport(pagePoint) : null\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId, impreciseShapeAnchor]\n\t)\n\tconst visible = point !== null\n\n\t// While the popover is open, every unread comment on display gets reported read \u2014 including\n\t// replies that arrive while it stays open, since the effect re-runs as `comments` changes.\n\t// The host's receipt write flips isCommentUnread to false, so re-runs find nothing to report.\n\tuseEffect(() => {\n\t\tif (!open || !visible || !isCommentUnread || !onCommentRead) return\n\t\tfor (const comment of comments) {\n\t\t\tif (isCommentUnread(comment.id)) {\n\t\t\t\tonCommentRead(comment.id)\n\t\t\t}\n\t\t}\n\t}, [open, visible, comments, isCommentUnread, onCommentRead])\n\n\tif (!point) return null\n\n\tconst postReply = () => {\n\t\tif (isCommentEmpty(reply) || !currentUserId) return\n\t\tcommitCommentMutation(editor, () => {\n\t\t\tconst comment = createComment({\n\t\t\t\tthreadId: thread.id,\n\t\t\t\tpageId: thread.pageId,\n\t\t\t\tauthorId: currentUserId,\n\t\t\t\tbody: reply,\n\t\t\t})\n\t\t\tputCommentRecords(editor, [comment])\n\t\t\tif (onPostComment) onPostComment(comment)\n\t\t})\n\t\tsetReply(EMPTY_COMMENT)\n\t}\n\n\tconst toggleResolve = () => {\n\t\tif (!currentUserId) return\n\t\tcommitCommentMutation(editor, () => {\n\t\t\tputCommentRecords(editor, [\n\t\t\t\t{\n\t\t\t\t\t...thread,\n\t\t\t\t\tresolved: thread.resolved ? null : { at: Date.now(), by: currentUserId },\n\t\t\t\t},\n\t\t\t])\n\t\t})\n\t}\n\n\tconst deleteThread = () => {\n\t\topenThreadId.set(editor, null)\n\t\tcommitCommentMutation(editor, () =>\n\t\t\tremoveCommentRecords(editor, [thread.id, ...comments.map((c) => c.id)])\n\t\t)\n\t}\n\n\tconst startEdit = (comment: TLComment) => {\n\t\tsetEditingId(comment.id)\n\t\tsetEditText(comment.body)\n\t}\n\n\tconst saveEdit = () => {\n\t\tconst comment = comments.find((c) => c.id === editingId)\n\t\tif (!comment || isCommentEmpty(editText)) return\n\t\tcommitCommentMutation(editor, () => {\n\t\t\tputCommentRecords(editor, [{ ...comment, body: editText, editedAt: Date.now() }])\n\t\t})\n\t\tsetEditingId(null)\n\t}\n\n\t// Swap a comment for a pre-filled composer while it's being edited; otherwise show the card,\n\t// with an edit affordance on your own comments.\n\tconst renderComment = (card: CommentCardProps, index: number): ReactNode => {\n\t\tconst comment = comments[index]\n\t\tif (editingId === comment.id) {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"cmt-editing\"\n\t\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\t\tif (e.key === 'Escape') {\n\t\t\t\t\t\t\tsetEditingId(null)\n\t\t\t\t\t\t\te.stopPropagation()\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<CommentComposer\n\t\t\t\t\t\tauthor={card.author}\n\t\t\t\t\t\tplaceholder={msg('comments.edit-placeholder')}\n\t\t\t\t\t\tvalue={editText}\n\t\t\t\t\t\tonChange={setEditText}\n\t\t\t\t\t\tonSubmit={saveEdit}\n\t\t\t\t\t\tsendLabel={msg('comments.save')}\n\t\t\t\t\t\tdisabled={isCommentEmpty(editText)}\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/>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\t\treturn (\n\t\t\t<CommentCard\n\t\t\t\t{...card}\n\t\t\t\tactions={\n\t\t\t\t\tcomment.authorId === currentUserId ? (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tclassName=\"cmt-thread__action\"\n\t\t\t\t\t\t\ttitle={msg('comments.edit')}\n\t\t\t\t\t\t\tonClick={() => startEdit(comment)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TldrawUiIcon icon=\"dots-horizontal\" label={msg('comments.edit')} small />\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) : undefined\n\t\t\t\t}\n\t\t\t/>\n\t\t)\n\t}\n\n\tconst headerActions = (\n\t\t<>\n\t\t\t{currentUserId && (\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"cmt-thread__action\"\n\t\t\t\t\ttitle={msg(thread.resolved ? 'comments.reopen' : 'comments.resolve')}\n\t\t\t\t\tonClick={toggleResolve}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiIcon\n\t\t\t\t\t\ticon=\"check\"\n\t\t\t\t\t\tlabel={msg(thread.resolved ? 'comments.reopen' : 'comments.resolve')}\n\t\t\t\t\t\tsmall\n\t\t\t\t\t/>\n\t\t\t\t</button>\n\t\t\t)}\n\t\t\t{currentUserId && (\n\t\t\t\t<button\n\t\t\t\t\tclassName=\"cmt-thread__action\"\n\t\t\t\t\ttitle={msg('comments.delete')}\n\t\t\t\t\tonClick={deleteThread}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiIcon icon=\"trash\" label={msg('comments.delete')} small />\n\t\t\t\t</button>\n\t\t\t)}\n\t\t\t<button\n\t\t\t\tclassName=\"cmt-thread__action\"\n\t\t\t\ttitle={msg('comments.dismiss')}\n\t\t\t\tonClick={() => openThreadId.set(editor, null)}\n\t\t\t>\n\t\t\t\t<TldrawUiIcon icon=\"cross-2\" label={msg('comments.dismiss')} small />\n\t\t\t</button>\n\t\t</>\n\t)\n\n\tconst PinContent = options.components.PinContent\n\t// The `PinContent` component slot overrides the built-in author-initial default.\n\tconst pinContent = PinContent ? (\n\t\t<PinContent thread={thread} comments={comments} />\n\t) : (\n\t\tinitialOf(resolveName(thread.createdBy) ?? UNKNOWN_AUTHOR)\n\t)\n\n\t// Drag the marker to move the thread: its position is overridden locally while dragging, then\n\t// re-anchored on drop. A point/shape thread re-anchors to whatever it's dropped on (a shape, else\n\t// a point); a region thread translates, keeping its size. A pointer that barely moves is a click \u2014\n\t// toggle the popover.\n\t// Which affordances move a region, per the option: 'pin' \u2192 pin only, 'body' \u2192 body only, 'both'.\n\tconst isRegion = thread.anchor.type === 'region'\n\tconst pinMovable = regionOptions.move !== 'body'\n\tconst bodyMovable = regionOptions.move !== 'pin'\n\tconst startDrag = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\te.stopPropagation()\n\t\tdragRef.current = { startX: e.clientX, startY: e.clientY, moved: false }\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onDrag = (e: ReactPointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\t// A region that moves by its body ignores pin drags (the pin only toggles the thread).\n\t\tif (isRegion && !pinMovable) 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\tsetDragPagePoint(editor.screenToPage({ x: e.clientX, y: e.clientY }))\n\t}\n\tconst endDrag = (e: ReactPointerEvent<HTMLDivElement>) => {\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\tif (!drag) return\n\t\tif (!drag.moved) {\n\t\t\topenThreadId.set(editor, openThreadId.get(editor) === thread.id ? null : thread.id)\n\t\t\treturn\n\t\t}\n\t\tconst pagePoint = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tsetDragPagePoint(null)\n\t\tlet anchor: TLCommentThread['anchor']\n\t\tif (thread.anchor.type === 'region') {\n\t\t\t// Translate so the pin (the region's pin corner) lands at the drop; size unchanged.\n\t\t\tanchor = {\n\t\t\t\t...thread.anchor,\n\t\t\t\tx: pagePoint.x - regionOptions.pinCorner.x * thread.anchor.w,\n\t\t\t\ty: pagePoint.y - regionOptions.pinCorner.y * thread.anchor.h,\n\t\t\t}\n\t\t} else {\n\t\t\tconst hit = editor.getShapeAtPoint(pagePoint, { hitInside: true })\n\t\t\tanchor = hit\n\t\t\t\t? shapeAnchorAt(editor, hit.id, pagePoint, e.altKey)\n\t\t\t\t: { type: 'point', x: pagePoint.x, y: pagePoint.y }\n\t\t}\n\t\tcommitCommentMutation(editor, () => putCommentRecords(editor, [{ ...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\n\t\t? regionPinPoint(resizeBounds, regionOptions.pinCorner)\n\t\t: dragPagePoint\n\tconst renderPoint = livePinPage ? editor.pageToViewport(livePinPage) : point\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? {\n\t\t\t\t\t...regionAnchor,\n\t\t\t\t\tx: dragPagePoint.x - regionOptions.pinCorner.x * regionAnchor.w,\n\t\t\t\t\ty: dragPagePoint.y - regionOptions.pinCorner.y * regionAnchor.h,\n\t\t\t\t}\n\t\t\t: regionAnchor\n\tconst regionBoxBounds = resizeBounds ?? movedRegion\n\tconst commitResize = (bounds: BoxModel) => {\n\t\tsetResizeBounds(null)\n\t\teditor.run(\n\t\t\t() => putCommentRecords(editor, [{ ...thread, anchor: { type: 'region', ...bounds } }]),\n\t\t\t{\n\t\t\t\thistory: 'ignore',\n\t\t\t}\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{regionBoxBounds && (dragPagePoint || revealed) && (\n\t\t\t\t<RegionBox\n\t\t\t\t\teditor={editor}\n\t\t\t\t\tbox={regionBoxBounds}\n\t\t\t\t\tmovable={bodyMovable && !dragPagePoint}\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{regionBoxBounds && revealed && !dragPagePoint && regionOptions.resize !== 'none' && (\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={open ? 'cmt-canvas-pin cmt-canvas-pin--open' : 'cmt-canvas-pin'}\n\t\t\t\tstyle={{ left: renderPoint.x, top: renderPoint.y }}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={markerRef}\n\t\t\t\t\tclassName=\"cmt-canvas-pin__marker\"\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\tonPointerEnter={() => setPinHovered(true)}\n\t\t\t\t\tonPointerLeave={() => setPinHovered(false)}\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</div>\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\tcontainer={container}\n\t\t\t\t\t\tstyle={{ left: renderPoint.x + 36, top: renderPoint.y - 28 }}\n\t\t\t\t\t>\n\t\t\t\t\t\t<CommentThread\n\t\t\t\t\t\t\theader={msg('comments.thread-title')}\n\t\t\t\t\t\t\theaderActions={headerActions}\n\t\t\t\t\t\t\trenderComment={renderComment}\n\t\t\t\t\t\t\tcomments={comments.map((c) => toCardProps(c, props, options.components))}\n\t\t\t\t\t\t\tresolvedBanner={\n\t\t\t\t\t\t\t\tthread.resolved\n\t\t\t\t\t\t\t\t\t? msg('comments.resolved-by').replace(\n\t\t\t\t\t\t\t\t\t\t\t'{name}',\n\t\t\t\t\t\t\t\t\t\t\tresolveName(thread.resolved.by) ?? UNKNOWN_AUTHOR\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcomposer={\n\t\t\t\t\t\t\t\tcurrentUserId && !thread.resolved\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\tauthor: resolveName(currentUserId) ?? UNKNOWN_AUTHOR,\n\t\t\t\t\t\t\t\t\t\t\tplaceholder: msg('comments.reply-placeholder'),\n\t\t\t\t\t\t\t\t\t\t\tsendLabel: msg('comments.send'),\n\t\t\t\t\t\t\t\t\t\t\tvalue: reply,\n\t\t\t\t\t\t\t\t\t\t\tonChange: setReply,\n\t\t\t\t\t\t\t\t\t\t\tonSubmit: postReply,\n\t\t\t\t\t\t\t\t\t\t\tdisabled: isCommentEmpty(reply),\n\t\t\t\t\t\t\t\t\t\t\tgetMentionSuggestions,\n\t\t\t\t\t\t\t\t\t\t\trenderMentionSuggestion,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ThreadPopover>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t)\n})\n\nfunction PendingComposer({\n\teditor,\n\tpending,\n\tcurrentUserId,\n\tresolveName,\n\tonPostComment,\n\tgetMentionSuggestions,\n\trenderMentionSuggestion,\n}: CanvasCommentsProps & { editor: Editor; pending: PendingComment }) {\n\tconst [text, setText] = useState<TLRichText>(EMPTY_COMMENT)\n\tconst ref = useRef<HTMLDivElement>(null)\n\tconst msg = useTranslation()\n\tconst container = useContainer()\n\t// Over this floating panel, scroll and hover reach the canvas (except where it scrolls itself).\n\tusePassThroughWheelEvents(ref)\n\tusePassThroughMouseOverEvents(ref)\n\n\tconst point = useValue('composer point', () => editor.pageToViewport(pending.point), [\n\t\teditor,\n\t\tpending.point,\n\t])\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('.cmt-mention-popup')) 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\tcommitCommentMutation(editor, () => {\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\tputCommentRecords(editor, [thread, comment])\n\t\t\tif (onPostComment) onPostComment(comment)\n\t\t})\n\t\tsetText(EMPTY_COMMENT)\n\t\tpendingComment.set(editor, null)\n\t}\n\n\treturn createPortal(\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName=\"cmt-canvas-composer\"\n\t\t\tstyle={{ left: point.x, top: point.y }}\n\t\t\tonPointerDown={stop}\n\t\t\tonKeyDown={(e) => {\n\t\t\t\tif (e.key === 'Escape' && !isMentionPickerOpen()) pendingComment.set(editor, null)\n\t\t\t}}\n\t\t>\n\t\t\t<CommentComposer\n\t\t\t\tauthor={currentUserId ? (resolveName(currentUserId) ?? UNKNOWN_AUTHOR) : ''}\n\t\t\t\tplaceholder={msg('comments.add-placeholder')}\n\t\t\t\tsendLabel={msg('comments.send')}\n\t\t\t\tvalue={text}\n\t\t\t\tonChange={setText}\n\t\t\t\tonSubmit={submit}\n\t\t\t\tdisabled={isCommentEmpty(text)}\n\t\t\t\tgetMentionSuggestions={getMentionSuggestions}\n\t\t\t\trenderMentionSuggestion={renderMentionSuggestion}\n\t\t\t\tautoFocus\n\t\t\t\tleading={draftAvatar}\n\t\t\t/>\n\t\t</div>,\n\t\tcontainer\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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iB;AACvC,YAAM,aAAS,mCAAoB;AAAA,QAClC;AAAA,QACA,QAAQ,QAAQ;AAAA,QAChB,WAAW;AAAA,MACZ,CAAC;AACD,YAAM,cAAU,6BAAc;AAAA,QAC7B,UAAU,OAAO;AAAA,QACjB;AAAA,QACA,UAAU;AAAA,QACV,MAAM;AAAA,MACP,CAAC;AACD,kDAAkB,QAAQ,CAAC,QAAQ,OAAO,CAAC;AAC3C,UAAI,cAAe,eAAc,OAAO;AAAA,IACzC,CAAC;AACD,YAAQ,uCAAa;AACrB,gCAAe,IAAI,QAAQ,IAAI;AAAA,EAChC;AAEA,aAAO;AAAA,IACN;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,WAAU;AAAA,QACV,OAAO,EAAE,MAAM,MAAM,GAAG,KAAK,MAAM,EAAE;AAAA,QACrC,eAAe;AAAA,QACf,WAAW,CAAC,MAAM;AACjB,cAAI,EAAE,QAAQ,YAAY,KAAC,+CAAoB,EAAG,6BAAe,IAAI,QAAQ,IAAI;AAAA,QAClF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACA,QAAQ,gBAAiB,YAAY,aAAa,KAAK,uCAAkB;AAAA,YACzE,aAAa,IAAI,0BAA0B;AAAA,YAC3C,WAAW,IAAI,eAAe;AAAA,YAC9B,OAAO;AAAA,YACP,UAAU;AAAA,YACV,UAAU;AAAA,YACV,cAAU,0CAAe,IAAI;AAAA,YAC7B;AAAA,YACA;AAAA,YACA,WAAS;AAAA,YACT,SAAS;AAAA;AAAA,QACV;AAAA;AAAA,IACD;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { isMentionPickerOpen } from '@tldraw/mentions'\nimport { Fragment, ReactNode, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { EditorPortal, TLCommentThread, useEditor, useValue } from 'tldraw'\nimport type { ClusterNode } from '../clustering/types'\nimport { registerCommentAnchorLifecycle } from './anchor-lifecycle'\nimport { ClusterBadge } from './cluster-badge'\nimport { clusterFadeClassName } from './cluster-fade'\nimport {\n\tCLUSTER_EXPAND_ZOOM_MS,\n\trevealThreadPin,\n\tuseClusterModel,\n\tzoomToClusterSplit,\n} from './cluster-model'\nimport { getCommentRecord } from './comment-store'\nimport { type CommentingContext } from './context'\nimport { useCommentThreads } from './hooks'\nimport { useCommentingEnabled } from './license'\nimport { useCanComment, useCommentingOptions } from './options'\nimport { PendingComposer } from './pending-composer'\nimport { computePinStacks, isOpenStackKeyLive, pinStacksEqual } from './pin-stacking'\nimport { RegionBox, RegionDraftBox } from './region-box'\nimport {\n\tcommentsHidden,\n\topenStackId,\n\topenThreadId,\n\tpendingComment,\n\trevealThreadRequest,\n\tsidebarFilters,\n\ttoggleCommentsHidden,\n\tusePendingComment,\n} from './state'\nimport { ThreadPin } from './thread-pin'\nimport { ThreadStackPin } from './thread-stack'\n\n/**\n * The host wiring for {@link CanvasComments} \u2014 see {@link CommentingContext}, which the sidebar\n * takes the same fields from.\n *\n * @public\n */\nexport type CanvasCommentsProps = CommentingContext\n\n/**\n * A ready-to-use comments layer for a tldraw canvas: pins each thread at its anchor, opens a\n * thread popover (with a reply composer) on click, and shows a composer where the comment tool\n * placed a new thread. Reads/writes comment records straight from `editor.store`.\n *\n * It's the batteries-included default: every visible piece is a slot on\n * `CommentTool.configure({ components })`, and the pieces it composes (`CommentPin`,\n * `CommentThread`, `CommentComposer`, the hooks, the tool) are all exported, so a consumer can\n * rebuild it from parts instead. The host wiring is the {@link CommentingContext}, which\n * `CanvasCommentsSidebar` takes too.\n *\n * @public @react\n */\nexport function CanvasComments(props: CanvasCommentsProps) {\n\t// The inner component holds every other hook, so mounting it as the license resolves keeps hook\n\t// order stable here.\n\tconst commentingEnabled = useCommentingEnabled()\n\tif (!commentingEnabled) return null\n\treturn <CanvasCommentsLayer {...props} />\n}\n\nfunction CanvasCommentsLayer(props: CommentingContext) {\n\tconst editor = useEditor()\n\tconst options = useCommentingOptions()\n\tconst allThreads = useCommentThreads(editor)\n\tconst pending = usePendingComment()\n\tconst canComment = useCanComment(props.currentUserId)\n\t// Nothing renders a pending comment when composing is blocked and there's no fallback slot, and\n\t// the dismiss handlers live inside PendingComposer \u2014 so clear the atom rather than strand it.\n\tconst canRenderComposer = canComment || options.components.ComposerFallback != null\n\tconst showPendingComposer = pending != null && canRenderComposer\n\tuseEffect(() => {\n\t\tif (pending && !showPendingComposer) pendingComment.set(editor, null)\n\t}, [editor, pending, showPendingComposer])\n\tconst openId = useValue('open thread id', () => openThreadId.get(editor), [editor])\n\t// Matches the sidebar's `showResolved` filter. The open thread stays in \u2014 resolving from its own\n\t// popover shouldn't make the pin vanish under it.\n\tconst showResolved = useValue('show resolved', () => sidebarFilters.get(editor).showResolved, [\n\t\teditor,\n\t])\n\tconst threads = useMemo(\n\t\t() => allThreads.filter((t) => showResolved || t.resolved == null || t.id === openId),\n\t\t[allThreads, showResolved, openId]\n\t)\n\tuseEffect(() => registerCommentAnchorLifecycle(editor), [editor])\n\tconst {\n\t\tmodel: clusterModel,\n\t\tzoomBounds: clusterZoomBounds,\n\t\tfadeNodes,\n\t\torphanThreads,\n\t\theldThreads,\n\t} = useClusterModel(editor, threads, openId)\n\tconst threadsById = useMemo(\n\t\t() => new Map<string, TLCommentThread>(threads.map((thread) => [thread.id, thread])),\n\t\t[threads]\n\t)\n\t// Pins with the *same* anchor point coincide at every zoom, so they render as one count-badge\n\t// stack. Keyed on page-space anchors, so camera moves never recompute this. Holding the map's\n\t// identity while the grouping is unchanged keeps a reply from re-rendering every pin \u2014 but the\n\t// map has no positions in it, so anything needing a stack's *point* must read the anchors itself.\n\tconst pinStacksRef = useRef<Map<string, readonly string[]>>(new Map())\n\tconst pinStacks = useValue(\n\t\t'comment pin stacks',\n\t\t() => {\n\t\t\tconst stacks = computePinStacks(editor, threads)\n\t\t\tif (pinStacksEqual(pinStacksRef.current, stacks)) return pinStacksRef.current\n\t\t\tpinStacksRef.current = stacks\n\t\t\treturn stacks\n\t\t},\n\t\t[editor, threads]\n\t)\n\tconst openThread = openId ? threadsById.get(openId) : null\n\tconst hidden = useValue('comments hidden', () => commentsHidden.get(editor), [editor])\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\topenThreadId.set(editor, null)\n\t\t\topenStackId.set(editor, null)\n\t\t\tpendingComment.set(editor, null)\n\t\t\trevealThreadRequest.set(editor, null)\n\t\t}\n\t}, [editor])\n\n\t// Clear a stale open-stack key: only the stack's own mounted handlers clear it, so collapsing to\n\t// a single pin strands it \u2014 and `useMarkerPreview` reads any non-null value as \"a stack is open\"\n\t// and suppresses every hover preview. Kept while any live stack still sits at that key. Reads the\n\t// anchors rather than keying off `pinStacks`, whose identity survives a stack moving as a whole.\n\tconst openStackKeyIsStale = useValue(\n\t\t'open stack key stale',\n\t\t() => {\n\t\t\tconst key = openStackId.get(editor)\n\t\t\tif (!key) return false\n\t\t\treturn !isOpenStackKeyLive(editor, key, pinStacks, threadsById)\n\t\t},\n\t\t[editor, pinStacks, threadsById]\n\t)\n\tuseEffect(() => {\n\t\tif (openStackKeyIsStale) openStackId.set(editor, null)\n\t}, [editor, openStackKeyIsStale])\n\n\t// The requested thread, once it (and, for a comment id, its parent thread) has synced into the\n\t// store; null while records are still arriving or when no request is pending.\n\tconst requestedRevealThread = useValue(\n\t\t'requested reveal thread',\n\t\t() => {\n\t\t\tconst id = revealThreadRequest.get(editor)\n\t\t\tif (!id) return null\n\t\t\tconst record = getCommentRecord(editor, id)\n\t\t\tif (!record) return null\n\t\t\tconst thread =\n\t\t\t\trecord.typeName === 'comment' ? getCommentRecord(editor, record.threadId) : record\n\t\t\treturn thread?.typeName === 'comment-thread' ? thread : null\n\t\t},\n\t\t[editor]\n\t)\n\n\t// Serve a pending reveal request, zooming to the first cluster split that reveals the pin if it's\n\t// folded into a badge. Also unhides pins: the popover opens on the layer that hiding withholds.\n\tuseEffect(() => {\n\t\tif (!requestedRevealThread) return\n\t\trevealThreadRequest.set(editor, null)\n\t\tcommentsHidden.set(editor, false)\n\t\trevealThreadPin(editor, requestedRevealThread, clusterModel.table, clusterZoomBounds, options)\n\t\topenThreadId.set(editor, requestedRevealThread.id)\n\t}, [requestedRevealThread, clusterModel.table, clusterZoomBounds, editor, options])\n\n\t// Picking a thread out of a cluster's hover preview. `openThreadId` alone would work, but would\n\t// cut straight there from the badge \u2014 zoom in first, the same move the badge's own click makes.\n\tconst revealClusteredThread = useCallback(\n\t\t(thread: TLCommentThread) => {\n\t\t\trevealThreadPin(\n\t\t\t\teditor,\n\t\t\t\tthread,\n\t\t\t\tclusterModel.table,\n\t\t\t\tclusterZoomBounds,\n\t\t\t\toptions,\n\t\t\t\tCLUSTER_EXPAND_ZOOM_MS\n\t\t\t)\n\t\t\topenThreadId.set(editor, thread.id)\n\t\t},\n\t\t[clusterModel.table, clusterZoomBounds, editor, options]\n\t)\n\n\tconst expandCluster = useCallback(\n\t\t(node: ClusterNode) => {\n\t\t\tzoomToClusterSplit(editor, clusterModel.table, clusterZoomBounds, node)\n\t\t},\n\t\t[clusterModel.table, clusterZoomBounds, editor]\n\t)\n\n\t// Escape collapses the open thread. Capture-phase so it runs ahead of the editor, which would\n\t// otherwise cancel the tool or clear the selection.\n\tuseEffect(() => {\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key !== 'Escape' || openThreadId.get(editor) === null) return\n\t\t\t// The mention picker owns Escape while it's open \u2014 let it dismiss the roster alone.\n\t\t\tif (isMentionPickerOpen()) return\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (target && target.closest('.tlui-cmt-editing')) return\n\t\t\topenThreadId.set(editor, null)\n\t\t\te.preventDefault()\n\t\t\te.stopPropagation()\n\t\t}\n\t\tdocument.addEventListener('keydown', onKeyDown, true)\n\t\treturn () => document.removeEventListener('keydown', onKeyDown, true)\n\t}, [editor])\n\n\t// Shift+C toggles pin visibility. Physical `KeyC` so it's layout-independent, and skipped while\n\t// typing so it never fires from inside a composer.\n\tuseEffect(() => {\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.code !== 'KeyC' || !e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) return\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (target && target.closest('input, textarea, [contenteditable=\"true\"]')) return\n\t\t\ttoggleCommentsHidden(editor)\n\t\t\te.preventDefault()\n\t\t}\n\t\tdocument.addEventListener('keydown', onKeyDown, true)\n\t\treturn () => document.removeEventListener('keydown', onKeyDown, true)\n\t}, [editor])\n\n\t// The signal is read above so this stays mounted and its shortcut/Escape effects keep running.\n\tif (hidden) return null\n\n\t// The node's pin-stack group when every member shares one \u2014 a stack standing on its own, which\n\t// renders as a cascading count-badge list rather than a zoom-to-split cluster badge. The group\n\t// can include an open or orphan member the node's own leaves omit.\n\tconst stackGroupOf = (node: ClusterNode): readonly string[] | null => {\n\t\tconst group = pinStacks.get(node.members[0])\n\t\tif (!group) return null\n\t\treturn node.members.every((id) => group.includes(id)) ? group : null\n\t}\n\n\t// Which threads are on screen this render. A stack renders once, owned by its first on-screen\n\t// member \u2014 members arrive by different paths, so ownership can't be decided per-path.\n\tconst renderedThreadIds = new Set<string>()\n\tif (options.enableClustering) {\n\t\tfor (const { node } of fadeNodes) {\n\t\t\tif (node.count === 1) renderedThreadIds.add(node.id)\n\t\t\t// A pure-stack node's members aren't count-1 leaves, so register them here for the owner\n\t\t\t// logic to pick from.\n\t\t\telse if (stackGroupOf(node)) for (const id of node.members) renderedThreadIds.add(id)\n\t\t}\n\t\tfor (const thread of orphanThreads) renderedThreadIds.add(thread.id)\n\t\tfor (const thread of heldThreads) renderedThreadIds.add(thread.id)\n\t} else {\n\t\tfor (const thread of threads) renderedThreadIds.add(thread.id)\n\t}\n\tif (openThread) renderedThreadIds.add(openThread.id)\n\n\t// A coincident-stack member renders as the group's single count-badge stack (if it owns it)\n\t// or not at all; everything else is an ordinary pin.\n\tconst renderThreadPin = (thread: TLCommentThread): ReactNode => {\n\t\tconst group = pinStacks.get(thread.id)\n\t\tif (group) {\n\t\t\tconst owner = group.find((id) => renderedThreadIds.has(id))\n\t\t\tif (owner !== thread.id) return null\n\t\t\tconst stackThreads = group\n\t\t\t\t.map((id) => threadsById.get(id))\n\t\t\t\t.filter((t): t is TLCommentThread => t !== undefined)\n\t\t\treturn <ThreadStackPin editor={editor} threads={stackThreads} {...props} />\n\t\t}\n\t\treturn <ThreadPin editor={editor} thread={thread} {...props} />\n\t}\n\n\t// Portalled rather than rendered into this component's slot: pins sit below the collaborator\n\t// cursors and popovers above the UI panels, and no single canvas layer spans both. The portal\n\t// also fixes where the layer lands among the container's children, keeping it behind the UI's\n\t// skip link in the tab order.\n\treturn (\n\t\t<EditorPortal>\n\t\t\t{/* Wheel pass-through lives on each interactive element, not this root: the root spans the\n\t\t\t whole canvas, so a pin past its bottom/right edge inflates scrollHeight and the wheel\n\t\t\t hook's is-this-scrollable guard silently disables pass-through. */}\n\t\t\t<div className=\"tlui-cmt-canvas-layer\">\n\t\t\t\t{options.enableClustering ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{fadeNodes.map(({ node, phase }) => {\n\t\t\t\t\t\t\tlet content: ReactNode\n\t\t\t\t\t\t\tconst stackGroup = node.count > 1 ? stackGroupOf(node) : null\n\t\t\t\t\t\t\tif (node.count === 1) {\n\t\t\t\t\t\t\t\tconst thread = threadsById.get(node.id)\n\t\t\t\t\t\t\t\tif (!thread) return null\n\t\t\t\t\t\t\t\tcontent = renderThreadPin(thread)\n\t\t\t\t\t\t\t} else if (stackGroup) {\n\t\t\t\t\t\t\t\t// Routed through the stack's owner so the open/orphan/held slots stay deduped:\n\t\t\t\t\t\t\t\t// when the owner is one of them, that slot draws the stack and this draws nothing.\n\t\t\t\t\t\t\t\tconst owner = stackGroup.find((id) => renderedThreadIds.has(id))\n\t\t\t\t\t\t\t\tcontent =\n\t\t\t\t\t\t\t\t\towner && node.members.includes(owner)\n\t\t\t\t\t\t\t\t\t\t? renderThreadPin(threadsById.get(owner)!)\n\t\t\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcontent = (\n\t\t\t\t\t\t\t\t\t<ClusterBadge\n\t\t\t\t\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\t\t\t\t\tnode={node}\n\t\t\t\t\t\t\t\t\t\tonExpand={expandCluster}\n\t\t\t\t\t\t\t\t\t\tonSelectThread={revealClusteredThread}\n\t\t\t\t\t\t\t\t\t\tthreadsById={threadsById}\n\t\t\t\t\t\t\t\t\t\tcurrentUserId={props.currentUserId}\n\t\t\t\t\t\t\t\t\t\tresolveAuthor={props.resolveAuthor}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<div key={`cluster-fade:${node.id}`} className={clusterFadeClassName(phase)}>\n\t\t\t\t\t\t\t\t\t{content}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t\t\t{orphanThreads.map((thread) => (\n\t\t\t\t\t\t\t<Fragment key={thread.id}>{renderThreadPin(thread)}</Fragment>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{heldThreads.map((thread) => (\n\t\t\t\t\t\t\t<Fragment key={thread.id}>{renderThreadPin(thread)}</Fragment>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t// Clustering off: every thread renders its own pin. The open thread is excluded and\n\t\t\t\t\t// rendered once below, or it would mount a second, stacked pin.\n\t\t\t\t\tthreads\n\t\t\t\t\t\t.filter((thread) => thread.id !== openId)\n\t\t\t\t\t\t.map((thread) => <Fragment key={thread.id}>{renderThreadPin(thread)}</Fragment>)\n\t\t\t\t)}\n\t\t\t\t{openThread && (\n\t\t\t\t\t<Fragment key={`open:${openThread.id}`}>{renderThreadPin(openThread)}</Fragment>\n\t\t\t\t)}\n\t\t\t\t<RegionDraftBox editor={editor} />\n\t\t\t\t{/* Keep the region visible while composing \u2014 the drag draft is gone by now, and no thread\n\t\t\t\t exists yet, so the pending anchor is what shows the area under the open composer. */}\n\t\t\t\t{pending?.anchor.type === 'region' && showPendingComposer && (\n\t\t\t\t\t<RegionBox editor={editor} box={pending.anchor} />\n\t\t\t\t)}\n\t\t\t\t{pending && showPendingComposer && (\n\t\t\t\t\t<PendingComposer editor={editor} pending={pending} {...props} />\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;AA4DQ;AA5DR,sBAAoC;AACpC,mBAA6E;AAC7E,oBAAmE;AAEnE,8BAA+C;AAC/C,2BAA6B;AAC7B,0BAAqC;AACrC,2BAKO;AACP,2BAAiC;AAEjC,mBAAkC;AAClC,qBAAqC;AACrC,qBAAoD;AACpD,8BAAgC;AAChC,0BAAqE;AACrE,wBAA0C;AAC1C,mBASO;AACP,wBAA0B;AAC1B,0BAA+B;AAuBxB,SAAS,eAAe,OAA4B;AAG1D,QAAM,wBAAoB,qCAAqB;AAC/C,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,4CAAC,uBAAqB,GAAG,OAAO;AACxC;AAEA,SAAS,oBAAoB,OAA0B;AACtD,QAAM,aAAS,yBAAU;AACzB,QAAM,cAAU,qCAAqB;AACrC,QAAM,iBAAa,gCAAkB,MAAM;AAC3C,QAAM,cAAU,gCAAkB;AAClC,QAAM,iBAAa,8BAAc,MAAM,aAAa;AAGpD,QAAM,oBAAoB,cAAc,QAAQ,WAAW,oBAAoB;AAC/E,QAAM,sBAAsB,WAAW,QAAQ;AAC/C,8BAAU,MAAM;AACf,QAAI,WAAW,CAAC,oBAAqB,6BAAe,IAAI,QAAQ,IAAI;AAAA,EACrE,GAAG,CAAC,QAAQ,SAAS,mBAAmB,CAAC;AACzC,QAAM,aAAS,wBAAS,kBAAkB,MAAM,0BAAa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tB,gBAAM,QAAQ,WAAW,KAAK,CAAC,OAAO,kBAAkB,IAAI,EAAE,CAAC;AAC/D,oBACC,SAAS,KAAK,QAAQ,SAAS,KAAK,IACjC,gBAAgB,YAAY,IAAI,KAAK,CAAE,IACvC;AAAA,QACL,OAAO;AACN,oBACC;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA,UAAU;AAAA,cACV,gBAAgB;AAAA,cAChB;AAAA,cACA,eAAe,MAAM;AAAA,cACrB,eAAe,MAAM;AAAA;AAAA,UACtB;AAAA,QAEF;AACA,eACC,4CAAC,SAAoC,eAAW,0CAAqB,KAAK,GACxE,qBADQ,gBAAgB,KAAK,EAAE,EAEjC;AAAA,MAEF,CAAC;AAAA,MACA,cAAc,IAAI,CAAC,WACnB,4CAAC,yBAA0B,0BAAgB,MAAM,KAAlC,OAAO,EAA6B,CACnD;AAAA,MACA,YAAY,IAAI,CAAC,WACjB,4CAAC,yBAA0B,0BAAgB,MAAM,KAAlC,OAAO,EAA6B,CACnD;AAAA,OACF;AAAA;AAAA;AAAA,MAIA,QACE,OAAO,CAAC,WAAW,OAAO,OAAO,MAAM,EACvC,IAAI,CAAC,WAAW,4CAAC,yBAA0B,0BAAgB,MAAM,KAAlC,OAAO,EAA6B,CAAW;AAAA;AAAA,IAEhF,cACA,4CAAC,yBAAwC,0BAAgB,UAAU,KAApD,QAAQ,WAAW,EAAE,EAAiC;AAAA,IAEtE,4CAAC,oCAAe,QAAgB;AAAA,IAG/B,SAAS,OAAO,SAAS,YAAY,uBACrC,4CAAC,+BAAU,QAAgB,KAAK,QAAQ,QAAQ;AAAA,IAEhD,WAAW,uBACX,4CAAC,2CAAgB,QAAgB,SAAmB,GAAG,OAAO;AAAA,KAEhE,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -18,17 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var comments_sidebar_exports = {};
|
|
20
20
|
__export(comments_sidebar_exports, {
|
|
21
|
-
CanvasCommentsSidebar: () => CanvasCommentsSidebar
|
|
21
|
+
CanvasCommentsSidebar: () => CanvasCommentsSidebar,
|
|
22
|
+
sortSidebarRows: () => sortSidebarRows
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(comments_sidebar_exports);
|
|
24
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
26
|
var import_react = require("react");
|
|
26
|
-
var import_react_dom = require("react-dom");
|
|
27
27
|
var import_tldraw = require("tldraw");
|
|
28
28
|
var import_comments_list = require("../ui/comments-list");
|
|
29
29
|
var import_comment_render = require("./comment-render");
|
|
30
30
|
var import_comments_filter_menu = require("./comments-filter-menu");
|
|
31
|
-
var
|
|
31
|
+
var import_comments_visibility_toggle = require("./comments-visibility-toggle");
|
|
32
32
|
var import_hooks = require("./hooks");
|
|
33
33
|
var import_license = require("./license");
|
|
34
34
|
var import_options = require("./options");
|
|
@@ -36,25 +36,16 @@ var import_rich_text = require("./rich-text");
|
|
|
36
36
|
var import_state = require("./state");
|
|
37
37
|
var import_thread_state = require("./thread-state");
|
|
38
38
|
function CanvasCommentsSidebar(props) {
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
currentUserId,
|
|
42
|
-
isCommentUnread,
|
|
43
|
-
tools,
|
|
44
|
-
header,
|
|
45
|
-
empty,
|
|
46
|
-
impreciseShapeAnchor
|
|
47
|
-
} = props;
|
|
39
|
+
const { resolveAuthor, currentUserId, isCommentUnread, header, empty, getThreadHref } = props;
|
|
40
|
+
const resolveName = (0, import_react.useCallback)((id) => resolveAuthor(id)?.name, [resolveAuthor]);
|
|
48
41
|
const editor = (0, import_tldraw.useEditor)();
|
|
49
42
|
const options = (0, import_options.useCommentingOptions)();
|
|
50
|
-
const sidebarTools = tools ?? ["comment"];
|
|
51
|
-
const container = (0, import_tldraw.useContainer)();
|
|
52
43
|
const commentingEnabled = (0, import_license.useCommentingEnabled)();
|
|
53
44
|
const msg = (0, import_tldraw.useTranslation)();
|
|
54
45
|
const threads = (0, import_hooks.useCommentThreads)(editor);
|
|
55
46
|
const comments = (0, import_hooks.useComments)(editor);
|
|
56
47
|
const currentPageId = (0, import_tldraw.useValue)("page id", () => editor.getCurrentPageId(), [editor]);
|
|
57
|
-
const
|
|
48
|
+
const open = (0, import_tldraw.useValue)("sidebar open", () => import_state.commentsSidebarOpen.get(editor), [editor]);
|
|
58
49
|
const openId = (0, import_tldraw.useValue)("open thread", () => import_state.openThreadId.get(editor), [editor]);
|
|
59
50
|
const filters = (0, import_tldraw.useValue)("sidebar filters", () => import_state.sidebarFilters.get(editor), [editor]);
|
|
60
51
|
const pageNames = (0, import_tldraw.useValue)(
|
|
@@ -62,7 +53,7 @@ function CanvasCommentsSidebar(props) {
|
|
|
62
53
|
() => new Map(editor.getPages().map((page) => [page.id, page.name])),
|
|
63
54
|
[editor]
|
|
64
55
|
);
|
|
65
|
-
if (!commentingEnabled || !
|
|
56
|
+
if (!commentingEnabled || !open) return null;
|
|
66
57
|
const byThread = /* @__PURE__ */ new Map();
|
|
67
58
|
for (const comment of comments) {
|
|
68
59
|
const list = byThread.get(comment.threadId) ?? [];
|
|
@@ -72,63 +63,80 @@ function CanvasCommentsSidebar(props) {
|
|
|
72
63
|
const pageThreads = threads.filter(
|
|
73
64
|
(thread) => !filters.onlyCurrentPage || thread.pageId === currentPageId
|
|
74
65
|
);
|
|
75
|
-
const
|
|
76
|
-
(thread) => !filters.onlyMine || currentUserId ===
|
|
66
|
+
const rows = pageThreads.filter((thread) => filters.showResolved || thread.resolved == null).filter(
|
|
67
|
+
(thread) => !filters.onlyMine || currentUserId === null || thread.createdBy === currentUserId
|
|
77
68
|
).filter(
|
|
78
69
|
(thread) => !filters.onlyUnread || isCommentUnread === void 0 || (byThread.get(thread.id) ?? []).some((c) => isCommentUnread(c.id))
|
|
79
70
|
).map((thread) => {
|
|
80
71
|
const threadComments = byThread.get(thread.id) ?? [];
|
|
81
72
|
const first = threadComments[0];
|
|
73
|
+
const last = threadComments[threadComments.length - 1];
|
|
82
74
|
let preview = "";
|
|
83
75
|
const ThreadPreview = options.components.ThreadPreview;
|
|
84
76
|
if (first) {
|
|
85
77
|
preview = ThreadPreview ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadPreview, { comment: first }) : (0, import_rich_text.richTextToPlaintext)(first.body, resolveName);
|
|
86
78
|
}
|
|
87
79
|
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
item: {
|
|
81
|
+
id: thread.id,
|
|
82
|
+
author: resolveAuthor(thread.createdBy) ?? import_comment_render.UNKNOWN_COMMENT_AUTHOR,
|
|
83
|
+
preview,
|
|
84
|
+
date: new Date((first ?? thread).createdAt).toISOString(),
|
|
85
|
+
resolved: thread.resolved != null,
|
|
86
|
+
// The page label only earns its place when it adds information: multiple pages
|
|
87
|
+
// exist, and the thread is somewhere other than where you already are.
|
|
88
|
+
page: pageNames.size > 1 && thread.pageId !== currentPageId ? pageNames.get(thread.pageId) : void 0,
|
|
89
|
+
count: threadComments.length,
|
|
90
|
+
selected: openId === thread.id,
|
|
91
|
+
href: getThreadHref?.(thread.id)
|
|
92
|
+
},
|
|
93
|
+
lastActivity: (last ?? thread).createdAt
|
|
96
94
|
};
|
|
97
|
-
}).sort((a, b) => {
|
|
98
|
-
if (!!a.resolved !== !!b.resolved) return a.resolved ? 1 : -1;
|
|
99
|
-
return b.date.localeCompare(a.date);
|
|
100
95
|
});
|
|
96
|
+
const items = sortSidebarRows(rows).map((row) => row.item);
|
|
101
97
|
const focus = (id) => {
|
|
102
98
|
const thread = threads.find((t) => t.id === id);
|
|
103
|
-
if (thread) (0, import_thread_state.focusThread)(editor, thread
|
|
99
|
+
if (thread) (0, import_thread_state.focusThread)(editor, thread);
|
|
104
100
|
};
|
|
105
|
-
|
|
101
|
+
const ThreadRow = options.components.ThreadRow;
|
|
102
|
+
const renderItem = ThreadRow ? (() => {
|
|
103
|
+
const threadsById = new Map(
|
|
104
|
+
threads.map((thread) => [thread.id, thread])
|
|
105
|
+
);
|
|
106
|
+
return (rowProps) => {
|
|
107
|
+
const thread = threadsById.get(rowProps.id);
|
|
108
|
+
if (!thread) return null;
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadRow, { ...rowProps, thread });
|
|
110
|
+
};
|
|
111
|
+
})() : void 0;
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SidebarPanel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
113
|
import_comments_list.CommentsList,
|
|
107
114
|
{
|
|
108
115
|
items,
|
|
109
116
|
header: header ?? msg("comments.title"),
|
|
110
|
-
headerAction: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cmt-list__header-actions", children: [
|
|
117
|
+
headerAction: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-cmt-list__header-actions", children: [
|
|
111
118
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
119
|
import_comments_filter_menu.CommentsFilterMenu,
|
|
113
120
|
{
|
|
114
|
-
canFilterByAuthor: currentUserId !==
|
|
121
|
+
canFilterByAuthor: currentUserId !== null,
|
|
115
122
|
canFilterByUnread: isCommentUnread !== void 0
|
|
116
123
|
}
|
|
117
124
|
),
|
|
118
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_comments_visibility_toggle.CommentsVisibilityToggle, {})
|
|
119
126
|
] }),
|
|
120
127
|
empty: items.length === 0 && pageThreads.length > 0 ? msg("comments.empty-filtered") : empty ?? msg("comments.empty"),
|
|
121
128
|
resolvedLabel: msg("comments.resolved"),
|
|
122
|
-
onSelect: focus
|
|
129
|
+
onSelect: focus,
|
|
130
|
+
renderItem
|
|
123
131
|
}
|
|
124
132
|
) });
|
|
125
133
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return (0, import_react_dom.createPortal)(
|
|
130
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, className: "cmt-canvas-sidebar", children }),
|
|
131
|
-
container
|
|
134
|
+
function sortSidebarRows(rows) {
|
|
135
|
+
return [...rows].sort(
|
|
136
|
+
(a, b) => Number(!!a.item.resolved) - Number(!!b.item.resolved) || b.lastActivity - a.lastActivity || (a.item.id < b.item.id ? -1 : 1)
|
|
132
137
|
);
|
|
133
138
|
}
|
|
139
|
+
function SidebarPanel({ children }) {
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tldraw.EditorPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-cmt-canvas-sidebar", onContextMenu: (e) => e.stopPropagation(), children }) });
|
|
141
|
+
}
|
|
134
142
|
//# sourceMappingURL=comments-sidebar.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/canvas/comments-sidebar.tsx"],
|
|
4
|
-
"sourcesContent": ["import { ReactNode,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { ReactNode, useCallback } from 'react'\nimport {\n\tEditorPortal,\n\tTLComment,\n\tTLCommentThread,\n\tuseEditor,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentListItemProps, CommentListItemRenderProps, CommentsList } from '../ui/comments-list'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { CommentsFilterMenu } from './comments-filter-menu'\nimport { CommentsVisibilityToggle } from './comments-visibility-toggle'\nimport { type CommentingContext } from './context'\nimport { useComments, useCommentThreads } from './hooks'\nimport { useCommentingEnabled } from './license'\nimport { useCommentingOptions } from './options'\nimport { richTextToPlaintext } from './rich-text'\nimport { commentsSidebarOpen, openThreadId, sidebarFilters } from './state'\nimport { focusThread } from './thread-state'\n\n/**\n * The host wiring for {@link CanvasCommentsSidebar}: the {@link CommentingContext} fields it reads,\n * plus the panel's own slots. A non-null `currentUserId` enables the \"only your threads\" filter, and\n * an `isCommentUnread` the \"only unread\" one. `CanvasComments` takes the same fields, so a host\n * mounting both can spread one object into each.\n *\n * @public\n */\nexport interface CanvasCommentsSidebarProps extends Pick<\n\tCommentingContext,\n\t'currentUserId' | 'resolveAuthor' | 'isCommentUnread' | 'getThreadHref'\n> {\n\t/** Header above the list. */\n\theader?: ReactNode\n\t/** Shown when the page has no threads. */\n\tempty?: ReactNode\n}\n\n/**\n * A comments list panel for the current page, shown while {@link commentsSidebarOpen} is set (e.g.\n * toggled by a button). Clicking a thread brings its pin into view and opens it. Batteries-included\n * over the store (a sibling to `CanvasComments`); `CommentsList` is exported for a differently-placed\n * or always-on list.\n * @public @react\n */\nexport function CanvasCommentsSidebar(props: CanvasCommentsSidebarProps) {\n\tconst { resolveAuthor, currentUserId, isCommentUnread, header, empty, getThreadHref } = props\n\t// Name-only view of the resolver, for the plaintext previews (which resolve @-mentions).\n\tconst resolveName = useCallback((id: string) => resolveAuthor(id)?.name, [resolveAuthor])\n\tconst editor = useEditor()\n\tconst options = useCommentingOptions()\n\tconst commentingEnabled = useCommentingEnabled()\n\tconst msg = useTranslation()\n\tconst threads = useCommentThreads(editor)\n\tconst comments = useComments(editor)\n\tconst currentPageId = useValue('page id', () => editor.getCurrentPageId(), [editor])\n\tconst open = useValue('sidebar open', () => commentsSidebarOpen.get(editor), [editor])\n\tconst openId = useValue('open thread', () => openThreadId.get(editor), [editor])\n\tconst filters = useValue('sidebar filters', () => sidebarFilters.get(editor), [editor])\n\tconst pageNames = useValue(\n\t\t'page names',\n\t\t() => new Map(editor.getPages().map((page) => [page.id, page.name])),\n\t\t[editor]\n\t)\n\n\tif (!commentingEnabled || !open) return null\n\n\t// Group comments by thread (they arrive oldest-first, so [0] is each thread's first comment).\n\tconst byThread = new Map<string, TLComment[]>()\n\tfor (const comment of comments) {\n\t\tconst list = byThread.get(comment.threadId) ?? []\n\t\tlist.push(comment)\n\t\tbyThread.set(comment.threadId, list)\n\t}\n\n\t// Page scoping is treated as scoping, not a filter: an empty page reads \"no comments yet\",\n\t// while a list emptied by the toggles below reads \"nothing matches your filters\".\n\tconst pageThreads = threads.filter(\n\t\t(thread) => !filters.onlyCurrentPage || thread.pageId === currentPageId\n\t)\n\n\tconst rows: SidebarRow[] = pageThreads\n\t\t.filter((thread) => filters.showResolved || thread.resolved == null)\n\t\t// \"Only mine\" is ignored without a known user \u2014 otherwise a persisted onlyMine=true would\n\t\t// empty the list for a signed-out viewer, with the (hidden) toggle giving no way to clear it.\n\t\t.filter(\n\t\t\t(thread) => !filters.onlyMine || currentUserId === null || thread.createdBy === currentUserId\n\t\t)\n\t\t// \"Only unread\" is likewise ignored without a read-status source.\n\t\t.filter(\n\t\t\t(thread) =>\n\t\t\t\t!filters.onlyUnread ||\n\t\t\t\tisCommentUnread === undefined ||\n\t\t\t\t(byThread.get(thread.id) ?? []).some((c) => isCommentUnread(c.id))\n\t\t)\n\t\t.map((thread) => {\n\t\t\tconst threadComments = byThread.get(thread.id) ?? []\n\t\t\tconst first = threadComments[0]\n\t\t\t// Comments arrive oldest-first, so the last one is the thread's most recent activity.\n\t\t\tconst last = threadComments[threadComments.length - 1]\n\t\t\tlet preview: ReactNode = ''\n\t\t\t// The `ThreadPreview` component slot overrides the built-in plaintext default.\n\t\t\tconst ThreadPreview = options.components.ThreadPreview\n\t\t\tif (first) {\n\t\t\t\tpreview = ThreadPreview ? (\n\t\t\t\t\t<ThreadPreview comment={first} />\n\t\t\t\t) : (\n\t\t\t\t\trichTextToPlaintext(first.body, resolveName)\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn {\n\t\t\t\titem: {\n\t\t\t\t\tid: thread.id,\n\t\t\t\t\tauthor: resolveAuthor(thread.createdBy) ?? UNKNOWN_COMMENT_AUTHOR,\n\t\t\t\t\tpreview,\n\t\t\t\t\tdate: new Date((first ?? thread).createdAt).toISOString(),\n\t\t\t\t\tresolved: thread.resolved != null,\n\t\t\t\t\t// The page label only earns its place when it adds information: multiple pages\n\t\t\t\t\t// exist, and the thread is somewhere other than where you already are.\n\t\t\t\t\tpage:\n\t\t\t\t\t\tpageNames.size > 1 && thread.pageId !== currentPageId\n\t\t\t\t\t\t\t? pageNames.get(thread.pageId)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcount: threadComments.length,\n\t\t\t\t\tselected: openId === thread.id,\n\t\t\t\t\thref: getThreadHref?.(thread.id),\n\t\t\t\t},\n\t\t\t\tlastActivity: (last ?? thread).createdAt,\n\t\t\t}\n\t\t})\n\n\tconst items = sortSidebarRows(rows).map((row) => row.item)\n\n\tconst focus = (id: string) => {\n\t\tconst thread = threads.find((t) => t.id === id)\n\t\tif (thread) focusThread(editor, thread)\n\t}\n\n\t// The `ThreadRow` component slot overrides the built-in row. It gets the thread record alongside\n\t// the summarized row, so host state on `thread.meta` is in reach without a second lookup. Indexed\n\t// once rather than scanned per row \u2014 this runs for every row on every render of the panel.\n\tconst ThreadRow = options.components.ThreadRow\n\tconst renderItem = ThreadRow\n\t\t? (() => {\n\t\t\t\t// Keyed by plain string: a row's id comes back as one, not as a branded thread id.\n\t\t\t\tconst threadsById = new Map<string, TLCommentThread>(\n\t\t\t\t\tthreads.map((thread) => [thread.id, thread])\n\t\t\t\t)\n\t\t\t\treturn (rowProps: CommentListItemRenderProps) => {\n\t\t\t\t\tconst thread = threadsById.get(rowProps.id)\n\t\t\t\t\t// Can't happen \u2014 the items are built from these threads \u2014 but a row with no thread has\n\t\t\t\t\t// nothing to render, and the slot's contract says the record is there.\n\t\t\t\t\tif (!thread) return null\n\t\t\t\t\treturn <ThreadRow {...rowProps} thread={thread} />\n\t\t\t\t}\n\t\t\t})()\n\t\t: undefined\n\n\treturn (\n\t\t<SidebarPanel>\n\t\t\t<CommentsList\n\t\t\t\titems={items}\n\t\t\t\theader={header ?? msg('comments.title')}\n\t\t\t\theaderAction={\n\t\t\t\t\t<div className=\"tlui-cmt-list__header-actions\">\n\t\t\t\t\t\t<CommentsFilterMenu\n\t\t\t\t\t\t\tcanFilterByAuthor={currentUserId !== null}\n\t\t\t\t\t\t\tcanFilterByUnread={isCommentUnread !== undefined}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommentsVisibilityToggle />\n\t\t\t\t\t</div>\n\t\t\t\t}\n\t\t\t\tempty={\n\t\t\t\t\titems.length === 0 && pageThreads.length > 0\n\t\t\t\t\t\t? msg('comments.empty-filtered')\n\t\t\t\t\t\t: (empty ?? msg('comments.empty'))\n\t\t\t\t}\n\t\t\t\tresolvedLabel={msg('comments.resolved')}\n\t\t\t\tonSelect={focus}\n\t\t\t\trenderItem={renderItem}\n\t\t\t/>\n\t\t</SidebarPanel>\n\t)\n}\n\n/** A list row paired with the sort key that isn't part of what the row displays. @public */\nexport interface SidebarRow {\n\titem: CommentListItemProps\n\t/** When the thread's most recent comment was posted \u2014 what the list orders by. */\n\tlastActivity: number\n}\n\n/**\n * Order the list: unresolved threads first, then by most recent activity, id as a stable tiebreak.\n * Recency is the thread's *latest* comment, not its first, so a thread someone just replied to rises\n * to the top instead of staying wherever it was started. (The row still shows the thread's opening\n * comment and its date \u2014 that's what identifies the thread; only the ordering follows the replies.)\n *\n * Exported so a hand-built list can match the sidebar's ordering instead of re-deriving it.\n *\n * @public\n */\nexport function sortSidebarRows(rows: readonly SidebarRow[]): readonly SidebarRow[] {\n\treturn [...rows].sort(\n\t\t(a, b) =>\n\t\t\tNumber(!!a.item.resolved) - Number(!!b.item.resolved) ||\n\t\t\tb.lastActivity - a.lastActivity ||\n\t\t\t(a.item.id < b.item.id ? -1 : 1)\n\t)\n}\n\n/** The sidebar surface, portaled into the container. It scrolls its own list, so \u2014 unlike tldraw's\n * wheel-transparent panels \u2014 a wheel over it doesn't pan the canvas. */\nfunction SidebarPanel({ children }: { children: ReactNode }) {\n\treturn (\n\t\t<EditorPortal>\n\t\t\t<div className=\"tlui-cmt-canvas-sidebar\" onContextMenu={(e) => e.stopPropagation()}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</EditorPortal>\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0GK;AA1GL,mBAAuC;AACvC,oBAOO;AACP,2BAA+E;AAC/E,4BAAuC;AACvC,kCAAmC;AACnC,wCAAyC;AAEzC,mBAA+C;AAC/C,qBAAqC;AACrC,qBAAqC;AACrC,uBAAoC;AACpC,mBAAkE;AAClE,0BAA4B;AA2BrB,SAAS,sBAAsB,OAAmC;AACxE,QAAM,EAAE,eAAe,eAAe,iBAAiB,QAAQ,OAAO,cAAc,IAAI;AAExF,QAAM,kBAAc,0BAAY,CAAC,OAAe,cAAc,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC;AACxF,QAAM,aAAS,yBAAU;AACzB,QAAM,cAAU,qCAAqB;AACrC,QAAM,wBAAoB,qCAAqB;AAC/C,QAAM,UAAM,8BAAe;AAC3B,QAAM,cAAU,gCAAkB,MAAM;AACxC,QAAM,eAAW,0BAAY,MAAM;AACnC,QAAM,oBAAgB,wBAAS,WAAW,MAAM,OAAO,iBAAiB,GAAG,CAAC,MAAM,CAAC;AACnF,QAAM,WAAO,wBAAS,gBAAgB,MAAM,iCAAoB,IAAI,MAAM,GAAG,CAAC,MAAM,CAAC;AACrF,QAAM,aAAS,wBAAS,eAAe,MAAM,0BAAa,IAAI,MAAM,GAAG,CAAC,MAAM,CAAC;AAC/E,QAAM,cAAU,wBAAS,mBAAmB,MAAM,4BAAe,IAAI,MAAM,GAAG,CAAC,MAAM,CAAC;AACtF,QAAM,gBAAY;AAAA,IACjB;AAAA,IACA,MAAM,IAAI,IAAI,OAAO,S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gB;AAAA,MAElC,eAAe,IAAI,mBAAmB;AAAA,MACtC,UAAU;AAAA,MACV;AAAA;AAAA,EACD,GACD;AAEF;AAmBO,SAAS,gBAAgB,MAAoD;AACnF,SAAO,CAAC,GAAG,IAAI,EAAE;AAAA,IAChB,CAAC,GAAG,MACH,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,KACpD,EAAE,eAAe,EAAE,iBAClB,EAAE,KAAK,KAAK,EAAE,KAAK,KAAK,KAAK;AAAA,EAChC;AACD;AAIA,SAAS,aAAa,EAAE,SAAS,GAA4B;AAC5D,SACC,4CAAC,8BACA,sDAAC,SAAI,WAAU,2BAA0B,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAC/E,UACF,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var comments_visibility_toggle_exports = {};
|
|
20
|
+
__export(comments_visibility_toggle_exports, {
|
|
21
|
+
CommentsVisibilityToggle: () => CommentsVisibilityToggle
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(comments_visibility_toggle_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_tldraw = require("tldraw");
|
|
26
|
+
var import_icons = require("../ui/icons");
|
|
27
|
+
var import_state = require("./state");
|
|
28
|
+
function CommentsVisibilityToggle() {
|
|
29
|
+
const editor = (0, import_tldraw.useEditor)();
|
|
30
|
+
const msg = (0, import_tldraw.useTranslation)();
|
|
31
|
+
const hidden = (0, import_tldraw.useValue)("comments hidden", () => import_state.commentsHidden.get(editor), [editor]);
|
|
32
|
+
const label = hidden ? msg("comments.show") : msg("comments.hide");
|
|
33
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
34
|
+
import_tldraw.TldrawUiButton,
|
|
35
|
+
{
|
|
36
|
+
type: "icon",
|
|
37
|
+
tooltip: label,
|
|
38
|
+
title: label,
|
|
39
|
+
className: "tlui-cmt-header-btn",
|
|
40
|
+
onClick: () => (0, import_state.toggleCommentsHidden)(editor),
|
|
41
|
+
children: hidden ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EyeClosedIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EyeOpenIcon, {})
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=comments-visibility-toggle.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/comments-visibility-toggle.tsx"],
|
|
4
|
+
"sourcesContent": ["import { TldrawUiButton, useEditor, useTranslation, useValue } from 'tldraw'\nimport { EyeClosedIcon, EyeOpenIcon } from '../ui/icons'\nimport { commentsHidden, toggleCommentsHidden } from './state'\n\n/** The sidebar header's show/hide toggle for comment pins \u2014 an eye that closes while comments\n * are hidden. The same state as the Shift+C shortcut.\n * @public @react */\nexport function CommentsVisibilityToggle() {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst hidden = useValue('comments hidden', () => commentsHidden.get(editor), [editor])\n\tconst label = hidden ? msg('comments.show') : msg('comments.hide')\n\n\treturn (\n\t\t<TldrawUiButton\n\t\t\ttype=\"icon\"\n\t\t\ttooltip={label}\n\t\t\ttitle={label}\n\t\t\tclassName=\"tlui-cmt-header-btn\"\n\t\t\tonClick={() => toggleCommentsHidden(editor)}\n\t\t>\n\t\t\t{hidden ? <EyeClosedIcon /> : <EyeOpenIcon />}\n\t\t</TldrawUiButton>\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBa;AArBb,oBAAoE;AACpE,mBAA2C;AAC3C,mBAAqD;AAK9C,SAAS,2BAA2B;AAC1C,QAAM,aAAS,yBAAU;AACzB,QAAM,UAAM,8BAAe;AAC3B,QAAM,aAAS,wBAAS,mBAAmB,MAAM,4BAAe,IAAI,MAAM,GAAG,CAAC,MAAM,CAAC;AACrF,QAAM,QAAQ,SAAS,IAAI,eAAe,IAAI,IAAI,eAAe;AAEjE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,MACP,WAAU;AAAA,MACV,SAAS,UAAM,mCAAqB,MAAM;AAAA,MAEzC,mBAAS,4CAAC,8BAAc,IAAK,4CAAC,4BAAY;AAAA;AAAA,EAC5C;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var context_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(context_exports);
|
|
17
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/context.ts"],
|
|
4
|
+
"sourcesContent": ["import { type CommentAuthor, type MentionMember } from '@tldraw/mentions'\nimport { type ReactNode } from 'react'\nimport { type TLComment, type TLCommentId, type TLCommentThreadId } from 'tldraw'\n\n/**\n * The live, host-supplied half of commenting: who the viewer is, how author ids become names, read\n * status, and the mention roster. (The static half is {@link CommentingOptions}, configured once on\n * the tool.)\n *\n * Every commenting surface reads the same set, so a host mounting more than one \u2014 `CanvasComments`\n * and `CanvasCommentsSidebar`, say \u2014 can build it once and spread it into each rather than\n * repeating the props:\n *\n * ```tsx\n * const commenting: CommentingContext = { currentUserId, resolveAuthor, isCommentUnread }\n *\n * <CanvasComments {...commenting} />\n * <CanvasCommentsSidebar {...commenting} />\n * ```\n *\n * @public\n */\nexport interface CommentingContext {\n\t/** The signed-in user's id, or null for a read-only viewer. Only a signed-in user composes. */\n\tcurrentUserId: string | null\n\t/** Map an author id to their display info, or `undefined` when the id can't be resolved. */\n\tresolveAuthor(id: string): CommentAuthor | undefined\n\t/** Called after any comment (a new thread's first comment, or a reply) is posted. */\n\tonPostComment?(comment: TLComment): void\n\t/** Whether a comment is unread for the current user (return true for unread). */\n\tisCommentUnread?(commentId: TLCommentId): boolean\n\t/**\n\t * Called with every unread comment shown to the user in an open thread popover, batched per\n\t * report, so hosts can record read receipts without a write per comment. Needs\n\t * `isCommentUnread` to know what's unread.\n\t */\n\tonCommentsRead?(commentIds: TLCommentId[]): void\n\t/** Resolve the members matching an `@`-query in the composers (sync or async). */\n\tgetMentionSuggestions?(query: string): MentionMember[] | Promise<MentionMember[]>\n\t/** Override a mention-picker row's content. */\n\trenderMentionSuggestion?(member: MentionMember): ReactNode\n\t/**\n\t * The host's URL for a thread, so surfaces can link to it \u2014 e.g. the sidebar's rows render as\n\t * anchors when this is present, letting ctrl/cmd-click and middle-click open the thread in a\n\t * new tab (a plain click still selects the thread in place; the href isn't followed).\n\t */\n\tgetThreadHref?(threadId: TLCommentThreadId): string | undefined\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|