{"action":"created","comment":{"url":"https://api.github.com/repos/ianstormtaylor/slate/pulls/comments/73578956","id":73578956,"diff_hunk":"@@ -180,6 +181,27 @@ class Editor extends React.Component {\n   }\n \n   /**\n+   * When the editor receives a new 'state'\n+   *\n+   * @param {State} state\n+   * @return {State} newState\n+   */\n+\n+  onReceiveState = (state) => {\n+    if (state == this.state.state) return\n+\n+    for (const plugin of this.state.plugins) {\n+      if (!plugin.onReceiveState) continue\n+      const newState = plugin.onReceiveState(state, this)\n+      if (newState == null) continue\n+      state = newState\n+    }\n+\n+    if (!this.props.onReceiveState) return state\n+    return this.props.onReceiveState(state)","path":"lib/components/editor.js","position":47,"original_position":47,"commit_id":"fa78564d5595d195c3f49268514a270140fca2fa","original_commit_id":"fa78564d5595d195c3f49268514a270140fca2fa","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},"body":"This call should be unnecessary because of the logic in `resolvePlugins` creating an \"editor plugin\", I believe.","created_at":"2016-08-04T18:38:25Z","updated_at":"2016-08-04T18:38:25Z","html_url":"https://github.com/ianstormtaylor/slate/pull/219#discussion_r73578956","pull_request_url":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219","_links":{"self":{"href":"https://api.github.com/repos/ianstormtaylor/slate/pulls/comments/73578956"},"html":{"href":"https://github.com/ianstormtaylor/slate/pull/219#discussion_r73578956"},"pull_request":{"href":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219"}}},"pull_request":{"url":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219","id":79868775,"html_url":"https://github.com/ianstormtaylor/slate/pull/219","diff_url":"https://github.com/ianstormtaylor/slate/pull/219.diff","patch_url":"https://github.com/ianstormtaylor/slate/pull/219.patch","issue_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/219","number":219,"state":"open","locked":false,"title":"Add handler \"onReceiveState\"","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},"body":"This PR is related to #218.\r\n\r\nIt adds an handler `onReceiveState` that can be used to do validation before rendering:\r\n\r\nHere is an example for a plugin to enforce that the document contains only one block:\r\n\r\n```js\r\nfunction MyPlugin(blockType) {\r\n    function onValidation(newState) {\r\n        let { document } = newState;\r\n        let { nodes } = document;\r\n\r\n        if (nodes.size > 1) {\r\n            nodes = nodes.slice(0, 1);\r\n        }\r\n        document = document.merge({ nodes });\r\n        return newState.merge({ document });\r\n    }\r\n\r\n    return {\r\n        onChange: onValidation,\r\n        onReceiveState: onValidation\r\n    };\r\n}\r\n````","created_at":"2016-08-03T08:47:56Z","updated_at":"2016-08-04T18:38:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c1e7c39a0075f2526a30fbd8157f95a095eb3611","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219/commits","review_comments_url":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219/comments","review_comment_url":"https://api.github.com/repos/ianstormtaylor/slate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/219/comments","statuses_url":"https://api.github.com/repos/ianstormtaylor/slate/statuses/fa78564d5595d195c3f49268514a270140fca2fa","head":{"label":"SamyPesse:add/onReceiveState","ref":"add/onReceiveState","sha":"fa78564d5595d195c3f49268514a270140fca2fa","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},"repo":{"id":64828796,"name":"slate","full_name":"SamyPesse/slate","owner":{"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},"private":false,"html_url":"https://github.com/SamyPesse/slate","description":"A completely customizable framework for building rich text editors.","fork":true,"url":"https://api.github.com/repos/SamyPesse/slate","forks_url":"https://api.github.com/repos/SamyPesse/slate/forks","keys_url":"https://api.github.com/repos/SamyPesse/slate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SamyPesse/slate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SamyPesse/slate/teams","hooks_url":"https://api.github.com/repos/SamyPesse/slate/hooks","issue_events_url":"https://api.github.com/repos/SamyPesse/slate/issues/events{/number}","events_url":"https://api.github.com/repos/SamyPesse/slate/events","assignees_url":"https://api.github.com/repos/SamyPesse/slate/assignees{/user}","branches_url":"https://api.github.com/repos/SamyPesse/slate/branches{/branch}","tags_url":"https://api.github.com/repos/SamyPesse/slate/tags","blobs_url":"https://api.github.com/repos/SamyPesse/slate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SamyPesse/slate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SamyPesse/slate/git/refs{/sha}","trees_url":"https://api.github.com/repos/SamyPesse/slate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SamyPesse/slate/statuses/{sha}","languages_url":"https://api.github.com/repos/SamyPesse/slate/languages","stargazers_url":"https://api.github.com/repos/SamyPesse/slate/stargazers","contributors_url":"https://api.github.com/repos/SamyPesse/slate/contributors","subscribers_url":"https://api.github.com/repos/SamyPesse/slate/subscribers","subscription_url":"https://api.github.com/repos/SamyPesse/slate/subscription","commits_url":"https://api.github.com/repos/SamyPesse/slate/commits{/sha}","git_commits_url":"https://api.github.com/repos/SamyPesse/slate/git/commits{/sha}","comments_url":"https://api.github.com/repos/SamyPesse/slate/comments{/number}","issue_comment_url":"https://api.github.com/repos/SamyPesse/slate/issues/comments{/number}","contents_url":"https://api.github.com/repos/SamyPesse/slate/contents/{+path}","compare_url":"https://api.github.com/repos/SamyPesse/slate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SamyPesse/slate/merges","archive_url":"https://api.github.com/repos/SamyPesse/slate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SamyPesse/slate/downloads","issues_url":"https://api.github.com/repos/SamyPesse/slate/issues{/number}","pulls_url":"https://api.github.com/repos/SamyPesse/slate/pulls{/number}","milestones_url":"https://api.github.com/repos/SamyPesse/slate/milestones{/number}","notifications_url":"https://api.github.com/repos/SamyPesse/slate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SamyPesse/slate/labels{/name}","releases_url":"https://api.github.com/repos/SamyPesse/slate/releases{/id}","deployments_url":"https://api.github.com/repos/SamyPesse/slate/deployments","created_at":"2016-08-03T08:23:19Z","updated_at":"2016-08-04T07:21:02Z","pushed_at":"2016-08-03T08:42:09Z","git_url":"git://github.com/SamyPesse/slate.git","ssh_url":"git@github.com:SamyPesse/slate.git","clone_url":"https://github.com/SamyPesse/slate.git","svn_url":"https://github.com/SamyPesse/slate","homepage":"http://slatejs.org","size":17986,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"ianstormtaylor:master","ref":"master","sha":"5825db3caa009a2b92332112e1a90f50c2f6bc4f","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},"repo":{"id":61412022,"name":"slate","full_name":"ianstormtaylor/slate","owner":{"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},"private":false,"html_url":"https://github.com/ianstormtaylor/slate","description":"A completely customizable framework for building rich text editors.","fork":false,"url":"https://api.github.com/repos/ianstormtaylor/slate","forks_url":"https://api.github.com/repos/ianstormtaylor/slate/forks","keys_url":"https://api.github.com/repos/ianstormtaylor/slate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ianstormtaylor/slate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ianstormtaylor/slate/teams","hooks_url":"https://api.github.com/repos/ianstormtaylor/slate/hooks","issue_events_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/events{/number}","events_url":"https://api.github.com/repos/ianstormtaylor/slate/events","assignees_url":"https://api.github.com/repos/ianstormtaylor/slate/assignees{/user}","branches_url":"https://api.github.com/repos/ianstormtaylor/slate/branches{/branch}","tags_url":"https://api.github.com/repos/ianstormtaylor/slate/tags","blobs_url":"https://api.github.com/repos/ianstormtaylor/slate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ianstormtaylor/slate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ianstormtaylor/slate/git/refs{/sha}","trees_url":"https://api.github.com/repos/ianstormtaylor/slate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ianstormtaylor/slate/statuses/{sha}","languages_url":"https://api.github.com/repos/ianstormtaylor/slate/languages","stargazers_url":"https://api.github.com/repos/ianstormtaylor/slate/stargazers","contributors_url":"https://api.github.com/repos/ianstormtaylor/slate/contributors","subscribers_url":"https://api.github.com/repos/ianstormtaylor/slate/subscribers","subscription_url":"https://api.github.com/repos/ianstormtaylor/slate/subscription","commits_url":"https://api.github.com/repos/ianstormtaylor/slate/commits{/sha}","git_commits_url":"https://api.github.com/repos/ianstormtaylor/slate/git/commits{/sha}","comments_url":"https://api.github.com/repos/ianstormtaylor/slate/comments{/number}","issue_comment_url":"https://api.github.com/repos/ianstormtaylor/slate/issues/comments{/number}","contents_url":"https://api.github.com/repos/ianstormtaylor/slate/contents/{+path}","compare_url":"https://api.github.com/repos/ianstormtaylor/slate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ianstormtaylor/slate/merges","archive_url":"https://api.github.com/repos/ianstormtaylor/slate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ianstormtaylor/slate/downloads","issues_url":"https://api.github.com/repos/ianstormtaylor/slate/issues{/number}","pulls_url":"https://api.github.com/repos/ianstormtaylor/slate/pulls{/number}","milestones_url":"https://api.github.com/repos/ianstormtaylor/slate/milestones{/number}","notifications_url":"https://api.github.com/repos/ianstormtaylor/slate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ianstormtaylor/slate/labels{/name}","releases_url":"https://api.github.com/repos/ianstormtaylor/slate/releases{/id}","deployments_url":"https://api.github.com/repos/ianstormtaylor/slate/deployments","created_at":"2016-06-18T01:52:42Z","updated_at":"2016-08-04T13:46:12Z","pushed_at":"2016-08-04T18:24:44Z","git_url":"git://github.com/ianstormtaylor/slate.git","ssh_url":"git@github.com:ianstormtaylor/slate.git","clone_url":"https://github.com/ianstormtaylor/slate.git","svn_url":"https://github.com/ianstormtaylor/slate","homepage":"http://slatejs.org","size":18168,"stargazers_count":2134,"watchers_count":2134,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":64,"mirror_url":null,"open_issues_count":29,"forks":64,"open_issues":29,"watchers":2134,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219"},"html":{"href":"https://github.com/ianstormtaylor/slate/pull/219"},"issue":{"href":"https://api.github.com/repos/ianstormtaylor/slate/issues/219"},"comments":{"href":"https://api.github.com/repos/ianstormtaylor/slate/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/ianstormtaylor/slate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ianstormtaylor/slate/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/ianstormtaylor/slate/statuses/fa78564d5595d195c3f49268514a270140fca2fa"}}}}
{"actor":{"display_login":"ianstormtaylor"}}