Very basic org properties rendering.
This commit is contained in:
parent
c397688a4a
commit
1c8f84ab4c
@ -1,5 +1,6 @@
|
|||||||
import React, { ReactNode, useState } from "react";
|
import React, { ReactNode, useState } from "react";
|
||||||
import styles from "./OrgAst.module.css";
|
import styles from "./OrgAst.module.css";
|
||||||
|
import { Fragment } from 'react';
|
||||||
|
|
||||||
const OrgAst = (props: {
|
const OrgAst = (props: {
|
||||||
setHighlight: Function;
|
setHighlight: Function;
|
||||||
@ -70,6 +71,18 @@ const OrgAstNode = (props: {
|
|||||||
<dd>{props.node["standard-properties"]["post-blank"]}</dd>
|
<dd>{props.node["standard-properties"]["post-blank"]}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</details>
|
</details>
|
||||||
|
{!!Object.keys(props.node.properties).length ? (
|
||||||
|
<>
|
||||||
|
<details>
|
||||||
|
<summary>Properties</summary>
|
||||||
|
<OrgPropertiesList selectNode={props.selectNode}
|
||||||
|
parentUniqueId={props.uid}
|
||||||
|
selectedNode={props.selectedNode}
|
||||||
|
properties={props.node.properties}
|
||||||
|
/>
|
||||||
|
</details>
|
||||||
|
</>
|
||||||
|
) : null }
|
||||||
{Array.isArray(props.node.children) && props.node.children.length > 0 ? (
|
{Array.isArray(props.node.children) && props.node.children.length > 0 ? (
|
||||||
<details open={true}>
|
<details open={true}>
|
||||||
<summary>Children</summary>
|
<summary>Children</summary>
|
||||||
@ -115,4 +128,25 @@ const OrgAstNodeList = (props: {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const OrgPropertiesList = (props: {
|
||||||
|
selectNode: Function;
|
||||||
|
parentUniqueId: string;
|
||||||
|
selectedNode: string;
|
||||||
|
properties: Object;
|
||||||
|
}): React.JSX.Element => {
|
||||||
|
const entries = Object.entries(props.properties).map(([key, value]) => {
|
||||||
|
return (
|
||||||
|
<Fragment key={key}>
|
||||||
|
<dt>{key}</dt>
|
||||||
|
<dd>{JSON.stringify(value)}</dd>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<dl>
|
||||||
|
{entries}
|
||||||
|
</dl>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default OrgAst;
|
export default OrgAst;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user