-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathconvertRoamNodeToFullContent.simple.example.ts
More file actions
46 lines (41 loc) · 1.22 KB
/
Copy pathconvertRoamNodeToFullContent.simple.example.ts
File metadata and controls
46 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { TreeNode } from "roamjs-components/types";
import type { CrossAppNode } from "@repo/database/crossAppNodeContract";
import { buildFullMarkdown } from "./convertRoamNodeToFullContent";
/**
* Small typed example for ENG-1848/ENG-1852 full markdown validation. The Roam
* app has no unit-test runner, so this keeps a compact in-memory tree that
* type-checks the generated markdown against the shared cross-app contract.
*/
const block = (text: string, children: TreeNode[] = []): TreeNode => ({
text,
children,
order: 0,
parents: [],
uid: "",
heading: 0,
open: true,
viewType: "bullet",
blockViewType: "outline",
editTime: new Date(0),
textAlign: "left",
props: { imageResize: {}, iframe: {} },
});
const title = "Sleep improves memory consolidation";
const blocks: TreeNode[] = [
block(
"Multiple studies show that sleep after learning strengthens memory traces.",
),
block("Supporting evidence:", [block("[[EVD]] - Rasch & Born 2013")]),
];
export const roamClaimFullMarkdownSimpleExample: {
title: string;
blocks: TreeNode[];
full: CrossAppNode["content"]["full"];
} = {
title,
blocks,
full: {
format: "text/markdown",
value: buildFullMarkdown({ title, blocks }),
},
};