{"action":"created","issue":{"url":"https://api.github.com/repos/SamyPesse/draft-js/issues/3","repository_url":"https://api.github.com/repos/SamyPesse/draft-js","labels_url":"https://api.github.com/repos/SamyPesse/draft-js/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/SamyPesse/draft-js/issues/3/comments","events_url":"https://api.github.com/repos/SamyPesse/draft-js/issues/3/events","html_url":"https://github.com/SamyPesse/draft-js/issues/3","id":155161492,"number":3,"title":"convertFromDraftStateToRaw should also support tree nested elements","user":{"login":"mitermayer","id":1042131,"avatar_url":"https://avatars.githubusercontent.com/u/1042131?v=3","gravatar_id":"","url":"https://api.github.com/users/mitermayer","html_url":"https://github.com/mitermayer","followers_url":"https://api.github.com/users/mitermayer/followers","following_url":"https://api.github.com/users/mitermayer/following{/other_user}","gists_url":"https://api.github.com/users/mitermayer/gists{/gist_id}","starred_url":"https://api.github.com/users/mitermayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitermayer/subscriptions","organizations_url":"https://api.github.com/users/mitermayer/orgs","repos_url":"https://api.github.com/users/mitermayer/repos","events_url":"https://api.github.com/users/mitermayer/events{/privacy}","received_events_url":"https://api.github.com/users/mitermayer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-17T02:05:07Z","updated_at":"2016-05-17T21:30:52Z","closed_at":null,"body":"## Background\r\n\r\nconvertFromDraftStateToRaw should also now support tree nested elements so that data can be persisted. It should do so by making sure that does not break backwards compatibility allowing data to still be saved as flat structure.\r\n\r\n## Actions\r\n\r\n- [ ] convertFromDraftStateToRaw should have an optional parameter __'enableNesting'__\\* configuration flag and when creating the ContentBlocks will generate the correct nesting keys `foo/bar`, `foo/foo`, `foo` for contentBlocks that have nested elements\r\n- [ ] Add tests, we should make sure that convertFromDraftStateToRaw behaves as normal when the  __'enableNesting'__\\* is disabled\r\n- [ ]  Add tests, we should make sure that convertFromDraftStateToRaw behaves as expected when the  __'enableNesting'__\\* is enabled\r\n\r\n\r\n\\* We still do not have such feature implemented https://github.com/SamyPesse/draft-js/issues/4"},"comment":{"url":"https://api.github.com/repos/SamyPesse/draft-js/issues/comments/219860486","html_url":"https://github.com/SamyPesse/draft-js/issues/3#issuecomment-219860486","issue_url":"https://api.github.com/repos/SamyPesse/draft-js/issues/3","id":219860486,"user":{"login":"SamyPesse","id":845425,"avatar_url":"https://avatars.githubusercontent.com/u/845425?v=3","gravatar_id":"","url":"https://api.github.com/users/SamyPesse","html_url":"https://github.com/SamyPesse","followers_url":"https://api.github.com/users/SamyPesse/followers","following_url":"https://api.github.com/users/SamyPesse/following{/other_user}","gists_url":"https://api.github.com/users/SamyPesse/gists{/gist_id}","starred_url":"https://api.github.com/users/SamyPesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamyPesse/subscriptions","organizations_url":"https://api.github.com/users/SamyPesse/orgs","repos_url":"https://api.github.com/users/SamyPesse/repos","events_url":"https://api.github.com/users/SamyPesse/events{/privacy}","received_events_url":"https://api.github.com/users/SamyPesse/received_events","type":"User","site_admin":false},"created_at":"2016-05-17T21:30:52Z","updated_at":"2016-05-17T21:30:52Z","body":"@mitermayer \r\n\r\nI've started this: https://github.com/SamyPesse/draft-js/commit/e1cb7e9a09158fde91812e41736b6ae379b8ee91\r\n\r\nThis is the cleaner solution (`convertBlockFromDraftToRaw` is defined inside `convertFromDraftStateToRaw`), but it avoid complex function signatures.\r\n\r\nAlso the `block.key` is the relative key, not the absolute one, so that:\r\n\r\n```js\r\nconvertFromRawToDraft(convertFromDraftToRaw(contentState)) == contentState\r\n```\r\n\r\nBut it also means:\r\n\r\n```js\r\nvar raw = convertFromDraftToRaw(contentState);\r\n\r\ncontentState.getBlockForKey(raw.blocks[0].blocks[0].key) === undefined\r\n```\r\n"}}