diff options
| author | bobzel <zzzman@gmail.com> | 2024-10-11 22:01:50 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-10-11 22:01:50 -0400 |
| commit | 737efc3e6cada537536c7bc5e46f5b57970da276 (patch) | |
| tree | 2be4f30196f829fea4c9579875bef4e0fe5fa393 /src/client/views/pdf | |
| parent | bb8fe2933154c6db70cfe5da1e890535bc9012d4 (diff) | |
Lots of cleanup in comparisonBox to get rid of duplicated code and siimplify long functions. Utility functions were added to ComparisonBox to simplify menu functions, and to FormattedTextBox to simplify creating centered text views.
Diffstat (limited to 'src/client/views/pdf')
| -rw-r--r-- | src/client/views/pdf/AnchorMenu.tsx | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index 7243473e0..5ab9b556c 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -10,7 +10,6 @@ import { emptyFunction, unimplementedFunction } from '../../../Utils'; import { Doc, Opt } from '../../../fields/Doc'; import { DocData } from '../../../fields/DocSymbols'; import { GPTCallType, gptAPICall } from '../../apis/gpt/GPT'; -import { Docs } from '../../documents/Documents'; import { SettingsManager } from '../../util/SettingsManager'; import { undoBatch } from '../../util/UndoManager'; import { AntimodeMenu, AntimodeMenuProps } from '../AntimodeMenu'; @@ -19,6 +18,7 @@ import { DocumentView } from '../nodes/DocumentView'; import { DrawingOptions, SmartDrawHandler } from '../smartdraw/SmartDrawHandler'; import './AnchorMenu.scss'; import { GPTPopup, GPTPopupMode } from './GPTPopup/GPTPopup'; +import { ComparisonBox } from '../nodes/ComparisonBox'; @observer export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { @@ -117,29 +117,15 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { */ transferToFlashcard = (text: string, x: number, y: number) => { - // put each question generated by GPT on the front of the flashcard - const senArr = text.trim().split('Question:'); - const collectionArr: Doc[] = []; - for (let i = 1; i < senArr.length; i++) { - const newDoc = Docs.Create.ComparisonDocument(senArr[i], { _layout_isFlashcard: true, _width: 300, _height: 300 }); - newDoc.text = senArr[i]; - - collectionArr.push(newDoc); - } - // create a new carousel collection of these flashcards - const newCol = Docs.Create.CarouselDocument(collectionArr, { - _width: 250, - _height: 200, - _layout_fitWidth: false, - _layout_autoHeight: true, - }); - - newCol.x = x; - newCol.y = y; - newCol.zIndex = 1000; - - this.addToCollection?.(newCol); - this._loading = false; + ComparisonBox.createFlashcardDeck(text, 250, 200, 'data_front', 'data_back').then( + action(newCol => { + newCol.x = x; + newCol.y = y; + newCol.zIndex = 1000; + this.addToCollection?.(newCol); + this._loading = false; + }) + ); }; /** |
