Skip to content
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

Preformatted: Add spacing support #45196

Merged
merged 17 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ Add text that respects your spacing and tabs, and also allows styling. ([Source]

- **Name:** core/preformatted
- **Category:** text
- **Supports:** anchor, color (background, gradients, text), typography (fontSize, lineHeight)
- **Supports:** anchor, color (background, gradients, text), spacing (margin, padding), typography (fontSize, lineHeight)
- **Attributes:** content

## Pullquote
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/preformatted/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"text": true
}
},
"spacing": {
"padding": true,
"margin": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/preformatted/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.wp-block-preformatted {
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;
white-space: pre-wrap;
}

.wp-block-preformatted.has-background {
// Add low specificity default padding when a background is used.
:where(.wp-block-preformatted.has-background) {
padding: $block-bg-padding--v $block-bg-padding--h;
}