diff --git a/src/Editor.tsx b/src/Editor.tsx
index f3265d9..71d9799 100644
--- a/src/Editor.tsx
+++ b/src/Editor.tsx
@@ -3,6 +3,7 @@ import "./Editor.css";
import { Highlight } from "./highlight";
import { buildShadow } from "./shadow";
import OrgAst from "./OrgAst";
+import { parse_org } from "../../organic/target/wasm32-unknown-unknown/js/wasm";
const default_org_source: string = `Welcome to the Organic Wasm Demo!
@@ -48,6 +49,9 @@ function Editor({ defaultValue = default_org_source }) {
setHighlights([]);
}
+ const astTree = parse_org(value);
+ console.log(JSON.stringify(astTree));
+
return (
@@ -62,6 +66,7 @@ function Editor({ defaultValue = default_org_source }) {
setHighlight={setHighlight}
clearHighlights={clearHighlights}
value={value}
+ astTree={astTree}
/>
);
diff --git a/src/OrgAst.tsx b/src/OrgAst.tsx
index 6d0e363..c2f1001 100644
--- a/src/OrgAst.tsx
+++ b/src/OrgAst.tsx
@@ -5,11 +5,9 @@ import styles from "./OrgAst.module.css";
const OrgAst = (props: {
setHighlight: Function;
clearHighlights: Function;
+ astTree: any,
value: string;
}) => {
- const ast_tree = parse_org(props.value);
- console.log(JSON.stringify(ast_tree));
-
const [selectedNode, setSelectedNode] = useState
("");
function selectNode(uid: string, start: number, end: number) {
@@ -17,14 +15,14 @@ const OrgAst = (props: {
setSelectedNode(uid);
}
- if (ast_tree.status !== "success") {
- return Error! {ast_tree.content}
;
+ if (props.astTree.status !== "success") {
+ return Error! {props.astTree.content}
;
} else {
return (
@@ -88,7 +86,7 @@ const OrgAstNode = (props: {