Skip to content

feat: Custom Blocks #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 73 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
65a058f
simplify formattingtoolbar
YousefED Mar 17, 2023
1b7a745
Fixed React component types and added customizable formatting toolbar…
matthewlipski Mar 29, 2023
7aa833e
Finished formatting toolbar customization with old props
matthewlipski Mar 30, 2023
4d44c84
Changed formatting toolbar props to use BlockNoteEditor
matthewlipski Mar 31, 2023
3a5a653
Fixed text alignment with basic selection object
matthewlipski Mar 31, 2023
e91708c
Fixed block nesting tests
matthewlipski Mar 31, 2023
adde0ab
Merge branch 'main' into custom-formattingtoolbar
matthewlipski Mar 31, 2023
f446be8
Removed multiple block shorthand for updateBlock
matthewlipski Mar 31, 2023
3c02d68
Merge remote-tracking branch 'origin/custom-formattingtoolbar' into c…
matthewlipski Mar 31, 2023
f4292e5
Added comments
matthewlipski Mar 31, 2023
6e0fafa
Added basic mouse cursor position
matthewlipski Apr 1, 2023
6dfd444
Added drag handle menu customization API
matthewlipski Apr 1, 2023
77591d7
Copied changes from PR and minor improvements
matthewlipski Apr 3, 2023
5acf0c2
Table block test
matthewlipski Apr 5, 2023
c1779ef
wip: custom blocks typing and API
YousefED Apr 12, 2023
e6e4d75
add comments
YousefED Apr 12, 2023
56c4988
fix nodeConversions, add schema
YousefED Apr 12, 2023
bcaf62c
comments
YousefED Apr 14, 2023
e28df3c
Implemented renderHTML and parseHTML for createCustomBlock
matthewlipski Apr 21, 2023
3c94fa1
Temp changes
matthewlipski Apr 27, 2023
255a0d1
Mostly implemented stricter typing for custom blocks
matthewlipski Apr 27, 2023
adc437d
Cleanup & fixed build issues
matthewlipski May 1, 2023
a364e6f
Fixed useBlockNote and improved some typing
matthewlipski May 1, 2023
32af8b0
Implemented PR feedback
matthewlipski May 2, 2023
671a9da
Minor changes
matthewlipski May 4, 2023
e053f7b
Made custom blocks use node views
matthewlipski May 8, 2023
1fa2442
Created custom example and setup component testing
matthewlipski May 10, 2023
25a0911
Changed custom block `renderHTML` implementation
matthewlipski May 11, 2023
fc35039
Changed custom block `renderHTML` implementation
matthewlipski May 16, 2023
861cb6c
Changed custom block testing setup and added custom block examples
matthewlipski May 16, 2023
d149ab4
Merge remote-tracking branch 'origin/custom-blocks-example' into cust…
matthewlipski May 16, 2023
9d25b62
Slightly changed `blockConfig.render` type
matthewlipski May 17, 2023
990f22e
Merge branch 'custom-blocks-api-changes' into custom-blocks-example
matthewlipski May 17, 2023
e5ce713
Merge branch 'main' into custom-blocks-example
matthewlipski May 17, 2023
0b733e2
Fixed merge issues
matthewlipski May 17, 2023
35f4c90
custom blocks react poc
YousefED May 18, 2023
060ddc4
Added internal custom block copy/paste tests
matthewlipski May 18, 2023
748ec31
Small fix
matthewlipski May 18, 2023
89f6f7a
Added external custom block copy/paste tests
matthewlipski May 18, 2023
b7bff3b
Added expected serialized HTML for example custom blocks
matthewlipski May 19, 2023
5a4f3fa
Updated playwright scripts
matthewlipski May 19, 2023
fded699
Updated component tests and added serializer extension
matthewlipski May 22, 2023
78e2d51
Merge branch 'main' into custom-blocks-example
matthewlipski May 22, 2023
7693d14
Updated React custom block API
matthewlipski May 22, 2023
17ec6af
Merge remote-tracking branch 'origin/custom-blocks-react' into custom…
matthewlipski May 23, 2023
5068d6c
Reverted `App.tsx`
matthewlipski May 23, 2023
8878d73
Fixed `test:updateSnaps` script
matthewlipski May 23, 2023
6d50424
Added external copypaste snapshots
matthewlipski May 23, 2023
d32206e
Fixed failing tests
matthewlipski May 23, 2023
008bb25
Copy/paste tests are now skipped for WebKit
matthewlipski May 23, 2023
dc2a27f
Removed old `console.log`s
matthewlipski May 23, 2023
0a94c76
Small change to `test-ct` script
matthewlipski May 23, 2023
bd17bcd
Removed image block from `defaultBlocks.ts`
matthewlipski May 23, 2023
edd6e1c
Updated component tests & snapshots
matthewlipski May 23, 2023
041895c
General cleanup
matthewlipski May 23, 2023
ca2c577
Updated firefox colors snapshot
matthewlipski May 23, 2023
558379f
remove unnecessary generics for slash menu items
YousefED May 24, 2023
a4fdca4
fix types
YousefED May 24, 2023
666ab84
hack around TextAlignButton types
YousefED May 24, 2023
018e676
Custom blocks example typing improvements (#202)
YousefED May 24, 2023
f833b94
Merge branch 'main' into custom-blocks-example
matthewlipski May 24, 2023
2cce86a
Implemented most PR feedback
matthewlipski May 24, 2023
d349266
Implemented most PR feedback
matthewlipski May 24, 2023
39e7d3e
Merge remote-tracking branch 'origin/custom-blocks-example' into cust…
matthewlipski May 25, 2023
b4b23a6
Minor fixes to custom blocks
matthewlipski May 25, 2023
1d46994
Custom blocks docs (#217)
matthewlipski May 30, 2023
7bb140e
Updated unit tests
matthewlipski May 30, 2023
60846de
simplify docs
YousefED May 30, 2023
2f6ca2a
package lock update
YousefED May 30, 2023
78a8352
add comment
YousefED May 30, 2023
f29fd00
retreat, fallback slash command to "any"
YousefED May 30, 2023
0ba0ebf
update packages incl prosemirror-view (#223)
YousefED May 31, 2023
3a9156b
Merge remote-tracking branch 'origin/main' into custom-blocks-example
YousefED May 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ yarn-error.log*
.vercel
test-results/
playwright-report/
release
release
/test-results/
/playwright-report/
/playwright/.cache/
2 changes: 1 addition & 1 deletion examples/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@vitejs/plugin-react": "^3.1.0",
"eslint": "^8.10.0",
"eslint-config-react-app": "^7.0.0",
"typescript": "^4.5.4",
"typescript": "^5.0.4",
"vite": "^4.1.2",
"vite-plugin-eslint": "^1.8.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"eslint": "^8.10.0",
"eslint-config-react-app": "^7.0.0",
"typescript": "^4.5.4",
"typescript": "^5.0.4",
"vite": "^4.1.2",
"vite-plugin-eslint": "^1.8.1"
},
Expand Down
6 changes: 4 additions & 2 deletions examples/vanilla/src/ui/blockSideMenuFactory.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { BlockSideMenuFactory } from "@blocknote/core";
import { BlockSideMenuFactory, DefaultBlockSchema } from "@blocknote/core";
import { createButton } from "./util";

/**
* This menu is drawn next to a block, when it's hovered over
* It renders a drag handle and + button to create a new block
*/
export const blockSideMenuFactory: BlockSideMenuFactory = (staticParams) => {
export const blockSideMenuFactory: BlockSideMenuFactory<DefaultBlockSchema> = (
staticParams
) => {
const container = document.createElement("div");
container.style.background = "gray";
container.style.position = "absolute";
Expand Down
12 changes: 7 additions & 5 deletions examples/vanilla/src/ui/formattingToolbarFactory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FormattingToolbarFactory } from "@blocknote/core";
import { DefaultBlockSchema, FormattingToolbarFactory } from "@blocknote/core";
import { createButton } from "./util";

/**
* This menu is drawn when a piece of text is selected. We can use it to change formatting options
* such as bold, italic, indentation, etc.
*/
export const formattingToolbarFactory: FormattingToolbarFactory = (
staticParams
) => {
export const formattingToolbarFactory: FormattingToolbarFactory<
DefaultBlockSchema
> = (staticParams) => {
const container = document.createElement("div");
container.style.background = "gray";
container.style.position = "absolute";
Expand Down Expand Up @@ -35,7 +35,9 @@ export const formattingToolbarFactory: FormattingToolbarFactory = (
}

boldBtn.text =
"bold" in staticParams.editor.getActiveStyles() ? "unset bold" : "set bold";
"bold" in staticParams.editor.getActiveStyles()
? "unset bold"
: "set bold";
container.style.top = params.referenceRect.y + "px";
container.style.left = params.referenceRect.x + "px";
},
Expand Down
16 changes: 10 additions & 6 deletions examples/vanilla/src/ui/slashMenuFactory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { BaseSlashMenuItem, SuggestionsMenuFactory } from "@blocknote/core";
import {
BaseSlashMenuItem,
DefaultBlockSchema,
SuggestionsMenuFactory,
} from "@blocknote/core";
import { createButton } from "./util";

/**
* This menu is drawn when the cursor is moved to a hyperlink (using the keyboard),
* or when the mouse is hovering over a hyperlink
*/
export const slashMenuFactory: SuggestionsMenuFactory<BaseSlashMenuItem> = (
staticParams
) => {
export const slashMenuFactory: SuggestionsMenuFactory<
BaseSlashMenuItem<DefaultBlockSchema>
> = (staticParams) => {
const container = document.createElement("div");
container.style.background = "gray";
container.style.position = "absolute";
Expand All @@ -17,8 +21,8 @@ export const slashMenuFactory: SuggestionsMenuFactory<BaseSlashMenuItem> = (
document.body.appendChild(container);

function updateItems(
items: BaseSlashMenuItem[],
onClick: (item: BaseSlashMenuItem) => void,
items: BaseSlashMenuItem<DefaultBlockSchema>[],
onClick: (item: BaseSlashMenuItem<DefaultBlockSchema>) => void,
selected: number
) {
container.innerHTML = "";
Expand Down
Loading