Conversation
|
@falsaadehh @harbournick looks good to me! |
There was a problem hiding this comment.
Pull Request Overview
This PR adds trackable block IDs to various node types in the super-editor by implementing a sdBlockId attribute system. The purpose is to enable tracking and manipulation of block-level nodes through unique identifiers.
Key changes:
- Adds
sdBlockIdattribute to multiple node types (Table, DocumentSection, ShapeTextbox, etc.) - Creates a new
BlockNodeextension with commands and helpers for block manipulation - Implements a
generateBlockUniqueIdutility function for creating unique identifiers
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/super-editor/src/extensions/table/table.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/structured-content/document-section.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/shape-textbox/shape-textbox.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/shape-container/shape-container.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/paragraph/paragraph.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/ordered-list/ordered-list.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/heading/heading.js |
Adds sdBlockId attribute with different implementation pattern |
packages/super-editor/src/extensions/bullet-list/bullet-list.js |
Adds sdBlockId attribute with HTML parsing/rendering |
packages/super-editor/src/extensions/block-node/block-node.js |
New extension providing commands and helpers for block manipulation |
packages/super-editor/src/core/utilities/sdBlockUniqueId.js |
Utility function for generating unique block IDs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@VladaHarbour can you give this another look now? |
There was a problem hiding this comment.
Hi @falsaadehh! I think that onCreate hook of BlockNode extension is extra and we can proceed with appendTransaction which is executed right after onCreate every time we face block node. We can reduce the number of calculations. @harbournick can you please confirm my point
But what is more, I found one lists related issue. Every paragraph added after newly inserted list has the same id which is weird. Also @harbournick do you think every list item(which is a separate list) should have the same or different id? For now it's the same if we create new list but different if we upload a document
Screen.Recording.2025-08-20.at.15.51.25.mov
if onCreate is removed then uploaded documents won't have unique ids wrapped around their nodes. for lists having the same unique id I think it's better if i move unique id to list item or not add unique ids to lists at all since it has many attributes that identify it and I think that will fix the issue for the following paragraph having same id as will @harbournick should we remove lists from our block node types? |
harbournick
left a comment
There was a problem hiding this comment.
Great call using appendTransaction here! Please see my comments and #793
|
One more comment: let's please add some unit tests for each of the helpers and commands |
…hen first loaded (#793) * chore: update content block * fix: create utility fns for block node, add tests, add hasInitialized for first pass
|
done @harbournick @VladaHarbour considered all the review comments here |
harbournick
left a comment
There was a problem hiding this comment.
Just two super minor fixes but otherwise looks great!
|
|
||
| const { findChildren } = helpers; | ||
| const SD_BLOCK_ID_ATTRIBUTE_NAME = 'sdBlockId'; | ||
| export const BlockNodePluginKey = new PluginKey('blockNdePlugin'); |
There was a problem hiding this comment.
Let's fix typo in blockNdePlugin
| const SD_BLOCK_ID_ATTRIBUTE_NAME = 'sdBlockId'; | ||
| export const BlockNodePluginKey = new PluginKey('blockNdePlugin'); | ||
| export const BlockNode = Extension.create({ | ||
| name: 'BlockNode', |
There was a problem hiding this comment.
let's go with blockNode for consistency (lower case b) in the actual name key
done |
|
I see the unit tests are failing. Is this expected @harbournick @falsaadehh ? |
@chittolinag great catch! you're right - by changing the name of the block we introduced a namespace issue. And that's why we have unit tests! |
No description provided.