minor fix

This commit is contained in:
Red Adaya 2024-05-06 21:15:54 +08:00
parent 35a5f1645d
commit 8a22e73e60
3 changed files with 29 additions and 32 deletions

View File

@ -43,17 +43,16 @@ class CodeBlockMarkdown extends React.Component<
this.blockIndex = GlobalModel.inputModel.addCodeBlockToCodeSelect(this.blockRef, this.props.uuid);
}
@boundMethod
handleClick(e: React.MouseEvent<HTMLPreElement>) {
console.log("this.blockIndex", this.blockIndex);
GlobalModel.inputModel.setCodeSelectSelectedCodeBlock(this.blockIndex);
}
render() {
const clickHandler = (e: React.MouseEvent<HTMLElement>, blockIndex: number) => {
GlobalModel.inputModel.setCodeSelectSelectedCodeBlock(blockIndex);
};
let selected = this.blockIndex == this.props.codeSelectSelectedIndex;
return (
<pre
ref={this.blockRef}
className={cn({ selected: selected })}
onClick={(event) => clickHandler(event, this.blockIndex)}
>
<pre ref={this.blockRef} className={cn({ selected: selected })} onClick={this.handleClick}>
{this.props.children}
</pre>
);

View File

@ -161,6 +161,26 @@ class AIChat extends React.Component<{}, {}> {
chatWindowRef: React.RefObject<HTMLDivElement> = 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 (

View File

@ -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");