12ed7123ab
* fix: support markdown preview comments * fix: address markdown preview review feedback * fix: address markdown preview comment scope * fix: address markdown preview follow-up feedback * fix: preserve markdown preview run action in file tabs * fix: ignore svg clicks in markdown preview controls * fix: ignore svg markdown preview selection targets
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import type { DiffComment } from "@/lib/state/slices/comments";
|
|
import { buildDiffComment } from "@/lib/diff/comment-utils";
|
|
import type { SourceLineRange } from "./source-line-ranges";
|
|
|
|
export type BuildMarkdownPreviewCommentArgs = SourceLineRange & {
|
|
filePath: string;
|
|
repositoryId?: string;
|
|
sessionId: string;
|
|
selectedText: string;
|
|
text: string;
|
|
};
|
|
|
|
export function buildMarkdownPreviewComment(args: BuildMarkdownPreviewCommentArgs): DiffComment {
|
|
const comment = buildDiffComment({
|
|
filePath: args.filePath,
|
|
sessionId: args.sessionId,
|
|
startLine: args.startLine,
|
|
endLine: args.endLine,
|
|
side: "additions",
|
|
text: args.text,
|
|
codeContent: args.selectedText,
|
|
});
|
|
if (args.repositoryId) comment.repositoryId = args.repositoryId;
|
|
return comment;
|
|
}
|
|
|
|
export function commentsOverlapRange(comments: DiffComment[], range: SourceLineRange): boolean {
|
|
return comments.some(
|
|
(comment) => comment.startLine <= range.endLine && comment.endLine >= range.startLine,
|
|
);
|
|
}
|
|
|
|
export function commentsBeginInRange(comments: DiffComment[], range: SourceLineRange): boolean {
|
|
return comments.some(
|
|
(comment) => comment.startLine >= range.startLine && comment.startLine <= range.endLine,
|
|
);
|
|
}
|