Skip to content

HAR-10208 - Trackable id #788

Merged
harbournick merged 14 commits intodevelopfrom
trackable_ids
Aug 22, 2025
Merged

HAR-10208 - Trackable id #788
harbournick merged 14 commits intodevelopfrom
trackable_ids

Conversation

@falsaadehh
Copy link
Copy Markdown
Contributor

No description provided.

@falsaadehh falsaadehh marked this pull request as draft August 19, 2025 13:16
@falsaadehh falsaadehh marked this pull request as ready for review August 19, 2025 13:51
@falsaadehh falsaadehh changed the title WIP - Trackable id - HAR-10208 Trackable id - HAR-10208 Aug 19, 2025
@falsaadehh falsaadehh changed the title Trackable id - HAR-10208 HAR-10208 - Trackable id Aug 19, 2025
@VladaHarbour
Copy link
Copy Markdown
Contributor

VladaHarbour commented Aug 19, 2025

@falsaadehh @harbournick looks good to me!
The only thing I would like to mention is that I noticed that all block nodes of the same type have the same id. I'm not aware of the ticket details but just wondering whether this is desired behavior

Comment thread packages/super-editor/src/extensions/heading/heading.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 sdBlockId attribute to multiple node types (Table, DocumentSection, ShapeTextbox, etc.)
  • Creates a new BlockNode extension with commands and helpers for block manipulation
  • Implements a generateBlockUniqueId utility 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.

Comment thread packages/super-editor/src/extensions/heading/heading.js Outdated
Comment thread packages/super-editor/src/extensions/heading/heading.js Outdated
Comment thread packages/super-editor/src/core/utilities/sdBlockUniqueId.js Outdated
@falsaadehh
Copy link
Copy Markdown
Contributor Author

@VladaHarbour can you give this another look now?
@harbournick I tried to implement this without a plugin but it wasn't a good solution, if default return the id then it's executed once per node type, hence multiple nodes of same type will have the same id even if i have keepOnSplit: false, also it wasn't an elegant solution overall. if i'm using it then i need to use parseHTML instead of parseDOM to make sure the id is in the node not only in the dom which also is not a good practice here
based on this conversation the best way to do it via appendTransaction
https://discuss.prosemirror.net/t/how-i-can-attach-attribute-with-dynamic-value-when-new-paragraph-is-inserted/751/3
let me know what you think

Copy link
Copy Markdown
Contributor

@VladaHarbour VladaHarbour left a comment

Choose a reason for hiding this comment

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

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

@falsaadehh
Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

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

Great call using appendTransaction here! Please see my comments and #793

Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js
Comment thread packages/super-editor/src/extensions/block-node/block-node.js Outdated
Comment thread packages/super-editor/src/extensions/block-node/block-node.js
@harbournick
Copy link
Copy Markdown
Collaborator

One more comment: let's please add some unit tests for each of the helpers and commands

harbournick and others added 3 commits August 21, 2025 11:10
…hen first loaded (#793)

* chore: update content block

* fix: create utility fns for block node, add tests, add hasInitialized for first pass
@falsaadehh
Copy link
Copy Markdown
Contributor Author

done @harbournick @VladaHarbour considered all the review comments here

Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

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

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');
Copy link
Copy Markdown
Collaborator

@harbournick harbournick Aug 21, 2025

Choose a reason for hiding this comment

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

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',
Copy link
Copy Markdown
Collaborator

@harbournick harbournick Aug 21, 2025

Choose a reason for hiding this comment

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

let's go with blockNode for consistency (lower case b) in the actual name key

@falsaadehh
Copy link
Copy Markdown
Contributor Author

Just two super minor fixes but otherwise looks great!

done

Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

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

LGTM

@chittolinag
Copy link
Copy Markdown
Contributor

I see the unit tests are failing. Is this expected @harbournick @falsaadehh ?

@harbournick
Copy link
Copy Markdown
Collaborator

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!
pushed a commit to fix

@harbournick harbournick merged commit 7a696c6 into develop Aug 22, 2025
5 of 7 checks passed
@harbournick harbournick deleted the trackable_ids branch August 22, 2025 17:42
@chittolinag chittolinag restored the trackable_ids branch August 22, 2025 18:41
@chittolinag chittolinag deleted the trackable_ids branch August 22, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants