{"action":"created","comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/183139510","pull_request_review_id":114087718,"id":183139510,"diff_hunk":"@@ -150,33 +187,21 @@ export default function rawHandler( { HTML, plainText = '', mode = 'AUTO', tagNa\n \n \t\tdoc.body.innerHTML = piece;\n \n-\t\tconst transformsFrom = getBlockTransforms( 'from' );\n-\n-\t\tconst blocks = Array.from( doc.body.children ).map( ( node ) => {\n-\t\t\tconst transformation = findTransform( transformsFrom, ( transform ) => (\n-\t\t\t\ttransform.type === 'raw' &&\n-\t\t\t\ttransform.isMatch( node )\n-\t\t\t) );\n-\n-\t\t\tif ( transformation ) {\n-\t\t\t\tif ( transformation.transform ) {\n-\t\t\t\t\treturn transformation.transform( node );\n-\t\t\t\t}\n-\n-\t\t\t\treturn createBlock(\n-\t\t\t\t\ttransformation.blockName,\n-\t\t\t\t\tgetBlockAttributes(\n-\t\t\t\t\t\tgetBlockType( transformation.blockName ),\n-\t\t\t\t\t\tnode.outerHTML\n-\t\t\t\t\t)\n-\t\t\t\t);\n+\t\treturn Array.from( doc.body.children ).map( ( node ) => {\n+\t\t\tconst { transform, blockName } =\n+\t\t\t\tfind( rawTransformations, ( { isMatch } ) => isMatch( node ) );","path":"blocks/api/raw-handling/index.js","position":255,"original_position":255,"commit_id":"c5a23d874d35ac089d9251f9c8ae701b668994ff","original_commit_id":"c5a23d874d35ac089d9251f9c8ae701b668994ff","user":{"login":"iseulde","id":4710635,"avatar_url":"https://avatars3.githubusercontent.com/u/4710635?v=4","gravatar_id":"","url":"https://api.github.com/users/iseulde","html_url":"https://github.com/iseulde","followers_url":"https://api.github.com/users/iseulde/followers","following_url":"https://api.github.com/users/iseulde/following{/other_user}","gists_url":"https://api.github.com/users/iseulde/gists{/gist_id}","starred_url":"https://api.github.com/users/iseulde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iseulde/subscriptions","organizations_url":"https://api.github.com/users/iseulde/orgs","repos_url":"https://api.github.com/users/iseulde/repos","events_url":"https://api.github.com/users/iseulde/events{/privacy}","received_events_url":"https://api.github.com/users/iseulde/received_events","type":"User","site_admin":false},"body":"Adjusted so that if someone forgets to add a selector:\r\n\r\n> A block registered a raw transformation schema for `H2` but did not match it. Make sure there is a `selector` or `isMatch` property that can match the schema.\r\n> Sanitized HTML: `<h2>Issue Overview</h2>`","created_at":"2018-04-20T18:48:52Z","updated_at":"2018-04-20T18:48:53Z","html_url":"https://github.com/WordPress/gutenberg/pull/5966#discussion_r183139510","pull_request_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/183139510"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/5966#discussion_r183139510"},"pull_request":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966"}},"in_reply_to_id":182829321},"pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966","id":179241291,"html_url":"https://github.com/WordPress/gutenberg/pull/5966","diff_url":"https://github.com/WordPress/gutenberg/pull/5966.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/5966.patch","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/5966","number":5966,"state":"open","locked":false,"title":"Add paste schema (fix various issues, simplify)","user":{"login":"iseulde","id":4710635,"avatar_url":"https://avatars3.githubusercontent.com/u/4710635?v=4","gravatar_id":"","url":"https://api.github.com/users/iseulde","html_url":"https://github.com/iseulde","followers_url":"https://api.github.com/users/iseulde/followers","following_url":"https://api.github.com/users/iseulde/following{/other_user}","gists_url":"https://api.github.com/users/iseulde/gists{/gist_id}","starred_url":"https://api.github.com/users/iseulde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iseulde/subscriptions","organizations_url":"https://api.github.com/users/iseulde/orgs","repos_url":"https://api.github.com/users/iseulde/repos","events_url":"https://api.github.com/users/iseulde/events{/privacy}","received_events_url":"https://api.github.com/users/iseulde/received_events","type":"User","site_admin":false},"body":"## Description\r\n\r\nThis branch simplifies whitelisting and reduces the amount of filters. The idea is that there is one schema with all possible paths that a pasted node tree can have. If something is different from what is possible, the node should unwrap or be deleted.\r\n\r\nWhy adding a schema with an infinite amount of paths? The whitelisting we had before was just too simplistic. It lacks context. For example, a list (`OL`) can only contain list items (`LI`), a figure caption can only be part of a figure etc. The schema also takes care of a number of filters we had before by the generalisation, e.g. stripping text nodes out of tables where they don't belong, stripping comments, and finally it also incorporates attribute stripping.\r\n\r\nInstead of looping three times over the whole pasted node tree, we are now only looping twice. One filters and adjusts broken HTML, from the bottom of the tree to the top, and the other one removes invalid HTML according to the schema, from the top to the bottom of the tree.\r\n\r\nAnother big difference from master is that the schema is now part of the transforms that blocks register, not of the raw handler module itself. This is quite a nice separation and it also enables block authors to register more schemas to be taken into account when converting old content.\r\n\r\nAlso new is the `selector` property on transforms. In a lot of cases in can be used in favour of the `isMatch( node )` function.\r\n\r\nI also got rid of the `inInvalidInline` filter which was looping through all nodes inside a loop. 🙈\r\n\r\nAdditionally I tried to simplify and optimize some of the rest of the code, and add some doc blocks.\r\n\r\n## How Has This Been Tested?\r\nPaste tests should pass.\r\n\r\nFixes case where a loose `figcaption` is kept and put in a classic block. The expected result is the `figcaption` element to unwrap. Try pasting from https://www.nytimes.com/2018/03/28/magazine/poem-the-nod.html.\r\n\r\n## Checklist:\r\n- [x] My code is tested.\r\n- [x] My code follows the WordPress code style.\r\n- [x] My code has proper inline documentation.","created_at":"2018-04-03T22:56:05Z","updated_at":"2018-04-20T18:48:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"19169a1ab1d1410543f1841780a536868e196093","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":671400480,"url":"https://api.github.com/repos/WordPress/gutenberg/labels/[Component]%20Copy/Paste","name":"[Component] Copy/Paste","color":"fbca04","default":false}],"milestone":{"url":"https://api.github.com/repos/WordPress/gutenberg/milestones/52","html_url":"https://github.com/WordPress/gutenberg/milestone/52","labels_url":"https://api.github.com/repos/WordPress/gutenberg/milestones/52/labels","id":3277284,"number":52,"title":"2.8","description":"","creator":{"login":"youknowriad","id":272444,"avatar_url":"https://avatars3.githubusercontent.com/u/272444?v=4","gravatar_id":"","url":"https://api.github.com/users/youknowriad","html_url":"https://github.com/youknowriad","followers_url":"https://api.github.com/users/youknowriad/followers","following_url":"https://api.github.com/users/youknowriad/following{/other_user}","gists_url":"https://api.github.com/users/youknowriad/gists{/gist_id}","starred_url":"https://api.github.com/users/youknowriad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youknowriad/subscriptions","organizations_url":"https://api.github.com/users/youknowriad/orgs","repos_url":"https://api.github.com/users/youknowriad/repos","events_url":"https://api.github.com/users/youknowriad/events{/privacy}","received_events_url":"https://api.github.com/users/youknowriad/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":8,"state":"open","created_at":"2018-04-18T08:19:43Z","updated_at":"2018-04-20T16:24:31Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966/commits","review_comments_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966/comments","review_comment_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/5966/comments","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/c5a23d874d35ac089d9251f9c8ae701b668994ff","head":{"label":"WordPress:try/paste-whitelist","ref":"try/paste-whitelist","sha":"c5a23d874d35ac089d9251f9c8ae701b668994ff","user":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"name":"gutenberg","full_name":"WordPress/gutenberg","owner":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Beta plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-04-20T16:24:53Z","pushed_at":"2018-04-20T18:11:16Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/ ","size":12660,"stargazers_count":2335,"watchers_count":2335,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":571,"mirror_url":null,"archived":false,"open_issues_count":841,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":571,"open_issues":841,"watchers":2335,"default_branch":"master"}},"base":{"label":"WordPress:master","ref":"master","sha":"a1055928b76718dc363be410ad6b2f00ff367c2c","user":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"name":"gutenberg","full_name":"WordPress/gutenberg","owner":{"login":"WordPress","id":276006,"avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Beta plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-04-20T16:24:53Z","pushed_at":"2018-04-20T18:11:16Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/ ","size":12660,"stargazers_count":2335,"watchers_count":2335,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":571,"mirror_url":null,"archived":false,"open_issues_count":841,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":571,"open_issues":841,"watchers":2335,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/5966"},"issue":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/5966"},"comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/5966/comments"},"review_comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966/comments"},"review_comment":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/5966/commits"},"statuses":{"href":"https://api.github.com/repos/WordPress/gutenberg/statuses/c5a23d874d35ac089d9251f9c8ae701b668994ff"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"iseulde"}}