|
| 1 | +import "@blocknote/core/fonts/inter.css"; |
| 2 | +import { BlockNoteView } from "@blocknote/mantine"; |
| 3 | +import "@blocknote/mantine/style.css"; |
| 4 | +import { useCreateBlockNote } from "@blocknote/react"; |
| 5 | + |
| 6 | +export default function App() { |
| 7 | + // Creates a new editor instance. |
| 8 | + const editor = useCreateBlockNote({ |
| 9 | + // This enables the advanced table features |
| 10 | + tables: { |
| 11 | + splitCells: true, |
| 12 | + cellBackgroundColor: true, |
| 13 | + cellTextColor: true, |
| 14 | + headers: true, |
| 15 | + }, |
| 16 | + initialContent: [ |
| 17 | + { |
| 18 | + id: "7e498b3d-d42e-4ade-9be0-054b292715ea", |
| 19 | + type: "heading", |
| 20 | + props: { |
| 21 | + textColor: "default", |
| 22 | + backgroundColor: "default", |
| 23 | + textAlignment: "left", |
| 24 | + level: 2, |
| 25 | + }, |
| 26 | + content: [ |
| 27 | + { |
| 28 | + type: "text", |
| 29 | + text: "Advanced Tables", |
| 30 | + styles: {}, |
| 31 | + }, |
| 32 | + ], |
| 33 | + children: [], |
| 34 | + }, |
| 35 | + { |
| 36 | + id: "cbf287c6-770b-413a-bff5-ad490a0b562a", |
| 37 | + type: "table", |
| 38 | + props: { |
| 39 | + textColor: "default", |
| 40 | + }, |
| 41 | + content: { |
| 42 | + type: "tableContent", |
| 43 | + columnWidths: [199, 148, 201], |
| 44 | + headerRows: 1, |
| 45 | + rows: [ |
| 46 | + { |
| 47 | + cells: [ |
| 48 | + { |
| 49 | + type: "tableCell", |
| 50 | + content: [ |
| 51 | + { |
| 52 | + type: "text", |
| 53 | + text: "This row has headers", |
| 54 | + styles: {}, |
| 55 | + }, |
| 56 | + ], |
| 57 | + props: { |
| 58 | + colspan: 1, |
| 59 | + rowspan: 1, |
| 60 | + backgroundColor: "default", |
| 61 | + textColor: "default", |
| 62 | + textAlignment: "center", |
| 63 | + }, |
| 64 | + }, |
| 65 | + { |
| 66 | + type: "tableCell", |
| 67 | + content: [ |
| 68 | + { |
| 69 | + type: "text", |
| 70 | + text: "This is ", |
| 71 | + styles: {}, |
| 72 | + }, |
| 73 | + { |
| 74 | + type: "text", |
| 75 | + text: "RED", |
| 76 | + styles: { |
| 77 | + bold: true, |
| 78 | + }, |
| 79 | + }, |
| 80 | + ], |
| 81 | + props: { |
| 82 | + colspan: 1, |
| 83 | + rowspan: 1, |
| 84 | + backgroundColor: "red", |
| 85 | + textColor: "default", |
| 86 | + textAlignment: "center", |
| 87 | + }, |
| 88 | + }, |
| 89 | + { |
| 90 | + type: "tableCell", |
| 91 | + content: [ |
| 92 | + { |
| 93 | + type: "text", |
| 94 | + text: "Text is Blue", |
| 95 | + styles: {}, |
| 96 | + }, |
| 97 | + ], |
| 98 | + props: { |
| 99 | + colspan: 1, |
| 100 | + rowspan: 1, |
| 101 | + backgroundColor: "default", |
| 102 | + textColor: "blue", |
| 103 | + textAlignment: "center", |
| 104 | + }, |
| 105 | + }, |
| 106 | + ], |
| 107 | + }, |
| 108 | + { |
| 109 | + cells: [ |
| 110 | + { |
| 111 | + type: "tableCell", |
| 112 | + content: [ |
| 113 | + { |
| 114 | + type: "text", |
| 115 | + text: "This spans 2 columns\nand 2 rows", |
| 116 | + styles: {}, |
| 117 | + }, |
| 118 | + ], |
| 119 | + props: { |
| 120 | + colspan: 2, |
| 121 | + rowspan: 2, |
| 122 | + backgroundColor: "yellow", |
| 123 | + textColor: "default", |
| 124 | + textAlignment: "left", |
| 125 | + }, |
| 126 | + }, |
| 127 | + { |
| 128 | + type: "tableCell", |
| 129 | + content: [ |
| 130 | + { |
| 131 | + type: "text", |
| 132 | + text: "Sooo many features", |
| 133 | + styles: {}, |
| 134 | + }, |
| 135 | + ], |
| 136 | + props: { |
| 137 | + colspan: 1, |
| 138 | + rowspan: 1, |
| 139 | + backgroundColor: "gray", |
| 140 | + textColor: "default", |
| 141 | + textAlignment: "left", |
| 142 | + }, |
| 143 | + }, |
| 144 | + ], |
| 145 | + }, |
| 146 | + { |
| 147 | + cells: [ |
| 148 | + { |
| 149 | + type: "tableCell", |
| 150 | + content: [], |
| 151 | + props: { |
| 152 | + colspan: 1, |
| 153 | + rowspan: 1, |
| 154 | + backgroundColor: "gray", |
| 155 | + textColor: "purple", |
| 156 | + textAlignment: "left", |
| 157 | + }, |
| 158 | + }, |
| 159 | + ], |
| 160 | + }, |
| 161 | + { |
| 162 | + cells: [ |
| 163 | + { |
| 164 | + type: "tableCell", |
| 165 | + content: [ |
| 166 | + { |
| 167 | + type: "text", |
| 168 | + text: "A cell", |
| 169 | + styles: {}, |
| 170 | + }, |
| 171 | + ], |
| 172 | + props: { |
| 173 | + colspan: 1, |
| 174 | + rowspan: 1, |
| 175 | + backgroundColor: "default", |
| 176 | + textColor: "default", |
| 177 | + textAlignment: "left", |
| 178 | + }, |
| 179 | + }, |
| 180 | + { |
| 181 | + type: "tableCell", |
| 182 | + content: [ |
| 183 | + { |
| 184 | + type: "text", |
| 185 | + text: "Another Cell", |
| 186 | + styles: {}, |
| 187 | + }, |
| 188 | + ], |
| 189 | + props: { |
| 190 | + colspan: 1, |
| 191 | + rowspan: 1, |
| 192 | + backgroundColor: "default", |
| 193 | + textColor: "default", |
| 194 | + textAlignment: "right", |
| 195 | + }, |
| 196 | + }, |
| 197 | + { |
| 198 | + type: "tableCell", |
| 199 | + content: [ |
| 200 | + { |
| 201 | + type: "text", |
| 202 | + text: "Aligned center", |
| 203 | + styles: {}, |
| 204 | + }, |
| 205 | + ], |
| 206 | + props: { |
| 207 | + colspan: 1, |
| 208 | + rowspan: 1, |
| 209 | + backgroundColor: "default", |
| 210 | + textColor: "default", |
| 211 | + textAlignment: "center", |
| 212 | + }, |
| 213 | + }, |
| 214 | + ], |
| 215 | + }, |
| 216 | + ], |
| 217 | + }, |
| 218 | + children: [], |
| 219 | + }, |
| 220 | + { |
| 221 | + id: "16e76a94-74e5-42e2-b461-fc9da9f381f7", |
| 222 | + type: "paragraph", |
| 223 | + props: { |
| 224 | + textColor: "default", |
| 225 | + backgroundColor: "default", |
| 226 | + textAlignment: "left", |
| 227 | + }, |
| 228 | + content: [ |
| 229 | + { |
| 230 | + type: "text", |
| 231 | + text: "Featuring:", |
| 232 | + styles: {}, |
| 233 | + }, |
| 234 | + ], |
| 235 | + children: [ |
| 236 | + { |
| 237 | + id: "785fc9f7-8554-47f4-a4df-8fe2f1438cac", |
| 238 | + type: "bulletListItem", |
| 239 | + props: { |
| 240 | + textColor: "default", |
| 241 | + backgroundColor: "default", |
| 242 | + textAlignment: "left", |
| 243 | + }, |
| 244 | + content: [ |
| 245 | + { |
| 246 | + type: "text", |
| 247 | + text: "Cell background & foreground coloring", |
| 248 | + styles: {}, |
| 249 | + }, |
| 250 | + ], |
| 251 | + children: [], |
| 252 | + }, |
| 253 | + { |
| 254 | + id: "1d0adf08-1b42-421a-b9ea-b3125dcc96d9", |
| 255 | + type: "bulletListItem", |
| 256 | + props: { |
| 257 | + textColor: "default", |
| 258 | + backgroundColor: "default", |
| 259 | + textAlignment: "left", |
| 260 | + }, |
| 261 | + content: [ |
| 262 | + { |
| 263 | + type: "text", |
| 264 | + text: "Splitting & merging cells", |
| 265 | + styles: {}, |
| 266 | + }, |
| 267 | + ], |
| 268 | + children: [], |
| 269 | + }, |
| 270 | + { |
| 271 | + id: "99991aa7-9d86-4d06-9073-b1a9c0329062", |
| 272 | + type: "bulletListItem", |
| 273 | + props: { |
| 274 | + textColor: "default", |
| 275 | + backgroundColor: "default", |
| 276 | + textAlignment: "left", |
| 277 | + }, |
| 278 | + content: [ |
| 279 | + { |
| 280 | + type: "text", |
| 281 | + text: "Header row & column", |
| 282 | + styles: {}, |
| 283 | + }, |
| 284 | + ], |
| 285 | + children: [], |
| 286 | + }, |
| 287 | + ], |
| 288 | + }, |
| 289 | + { |
| 290 | + id: "c7bf2a7c-8972-44f1-acd8-cf60fa734068", |
| 291 | + type: "paragraph", |
| 292 | + props: { |
| 293 | + textColor: "default", |
| 294 | + backgroundColor: "default", |
| 295 | + textAlignment: "left", |
| 296 | + }, |
| 297 | + content: [], |
| 298 | + children: [], |
| 299 | + }, |
| 300 | + ], |
| 301 | + }); |
| 302 | + |
| 303 | + // Renders the editor instance using a React component. |
| 304 | + return <BlockNoteView editor={editor}></BlockNoteView>; |
| 305 | +} |
0 commit comments