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

[Change] Change the way code blocks interact and overlap with floating images #138

Open
arturolinares opened this issue Nov 9, 2021 · 1 comment
Labels
change request A request to change the way something works

Comments

@arturolinares
Copy link

Describe the bug
When using an image next to a code block, the background overlaps the image margins and area.

To Reproduce
Steps to reproduce the behavior:

  1. Type several paragraphs of text.
  2. Add an image and align it to the left.
  3. In the same line, add a code block.
  4. The code background overlaps the image.

Expected behavior
The code block background aligns with the image margins, along with the text.

Screenshots
image

System Information (please complete the following information):

  • Device: Laptop
  • OS: Linux (Fedora 35)
  • Browser: Vivaldi (Chrome)
  • Browser Version: Any

Additional context
NA

@arturolinares arturolinares changed the title Code blocks don't repect image margins Code blocks don't overlaps with image margins Nov 9, 2021
@arturolinares arturolinares changed the title Code blocks don't overlaps with image margins [Bug] Code blocks overlaps with image margins Nov 13, 2021
@johnozbay johnozbay added the change request A request to change the way something works label Nov 15, 2021
@johnozbay
Copy link
Member

Hi there!

Thanks for filing this in!

What you're seeing here is actually the expected interaction between floated elements and block elements in the web.
Code-blocks are as the name suggests, display:block elements. Consequently, when you have a floating image, the text itself gets indented / pushed-in while the width of the block element remains 100%.

Tried to reproduce your example as accurately as possible with some screenshot-magic.
Here's a screenshot of the inspector with this code-block element highlighted :

image

As you can see it's 100% width.

What you're looking for could be done in 3 ways.

  1. If code-blocks are actually inline-blocks but then, here's how they would look like :

image

  1. by using overflow : auto on the code-blocks, however if the code-block has a long string of text, like a URL etc this could cause overflow issues :

image

  1. OR by using a rather new and experimental CSS display style called flow-root :
    https://caniuse.com/flow-root

image

However, while flow-root is supported by most browsers, it's still only a very new and working-draft addition to CSS. The tricky part here is, since all documents in Cryptee are encrypted, they have to work in a backwards compatible way. And essentially with any tiny change we make to the elements in the editor can break old documents forever. i.e. once you use them, and the document is encrypted, it will forever stay frozen-in-time that way. So we can only switch to flow-root once we know for sure it's here to stay, or a document you created today using flow-root and encrypted would be broken in the future if flow-root is no longer used.


I'm going to check to see if we can use overflow:auto and still handle things like long links / strings of text etc in a meaningful way with some margin / padding etc hacks in a cross-browser compatible way. If it works as expected, we'll release a quick fix to get this fixed right away!

Hoping these make sense and help! ✌🏻

– I'm going to leave this open while we investigate a hacky fix, but for the moment, I'm marking this as a 'change request' and not a 'bug' per-se, since this is unfortunately an expected-behavior.

@johnozbay johnozbay changed the title [Bug] Code blocks overlaps with image margins [Change] Change the way code blocks interact and overlap with floating images Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request A request to change the way something works
Projects
None yet
Development

No branches or pull requests

2 participants