Giter VIP home page Giter VIP logo

Comments (7)

circAssimilate avatar circAssimilate commented on August 17, 2024 22

@praneshr, @EricCatlin, the simplest workaround I just found was to add the following style override to ensure a wrap happens (probably should be default):

line: {
    wordBreak: 'break-word',
},

image

Then, something like this helps with preventing wrap but allowing horizontal scroll:

diffRemoved: {
    overflowX: 'auto',
    maxWidth: 300,
},
diffAdded: {
    overflowX: 'auto',
    maxWidth: 300,
},

Screen Shot 2020-01-02 at 10 20 17 PM

For that, it would be best if the maxWidth could be computed within to be half the width of the table container minus gutters and whatnot.

The above works for now but I could imagine these could be powered by an shouldWrapText option that defaults to true.

from react-diff-viewer.

fev4 avatar fev4 commented on August 17, 2024 1

The solution above ends up for me like this:
image

Shows multiple horizontal scrolling bars. Optimally there should only be one.


To avoid this, here's what I'm using:

styles={{
  diffContainer: {
    overflowX: "auto",
    display: "block",
    "& pre": { whiteSpace: "pre" },
  },
}}

Then just set the max-width on the container or the table it self and it should result in something like this:
image

from react-diff-viewer.

praneshr avatar praneshr commented on August 17, 2024

Hi @circAssimilate, can you provide me an example with screenshot?

Currently, all the text inside <pre> has a style white-space: pre-wrap. You can override by adding it under diffContainer style.

from react-diff-viewer.

circAssimilate avatar circAssimilate commented on August 17, 2024

Thanks, @praneshr. The white-space: pre-wrap suggestion is a good tip, but upon switching it to no-wrap I'd additionally like to control the max-width of each column and allow for before / after diff horizontal scrolling as an option after 50% of the parent container. So here's how it looks without wrap:

image

And I envision an opportunity to allow overflow-x: auto on the content column when it's longer than 50% of the parent container.

from react-diff-viewer.

circAssimilate avatar circAssimilate commented on August 17, 2024

I think I narrowed in on the core issue here. When a long string has no spaces, automatic breaking doesn't happen as expected and the container gets really big (while still wrapping). It would still be nice to allow for a non wrap option or style with a set width, but also figuring out how to ensure breaking happens at 50% for long strings like this:

Before

"[\"and\",[\"or\",[\"or\",{\"name\":\"user_id\",\"value\":123,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":456,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":789,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":321,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":654,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":987,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":111,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":333,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":777,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":999,\"match_type\":\"exact\",\"type\":\"custom_attribute\"}]]]"

After

"[\"and\",[\"or\",[\"or\",{\"name\":\"user_id\",\"value\":123,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":456,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":789,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":321,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":654,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":987,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":111,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":333,\"match_type\":\"exact\",\"type\":\"custom_attribute\"},{\"name\":\"user_id\",\"value\":777,\"match_type\":\"exact\",\"type\":\"custom_attribute\"}]]]"

from react-diff-viewer.

EricCatlin avatar EricCatlin commented on August 17, 2024

Hi, i am having this exact issue when my payload contains a JWT.
JWTs are fairly lengthy and have no good break point.

from react-diff-viewer.

YeeJone avatar YeeJone commented on August 17, 2024

image

I have the same problem. The style is ...

from react-diff-viewer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.