Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#50443 new defect (bug)

Heading h2 rest api level

Reported by: zavod008's profile zavod008 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4.2
Component: Editor Keywords: reporter-feedback
Focuses: Cc:

Description

Во всех заголовках кроме h2, возвращаются нормальные атрибуты уровня. Не знаю с чем это связано.

{
    "blockName": "core/heading",
    "attrs": [],
    "innerBlocks": [],
    "innerHTML": "\n<h2>222222222222222</h2>\n",
    "innerContent": [
        "\n<h2>222222222222222</h2>\n"
    ],
    "content": {
        "text": "222222222222222"
    }
},

Change History (7)

#1 @TimothyBlynJacobs
4 years ago

  • Keywords reporter-feedback added; needs-patch removed

Hello @zavod008, welcome to trac!

Could you share what REST API call you are making to receive that response?

#2 @zavod008
4 years ago

Yes, I’m doing a custom api, and for vue, I need to output the text of the article in json format, I knew that there is a parse_blocks function that turns gutenberg blocks into json format.

parse_blocks($post->post_content)

#3 @zavod008
4 years ago

Example tag h3

{
	"blockName": "core/heading",
	"attrs": {
		"level": 3
	},
	"innerBlocks": [],
	"innerHTML": "\n<h3>33333333333333</h3>\n",
	"innerContent": [
		"\n<h3>33333333333333</h3>\n"
	]
}

#4 @zavod008
4 years ago

I add the content field myself, but it affects the parser function, without this field the same result.

#5 @TimothyBlynJacobs
4 years ago

  • Component changed from REST API to Editor
  • Focuses rest-api removed

Thanks for the details @zavod008!

Could you share what content you are passing to parse_blocks in this case, and what you expected the output to be?

#6 @zavod008
4 years ago

I copied purely text from the admin panel:

<!-- wp:heading {"level":3} -->
<h3>33333333333333</h3>
<!-- /wp:heading -->

<!-- wp:heading -->
<h2>2q3123</h2>
<!-- /wp:heading -->

The text that comes in $ post-> post_content:

<!-- wp:heading -->
<h2>222222222222222</h2>
<!-- /wp:heading -->

<!-- wp:heading {
    "level": 3
} -->
<h3>33333333333333</h3>
<!-- /wp:heading -->

I do not understand what this is connected with, I created a new h2 block from scratch but the problem remains.

#7 @noisysocks
3 years ago

Hi @zavod008. What's the issue here? What do you expect parse_blocks() to return?

Note: See TracTickets for help on using tickets.