mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
remove inputModel dep prop in Markdown component
This commit is contained in:
parent
34837aabae
commit
35a5f1645d
@ -207,7 +207,7 @@ class Bookmark extends React.Component<BookmarkProps, {}> {
|
||||
<div className="bookmark-id-div">{bm.bookmarkid.substr(0, 8)}</div>
|
||||
<div className="bookmark-content">
|
||||
<If condition={hasDesc}>
|
||||
<Markdown inputModel={GlobalModel.inputModel} text={markdown} extraClassName="bottom-margin" />
|
||||
<Markdown text={markdown} extraClassName="bottom-margin" />
|
||||
</If>
|
||||
<CmdStrCode
|
||||
cmdstr={bm.cmdstr}
|
||||
|
@ -31,7 +31,7 @@ function CodeRenderer(props: any): any {
|
||||
|
||||
@mobxReact.observer
|
||||
class CodeBlockMarkdown extends React.Component<
|
||||
{ inputModel: any; children: React.ReactNode; codeSelectSelectedIndex?: number; uuid: string },
|
||||
{ children: React.ReactNode; codeSelectSelectedIndex?: number; uuid: string },
|
||||
{}
|
||||
> {
|
||||
blockIndex: number;
|
||||
@ -40,13 +40,12 @@ class CodeBlockMarkdown extends React.Component<
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.blockRef = React.createRef();
|
||||
this.blockIndex = props.inputModel.addCodeBlockToCodeSelect(this.blockRef, this.props.uuid);
|
||||
this.blockIndex = GlobalModel.inputModel.addCodeBlockToCodeSelect(this.blockRef, this.props.uuid);
|
||||
}
|
||||
|
||||
render() {
|
||||
const inputModel = this.props.inputModel;
|
||||
const clickHandler = (e: React.MouseEvent<HTMLElement>, blockIndex: number) => {
|
||||
inputModel.setCodeSelectSelectedCodeBlock(blockIndex);
|
||||
GlobalModel.inputModel.setCodeSelectSelectedCodeBlock(blockIndex);
|
||||
};
|
||||
let selected = this.blockIndex == this.props.codeSelectSelectedIndex;
|
||||
return (
|
||||
@ -63,7 +62,7 @@ class CodeBlockMarkdown extends React.Component<
|
||||
|
||||
@mobxReact.observer
|
||||
class Markdown extends React.Component<
|
||||
{ inputModel: any; text: string; style?: any; extraClassName?: string; codeSelect?: boolean },
|
||||
{ text: string; style?: any; extraClassName?: string; codeSelect?: boolean },
|
||||
{}
|
||||
> {
|
||||
curUuid: string;
|
||||
@ -77,11 +76,7 @@ class Markdown extends React.Component<
|
||||
codeBlockRenderer(props: any, codeSelect: boolean, codeSelectIndex: number, curUuid: string): any {
|
||||
if (codeSelect) {
|
||||
return (
|
||||
<CodeBlockMarkdown
|
||||
inputModel={this.props.inputModel}
|
||||
codeSelectSelectedIndex={codeSelectIndex}
|
||||
uuid={curUuid}
|
||||
>
|
||||
<CodeBlockMarkdown codeSelectSelectedIndex={codeSelectIndex} uuid={curUuid}>
|
||||
{props.children}
|
||||
</CodeBlockMarkdown>
|
||||
);
|
||||
@ -98,9 +93,9 @@ class Markdown extends React.Component<
|
||||
}
|
||||
|
||||
render() {
|
||||
let { text, inputModel } = this.props;
|
||||
let { text } = this.props;
|
||||
let codeSelect = this.props.codeSelect;
|
||||
let curCodeSelectIndex = inputModel.getCodeSelectSelectedIndex();
|
||||
let curCodeSelectIndex = GlobalModel.inputModel.getCodeSelectSelectedIndex();
|
||||
let markdownComponents = {
|
||||
a: LinkRenderer,
|
||||
h1: (props) => HeaderRenderer(props, 1),
|
||||
|
@ -42,11 +42,7 @@ class AlertModal extends React.Component<{}, {}> {
|
||||
<Modal.Header onClose={this.closeModal} title={title} keybindings={true} />
|
||||
<div className="wave-modal-body">
|
||||
<If condition={message?.markdown}>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.inputModel}
|
||||
text={message?.message ?? ""}
|
||||
extraClassName="bottom-margin"
|
||||
/>
|
||||
<Markdown text={message?.message ?? ""} extraClassName="bottom-margin" />
|
||||
</If>
|
||||
<If condition={!message?.markdown}>{message?.message}</If>
|
||||
<If condition={message?.confirmflag}>
|
||||
|
@ -64,11 +64,7 @@ export const UserInputModal = (userInputRequest: UserInputRequest) => {
|
||||
<div className="wave-modal-dialog">
|
||||
<div className="userinput-query">
|
||||
<If condition={userInputRequest.markdown}>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.inputModel}
|
||||
text={userInputRequest.querytext}
|
||||
extraClassName="bottom-margin"
|
||||
/>
|
||||
<Markdown text={userInputRequest.querytext} extraClassName="bottom-margin" />
|
||||
</If>
|
||||
<If condition={!userInputRequest.markdown}>{userInputRequest.querytext}</If>
|
||||
</div>
|
||||
|
@ -78,7 +78,7 @@ class PluginsView extends React.Component<{}, {}> {
|
||||
{plugin.readme && (
|
||||
<div className="plugin-readme">
|
||||
<div className="plugin-label">{"Readme"}</div>
|
||||
<Markdown inputModel={GlobalModel.inputModel} text={plugin.readme} />
|
||||
<Markdown text={plugin.readme} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
@ -115,11 +115,7 @@ class ChatContent extends React.Component<{ chatWindowRef }, {}> {
|
||||
<div className="chat-msg-header">
|
||||
<i className="fa-sharp fa-solid fa-sparkles"></i>
|
||||
</div>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.inputModel}
|
||||
text={chatItem.assistantresponse.message}
|
||||
codeSelect
|
||||
/>
|
||||
<Markdown text={chatItem.assistantresponse.message} codeSelect />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@ -287,7 +283,6 @@ class AIChat extends React.Component<{}, {}> {
|
||||
}
|
||||
|
||||
onArrowDownPressed(): boolean {
|
||||
console.log("got here");
|
||||
const currentRef = this.textAreaRef.current;
|
||||
const inputModel = GlobalModel.inputModel;
|
||||
if (currentRef == null) {
|
||||
|
@ -224,11 +224,7 @@ class AIChat extends React.Component<{}, {}> {
|
||||
<i className="fa-sharp fa-solid fa-sparkles"></i>
|
||||
<div className="chat-username">AI Assistant</div>
|
||||
</div>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.inputModel}
|
||||
text={chatItem.assistantresponse.message}
|
||||
codeSelect
|
||||
/>
|
||||
<Markdown text={chatItem.assistantresponse.message} codeSelect />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
@ -461,11 +461,7 @@ class SourceCodeRenderer extends React.Component<
|
||||
ref={this.markdownRef}
|
||||
onScroll={() => this.handleDivScroll()}
|
||||
>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.inputModel}
|
||||
text={this.state.code}
|
||||
style={{ width: "100%", padding: "1rem" }}
|
||||
/>
|
||||
<Markdown text={this.state.code} style={{ width: "100%", padding: "1rem" }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ class SimpleMarkdownRenderer extends React.Component<
|
||||
}}
|
||||
>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.inputModel}
|
||||
text={this.markdownText.get()}
|
||||
style={{ maxHeight: opts.maxSize.height, maxWidth: DefaultMaxMarkdownWidth }}
|
||||
/>
|
||||
|
@ -208,11 +208,7 @@ class OpenAIRenderer extends React.Component<{ model: OpenAIRendererModel }> {
|
||||
paddingRight: 5,
|
||||
}}
|
||||
>
|
||||
<Markdown
|
||||
inputModel={GlobalModel.aichatModel}
|
||||
text={message}
|
||||
style={{ maxHeight: opts.maxSize.height }}
|
||||
/>
|
||||
<Markdown text={message} style={{ maxHeight: opts.maxSize.height }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user