From d95730d904612640184ca6fdc00864b0c81b0c0c Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 18 Sep 2024 20:46:38 -0400
Subject: lots of changes to fix dragging cards, integrate iconTags with other
 tags, sizing docs when selected to fit window,

---
 src/client/views/nodes/formattedText/FormattedTextBox.tsx | 1 +
 1 file changed, 1 insertion(+)

(limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')

diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 343e255dc..e0331a422 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -275,6 +275,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
                 ele.append(contents);
             }
             this._selectionHTML = ele?.innerHTML;
+            // eslint-disable-next-line @typescript-eslint/no-unused-vars
         } catch (e) {
             /* empty */
         }
-- 
cgit v1.2.3-70-g09d2


From e9167b125a59ff08b5d75691500d80359ebb4d41 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 19 Sep 2024 10:42:41 -0400
Subject: fixed setting rotation center.  fixed not dropping docs onto
 themselves.

---
 eslint.config.mjs                                         | 2 +-
 src/client/views/DocumentDecorations.tsx                  | 4 ++--
 src/client/views/collections/CollectionSubView.tsx        | 2 +-
 src/client/views/nodes/formattedText/FormattedTextBox.tsx | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')

diff --git a/eslint.config.mjs b/eslint.config.mjs
index 8926afd7c..706a5ac09 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -47,7 +47,7 @@ export default [
             'no-return-assign': 'error',
             'no-await-in-loop': 'error',
             'no-loop-func': 'error',
-            'no-cond-assign': 'error',
+            '@typescript-eslint/no-cond-assign': 'error',
             'no-use-before-define': 'error',
             '@typescript-eslint/no-explicit-any': 'error',
             'no-restricted-globals': ['error', 'event'],
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 5e7908725..33022fa81 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -340,7 +340,7 @@ export class DocumentDecorations extends ObservableReactComponent<DocumentDecora
 
     setRotateCenter = (seldocview: DocumentView, rotCenter: number[]) => {
         const selDoc = seldocview.Document;
-        const newloccentern = seldocview.screenToContentsTransform().transformPoint(rotCenter[0], rotCenter[1]);
+        const newloccentern = seldocview.screenToViewTransform().transformPoint(rotCenter[0], rotCenter[1]);
         const newlocenter = [newloccentern[0] - NumCast(seldocview.layoutDoc._width) / 2, newloccentern[1] - NumCast(seldocview.layoutDoc._height) / 2];
         const final = Utils.rotPt(newlocenter[0], newlocenter[1], -(NumCast(seldocview.Document._rotation) / 180) * Math.PI);
         selDoc._rotation_centerX = final.x / NumCast(seldocview.layoutDoc._width);
@@ -635,7 +635,7 @@ export class DocumentDecorations extends ObservableReactComponent<DocumentDecora
     @computed get rotCenter() {
         const lastView = DocumentView.Selected().lastElement();
         if (lastView) {
-            const invXf = lastView.screenToContentsTransform().inverse();
+            const invXf = lastView.screenToViewTransform().inverse();
             const seldoc = lastView.layoutDoc;
             const loccenter = Utils.rotPt(NumCast(seldoc._rotation_centerX) * NumCast(seldoc._width), NumCast(seldoc._rotation_centerY) * NumCast(seldoc._height), invXf.Rotate);
             return invXf.transformPoint(loccenter.x + NumCast(seldoc._width) / 2, loccenter.y + NumCast(seldoc._height) / 2);
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 6aca8f2ca..99d6ed28a 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -251,7 +251,7 @@ export function CollectionSubView<X>() {
 
         protected onInternalDrop(e: Event, de: DragManager.DropEvent): boolean {
             const { docDragData } = de.complete;
-            if (docDragData) {
+            if (docDragData && !docDragData.draggedDocuments.includes(this.Document)) {
                 let added;
                 const dropAction = docDragData.dropAction || docDragData.userDropAction;
                 const targetDocments = DocListCast(this.dataDoc[this._props.fieldKey]);
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 343e255dc..7287e2b9f 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -561,7 +561,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
             const draggedDoc = dragData.droppedDocuments.lastElement();
             let added: Opt<boolean>;
             const dropAction = dragData.dropAction || dragData.userDropAction;
-            if ([AclEdit, AclAdmin, AclSelfEdit].includes(effectiveAcl)) {
+            if ([AclEdit, AclAdmin, AclSelfEdit].includes(effectiveAcl) && !dragData.draggedDocuments.includes(this.Document)) {
                 // replace text contents when dragging with Alt
                 if (de.altKey) {
                     const fieldKey = Doc.LayoutFieldKey(draggedDoc);
-- 
cgit v1.2.3-70-g09d2


From ac7f34fa5ee67900714121b700768ebb18b874d1 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sat, 21 Sep 2024 23:26:52 -0400
Subject: added flashcard deck creator to foramtted text box.

---
 src/client/views/nodes/ComparisonBox.tsx                  |  6 +++---
 src/client/views/nodes/formattedText/FormattedTextBox.tsx | 13 +++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

(limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')

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
-- 
cgit v1.2.3-70-g09d2

