Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add anchor support for dynamic blocks #69023

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

shimotmk
Copy link
Contributor

@shimotmk shimotmk commented Feb 4, 2025

What?

Closes #51402

In previous versions, attributes were not saved in commented out format, so we changed it to save them in commented out format.

The PHP code was based on this PR #44771 .

<!-- wp:paragraph -->
<p id="paragraph-anchor">Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>
<!-- /wp:paragraph -->

<!-- wp:archives {"anchor":"archives-anchor"} /-->

You can set anchors in both static and dynamic blocks without errors.
First, we implemented only the Archives block.

Testing Instructions

  1. Open a post or page.
  2. Insert a Archives block.
  3. You can set the anchor
  4. You can see that even if there is code that was not previously saved in commented out format, such as a paragraph block, no errors will occur.

Testing Instructions for Keyboard

Screenshots or screencast

Before After
before anchor

Copy link

github-actions bot commented Feb 4, 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.

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: shimotmk <shimotomoki@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: stefanfisk <stefanfisk@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Feature] Block API API that allows to express the block paradigm. labels Feb 4, 2025
@Mamaduka
Copy link
Member

Mamaduka commented Feb 4, 2025

@shimotmk, have a look at #69002. @t-hamano suggested using a similar method for anchor support.

@shimotmk
Copy link
Contributor Author

shimotmk commented Feb 4, 2025

Oh.That's a good approach.
That might be a smarter approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore how to re-add anchor support to dynamic blocks
2 participants