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