{"action":"opened","issue":{"url":"https://api.github.com/repos/ianstormtaylor/slate/issues/1096","repository_url":"https://api.github.com/repos/ianstormtaylor/slate","labels_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/1096/labels{/name}","comments_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/1096/comments","events_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/1096/events","html_url":"https://github.com/ianstormtaylor/slate/issues/1096","id":256361077,"number":1096,"title":"change `Raw` serializer to be part of models as `to/fromRaw`","user":{"login":"ianstormtaylor","id":311752,"avatar_url":"https://avatars0.githubusercontent.com/u/311752?v=4","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":[{"id":412790240,"url":"https://api.github.com/repos/ianstormtaylor/slate/labels/idea","name":"idea","color":"eeeeee","default":false},{"id":404055732,"url":"https://api.github.com/repos/ianstormtaylor/slate/labels/improvement","name":"improvement","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-08T20:20:28Z","updated_at":"2017-09-08T20:20:28Z","closed_at":null,"author_association":"OWNER","body":"I noticed this issue while working on #1095. Basically these things are in conflict:\r\n\r\n- Slate serializers should be split apart from \"core\", such that no one serializer is given more \"priority\" in the abstraction that others.\r\n- Slate serializers should only need a peer dependency on `slate` to work. (And of course other peer dependencies if they need for the specific serializer, like `react` for the `Html` serializer.)\r\n\r\nBecause of how `Raw` is currently handled, it feels like it should be separated from \"core\" since it's one of the many serializers. But at the same time it is so central to everything, and the other serializers would then all want to depend on it too.\r\n\r\nI had been thinking this before, but running into that issue made me more aware of it.\r\n\r\nI think instead, \"raw\" should be part of core and added to the Slate models, so that you could do:\r\n\r\n```js\r\nBlock.fromRaw({\r\n  type: 'paragraph',\r\n  nodes: [{\r\n    kind: 'text',\r\n    text: 'A string of text.',\r\n  }],\r\n})\r\n```\r\n\r\nOr...\r\n\r\n```js\r\nconst raw = Block.toRaw()\r\n```\r\n\r\nThe `fromRaw` method sounds similar to `Block.create`, but `create` would actually use `fromRaw` under the covers. Keeping `create` as the flexible one, with `fromRaw` expecting a properly formed raw JSON object.\r\n\r\n---\r\n\r\nAlternatively, we could override the `toJSON` methods of Immutable.js records. But I'm not sure if we'll regret that or not. It seems like it would be cleaner mentally if possible."}}
{"actor":{"display_login":"ianstormtaylor"}}