diff options
| author | bobzel <zzzman@gmail.com> | 2024-05-08 23:16:54 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-05-08 23:16:54 -0400 |
| commit | d40efe81ab30485266b7b686dfb35c531e75a568 (patch) | |
| tree | f12c9b151e1c6b35f4afa3962595386ce596e37c /src/client/views/pdf/AnchorMenu.tsx | |
| parent | b858bd3cad81da41e63b9f8e807e41421ca4aa34 (diff) | |
fixed text selection on web pages. cleaned up gptSummarize to work on any text.
Diffstat (limited to 'src/client/views/pdf/AnchorMenu.tsx')
| -rw-r--r-- | src/client/views/pdf/AnchorMenu.tsx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index a837969aa..495ea59f0 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -36,10 +36,10 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { @observable public Status: 'marquee' | 'annotation' | '' = ''; // GPT additions - @observable private selectedText: string = ''; + @observable private _selectedText: string = ''; @action public setSelectedText = (txt: string) => { - this.selectedText = txt; + this._selectedText = txt.trim(); }; public onMakeAnchor: () => Opt<Doc> = () => undefined; // Method to get anchor from text search @@ -76,7 +76,7 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { * @param e pointer down event */ gptSummarize = async () => { - GPTPopup.Instance?.setSelectedText(this.selectedText); + GPTPopup.Instance?.setSelectedText(this._selectedText); GPTPopup.Instance.generateSummary(); }; @@ -140,13 +140,6 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { this.highlightColor = ClientUtils.colorString(col); }; - /** - * Returns whether the selected text can be summarized. The goal is to have - * all selected text available to summarize but its only supported for pdf and web ATM. - * @returns Whether the GPT icon for summarization should appear - */ - canSummarize = () => DocumentView.SelectedDocs().some(doc => [DocumentType.PDF, DocumentType.WEB].includes(doc.type as any)); - render() { const buttons = this.Status === 'marquee' ? ( @@ -161,7 +154,7 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { /> </div> {/* GPT Summarize icon only shows up when text is highlighted, not on marquee selection */} - {AnchorMenu.Instance.StartCropDrag === unimplementedFunction && this.canSummarize() && ( + {this._selectedText && ( <IconButton tooltip="Summarize with AI" // onPointerDown={this.gptSummarize} |
