shr*_*mee 9 wordpress wordpress-gutenberg
回到TMCE时代,我们可以很容易地获得编辑器内容editor.getContent().然而在新的Gutenberg编辑器中,我找不到一种方法来做到这一点.
我需要所有编辑器内容作为HTML(它将保存在数据库中的方式).
我发现wp.block.serialize()听起来很有前途的方法.但似乎需要块(作为参数).所以我有点卡住了.
从3.1版开始.古腾堡,试试这个:
获取普通块内容:
var originalContent = wp.data.select( "core/editor" ).getCurrentPost().content;
var editedContent = wp.data.select( "core/editor" ).getEditedPostContent();
Run Code Online (Sandbox Code Playgroud)
渲染帖子(转换为块):
wp.blocks.parse( editedContent );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1945 次 |
| 最近记录: |