GithubHelp home page GithubHelp logo

Comments (2)

lokiuz avatar lokiuz commented on July 17, 2024

I'm not sure what inconsistencies are you getting? Seems like you first thing you want to check is that you're not using the cleanup option - that's what causes the behavior in the example.

I tweaked it a little so that an empty line returns just a <br/> not wrapped in a <div>.

unstyled: (children, { keys }) =>
    children.map((child, index) => {
      const last = child[child.length - 1];
      if (last.length === 0) {
        return <br key={keys[index]} />;
      }
      return <div key={keys[index]}>{child}</div>;
    }),

Another solution would be doing something similar to the example:

const addBreaklines = children => children.map(child => [child, <br />]);

blocks = {
  unstyled: (children, { keys }) => <div key={keys[0]}>{addBreaklines(children)}</div>,
}

This creates a single <div> around all the unstyled blocks and also adds a <br /> after each block.

from redraft.

cusxio avatar cusxio commented on July 17, 2024

ah I see the issue now. I've been adding the line break to the children's children, instead of the children.

No wonder it created some issues with the styles clashing with other entities.

from redraft.

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.