{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/draft-js/issues/452","repository_url":"https://api.github.com/repos/facebook/draft-js","labels_url":"https://api.github.com/repos/facebook/draft-js/issues/452/labels{/name}","comments_url":"https://api.github.com/repos/facebook/draft-js/issues/452/comments","events_url":"https://api.github.com/repos/facebook/draft-js/issues/452/events","html_url":"https://github.com/facebook/draft-js/issues/452","id":159264768,"number":452,"title":"draft doesn't allow for two code blocks next to each other","user":{"login":"ianstormtaylor","id":311752,"avatar_url":"https://avatars.githubusercontent.com/u/311752?v=3","gravatar_id":"","url":"https://api.github.com/users/ianstormtaylor","html_url":"https://github.com/ianstormtaylor","followers_url":"https://api.github.com/users/ianstormtaylor/followers","following_url":"https://api.github.com/users/ianstormtaylor/following{/other_user}","gists_url":"https://api.github.com/users/ianstormtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/ianstormtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianstormtaylor/subscriptions","organizations_url":"https://api.github.com/users/ianstormtaylor/orgs","repos_url":"https://api.github.com/users/ianstormtaylor/repos","events_url":"https://api.github.com/users/ianstormtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/ianstormtaylor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-06-08T20:36:17Z","updated_at":"2016-06-10T18:34:23Z","closed_at":null,"body":"Right now, it seems like code blocks are handled by creating a new \"block\" for each line of code, instead of keeping all of the code text inside a single block. Which means that it is impossible to have two code adjacent code blocks, since they will be rendered as one.\r\n\r\nFor example, imagine wanting to have a block of `javascript` followed immediately by a block of `css`, with no extra paragraphs or lines in between:\r\n\r\n![](http://g.recordit.co/YA8r25o9EK.gif)\r\n\r\nThe demo gets around this because it uses \"unstyled\" lines, so the workaround is to just chuck an extra unstyled line between them. But as soon as you try to do the same with paragraphs, you end up with an entire paragraph between them, instead of two blocks of code.\r\n\r\nIn other words, this output is impossible:\r\n\r\n```html\r\n<p>...</p>\r\n<p>...</p>\r\n<pre><code>...</code></pre>\r\n<pre><code>...</code></pre>\r\n<p>...</p>\r\n```\r\n\r\nBecause you'd instead have to do this:\r\n\r\n```html\r\n<p>...</p>\r\n<p>...</p>\r\n<pre><code>...</code></pre>\r\n<p></p>\r\n<pre><code>...</code></pre>\r\n<p>...</p>\r\n```\r\n\r\nThis weirdness comes up in other places, where if you're trying to serialize code blocks, you need to make sure that you continue as long as the `i+1` block is also a code block. And it also comes up when trying to attach \"syntax\" data to a block, since you actually need to loop and attach it to all blocks that are next to each other.\r\n\r\nRendering wise, to get around it feeling like each line is a block, a separate wrapper `<pre>` tag is rendered with a `.public-DraftStyleDefault-pre` class. But this is kind of just patching over the problem.\r\n\r\nIt seems like code blocks should be handled as first-class, where lines are separated by `\\n` instead of by creating separate blocks. Otherwise, the leaky abstraction ends up being a problem in lots of different places throughout the codebase.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/draft-js/issues/comments/225261372","html_url":"https://github.com/facebook/draft-js/issues/452#issuecomment-225261372","issue_url":"https://api.github.com/repos/facebook/draft-js/issues/452","id":225261372,"user":{"login":"ianstormtaylor","id":311752,"avatar_url":"https://avatars.githubusercontent.com/u/311752?v=3","gravatar_id":"","url":"https://api.github.com/users/ianstormtaylor","html_url":"https://github.com/ianstormtaylor","followers_url":"https://api.github.com/users/ianstormtaylor/followers","following_url":"https://api.github.com/users/ianstormtaylor/following{/other_user}","gists_url":"https://api.github.com/users/ianstormtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/ianstormtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianstormtaylor/subscriptions","organizations_url":"https://api.github.com/users/ianstormtaylor/orgs","repos_url":"https://api.github.com/users/ianstormtaylor/repos","events_url":"https://api.github.com/users/ianstormtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/ianstormtaylor/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T18:34:23Z","updated_at":"2016-06-10T18:34:23Z","body":"@oyeanuj I don't think so, but could be missing something there. I think even with the breakout, the limitation on adjacent `code-block` blocks is hardcoded in Draft core.\r\n\r\nAlthough, unrelated, that plugin is sweet, I'd implemented it internally for other use cases and will switch over to it. So, thanks!"}}
{"actor":{"display_login":"ianstormtaylor"}}