diff options
Diffstat (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')
| -rw-r--r-- | src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx | 101 |
1 files changed, 100 insertions, 1 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index 98f242ebf..14fdd9b8d 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -418,16 +418,88 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { * @param options Other optional document options (e.g. color) * @param id The unique ID for the document. */ + + // @action + // createDocInDash = async (docs: string[]) => { + // console.log('DOCS HERE' + docs); + // docs.forEach(doc => { + // const parsedDoc = JSON.parse(doc); + // this.createIndivDocInDash(parsedDoc.doc_type, parsedDoc.data, parsedDoc.options, ''); + // }); + // }; + @action createDocInDash = async (doc_type: string, data: string, options: DocumentOptions, id: string) => { + console.log('INDIV DOC' + doc_type); let doc; switch (doc_type) { case 'text': doc = DocCast(Docs.Create.TextDocument(data, options)); + break; + case 'flashcard': + doc = this.createFlashcard(data, options); + break; + case 'image': + doc = DocCast(Docs.Create.ImageDocument(data, options)); + break; + case 'equation': + doc = DocCast(Docs.Create.EquationDocument('', options)); + break; + case 'noteboard': + doc = DocCast(Docs.Create.NoteTakingDocument([], options)); + break; + case 'simulation': + doc = DocCast(Docs.Create.SimulationDocument(options)); + break; + case 'collection': + doc = DocCast(Docs.Create.FreeformDocument([], options)); + break; + case 'web': + doc = DocCast(Docs.Create.WebDocument(data, options)); + break; + case 'comparison': + doc = Docs.Create.ComparisonDocument('', options); + break; + case 'diagram': + doc = Docs.Create.DiagramDocument(options); + break; + case 'audio': + doc = Docs.Create.AudioDocument(data, options); + break; + case 'map': + doc = Docs.Create.MapDocument([], options); + break; + case 'screengrab': + doc = Docs.Create.ScreenshotDocument(options); + break; + case 'webcam': + doc = Docs.Create.WebCamDocument('', options); + break; + case 'button': + doc = Docs.Create.ButtonDocument(options); + break; + case 'script': + doc = Docs.Create.ScriptingDocument(null, options); + break; + case 'dataviz': + doc = Docs.Create.DataVizDocument('/users/rz/Downloads/addresses.csv', options); + break; + case 'chat': + doc = Docs.Create.ChatDocument(options); + break; + case 'trail': + doc = Docs.Create.PresDocument(options); + break; + case 'tab': + doc = Docs.Create.FreeformDocument([], options); + break; + case 'slide': + doc = Docs.Create.TreeDocument([], options); + break; default: doc = DocCast(Docs.Create.TextDocument(data, options)); } - + console.log('DOC' + doc_type); const linkDoc = Docs.Create.LinkDocument(this.Document, doc); LinkManager.Instance.addLink(linkDoc); @@ -435,6 +507,33 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { await DocumentManager.Instance.showDocument(doc, { willZoomCentered: true }, () => {}); }; + // TODO: DELEGATE TO DIFFERENT CLASS + @action + createFlashcard = (data: string, options: DocumentOptions) => { + const flashcardDeck: Doc[] = []; + const parsedItems: { [key: string]: string } = JSON.parse(data); + Object.entries(parsedItems).forEach(([key, val]) => { + console.log('key' + key); + console.log('key' + val); + + const side1 = Docs.Create.CenteredTextCreator('question', key, options); + const side2 = Docs.Create.CenteredTextCreator('answer', val, options); + const doc = DocCast(Docs.Create.FlashcardDocument(data, side1, side2, { _width: 300, _height: 300 })); + this._props.addDocument?.(doc); + flashcardDeck.push(doc); + }); + const col = DocCast( + Docs.Create.CarouselDocument(flashcardDeck, { + title: options.title, + _width: 300, + _height: 300, + _layout_fitWidth: false, + _layout_autoHeight: true, + }) + ); + return col; + }; + /** * Event handler to manage citations click in the message components. * @param citation The citation object clicked by the user. |
