@tldraw/commenting 5.7.0-canary.fd4a9d669e63 → 5.7.0-internal.5fe8922939ec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commenting.css +280 -275
- package/dist-cjs/canvas/canvas-events.js +25 -1
- package/dist-cjs/canvas/canvas-events.js.map +2 -2
- package/dist-cjs/canvas/comment-mutations.js +5 -0
- package/dist-cjs/canvas/comment-mutations.js.map +2 -2
- package/dist-cjs/canvas/comment-tool.js +29 -28
- package/dist-cjs/canvas/comment-tool.js.map +2 -2
- package/dist-cjs/canvas/comments-filter-menu.js +55 -38
- package/dist-cjs/canvas/comments-filter-menu.js.map +2 -2
- package/dist-cjs/canvas/comments-overflow-menu.js +6 -24
- package/dist-cjs/canvas/comments-overflow-menu.js.map +2 -2
- package/dist-cjs/canvas/comments-overlay.js +1 -0
- package/dist-cjs/canvas/comments-overlay.js.map +2 -2
- package/dist-cjs/canvas/comments-sidebar.js +15 -3
- package/dist-cjs/canvas/comments-sidebar.js.map +2 -2
- package/dist-cjs/canvas/comments-visibility-toggle.js +1 -1
- package/dist-cjs/canvas/comments-visibility-toggle.js.map +1 -1
- package/dist-cjs/canvas/options.js +12 -0
- package/dist-cjs/canvas/options.js.map +2 -2
- package/dist-cjs/canvas/pending-composer.js +139 -9
- package/dist-cjs/canvas/pending-composer.js.map +2 -2
- package/dist-cjs/canvas/region-box.js +150 -35
- package/dist-cjs/canvas/region-box.js.map +3 -3
- package/dist-cjs/canvas/thread-pin.js +20 -4
- package/dist-cjs/canvas/thread-pin.js.map +2 -2
- package/dist-cjs/canvas/thread-view.js +134 -58
- package/dist-cjs/canvas/thread-view.js.map +2 -2
- package/dist-cjs/index.d.ts +46 -12
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/ui/byline.js +2 -2
- package/dist-cjs/ui/byline.js.map +2 -2
- package/dist-cjs/ui/comment-card.js +3 -1
- package/dist-cjs/ui/comment-card.js.map +2 -2
- package/dist-cjs/ui/comment-extensions.js +4 -1
- package/dist-cjs/ui/comment-extensions.js.map +2 -2
- package/dist-cjs/ui/comments-list.js +6 -7
- package/dist-cjs/ui/comments-list.js.map +2 -2
- package/dist-cjs/ui/icons.js +4 -4
- package/dist-cjs/ui/icons.js.map +2 -2
- package/dist-cjs/ui/reaction-picker.js +2 -2
- package/dist-cjs/ui/reaction-picker.js.map +1 -1
- package/dist-cjs/ui/send-button.js.map +1 -1
- package/dist-esm/canvas/canvas-events.mjs +25 -1
- package/dist-esm/canvas/canvas-events.mjs.map +2 -2
- package/dist-esm/canvas/comment-mutations.mjs +5 -0
- package/dist-esm/canvas/comment-mutations.mjs.map +2 -2
- package/dist-esm/canvas/comment-tool.mjs +30 -29
- package/dist-esm/canvas/comment-tool.mjs.map +2 -2
- package/dist-esm/canvas/comments-filter-menu.mjs +57 -39
- package/dist-esm/canvas/comments-filter-menu.mjs.map +2 -2
- package/dist-esm/canvas/comments-overflow-menu.mjs +8 -24
- package/dist-esm/canvas/comments-overflow-menu.mjs.map +2 -2
- package/dist-esm/canvas/comments-overlay.mjs +1 -0
- package/dist-esm/canvas/comments-overlay.mjs.map +2 -2
- package/dist-esm/canvas/comments-sidebar.mjs +16 -4
- package/dist-esm/canvas/comments-sidebar.mjs.map +2 -2
- package/dist-esm/canvas/comments-visibility-toggle.mjs +1 -1
- package/dist-esm/canvas/comments-visibility-toggle.mjs.map +1 -1
- package/dist-esm/canvas/options.mjs +12 -0
- package/dist-esm/canvas/options.mjs.map +2 -2
- package/dist-esm/canvas/pending-composer.mjs +150 -11
- package/dist-esm/canvas/pending-composer.mjs.map +2 -2
- package/dist-esm/canvas/region-box.mjs +161 -38
- package/dist-esm/canvas/region-box.mjs.map +3 -3
- package/dist-esm/canvas/thread-pin.mjs +22 -6
- package/dist-esm/canvas/thread-pin.mjs.map +2 -2
- package/dist-esm/canvas/thread-view.mjs +145 -60
- package/dist-esm/canvas/thread-view.mjs.map +2 -2
- package/dist-esm/index.d.mts +46 -12
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/ui/byline.mjs +2 -2
- package/dist-esm/ui/byline.mjs.map +2 -2
- package/dist-esm/ui/comment-card.mjs +3 -1
- package/dist-esm/ui/comment-card.mjs.map +2 -2
- package/dist-esm/ui/comment-extensions.mjs +11 -2
- package/dist-esm/ui/comment-extensions.mjs.map +2 -2
- package/dist-esm/ui/comments-list.mjs +6 -7
- package/dist-esm/ui/comments-list.mjs.map +2 -2
- package/dist-esm/ui/icons.mjs +4 -4
- package/dist-esm/ui/icons.mjs.map +2 -2
- package/dist-esm/ui/reaction-picker.mjs +2 -2
- package/dist-esm/ui/reaction-picker.mjs.map +1 -1
- package/dist-esm/ui/send-button.mjs.map +1 -1
- package/package.json +5 -5
- package/src/canvas/canvas-events.ts +39 -2
- package/src/canvas/canvas.css +76 -38
- package/src/canvas/comment-mutations.test.ts +51 -0
- package/src/canvas/comment-mutations.ts +14 -0
- package/src/canvas/comment-render.test.ts +8 -1
- package/src/canvas/comment-tool.test.ts +34 -44
- package/src/canvas/comment-tool.tsx +51 -55
- package/src/canvas/comments-filter-menu.tsx +19 -6
- package/src/canvas/comments-overflow-menu.tsx +12 -18
- package/src/canvas/comments-overlay.tsx +5 -2
- package/src/canvas/comments-sidebar.tsx +20 -5
- package/src/canvas/comments-visibility-toggle.tsx +1 -1
- package/src/canvas/options.test.ts +23 -1
- package/src/canvas/options.ts +41 -3
- package/src/canvas/pending-composer.tsx +190 -19
- package/src/canvas/region-box.tsx +192 -42
- package/src/canvas/thread-pin.tsx +28 -6
- package/src/canvas/thread-view.test.ts +39 -0
- package/src/canvas/thread-view.tsx +192 -72
- package/src/ui/byline.tsx +5 -2
- package/src/ui/comment-card.tsx +7 -1
- package/src/ui/comment-extensions.ts +18 -5
- package/src/ui/comments-list.tsx +23 -17
- package/src/ui/comments.css +175 -201
- package/src/ui/icons.tsx +5 -5
- package/src/ui/reaction-picker.tsx +2 -2
- package/src/ui/send-button.tsx +2 -2
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
useValue
|
|
16
16
|
} from "tldraw";
|
|
17
17
|
import { CommentPin } from "../ui/comment-pin.mjs";
|
|
18
|
-
import { forwardPointerEventToCanvas, isCanvasPanGesture } from "./canvas-events.mjs";
|
|
18
|
+
import { forwardPointerEventToCanvas, isCanvasPanGesture, startCommentDrag } from "./canvas-events.mjs";
|
|
19
19
|
import { commitCommentMutation } from "./comment-mutations.mjs";
|
|
20
20
|
import { UNKNOWN_COMMENT_AUTHOR } from "./comment-render.mjs";
|
|
21
21
|
import { useThreadComments } from "./hooks.mjs";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
regionWithPinAt,
|
|
42
42
|
shapeAnchorAt
|
|
43
43
|
} from "./thread-state.mjs";
|
|
44
|
-
import { POPOVER_OFFSET, ThreadPopover, ThreadView } from "./thread-view.mjs";
|
|
44
|
+
import { avatarRenderer, POPOVER_OFFSET, ThreadPopover, ThreadView } from "./thread-view.mjs";
|
|
45
45
|
const messages = defineMessages({
|
|
46
46
|
commentsUnknownAuthor: { id: "comments.unknown-author", defaultMessage: "Someone" },
|
|
47
47
|
commentsPinLabel: { id: "comments.pin-label", defaultMessage: "Comment by {name}" },
|
|
@@ -93,7 +93,9 @@ const ThreadPin = memo(function ThreadPin2({
|
|
|
93
93
|
usePassThroughWheelEvents(markerRef);
|
|
94
94
|
useEffect(() => {
|
|
95
95
|
return () => {
|
|
96
|
-
if (dragRef.current)
|
|
96
|
+
if (!dragRef.current) return;
|
|
97
|
+
editor.setHintingShapes([]);
|
|
98
|
+
dragRef.current.endDrag?.();
|
|
97
99
|
};
|
|
98
100
|
}, [editor]);
|
|
99
101
|
useEffect(() => {
|
|
@@ -131,7 +133,8 @@ const ThreadPin = memo(function ThreadPin2({
|
|
|
131
133
|
const toggleOpen = () => openThreadId.set(editor, openThreadId.get(editor) === thread.id ? null : thread.id);
|
|
132
134
|
const PinContent = options.components.PinContent;
|
|
133
135
|
const threadAuthor = resolveAuthor(thread.createdBy);
|
|
134
|
-
const
|
|
136
|
+
const pinAuthor = threadAuthor ?? UNKNOWN_COMMENT_AUTHOR;
|
|
137
|
+
const pinContent = PinContent ? /* @__PURE__ */ jsx(PinContent, { thread, comments }) : avatarRenderer(options.components, thread.createdBy)?.(pinAuthor) ?? /* @__PURE__ */ jsx(Avatar, { author: pinAuthor });
|
|
135
138
|
const pinLabel = msg(
|
|
136
139
|
thread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,
|
|
137
140
|
{
|
|
@@ -156,6 +159,8 @@ const ThreadPin = memo(function ThreadPin2({
|
|
|
156
159
|
dragRef.current = {
|
|
157
160
|
startX: e.clientX,
|
|
158
161
|
startY: e.clientY,
|
|
162
|
+
clientX: e.clientX,
|
|
163
|
+
clientY: e.clientY,
|
|
159
164
|
moved: false,
|
|
160
165
|
offsetX: anchorPage ? anchorPage.x - grabPage.x : 0,
|
|
161
166
|
offsetY: anchorPage ? anchorPage.y - grabPage.y : 0
|
|
@@ -167,8 +172,18 @@ const ThreadPin = memo(function ThreadPin2({
|
|
|
167
172
|
if (!drag) return;
|
|
168
173
|
if (!canComment) return;
|
|
169
174
|
if (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return;
|
|
170
|
-
drag.
|
|
171
|
-
|
|
175
|
+
drag.clientX = e.clientX;
|
|
176
|
+
drag.clientY = e.clientY;
|
|
177
|
+
if (!drag.moved) {
|
|
178
|
+
drag.moved = true;
|
|
179
|
+
drag.endDrag = startCommentDrag(editor, { cursor: "move", onCameraMove: dragToPointer });
|
|
180
|
+
}
|
|
181
|
+
dragToPointer();
|
|
182
|
+
};
|
|
183
|
+
const dragToPointer = () => {
|
|
184
|
+
const drag = dragRef.current;
|
|
185
|
+
if (!drag) return;
|
|
186
|
+
const cursorPage = editor.screenToPage({ x: drag.clientX, y: drag.clientY });
|
|
172
187
|
const pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY };
|
|
173
188
|
setDragPagePoint(pagePoint);
|
|
174
189
|
if (!isRegion) {
|
|
@@ -179,6 +194,7 @@ const ThreadPin = memo(function ThreadPin2({
|
|
|
179
194
|
const takeDrag = (e) => {
|
|
180
195
|
const drag = dragRef.current;
|
|
181
196
|
dragRef.current = null;
|
|
197
|
+
drag?.endDrag?.();
|
|
182
198
|
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
183
199
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
184
200
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/canvas/thread-pin.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Avatar } from '@tldraw/mentions'\nimport {\n\tmemo,\n\ttype PointerEvent as ReactPointerEvent,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport {\n\tdefineMessages,\n\tEditor,\n\tTLCommentThread,\n\ttype BoxModel,\n\tuseContainer,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentPin } from '../ui/comment-pin'\nimport { forwardPointerEventToCanvas, isCanvasPanGesture } from './canvas-events'\nimport { commitCommentMutation } from './comment-mutations'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { type CommentingContext } from './context'\nimport { useThreadComments } from './hooks'\nimport { getCommentingOptions, useCanComment, useCommentingOptions } from './options'\nimport {\n\tREGION_CORNERS,\n\tREGION_HANDLE_MARGIN_PX,\n\tRegionBox,\n\tRegionResizeHandles,\n} from './region-box'\nimport { openThreadId } from './state'\nimport { ThreadPreview, useMarkerPreview } from './thread-preview'\nimport {\n\tanchorPagePoint,\n\tanchorViewportPoint,\n\tcommentTargetShapeAt,\n\timpreciseShapePinInset,\n\tisBoxInInflatedViewport,\n\tisInInflatedViewport,\n\tREGION_PIN_CORNER,\n\tregionAnchorPinCorner,\n\tregionPinPoint,\n\tregionWithPinAt,\n\tshapeAnchorAt,\n} from './thread-state'\nimport { POPOVER_OFFSET, ThreadPopover, ThreadView } from './thread-view'\n\nconst messages = defineMessages({\n\tcommentsUnknownAuthor: { id: 'comments.unknown-author', defaultMessage: 'Someone' },\n\tcommentsPinLabel: { id: 'comments.pin-label', defaultMessage: 'Comment by {name}' },\n\tcommentsPinLabelResolved: {\n\t\tid: 'comments.pin-label-resolved',\n\t\tdefaultMessage: 'Resolved comment by {name}',\n\t},\n})\n\n/** The opened popover has a header row the hover preview lacks, so it opens this much higher \u2014 the\n * first comment then lands where the preview's sat. Re-measure if the header height or the preview\n * panel padding changes. */\nconst THREAD_HEADER_BLOCK = 36\n\n/**\n * A single thread's pin: the marker at its anchor, the thread popover when it's open, the hover\n * preview, and \u2014 for a region anchor \u2014 the dashed box and its resize handles. Dragging the marker\n * re-anchors the thread.\n *\n * Memoized so a pin skips re-rendering when the layer re-renders for unrelated reasons; camera\n * tracking still works, since the pin subscribes to its own viewport position via signals.\n */\nexport const ThreadPin = memo(function ThreadPin({\n\teditor,\n\tthread,\n\t...props\n}: CommentingContext & {\n\teditor: Editor\n\tthread: TLCommentThread\n}) {\n\tconst { resolveAuthor } = props\n\tconst options = useCommentingOptions()\n\tconst canComment = useCanComment(props.currentUserId)\n\tconst container = useContainer()\n\tconst msg = useTranslation()\n\tconst comments = useThreadComments(editor, thread.id)\n\t// Only one thread's popover is open at a time \u2014 shared across pins via the atom.\n\tconst open = useValue('thread open', () => openThreadId.get(editor) === thread.id, [\n\t\teditor,\n\t\tthread.id,\n\t])\n\t// While dragging the marker, its page point overrides the anchor's; committed on drop.\n\tconst [dragPagePoint, setDragPagePoint] = useState<{ x: number; y: number } | null>(null)\n\tconst [resizeBounds, setResizeBounds] = useState<BoxModel | null>(null)\n\t// Hovering the marker previews the thread's opening comment, on the delay every marker uses.\n\tconst { previewShown, previewHandlers } = useMarkerPreview(editor, `pin:${thread.id}`)\n\tconst previewThreads = useMemo(() => [thread], [thread])\n\t// The 'pointer' reveal mode: is the pointer within the region's bounds (plus a grab margin)?\n\t// Driven by pointer position, not DOM hover, so moving from anywhere in the region out to a corner\n\t// handle never loses the affordance \u2014 the box stays `pointer-events: none`.\n\tconst pointerInRegion = useValue(\n\t\t'pointer in region',\n\t\t() => {\n\t\t\tif (thread.anchor.type !== 'region' || thread.pageId !== editor.getCurrentPageId())\n\t\t\t\treturn false\n\t\t\tconst m = REGION_HANDLE_MARGIN_PX / editor.getZoomLevel()\n\t\t\tconst p = editor.inputs.getCurrentPagePoint()\n\t\t\tconst a = thread.anchor\n\t\t\treturn p.x >= a.x - m && p.x <= a.x + a.w + m && p.y >= a.y - m && p.y <= a.y + a.h + m\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId]\n\t)\n\t// A region's box and handles are revealed while open, mid-resize, or while the pointer is\n\t// within the region.\n\tconst revealed = open || resizeBounds != null || pointerInRegion\n\t// A region thread's pin corner is its own (the corner its creating drag released on), with\n\t// the default as the fallback for older records.\n\tconst pinCorner =\n\t\tthread.anchor.type === 'region' ? regionAnchorPinCorner(thread.anchor) : REGION_PIN_CORNER\n\t// A region resizes from its corners \u2014 every corner but the pin's own, which the pin owns.\n\tconst resizeHandles = useMemo(\n\t\t() => REGION_CORNERS.filter((c) => c.x !== pinCorner.x || c.y !== pinCorner.y),\n\t\t[pinCorner.x, pinCorner.y]\n\t)\n\tconst dragRef = useRef<{\n\t\tstartX: number\n\t\tstartY: number\n\t\tmoved: boolean\n\t\t// The anchor's page-space offset from the grab point, so a drag translates the pin by the\n\t\t// cursor's delta (like RegionBox's move) instead of snapping the anchor to the cursor.\n\t\toffsetX: number\n\t\toffsetY: number\n\t} | null>(null)\n\tconst markerRef = useRef<HTMLButtonElement>(null)\n\t// Wheel pass-through sits on the marker (which is never scrollable), not the layer root \u2014\n\t// see the note on the layer.\n\tusePassThroughWheelEvents(markerRef)\n\n\t// The drop-target hint is editor-global state with no automatic reset. If the pin unmounts\n\t// mid-drag (e.g. Shift+C hides comments), no pointer event will ever reach the drag handlers \u2014\n\t// clear the hint here or it stays on the shape indefinitely.\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (dragRef.current) editor.setHintingShapes([])\n\t\t}\n\t}, [editor])\n\n\t// Clicking outside the open popover closes the thread. Capture phase + a class check rather than\n\t// stopPropagation, since the popover portals elsewhere in the DOM. The marker is excluded so its own\n\t// click-to-toggle handles it instead of this closing and the toggle reopening.\n\tuseEffect(() => {\n\t\tif (!open) return\n\t\tconst onPointerDown = (e: PointerEvent) => {\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (!target) return\n\t\t\tif (target.closest('.tlui-cmt-canvas-popover')) return\n\t\t\tconst marker = markerRef.current\n\t\t\tif (marker && marker.contains(target)) return\n\t\t\t// A press on a region's resize handle edits this thread \u2014 don't dismiss it.\n\t\t\tif (target.closest('.tlui-cmt-canvas-region-handle')) return\n\t\t\t// A click inside a menu/popover layered above us (the sidebar's filter or overflow\n\t\t\t// dropdown, or the composer's mention picker \u2014 all portaled elsewhere) belongs to that\n\t\t\t// layer; defer to its own dismissal instead of closing the thread out from under it.\n\t\t\tif (\n\t\t\t\ttarget.closest('.tlui-menu, [data-radix-popper-content-wrapper], .tlui-cmt-mention-popup')\n\t\t\t)\n\t\t\t\treturn\n\t\t\topenThreadId.set(editor, null)\n\t\t}\n\t\tdocument.addEventListener('pointerdown', onPointerDown, true)\n\t\treturn () => document.removeEventListener('pointerdown', onPointerDown, true)\n\t}, [open, editor])\n\n\t// The pin must not unmount mid-interaction: an open thread's popover hangs off it, and a drag\n\t// or resize holds pointer capture on it \u2014 so those states are exempt from the viewport cull.\n\tconst exemptFromCull = open || dragPagePoint != null || resizeBounds != null\n\tconst point = useValue(\n\t\t'pin point',\n\t\t() => {\n\t\t\tif (thread.pageId !== editor.getCurrentPageId()) return null\n\t\t\tconst point = anchorViewportPoint(editor, thread.anchor)\n\t\t\tif (!point) return null\n\t\t\t// Off-screen pins (plus a pre-mount margin) unmount rather than re-render every camera frame. A\n\t\t\t// region thread stays mounted while any part of its box is on screen, since the box renders here too.\n\t\t\tif (!exemptFromCull) {\n\t\t\t\tconst visible =\n\t\t\t\t\tthread.anchor.type === 'region'\n\t\t\t\t\t\t? isBoxInInflatedViewport(editor, thread.anchor)\n\t\t\t\t\t\t: isInInflatedViewport(editor, point)\n\t\t\t\tif (!visible) return null\n\t\t\t}\n\t\t\treturn point\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId, exemptFromCull]\n\t)\n\tif (!point) return null\n\n\tconst toggleOpen = () =>\n\t\topenThreadId.set(editor, openThreadId.get(editor) === thread.id ? null : thread.id)\n\n\tconst PinContent = options.components.PinContent\n\tconst threadAuthor = resolveAuthor(thread.createdBy)\n\tconst pinContent = PinContent ? (\n\t\t<PinContent thread={thread} comments={comments} />\n\t) : (\n\t\t<Avatar author={threadAuthor ?? UNKNOWN_COMMENT_AUTHOR} />\n\t)\n\tconst pinLabel = msg(\n\t\tthread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,\n\t\t{\n\t\t\tname: threadAuthor?.name ?? msg(messages.commentsUnknownAuthor),\n\t\t}\n\t)\n\n\t// Drag the marker to move the thread: position is overridden locally while dragging, then re-anchored\n\t// on drop. A region translates keeping its size; a barely-moved pointer is a click.\n\tconst isRegion = thread.anchor.type === 'region'\n\t// The marker is a button (so it's keyboard-reachable), so the drag handlers are typed to it.\n\tconst startDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\t// A middle/right-button or space-held press over a pin is a camera pan, not a pin drag \u2014\n\t\t// hand it to the canvas untouched.\n\t\tif (isCanvasPanGesture(editor, e)) {\n\t\t\tforwardPointerEventToCanvas(container, e)\n\t\t\treturn\n\t\t}\n\t\te.stopPropagation()\n\t\tconst grabPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst anchorPage = anchorPagePoint(editor, thread.anchor)\n\t\t// The drag delta is taken from where the pin is drawn, which for an imprecise shape pin\n\t\t// is inset from its anchor point \u2014 without this the pin jumps by the inset on drag start.\n\t\tconst inset = impreciseShapePinInset(editor, thread.anchor)\n\t\tif (anchorPage && inset) {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tanchorPage.x += inset.x / zoom\n\t\t\tanchorPage.y += inset.y / zoom\n\t\t}\n\t\tdragRef.current = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tmoved: false,\n\t\t\toffsetX: anchorPage ? anchorPage.x - grabPage.x : 0,\n\t\t\toffsetY: anchorPage ? anchorPage.y - grabPage.y : 0,\n\t\t}\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\t// Moving a pin re-anchors the thread record \u2014 a commenting write. Without the permission the\n\t\t// press stays a click (`moved` never sets, so release toggles the popover and never commits).\n\t\tif (!canComment) return\n\t\tif (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return\n\t\tdrag.moved = true\n\t\tconst cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(pagePoint)\n\t\t// Hint the shape the pin would re-anchor to on drop \u2014 the same hit-test endDrag resolves\n\t\t// with. Regions translate rather than re-anchor, so they never hint.\n\t\tif (!isRegion) {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\teditor.setHintingShapes(hit ? [hit.id] : [])\n\t\t}\n\t}\n\t// Release capture and take the drag record; null when no drag was in progress.\n\tconst takeDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tdragRef.current = null\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId)) {\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\t}\n\t\treturn drag\n\t}\n\t// A cancelled pointer (touch gesture takeover, browser interruption) aborts the drag outright:\n\t// no re-anchor commit, no click-toggle \u2014 the pin snaps back and the hint clears.\n\tconst cancelDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tif (!takeDrag(e)) return\n\t\tsetDragPagePoint(null)\n\t\teditor.setHintingShapes([])\n\t}\n\tconst endDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = takeDrag(e)\n\t\tif (!drag) return\n\t\teditor.setHintingShapes([])\n\t\tif (!drag.moved) {\n\t\t\ttoggleOpen()\n\t\t\treturn\n\t\t}\n\t\tconst cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(null)\n\t\tlet anchor: TLCommentThread['anchor']\n\t\tif (thread.anchor.type === 'region') {\n\t\t\tanchor = regionWithPinAt(thread.anchor, pinCorner, pagePoint)\n\t\t} else {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\tanchor = hit\n\t\t\t\t? shapeAnchorAt(\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\thit.id,\n\t\t\t\t\t\tpagePoint,\n\t\t\t\t\t\tgetCommentingOptions(editor).shouldBePrecise(editor, {\n\t\t\t\t\t\t\tshapeId: hit.id,\n\t\t\t\t\t\t\tpoint: pagePoint,\n\t\t\t\t\t\t\taltKey: e.altKey,\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t: { type: 'point', x: pagePoint.x, y: pagePoint.y }\n\t\t}\n\t\tcommitCommentMutation(editor, ({ put }) => put([{ ...thread, anchor }]), 'drag')\n\t}\n\n\t// The pin (and its popover) track the live edit: a resize moves it to the region's pin corner, a\n\t// move to the drag point; otherwise it sits at the stored anchor's viewport point.\n\tconst livePinPage = resizeBounds ? regionPinPoint(resizeBounds, pinCorner) : dragPagePoint\n\tconst renderPointBase = livePinPage ? editor.pageToViewport(livePinPage) : point\n\t// A region's pin centres on its corner \u2014 overlapping the box \u2014 rather than hanging off it.\n\t// The marker anchors bottom-left, so step half its 28px size (--tlui-cmt-pin-size) left and\n\t// down (screen px), matching the draft composer's --region centring on the same corner.\n\tconst renderPoint = isRegion\n\t\t? { x: renderPointBase.x - 14, y: renderPointBase.y + 14 }\n\t\t: renderPointBase\n\n\t// A region's live box bounds, by priority: a corner resize, else a pin-drag translation (the pin\n\t// corner tracks the cursor), else the stored anchor. Undefined for non-region threads.\n\tconst regionAnchor = thread.anchor.type === 'region' ? thread.anchor : undefined\n\tconst movedRegion =\n\t\tregionAnchor && dragPagePoint\n\t\t\t? regionWithPinAt(regionAnchor, pinCorner, dragPagePoint)\n\t\t\t: regionAnchor\n\tconst regionBoxBounds = resizeBounds ?? movedRegion\n\tconst commitResize = (bounds: BoxModel) => {\n\t\tsetResizeBounds(null)\n\t\tif (!canComment) return\n\t\t// Same commit path as a pin drag, so the configured `dragHistory` governs both \u2014 going\n\t\t// straight to `editor.run` here would make region resizes silently ignore the option.\n\t\tcommitCommentMutation(\n\t\t\teditor,\n\t\t\t// Spread the existing anchor first so the region's pin corner survives a resize.\n\t\t\t({ put }) => put([{ ...thread, anchor: { ...regionAnchor!, ...bounds } }]),\n\t\t\t'drag'\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{regionBoxBounds && (dragPagePoint || revealed) && (\n\t\t\t\t<RegionBox editor={editor} box={regionBoxBounds} />\n\t\t\t)}\n\t\t\t{regionBoxBounds && revealed && !dragPagePoint && canComment && (\n\t\t\t\t<RegionResizeHandles\n\t\t\t\t\teditor={editor}\n\t\t\t\t\tbox={regionBoxBounds}\n\t\t\t\t\thandles={resizeHandles}\n\t\t\t\t\tonPreview={setResizeBounds}\n\t\t\t\t\tonCommit={commitResize}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={[\n\t\t\t\t\t'tlui-cmt-canvas-pin',\n\t\t\t\t\topen && 'tlui-cmt-canvas-pin--open',\n\t\t\t\t\tdragPagePoint && 'tlui-cmt-canvas-pin--dragging',\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(' ')}\n\t\t\t\tstyle={{ left: renderPoint.x, top: renderPoint.y }}\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tref={markerRef}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclassName=\"tlui-cmt-button tlui-cmt-canvas-pin__marker\"\n\t\t\t\t\taria-label={pinLabel}\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tonPointerDown={startDrag}\n\t\t\t\t\tonPointerMove={onDrag}\n\t\t\t\t\tonPointerUp={endDrag}\n\t\t\t\t\tonPointerCancel={cancelDrag}\n\t\t\t\t\t// Pointer activation is already handled by endDrag (which distinguishes a click\n\t\t\t\t\t// from a drag), so only take keyboard-synthesised clicks here \u2014 those report\n\t\t\t\t\t// `detail === 0` \u2014 or the thread would toggle twice per mouse click.\n\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\tif (e.detail === 0) toggleOpen()\n\t\t\t\t\t}}\n\t\t\t\t\tonPointerEnter={previewHandlers.onPointerEnter}\n\t\t\t\t\tonPointerLeave={previewHandlers.onPointerLeave}\n\t\t\t\t\t// Focus stands in for hover, so tabbing to a marker gets the same preview.\n\t\t\t\t\tonFocus={previewHandlers.onPointerEnter}\n\t\t\t\t\tonBlur={previewHandlers.onPointerLeave}\n\t\t\t\t>\n\t\t\t\t\t<CommentPin resolved={thread.resolved != null} open={open}>\n\t\t\t\t\t\t{pinContent}\n\t\t\t\t\t</CommentPin>\n\t\t\t\t</button>\n\t\t\t\t{/* The popover portals up to the menus layer (above the UI panels) so it isn't clipped;\n\t\t\t the pin itself stays in the canvas-in-front layer, beneath the UI. */}\n\t\t\t\t{open && (\n\t\t\t\t\t<ThreadPopover\n\t\t\t\t\t\tbase={{\n\t\t\t\t\t\t\tx: renderPoint.x + POPOVER_OFFSET.thread.x,\n\t\t\t\t\t\t\ty: renderPoint.y + POPOVER_OFFSET.thread.y - THREAD_HEADER_BLOCK,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ThreadView editor={editor} thread={thread} {...props} />\n\t\t\t\t\t</ThreadPopover>\n\t\t\t\t)}\n\t\t\t\t{/* Not while dragging: the pin is being moved, not read, and a panel trailing the\n\t\t\t\t cursor would obscure the drop target. */}\n\t\t\t\t{previewShown && !dragPagePoint && (\n\t\t\t\t\t<ThreadPreview\n\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\tthreads={previewThreads}\n\t\t\t\t\t\tvariant=\"thread\"\n\t\t\t\t\t\tpoint={renderPoint}\n\t\t\t\t\t\tonSelectThread={() => openThreadId.set(editor, thread.id)}\n\t\t\t\t\t\t{...previewHandlers}\n\t\t\t\t\t\tcurrentUserId={props.currentUserId}\n\t\t\t\t\t\tresolveAuthor={resolveAuthor}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</>\n\t)\n})\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Avatar } from '@tldraw/mentions'\nimport {\n\tmemo,\n\ttype PointerEvent as ReactPointerEvent,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport {\n\tdefineMessages,\n\tEditor,\n\tTLCommentThread,\n\ttype BoxModel,\n\tuseContainer,\n\tusePassThroughWheelEvents,\n\tuseTranslation,\n\tuseValue,\n} from 'tldraw'\nimport { CommentPin } from '../ui/comment-pin'\nimport { forwardPointerEventToCanvas, isCanvasPanGesture, startCommentDrag } from './canvas-events'\nimport { commitCommentMutation } from './comment-mutations'\nimport { UNKNOWN_COMMENT_AUTHOR } from './comment-render'\nimport { type CommentingContext } from './context'\nimport { useThreadComments } from './hooks'\nimport { getCommentingOptions, useCanComment, useCommentingOptions } from './options'\nimport {\n\tREGION_CORNERS,\n\tREGION_HANDLE_MARGIN_PX,\n\tRegionBox,\n\tRegionResizeHandles,\n} from './region-box'\nimport { openThreadId } from './state'\nimport { ThreadPreview, useMarkerPreview } from './thread-preview'\nimport {\n\tanchorPagePoint,\n\tanchorViewportPoint,\n\tcommentTargetShapeAt,\n\timpreciseShapePinInset,\n\tisBoxInInflatedViewport,\n\tisInInflatedViewport,\n\tREGION_PIN_CORNER,\n\tregionAnchorPinCorner,\n\tregionPinPoint,\n\tregionWithPinAt,\n\tshapeAnchorAt,\n} from './thread-state'\nimport { avatarRenderer, POPOVER_OFFSET, ThreadPopover, ThreadView } from './thread-view'\n\nconst messages = defineMessages({\n\tcommentsUnknownAuthor: { id: 'comments.unknown-author', defaultMessage: 'Someone' },\n\tcommentsPinLabel: { id: 'comments.pin-label', defaultMessage: 'Comment by {name}' },\n\tcommentsPinLabelResolved: {\n\t\tid: 'comments.pin-label-resolved',\n\t\tdefaultMessage: 'Resolved comment by {name}',\n\t},\n})\n\n/** The opened popover has a header row the hover preview lacks, so it opens this much higher \u2014 the\n * first comment then lands where the preview's sat. Re-measure if the header height or the preview\n * panel padding changes. */\nconst THREAD_HEADER_BLOCK = 36\n\n/**\n * A single thread's pin: the marker at its anchor, the thread popover when it's open, the hover\n * preview, and \u2014 for a region anchor \u2014 the dashed box and its resize handles. Dragging the marker\n * re-anchors the thread.\n *\n * Memoized so a pin skips re-rendering when the layer re-renders for unrelated reasons; camera\n * tracking still works, since the pin subscribes to its own viewport position via signals.\n */\nexport const ThreadPin = memo(function ThreadPin({\n\teditor,\n\tthread,\n\t...props\n}: CommentingContext & {\n\teditor: Editor\n\tthread: TLCommentThread\n}) {\n\tconst { resolveAuthor } = props\n\tconst options = useCommentingOptions()\n\tconst canComment = useCanComment(props.currentUserId)\n\tconst container = useContainer()\n\tconst msg = useTranslation()\n\tconst comments = useThreadComments(editor, thread.id)\n\t// Only one thread's popover is open at a time \u2014 shared across pins via the atom.\n\tconst open = useValue('thread open', () => openThreadId.get(editor) === thread.id, [\n\t\teditor,\n\t\tthread.id,\n\t])\n\t// While dragging the marker, its page point overrides the anchor's; committed on drop.\n\tconst [dragPagePoint, setDragPagePoint] = useState<{ x: number; y: number } | null>(null)\n\tconst [resizeBounds, setResizeBounds] = useState<BoxModel | null>(null)\n\t// Hovering the marker previews the thread's opening comment, on the delay every marker uses.\n\tconst { previewShown, previewHandlers } = useMarkerPreview(editor, `pin:${thread.id}`)\n\tconst previewThreads = useMemo(() => [thread], [thread])\n\t// The 'pointer' reveal mode: is the pointer within the region's bounds (plus a grab margin)?\n\t// Driven by pointer position, not DOM hover, so moving from anywhere in the region out to a corner\n\t// handle never loses the affordance \u2014 the box stays `pointer-events: none`.\n\tconst pointerInRegion = useValue(\n\t\t'pointer in region',\n\t\t() => {\n\t\t\tif (thread.anchor.type !== 'region' || thread.pageId !== editor.getCurrentPageId())\n\t\t\t\treturn false\n\t\t\tconst m = REGION_HANDLE_MARGIN_PX / editor.getZoomLevel()\n\t\t\tconst p = editor.inputs.getCurrentPagePoint()\n\t\t\tconst a = thread.anchor\n\t\t\treturn p.x >= a.x - m && p.x <= a.x + a.w + m && p.y >= a.y - m && p.y <= a.y + a.h + m\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId]\n\t)\n\t// A region's box and handles are revealed while open, mid-resize, or while the pointer is\n\t// within the region.\n\tconst revealed = open || resizeBounds != null || pointerInRegion\n\t// A region thread's pin corner is its own (the corner its creating drag released on), with\n\t// the default as the fallback for older records.\n\tconst pinCorner =\n\t\tthread.anchor.type === 'region' ? regionAnchorPinCorner(thread.anchor) : REGION_PIN_CORNER\n\t// A region resizes from its corners \u2014 every corner but the pin's own, which the pin owns.\n\tconst resizeHandles = useMemo(\n\t\t() => REGION_CORNERS.filter((c) => c.x !== pinCorner.x || c.y !== pinCorner.y),\n\t\t[pinCorner.x, pinCorner.y]\n\t)\n\tconst dragRef = useRef<{\n\t\tstartX: number\n\t\tstartY: number\n\t\tmoved: boolean\n\t\t// The anchor's page-space offset from the grab point, so a drag translates the pin by the\n\t\t// cursor's delta (like RegionBox's move) instead of snapping the anchor to the cursor.\n\t\toffsetX: number\n\t\toffsetY: number\n\t\tclientX: number\n\t\tclientY: number\n\t\tendDrag?(): void\n\t} | null>(null)\n\tconst markerRef = useRef<HTMLButtonElement>(null)\n\t// Wheel pass-through sits on the marker (which is never scrollable), not the layer root \u2014\n\t// see the note on the layer.\n\tusePassThroughWheelEvents(markerRef)\n\n\t// The drop-target hint is editor-global state with no automatic reset. If the pin unmounts\n\t// mid-drag (e.g. Shift+C hides comments), no pointer event will ever reach the drag handlers \u2014\n\t// clear the hint here or it stays on the shape indefinitely.\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (!dragRef.current) return\n\t\t\teditor.setHintingShapes([])\n\t\t\tdragRef.current.endDrag?.()\n\t\t}\n\t}, [editor])\n\n\t// Clicking outside the open popover closes the thread. Capture phase + a class check rather than\n\t// stopPropagation, since the popover portals elsewhere in the DOM. The marker is excluded so its own\n\t// click-to-toggle handles it instead of this closing and the toggle reopening.\n\tuseEffect(() => {\n\t\tif (!open) return\n\t\tconst onPointerDown = (e: PointerEvent) => {\n\t\t\tconst target = e.target as HTMLElement | null\n\t\t\tif (!target) return\n\t\t\tif (target.closest('.tlui-cmt-canvas-popover')) return\n\t\t\tconst marker = markerRef.current\n\t\t\tif (marker && marker.contains(target)) return\n\t\t\t// A press on a region's resize handle edits this thread \u2014 don't dismiss it.\n\t\t\tif (target.closest('.tlui-cmt-canvas-region-handle')) return\n\t\t\t// A click inside a menu/popover layered above us (the sidebar's filter or overflow\n\t\t\t// dropdown, or the composer's mention picker \u2014 all portaled elsewhere) belongs to that\n\t\t\t// layer; defer to its own dismissal instead of closing the thread out from under it.\n\t\t\tif (\n\t\t\t\ttarget.closest('.tlui-menu, [data-radix-popper-content-wrapper], .tlui-cmt-mention-popup')\n\t\t\t)\n\t\t\t\treturn\n\t\t\topenThreadId.set(editor, null)\n\t\t}\n\t\tdocument.addEventListener('pointerdown', onPointerDown, true)\n\t\treturn () => document.removeEventListener('pointerdown', onPointerDown, true)\n\t}, [open, editor])\n\n\t// The pin must not unmount mid-interaction: an open thread's popover hangs off it, and a drag\n\t// or resize holds pointer capture on it \u2014 so those states are exempt from the viewport cull.\n\tconst exemptFromCull = open || dragPagePoint != null || resizeBounds != null\n\tconst point = useValue(\n\t\t'pin point',\n\t\t() => {\n\t\t\tif (thread.pageId !== editor.getCurrentPageId()) return null\n\t\t\tconst point = anchorViewportPoint(editor, thread.anchor)\n\t\t\tif (!point) return null\n\t\t\t// Off-screen pins (plus a pre-mount margin) unmount rather than re-render every camera frame. A\n\t\t\t// region thread stays mounted while any part of its box is on screen, since the box renders here too.\n\t\t\tif (!exemptFromCull) {\n\t\t\t\tconst visible =\n\t\t\t\t\tthread.anchor.type === 'region'\n\t\t\t\t\t\t? isBoxInInflatedViewport(editor, thread.anchor)\n\t\t\t\t\t\t: isInInflatedViewport(editor, point)\n\t\t\t\tif (!visible) return null\n\t\t\t}\n\t\t\treturn point\n\t\t},\n\t\t[editor, thread.anchor, thread.pageId, exemptFromCull]\n\t)\n\tif (!point) return null\n\n\tconst toggleOpen = () =>\n\t\topenThreadId.set(editor, openThreadId.get(editor) === thread.id ? null : thread.id)\n\n\tconst PinContent = options.components.PinContent\n\tconst threadAuthor = resolveAuthor(thread.createdBy)\n\tconst pinAuthor = threadAuthor ?? UNKNOWN_COMMENT_AUTHOR\n\tconst pinContent = PinContent ? (\n\t\t<PinContent thread={thread} comments={comments} />\n\t) : (\n\t\t(avatarRenderer(options.components, thread.createdBy)?.(pinAuthor) ?? (\n\t\t\t<Avatar author={pinAuthor} />\n\t\t))\n\t)\n\tconst pinLabel = msg(\n\t\tthread.resolved ? messages.commentsPinLabelResolved : messages.commentsPinLabel,\n\t\t{\n\t\t\tname: threadAuthor?.name ?? msg(messages.commentsUnknownAuthor),\n\t\t}\n\t)\n\n\t// Drag the marker to move the thread: position is overridden locally while dragging, then re-anchored\n\t// on drop. A region translates keeping its size; a barely-moved pointer is a click.\n\tconst isRegion = thread.anchor.type === 'region'\n\t// The marker is a button (so it's keyboard-reachable), so the drag handlers are typed to it.\n\tconst startDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\t// A middle/right-button or space-held press over a pin is a camera pan, not a pin drag \u2014\n\t\t// hand it to the canvas untouched.\n\t\tif (isCanvasPanGesture(editor, e)) {\n\t\t\tforwardPointerEventToCanvas(container, e)\n\t\t\treturn\n\t\t}\n\t\te.stopPropagation()\n\t\tconst grabPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst anchorPage = anchorPagePoint(editor, thread.anchor)\n\t\t// The drag delta is taken from where the pin is drawn, which for an imprecise shape pin\n\t\t// is inset from its anchor point \u2014 without this the pin jumps by the inset on drag start.\n\t\tconst inset = impreciseShapePinInset(editor, thread.anchor)\n\t\tif (anchorPage && inset) {\n\t\t\tconst zoom = editor.getZoomLevel()\n\t\t\tanchorPage.x += inset.x / zoom\n\t\t\tanchorPage.y += inset.y / zoom\n\t\t}\n\t\tdragRef.current = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tclientX: e.clientX,\n\t\t\tclientY: e.clientY,\n\t\t\tmoved: false,\n\t\t\toffsetX: anchorPage ? anchorPage.x - grabPage.x : 0,\n\t\t\toffsetY: anchorPage ? anchorPage.y - grabPage.y : 0,\n\t\t}\n\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t}\n\tconst onDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\t// Moving a pin re-anchors the thread record \u2014 a commenting write. Without the permission the\n\t\t// press stays a click (`moved` never sets, so release toggles the popover and never commits).\n\t\tif (!canComment) return\n\t\tif (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < 4) return\n\t\tdrag.clientX = e.clientX\n\t\tdrag.clientY = e.clientY\n\t\tif (!drag.moved) {\n\t\t\tdrag.moved = true\n\t\t\tdrag.endDrag = startCommentDrag(editor, { cursor: 'move', onCameraMove: dragToPointer })\n\t\t}\n\t\tdragToPointer()\n\t}\n\t// Place the pin under the drag's last pointer position, at the current camera.\n\tconst dragToPointer = () => {\n\t\tconst drag = dragRef.current\n\t\tif (!drag) return\n\t\tconst cursorPage = editor.screenToPage({ x: drag.clientX, y: drag.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(pagePoint)\n\t\t// Hint the shape the pin would re-anchor to on drop \u2014 the same hit-test endDrag resolves\n\t\t// with. Regions translate rather than re-anchor, so they never hint.\n\t\tif (!isRegion) {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\teditor.setHintingShapes(hit ? [hit.id] : [])\n\t\t}\n\t}\n\t// Release capture and take the drag record; null when no drag was in progress.\n\tconst takeDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = dragRef.current\n\t\tdragRef.current = null\n\t\tdrag?.endDrag?.()\n\t\tif (e.currentTarget.hasPointerCapture(e.pointerId)) {\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\t\t}\n\t\treturn drag\n\t}\n\t// A cancelled pointer (touch gesture takeover, browser interruption) aborts the drag outright:\n\t// no re-anchor commit, no click-toggle \u2014 the pin snaps back and the hint clears.\n\tconst cancelDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tif (!takeDrag(e)) return\n\t\tsetDragPagePoint(null)\n\t\teditor.setHintingShapes([])\n\t}\n\tconst endDrag = (e: ReactPointerEvent<HTMLButtonElement>) => {\n\t\tconst drag = takeDrag(e)\n\t\tif (!drag) return\n\t\teditor.setHintingShapes([])\n\t\tif (!drag.moved) {\n\t\t\ttoggleOpen()\n\t\t\treturn\n\t\t}\n\t\tconst cursorPage = editor.screenToPage({ x: e.clientX, y: e.clientY })\n\t\tconst pagePoint = { x: cursorPage.x + drag.offsetX, y: cursorPage.y + drag.offsetY }\n\t\tsetDragPagePoint(null)\n\t\tlet anchor: TLCommentThread['anchor']\n\t\tif (thread.anchor.type === 'region') {\n\t\t\tanchor = regionWithPinAt(thread.anchor, pinCorner, pagePoint)\n\t\t} else {\n\t\t\tconst hit = commentTargetShapeAt(editor, pagePoint)\n\t\t\tanchor = hit\n\t\t\t\t? shapeAnchorAt(\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\thit.id,\n\t\t\t\t\t\tpagePoint,\n\t\t\t\t\t\tgetCommentingOptions(editor).shouldBePrecise(editor, {\n\t\t\t\t\t\t\tshapeId: hit.id,\n\t\t\t\t\t\t\tpoint: pagePoint,\n\t\t\t\t\t\t\taltKey: e.altKey,\n\t\t\t\t\t\t})\n\t\t\t\t\t)\n\t\t\t\t: { type: 'point', x: pagePoint.x, y: pagePoint.y }\n\t\t}\n\t\tcommitCommentMutation(editor, ({ put }) => put([{ ...thread, anchor }]), 'drag')\n\t}\n\n\t// The pin (and its popover) track the live edit: a resize moves it to the region's pin corner, a\n\t// move to the drag point; otherwise it sits at the stored anchor's viewport point.\n\tconst livePinPage = resizeBounds ? regionPinPoint(resizeBounds, pinCorner) : dragPagePoint\n\tconst renderPointBase = livePinPage ? editor.pageToViewport(livePinPage) : point\n\t// A region's pin centres on its corner \u2014 overlapping the box \u2014 rather than hanging off it.\n\t// The marker anchors bottom-left, so step half its 28px size (--tlui-cmt-pin-size) left and\n\t// down (screen px), matching the draft composer's --region centring on the same corner.\n\tconst renderPoint = isRegion\n\t\t? { x: renderPointBase.x - 14, y: renderPointBase.y + 14 }\n\t\t: renderPointBase\n\n\t// A region's live box bounds, by priority: a corner resize, else a pin-drag translation (the pin\n\t// corner tracks the cursor), else the stored anchor. Undefined for non-region threads.\n\tconst regionAnchor = thread.anchor.type === 'region' ? thread.anchor : undefined\n\tconst movedRegion =\n\t\tregionAnchor && dragPagePoint\n\t\t\t? regionWithPinAt(regionAnchor, pinCorner, dragPagePoint)\n\t\t\t: regionAnchor\n\tconst regionBoxBounds = resizeBounds ?? movedRegion\n\tconst commitResize = (bounds: BoxModel) => {\n\t\tsetResizeBounds(null)\n\t\tif (!canComment) return\n\t\t// Same commit path as a pin drag, so the configured `dragHistory` governs both \u2014 going\n\t\t// straight to `editor.run` here would make region resizes silently ignore the option.\n\t\tcommitCommentMutation(\n\t\t\teditor,\n\t\t\t// Spread the existing anchor first so the region's pin corner survives a resize.\n\t\t\t({ put }) => put([{ ...thread, anchor: { ...regionAnchor!, ...bounds } }]),\n\t\t\t'drag'\n\t\t)\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{regionBoxBounds && (dragPagePoint || revealed) && (\n\t\t\t\t<RegionBox editor={editor} box={regionBoxBounds} />\n\t\t\t)}\n\t\t\t{regionBoxBounds && revealed && !dragPagePoint && canComment && (\n\t\t\t\t<RegionResizeHandles\n\t\t\t\t\teditor={editor}\n\t\t\t\t\tbox={regionBoxBounds}\n\t\t\t\t\thandles={resizeHandles}\n\t\t\t\t\tonPreview={setResizeBounds}\n\t\t\t\t\tonCommit={commitResize}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={[\n\t\t\t\t\t'tlui-cmt-canvas-pin',\n\t\t\t\t\topen && 'tlui-cmt-canvas-pin--open',\n\t\t\t\t\tdragPagePoint && 'tlui-cmt-canvas-pin--dragging',\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(' ')}\n\t\t\t\tstyle={{ left: renderPoint.x, top: renderPoint.y }}\n\t\t\t>\n\t\t\t\t<button\n\t\t\t\t\tref={markerRef}\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclassName=\"tlui-cmt-button tlui-cmt-canvas-pin__marker\"\n\t\t\t\t\taria-label={pinLabel}\n\t\t\t\t\taria-expanded={open}\n\t\t\t\t\tonPointerDown={startDrag}\n\t\t\t\t\tonPointerMove={onDrag}\n\t\t\t\t\tonPointerUp={endDrag}\n\t\t\t\t\tonPointerCancel={cancelDrag}\n\t\t\t\t\t// Pointer activation is already handled by endDrag (which distinguishes a click\n\t\t\t\t\t// from a drag), so only take keyboard-synthesised clicks here \u2014 those report\n\t\t\t\t\t// `detail === 0` \u2014 or the thread would toggle twice per mouse click.\n\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\tif (e.detail === 0) toggleOpen()\n\t\t\t\t\t}}\n\t\t\t\t\tonPointerEnter={previewHandlers.onPointerEnter}\n\t\t\t\t\tonPointerLeave={previewHandlers.onPointerLeave}\n\t\t\t\t\t// Focus stands in for hover, so tabbing to a marker gets the same preview.\n\t\t\t\t\tonFocus={previewHandlers.onPointerEnter}\n\t\t\t\t\tonBlur={previewHandlers.onPointerLeave}\n\t\t\t\t>\n\t\t\t\t\t<CommentPin resolved={thread.resolved != null} open={open}>\n\t\t\t\t\t\t{pinContent}\n\t\t\t\t\t</CommentPin>\n\t\t\t\t</button>\n\t\t\t\t{/* The popover portals up to the menus layer (above the UI panels) so it isn't clipped;\n\t\t\t the pin itself stays in the canvas-in-front layer, beneath the UI. */}\n\t\t\t\t{open && (\n\t\t\t\t\t<ThreadPopover\n\t\t\t\t\t\tbase={{\n\t\t\t\t\t\t\tx: renderPoint.x + POPOVER_OFFSET.thread.x,\n\t\t\t\t\t\t\ty: renderPoint.y + POPOVER_OFFSET.thread.y - THREAD_HEADER_BLOCK,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ThreadView editor={editor} thread={thread} {...props} />\n\t\t\t\t\t</ThreadPopover>\n\t\t\t\t)}\n\t\t\t\t{/* Not while dragging: the pin is being moved, not read, and a panel trailing the\n\t\t\t\t cursor would obscure the drop target. */}\n\t\t\t\t{previewShown && !dragPagePoint && (\n\t\t\t\t\t<ThreadPreview\n\t\t\t\t\t\teditor={editor}\n\t\t\t\t\t\tthreads={previewThreads}\n\t\t\t\t\t\tvariant=\"thread\"\n\t\t\t\t\t\tpoint={renderPoint}\n\t\t\t\t\t\tonSelectThread={() => openThreadId.set(editor, thread.id)}\n\t\t\t\t\t\t{...previewHandlers}\n\t\t\t\t\t\tcurrentUserId={props.currentUserId}\n\t\t\t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W,QAAgB,QAAiB,GAAG,OAAO;AAAA;AAAA,UACxD;AAAA,UAIA,gBAAgB,CAAC,iBACjB;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA,SAAS;AAAA,cACT,SAAQ;AAAA,cACR,OAAO;AAAA,cACP,gBAAgB,MAAM,aAAa,IAAI,QAAQ,OAAO,EAAE;AAAA,cACvD,GAAG;AAAA,cACJ,eAAe,MAAM;AAAA,cACrB;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IAEF;AAAA,KACD;AAEF,CAAC;",
|
|
6
6
|
"names": ["ThreadPin", "point"]
|
|
7
7
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { isMentionPickerOpen } from "@tldraw/mentions";
|
|
3
|
+
import {
|
|
4
|
+
memo,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
3
12
|
import {
|
|
4
13
|
createComment,
|
|
5
14
|
defineMessages,
|
|
6
15
|
EditorPortal,
|
|
7
16
|
TldrawUiButton,
|
|
17
|
+
TldrawUiButtonLabel,
|
|
8
18
|
TldrawUiDropdownMenuContent,
|
|
9
19
|
TldrawUiDropdownMenuGroup,
|
|
10
20
|
TldrawUiDropdownMenuItem,
|
|
@@ -28,7 +38,7 @@ import {
|
|
|
28
38
|
saveCommentDraft
|
|
29
39
|
} from "./comment-drafts.mjs";
|
|
30
40
|
import {
|
|
31
|
-
|
|
41
|
+
commitCommentPost,
|
|
32
42
|
deleteComment,
|
|
33
43
|
deleteThread,
|
|
34
44
|
editComment,
|
|
@@ -50,7 +60,7 @@ const messages = defineMessages({
|
|
|
50
60
|
actionDelete: { id: "action.delete", defaultMessage: "Delete" },
|
|
51
61
|
commentsCopyLink: { id: "comments.copy-link", defaultMessage: "Copy link" },
|
|
52
62
|
commentsDelete: { id: "comments.delete", defaultMessage: "Delete thread" },
|
|
53
|
-
|
|
63
|
+
commentsClose: { id: "comments.close", defaultMessage: "Close" },
|
|
54
64
|
commentsEdit: { id: "comments.edit", defaultMessage: "Edit" },
|
|
55
65
|
commentsEditPlaceholder: {
|
|
56
66
|
id: "comments.edit-placeholder",
|
|
@@ -63,11 +73,49 @@ const messages = defineMessages({
|
|
|
63
73
|
commentsResolve: { id: "comments.resolve", defaultMessage: "Resolve" },
|
|
64
74
|
commentsResolvedBy: { id: "comments.resolved-by", defaultMessage: "Resolved by {name}" },
|
|
65
75
|
commentsSave: { id: "comments.save", defaultMessage: "Save" },
|
|
76
|
+
commentsSeeLess: { id: "comments.see-less", defaultMessage: "See less" },
|
|
77
|
+
commentsSeeMore: { id: "comments.see-more", defaultMessage: "See more" },
|
|
66
78
|
commentsSend: { id: "comments.send", defaultMessage: "Send" },
|
|
67
79
|
commentsThreadTitle: { id: "comments.thread-title", defaultMessage: "Comment" },
|
|
68
80
|
commentsUnknownAuthor: { id: "comments.unknown-author", defaultMessage: "Someone" }
|
|
69
81
|
});
|
|
70
82
|
const stop = (e) => e.stopPropagation();
|
|
83
|
+
function CollapsibleBody({ children }) {
|
|
84
|
+
const msg = useTranslation();
|
|
85
|
+
const ref = useRef(null);
|
|
86
|
+
const [expanded, setExpanded] = useState(false);
|
|
87
|
+
const [overflows, setOverflows] = useState(false);
|
|
88
|
+
useLayoutEffect(() => {
|
|
89
|
+
const el = ref.current;
|
|
90
|
+
if (!el || expanded) return;
|
|
91
|
+
const measure = () => setOverflows(el.scrollHeight > el.clientHeight + 1);
|
|
92
|
+
measure();
|
|
93
|
+
const observer = new ResizeObserver(measure);
|
|
94
|
+
observer.observe(el);
|
|
95
|
+
for (const child of Array.from(el.children)) observer.observe(child);
|
|
96
|
+
return () => observer.disconnect();
|
|
97
|
+
}, [expanded, children]);
|
|
98
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
ref,
|
|
103
|
+
className: ["tlui-cmt-collapsible", !expanded && "tlui-cmt-collapsible--collapsed"].filter(Boolean).join(" "),
|
|
104
|
+
children
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
overflows && /* @__PURE__ */ jsx(
|
|
108
|
+
"button",
|
|
109
|
+
{
|
|
110
|
+
type: "button",
|
|
111
|
+
className: "tlui-cmt-see-more",
|
|
112
|
+
"aria-expanded": expanded,
|
|
113
|
+
onClick: () => setExpanded((v) => !v),
|
|
114
|
+
children: msg(expanded ? messages.commentsSeeLess : messages.commentsSeeMore)
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
71
119
|
function MoreOptionsMenu({
|
|
72
120
|
id,
|
|
73
121
|
moreFor,
|
|
@@ -81,39 +129,20 @@ function MoreOptionsMenu({
|
|
|
81
129
|
type: "icon",
|
|
82
130
|
tooltip: msg(messages.commentsMoreOptions),
|
|
83
131
|
title: msg(messages.commentsMoreOptions),
|
|
84
|
-
className: "tlui-cmt-
|
|
132
|
+
className: "tlui-cmt-icon-btn",
|
|
85
133
|
"data-cmt-more-for": moreFor,
|
|
86
134
|
children: /* @__PURE__ */ jsx(TldrawUiIcon, { icon: "dots-vertical", label: msg(messages.commentsMoreOptions), small: true })
|
|
87
135
|
}
|
|
88
136
|
) }),
|
|
89
|
-
/* @__PURE__ */ jsx(
|
|
90
|
-
TldrawUiDropdownMenuContent,
|
|
91
|
-
{
|
|
92
|
-
className: "tlui-cmt-menu",
|
|
93
|
-
side: "bottom",
|
|
94
|
-
align: "start",
|
|
95
|
-
alignOffset: 0,
|
|
96
|
-
sideOffset: 4,
|
|
97
|
-
children: /* @__PURE__ */ jsx(TldrawUiDropdownMenuGroup, { children })
|
|
98
|
-
}
|
|
99
|
-
)
|
|
137
|
+
/* @__PURE__ */ jsx(TldrawUiDropdownMenuContent, { side: "bottom", align: "end", alignOffset: -6, sideOffset: 0, children })
|
|
100
138
|
] });
|
|
101
139
|
}
|
|
102
140
|
function MenuItem({
|
|
103
141
|
label,
|
|
104
|
-
danger,
|
|
105
142
|
noClose,
|
|
106
143
|
onClick
|
|
107
144
|
}) {
|
|
108
|
-
return /* @__PURE__ */ jsx(TldrawUiDropdownMenuItem, { noClose, children: /* @__PURE__ */ jsx(
|
|
109
|
-
"button",
|
|
110
|
-
{
|
|
111
|
-
type: "button",
|
|
112
|
-
className: danger ? "tlui-cmt-menu-item tlui-cmt-menu-item--danger" : "tlui-cmt-menu-item",
|
|
113
|
-
onClick,
|
|
114
|
-
children: /* @__PURE__ */ jsx("span", { children: label })
|
|
115
|
-
}
|
|
116
|
-
) });
|
|
145
|
+
return /* @__PURE__ */ jsx(TldrawUiDropdownMenuItem, { noClose, children: /* @__PURE__ */ jsx(TldrawUiButton, { type: "menu", onClick, children: /* @__PURE__ */ jsx(TldrawUiButtonLabel, { children: label }) }) });
|
|
117
146
|
}
|
|
118
147
|
function useResolveName(resolveAuthor) {
|
|
119
148
|
return useCallback((id) => resolveAuthor(id)?.name, [resolveAuthor]);
|
|
@@ -142,15 +171,36 @@ function useCopyLink(href) {
|
|
|
142
171
|
}, [href]);
|
|
143
172
|
return [copied, copy];
|
|
144
173
|
}
|
|
174
|
+
function avatarRenderer(components, authorId) {
|
|
175
|
+
const Avatar = components.Avatar;
|
|
176
|
+
if (!Avatar) return void 0;
|
|
177
|
+
return (author) => /* @__PURE__ */ jsx(Avatar, { author, authorId });
|
|
178
|
+
}
|
|
145
179
|
function toCardProps(comment, props, components, resolveName) {
|
|
146
180
|
const Body = components.CommentBody;
|
|
147
181
|
const body = Body ? /* @__PURE__ */ jsx(Body, { comment }) : /* @__PURE__ */ jsx(CommentBody, { richText: comment.body, resolveName });
|
|
182
|
+
const author = props.resolveAuthor(comment.authorId) ?? UNKNOWN_COMMENT_AUTHOR;
|
|
183
|
+
const date = new Date(comment.createdAt).toISOString();
|
|
184
|
+
const edited = comment.editedAt != null;
|
|
185
|
+
const renderAvatar = avatarRenderer(components, comment.authorId);
|
|
186
|
+
const Byline = components.CommentByline;
|
|
148
187
|
return {
|
|
149
|
-
author
|
|
188
|
+
author,
|
|
150
189
|
body,
|
|
151
|
-
date
|
|
190
|
+
date,
|
|
152
191
|
you: comment.authorId === props.currentUserId,
|
|
153
|
-
edited
|
|
192
|
+
edited,
|
|
193
|
+
renderAvatar,
|
|
194
|
+
byline: Byline ? /* @__PURE__ */ jsx(
|
|
195
|
+
Byline,
|
|
196
|
+
{
|
|
197
|
+
author,
|
|
198
|
+
date,
|
|
199
|
+
edited,
|
|
200
|
+
renderAvatar,
|
|
201
|
+
comment
|
|
202
|
+
}
|
|
203
|
+
) : void 0
|
|
154
204
|
};
|
|
155
205
|
}
|
|
156
206
|
const PIN_SIZE = 28;
|
|
@@ -201,9 +251,15 @@ const ThreadView = memo(function ThreadView2({
|
|
|
201
251
|
const msg = useTranslation();
|
|
202
252
|
const resolveName = useResolveName(resolveAuthor);
|
|
203
253
|
const cards = useMemo(
|
|
204
|
-
() => comments.map(
|
|
205
|
-
|
|
206
|
-
|
|
254
|
+
() => comments.map((c) => {
|
|
255
|
+
const card = toCardProps(
|
|
256
|
+
c,
|
|
257
|
+
{ currentUserId, resolveAuthor },
|
|
258
|
+
options.components,
|
|
259
|
+
resolveName
|
|
260
|
+
);
|
|
261
|
+
return { ...card, body: /* @__PURE__ */ jsx(CollapsibleBody, { children: card.body }) };
|
|
262
|
+
}),
|
|
207
263
|
[comments, currentUserId, resolveAuthor, options.components, resolveName]
|
|
208
264
|
);
|
|
209
265
|
const me = currentUserId ? resolveAuthor(currentUserId) : void 0;
|
|
@@ -234,7 +290,27 @@ const ThreadView = memo(function ThreadView2({
|
|
|
234
290
|
const [editText, setEditText] = useState(EMPTY_COMMENT);
|
|
235
291
|
const canReply = canComment && !thread.resolved;
|
|
236
292
|
const container = useContainer();
|
|
293
|
+
const replyRef = useRef(reply);
|
|
294
|
+
replyRef.current = reply;
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
const win = container.ownerDocument.defaultView;
|
|
297
|
+
if (!win) return;
|
|
298
|
+
const onKeyDown = (e) => {
|
|
299
|
+
if (e.key !== "Escape" || isMentionPickerOpen()) return;
|
|
300
|
+
const target = e.target;
|
|
301
|
+
if (!target?.closest(".tlui-cmt-thread .tlui-cmt-composer")) return;
|
|
302
|
+
if (target.closest(".tlui-cmt-editing")) return;
|
|
303
|
+
if (isCommentEmpty(replyRef.current)) return;
|
|
304
|
+
setReply(EMPTY_COMMENT);
|
|
305
|
+
clearCommentDraft(replyDraftSlot(thread.id));
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
e.stopPropagation();
|
|
308
|
+
};
|
|
309
|
+
win.addEventListener("keydown", onKeyDown, true);
|
|
310
|
+
return () => win.removeEventListener("keydown", onKeyDown, true);
|
|
311
|
+
}, [container, thread.id]);
|
|
237
312
|
const editReturnFocus = useRef(null);
|
|
313
|
+
const editEndedByKeyboard = useRef(false);
|
|
238
314
|
const [focusReply, setFocusReply] = useState(false);
|
|
239
315
|
const tabTaken = useRef(false);
|
|
240
316
|
const swallowTabUp = useRef(false);
|
|
@@ -272,7 +348,8 @@ const ThreadView = memo(function ThreadView2({
|
|
|
272
348
|
if (editingId !== null) return;
|
|
273
349
|
const resolve = editReturnFocus.current;
|
|
274
350
|
editReturnFocus.current = null;
|
|
275
|
-
resolve?.()?.focus();
|
|
351
|
+
resolve?.()?.focus({ focusVisible: editEndedByKeyboard.current });
|
|
352
|
+
editEndedByKeyboard.current = false;
|
|
276
353
|
}, [editingId]);
|
|
277
354
|
useEffect(() => {
|
|
278
355
|
if (!isCommentUnread || !onCommentsRead) return;
|
|
@@ -283,7 +360,7 @@ const ThreadView = memo(function ThreadView2({
|
|
|
283
360
|
}, [comments, isCommentUnread, onCommentsRead]);
|
|
284
361
|
const postReply = () => {
|
|
285
362
|
if (isCommentEmpty(reply) || !currentUserId) return;
|
|
286
|
-
const comment =
|
|
363
|
+
const comment = commitCommentPost(editor, ({ put }) => {
|
|
287
364
|
const comment2 = createComment({
|
|
288
365
|
threadId: thread.id,
|
|
289
366
|
pageId: thread.pageId,
|
|
@@ -293,6 +370,7 @@ const ThreadView = memo(function ThreadView2({
|
|
|
293
370
|
put([comment2]);
|
|
294
371
|
return comment2;
|
|
295
372
|
});
|
|
373
|
+
if (!comment) return;
|
|
296
374
|
setReply(EMPTY_COMMENT);
|
|
297
375
|
clearCommentDraft(replyDraftSlot(thread.id));
|
|
298
376
|
onPostComment?.(comment);
|
|
@@ -326,7 +404,11 @@ const ThreadView = memo(function ThreadView2({
|
|
|
326
404
|
"div",
|
|
327
405
|
{
|
|
328
406
|
className: "tlui-cmt-editing",
|
|
407
|
+
onPointerDown: () => {
|
|
408
|
+
editEndedByKeyboard.current = false;
|
|
409
|
+
},
|
|
329
410
|
onKeyDown: (e) => {
|
|
411
|
+
editEndedByKeyboard.current = true;
|
|
330
412
|
if (e.key === "Escape") {
|
|
331
413
|
setEditingId(null);
|
|
332
414
|
e.stopPropagation();
|
|
@@ -336,6 +418,7 @@ const ThreadView = memo(function ThreadView2({
|
|
|
336
418
|
CommentComposer,
|
|
337
419
|
{
|
|
338
420
|
author: card.author,
|
|
421
|
+
leading: card.renderAvatar?.(card.author),
|
|
339
422
|
placeholder: msg(messages.commentsEditPlaceholder),
|
|
340
423
|
value: editText,
|
|
341
424
|
onChange: setEditText,
|
|
@@ -363,7 +446,8 @@ const ThreadView = memo(function ThreadView2({
|
|
|
363
446
|
}
|
|
364
447
|
),
|
|
365
448
|
actions: canComment && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
366
|
-
|
|
449
|
+
/* @__PURE__ */ jsx(CommentReactionPicker, { comment, currentUserId }),
|
|
450
|
+
(permissions?.edit || permissions?.delete) && /* @__PURE__ */ jsx(MoreOptionsMenu, { id: `comment-actions-${comment.id}`, moreFor: comment.id, children: /* @__PURE__ */ jsxs(TldrawUiDropdownMenuGroup, { children: [
|
|
367
451
|
permissions?.edit && /* @__PURE__ */ jsx(
|
|
368
452
|
MenuItem,
|
|
369
453
|
{
|
|
@@ -375,12 +459,10 @@ const ThreadView = memo(function ThreadView2({
|
|
|
375
459
|
MenuItem,
|
|
376
460
|
{
|
|
377
461
|
label: msg(messages.actionDelete),
|
|
378
|
-
danger: true,
|
|
379
462
|
onClick: () => deleteComment(editor, comment)
|
|
380
463
|
}
|
|
381
464
|
)
|
|
382
|
-
] })
|
|
383
|
-
/* @__PURE__ */ jsx(CommentReactionPicker, { comment, currentUserId })
|
|
465
|
+
] }) })
|
|
384
466
|
] })
|
|
385
467
|
}
|
|
386
468
|
);
|
|
@@ -388,39 +470,37 @@ const ThreadView = memo(function ThreadView2({
|
|
|
388
470
|
const resolveLabel = msg(thread.resolved ? messages.commentsReopen : messages.commentsResolve);
|
|
389
471
|
const headerActions = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
390
472
|
ThreadActions && /* @__PURE__ */ jsx(ThreadActions, { thread, comments }),
|
|
391
|
-
(threadHref !== void 0 || canDeleteThread) && /* @__PURE__ */ jsxs(MoreOptionsMenu, { id: `comment-thread-actions-${thread.id}`, children: [
|
|
392
|
-
threadHref !== void 0 && /* @__PURE__ */ jsx(
|
|
393
|
-
MenuItem,
|
|
394
|
-
{
|
|
395
|
-
label: msg(linkCopied ? messages.commentsLinkCopied : messages.commentsCopyLink),
|
|
396
|
-
noClose: true,
|
|
397
|
-
onClick: copyThreadLink
|
|
398
|
-
}
|
|
399
|
-
),
|
|
400
|
-
canDeleteThread && /* @__PURE__ */ jsx(MenuItem, { label: msg(messages.commentsDelete), danger: true, onClick: removeThread })
|
|
401
|
-
] }),
|
|
402
473
|
canComment && currentUserId && /* @__PURE__ */ jsx(
|
|
403
474
|
TldrawUiButton,
|
|
404
475
|
{
|
|
405
476
|
type: "icon",
|
|
406
477
|
tooltip: resolveLabel,
|
|
407
478
|
title: resolveLabel,
|
|
408
|
-
className: "tlui-cmt-
|
|
479
|
+
className: "tlui-cmt-icon-btn",
|
|
409
480
|
onClick: toggleResolve,
|
|
410
481
|
children: /* @__PURE__ */ jsx(TldrawUiIcon, { icon: "check", label: resolveLabel, small: true })
|
|
411
482
|
}
|
|
412
483
|
),
|
|
413
|
-
/* @__PURE__ */
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
484
|
+
/* @__PURE__ */ jsxs(MoreOptionsMenu, { id: `comment-thread-actions-${thread.id}`, children: [
|
|
485
|
+
(threadHref !== void 0 || canDeleteThread) && /* @__PURE__ */ jsxs(TldrawUiDropdownMenuGroup, { children: [
|
|
486
|
+
threadHref !== void 0 && /* @__PURE__ */ jsx(
|
|
487
|
+
MenuItem,
|
|
488
|
+
{
|
|
489
|
+
label: msg(linkCopied ? messages.commentsLinkCopied : messages.commentsCopyLink),
|
|
490
|
+
noClose: true,
|
|
491
|
+
onClick: copyThreadLink
|
|
492
|
+
}
|
|
493
|
+
),
|
|
494
|
+
canDeleteThread && /* @__PURE__ */ jsx(MenuItem, { label: msg(messages.commentsDelete), onClick: removeThread })
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ jsx(TldrawUiDropdownMenuGroup, { children: /* @__PURE__ */ jsx(
|
|
497
|
+
MenuItem,
|
|
498
|
+
{
|
|
499
|
+
label: msg(messages.commentsClose),
|
|
500
|
+
onClick: () => openThreadId.set(editor, null)
|
|
501
|
+
}
|
|
502
|
+
) })
|
|
503
|
+
] })
|
|
424
504
|
] });
|
|
425
505
|
return /* @__PURE__ */ jsx(
|
|
426
506
|
CommentThread,
|
|
@@ -434,6 +514,10 @@ const ThreadView = memo(function ThreadView2({
|
|
|
434
514
|
}) : void 0,
|
|
435
515
|
composer: canReply ? {
|
|
436
516
|
author: me ?? UNKNOWN_COMMENT_AUTHOR,
|
|
517
|
+
leading: avatarRenderer(
|
|
518
|
+
options.components,
|
|
519
|
+
currentUserId
|
|
520
|
+
)?.(me ?? UNKNOWN_COMMENT_AUTHOR),
|
|
437
521
|
placeholder: msg(messages.commentsReplyPlaceholder),
|
|
438
522
|
sendLabel: msg(messages.commentsSend),
|
|
439
523
|
value: reply,
|
|
@@ -465,6 +549,7 @@ export {
|
|
|
465
549
|
ThreadPopover,
|
|
466
550
|
ThreadView,
|
|
467
551
|
absoluteThreadLink,
|
|
552
|
+
avatarRenderer,
|
|
468
553
|
toCardProps,
|
|
469
554
|
useResolveName
|
|
470
555
|
};
|