From 8a22e73e60d33f26d73b8b34af8b2a32952a4520 Mon Sep 17 00:00:00 2001 From: Red Adaya Date: Mon, 6 May 2024 21:15:54 +0800 Subject: [PATCH] minor fix --- src/app/common/elements/markdown.tsx | 15 +++++----- src/app/sidebar/aichat.tsx | 44 +++++++++++++--------------- src/models/input.ts | 2 +- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/app/common/elements/markdown.tsx b/src/app/common/elements/markdown.tsx index 1fca32a5f..a88386e44 100644 --- a/src/app/common/elements/markdown.tsx +++ b/src/app/common/elements/markdown.tsx @@ -43,17 +43,16 @@ class CodeBlockMarkdown extends React.Component< this.blockIndex = GlobalModel.inputModel.addCodeBlockToCodeSelect(this.blockRef, this.props.uuid); } + @boundMethod + handleClick(e: React.MouseEvent) { + console.log("this.blockIndex", this.blockIndex); + GlobalModel.inputModel.setCodeSelectSelectedCodeBlock(this.blockIndex); + } + render() { - const clickHandler = (e: React.MouseEvent, blockIndex: number) => { - GlobalModel.inputModel.setCodeSelectSelectedCodeBlock(blockIndex); - }; let selected = this.blockIndex == this.props.codeSelectSelectedIndex; return ( -
 clickHandler(event, this.blockIndex)}
-            >
+            
                 {this.props.children}
             
); diff --git a/src/app/sidebar/aichat.tsx b/src/app/sidebar/aichat.tsx index 1890171e6..c8d847fd8 100644 --- a/src/app/sidebar/aichat.tsx +++ b/src/app/sidebar/aichat.tsx @@ -161,6 +161,26 @@ class AIChat extends React.Component<{}, {}> { chatWindowRef: React.RefObject = React.createRef(); termFontSize: number = 14; + componentDidMount() { + const inputModel = GlobalModel.inputModel; + + inputModel.openAIAssistantChat(); + + if (this.textAreaRef.current != null) { + this.textAreaRef.current.focus(); + inputModel.setCmdInfoChatRefs(this.textAreaRef, this.chatWindowRef); + } + this.requestChatUpdate(); + this.onTextAreaChange(null); + } + + requestChatUpdate() { + const chatMessageItems = GlobalModel.inputModel.AICmdInfoChatItems.slice(); + if (chatMessageItems == null || chatMessageItems.length == 0) { + this.submitChatMessage(""); + } + } + // Adjust the height of the textarea to fit the text @boundMethod onTextAreaChange(e: any) { @@ -183,26 +203,6 @@ class AIChat extends React.Component<{}, {}> { GlobalModel.inputModel.codeSelectDeselectAll(); } - componentDidMount() { - const inputModel = GlobalModel.inputModel; - - inputModel.openAIAssistantChat(); - - if (this.textAreaRef.current != null) { - this.textAreaRef.current.focus(); - inputModel.setCmdInfoChatRefs(this.textAreaRef, this.chatWindowRef); - } - this.requestChatUpdate(); - this.onTextAreaChange(null); - } - - requestChatUpdate() { - const chatMessageItems = GlobalModel.inputModel.AICmdInfoChatItems.slice(); - if (chatMessageItems == null || chatMessageItems.length == 0) { - this.submitChatMessage(""); - } - } - submitChatMessage(messageStr: string) { const curLine = GlobalModel.inputModel.curLine; const prtn = GlobalModel.submitChatInfoCommand(messageStr, curLine, false); @@ -222,7 +222,6 @@ class AIChat extends React.Component<{}, {}> { @mobx.action @boundMethod onTextAreaFocused(e: any) { - console.log("focused"); GlobalModel.inputModel.setAuxViewFocus(true); GlobalModel.inputModel.setActiveAuxView(appconst.InputAuxView_AIChat); @@ -307,8 +306,7 @@ class AIChat extends React.Component<{}, {}> { render() { const chatMessageItems = GlobalModel.inputModel.AICmdInfoChatItems.slice(); const renderAIChatKeybindings = GlobalModel.inputModel.shouldRenderAuxViewKeybindings( - appconst.InputAuxView_AIChat, - "sidebar" + appconst.InputAuxView_AIChat ); console.log("renderAIChatKeybindings=====", renderAIChatKeybindings); return ( diff --git a/src/models/input.ts b/src/models/input.ts index 7b2bc8d94..2a239edad 100644 --- a/src/models/input.ts +++ b/src/models/input.ts @@ -460,7 +460,7 @@ class InputModel { this.giveFocus(); } - shouldRenderAuxViewKeybindings(view: InputAuxViewType, test?: string): boolean { + shouldRenderAuxViewKeybindings(view: InputAuxViewType): boolean { console.log("view", view, this.getAuxViewFocus(), this.getActiveAuxView()); if (GlobalModel.activeMainView.get() != "session") { console.log("1");