最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

hooks - Is it possible to switch Gutenberg's editor styles when document settings change?

programmeradmin3浏览0评论

I want to show different editor styles based on one of the post's value in the core/editor store. Let's say, for example, that I've got a setting like, picture_frame in my post meta, that adds gimicky "picture frame" border around all of the content in the post. (Ignore whether this is a good or bad idea, it's just an example). On the front end, I use the_content filter to add the classes I need for CSS. But in Gutenberg, I'm not sure what filter to use. If I dispatch an action to change that value in the editor, like this;

dispatch('core/editor').editPost({
  meta: { _picture_frame: true },
});

I want the styles in the editor to change accordingly. Either by adding a .has-picture-frame class to a parent element, or enqueueing a picture-frame-styles.css stylesheet. But I can't figure out the correct filter for either modifying the editor's classes, or changing which stylesheets are enqueued.

发布评论

评论列表(0)

  1. 暂无评论