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

Restore floated image margins. #21500

Merged
merged 1 commit into from
Apr 22, 2020
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
13 changes: 13 additions & 0 deletions packages/block-library/src/image/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
margin-top: -9px;
margin-left: -9px;
}

// These need specificity to override an inherited left/right block margin in the editor.
&.wp-block-image.alignleft {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be generally applied to any block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, probably. There's a generic float rule, as mentioned, that looks like this:

.block-editor-block-list__layout .block-editor-block-list__block[data-align="left"] > .is-block-content {
    float: left;
    margin-right: 2em;
}

But of course that only applies to blocks that have the "is-block-content" container. I can't recall the heuristic for when such a container.

margin-right: 1em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}

&.wp-block-image.alignright {
margin-left: 1em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
}

// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@
float: left;
/*rtl:ignore*/
margin-right: 1em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}

.alignright {
/*rtl:ignore*/
float: right;
/*rtl:ignore*/
margin-left: 1em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}

.aligncenter {
Expand Down