Skip to content

Commit

Permalink
Disable flowcharts in shared docs (viewer mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
Komediruzecki authored and Rokt33r committed Jul 20, 2022
1 parent 10a0ae9 commit d024e11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cloud/components/MarkdownView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
rehypeMermaid,
Chart,
remarkPlantUML,
FlowchartWarningBlock,
} from '../../lib/charts'
import MarkdownCheckbox from './MarkdownCheckbox'
import { mergeDeepRight } from 'ramda'
Expand Down Expand Up @@ -293,6 +294,9 @@ const MarkdownView = ({
)
},
flowchart: ({ children }: any) => {
if (showLinkOpenWarning) {
return <FlowchartWarningBlock />
}
return <Flowchart code={children[0]} />
},
chart: ({ children }: any) => {
Expand Down
11 changes: 11 additions & 0 deletions src/cloud/lib/charts/flowchart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ import visit from 'unist-util-visit'
import unified from 'unified'
import rehypeParse from 'rehype-parse'
import { appendElementToBody } from './charts'
import Icon from '../../../design/components/atoms/Icon'
import { mdiFileAlertOutline } from '@mdi/js'

export interface FlowchartProps {
code: string
options?: any
}

export const FlowchartWarningBlock = () => {
return (
<div>
<Icon path={mdiFileAlertOutline} /> Flowcharts are not available in shared
docs.
</div>
)
}

export const Flowchart = ({ code, options }: FlowchartProps) => {
const eleRef = useRef<HTMLDivElement>(null)
const [err, setErr] = useState(false)
Expand Down

0 comments on commit d024e11

Please sign in to comment.