Dav*_*nes 2 wordpress wordpress-gutenberg
Gutenberg 编辑器带有一个嵌入式样式表。这是该样式表的一个片段:
...
.editor-styles-wrapper {
font-family: "Noto Serif", serif;
font-size: 16px;
line-height: 1.8;
color: #191e23;
}
.editor-styles-wrapper p {
font-size: 16px;
line-height: 1.8;
}
...
Run Code Online (Sandbox Code Playgroud)
我使用以下内容将我自己的编辑器样式表排入队列:
add_action("enqueue_block_editor_assets", "enqueue_custom_block_editor_assets");
function enqueue_custom_block_editor_assets() {
wp_enqueue_style("editor-style", get_stylesheet_directory_uri()."/editor-style.css", null, null);
}
Run Code Online (Sandbox Code Playgroud)
因为我有自己的编辑器 stylehseet,所以我想去掉默认的。对这个主题的搜索产生了很多删除前端默认块样式的结果,但我指的是后端的编辑器样式。谢谢你的帮助!
我深入研究了它是如何注入的,并找到了一种通过block_editor_settings过滤器将其清除的方法。有一个styles包含 css 数组的键。对我来说唯一不确定的事情是我假设数组的形状总是相同的,我应该在这里进行某种类型的检查。
add_filter( 'block_editor_settings' , 'remove_guten_wrapper_styles' );
public function remove_guten_wrapper_styles( $settings ) {
unset($settings['styles'][0]);
return $settings;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1618 次 |
| 最近记录: |