From cd30c14116bbbab16c21a7ecc31090d2b4bf413f Mon Sep 17 00:00:00 2001 From: Sophie Zhang Date: Thu, 13 Apr 2023 01:50:41 -0400 Subject: cleaning --- src/client/views/pdf/AnchorMenu.tsx | 13 +++++++------ src/client/views/pdf/GPTPopup/GPTPopup.scss | 4 ++-- src/client/views/pdf/GPTPopup/GPTPopup.tsx | 24 +++++++++++++----------- 3 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index c38a83238..620750f36 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -48,7 +48,7 @@ export class AnchorMenu extends AntimodeMenu { // GPT additions @observable private GPTpopupText: string = ''; - @observable private loadingSummary: boolean = false; + @observable private loadingGPT: boolean = false; @observable private showGPTPopup: boolean = false; @observable private GPTMode: GPTPopupMode = GPTPopupMode.SUMMARY; @observable private selectedText: string = ''; @@ -73,7 +73,7 @@ export class AnchorMenu extends AntimodeMenu { @action setLoading = (loading: boolean) => { - this.loadingSummary = loading; + this.loadingGPT = loading; }; @action @@ -203,9 +203,10 @@ export class AnchorMenu extends AntimodeMenu { try { let res = await gptAPICall(selectedText, GPTCallType.EDIT); - // let res = await this.mockGPTCall(); + // let res = await this.mockGPTCall(); + if (!res) return; res = res.trim(); - const resultText = fullText.slice(0, sel.from - 1) + res + fullText.slice(sel.to); + const resultText = fullText.slice(0, sel.from - 1) + res + fullText.slice(sel.to - 1); if (res) { this.setGPTPopupText(resultText); @@ -368,7 +369,7 @@ export class AnchorMenu extends AntimodeMenu { visible={this.showGPTPopup} text={this.GPTpopupText} highlightRange={this.highlightRange} - loading={this.loadingSummary} + loading={this.loadingGPT} callSummaryApi={this.gptSummarize} callEditApi={this.gptEdit} replaceText={this.replaceText} @@ -382,7 +383,7 @@ export class AnchorMenu extends AntimodeMenu { )} {this.canEdit() && ( - Edit text with AI}> + AI edit suggestions}> diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.scss b/src/client/views/pdf/GPTPopup/GPTPopup.scss index 50fbe5211..44413ede7 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.scss +++ b/src/client/views/pdf/GPTPopup/GPTPopup.scss @@ -13,8 +13,8 @@ $highlightedText: #82e0ff; box-shadow: 0 2px 5px #7474748d; color: $textgrey; position: fixed; - bottom: 5px; - right: 5px; + bottom: 10px; + right: 10px; width: 250px; min-height: 200px; border-radius: 15px; diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index 91bc0a7ff..cc0072a94 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -127,17 +127,19 @@ export class GPTPopup extends React.Component { editBox = () => { const hr = this.props.highlightRange; return ( - hr && ( - <> -
- {this.heading('TEXT EDIT SUGGESTIONS')} -
+ <> +
+ {this.heading('TEXT EDIT SUGGESTIONS')} +
+ {hr && (
{this.props.text.slice(0, hr[0])} {this.props.text.slice(hr[0], hr[1])} {this.props.text.slice(hr[1])}
-
+ )}
- {!this.props.loading && ( +
+ {hr && !this.props.loading && ( + <>
<>
- )} - {this.aiWarning()} - - ) + {this.aiWarning()} + + )} + ); }; -- cgit v1.2.3-70-g09d2