-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple editor widths #12874
Comments
To answer your question with some context, you are asking to change editor width based on To answer your question with a potential solution, you can currently work around this problem by enqueueing your custom editor width styles a bit differently. Here is an example: Change
Add a
Tested with WordPress 5.0.3-RC1-44445 and the Twenty Nineteen 1.2 theme. Caveat! Because I used the Twenty Nineteen 1.2 theme in my test and because that theme already had more specific editor width styling, I had to remove those styles in order to allow mine to work. Of course, if you were developing your own theme, you would likely not have encoded conflicting editor styles into your theme without knowing but it is something to watch out for when making edits to another theme you may not be as familiar with. Here are the styles I removed from Twenty Nineteen for my test:
I acknowledge my code may not be perfect! I typically work in testing and triage and love themes but am not a full-time developer. If anyone sees area for improvement, I'd love feedback. 😊 Regarding documenting exact steps or a copy/paste solution, I wouldn't want to do that just yet because how to solve the specificity issues are still under discussion in places like #10067 (comment) (also see #9008 (comment)) and also because I would consider my solution above to be a temporary workaround and would want whatever comes out of the currently open issues to supersede the sample code I've posted here. Regarding the bulleted list of issues you referenced, sometimes the trouble with looking at past solutions in a repository is that the code has since changed. For example, the solution proposed in #8420 no longer applies after the changes in #9008. A better approach is to include a clear set of steps to reproduce the problem and include code examples whenever possible exactly like you did in #12904. That issue is ace! @manake if this explanation and example are sufficient for you for now, would you be okay if I closed this issue in favor of consolidating to other already-open issues such as #10067 where they are discussing this in conjunction with some other specificity problems? |
@samikeijonen I got the idea to use |
@designsimply Sorry I missed your comment. I don't see issues on your example but as always, it might depend on theme you're working on. |
@samikeijonen thanks for taking a look! |
@manake were you able to try out the solution I proposed? |
I needed custom editor width depending on page template (so not post-type). /*
Append gutenberg editor custom styles
*/
function add_theme_scripts() {
wp_enqueue_style( 'editor-styles', get_template_directory_uri() . '/dist/styles/editor-styles.css', array(), wp_get_theme()->get( 'Version' ), 'all');
}
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ .'\\add_theme_scripts' );
function custom_admin_body_class( $classes ) {
global $post;
$cls = '';
if ($post) {
$cls = str_replace(".php","",get_page_template_slug());
}
return "$classes $cls";
}
add_filter( 'admin_body_class', __NAMESPACE__ .'\\custom_admin_body_class' );`
**editor-styles.css**
`.wp-block {
max-width: 692px;
}
body.template-overview .wp-block {
max-width: 1200px;
} I think this is a flexible solution (you could easily add post-types or other contextual classes to determine your editor width or other properties). But my itnuition says this should be done in a more clean way, fi: add_theme_support( 'wp-block-styles' );
add_editor_style( Assets\asset_path('styles/editor-styles.css') ); This css doen't seem to apply when using the body class selector, probably because gutenberg loads this in another context, so maybe the 'page-template' class needs to be applied with another hook to another wrapper on the block editor (like the editor-styles-wrapper), but currently I lack the knowledge how to do this. |
It seems that this has already some good replies. Let us know if the proposed solutions don't work for you. |
This is already asked by like 10 people but there is no solution.
Sorry for asking this again but no working solution was ever provided anywhere and all questions are being ignored so far or contain wrong answers.
body.gutenberg-editor-page.post-type-post
code snippet.)textarea
of the title gets inlineheight
and would not be refreshed)page
andpost
separately.)This is frequently suggested but this just doesn't work:
body.gutenberg-editor-page.post-type-post .edit-post-visual-editor .editor-post-title__block, body.gutenberg-editor-page.post-type-post .edit-post-visual-editor .editor-block-list__block { max-width: 500px; }
Can someone please provide the official copy/paste solution (exact steps that we have to take to define
width: 500px
forpost
andwidth: 1000px
forpage
)? What would I have to paste into my style-editor.css or functions.php?The text was updated successfully, but these errors were encountered: