Skip to content

Commit

Permalink
Add rendering mode parameter to the setRenderingMode utility
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerB24890 committed Jul 18, 2024
1 parent a2ac4b3 commit 3496d55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export async function createNewPost(
// Navigate to the new post page.
await this.visitAdminPage( 'post-new.php', query.toString() );

// Set editing mode
await this.editor.setRenderingMode();
await this.editor.setRenderingMode( 'post-only' );

await this.editor.setPreferences( 'core/edit-post', {
welcomeGuide: options.showWelcomeGuide ?? false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import type { Editor } from './index';
* Set the rendering mode of the editor.
*
* @param this
* @param mode The rendering mode to set.
*/
async function setRenderingMode( this: Editor ) {
async function setRenderingMode( this: Editor, mode: string = 'post-only' ) {
await this.page.waitForFunction( () => window?.wp?.data );

await this.page.evaluate( () => {
await this.page.evaluate( ( renderingMode ) => {
// Set editing mode
window.wp.data
.dispatch( 'core/editor' )
.setRenderingMode( 'post-only' );
} );
.setRenderingMode( renderingMode );
}, mode );
}

export { setRenderingMode };

0 comments on commit 3496d55

Please sign in to comment.