Skip to content

Commit ce7b3e4

Browse files
initial website (#103)
* update v * wip poc * poc * api poc * Implemented basic block retrieval API functions * tiny fixes * Added marks API support, block conversion/insertion functions, and WIP markdown conversion * Changed markdown parsing to use remark * Added API support for serializing blocks to HTML and Markdown * General cleanup & refactor * Implemented PR feedback * Added documentation to API functions * Added basic HTML/Markdown conversion test cases and fixed some bugs * Added more HTML/Markdown conversion test cases * Fixed comments * Added HTML/Markdown conversion test snapshots * Small changes * initial website * Added text content for several sections * Added API functions to update and remove blocks, improved distinction between `Block` and `BlockSpec` types * Added "Accessing Blocks", "BlockSpec Objects" sections and other changes * Finished text content for Introduction to Blocks * Finished text content for Introduction * Finished text content for Quickstart * Finished text content for Manipulating Blocks * Small change to Block Types * update homepage * update site * Changes to most pages' text content and added live demos * Added remaining unit tests * sandpack vertical * add vanilla js docs * comment * temp expose api * Changed `BlockSpec` to `PartialBlock` and improved error messages * add draggable to vanillajs example * Added `replaceBlock` function, updated others. * Added global props * Fixed node conversion tests & snapshots * Fixed format conversion tests & snapshots * Fixed block manipulation tests & snapshots * Commented out failing format conversion tests * Fixed build failures * Fixed list item parsing issue * Changed API file structure * Moved type import to dev dependencies * Added `PartialBlock` and `replaceBlocks()` text * changes to intro * fix lockfile * Updated editor API docs * make api accessible via editor, hide tiptap initialization options (#106) * make api accessible via editor, hide tiptap initialization options * remove comment * Fixed tests * Fixed tests * small renames + expose domElement * improve block types * Small fix to PartialBlock type * Removed logs * add comments about waitForEditor --------- Co-authored-by: Matthew Lipski <[email protected]> * add comment * clean up timeout * small cleanup * rename to InlineContent * Simplified text * doc improvements * Finished block types and other changes * doc updates * fix handlers and padding * Added text cursor and inline content text * General doc fixes * doc suggestions * unset css for heading * Added customizing editor and small changes * Removed generic inline content definition * small doc fixes * Changed styles structure * Updated test screenshots * Made styles optional * Fixed build issue * Added slash menu content * hide editor review on mobile * small changes to docs --------- Co-authored-by: Matthew Lipski <[email protected]>
1 parent f6b505f commit ce7b3e4

File tree

114 files changed

+5601
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+5601
-408
lines changed

examples/editor/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ type WindowWithProseMirror = Window & typeof globalThis & { ProseMirror: any };
77

88
function App() {
99
const editor = useBlockNote({
10-
onUpdate: () => {
11-
// console.log(editor.getJSON());
10+
onUpdate: (editor) => {
11+
console.log(editor.topLevelBlocks);
1212
},
1313
editorDOMAttributes: {
1414
class: styles.editor,

package-lock.json

Lines changed: 2023 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/BlockNoteEditor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import styles from "./editor.module.css";
77
import { defaultSlashCommands, SlashCommand } from "./extensions/SlashMenu";
88

99
export type BlockNoteEditorOptions = {
10+
// TODO: Figure out if enableBlockNoteExtensions/disableHistoryExtension are needed and document them.
1011
enableBlockNoteExtensions: boolean;
1112
disableHistoryExtension: boolean;
1213
uiFactories: UiFactories;
1314
slashCommands: SlashCommand[];
1415
parentElement: HTMLElement;
1516
editorDOMAttributes: Record<string, string>;
16-
onUpdate: () => void;
17-
onCreate: () => void;
17+
onUpdate: (editor: BlockNoteEditor) => void;
18+
onCreate: (editor: BlockNoteEditor) => void;
1819

1920
// tiptap options, undocumented
2021
_tiptapOptions: any;
@@ -47,10 +48,10 @@ export class BlockNoteEditor extends EditorAPI {
4748
...blockNoteTipTapOptions,
4849
...options._tiptapOptions,
4950
onUpdate: () => {
50-
options.onUpdate?.();
51+
options.onUpdate?.(this);
5152
},
5253
onCreate: () => {
53-
options.onCreate?.();
54+
options.onCreate?.(this);
5455
},
5556
extensions:
5657
options.enableBlockNoteExtensions === false

packages/core/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
88
"children": [],
99
"content": [
1010
{
11-
"styles": [],
11+
"styles": {},
1212
"text": "Nested Heading 1",
1313
"type": "text",
1414
},
@@ -25,7 +25,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
2525
],
2626
"content": [
2727
{
28-
"styles": [],
28+
"styles": {},
2929
"text": "Heading 1",
3030
"type": "text",
3131
},
@@ -45,7 +45,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
4545
"children": [],
4646
"content": [
4747
{
48-
"styles": [],
48+
"styles": {},
4949
"text": "Nested Heading 2",
5050
"type": "text",
5151
},
@@ -62,7 +62,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
6262
],
6363
"content": [
6464
{
65-
"styles": [],
65+
"styles": {},
6666
"text": "Heading 2",
6767
"type": "text",
6868
},
@@ -98,7 +98,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
9898
"children": [],
9999
"content": [
100100
{
101-
"styles": [],
101+
"styles": {},
102102
"text": "Nested Heading 1",
103103
"type": "text",
104104
},
@@ -115,7 +115,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
115115
],
116116
"content": [
117117
{
118-
"styles": [],
118+
"styles": {},
119119
"text": "Heading 1",
120120
"type": "text",
121121
},
@@ -134,7 +134,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
134134
"children": [],
135135
"content": [
136136
{
137-
"styles": [],
137+
"styles": {},
138138
"text": "Nested Heading 2",
139139
"type": "text",
140140
},
@@ -151,7 +151,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
151151
],
152152
"content": [
153153
{
154-
"styles": [],
154+
"styles": {},
155155
"text": "Heading 2",
156156
"type": "text",
157157
},
@@ -185,7 +185,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blo
185185
"children": [],
186186
"content": [
187187
{
188-
"styles": [],
188+
"styles": {},
189189
"text": "Heading 1",
190190
"type": "text",
191191
},
@@ -218,7 +218,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete single block
218218
"children": [],
219219
"content": [
220220
{
221-
"styles": [],
221+
"styles": {},
222222
"text": "Paragraph",
223223
"type": "text",
224224
},
@@ -253,7 +253,7 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete single block
253253
"children": [],
254254
"content": [
255255
{
256-
"styles": [],
256+
"styles": {},
257257
"text": "Paragraph",
258258
"type": "text",
259259
},
@@ -269,26 +269,16 @@ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete single block
269269
],
270270
"content": [
271271
{
272-
"styles": [
273-
{
274-
"props": {
275-
"color": "red",
276-
},
277-
"type": "textColor",
278-
},
279-
],
272+
"styles": {
273+
"textColor": "red",
274+
},
280275
"text": "Heading ",
281276
"type": "text",
282277
},
283278
{
284-
"styles": [
285-
{
286-
"props": {
287-
"color": "red",
288-
},
289-
"type": "backgroundColor",
290-
},
291-
],
279+
"styles": {
280+
"backgroundColor": "red",
281+
},
292282
"text": "3",
293283
"type": "text",
294284
},
@@ -351,7 +341,7 @@ exports[`Inserting Blocks with Different Placements > Insert after existing bloc
351341
"children": [],
352342
"content": [
353343
{
354-
"styles": [],
344+
"styles": {},
355345
"text": "Nested Heading 1",
356346
"type": "text",
357347
},
@@ -368,7 +358,7 @@ exports[`Inserting Blocks with Different Placements > Insert after existing bloc
368358
],
369359
"content": [
370360
{
371-
"styles": [],
361+
"styles": {},
372362
"text": "Heading 1",
373363
"type": "text",
374364
},
@@ -388,7 +378,7 @@ exports[`Inserting Blocks with Different Placements > Insert after existing bloc
388378
"children": [],
389379
"content": [
390380
{
391-
"styles": [],
381+
"styles": {},
392382
"text": "Nested Heading 2",
393383
"type": "text",
394384
},
@@ -405,7 +395,7 @@ exports[`Inserting Blocks with Different Placements > Insert after existing bloc
405395
],
406396
"content": [
407397
{
408-
"styles": [],
398+
"styles": {},
409399
"text": "Heading 2",
410400
"type": "text",
411401
},
@@ -441,7 +431,7 @@ exports[`Inserting Blocks with Different Placements > Insert before existing blo
441431
"children": [],
442432
"content": [
443433
{
444-
"styles": [],
434+
"styles": {},
445435
"text": "Nested Heading 1",
446436
"type": "text",
447437
},
@@ -458,7 +448,7 @@ exports[`Inserting Blocks with Different Placements > Insert before existing blo
458448
],
459449
"content": [
460450
{
461-
"styles": [],
451+
"styles": {},
462452
"text": "Heading 1",
463453
"type": "text",
464454
},
@@ -478,7 +468,7 @@ exports[`Inserting Blocks with Different Placements > Insert before existing blo
478468
"children": [],
479469
"content": [
480470
{
481-
"styles": [],
471+
"styles": {},
482472
"text": "Nested Heading 2",
483473
"type": "text",
484474
},
@@ -495,7 +485,7 @@ exports[`Inserting Blocks with Different Placements > Insert before existing blo
495485
],
496486
"content": [
497487
{
498-
"styles": [],
488+
"styles": {},
499489
"text": "Heading 2",
500490
"type": "text",
501491
},
@@ -533,7 +523,7 @@ exports[`Inserting Blocks with Different Placements > Insert nested inside exist
533523
"children": [],
534524
"content": [
535525
{
536-
"styles": [],
526+
"styles": {},
537527
"text": "Nested Heading 1",
538528
"type": "text",
539529
},
@@ -550,7 +540,7 @@ exports[`Inserting Blocks with Different Placements > Insert nested inside exist
550540
],
551541
"content": [
552542
{
553-
"styles": [],
543+
"styles": {},
554544
"text": "Heading 1",
555545
"type": "text",
556546
},
@@ -570,7 +560,7 @@ exports[`Inserting Blocks with Different Placements > Insert nested inside exist
570560
"children": [],
571561
"content": [
572562
{
573-
"styles": [],
563+
"styles": {},
574564
"text": "Nested Heading 2",
575565
"type": "text",
576566
},
@@ -587,7 +577,7 @@ exports[`Inserting Blocks with Different Placements > Insert nested inside exist
587577
],
588578
"content": [
589579
{
590-
"styles": [],
580+
"styles": {},
591581
"text": "Heading 2",
592582
"type": "text",
593583
},

packages/core/src/api/blockManipulation/blockManipulation.test.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,16 @@ describe("Insert, Update, & Delete Blocks", () => {
126126
{
127127
type: "text",
128128
text: "Heading ",
129-
styles: [
130-
{
131-
type: "textColor",
132-
props: {
133-
color: "red",
134-
},
135-
},
136-
],
129+
styles: {
130+
textColor: "red",
131+
},
137132
},
138133
{
139134
type: "text",
140135
text: "3",
141-
styles: [
142-
{
143-
type: "backgroundColor",
144-
props: {
145-
color: "red",
146-
},
147-
},
148-
],
136+
styles: {
137+
backgroundColor: "red",
138+
},
149139
},
150140
],
151141
children: [singleBlock],

0 commit comments

Comments
 (0)