-
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
Paragraph block: becomes invalid when setting text alignment to justified #8450
Comments
Just throwing this out there: if it's not important enough to surface via the UI, is it something we want to keep? A more richly-featured paragraph block with a justify alignment is possible, but maybe if there's no way to affect a change in the UI we shouldn't allow it in a basic block like this? 🤷♂️ cc'ing @karmatosed @mtias–I'm curious what our rule around allowing options that the UI doesn't expose is? Do we generally say "okay" or do we want to explicitly remove stuff that we don't support in our UI? The latter is my preference as it's simpler but is obviously a bit needlessly hostile toward legacy/custom/expertly-made content. |
Whilst I feel we shouldn't surface things we don't have in UI the issue is we do have the ability to add HTML. As a result I think we have to at least not have this break as it is valid HTML. |
Seems we will need a (new) way to set/update block props: by parsing the (user edited) HTML. That seems quite doable for simple blocks and HTML attributes but can quickly get "out of hand" for complex blocks (and introduce edge cases). On the other hand editing the HTML is probably the most "unfriendly" way of doing this. Wondering what's the right balance here:
To me personally number three seems the best balance. |
Related #6878 (comment) #10204 |
Just noting the Underline shortcut - |
It'd be good to test to see if a plugin can add a "justify" button using rich text. |
No "justify" option is a serious Backwards Compatibility issue! 1.) Make "justify" work for existing posts/pages which are converted to Gutenberg blocks. |
This has nothing to do with the |
Noting here that I don't think the problem is the update cycle on user-edited HTML. The problem in this case is that the block isn't defining the alignment attribute as being sourced from the inline CSS. I ran an experiment and added the justify attribute to the JSON attributes in the block comment delimiter. It worked. This is not to say that we don't have a problem, but more to direct the problem statement to the cause of the problem. I think that had we chosen a custom JSON-format stored in the database we would have a different way of wording this, but as we are using HTML as our source of truth we have the appearance that we should be able to change the HTML without breaking blocks. That is, we are experiencing the tension between having freeform HTML and structured semantic types of content stored in blocks as HTML. On one hand we might say that adding a custom inline CSS rule shouldn't invalidate a block, but on the other hand we're also at a loss for how to handle that in the general sense when a block doesn't understand the content passed into it, and there's no way we can provide any guarantee that those custom changes will persist after editing the block again. |
I know that "justify" formatting option was removed from WordPress intentionally, but although for some developers this seems to be a holy crusade, apparently many users are not willing to do without it. |
Thanks for replying @burnuser, I'm sorry if I was unclear. What I meant to communicate was that this issue as written should probably be closed and recreated as a new feature request: "Please support justified text in the paragraph block." Or… it should probably be closed and recreated as a new feature request: "Preserve unsupported but non-breaking changes to block code" or something like that. |
We run a local newspaper website, and have always used full justification. I've been getting worried about not being able to get it sorted, and the idea of going into every news story to add css is a nightmare. However, the simple solution, if you are going to use full justification on all posts is to add the following css to your theme:
Obvious to most, I'm sure, but it's an option not mentioned anywhere that I've looked. I suppose you could just add that to the advanced section on single posts, but not something I've tested. |
Another solution, is to use the 'Classic Block', which I've tested and shows the full justify button which is added with the free WP Edit plugin. |
You can target a single block with CSS to set the justify, I posted info here: #6833 (comment) |
I've just looked for this... I can't see it. |
Added Justify alignment format on EditorsKit plugin ( https://wordpress.org/plugins/block-options/ ) together with highlighted text color and underline controls. Here's how the "Justify" works: Hoping this will solve everybody's problem :) Thanks! |
So no intention to have Justify by default? seriously?? |
My current approach for theme (SASS): body {
p {
&:not(.has-text-align-center):not(.has-text-align-right) {
text-align: justify;
}
}
} |
The paragraph block fails validation with possibly any style attribute on the Each of these contained "unexpected or invalid" content:
(Adding the color to a span tag within the paragraph does work, though.) |
Opened a PR to add a 'Justify' option to alignment controls: #48146 Would love a review from anyone who wants to test it 😊 |
I lied. 'Justify' is going in Global Styles first #48202 |
I tested this issue with the latest version of Gutenberg, and when I change the text alignment in the block toolbar, the attributes and class names are changed instead of the inline styles. <!-- wp:paragraph {"align":"justify"} -->
<p class="has-text-align-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<!-- /wp:paragraph --> And if you change this attribute and class name to "justify" in the code editor, the block will NOT break. I think this problem can be solved by providing a UI for justifying and defining a CSS style called One concern is that if we add the justify option to the
In the classic editor (and the Classic block), the justify button is not visible, but the shortcut is available. Does anyone know why the UI is intentionally not visible? |
I submitted #59531, which aims to add new "textAlign" block support to also allow for the provision of a "justify" option UI for the Paragraph block in the future. |
The issue
You can not set the
text-align
CSS property of a Paragraph block tojustify
. If you add it manually via Edit as HTML, the block will become invalid. Justified text alignment should be allowed, even if it is not exposed through the UI.How to reproduce
<p>
tag:style="text-align:justify"
.Related issues and PRs
The text was updated successfully, but these errors were encountered: