Skip to content

Commit

Permalink
handle content updates (?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed Jun 24, 2022
1 parent b8313b3 commit 2d10e0c
Show file tree
Hide file tree
Showing 6 changed files with 2,766 additions and 2,714 deletions.
24 changes: 1 addition & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,16 @@
"serve": "vite preview"
},
"blocks": [
{
"type": "file",
"id": "file-block",
"title": "Example File Block",
"description": "A basic file block",
"entry": "/src/blocks/example-file-block/index.tsx",
"extensions": [
"*"
],
"example_path": "https://github.com/facebook/react/blob/main/packages/react-dom/index.js"
},
{
"type": "file",
"id": "mermaid-block",
"title": "Mermaid Block",
"description": "Render file with Mermaid",
"entry": "/src/blocks/mermaid-block/index.tsx",
"extensions": [
"*"
"*.mermaid"
],
"example_path": "https://github.com/sourcegraph/sourcegraph/blob/main/doc/code_intelligence/explanations/diagrams/index-states.mermaid"
},
{
"type": "folder",
"id": "folder-block",
"title": "Example Folder Block",
"description": "A basic folder block",
"entry": "/src/blocks/example-folder-block/index.tsx",
"extensions": [
"*"
],
"example_path": "https://github.com/githubocto/flat"
}
],
"dependencies": {
Expand Down
3 changes: 0 additions & 3 deletions src/blocks/example-file-block/index.css

This file was deleted.

35 changes: 0 additions & 35 deletions src/blocks/example-file-block/index.tsx

This file was deleted.

47 changes: 0 additions & 47 deletions src/blocks/example-folder-block/index.tsx

This file was deleted.

27 changes: 13 additions & 14 deletions src/blocks/mermaid-block/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import {
FileBlockProps,
} from "@githubnext/utils";
import React from "react";

import { FileBlockProps } from "@githubnext/utils";
import "./index.css";

import mermaid from 'mermaid';
import mermaid from "mermaid";

mermaid.mermaidAPI.initialize({ startOnLoad: false });

const Mermaid: React.FC = (props) => {
const __html = mermaid.mermaidAPI.render(
'id',
String(props.children),
);
return <div dangerouslySetInnerHTML={{ __html }}/>;
}

export default function (props: FileBlockProps) {
const { context, content, metadata, onUpdateMetadata } = props;
return <Mermaid>{content}</Mermaid>;
const { content } = props;
const [rendered, setRendered] = React.useState("");

React.useEffect(() => {
const rendered = mermaid.mermaidAPI.render("id", content);
setRendered(rendered);
}, [content]);

return <div dangerouslySetInnerHTML={{ __html: rendered }} />;
}
Loading

0 comments on commit 2d10e0c

Please sign in to comment.