@tldraw/commenting 0.0.0-bootstrap
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 +11 -0
- package/commenting.css +832 -0
- package/dist-cjs/canvas/cluster-input.js +40 -0
- package/dist-cjs/canvas/cluster-input.js.map +7 -0
- package/dist-cjs/canvas/comment-body.js +31 -0
- package/dist-cjs/canvas/comment-body.js.map +7 -0
- package/dist-cjs/canvas/comment-render.js +72 -0
- package/dist-cjs/canvas/comment-render.js.map +7 -0
- package/dist-cjs/canvas/comment-store.js +48 -0
- package/dist-cjs/canvas/comment-store.js.map +7 -0
- package/dist-cjs/canvas/comment-tool.js +160 -0
- package/dist-cjs/canvas/comment-tool.js.map +7 -0
- package/dist-cjs/canvas/comments-filter-menu.js +109 -0
- package/dist-cjs/canvas/comments-filter-menu.js.map +7 -0
- package/dist-cjs/canvas/comments-menu-item.js +42 -0
- package/dist-cjs/canvas/comments-menu-item.js.map +7 -0
- package/dist-cjs/canvas/comments-overflow-menu.js +64 -0
- package/dist-cjs/canvas/comments-overflow-menu.js.map +7 -0
- package/dist-cjs/canvas/comments-overlay.js +1081 -0
- package/dist-cjs/canvas/comments-overlay.js.map +7 -0
- package/dist-cjs/canvas/comments-sidebar.js +134 -0
- package/dist-cjs/canvas/comments-sidebar.js.map +7 -0
- package/dist-cjs/canvas/hooks.js +45 -0
- package/dist-cjs/canvas/hooks.js.map +7 -0
- package/dist-cjs/canvas/license.js +28 -0
- package/dist-cjs/canvas/license.js.map +7 -0
- package/dist-cjs/canvas/options.js +45 -0
- package/dist-cjs/canvas/options.js.map +7 -0
- package/dist-cjs/canvas/region-options.js +49 -0
- package/dist-cjs/canvas/region-options.js.map +7 -0
- package/dist-cjs/canvas/rich-text.js +28 -0
- package/dist-cjs/canvas/rich-text.js.map +7 -0
- package/dist-cjs/canvas/sidebar-filters.js +30 -0
- package/dist-cjs/canvas/sidebar-filters.js.map +7 -0
- package/dist-cjs/canvas/state.js +76 -0
- package/dist-cjs/canvas/state.js.map +7 -0
- package/dist-cjs/canvas/thread-state.js +81 -0
- package/dist-cjs/canvas/thread-state.js.map +7 -0
- package/dist-cjs/clustering/computeClusterTable.js +83 -0
- package/dist-cjs/clustering/computeClusterTable.js.map +7 -0
- package/dist-cjs/clustering/mst.js +117 -0
- package/dist-cjs/clustering/mst.js.map +7 -0
- package/dist-cjs/clustering/replay.js +275 -0
- package/dist-cjs/clustering/replay.js.map +7 -0
- package/dist-cjs/clustering/runtime.js +134 -0
- package/dist-cjs/clustering/runtime.js.map +7 -0
- package/dist-cjs/clustering/schedule.js +170 -0
- package/dist-cjs/clustering/schedule.js.map +7 -0
- package/dist-cjs/clustering/types.js +17 -0
- package/dist-cjs/clustering/types.js.map +7 -0
- package/dist-cjs/index.d.ts +868 -0
- package/dist-cjs/index.js +126 -0
- package/dist-cjs/index.js.map +7 -0
- package/dist-cjs/ui/avatar.js +43 -0
- package/dist-cjs/ui/avatar.js.map +7 -0
- package/dist-cjs/ui/byline.js +35 -0
- package/dist-cjs/ui/byline.js.map +7 -0
- package/dist-cjs/ui/comment-card.js +37 -0
- package/dist-cjs/ui/comment-card.js.map +7 -0
- package/dist-cjs/ui/comment-composer.js +136 -0
- package/dist-cjs/ui/comment-composer.js.map +7 -0
- package/dist-cjs/ui/comment-extensions.js +37 -0
- package/dist-cjs/ui/comment-extensions.js.map +7 -0
- package/dist-cjs/ui/comment-mention.js +42 -0
- package/dist-cjs/ui/comment-mention.js.map +7 -0
- package/dist-cjs/ui/comment-pin.js +29 -0
- package/dist-cjs/ui/comment-pin.js.map +7 -0
- package/dist-cjs/ui/comment-text.js +29 -0
- package/dist-cjs/ui/comment-text.js.map +7 -0
- package/dist-cjs/ui/comment-thread.js +45 -0
- package/dist-cjs/ui/comment-thread.js.map +7 -0
- package/dist-cjs/ui/comments-list.js +106 -0
- package/dist-cjs/ui/comments-list.js.map +7 -0
- package/dist-cjs/ui/count-badge.js +28 -0
- package/dist-cjs/ui/count-badge.js.map +7 -0
- package/dist-cjs/ui/empty-state.js +31 -0
- package/dist-cjs/ui/empty-state.js.map +7 -0
- package/dist-cjs/ui/format-time.js +46 -0
- package/dist-cjs/ui/format-time.js.map +7 -0
- package/dist-cjs/ui/mention-list.js +70 -0
- package/dist-cjs/ui/mention-list.js.map +7 -0
- package/dist-cjs/ui/mention-suggestion.js +206 -0
- package/dist-cjs/ui/mention-suggestion.js.map +7 -0
- package/dist-cjs/ui/mention.js +31 -0
- package/dist-cjs/ui/mention.js.map +7 -0
- package/dist-cjs/ui/reaction.js +31 -0
- package/dist-cjs/ui/reaction.js.map +7 -0
- package/dist-cjs/ui/reactions.js +34 -0
- package/dist-cjs/ui/reactions.js.map +7 -0
- package/dist-cjs/ui/render-markdown.js +63 -0
- package/dist-cjs/ui/render-markdown.js.map +7 -0
- package/dist-cjs/ui/send-button.js +28 -0
- package/dist-cjs/ui/send-button.js.map +7 -0
- package/dist-esm/canvas/cluster-input.mjs +20 -0
- package/dist-esm/canvas/cluster-input.mjs.map +7 -0
- package/dist-esm/canvas/comment-body.mjs +11 -0
- package/dist-esm/canvas/comment-body.mjs.map +7 -0
- package/dist-esm/canvas/comment-render.mjs +52 -0
- package/dist-esm/canvas/comment-render.mjs.map +7 -0
- package/dist-esm/canvas/comment-store.mjs +28 -0
- package/dist-esm/canvas/comment-store.mjs.map +7 -0
- package/dist-esm/canvas/comment-tool.mjs +142 -0
- package/dist-esm/canvas/comment-tool.mjs.map +7 -0
- package/dist-esm/canvas/comments-filter-menu.mjs +99 -0
- package/dist-esm/canvas/comments-filter-menu.mjs.map +7 -0
- package/dist-esm/canvas/comments-menu-item.mjs +22 -0
- package/dist-esm/canvas/comments-menu-item.mjs.map +7 -0
- package/dist-esm/canvas/comments-overflow-menu.mjs +53 -0
- package/dist-esm/canvas/comments-overflow-menu.mjs.map +7 -0
- package/dist-esm/canvas/comments-overlay.mjs +1094 -0
- package/dist-esm/canvas/comments-overlay.mjs.map +7 -0
- package/dist-esm/canvas/comments-sidebar.mjs +120 -0
- package/dist-esm/canvas/comments-sidebar.mjs.map +7 -0
- package/dist-esm/canvas/hooks.mjs +25 -0
- package/dist-esm/canvas/hooks.mjs.map +7 -0
- package/dist-esm/canvas/license.mjs +8 -0
- package/dist-esm/canvas/license.mjs.map +7 -0
- package/dist-esm/canvas/options.mjs +27 -0
- package/dist-esm/canvas/options.mjs.map +7 -0
- package/dist-esm/canvas/region-options.mjs +29 -0
- package/dist-esm/canvas/region-options.mjs.map +7 -0
- package/dist-esm/canvas/rich-text.mjs +8 -0
- package/dist-esm/canvas/rich-text.mjs.map +7 -0
- package/dist-esm/canvas/sidebar-filters.mjs +10 -0
- package/dist-esm/canvas/sidebar-filters.mjs.map +7 -0
- package/dist-esm/canvas/state.mjs +60 -0
- package/dist-esm/canvas/state.mjs.map +7 -0
- package/dist-esm/canvas/thread-state.mjs +61 -0
- package/dist-esm/canvas/thread-state.mjs.map +7 -0
- package/dist-esm/clustering/computeClusterTable.mjs +63 -0
- package/dist-esm/clustering/computeClusterTable.mjs.map +7 -0
- package/dist-esm/clustering/mst.mjs +97 -0
- package/dist-esm/clustering/mst.mjs.map +7 -0
- package/dist-esm/clustering/replay.mjs +255 -0
- package/dist-esm/clustering/replay.mjs.map +7 -0
- package/dist-esm/clustering/runtime.mjs +114 -0
- package/dist-esm/clustering/runtime.mjs.map +7 -0
- package/dist-esm/clustering/schedule.mjs +150 -0
- package/dist-esm/clustering/schedule.mjs.map +7 -0
- package/dist-esm/clustering/types.mjs +1 -0
- package/dist-esm/clustering/types.mjs.map +7 -0
- package/dist-esm/index.d.mts +868 -0
- package/dist-esm/index.mjs +139 -0
- package/dist-esm/index.mjs.map +7 -0
- package/dist-esm/ui/avatar.mjs +23 -0
- package/dist-esm/ui/avatar.mjs.map +7 -0
- package/dist-esm/ui/byline.mjs +15 -0
- package/dist-esm/ui/byline.mjs.map +7 -0
- package/dist-esm/ui/comment-card.mjs +17 -0
- package/dist-esm/ui/comment-card.mjs.map +7 -0
- package/dist-esm/ui/comment-composer.mjs +116 -0
- package/dist-esm/ui/comment-composer.mjs.map +7 -0
- package/dist-esm/ui/comment-extensions.mjs +17 -0
- package/dist-esm/ui/comment-extensions.mjs.map +7 -0
- package/dist-esm/ui/comment-mention.mjs +22 -0
- package/dist-esm/ui/comment-mention.mjs.map +7 -0
- package/dist-esm/ui/comment-pin.mjs +9 -0
- package/dist-esm/ui/comment-pin.mjs.map +7 -0
- package/dist-esm/ui/comment-text.mjs +9 -0
- package/dist-esm/ui/comment-text.mjs.map +7 -0
- package/dist-esm/ui/comment-thread.mjs +25 -0
- package/dist-esm/ui/comment-thread.mjs.map +7 -0
- package/dist-esm/ui/comments-list.mjs +86 -0
- package/dist-esm/ui/comments-list.mjs.map +7 -0
- package/dist-esm/ui/count-badge.mjs +8 -0
- package/dist-esm/ui/count-badge.mjs.map +7 -0
- package/dist-esm/ui/empty-state.mjs +11 -0
- package/dist-esm/ui/empty-state.mjs.map +7 -0
- package/dist-esm/ui/format-time.mjs +26 -0
- package/dist-esm/ui/format-time.mjs.map +7 -0
- package/dist-esm/ui/mention-list.mjs +50 -0
- package/dist-esm/ui/mention-list.mjs.map +7 -0
- package/dist-esm/ui/mention-suggestion.mjs +186 -0
- package/dist-esm/ui/mention-suggestion.mjs.map +7 -0
- package/dist-esm/ui/mention.mjs +11 -0
- package/dist-esm/ui/mention.mjs.map +7 -0
- package/dist-esm/ui/reaction.mjs +11 -0
- package/dist-esm/ui/reaction.mjs.map +7 -0
- package/dist-esm/ui/reactions.mjs +14 -0
- package/dist-esm/ui/reactions.mjs.map +7 -0
- package/dist-esm/ui/render-markdown.mjs +45 -0
- package/dist-esm/ui/render-markdown.mjs.map +7 -0
- package/dist-esm/ui/send-button.mjs +8 -0
- package/dist-esm/ui/send-button.mjs.map +7 -0
- package/package.json +71 -0
- package/src/canvas/canvas.css +148 -0
- package/src/canvas/cluster-input.test.ts +223 -0
- package/src/canvas/cluster-input.ts +29 -0
- package/src/canvas/comment-body.tsx +21 -0
- package/src/canvas/comment-render.test.ts +90 -0
- package/src/canvas/comment-render.ts +92 -0
- package/src/canvas/comment-store.ts +55 -0
- package/src/canvas/comment-tool.tsx +200 -0
- package/src/canvas/comments-filter-menu.tsx +104 -0
- package/src/canvas/comments-menu-item.tsx +24 -0
- package/src/canvas/comments-overflow-menu.tsx +62 -0
- package/src/canvas/comments-overlay.tsx +1460 -0
- package/src/canvas/comments-sidebar.tsx +184 -0
- package/src/canvas/hooks.ts +28 -0
- package/src/canvas/license.ts +15 -0
- package/src/canvas/options.test.ts +127 -0
- package/src/canvas/options.ts +111 -0
- package/src/canvas/region-options.ts +57 -0
- package/src/canvas/rich-text.ts +15 -0
- package/src/canvas/sidebar-filters.ts +25 -0
- package/src/canvas/state.ts +102 -0
- package/src/canvas/thread-state.ts +91 -0
- package/src/clustering/computeClusterTable.test.ts +299 -0
- package/src/clustering/computeClusterTable.ts +82 -0
- package/src/clustering/locality.test.ts +189 -0
- package/src/clustering/mst.test.ts +383 -0
- package/src/clustering/mst.ts +134 -0
- package/src/clustering/replay.test.ts +547 -0
- package/src/clustering/replay.ts +326 -0
- package/src/clustering/runtime.test.ts +596 -0
- package/src/clustering/runtime.ts +153 -0
- package/src/clustering/schedule.test.ts +514 -0
- package/src/clustering/schedule.ts +184 -0
- package/src/clustering/types.ts +102 -0
- package/src/index.ts +96 -0
- package/src/ui/avatar.tsx +31 -0
- package/src/ui/byline.tsx +23 -0
- package/src/ui/comment-card.tsx +32 -0
- package/src/ui/comment-composer.tsx +179 -0
- package/src/ui/comment-extensions.ts +25 -0
- package/src/ui/comment-mention.ts +47 -0
- package/src/ui/comment-pin.tsx +21 -0
- package/src/ui/comment-text.tsx +12 -0
- package/src/ui/comment-thread.tsx +56 -0
- package/src/ui/comments-list.tsx +139 -0
- package/src/ui/comments.css +678 -0
- package/src/ui/count-badge.tsx +9 -0
- package/src/ui/empty-state.tsx +16 -0
- package/src/ui/format-time.ts +29 -0
- package/src/ui/mention-list.tsx +106 -0
- package/src/ui/mention-suggestion.test.ts +18 -0
- package/src/ui/mention-suggestion.tsx +285 -0
- package/src/ui/mention.tsx +9 -0
- package/src/ui/reaction.tsx +16 -0
- package/src/ui/reactions.tsx +15 -0
- package/src/ui/render-markdown.tsx +72 -0
- package/src/ui/send-button.tsx +15 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;AAAA;AAuHE;AAvHF,mBAUO;AACP,uBAA6B;AAC7B,oBAmBO;AACP,iCAAoC;AACpC,qBAA0D;AAE1D,0BAA8C;AAC9C,8BAAgC;AAChC,gCAA8C;AAC9C,yBAA2B;AAC3B,4BAA8B;AAC9B,yBAA2B;AAE3B,gCAAoC;AACpC,2BAAqC;AACrC,0BAA4B;AAC5B,4BAA+B;AAC/B,2BAA0E;AAE1E,mBAAqD;AACrD,qBAAqC;AACrC,qBAKO;AACP,4BAIO;AACP,mBAQO;AACP,0BAA+D;AAsC/D,MAAM,OAAO,CAAC,MAAmC,EAAE,gBAAgB;AAEnE,MAAM,YAAY,CAAC,cAA0B,iCAAkB,KAAK,KAAK,CAAC,KAAK,KAAK,YAAY;AAChG,MAAM,kBAAkB;AAExB,MAAM,yBAAyB;AAI/B,MAAM,cACL,4CAAC,iCACA;AAAA,EAAC;AAAA;AAAA,IACA,SAAQ;AAAA,IACR,OAAM;AAAA,IACN,QAAO;AAAA,IACP,MAAK;AAAA,IACL,QAAO;AAAA,IACP,aAAY;AAAA,IACZ,eAAc;AAAA,IACd,gBAAe;AAAA,IACf,eAAY;AAAA,IAEZ;AAAA,kDAAC,UAAK,GAAE,YAAW;AAAA,MACnB,4CAAC,UAAK,GAAE,0DAAyD;AAAA;AAAA;AAClE,GACD;AA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P,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": ["ClusterBadge", "ThreadPin"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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_sidebar_exports = {};
|
|
20
|
+
__export(comments_sidebar_exports, {
|
|
21
|
+
CanvasCommentsSidebar: () => CanvasCommentsSidebar
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(comments_sidebar_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_react_dom = require("react-dom");
|
|
27
|
+
var import_tldraw = require("tldraw");
|
|
28
|
+
var import_comments_list = require("../ui/comments-list");
|
|
29
|
+
var import_comment_render = require("./comment-render");
|
|
30
|
+
var import_comments_filter_menu = require("./comments-filter-menu");
|
|
31
|
+
var import_comments_overflow_menu = require("./comments-overflow-menu");
|
|
32
|
+
var import_hooks = require("./hooks");
|
|
33
|
+
var import_license = require("./license");
|
|
34
|
+
var import_options = require("./options");
|
|
35
|
+
var import_rich_text = require("./rich-text");
|
|
36
|
+
var import_state = require("./state");
|
|
37
|
+
var import_thread_state = require("./thread-state");
|
|
38
|
+
function CanvasCommentsSidebar(props) {
|
|
39
|
+
const {
|
|
40
|
+
resolveName,
|
|
41
|
+
currentUserId,
|
|
42
|
+
isCommentUnread,
|
|
43
|
+
tools,
|
|
44
|
+
header,
|
|
45
|
+
empty,
|
|
46
|
+
impreciseShapeAnchor
|
|
47
|
+
} = props;
|
|
48
|
+
const editor = (0, import_tldraw.useEditor)();
|
|
49
|
+
const options = (0, import_options.useCommentingOptions)();
|
|
50
|
+
const sidebarTools = tools ?? ["comment"];
|
|
51
|
+
const container = (0, import_tldraw.useContainer)();
|
|
52
|
+
const commentingEnabled = (0, import_license.useCommentingEnabled)();
|
|
53
|
+
const msg = (0, import_tldraw.useTranslation)();
|
|
54
|
+
const threads = (0, import_hooks.useCommentThreads)(editor);
|
|
55
|
+
const comments = (0, import_hooks.useComments)(editor);
|
|
56
|
+
const currentPageId = (0, import_tldraw.useValue)("page id", () => editor.getCurrentPageId(), [editor]);
|
|
57
|
+
const activeTool = (0, import_tldraw.useValue)("tool id", () => editor.getCurrentToolId(), [editor]);
|
|
58
|
+
const openId = (0, import_tldraw.useValue)("open thread", () => import_state.openThreadId.get(editor), [editor]);
|
|
59
|
+
const filters = (0, import_tldraw.useValue)("sidebar filters", () => import_state.sidebarFilters.get(editor), [editor]);
|
|
60
|
+
const pageNames = (0, import_tldraw.useValue)(
|
|
61
|
+
"page names",
|
|
62
|
+
() => new Map(editor.getPages().map((page) => [page.id, page.name])),
|
|
63
|
+
[editor]
|
|
64
|
+
);
|
|
65
|
+
if (!commentingEnabled || !sidebarTools.includes(activeTool)) return null;
|
|
66
|
+
const byThread = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const comment of comments) {
|
|
68
|
+
const list = byThread.get(comment.threadId) ?? [];
|
|
69
|
+
list.push(comment);
|
|
70
|
+
byThread.set(comment.threadId, list);
|
|
71
|
+
}
|
|
72
|
+
const pageThreads = threads.filter(
|
|
73
|
+
(thread) => !filters.onlyCurrentPage || thread.pageId === currentPageId
|
|
74
|
+
);
|
|
75
|
+
const items = pageThreads.filter((thread) => filters.showResolved || thread.resolved == null).filter(
|
|
76
|
+
(thread) => !filters.onlyMine || currentUserId === void 0 || thread.createdBy === currentUserId
|
|
77
|
+
).filter(
|
|
78
|
+
(thread) => !filters.onlyUnread || isCommentUnread === void 0 || (byThread.get(thread.id) ?? []).some((c) => isCommentUnread(c.id))
|
|
79
|
+
).map((thread) => {
|
|
80
|
+
const threadComments = byThread.get(thread.id) ?? [];
|
|
81
|
+
const first = threadComments[0];
|
|
82
|
+
let preview = "";
|
|
83
|
+
const ThreadPreview = options.components.ThreadPreview;
|
|
84
|
+
if (first) {
|
|
85
|
+
preview = ThreadPreview ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThreadPreview, { comment: first }) : (0, import_rich_text.richTextToPlaintext)(first.body, resolveName);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
id: thread.id,
|
|
89
|
+
author: resolveName(thread.createdBy) ?? import_comment_render.UNKNOWN_AUTHOR,
|
|
90
|
+
preview,
|
|
91
|
+
date: new Date((first ?? thread).createdAt).toISOString(),
|
|
92
|
+
resolved: thread.resolved != null,
|
|
93
|
+
page: pageNames.get(thread.pageId),
|
|
94
|
+
count: threadComments.length,
|
|
95
|
+
selected: openId === thread.id
|
|
96
|
+
};
|
|
97
|
+
}).sort((a, b) => {
|
|
98
|
+
if (!!a.resolved !== !!b.resolved) return a.resolved ? 1 : -1;
|
|
99
|
+
return b.date.localeCompare(a.date);
|
|
100
|
+
});
|
|
101
|
+
const focus = (id) => {
|
|
102
|
+
const thread = threads.find((t) => t.id === id);
|
|
103
|
+
if (thread) (0, import_thread_state.focusThread)(editor, thread, impreciseShapeAnchor ?? options.impreciseShapeAnchor);
|
|
104
|
+
};
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SidebarPanel, { container, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
import_comments_list.CommentsList,
|
|
107
|
+
{
|
|
108
|
+
items,
|
|
109
|
+
header: header ?? msg("comments.title"),
|
|
110
|
+
headerAction: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cmt-list__header-actions", children: [
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
+
import_comments_filter_menu.CommentsFilterMenu,
|
|
113
|
+
{
|
|
114
|
+
canFilterByAuthor: currentUserId !== void 0,
|
|
115
|
+
canFilterByUnread: isCommentUnread !== void 0
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_comments_overflow_menu.CommentsOverflowMenu, {})
|
|
119
|
+
] }),
|
|
120
|
+
empty: items.length === 0 && pageThreads.length > 0 ? msg("comments.empty-filtered") : empty ?? msg("comments.empty"),
|
|
121
|
+
resolvedLabel: msg("comments.resolved"),
|
|
122
|
+
onSelect: focus
|
|
123
|
+
}
|
|
124
|
+
) });
|
|
125
|
+
}
|
|
126
|
+
function SidebarPanel({ container, children }) {
|
|
127
|
+
const ref = (0, import_react.useRef)(null);
|
|
128
|
+
(0, import_tldraw.usePassThroughMouseOverEvents)(ref);
|
|
129
|
+
return (0, import_react_dom.createPortal)(
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, className: "cmt-canvas-sidebar", children }),
|
|
131
|
+
container
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=comments-sidebar.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/comments-sidebar.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ReactNode, useRef } from 'react'\nimport { createPortal } from 'react-dom'\nimport {\n\tTLComment,\n\tTLCommentId,\n\tuseContainer,\n\tuseEditor,\n\tusePassThroughMouseOverEvents,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentListItemProps, CommentsList } from '../ui/comments-list'\nimport { UNKNOWN_AUTHOR } from './comment-render'\nimport { CommentsFilterMenu } from './comments-filter-menu'\nimport { CommentsOverflowMenu } from './comments-overflow-menu'\nimport { useComments, useCommentThreads } from './hooks'\nimport { useCommentingEnabled } from './license'\nimport { useCommentingOptions } from './options'\nimport { richTextToPlaintext } from './rich-text'\nimport { openThreadId, sidebarFilters } from './state'\nimport { focusThread } from './thread-state'\n\n/** @public */\nexport interface CanvasCommentsSidebarProps {\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/** The signed-in user's id. Enables the \"only your threads\" filter when present. */\n\tcurrentUserId?: string\n\t/**\n\t * Whether a comment is unread for the current user (return true for unread). Enables the\n\t * \"only unread\" filter when present.\n\t */\n\tisCommentUnread?(commentId: TLCommentId): boolean\n\t/** Tool ids that show the sidebar. Defaults to the comment tool. */\n\ttools?: string[]\n\t/** Header above the list. */\n\theader?: ReactNode\n\t/** Shown when the page has no threads. */\n\tempty?: ReactNode\n\t/** Where imprecise shape pins sit, so navigation centres on the same spot. Default top-right. */\n\timpreciseShapeAnchor?: { x: number; y: number }\n}\n\n/**\n * A comments list panel for the current page, shown while the comment tool is active. Clicking a\n * thread brings its pin into view and opens it. Batteries-included over the store (a sibling to\n * `CanvasComments`); `CommentsList` is exported for a differently-placed or always-on list.\n * @public @react\n */\nexport function CanvasCommentsSidebar(props: CanvasCommentsSidebarProps) {\n\tconst {\n\t\tresolveName,\n\t\tcurrentUserId,\n\t\tisCommentUnread,\n\t\ttools,\n\t\theader,\n\t\tempty,\n\t\timpreciseShapeAnchor,\n\t} = props\n\tconst editor = useEditor()\n\tconst options = useCommentingOptions()\n\tconst sidebarTools = tools ?? ['comment']\n\tconst container = useContainer()\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 activeTool = useValue('tool id', () => editor.getCurrentToolId(), [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 || !sidebarTools.includes(activeTool)) 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 items: CommentListItemProps[] = 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) =>\n\t\t\t\t!filters.onlyMine || currentUserId === undefined || 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\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\tid: thread.id,\n\t\t\t\tauthor: resolveName(thread.createdBy) ?? UNKNOWN_AUTHOR,\n\t\t\t\tpreview,\n\t\t\t\tdate: new Date((first ?? thread).createdAt).toISOString(),\n\t\t\t\tresolved: thread.resolved != null,\n\t\t\t\tpage: pageNames.get(thread.pageId),\n\t\t\t\tcount: threadComments.length,\n\t\t\t\tselected: openId === thread.id,\n\t\t\t}\n\t\t})\n\t\t// unresolved first, then most-recent first\n\t\t.sort((a, b) => {\n\t\t\tif (!!a.resolved !== !!b.resolved) return a.resolved ? 1 : -1\n\t\t\treturn b.date.localeCompare(a.date)\n\t\t})\n\n\tconst focus = (id: string) => {\n\t\tconst thread = threads.find((t) => t.id === id)\n\t\t// Resolve prop-or-option like the overlay pins do, so sidebar navigation centers on the same\n\t\t// spot the pin renders at when the anchor is configured via `CommentTool.configure`.\n\t\tif (thread) focusThread(editor, thread, impreciseShapeAnchor ?? options.impreciseShapeAnchor)\n\t}\n\n\treturn (\n\t\t<SidebarPanel container={container}>\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=\"cmt-list__header-actions\">\n\t\t\t\t\t\t<CommentsFilterMenu\n\t\t\t\t\t\t\tcanFilterByAuthor={currentUserId !== undefined}\n\t\t\t\t\t\t\tcanFilterByUnread={isCommentUnread !== undefined}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<CommentsOverflowMenu />\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/>\n\t\t</SidebarPanel>\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. Hover still passes through so\n * shapes beneath it stay interactive. */\nfunction SidebarPanel({ container, children }: { container: HTMLElement; children: ReactNode }) {\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughMouseOverEvents(ref)\n\treturn createPortal(\n\t\t<div ref={ref} className=\"cmt-canvas-sidebar\">\n\t\t\t{children}\n\t\t</div>,\n\t\tcontainer\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoHK;AApHL,mBAAkC;AAClC,uBAA6B;AAC7B,oBAQO;AACP,2BAAmD;AACnD,4BAA+B;AAC/B,kCAAmC;AACnC,oCAAqC;AACrC,mBAA+C;AAC/C,qBAAqC;AACrC,qBAAqC;AACrC,uBAAoC;AACpC,mBAA6C;AAC7C,0BAA4B;AA6BrB,SAAS,sBAAsB,OAAmC;AACxE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,QAAM,aAAS,yBAAU;AACzB,QAAM,cAAU,qCAAqB;AACrC,QAAM,eAAe,SAAS,CAAC,SAAS;AACxC,QAAM,gBAAY,4BAAa;AAC/B,QAAM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AAqB;AAAA,SACvB;AAAA,MAED,OACC,MAAM,WAAW,KAAK,YAAY,SAAS,IACxC,IAAI,yBAAyB,IAC5B,SAAS,IAAI,gBAAgB;AAAA,MAElC,eAAe,IAAI,mBAAmB;AAAA,MACtC,UAAU;AAAA;AAAA,EACX,GACD;AAEF;AAKA,SAAS,aAAa,EAAE,WAAW,SAAS,GAAoD;AAC/F,QAAM,UAAM,qBAAuB,IAAI;AACvC,mDAA8B,GAAG;AACjC,aAAO;AAAA,IACN,4CAAC,SAAI,KAAU,WAAU,sBACvB,UACF;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
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 hooks_exports = {};
|
|
20
|
+
__export(hooks_exports, {
|
|
21
|
+
useCommentThreads: () => useCommentThreads,
|
|
22
|
+
useComments: () => useComments,
|
|
23
|
+
useThreadComments: () => useThreadComments
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
26
|
+
var import_tldraw = require("tldraw");
|
|
27
|
+
var import_comment_store = require("./comment-store");
|
|
28
|
+
function useCommentThreads(editor) {
|
|
29
|
+
return (0, import_tldraw.useValue)("comment threads", () => (0, import_comment_store.getCommentThreads)(editor), [editor]);
|
|
30
|
+
}
|
|
31
|
+
function useThreadComments(editor, threadId) {
|
|
32
|
+
return (0, import_tldraw.useValue)(
|
|
33
|
+
"thread comments",
|
|
34
|
+
() => (0, import_comment_store.getComments)(editor).filter((c) => c.threadId === threadId).sort((a, b) => a.createdAt - b.createdAt),
|
|
35
|
+
[editor, threadId]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function useComments(editor) {
|
|
39
|
+
return (0, import_tldraw.useValue)(
|
|
40
|
+
"all comments",
|
|
41
|
+
() => (0, import_comment_store.getComments)(editor).sort((a, b) => a.createdAt - b.createdAt),
|
|
42
|
+
[editor]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/hooks.ts"],
|
|
4
|
+
"sourcesContent": ["import { Editor, TLComment, TLCommentThread, TLCommentThreadId, useValue } from 'tldraw'\nimport { getComments, getCommentThreads } from './comment-store'\n\n/** All comment threads in the store, reactively. @public */\nexport function useCommentThreads(editor: Editor): TLCommentThread[] {\n\treturn useValue('comment threads', () => getCommentThreads(editor), [editor])\n}\n\n/** A thread's comments, oldest first, reactively. @public */\nexport function useThreadComments(editor: Editor, threadId: TLCommentThreadId): TLComment[] {\n\treturn useValue(\n\t\t'thread comments',\n\t\t() =>\n\t\t\tgetComments(editor)\n\t\t\t\t.filter((c) => c.threadId === threadId)\n\t\t\t\t.sort((a, b) => a.createdAt - b.createdAt),\n\t\t[editor, threadId]\n\t)\n}\n\n/** Every comment in the store, oldest first, reactively. Group by `threadId` for per-thread lists. @public */\nexport function useComments(editor: Editor): TLComment[] {\n\treturn useValue(\n\t\t'all comments',\n\t\t() => getComments(editor).sort((a, b) => a.createdAt - b.createdAt),\n\t\t[editor]\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgF;AAChF,2BAA+C;AAGxC,SAAS,kBAAkB,QAAmC;AACpE,aAAO,wBAAS,mBAAmB,UAAM,wCAAkB,MAAM,GAAG,CAAC,MAAM,CAAC;AAC7E;AAGO,SAAS,kBAAkB,QAAgB,UAA0C;AAC3F,aAAO;AAAA,IACN;AAAA,IACA,UACC,kCAAY,MAAM,EAChB,OAAO,CAAC,MAAM,EAAE,aAAa,QAAQ,EACrC,KAAK,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,SAAS;AAAA,IAC3C,CAAC,QAAQ,QAAQ;AAAA,EAClB;AACD;AAGO,SAAS,YAAY,QAA6B;AACxD,aAAO;AAAA,IACN;AAAA,IACA,UAAM,kCAAY,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,SAAS;AAAA,IAClE,CAAC,MAAM;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 license_exports = {};
|
|
20
|
+
__export(license_exports, {
|
|
21
|
+
useCommentingEnabled: () => useCommentingEnabled
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(license_exports);
|
|
24
|
+
var import_tldraw = require("tldraw");
|
|
25
|
+
function useCommentingEnabled() {
|
|
26
|
+
return (0, import_tldraw.useLicenseFeatureFlag)((0, import_tldraw.useLicenseContext)(), "commenting");
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=license.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/license.ts"],
|
|
4
|
+
"sourcesContent": ["import { useLicenseContext, useLicenseFeatureFlag } from 'tldraw'\n\n/**\n * Whether commenting is licensed for this editor. Enabled in development; in production it requires\n * a tldraw license that includes the commenting feature (or the collaboration umbrella that grants\n * it). Reactive: re-reads when license validation resolves, and returns `false` while validation is\n * pending, so gated UI stays hidden until the license is confirmed.\n *\n * The built-in commenting components (`CanvasComments`, `CanvasCommentsSidebar`, and the comment\n * tool's toolbar button) gate on this. Use it to gate any custom commenting UI the same way.\n * @public\n */\nexport function useCommentingEnabled(): boolean {\n\treturn useLicenseFeatureFlag(useLicenseContext(), 'commenting')\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyD;AAYlD,SAAS,uBAAgC;AAC/C,aAAO,yCAAsB,iCAAkB,GAAG,YAAY;AAC/D;",
|
|
6
|
+
"names": []
|
|
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 options_exports = {};
|
|
20
|
+
__export(options_exports, {
|
|
21
|
+
defaultCommentingOptions: () => defaultCommentingOptions,
|
|
22
|
+
getCommentingOptions: () => getCommentingOptions,
|
|
23
|
+
useCommentingOptions: () => useCommentingOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(options_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_tldraw = require("tldraw");
|
|
28
|
+
const defaultCommentingOptions = {
|
|
29
|
+
history: "ignore",
|
|
30
|
+
dragHistory: void 0,
|
|
31
|
+
enableClustering: true,
|
|
32
|
+
impreciseShapeAnchor: { x: 1, y: 0 },
|
|
33
|
+
clusterCullMargin: 120,
|
|
34
|
+
clusterSplitZoomFactor: 1.05,
|
|
35
|
+
components: {}
|
|
36
|
+
};
|
|
37
|
+
function getCommentingOptions(editor) {
|
|
38
|
+
const tool = editor.getStateDescendant("comment");
|
|
39
|
+
return tool?.options ?? defaultCommentingOptions;
|
|
40
|
+
}
|
|
41
|
+
function useCommentingOptions() {
|
|
42
|
+
const editor = (0, import_tldraw.useEditor)();
|
|
43
|
+
return (0, import_react.useMemo)(() => getCommentingOptions(editor), [editor]);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/options.ts"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, type ComponentType } from 'react'\nimport {\n\ttype Editor,\n\ttype TLComment,\n\ttype TLCommentThread,\n\ttype TLHistoryBatchOptions,\n\tuseEditor,\n} from 'tldraw'\n\n/**\n * Component overrides for the batteries-included comments layer. Each slot replaces a built-in\n * piece; leave a slot unset to keep its default.\n *\n * @public\n */\nexport interface CommentingComponents {\n\t/** A comment's body. Replaces the default rich-text `<CommentBody>`. */\n\tCommentBody?: ComponentType<{ comment: TLComment }>\n\t/** A pin's inner content. Replaces the author-initial default. */\n\tPinContent?: ComponentType<{ thread: TLCommentThread; comments: TLComment[] }>\n\t/** A sidebar row's preview. Replaces the plaintext default. */\n\tThreadPreview?: ComponentType<{ comment: TLComment }>\n}\n\n/**\n * Configuration for the commenting layer. Static config only \u2014 pass it once via\n * `CommentTool.configure({ ... })`, mirroring `ShapeUtil.configure`. Live, reactive values\n * (`currentUserId`, `resolveName`, read-status callbacks) stay as props on `<CanvasComments>`.\n *\n * For defaults, see {@link defaultCommentingOptions}.\n *\n * @example\n * ```tsx\n * <Tldraw tools={[CommentTool.configure({ history: 'ignore', enableClustering: false })]} />\n * ```\n *\n * @public\n */\nexport interface CommentingOptions {\n\t// \u2500\u2500 History / undo \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\t/**\n\t * How comment mutations (post, reply, edit, resolve, delete) interact with the editor undo\n\t * stack. Defaults to `'ignore'` \u2014 comments are deliberately not undoable (see `TLComment`).\n\t * `'record'` is a multiplayer footgun: undoing a delete resurrects a thread a collaborator\n\t * already removed, and undoing a resolve/edit reverts their newer state. Safe only single-player\n\t * or on a non-synced local comment store.\n\t */\n\treadonly history: TLHistoryBatchOptions['history']\n\t/**\n\t * History mode for the pin drag-to-move re-anchor specifically. Unlike posts/edits this is a\n\t * spatial edit that may reasonably be undoable alongside a shape move. Defaults to `history`.\n\t */\n\treadonly dragHistory: TLHistoryBatchOptions['history'] | undefined\n\n\t// \u2500\u2500 Feature toggles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\t/** Fold nearby pins into count badges as the camera zooms out. */\n\treadonly enableClustering: boolean\n\n\t// \u2500\u2500 Anchoring \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\t/** Normalized (0\u20131) spot within a shape where imprecise shape pins sit. Default top-right. */\n\treadonly impreciseShapeAnchor: { readonly x: number; readonly y: number }\n\n\t// \u2500\u2500 Clustering tuning \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\t/** Screen-pixel margin by which the viewport is inflated when culling cluster badges. */\n\treadonly clusterCullMargin: number\n\t/** How far past a cluster's split zoom to land when expanding it (1.05 = 5% overshoot). */\n\treadonly clusterSplitZoomFactor: number\n\n\t// \u2500\u2500 Components \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\t/** Component overrides. See {@link CommentingComponents}. */\n\treadonly components: CommentingComponents\n}\n\n/**\n * The default {@link CommentingOptions}. Override via `CommentTool.configure({ ... })`.\n *\n * @public\n */\nexport const defaultCommentingOptions = {\n\thistory: 'ignore',\n\tdragHistory: undefined,\n\tenableClustering: true,\n\timpreciseShapeAnchor: { x: 1, y: 0 },\n\tclusterCullMargin: 120,\n\tclusterSplitZoomFactor: 1.05,\n\tcomponents: {},\n} as const satisfies CommentingOptions\n\n/**\n * The merged {@link CommentingOptions} for an editor, read off the registered comment tool (which\n * carries them via `CommentTool.configure`). Falls back to {@link defaultCommentingOptions} when\n * the comment tool isn't registered. Usable from anywhere with an `Editor` \u2014 including the tool's\n * own state, which has no React context.\n *\n * @public\n */\nexport function getCommentingOptions(editor: Editor): CommentingOptions {\n\tconst tool = editor.getStateDescendant('comment') as { options?: CommentingOptions } | undefined\n\treturn tool?.options ?? defaultCommentingOptions\n}\n\n/**\n * React hook for {@link getCommentingOptions}. Options are fixed per editor (set at tool\n * registration), so this doesn't need to be reactive.\n *\n * @public\n */\nexport function useCommentingOptions(): CommentingOptions {\n\tconst editor = useEditor()\n\treturn useMemo(() => getCommentingOptions(editor), [editor])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAC5C,oBAMO;AAuEA,MAAM,2BAA2B;AAAA,EACvC,SAAS;AAAA,EACT,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,sBAAsB,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EACnC,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,YAAY,CAAC;AACd;AAUO,SAAS,qBAAqB,QAAmC;AACvE,QAAM,OAAO,OAAO,mBAAmB,SAAS;AAChD,SAAO,MAAM,WAAW;AACzB;AAQO,SAAS,uBAA0C;AACzD,QAAM,aAAS,yBAAU;AACzB,aAAO,sBAAQ,MAAM,qBAAqB,MAAM,GAAG,CAAC,MAAM,CAAC;AAC5D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 region_options_exports = {};
|
|
20
|
+
__export(region_options_exports, {
|
|
21
|
+
DEFAULT_REGION_COMMENT_OPTIONS: () => DEFAULT_REGION_COMMENT_OPTIONS,
|
|
22
|
+
getRegionCommentOptions: () => getRegionCommentOptions,
|
|
23
|
+
setRegionCommentOptions: () => setRegionCommentOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(region_options_exports);
|
|
26
|
+
var import_tldraw = require("tldraw");
|
|
27
|
+
const DEFAULT_REGION_COMMENT_OPTIONS = {
|
|
28
|
+
enabled: false,
|
|
29
|
+
pinCorner: { x: 1, y: 1 },
|
|
30
|
+
reveal: "pointer",
|
|
31
|
+
move: "pin",
|
|
32
|
+
resize: "corners"
|
|
33
|
+
};
|
|
34
|
+
const byEditor = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
function getEditorAtom(editor) {
|
|
36
|
+
let a = byEditor.get(editor);
|
|
37
|
+
if (!a) {
|
|
38
|
+
a = (0, import_tldraw.atom)("regionCommentOptions", DEFAULT_REGION_COMMENT_OPTIONS);
|
|
39
|
+
byEditor.set(editor, a);
|
|
40
|
+
}
|
|
41
|
+
return a;
|
|
42
|
+
}
|
|
43
|
+
function setRegionCommentOptions(editor, options) {
|
|
44
|
+
getEditorAtom(editor).set(options);
|
|
45
|
+
}
|
|
46
|
+
function getRegionCommentOptions(editor) {
|
|
47
|
+
return getEditorAtom(editor).get();
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=region-options.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/canvas/region-options.ts"],
|
|
4
|
+
"sourcesContent": ["import { atom, Atom, Editor, VecLike } from 'tldraw'\n\n/**\n * The configurable dimensions of region comments \u2014 a design surface for prototyping the interaction\n * before settling it. Region is **off by default**, so a consumer that leaves it unset keeps plain\n * click-only point/shape commenting. Set it per editor through `<CanvasComments regionOptions>`.\n * @public\n */\nexport interface RegionCommentOptions {\n\t/** Whether dragging the comment tool out creates a region anchor. Off \u2192 click-only. */\n\tenabled: boolean\n\t/** Which corner the pin and composer sit on, as a normalized 0\u20131 offset. Default bottom-right. */\n\tpinCorner: VecLike\n\t/** When the dashed box and its handles reveal: while the pointer is within the region, while the\n\t * pin is hovered, or only while the thread is open. */\n\treveal: 'pointer' | 'pin-hover' | 'open'\n\t/** How a region is moved: dragging its pin, dragging its body, or either. */\n\tmove: 'pin' | 'body' | 'both'\n\t/** The resize affordance: corner handles, edge handles, or none. */\n\tresize: 'corners' | 'edges' | 'none'\n}\n\n/** The out-of-the-box region config: disabled, and \u2014 when a consumer enables it \u2014 the current\n * bottom-right / pointer-reveal / pin-move / corner-resize behaviour.\n * @public */\nexport const DEFAULT_REGION_COMMENT_OPTIONS: RegionCommentOptions = {\n\tenabled: false,\n\tpinCorner: { x: 1, y: 1 },\n\treveal: 'pointer',\n\tmove: 'pin',\n\tresize: 'corners',\n}\n\n// Per-editor region config. The overlay publishes its merged `regionOptions` here so the comment\n// tool \u2014 which has no props of its own \u2014 can read the same per-instance config at interaction time.\n// Held in an atom so reactive readers (e.g. `anchorPagePoint`, called inside `useValue`) recompute\n// when the config changes; a plain map read wouldn't, leaving the pin at the stale default corner.\nconst byEditor = new WeakMap<Editor, Atom<RegionCommentOptions>>()\n\nfunction getEditorAtom(editor: Editor): Atom<RegionCommentOptions> {\n\tlet a = byEditor.get(editor)\n\tif (!a) {\n\t\ta = atom('regionCommentOptions', DEFAULT_REGION_COMMENT_OPTIONS)\n\t\tbyEditor.set(editor, a)\n\t}\n\treturn a\n}\n\n/** Publish an editor's region config (called by the overlay from its `regionOptions` prop). */\nexport function setRegionCommentOptions(editor: Editor, options: RegionCommentOptions): void {\n\tgetEditorAtom(editor).set(options)\n}\n\n/** The editor's region config, or the disabled default when none was set. */\nexport function getRegionCommentOptions(editor: Editor): RegionCommentOptions {\n\treturn getEditorAtom(editor).get()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA4C;AAyBrC,MAAM,iCAAuD;AAAA,EACnE,SAAS;AAAA,EACT,WAAW,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EACxB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACT;AAMA,MAAM,WAAW,oBAAI,QAA4C;AAEjE,SAAS,cAAc,QAA4C;AAClE,MAAI,IAAI,SAAS,IAAI,MAAM;AAC3B,MAAI,CAAC,GAAG;AACP,YAAI,oBAAK,wBAAwB,8BAA8B;AAC/D,aAAS,IAAI,QAAQ,CAAC;AAAA,EACvB;AACA,SAAO;AACR;AAGO,SAAS,wBAAwB,QAAgB,SAAqC;AAC5F,gBAAc,MAAM,EAAE,IAAI,OAAO;AAClC;AAGO,SAAS,wBAAwB,QAAsC;AAC7E,SAAO,cAAc,MAAM,EAAE,IAAI;AAClC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|