Skip to content

Commit 88565cc

Browse files
feat: File blocks (#731)
* WIP file blocks * Refactored API for extending file block previews * Added `parse`/`toExternalHTML` to vanilla file block API * Added `parse`/`toExternalHTML` to React file block API * Fixed issues from merge * Added audio/video file extensions, file UI buttons, and code improvements * wip * update formatting toolbar buttons * Added `parse` & `toExternalHTML` * Moved `parse` & `toExternalHTML` for file block * wip * Finished core refactor * Refactored react package * small improvements * Updated CSS * fix build * Updated examples * Implemented PR feedback * Implemented PR feedback * Fixed issues with `toExternalHTML` * Updated core unit tests * Updated React unit tests * Fixed build * small fixes * fix build * Updated PW tests * Fixed PW tests * small cleanup * small fixes + add accept for file uploads * Small fix to buttons & PDF example * fix dictionary * Updated locales * Updated test screenshots * Reverted test editor changes * Updated snapshots * Updated snapshots * Changed how focus is set in toolbar buttons * tmp fix for resetting fileId * Simplified React unit tests * Small CSS fix * Removed text alignment from default file block * Updated unit test snapshots * Updated PW tests --------- Co-authored-by: yousefed <[email protected]>
1 parent 78864ee commit 88565cc

File tree

252 files changed

+5437
-1255
lines changed

Some content is hidden

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

252 files changed

+5437
-1255
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"react": "^18",
3232
"react-dom": "^18",
3333
"react-github-btn": "^1.4.0",
34-
"react-icons": "^4.3.1",
34+
"react-icons": "^5.2.1",
3535
"y-partykit": "^0.0.25",
3636
"yjs": "^13.6.1"
3737
},

docs/pages/docs/advanced/vanilla-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ While it's up to you to decide how you want the elements to be rendered, BlockNo
4949
type UIElement =
5050
| "formattingToolbar"
5151
| "linkToolbar"
52-
| "imageToolbar"
52+
| "filePanel"
5353
| "sideMenu"
5454
| "suggestionMenu"
5555
| "tableHandles"

docs/pages/docs/editor-basics/setup.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export type BlockNoteViewProps = {
9696
linkToolbar?: boolean;
9797
sideMenu?: boolean;
9898
slashMenu?: boolean;
99-
imageToolbar?: boolean;
99+
filePanel?: boolean;
100100
tableHandles?: boolean;
101101
children?:
102102
} & HTMLAttributes<HTMLDivElement>;
@@ -120,7 +120,7 @@ export type BlockNoteViewProps = {
120120

121121
`slashMenu`: Whether the [Slash Menu](/docs/ui-components/suggestion-menus#slash-menu) should be enabled.
122122

123-
`imageToolbar`: Whether the Image Toolbar should be enabled.
123+
`filePanel`: Whether the File Toolbar should be enabled.
124124

125125
`tableHandles`: Whether the Table Handles should be enabled.
126126

examples/01-basic/03-all-blocks/App.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ export default function App() {
4040
type: "numberedListItem",
4141
content: "Numbered List Item",
4242
},
43-
{
44-
type: "image",
45-
},
4643
{
4744
type: "table",
4845
content: {
@@ -60,6 +57,33 @@ export default function App() {
6057
],
6158
},
6259
},
60+
{
61+
type: "file",
62+
},
63+
{
64+
type: "image",
65+
props: {
66+
url: "https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
67+
caption:
68+
"From https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
69+
},
70+
},
71+
{
72+
type: "video",
73+
props: {
74+
url: "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm",
75+
caption:
76+
"From https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm",
77+
},
78+
},
79+
{
80+
type: "audio",
81+
props: {
82+
url: "https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3",
83+
caption:
84+
"From https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3",
85+
},
86+
},
6387
{
6488
type: "paragraph",
6589
},

examples/01-basic/testing/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "@blocknote/core";
22
import "@blocknote/core/fonts/inter.css";
3-
import { useCreateBlockNote } from "@blocknote/react";
43
import { BlockNoteView } from "@blocknote/mantine";
54
import "@blocknote/mantine/style.css";
5+
import { useCreateBlockNote } from "@blocknote/react";
66

77
export default function App() {
88
// Creates a new editor instance.

examples/02-ui-components/01-ui-elements-remove/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "@blocknote/core/fonts/inter.css";
2-
import { useCreateBlockNote } from "@blocknote/react";
32
import { BlockNoteView } from "@blocknote/mantine";
43
import "@blocknote/mantine/style.css";
4+
import { useCreateBlockNote } from "@blocknote/react";
55

66
export default function App() {
77
// Creates a new editor instance.
@@ -34,7 +34,7 @@ export default function App() {
3434
// Removes all menus and toolbars.
3535
formattingToolbar={false}
3636
linkToolbar={false}
37-
imageToolbar={false}
37+
filePanel={false}
3838
sideMenu={false}
3939
slashMenu={false}
4040
tableHandles={false}

examples/02-ui-components/02-formatting-toolbar-buttons/App.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import "@blocknote/core/fonts/inter.css";
2+
import { BlockNoteView } from "@blocknote/mantine";
3+
import "@blocknote/mantine/style.css";
24
import {
35
BasicTextStyleButton,
46
BlockTypeSelect,
57
ColorStyleButton,
68
CreateLinkButton,
9+
FileCaptionButton,
10+
FileReplaceButton,
711
FormattingToolbar,
812
FormattingToolbarController,
9-
ImageCaptionButton,
1013
NestBlockButton,
11-
ReplaceImageButton,
1214
TextAlignButton,
1315
UnnestBlockButton,
1416
useCreateBlockNote,
1517
} from "@blocknote/react";
16-
import { BlockNoteView } from "@blocknote/mantine";
17-
import "@blocknote/mantine/style.css";
1818

1919
import { BlueButton } from "./BlueButton";
2020

@@ -77,8 +77,8 @@ export default function App() {
7777
{/* Extra button to toggle blue text & background */}
7878
<BlueButton key={"customButton"} />
7979

80-
<ImageCaptionButton key={"imageCaptionButton"} />
81-
<ReplaceImageButton key={"replaceImageButton"} />
80+
<FileCaptionButton key={"fileCaptionButton"} />
81+
<FileReplaceButton key={"replaceFileButton"} />
8282

8383
<BasicTextStyleButton
8484
basicTextStyle={"bold"}

examples/02-ui-components/03-formatting-toolbar-block-type-items/.bnexample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"tags": ["Intermediate", "Blocks", "UI Components", "Formatting Toolbar", "Custom Schemas"],
66
"dependencies": {
77
"@mantine/core": "^7.7.1",
8-
"react-icons": "^4.3.1"
8+
"react-icons": "^5.2.1"
99
}
1010
}

examples/02-ui-components/03-formatting-toolbar-block-type-items/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react": "^18.2.0",
2020
"react-dom": "^18.2.0",
2121
"@mantine/core": "^7.7.1",
22-
"react-icons": "^4.3.1"
22+
"react-icons": "^5.2.1"
2323
},
2424
"devDependencies": {
2525
"@types/react": "^18.0.25",

examples/02-ui-components/04-side-menu-buttons/.bnexample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"author": "matthewlipski",
55
"tags": ["Intermediate", "Blocks", "UI Components", "Block Side Menu"],
66
"dependencies": {
7-
"react-icons": "^4.3.1"
7+
"react-icons": "^5.2.1"
88
}
99
}

0 commit comments

Comments
 (0)