diff options
author | Sophie Zhang <sophie_zhang@brown.edu> | 2023-04-13 01:50:41 -0400 |
---|---|---|
committer | Sophie Zhang <sophie_zhang@brown.edu> | 2023-04-13 01:50:41 -0400 |
commit | cd30c14116bbbab16c21a7ecc31090d2b4bf413f (patch) | |
tree | 3373db680316825e3315b131e74028436bc742d7 /src | |
parent | 65781ccf9a3f19578cf4a51bca65b35c05c0795b (diff) |
cleaning
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/pdf/AnchorMenu.tsx | 13 | ||||
-rw-r--r-- | src/client/views/pdf/GPTPopup/GPTPopup.scss | 4 | ||||
-rw-r--r-- | src/client/views/pdf/GPTPopup/GPTPopup.tsx | 24 |
3 files changed, 22 insertions, 19 deletions
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<AntimodeMenuProps> { // 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<AntimodeMenuProps> { @action setLoading = (loading: boolean) => { - this.loadingSummary = loading; + this.loadingGPT = loading; }; @action @@ -203,9 +203,10 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { 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<AntimodeMenuProps> { 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<AntimodeMenuProps> { </Tooltip> )} {this.canEdit() && ( - <Tooltip key="gpttextedit" title={<div className="dash-tooltip">Edit text with AI</div>}> + <Tooltip key="gpttextedit" title={<div className="dash-tooltip">AI edit suggestions</div>}> <button className="antimodeMenu-button annotate" onPointerDown={this.gptEdit} style={{ cursor: 'grab' }}> <FontAwesomeIcon icon="pencil-alt" size="lg" /> </button> 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<GPTPopupProps> { editBox = () => { const hr = this.props.highlightRange; return ( - hr && ( - <> - <div> - {this.heading('TEXT EDIT SUGGESTIONS')} - <div className="content-wrapper"> + <> + <div> + {this.heading('TEXT EDIT SUGGESTIONS')} + <div className="content-wrapper"> + {hr && ( <div> {this.props.text.slice(0, hr[0])} <span className="highlighted-text">{this.props.text.slice(hr[0], hr[1])}</span> {this.props.text.slice(hr[1])} </div> - </div> + )} </div> - {!this.props.loading && ( + </div> + {hr && !this.props.loading && ( + <> <div className="btns-wrapper"> <> <button className="icon-btn" onPointerDown={e => this.props.callEditApi(e)}> @@ -152,10 +154,10 @@ export class GPTPopup extends React.Component<GPTPopupProps> { </button> </> </div> - )} - {this.aiWarning()} - </> - ) + {this.aiWarning()} + </> + )} + </> ); }; |