{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/10551","repository_url":"https://api.github.com/repos/WordPress/gutenberg","labels_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10551/labels{/name}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10551/comments","events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10551/events","html_url":"https://github.com/WordPress/gutenberg/pull/10551","id":369524396,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNDQ1NTI3","number":10551,"title":"Add a ‘raw’ block attribute type","user":{"login":"johngodley","id":1277682,"node_id":"MDQ6VXNlcjEyNzc2ODI=","avatar_url":"https://avatars1.githubusercontent.com/u/1277682?v=4","gravatar_id":"","url":"https://api.github.com/users/johngodley","html_url":"https://github.com/johngodley","followers_url":"https://api.github.com/users/johngodley/followers","following_url":"https://api.github.com/users/johngodley/following{/other_user}","gists_url":"https://api.github.com/users/johngodley/gists{/gist_id}","starred_url":"https://api.github.com/users/johngodley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johngodley/subscriptions","organizations_url":"https://api.github.com/users/johngodley/orgs","repos_url":"https://api.github.com/users/johngodley/repos","events_url":"https://api.github.com/users/johngodley/events{/privacy}","received_events_url":"https://api.github.com/users/johngodley/received_events","type":"User","site_admin":false},"labels":[{"id":570263070,"node_id":"MDU6TGFiZWw1NzAyNjMwNzA=","url":"https://api.github.com/repos/WordPress/gutenberg/labels/Blocks","name":"Blocks","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-12T12:09:50Z","updated_at":"2018-11-26T11:03:19Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/10551","html_url":"https://github.com/WordPress/gutenberg/pull/10551","diff_url":"https://github.com/WordPress/gutenberg/pull/10551.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/10551.patch"},"body":"Currently if you use an HTML block it will be parsed and reformatted when saved. This has the effect of transforming valid HTML such as:\r\n\r\n`<path d=\"M0,0h24v24H0V0z M0,0h24v24H0V0z\" fill=\"none\" />`\r\n\r\nInto:\r\n\r\n`<path d=\"M0,0h24v24H0V0z M0,0h24v24H0V0z\" fill=\"none\"></path>`\r\n\r\nAlthough technically correct it does mean the HTML changes on save, which is unexpected.\r\n\r\nThe reason for this is the HTML goes into `hpq`, which uses the browser and `createHTMLDocument`. This converts the user HTML into a valid DOM tree, modifying as appropriate, expanding self-closing tags, and removing unnecessary whitespace.\r\n\r\nWhen the HTML is then returned it is the browser's version, and the original version is discarded. For most blocks this is fine as the HTML is generated by Gutenberg, but for the HTML block the HTML is generated by the user.\r\n\r\nThis PR adds a 'raw' block attribute type so an attribute can avoid being processed by Gutenberg in this way. This is then used by the HTML block type so it doesn't change the original HTML.\r\n\r\nThis is another follow-on from #10066, and in conjunction with #10474.\r\n\r\n## Note\r\n\r\nFundamentally I'm not sure if the 'conversion' is a problem. Do we want Gutenberg to be opinionated about its HTML and are fine saying the HTML block will reformat and validate the HTML, or do we want to leave it as-is?\r\n\r\nIs this something that could be optional within the HTML block? That is, the HTML is parsed by default but there is a block setting to disable this (a 'managed' and 'unmanaged' HTML block)?\r\n\r\nThe test case for this has been an SVG, where pasting an SVG into an HTML block results in the HTML changing. Could another option be to create an SVG block which handles this specific case?\r\n\r\nWhile this PR has a simple solution, it's more of a question and could require more work.\r\n\r\n## How has this been tested?\r\nAdditional unit test added\r\n\r\n## Checklist:\r\n- [ ] My code is tested.\r\n- [ ] My code follows the WordPress code style. <!-- Check code: `npm run lint`, Guidelines: https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/ -->\r\n- [ ] My code follows the accessibility standards. <!-- Guidelines: https://make.wordpress.org/core/handbook/best-practices/coding-standards/accessibility-coding-standards/ -->\r\n- [ ] My code has proper inline documentation. <!-- Guidelines: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/ -->\r\n"},"comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments/441600843","html_url":"https://github.com/WordPress/gutenberg/pull/10551#issuecomment-441600843","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10551","id":441600843,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTYwMDg0Mw==","user":{"login":"johngodley","id":1277682,"node_id":"MDQ6VXNlcjEyNzc2ODI=","avatar_url":"https://avatars1.githubusercontent.com/u/1277682?v=4","gravatar_id":"","url":"https://api.github.com/users/johngodley","html_url":"https://github.com/johngodley","followers_url":"https://api.github.com/users/johngodley/followers","following_url":"https://api.github.com/users/johngodley/following{/other_user}","gists_url":"https://api.github.com/users/johngodley/gists{/gist_id}","starred_url":"https://api.github.com/users/johngodley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johngodley/subscriptions","organizations_url":"https://api.github.com/users/johngodley/orgs","repos_url":"https://api.github.com/users/johngodley/repos","events_url":"https://api.github.com/users/johngodley/events{/privacy}","received_events_url":"https://api.github.com/users/johngodley/received_events","type":"User","site_admin":false},"created_at":"2018-11-26T11:03:19Z","updated_at":"2018-11-26T11:03:19Z","author_association":"CONTRIBUTOR","body":"Based on the feedback I've updated this PR to just check for `source` = `html` and an empty `selector`, removing the `raw` block type.\r\n\r\nAs mentioned this does affect `core/freeform` and I've updated existing tests to reflect this.\r\n\r\nIf this PR still makes sense to include I can also create a separate issue (here or in `hpq`) summarising the discussion above about implementing it in `hpq`."}}
{"actor":{"display_login":"johngodley"}}