diff --git a/src/Editor.tsx b/src/Editor.tsx index b5ce31b..f3265d9 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -58,7 +58,11 @@ function Editor({ defaultValue = default_org_source }) { />
{buildShadow(highlights, value)}
- + ); } diff --git a/src/OrgAst.tsx b/src/OrgAst.tsx index 65f9a33..6d0e363 100644 --- a/src/OrgAst.tsx +++ b/src/OrgAst.tsx @@ -2,7 +2,11 @@ import React, { ReactNode, useState } from "react"; import { parse_org } from "../../organic/target/wasm32-unknown-unknown/js/wasm"; import styles from "./OrgAst.module.css"; -const OrgAst = (props: { setHighlight: Function; clearHighlights: Function; value: string }) => { +const OrgAst = (props: { + setHighlight: Function; + clearHighlights: Function; + value: string; +}) => { const ast_tree = parse_org(props.value); console.log(JSON.stringify(ast_tree)); @@ -18,25 +22,51 @@ const OrgAst = (props: { setHighlight: Function; clearHighlights: Function; valu } else { return (
- +
); } }; -const OrgAstNode = (props: { selectNode: Function; node: any, parentUniqueId: string, selectedNode: string }) => { - - const uid = props.parentUniqueId + "_" + props.node["ast-node"] + "/" + props.node["standard-properties"]["begin"] + "/" + props.node["standard-properties"]["end"] + "#"; +const OrgAstNode = (props: { + selectNode: Function; + node: any; + parentUniqueId: string; + selectedNode: string; +}) => { + const uid = + props.parentUniqueId + + "_" + + props.node["ast-node"] + + "/" + + props.node["standard-properties"]["begin"] + + "/" + + props.node["standard-properties"]["end"] + + "#"; function selectNode() { - props.selectNode(uid, props.node["standard-properties"]["begin"] - 1, props.node["standard-properties"]["end"] - 1); + props.selectNode( + uid, + props.node["standard-properties"]["begin"] - 1, + props.node["standard-properties"]["end"] - 1, + ); } - const nodeClassName = props.selectedNode === uid ? styles.OrgAstNode + " " + styles.selected : styles.OrgAstNode; + const nodeClassName = + props.selectedNode === uid + ? styles.OrgAstNode + " " + styles.selected + : styles.OrgAstNode; return (
-
{props.node["ast-node"]}
+
+ {props.node["ast-node"]} +
Standard Properties
@@ -56,7 +86,12 @@ const OrgAstNode = (props: { selectNode: Function; node: any, parentUniqueId: st
Children
- +
) : null} @@ -64,9 +99,21 @@ const OrgAstNode = (props: { selectNode: Function; node: any, parentUniqueId: st ); }; -const OrgAstNodeList = (props: { selectNode: Function; parentUniqueId: string; selectedNode: string; node_list: any[] }): React.JSX.Element[] => { +const OrgAstNodeList = (props: { + selectNode: Function; + parentUniqueId: string; + selectedNode: string; + node_list: any[]; +}): React.JSX.Element[] => { return props.node_list.map((node) => { - return ; + return ( + + ); }); }; diff --git a/src/index.tsx b/src/index.tsx index 4fcf454..4a4e800 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,10 +1,10 @@ import React from "react"; -import ReactDOM from "react-dom"; import App from "./App"; +import { createRoot } from "react-dom/client"; -ReactDOM.render( +const root = createRoot(document.getElementById("root")!); +root.render( <> , - document.getElementById("root"), );