Skip to content

Block Restructuring#64

Merged
matthewlipski merged 57 commits into
mainfrom
block-restructuring
Dec 7, 2022
Merged

Block Restructuring#64
matthewlipski merged 57 commits into
mainfrom
block-restructuring

Conversation

@matthewlipski
Copy link
Copy Markdown
Collaborator

Currently, the way block types are handled by BlockNote is through setting custom attributes on blocks. This heavily restricts how extensible blocks can be as the custom attributes only affect styling and block contents are always expected to be made up of divs. This PR restructures blocks so that it's possible to easily extend what kind of content they can contain.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
blocknote ✅ Ready (Inspect) Visit Preview Dec 6, 2022 at 8:24PM (UTC)

Copy link
Copy Markdown
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a great improvement, but still some quirks to iron out. I'm running into some issues in the vercel build:

  • list items are quite funky on chrome I think
  • I also got into a state where nothing happens when clicking +. Not sure how I can reproduce
  • pressing Tab focusses the URL bar of the browser

I think many of these are related to the commands in AddKeyboardShortcuts. Maybe we should go over these changes together?

I've also added some other thoughts / suggestions in this review.

Comment thread packages/core/src/extensions/Blocks/nodes/ListItemBlock.ts Outdated
Comment thread packages/core/src/extensions/Blocks/nodes/Block.ts Outdated
Comment thread packages/core/src/extensions/Blocks/nodes/HeadingBlock.ts Outdated
Comment thread packages/core/src/extensions/Blocks/nodes/Block.ts Outdated
Comment thread packages/core/src/extensions/Blocks/nodes/Block.ts Outdated
Comment thread packages/core/src/extensions/BubbleMenu/component/BubbleMenu.tsx
Comment thread packages/core/src/extensions/DraggableBlocks/components/DragHandle.tsx Outdated
Comment thread packages/core/src/extensions/Blocks/nodes/Block.ts Outdated
* fix animations for headings and indents

* remove submodule

* fix css
};
},

parseHTML() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe remove this? Let's do it after tests work, and also create a test for pasting a or other unsupported tag

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since copy/pasting from other sites doesn't work very well after the restructuring, I think we should just leave it as is for now and try to fix the issue later, since it's quite a bit more complex than originally expected.

…restructuring

# Conflicts:
#	packages/core/src/extensions/Blocks/nodes/Block.ts
#	packages/core/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.ts
@matthewlipski matthewlipski changed the title WIP: Block Restructuring Block Restructuring Dec 6, 2022
Comment thread packages/core/src/extensions/Blocks/PreviousBlockTypePlugin.ts
tr.setNodeMarkup(currentBlock.pos, undefined, attributes);
// Finds the nearest previous block, prioritizing higher nesting levels.
while (prevBlockInfo.numChildBlocks > 0) {
prevBlockEndPos--;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were not able to find a built-in Tiptap / PM function for this?

Comment thread packages/core/src/extensions/Blocks/nodes/Block.ts Outdated
@matthewlipski
Copy link
Copy Markdown
Collaborator Author

Referring to this
Yes, we looked at using findParentNodeClosestToPos but found out that it has a similar implementation to getBlockFromPos (i.e. it loops and gets a block at a higher depth each iteration), so IIRC we decided not to change it since it didn't really make it more efficient.

@matthewlipski matthewlipski merged commit c69fc33 into main Dec 7, 2022
fogle pushed a commit to fogle/BlockNote that referenced this pull request May 20, 2023
* Restructured text & heading blocks (excluding drag handle add implementation)

* Small cleanup

* Cleaned up drag handle code

* Added basic list item implementation

* Updated block commands and keyboard handling

* Added ordered list item indexing

* Finished block manipulation logic

* Fixed bug causing suggestion menu to not work properly in list item blocks

* Refactoring changes

* Minor fix

* fix animations for headings and indents (TypeCellOS#67)

* fix animations for headings and indents

* remove submodule

* fix css

* Fixed bug where splitting a block created an additional empty block

* Cleaned up drag handle code

* Fixed bug where the suggestion plugin tried to process transactions created by the ordered list indexing plugin

* Improvements to block content naming and file structure

* Code style changes and small fix to block keyboard shortcuts

* Fixed bugs regarding selection when deleting blocks and using the suggestion menu with the keyboard

* Block content attribute naming fixes

* Fixed list item copy/pasting within the editor

* Updated element selectors for tests

* Updated snapshots for copy/paste and drag/drop tests

* Adjusted enter key handler behavior

* Changed ordered list item indices to start at 1 instead of 0

* Fixed list styling (no animations)

* Updated remaining test snapshots

* try clean playwright cache

* Fixed bug where splitting a block duplicates its ID

* Fixed bug where ordered list item indices were being updated unnecessarily

* clean up OrderedListItemIndexPlugin

* Fixed animation issue caused by change in naming convention

* Added animations for unordered lists

* Added animations for ordered lists

* Added dispatch to block commands

* Made backspace revert all block typing instead of just list items

* Removed redundant conditions in block keyboard handlers

* Changed ordered list index type from number to string in plugin

* Optimized `getPosFromBlock` function

* Fixed multiple block dragging

* Improved transaction filtering for `PreviousBlockTypePlugin`

* Improved paste behaviour for content outside the editor

* Removed dispatch calls from block commands

* Added edge cases for block commands (not currently being triggered)

* Added test for Enter keyboard handler with selection spanning multiple blocks

* Added functions to allow testing block IDs

* Tests in which blocks are deleted/moved now verify block IDs

* Added updated snapshots

* Added updated screenshots for drag handle menu

* Removed `joinBackward` as it is no longer used

* Improved paste reliability from other sites, broke inline styles.

* Improved paste reliability from other sites, broke inline styles.

* Revert "Improved paste reliability from other sites, broke inline styles."

This reverts commit 5c5c448.

* Small fixes

* Improved block ID mocking implementation.

* Updated snapshot

Co-authored-by: Yousef <yousefdardiry@gmail.com>
Co-authored-by: Matthew Lipski <matthewlipski@Matthews-Mac-mini.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants