-
Notifications
You must be signed in to change notification settings - Fork 2.6k
code-block
in nested inside of two pre
now by default
#406
Comments
@ianstormtaylor, that looks like a bug, i think in order to fix it we need to: A a solution for it would be to make the 'element' property from the blockRenderMap only responsible for dealing with reverse enginering pasted and converted from html blocks into their respective blockTypes and add a another option that would then define the render. This option could then be nullable which would be similar to the problem on issue: #372 |
This is happening because we have code-block using a
'code-block': {
68 element: 'pre',
69 wrapper: PRE_WRAP,
70 nestingEnabled: false
71 }, We could just add another option maybe something like what do you guys think about this ? |
For what it's worth, I think But even then, I think it would also be better as a function that could perform slightly more complex logic, for example The current system for dealing with block rendering feels really convoluted. I personally like the idea of streamlining more, like you're talking about. Is there a reason why |
@ianstormtaylor: As I recall, We were using functions before, to define the wrapper and rendered elements (i.e. https://github.com/facebook/draft-js/blob/5c957ad75d299fd77b098bed3965f753defc4d9a/src/component/utils/getElementForBlockType.js). This was separate from how block types were extracted from pasted content. To clarify, is the suggestion to move back in this direction but make this behavior customizable? (It was previously baked into |
I don't have a concrete suggestion either way, since I'm not familiar enough with the internal code, but general feeling is that dealing with "custom blocks" is a convoluted right now, since it seems like there are so many overlapping places that pieces need to be defined for them:
Note: requirements 4 and 5 are technically "outside of Draft's realm", but I feel like they should be treated much more like core responsibilities (not necessarily supported by the codebase, but supported by the architecture) since it seems prudent to not couple your data storage with Draft's opinionated way of structuring the data for interoperability and other reasons. It feels like each of these things is being considered in isolation. And the system could really be boiled down to a simpler model where you have a few things:
I think those are the only two requirements, maybe there are more. (It seems like?) they could be defined in a single place, as a single piece of data—canonically—so that it doesn't feel like we have to bandaid together things from all different parts of the API. I might be misunderstanding how they are supposed to work together though. I had to migrate back to |
I'd personally love to go more towards the direction of having all of the built-in block types be composed from the same types of custom block definitions, since I think doing that would make that code/architecture path handled more as a first-class use case. |
Since we are talking about restructuring blocks, I'd like the ability to create a custom type. Meaning it has a new string when you call getBlockType() and I can control the generated DOM and styling. I think this is possible today by using an atomic block type with a custom renderer, but that doesn't feel right if the new block type is still editable like any traditional block. |
@ianstormtaylor I raised this issue #486 in order to track down a potential solution and improvement of the current behaviour. Would be great to have your suggestions on how to deal / tackle that problem in there as well |
I think this might be related to the @mitermayer? It looks like all code blocks are nested inside of two wrapping
<pre>
elements, instead of just one like before. (Tested on the Draft.js example on the website.)The text was updated successfully, but these errors were encountered: