Plugin: Extract block editor styles replacement as filter#13625
Merged
noisysocks merged 3 commits intomasterfrom Feb 18, 2019
Merged
Plugin: Extract block editor styles replacement as filter#13625noisysocks merged 3 commits intomasterfrom
noisysocks merged 3 commits intomasterfrom
Conversation
13 tasks
youknowriad
approved these changes
Feb 11, 2019
lib/client-assets.php
Outdated
| * own custom styles, it's assumed that the first entry of the styles | ||
| * setting should be the default (core) stylesheet. | ||
| */ | ||
| array_shift( $settings['styles'] ); |
Contributor
There was a problem hiding this comment.
I wonder if it's simpler to just loop over the styles are replace the core editor styles if found (checking the path or something).
Member
Author
There was a problem hiding this comment.
replace the core editor styles if found (checking the path or something).
The problem is that the array contains only the CSS string, no file paths.
It looks something like:
$settings = array(
'styles' => array(
array( 'css' => 'body { /* ... */ }' )
)
);So we've got nothing to work from to know whether it's the core style, unless we explicitly (re-)read the ABSPATH . WPINC . '/css/dist/editor/editor-styles.css' file from disk and compare it with the array style contents.
Member
Author
|
Default styles matching made more reliable in d4be401 by exact file contents match. Fun testing instructions: |
youknowriad
approved these changes
Feb 15, 2019
This was referenced Feb 18, 2019
youknowriad
pushed a commit
that referenced
this pull request
Mar 6, 2019
* Plugin: Extract block editor styles replacement as filter * Plugin: Override default styles by exact file contents match * Plugin: Fix editor styles prepend behavior
youknowriad
pushed a commit
that referenced
this pull request
Mar 6, 2019
* Plugin: Extract block editor styles replacement as filter * Plugin: Override default styles by exact file contents match * Plugin: Fix editor styles prepend behavior
This was referenced Apr 30, 2020
This was referenced May 1, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from: #13569
Related: #9008
This pull request seeks to implement Gutenberg's replacement
editor-stylessetting value as a filter onblock_settings. This was allow for compatibility with the core implementation once Gutenberg stops reimplementing its own replacement editor (#13569).Implementation notes:
The change to assign
$styleswithABSPATH . WPINC . '/css/dist/editor/editor-styles.css'is merely meant to provide direct alignment to the core implementation. It's never actually used, since the filtering behavior will substitute the styles with its own implementation. But it needs to exist because the filtering assumes that the styles would be the first entry of the default$settings['styles']array. Unfortunately, we must operate on assumptions since the entries of styles are the contents of the stylesheets themselves, not named or assigned as paths. An alternative implementation could consider reading from theABSPATH . WPINCto find and substitute the value by the actual file contents assigned, but there'd be a small amount of overhead in reading from the filesystem.Testing instructions:
Verify that the contents of the built copy of
packages/editor/src/editor-stylesare present on the page. This may require inspecting the source of the page. It's easier to verify that it's in-fact the Gutenberg copy by making a change to the source file and rebuilding it.Additionally, verify that the separate locale font family assignment (
font-family: 'Noto Serif') is not impacted by these changes, meaning that it is still present and occurs after theeditor-styles.css.