admin管理员组文章数量:1122832
I am updating my post status with following snippet:
dispatch("core/editor").editPost( {
status: 'draft'
} );
My problem is, that this action creates a new undo-entry. Is it possible to avoid this (eg. "undo: false" or something similar)?
Thank you in advance
I am updating my post status with following snippet:
dispatch("core/editor").editPost( {
status: 'draft'
} );
My problem is, that this action creates a new undo-entry. Is it possible to avoid this (eg. "undo: false" or something similar)?
Thank you in advance
Share Improve this question edited Jun 18, 2024 at 21:22 Tom J Nowell♦ 60.7k7 gold badges77 silver badges147 bronze badges asked Jun 18, 2024 at 18:09 AlexAlex 31 bronze badge1 Answer
Reset to default 0Yes, editPost
is a wrapper around editEntityRecord
which according to the core/data
docs takes an options object that supports undoIgnore
:
- options
Object
: Options for the edit.- options.undoIgnore
[boolean]
: Whether to ignore the edit in undo history or not.
While you could use this, generally the need to use it implies a mistake or misunderstanding somewhere, or that the draft status is being set too late and should be set earlier.
A Warning: Editing vs Saving
Using editPost
and editEntityRecord
to set your post status to draft might not edit the database, it just changes the block editors internal state. It still needs to be saved/published to take effect.
This is why we have a saveEntityRecord
function too, and it's how the editor knows what posts/templates to list in the checkbox list when you click publish ( e.g. it'll prompt if you want to update nav menus and synced templates etc )
For this reason, you might want to keep the undo/redo record.
本文标签: postseditPost without undo entry
版权声明:本文标题:posts - editPost without undo entry 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303328a1931845.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论