Skip to content

refactor: blocknote API uses lowest possible level prosemirror primitives #1609

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 27 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
26440c0
feat(core): add blocknote transactions
nperez0111 Apr 4, 2025
760d76e
fix: do not even worry about tiptap transactions
nperez0111 Apr 4, 2025
77f1bee
fix: execute `updateBlock` as a transaction
nperez0111 Apr 4, 2025
4a3d364
chore: use replace step to insert blocks
nperez0111 Apr 4, 2025
eb849cd
chore: remove use of ttEditor
nperez0111 Apr 7, 2025
fc60121
chore: clarifying comments
nperez0111 Apr 9, 2025
35a7753
fix: switch to only using transactions instead of prosemirrorState
nperez0111 Apr 11, 2025
3dc0fcd
test: intentionally failing test
nperez0111 Apr 11, 2025
ffc4a5b
fix: apply plugin `appendedTransactions`
nperez0111 Apr 11, 2025
7133bc8
revert: "fix: apply plugin `appendedTransactions`"
nperez0111 Apr 14, 2025
6fac1fd
refactor: blocknote API uses lowest possible level prosemirror primit…
nperez0111 Apr 14, 2025
934adc5
chore: use tr state instead of prosemirrorState
nperez0111 Apr 14, 2025
34ebafa
refactor: update the updateBlock command
nperez0111 Apr 15, 2025
6e1d9d6
refactor: use high-level methods for moveBlocks
nperez0111 Apr 15, 2025
2980c6c
refactor: stash into `cached` schema property
nperez0111 Apr 15, 2025
777ed99
refactor: make everything based on editor schema
nperez0111 Apr 15, 2025
9284a85
chore: update
nperez0111 Apr 15, 2025
ddfed65
refactor: make dispatch private
nperez0111 Apr 15, 2025
402dd37
refactor: make `transaction` private
nperez0111 Apr 15, 2025
7ee1c42
refactor: remove reading from `prosemirrorState` add `exec` and `canE…
nperez0111 Apr 16, 2025
cc23f3f
fix: have dispatch be bound
nperez0111 Apr 16, 2025
9511604
fix: throw an error for canExec too
nperez0111 Apr 16, 2025
47de76e
chore: rm transactions test
nperez0111 Apr 16, 2025
3440c3d
refactor: reorganize the arguments
nperez0111 Apr 16, 2025
6a9230b
Merge branch 'main' into feat/blocknote-transactions-3
nperez0111 Apr 16, 2025
387088d
refactor: do not use prosemirrorState
nperez0111 Apr 16, 2025
6e6c5fd
chore: add jsdoc
nperez0111 Apr 16, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Test blocknote transactions > should return the correct block info 1`] = `
[
{
"children": [],
"content": [
{
"styles": {},
"text": "Hey-yo",
"type": "text",
},
],
"id": "1",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": [],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Test insertBlocks > Insert multiple blocks after 1`] = `
[
{
"children": [],
"content": [
{
"styles": {},
"text": "Inserted paragraph 1",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Inserted paragraph 2",
"type": "text",
},
],
"id": "1",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Inserted paragraph 3",
"type": "text",
},
],
"id": "2",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
`;

exports[`Test insertBlocks > Insert multiple blocks after 2`] = `
[
{
"children": [],
Expand Down Expand Up @@ -619,6 +675,62 @@ exports[`Test insertBlocks > Insert multiple blocks after 1`] = `
`;

exports[`Test insertBlocks > Insert multiple blocks before 1`] = `
[
{
"children": [],
"content": [
{
"styles": {},
"text": "Inserted paragraph 1",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Inserted paragraph 2",
"type": "text",
},
],
"id": "1",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
{
"children": [],
"content": [
{
"styles": {},
"text": "Inserted paragraph 3",
"type": "text",
},
],
"id": "2",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
`;

exports[`Test insertBlocks > Insert multiple blocks before 2`] = `
[
{
"children": [],
Expand Down Expand Up @@ -1237,6 +1349,22 @@ exports[`Test insertBlocks > Insert multiple blocks before 1`] = `
`;

exports[`Test insertBlocks > Insert single basic block after 1`] = `
[
{
"children": [],
"content": [],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
`;

exports[`Test insertBlocks > Insert single basic block after 2`] = `
[
{
"children": [],
Expand Down Expand Up @@ -1815,6 +1943,28 @@ exports[`Test insertBlocks > Insert single basic block after 1`] = `
`;

exports[`Test insertBlocks > Insert single basic block before (without type) 1`] = `
[
{
"children": [],
"content": [
{
"styles": {},
"text": "test",
"type": "text",
},
],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
`;

exports[`Test insertBlocks > Insert single basic block before (without type) 2`] = `
[
{
"children": [],
Expand Down Expand Up @@ -2399,6 +2549,22 @@ exports[`Test insertBlocks > Insert single basic block before (without type) 1`]
`;

exports[`Test insertBlocks > Insert single basic block before 1`] = `
[
{
"children": [],
"content": [],
"id": "0",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
]
`;

exports[`Test insertBlocks > Insert single basic block before 2`] = `
[
{
"children": [],
Expand Down Expand Up @@ -2977,6 +3143,79 @@ exports[`Test insertBlocks > Insert single basic block before 1`] = `
`;

exports[`Test insertBlocks > Insert single complex block after 1`] = `
[
{
"children": [
{
"children": [
{
"children": [],
"content": [
{
"styles": {},
"text": "Double Nested Paragraph 2",
"type": "text",
},
],
"id": "inserted-double-nested-paragraph-2",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
],
"content": [
{
"styles": {},
"text": "Nested Paragraph 2",
"type": "text",
},
],
"id": "inserted-nested-paragraph-2",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
],
"content": [
{
"styles": {
"bold": true,
},
"text": "Heading",
"type": "text",
},
{
"styles": {},
"text": " with styled ",
"type": "text",
},
{
"styles": {
"italic": true,
},
"text": "content",
"type": "text",
},
],
"id": "inserted-heading-with-everything",
"props": {
"backgroundColor": "red",
"level": 2,
"textAlignment": "center",
"textColor": "red",
},
"type": "heading",
},
]
`;

exports[`Test insertBlocks > Insert single complex block after 2`] = `
[
{
"children": [],
Expand Down Expand Up @@ -3612,6 +3851,79 @@ exports[`Test insertBlocks > Insert single complex block after 1`] = `
`;

exports[`Test insertBlocks > Insert single complex block before 1`] = `
[
{
"children": [
{
"children": [
{
"children": [],
"content": [
{
"styles": {},
"text": "Double Nested Paragraph 2",
"type": "text",
},
],
"id": "inserted-double-nested-paragraph-2",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
],
"content": [
{
"styles": {},
"text": "Nested Paragraph 2",
"type": "text",
},
],
"id": "inserted-nested-paragraph-2",
"props": {
"backgroundColor": "default",
"textAlignment": "left",
"textColor": "default",
},
"type": "paragraph",
},
],
"content": [
{
"styles": {
"bold": true,
},
"text": "Heading",
"type": "text",
},
{
"styles": {},
"text": " with styled ",
"type": "text",
},
{
"styles": {
"italic": true,
},
"text": "content",
"type": "text",
},
],
"id": "inserted-heading-with-everything",
"props": {
"backgroundColor": "red",
"level": 2,
"textAlignment": "center",
"textColor": "red",
},
"type": "heading",
},
]
`;

exports[`Test insertBlocks > Insert single complex block before 2`] = `
[
{
"children": [
Expand Down
Loading
Loading