From 04669ffeb163688c7aefd7b5face7998252abdca Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 10 Mar 2025 18:02:07 -0400 Subject: removed label creation from text's anchor menu. removed label creation from pdfs. --- src/client/views/pdf/AnchorMenu.tsx | 53 +++---------------------------------- src/client/views/pdf/PDFViewer.tsx | 8 +++--- 2 files changed, 8 insertions(+), 53 deletions(-) (limited to 'src/client/views/pdf') diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index 9aa8fe649..eaaeb8d97 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -1,24 +1,19 @@ import { ColorPicker, Group, IconButton, Popup, Size, Toggle, ToggleType, Type } from '@dash/components'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { IReactionDisposer, ObservableMap, action, computed, makeObservable, observable, reaction, runInAction } from 'mobx'; +import { IReactionDisposer, ObservableMap, action, computed, makeObservable, observable, reaction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { ColorResult } from 'react-color'; -import ReactLoading from 'react-loading'; import { ClientUtils, returnFalse, setupMoveUpEvents } from '../../../ClientUtils'; import { emptyFunction, unimplementedFunction } from '../../../Utils'; import { Doc, Opt } from '../../../fields/Doc'; -import { DocData } from '../../../fields/DocSymbols'; import { SettingsManager } from '../../util/SettingsManager'; -import { undoBatch } from '../../util/UndoManager'; import { AntimodeMenu, AntimodeMenuProps } from '../AntimodeMenu'; import { LinkPopup } from '../linking/LinkPopup'; import { ComparisonBox } from '../nodes/ComparisonBox'; import { DocumentView } from '../nodes/DocumentView'; -import { DrawingOptions, SmartDrawHandler } from '../smartdraw/SmartDrawHandler'; import './AnchorMenu.scss'; import { GPTPopup } from './GPTPopup/GPTPopup'; -import { RichTextMenu } from '../nodes/formattedText/RichTextMenu'; @observer export class AnchorMenu extends AntimodeMenu { @@ -116,39 +111,6 @@ export class AnchorMenu extends AntimodeMenu { ); }; - /** - * Creates a GPT drawing based on selected text. - */ - gptDraw = (e: React.PointerEvent) => { - try { - SmartDrawHandler.Instance.AddDrawing = this.createDrawingAnnotation; - runInAction(() => (this._isLoading = true)); - SmartDrawHandler.Instance.drawWithGPT({ X: e.clientX, Y: e.clientY }, this._selectedText, 5, 100, true)?.then( - action(() => { - this._isLoading = false; - }) - ); - } catch (err) { - console.error(err); - } - }; - - /** - * Defines how a GPT drawing should be added to the current document. - */ - @undoBatch - createDrawingAnnotation = action((drawing: Doc, opts: DrawingOptions, gptRes: string) => { - this.AddDrawingAnnotation(drawing); - const docData = drawing[DocData]; - docData.title = opts.text?.match(/^(.*?)~~~.*$/)?.[1] || opts.text; - docData.ai_drawing_input = opts.text; - docData.ai_drawing_complexity = opts.complexity; - docData.ai_drawing_colored = opts.autoColor; - docData.ai_drawing_size = opts.size; - docData.ai_drawing_data = gptRes; - docData.ai = 'gpt'; - }); - pointerDown = (e: React.PointerEvent) => { setupMoveUpEvents( this, @@ -232,17 +194,8 @@ export class AnchorMenu extends AntimodeMenu { /> )} {/* Adds a create flashcards option to the anchor menu, which calls the gptFlashcard method. */} - } color={SettingsManager.userColor} /> - } color={SettingsManager.userColor} /> - {this._selectedText && ( - this.gptDraw(e)} - icon={this._isLoading ? : } - color={SettingsManager.userColor} - /> - )} - {this._selectedText && RichTextMenu.Instance?.createLinkButton()} + {this.gptFlashcards === unimplementedFunction ? null : } color={SettingsManager.userColor} />} + {this.makeLabels === unimplementedFunction ? null : } color={SettingsManager.userColor} />} {AnchorMenu.Instance.OnAudio === unimplementedFunction ? null : ( { */ gptPDFFlashcards = async () => { const queryText = this._selectionText; - this._loading = true; + runInAction(() => (this._loading = true)); try { const res = await gptAPICall(queryText, GPTCallType.FLASHCARD); @@ -406,11 +406,12 @@ export class PDFViewer extends ObservableReactComponent { } catch (err) { console.error(err); } - this._loading = false; + runInAction(() => (this._loading = false)); }; @action finishMarquee = (/* x?: number, y?: number */) => { + AnchorMenu.Instance.makeLabels = unimplementedFunction; this._getAnchor = AnchorMenu.Instance?.GetAnchor; this.isAnnotating = false; this._marqueeref.current?.onTerminateSelection(); @@ -442,6 +443,7 @@ export class PDFViewer extends ObservableReactComponent { // allows for creating collection AnchorMenu.Instance.addToCollection = this._props.DocumentView?.()._props.addDocument; AnchorMenu.Instance.gptFlashcards = this.gptPDFFlashcards; + AnchorMenu.Instance.makeLabels = unimplementedFunction; AnchorMenu.Instance.AddDrawingAnnotation = this.addDrawingAnnotation; }; -- cgit v1.2.3-70-g09d2