michelson / dante2

A complete rewrite of dante editor in draft-js
https://michelson.github.io/dante2/
Other
912 stars 121 forks source link

preserve paragraph as block #204

Closed mbm-michal closed 4 years ago

mbm-michal commented 4 years ago

When copy pasting from word it was connecting multiple paragraphs into 1 block. I've noticed that solution was already applied: https://stackoverflow.com/questions/39047832/draft-js-how-to-preserve-paragraph-breaks-when-pasting-content?rq=1

image image

michelson commented 4 years ago

Hi @mbm-michal , why you close this PR? it seems an interesting solution , did it work for you ?

there is also another solution mentioned in the link you've provided that's mentions the customRenderMap

import { Map } from 'immutable';
import Editor from 'draft-js';

const customRenderMap = Map({
  unstyled: {
    element: 'div',
    // will be used in convertFromHTMLtoContentBlocks
    aliasedElements: ['p'],
  },
});

<Editor
  editorState={this.state.editorState}
  blockRenderMap={customRenderMap}
/>

so , maybe the solution could be extend the unstyled in https://github.com/michelson/dante2/blob/master/src/editor/components/core/editor.js#L47