Start rendering the Org Ast.
This commit is contained in:
parent
c419a41998
commit
6901541fe4
@ -43,11 +43,6 @@
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.Editor-ast {
|
||||
flex: 1;
|
||||
background: green;
|
||||
}
|
||||
|
||||
.Editor-underlay {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
@ -2,10 +2,10 @@ import React, { ReactNode, useState } from "react";
|
||||
import "./Editor.css";
|
||||
import { Highlight } from "./highlight";
|
||||
import { buildShadow } from "./shadow";
|
||||
import OrgAst from "./OrgAst";
|
||||
|
||||
function Editor({ defaultValue = "I have a text value." }) {
|
||||
function handleChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
console.log(event.target.value);
|
||||
setValue(event.target.value);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ function Editor({ defaultValue = "I have a text value." }) {
|
||||
/>
|
||||
<div className="Editor-underlay">{buildShadow(highlights, value)}</div>
|
||||
</div>
|
||||
<div className="Editor-ast"></div>
|
||||
<OrgAst addHighlight={addHighlight} value={value} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
10
src/OrgAst.module.css
Normal file
10
src/OrgAst.module.css
Normal file
@ -0,0 +1,10 @@
|
||||
.OrgAst {
|
||||
flex: 1;
|
||||
background: green;
|
||||
}
|
||||
|
||||
.OrgAstNode {
|
||||
}
|
||||
|
||||
.OrgAstNodeType {
|
||||
}
|
3
src/OrgAst.module.css.d.ts
vendored
Normal file
3
src/OrgAst.module.css.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export const OrgAst: string;
|
||||
export const OrgAstNode: string;
|
||||
export const OrgAstNodeType: string;
|
32
src/OrgAst.tsx
Normal file
32
src/OrgAst.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
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: {addHighlight: Function, value: string}) => {
|
||||
console.log(styles);
|
||||
const ast_tree = parse_org(props.value);
|
||||
console.log(JSON.stringify(ast_tree));
|
||||
|
||||
if (ast_tree.status !== "success") {
|
||||
return (
|
||||
<div className={styles.OrgAst}>Error! {ast_tree.content}</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className={styles.OrgAst}><OrgAstNode node={ast_tree.content}/></div>
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const OrgAstNode = (props: {node: any}) => {
|
||||
return (
|
||||
<div className={styles.OrgAstNode}>
|
||||
<div className={styles.OrgAstNodeType}>{props.node["ast-node"]}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default OrgAst;
|
@ -1,12 +1,9 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import init, {
|
||||
parse_org,
|
||||
} from "../../organic/target/wasm32-unknown-unknown/js/wasm";
|
||||
import init from "../../organic/target/wasm32-unknown-unknown/js/wasm";
|
||||
import App from "./App";
|
||||
|
||||
init().then(() => {
|
||||
console.log(parse_org("foo"));
|
||||
ReactDOM.render(
|
||||
<>
|
||||
<App />
|
||||
|
Loading…
Reference in New Issue
Block a user