@@ -14,7 +14,8 @@ import React from "react";
1414import { useDebouncedCallback } from "use-debounce" ;
1515import { showImageModal , FullScreen } from "./ui-lib" ;
1616import { ArtifactShareButton , HTMLPreview } from "./artifact" ;
17-
17+ import { Plugin } from "../constant" ;
18+ import { useChatStore } from "../store" ;
1819export function Mermaid ( props : { code : string } ) {
1920 const ref = useRef < HTMLDivElement > ( null ) ;
2021 const [ hasError , setHasError ] = useState ( false ) ;
@@ -67,6 +68,9 @@ export function PreCode(props: { children: any }) {
6768 const [ mermaidCode , setMermaidCode ] = useState ( "" ) ;
6869 const [ htmlCode , setHtmlCode ] = useState ( "" ) ;
6970 const { height } = useWindowSize ( ) ;
71+ const chatStore = useChatStore ( ) ;
72+ const session = chatStore . currentSession ( ) ;
73+ const plugins = session . mask ?. plugin ;
7074
7175 const renderArtifacts = useDebouncedCallback ( ( ) => {
7276 if ( ! ref . current ) return ;
@@ -87,6 +91,11 @@ export function PreCode(props: { children: any }) {
8791 // eslint-disable-next-line react-hooks/exhaustive-deps
8892 } , [ refText ] ) ;
8993
94+ const enableArtifacts = useMemo (
95+ ( ) => plugins ?. includes ( Plugin . Artifact ) ,
96+ [ plugins ] ,
97+ ) ;
98+
9099 return (
91100 < >
92101 < pre ref = { ref } >
@@ -104,7 +113,7 @@ export function PreCode(props: { children: any }) {
104113 { mermaidCode . length > 0 && (
105114 < Mermaid code = { mermaidCode } key = { mermaidCode } />
106115 ) }
107- { htmlCode . length > 0 && (
116+ { htmlCode . length > 0 && enableArtifacts && (
108117 < FullScreen className = "no-dark html" right = { 70 } >
109118 < ArtifactShareButton
110119 style = { { position : "absolute" , right : 20 , top : 10 } }
0 commit comments