-
-
Notifications
You must be signed in to change notification settings - Fork 517
/
Copy pathApp.tsx
95 lines (93 loc) · 2.5 KB
/
App.tsx
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
94
95
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";
// Bundle created from `npx shiki-codegen --langs typescript,javascript,react --themes light-plus,dark-plus --engine javascript --precompiled ./shiki.bundle.ts`
import { createHighlighter } from "./shiki.bundle.js";
export default function App() {
// Creates a new editor instance.
const editor = useCreateBlockNote({
codeBlock: {
indentLineWithTab: true,
defaultLanguage: "typescript",
supportedLanguages: {
typescript: {
name: "TypeScript",
aliases: ["ts"],
},
javascript: {
name: "JavaScript",
aliases: ["js"],
},
vue: {
name: "Vue",
},
},
// This creates a highlighter, it can be asynchronous to load it afterwards
createHighlighter: () =>
createHighlighter({
themes: ["dark-plus", "light-plus"],
langs: [],
}),
},
initialContent: [
{
id: "fc832df4-bd15-49d2-8d64-140c27f29692",
type: "codeBlock",
props: {
language: "typescript",
},
content: [
{
type: "text",
text: "const x = 3 * 4;",
styles: {},
},
],
children: [],
},
{
id: "aecf786b-cbde-4915-b86c-b4c8264fc8f7",
type: "paragraph",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [],
children: [],
},
{
id: "f85ab261-dfe8-47f0-929f-533808a4184d",
type: "heading",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
level: 3,
},
content: [
{
type: "text",
text: 'Click on "Typescript" above to see the different supported languages',
styles: {},
},
],
children: [],
},
{
id: "dec03378-6b49-442a-89f0-b2551ce0f60c",
type: "paragraph",
props: {
textColor: "default",
backgroundColor: "default",
textAlignment: "left",
},
content: [],
children: [],
},
],
});
// Renders the editor instance using a React component.
return <BlockNoteView editor={editor} />;
}