aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/nodes/ComparisonBox.tsx6
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx13
2 files changed, 16 insertions, 3 deletions
diff --git a/src/client/views/nodes/ComparisonBox.tsx b/src/client/views/nodes/ComparisonBox.tsx
index 338604302..9d9535abd 100644
--- a/src/client/views/nodes/ComparisonBox.tsx
+++ b/src/client/views/nodes/ComparisonBox.tsx
@@ -116,7 +116,7 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
<FontAwesomeIcon icon="lightbulb" size="xl" />
</div>
</Tooltip>
- {DocCast(this.Document.embedContainer).type_collection === 'carousel' ? null : (
+ {DocCast(this.Document.embedContainer)?.type_collection === CollectionViewType.Carousel ? null : (
<div>
<Tooltip title={<div>Create a flashcard pile</div>}>
<div style={{ position: 'absolute', bottom: '3px', right: '74px', cursor: 'pointer' }} onPointerDown={e => this.createFlashcardPile([this.Document], false)}>
@@ -688,13 +688,13 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
// (!this.dataDoc[this.fieldKey + '_0'] && this.dataDoc[this._props.fieldKey + '_0'] !== 'empty')
if (!this.dataDoc[this.fieldKey + '_0'] && !this._isEmpty) {
const dataSplit = StrCast(this.dataDoc.data).includes('Keyword: ') ? StrCast(this.dataDoc.data).split('Keyword: ') : StrCast(this.dataDoc.data).split('Answer: ');
- const newDoc = Docs.Create.TextDocument(dataSplit[1]);
+ const newDoc = Docs.Create.TextDocument(dataSplit[1], { _layout_autoHeight: true });
this.addDoc(newDoc, this.fieldKey + '_0');
}
if (!this.dataDoc[this.fieldKey + '_1'] && !this._isEmpty) {
const dataSplit = StrCast(this.dataDoc.data).includes('Keyword: ') ? StrCast(this.dataDoc.data).split('Keyword: ') : StrCast(this.dataDoc.data).split('Answer: ');
- const newDoc = Docs.Create.TextDocument(dataSplit[0]);
+ const newDoc = Docs.Create.TextDocument(dataSplit[0], { _layout_autoHeight: true });
this.addDoc(newDoc, this.fieldKey + '_1');
}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index c8e020192..07a4d1093 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -213,9 +213,22 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
return anchor;
};
+ gptPDFFlashcards = async () => {
+ const queryText = window.getSelection()?.toString() ?? '';
+ try {
+ if (queryText) {
+ const res = await gptAPICall(queryText, GPTCallType.FLASHCARD);
+ AnchorMenu.Instance.transferToFlashcard(res || 'Something went wrong', NumCast(this.layoutDoc.x), NumCast(this.layoutDoc.y));
+ }
+ } catch (err) {
+ console.error(err);
+ }
+ };
+
@action
setupAnchorMenu = () => {
AnchorMenu.Instance.Status = 'marquee';
+ AnchorMenu.Instance.gptFlashcards = this.gptPDFFlashcards;
AnchorMenu.Instance.OnClick = () => {
!this.layoutDoc.layout_showSidebar && this.toggleSidebar();
setTimeout(() => this._sidebarRef.current?.anchorMenuClick(this.makeLinkAnchor(undefined, OpenWhere.addRight, undefined, 'Anchored Selection', true))); // give time for sidebarRef to be created