-
-
Notifications
You must be signed in to change notification settings - Fork 550
/
cells.ts
93 lines (77 loc) · 1.91 KB
/
cells.ts
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { ImmutableOutput } from "./outputs";
import { ExecutionCount } from "./primitives";
import {
List as ImmutableList,
Map as ImmutableMap,
Record,
RecordOf
} from "immutable";
/* CodeCell Record Boilerplate */
export interface CodeCellParams {
cell_type: "code";
// Sadly untyped and widely unspecced
metadata: ImmutableMap<string, any>;
execution_count: ExecutionCount;
source: string;
outputs: ImmutableList<ImmutableOutput>;
}
export const makeCodeCell = Record<CodeCellParams>({
cell_type: "code",
execution_count: null,
metadata: ImmutableMap({
collapsed: false,
jupyter: ImmutableMap({
source_hidden: false,
outputs_hidden: false
}),
nteract: ImmutableMap({
transient: ImmutableMap({
deleting: false
})
})
}),
source: "",
outputs: ImmutableList()
});
export type ImmutableCodeCell = RecordOf<CodeCellParams>;
/* MarkdownCell Record Boilerplate */
export interface MarkdownCellParams {
cell_type: "markdown";
source: string;
metadata: ImmutableMap<string, any>;
}
export const makeMarkdownCell = Record<MarkdownCellParams>({
cell_type: "markdown",
metadata: ImmutableMap({
nteract: ImmutableMap({
transient: ImmutableMap({
deleting: false
})
})
}),
source: ""
});
export type ImmutableMarkdownCell = RecordOf<MarkdownCellParams>;
/* RawCell Record Boilerplate */
export interface RawCellParams {
cell_type: "raw";
source: string;
metadata: ImmutableMap<string, any>;
}
export const makeRawCell = Record<RawCellParams>({
cell_type: "raw",
metadata: ImmutableMap({
nteract: ImmutableMap({
transient: ImmutableMap({
deleting: false
})
})
}),
source: ""
});
export type ImmutableRawCell = RecordOf<RawCellParams>;
export type ImmutableCell =
| ImmutableMarkdownCell
| ImmutableCodeCell
| ImmutableRawCell;
export type CellType = "raw" | "markdown" | "code";