Skip to content

Commit c8da5eb

Browse files
committed
refactor: Scope editor content styles to block canvas
Load these styles in the editor block canvas `iframe` to minimize potential style collisions in the top-level editor. These styles are only intended for content within the editor, not the editor UI itself.
1 parent e48d84d commit c8da5eb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/components/visual-editor/index.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { store as editorStore, PostTitle } from '@wordpress/editor';
1616
import { useSelect } from '@wordpress/data';
1717
import { store as editPostStore } from '@wordpress/edit-post';
1818
import '@wordpress/format-library';
19+
// Base styles for the content within the block canvas iframe.
20+
import blockEditorContentStyles from '@wordpress/block-editor/build-style/content.css?inline';
21+
import blocksStyles from '@wordpress/block-library/build-style/style.css?inline';
22+
import blocksEditorStyles from '@wordpress/block-library/build-style/editor.css?inline';
23+
import blocksThemeStyles from '@wordpress/block-library/build-style/theme.css?inline';
1924

2025
/**
2126
* Internal dependencies
@@ -89,7 +94,11 @@ function VisualEditor( { hideTitle } ) {
8994
// context.
9095
commonStyles,
9196
// Add sensible default styles if theme styles are not present.
92-
hasThemeStyles ? '' : defaultThemeStyles
97+
hasThemeStyles ? '' : defaultThemeStyles,
98+
blockEditorContentStyles,
99+
blocksStyles,
100+
blocksEditorStyles,
101+
blocksThemeStyles
93102
);
94103

95104
const editorClasses = clsx( 'gutenberg-kit-visual-editor', {

src/utils/editor-styles.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,5 @@
44
// Default styles that are needed for the editor.
55
import '@wordpress/components/build-style/style.css';
66
import '@wordpress/block-editor/build-style/style.css';
7-
// Default styles that are needed for the core blocks.
8-
import '@wordpress/block-library/build-style/style.css';
9-
import '@wordpress/block-library/build-style/editor.css';
10-
import '@wordpress/block-library/build-style/theme.css';
117
import '@wordpress/format-library/build-style/style.css';
12-
import '@wordpress/block-editor/build-style/content.css';
138
import '@wordpress/editor/build-style/style.css';

0 commit comments

Comments
 (0)