Skip to content

Notes: Add inline notes to text in string and nested attributes - #84337

Closed
mdtanjid0 wants to merge 5 commits into
WordPress:trunkfrom
mdtanjid0:fix/notes-inline-note-string-nested-attributes
Closed

mdtanjid0 wants to merge 5 commits into
WordPress:trunkfrom
mdtanjid0:fix/notes-inline-note-string-nested-attributes

Conversation

@mdtanjid0

@mdtanjid0 mdtanjid0 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What?

Part of #84328

Selecting text and adding a note now creates an inline note in blocks whose text is stored in a string attribute or nested in another attribute. Before, these always got a block-level note.

Now inline: Table cells, Navigation Link, Submenu, Home Link, Navigation Overlay Close, Search, Read More, Post Terms, Post Author (byline), Post Navigation Link, Post Excerpt ("read more" text), and Playlist (caption, not listed in the issue).

Why?

The listed blocks fail for three different reasons. This PR covers the first two:

  • wrapInlineNote and removeNoteFormat only accepted a RichTextData, so a string attribute edited through RichText never got a marker. The readers (findNoteRange, getNoteAtCaret) already handled strings.
  • A table cell reports its selection as a path (body.0.cells.1.content), but the helpers only read and wrote top-level attribute keys.
  • Accordion Heading and Categories have no identifier, so the selection carries no attributeKey. That is a block-library change and is in Categories: Add the RichText identifier to the label #84522.

How?

  • The two writers accept an HTML string and return the same type they were given. Changing these attributes to rich-text in block.json isn't an option: a rich-text attribute without a source fails validation on parse and the saved value is dropped.
  • findNoteInBlock and the caret helpers walk nested attribute values and key them by the same dot-separated path RichText reports. A nested value is written back by copying its top-level attribute with the value replaced. The marker stays the only anchor; the path is found at read time.

On the front end, markers in these attributes are removed by the existing render_block filter. I checked Read More, Search (including the button's aria-label), Post Terms, Post Navigation Link, Post Author and Navigation Link.

Not covered, happy to follow up or adjust based on what you prefer:

  • Tab List: the label lives in the child Tab block's attributes, not the Tab List's.
  • Site Title, Site Tagline and the Post Excerpt body: the text is an entity value, so a marker would be saved into the site option or the excerpt. A block-level note seems right there.
  • Home Link and Navigation Overlay Close while showing their default label: the text isn't in the attribute yet.
  • Text Columns (deprecated).

Testing Instructions

  1. Open a post and enable Notes from the Options menu > Notes > All notes.
  2. Insert a Table block and type some text in a cell. Select part of the text and choose Add note from the block options menu. Send the note. The selected text is highlighted, and the note is not attached to the whole block.
  3. Delete the note. The highlight is gone and the cell text is unchanged. Click Undo in the snackbar: the highlight comes back.
  4. Repeat steps 2 and 3 with a Read More block.
  5. Add an inline note to a Read More block, save, and view the post. The link text has no <mark> around it.

Automated:

  • npm run test:unit -- packages/editor/src/components/collab-sidebar/test/utils.jsdom.test.js
  • npm run test:e2e -- test/e2e/specs/editor/various/block-notes.spec.js

Testing Instructions for Keyboard

Same as above. Select the text with Shift+Arrow keys, press Shift+F10 on the block toolbar's Options button, and choose Add note.

Use of AI Tools

This PR was authored with Claude Code (Claude Opus 5.5). I reviewed the changes; the unit tests and the Chromium e2e tests for Notes were run locally.

🤖 Generated with Claude Code

mdtanjid0 and others added 2 commits October 9, 2026 00:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Block library /packages/block-library labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @mdtanjid0! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mdtanjid0 <mdtanjid@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 8, 2026
@mdtanjid0
mdtanjid0 marked this pull request as ready for review October 8, 2026 18:25
@mdtanjid0
mdtanjid0 requested a review from fabiankaegy as a code owner October 8, 2026 18:25
@Mamaduka

Mamaduka commented Oct 9, 2026

Copy link
Copy Markdown
Member

Thanks for contributing, @mdtanjid0!

I think it's better to split the PR. We can extract the block-library changes into a separate PR. Then focus on notes utility improvements here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…laude/gutenberg-issue-84328-3bffa7

# Conflicts:
#	packages/editor/src/components/collab-sidebar/utils.js
…laude/gutenberg-issue-84328-3bffa7

# Conflicts:
#	packages/editor/CHANGELOG.md
@adamsilverstein adamsilverstein added the [Type] Bug An existing feature does not function as intended label Oct 30, 2026
@adamsilverstein

adamsilverstein commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

I confirmed the basic funcitonality works as expected for tables with text:

image

Although behavior was unexpected when I hit undo - the mark was removed, but the note was left orphaned.

@adamsilverstein

Copy link
Copy Markdown
Member

@mdtanjid0 thanks for the effort here, I suggest closing this as not planned, see #84328 (comment)

@Mamaduka Mamaduka added the [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting label Nov 18, 2026
@Mamaduka

Copy link
Copy Markdown
Member

Thanks for contributing, @mdtanjid0!

Closing based on the discussion in the issue: #84328 (comment).

@Mamaduka Mamaduka closed this Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants