diff --git a/src/lib/components/CodeEditor.svelte b/src/lib/components/CodeEditor.svelte index 935e302..a035e06 100644 --- a/src/lib/components/CodeEditor.svelte +++ b/src/lib/components/CodeEditor.svelte @@ -11,12 +11,18 @@ content?: string; language?: 'markdown' | 'asciidoc' | 'text'; onChange?: (value: string) => void; + onSelection?: (selectedText: string, startLine: number, endLine: number, startPos: number, endPos: number) => void; + readOnly?: boolean; + highlights?: Array<{ id: string; startLine: number; endLine: number; content: string }>; } let { content = $bindable(''), language = $bindable('text'), - onChange = () => {} + onChange = () => {}, + onSelection = () => {}, + readOnly = false, + highlights = [] }: Props = $props(); let editorView: EditorView | null = null; @@ -44,7 +50,26 @@ const newContent = update.state.doc.toString(); onChange(newContent); } - }) + + // Handle text selection + if (update.selectionSet && !readOnly) { + const selection = update.state.selection.main; + if (!selection.empty) { + const selectedText = update.state.doc.sliceString(selection.from, selection.to); + const startLine = update.state.doc.lineAt(selection.from); + const endLine = update.state.doc.lineAt(selection.to); + + onSelection( + selectedText, + startLine.number, + endLine.number, + selection.from, + selection.to + ); + } + } + }), + EditorView.editable.of(!readOnly) ] }); diff --git a/src/lib/components/PRDetail.svelte b/src/lib/components/PRDetail.svelte new file mode 100644 index 0000000..9f7927e --- /dev/null +++ b/src/lib/components/PRDetail.svelte @@ -0,0 +1,661 @@ + + +
{highlight.highlightedContent}
+ No pull requests found. Create one to get started!