aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-05-14 23:16:04 -0400
committerbobzel <zzzman@gmail.com>2024-05-14 23:16:04 -0400
commit6a332d5c1e248d976c44eecc67161b4d1b401a0e (patch)
tree7ab811cd5350578c8b7daf731236765b10daf154
parent3534aaf88a3c30a474b3b5a5b7f04adfe6f15fac (diff)
post merge fixes for sarah-ai-visualizatoin
-rw-r--r--src/client/views/DocComponent.tsx2
-rw-r--r--src/client/views/nodes/DataVizBox/utils/D3Utils.ts5
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx10
-rw-r--r--src/client/views/nodes/generativeFill/GenerativeFill.tsx6
4 files changed, 16 insertions, 7 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 94e84e647..e5752dcd2 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -233,7 +233,7 @@ export function ViewBoxAnnotatableComponent<P extends FieldViewProps>() {
const annoDocs = Doc.Get(targetDataDoc, annotationKey ?? this.annotationKey, true) as List<Doc>; // get the dataDoc directly ... when using templates there may be some default items already there, but we can't change them, so we copy them below (should really be some kind of inheritance since the template contents could change)
if (annoDocs instanceof List) annoDocs.push(...added.filter(add => !annoDocs.includes(add)));
- else targetDataDoc[annotationKey ?? this.annotationKey] = new List<Doc>([...added, ...(annoDocs === undefined ? DocListCast(targetDataDoc[annotationKey ?? this.annotationKey]) : [])]);
+ else targetDataDoc[annotationKey || this.annotationKey] = new List<Doc>([...added, ...(annoDocs === undefined ? DocListCast(targetDataDoc[annotationKey ?? this.annotationKey]) : [])]);
targetDataDoc[(annotationKey ?? this.annotationKey) + '_modificationDate'] = new DateField();
}
}
diff --git a/src/client/views/nodes/DataVizBox/utils/D3Utils.ts b/src/client/views/nodes/DataVizBox/utils/D3Utils.ts
index be05c3529..ffc859c92 100644
--- a/src/client/views/nodes/DataVizBox/utils/D3Utils.ts
+++ b/src/client/views/nodes/DataVizBox/utils/D3Utils.ts
@@ -1,6 +1,9 @@
import * as d3 from 'd3';
-import { DataPoint } from '../components/LineChart';
+export interface DataPoint {
+ x: number;
+ y: number;
+}
// TODO: nda - implement function that can handle range for strings
export const minMaxRange = (dataPts: DataPoint[][]) => {
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index e62a639c8..93cb67491 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -955,7 +955,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
icon: 'star',
});
optionItems.push({ description: `Generate Dall-E Image`, event: () => this.generateImage(), icon: 'star' });
- optionItems.push({ description: `Ask GPT-3`, event: () => this.askGPT(), icon: 'lightbulb' });
+ optionItems.push({ description: `Ask GPT-3`, event: this.askGPT, icon: 'lightbulb' });
this._props.renderDepth &&
optionItems.push({
description: !this.Document._createDocOnCR ? 'Create New Doc on Carriage Return' : 'Allow Carriage Returns',
@@ -989,6 +989,8 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
askGPT = action(async () => {
try {
+ GPTPopup.Instance.setSidebarId(this.SidebarKey);
+ GPTPopup.Instance.addDoc = this.sidebarAddDocument;
const res = await gptAPICall((this.dataDoc.text as RichTextField)?.Text, GPTCallType.COMPLETION);
if (!res) {
this.animateRes(0, 'Something went wrong.');
@@ -1573,7 +1575,11 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
e.preventDefault();
}
};
- onSelectEnd = (): void => document.removeEventListener('pointerup', this.onSelectEnd);
+ onSelectEnd = () => {
+ GPTPopup.Instance.setSidebarId(this.SidebarKey);
+ GPTPopup.Instance.addDoc = this.sidebarAddDocument;
+ document.removeEventListener('pointerup', this.onSelectEnd);
+ };
onPointerUp = (e: React.PointerEvent): void => {
const state = this.EditorView?.state;
if (state && this.ProseRef?.children[0].className.includes('-focused') && this._props.isContentActive() && !e.button) {
diff --git a/src/client/views/nodes/generativeFill/GenerativeFill.tsx b/src/client/views/nodes/generativeFill/GenerativeFill.tsx
index 25289967e..6d8ba9222 100644
--- a/src/client/views/nodes/generativeFill/GenerativeFill.tsx
+++ b/src/client/views/nodes/generativeFill/GenerativeFill.tsx
@@ -535,14 +535,14 @@ const GenerativeFill = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addD
key={i}
alt="image edits"
width={75}
- src={edit[0] as string}
+ src={edit.url}
style={{ cursor: 'pointer' }}
onClick={async () => {
const img = new Image();
- img.src = edit[0] as string;
+ img.src = edit.url;
ImageUtility.drawImgToCanvas(img, canvasRef, canvasDims.width, canvasDims.height);
currImg.current = img;
- parentDoc.current = edit[1] as Doc;
+ parentDoc.current = edit.saveRes ?? null;
}}
/>
))}