You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request refactors server-side editor initialization to pass initial edits as a setting directly to the editor initialization, rather than by proxy through a window._wpGutenbergDefaultPost global. In doing so, it resolves a yet-undiscovered issue where our filtering of the_title was effectively disregarded, since we never used the rendered property of the title populating the editor. This will be further separately improved by efforts in #9403.
Related to these future efforts, I think we should consider demo content as an external influencer, exposing filters necessary to provide these initial edits, in a similar fashion to what exists already with the block_editor_settings filter. Here's a patch which, when applied to this branch, would achieve this. However, I am choosing to defer this to after #9403, as it is not my desire for the raw / rendered distinction of content attributes persist, and thus be exposed into a public interface for extending initial edits.
Testing instructions:
Verify there are no regressions in the behavior of initial edits, notably:
Demo post title and content
Editing an existing post
New post with and without the_title filter
Here's a small plugin for testing the_title:
<?php/** * Plugin Name: Filter The Title */add_filter( 'the_title', function() {
return'My default title';
} );
(Note: the_title is not an editor-specific filter, so it will have additional side-effects to leave the above plugin activated after testing)
For transparency's sake, I should note that there's technically a breaking change here in that we no longer expose the _wpGutenbergDefaultPost global which would have been previously available and perhaps an option for other plugin's to manipulate values of the post before initialization. While this was never officially supported and the name of the global itself (with underscore prefixing and Gutenberg codename) could serve as a hint to its being an internal-global, we've had some precedent elsewhere of encouraging use of these globals (more specifically, the _wpLoadGutenbergEditor promise). At the very least, we should stop encouraging their use, as even for this latter global we'll want to at least remove reference to "Gutenberg" in its name.
As mentioned in the original comment, there is certainly intention to make overriding initial values part of the public interface, likely through a new block_editor_initial_edits PHP filter, but this will first require additional changes as explored in #9403.
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
FrameworkIssues related to broader framework topics, especially as it relates to javascript
2 participants
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 #9403
This pull request refactors server-side editor initialization to pass initial edits as a setting directly to the editor initialization, rather than by proxy through a
window._wpGutenbergDefaultPostglobal. In doing so, it resolves a yet-undiscovered issue where our filtering ofthe_titlewas effectively disregarded, since we never used therenderedproperty of the title populating the editor. This will be further separately improved by efforts in #9403.Related to these future efforts, I think we should consider demo content as an external influencer, exposing filters necessary to provide these initial edits, in a similar fashion to what exists already with the
block_editor_settingsfilter. Here's a patch which, when applied to this branch, would achieve this. However, I am choosing to defer this to after #9403, as it is not my desire for theraw/rendereddistinction of content attributes persist, and thus be exposed into a public interface for extending initial edits.Testing instructions:
Verify there are no regressions in the behavior of initial edits, notably:
the_titlefilterHere's a small plugin for testing
the_title:(Note:
the_titleis not an editor-specific filter, so it will have additional side-effects to leave the above plugin activated after testing)