summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/uniorg.tsx8
-rw-r--r--util/webSocketFunctions.ts25
2 files changed, 29 insertions, 4 deletions
diff --git a/util/uniorg.tsx b/util/uniorg.tsx
index e4d8dfd..ba86a89 100644
--- a/util/uniorg.tsx
+++ b/util/uniorg.tsx
@@ -7,11 +7,11 @@ import katex from 'rehype-katex'
import rehype2react from 'rehype-react'
import React from 'react'
-export interface uniorgProps {
+export interface UniOrgProps {
orgText: string
}
-const uniorg = (props: uniorgProps) => {
+export const UniOrg = (props: UniOrgProps) => {
const { orgText } = props
const processor = unified()
.use(uniorgParse)
@@ -19,7 +19,7 @@ const uniorg = (props: uniorgProps) => {
.use(katex)
.use(rehype2react, { createElement: React.createElement })
- return processor.processSync(orgText)
+ console.log(processor.processSync(orgText))
+ return <div> {processor.processSync(orgText).result}</div>
}
-export default uniorg
diff --git a/util/webSocketFunctions.ts b/util/webSocketFunctions.ts
new file mode 100644
index 0000000..8e2bd7e
--- /dev/null
+++ b/util/webSocketFunctions.ts
@@ -0,0 +1,25 @@
+import { OrgRoamNode } from '../api'
+import ReconnectingWebSocket from 'reconnecting-websocket'
+
+export function sendMessageToEmacs(command: string, data: {}, webSocket: ReconnectingWebSocket) {
+ webSocket.send(JSON.stringify({ command: command, data: data }))
+}
+
+export function getOrgText(node: OrgRoamNode, webSocket: ReconnectingWebSocket) {
+ sendMessageToEmacs('getText', { id: node.id }, webSocket)
+}
+
+export function openNodeInEmacs(node: OrgRoamNode, webSocket: ReconnectingWebSocket) {
+ sendMessageToEmacs('open', { id: node.id }, webSocket)
+}
+
+export function deleteNodeInEmacs(node: OrgRoamNode, webSocket: ReconnectingWebSocket) {
+ if (node.level !== 0) {
+ return
+ }
+ sendMessageToEmacs('delete', { id: node.id, file: node.file }, webSocket)
+}
+
+export function createNodeInEmacs(node: OrgRoamNode, webSocket: ReconnectingWebSocket) {
+ sendMessageToEmacs('create', { id: node.id, title: node.title, ref: node.properties.ROAM_REFS }, webSocket)
+}