close
Skip to content

[New Block] Todo block#70368

Open
sarthaknagoshe2002 wants to merge 5 commits intoWordPress:trunkfrom
sarthaknagoshe2002:new-block/todo
Open

[New Block] Todo block#70368
sarthaknagoshe2002 wants to merge 5 commits intoWordPress:trunkfrom
sarthaknagoshe2002:new-block/todo

Conversation

@sarthaknagoshe2002
Copy link
Copy Markdown
Contributor

What?

This PR adds a new core/todo block, allowing editors to embed a to-do list in posts or pages. The block supports:

  • Role‑based access: configure which user roles (e.g., Administrator, Editor, Subscriber) can toggle checkbox states.
  • Global or per-user lists: stored via post meta (global across users) or localStorage (per-user).
  • Custom styling: control the checkbox color and size.
  • List management: add, edit, reorder, and delete tasks.

Closes #15005

Why?

Editors often need lightweight checklists—whether for content preparation, collaboration tracking, or simple task lists. The core/todo block provides this functionality natively in Gutenberg, avoiding the need for custom plugins or external solutions. It supports both site-wide and local to-do use cases for logged-in users.

How?

The block uses block attributes and post meta to manage task data and sync checkbox states. It uses useEntityProp for global persistence and localStorage for per-user local mode. Role-based access is handled by checking the current user's capabilities against the allowed roles set in the block. Server-side rendering ensures frontend behavior matches the editor view, with checkbox styling and behavior controlled by inspector settings. Tasks can be added, reordered, and edited directly in the editor.

Testing Instructions

  1. Add the Todo block to a page or post.

  2. In the block inspector, configure:

    • Allowed user roles.
    • Global vs local mode (global = shared across users).
    • Checkbox color and size.
  3. Add several to-do items.

  4. Toggle checkboxes as permitted:

    • Global mode: changes sync across roles with permission.
    • Local mode: checkbox state is stored per user via localStorage.
  5. Switch roles or log in as a different user to verify role-based toggling.

  6. Reload the page and confirm checkbox states persist appropriately.

Screenshots or screencast

Screenshot 2025-06-09 at 10 37 16 PM Screenshot 2025-06-09 at 10 37 29 PM

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 9, 2025

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 9, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @khristiansnyder, @ccwalburn.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: khristiansnyder, ccwalburn.

Co-authored-by: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: mtias <matveb@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: davipontesblog <dpontes@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

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

@sarthaknagoshe2002 sarthaknagoshe2002 changed the title Feat: add todo block [New Block] Todo block Jun 9, 2025
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. New Block Suggestion for a new block labels Jun 11, 2025
}
}
},
"editorStyle": "wp-block-todo-editor"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you also need a style key here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Block Suggestion for a new block [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Checkbox List Type to Gutenberg List Block

3 participants