{"action":"created","issue":{"url":"https://api.github.com/repos/ianstormtaylor/slate/issues/353","repository_url":"https://api.github.com/repos/ianstormtaylor/slate","labels_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/353/labels{/name}","comments_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/353/comments","events_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/353/events","html_url":"https://github.com/ianstormtaylor/slate/issues/353","id":178928238,"number":353,"title":"remove document normalize calls","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":[{"url":"https://api.github.com/repos/ianstormtaylor/slate/labels/bug","name":"bug","color":"f9d0c4"},{"url":"https://api.github.com/repos/ianstormtaylor/slate/labels/debt","name":"debt","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-23T17:11:03Z","updated_at":"2016-09-23T18:17:43Z","closed_at":null,"body":"There are a handful of bugs with the history (undo/redo) that are from `Node.normalize` calls in the transform logic.\r\n\r\nPreviously we used to call `.normalize()` to ensure that the document never got into \"weird\" states. This worked fine before we moved to operations, but now that all updates to Slate are performed via undo-able operations, the `.normalize()` calls are now harmful, since they don't actually add operations to the operation stack, so they aren't able to be undone. This results in strange errors when trying to undo certain behaviors (mostly around removing nodes, splitting nodes, and joining nodes).\r\n\r\nInstead of calling `.normalize()`, the transforms themselves should know about the potential \"weird\" states a transform can leave the document in, and handle them directly with more operations.\r\n\r\nA list of transforms to cover:\r\n\r\n#### `insertNodeByKey`\r\n\r\n- [ ] Should regenerate key if duplicated.\r\n- [ ] Should surround inline nodes with `isVoid: false` with text nodes when needed.\r\n\r\n#### `removeTextByKey`\r\n\r\n- [ ] Should remove inline nodes with `isVoid: false` when all characters are removed.\r\n- [ ] Should remove the text node when all characters are removed, if it's not needed anymore.\r\n\r\n#### `removeNodeByKey`\r\n\r\n- [ ] Should remove all characters instead of removing the last text node, to maintain text node leaves.\r\n- [ ] Should join text nodes when removing an inline node between them.\r\n\r\n#### `setNodeByKey`\r\n\r\n- [ ] Should add additional text nodes around the inline when setting `isVoid: true`.\r\n- [ ] Should remove additional text nodes around the inline when setting `isVoid: false`.\r\n- [ ] Should set text to `' '` when setting `isVoid: true`.\r\n\r\n#### `splitNodeByKey`\r\n\r\n- [ ] Should not split text nodes. (Except for internal use...)\r\n\r\nAlso, I think this should make performance better since we won't need to be iterating the whole document with every call to normalize 🎉 "},"comment":{"url":"https://api.github.com/repos/ianstormtaylor/slate/issues/comments/249265236","html_url":"https://github.com/ianstormtaylor/slate/issues/353#issuecomment-249265236","issue_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/353","id":249265236,"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-09-23T18:17:43Z","updated_at":"2016-09-23T18:17:43Z","body":"Alternatively this might be solved by instead using a `Schema` to normalize internally after all transforms, which might be less error prone. Only reason I could think that this wouldn't work is if it gets strange for user-land transforms that expect the internally schema to be being obeyed."}}
{"actor":{"display_login":"ianstormtaylor"}}