{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/10439","repository_url":"https://api.github.com/repos/WordPress/gutenberg","labels_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10439/labels{/name}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10439/comments","events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10439/events","html_url":"https://github.com/WordPress/gutenberg/pull/10439","id":368190298,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNDIzMjE4","number":10439,"title":"Only use rich text value internally to the RichText component","user":{"login":"iseulde","id":4710635,"node_id":"MDQ6VXNlcjQ3MTA2MzU=","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},"labels":[{"id":598548627,"node_id":"MDU6TGFiZWw1OTg1NDg2Mjc=","url":"https://api.github.com/repos/WordPress/gutenberg/labels/[Component]%20Rich%20Text","name":"[Component] Rich Text","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/WordPress/gutenberg/milestones/65","html_url":"https://github.com/WordPress/gutenberg/milestone/65","labels_url":"https://api.github.com/repos/WordPress/gutenberg/milestones/65/labels","id":3648185,"node_id":"MDk6TWlsZXN0b25lMzY0ODE4NQ==","number":65,"title":"4.0","description":"","creator":{"login":"mtias","id":548849,"node_id":"MDQ6VXNlcjU0ODg0OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/548849?v=4","gravatar_id":"","url":"https://api.github.com/users/mtias","html_url":"https://github.com/mtias","followers_url":"https://api.github.com/users/mtias/followers","following_url":"https://api.github.com/users/mtias/following{/other_user}","gists_url":"https://api.github.com/users/mtias/gists{/gist_id}","starred_url":"https://api.github.com/users/mtias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtias/subscriptions","organizations_url":"https://api.github.com/users/mtias/orgs","repos_url":"https://api.github.com/users/mtias/repos","events_url":"https://api.github.com/users/mtias/events{/privacy}","received_events_url":"https://api.github.com/users/mtias/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":172,"state":"closed","created_at":"2018-09-12T09:58:31Z","updated_at":"2018-10-18T13:01:11Z","due_on":null,"closed_at":"2018-10-17T23:06:20Z"},"comments":14,"created_at":"2018-10-09T12:40:47Z","updated_at":"2018-10-19T14:44:34Z","closed_at":"2018-10-10T17:44:34Z","author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/10439","html_url":"https://github.com/WordPress/gutenberg/pull/10439","diff_url":"https://github.com/WordPress/gutenberg/pull/10439.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/10439.patch"},"body":"## Description\r\n\r\nThis is a proposal to use the string format on the RichText component by default.\r\n\r\nBenefits:\r\n\r\n* The block attribute values are plain HTML, so I'd be no longer concerned about plugin authors manipulating the raw rich text value directly.\r\n* Plain HTML can be passed to `createBlock` to create templates.\r\n* The rich text value is only used internally to rich text. No other code should be aware of this value shape.\r\n* It would be okay if the value is not serialisable as JSON. It will never be in the global state.\r\n* The value can be stored in the block comments.\r\n* No need to start recommending different formats for different use cases such as post meta.\r\n* The format is internal only so we can continue to make improvements.\r\n\r\nCons:\r\n\r\n* Slightly less performant, but I would consider this is negligible.\r\n\r\n## How has this been tested?\r\n<!-- Please describe in detail how you tested your changes. -->\r\n<!-- Include details of your testing environment, tests ran to see how -->\r\n<!-- your change affects other areas of the code, etc. -->\r\n\r\n## Screenshots <!-- if applicable -->\r\n\r\n## Types of changes\r\n<!-- What types of changes does your code introduce?  -->\r\n<!-- Bug fix (non-breaking change which fixes an issue) -->\r\n<!-- New feature (non-breaking change which adds functionality) -->\r\n<!-- Breaking change (fix or feature that would cause existing functionality to not work as expected) -->\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/ -->"},"comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments/431387645","html_url":"https://github.com/WordPress/gutenberg/pull/10439#issuecomment-431387645","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/10439","id":431387645,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTM4NzY0NQ==","user":{"login":"ktmn","id":6892634,"node_id":"MDQ6VXNlcjY4OTI2MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6892634?v=4","gravatar_id":"","url":"https://api.github.com/users/ktmn","html_url":"https://github.com/ktmn","followers_url":"https://api.github.com/users/ktmn/followers","following_url":"https://api.github.com/users/ktmn/following{/other_user}","gists_url":"https://api.github.com/users/ktmn/gists{/gist_id}","starred_url":"https://api.github.com/users/ktmn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktmn/subscriptions","organizations_url":"https://api.github.com/users/ktmn/orgs","repos_url":"https://api.github.com/users/ktmn/repos","events_url":"https://api.github.com/users/ktmn/events{/privacy}","received_events_url":"https://api.github.com/users/ktmn/received_events","type":"User","site_admin":false},"created_at":"2018-10-19T14:44:34Z","updated_at":"2018-10-19T14:44:34Z","author_association":"NONE","body":"> What I am wondering is why your blocks without any change broke the templates as we tried to keep the children sources with their corresponding templates as is.\r\n\r\nIn short, this is how my block looked like:\r\n\r\n```js\r\n{\r\n\tattributes: {\r\n\t\tcontent: {\r\n\t\t\ttype: 'array',\r\n\t\t},\r\n\t},\r\n\tedit: ({attributes, setAttributes}) => {\r\n\t\treturn (\r\n\t\t\t<div className='custom-block'>\r\n\t\t\t\t<wp.editor.RichText\r\n\t\t\t\t\tvalue={attributes.content}\r\n\t\t\t\t\tonChange={value => setAttributes({content: value})}\r\n\t\t\t\t/>\r\n\t\t\t</div>\r\n\t\t)\r\n\t},\r\n\tsave: ({attributes}) => {\r\n\t\treturn (\r\n\t\t\t<div className='custom-block'>\r\n\t\t\t\t{attributes.content}\r\n\t\t\t</div>\r\n\t\t)\r\n\t},\r\n}\r\n```\r\n\r\nAfter 4.0.0 that produced `This block contains unexpected or invalid content.` after refreshing the editor, since the rich text now returns a string and I guess it get's removed from the block comments because it doesn't match the type specified.\r\n\r\nSo I changed it to string:\r\n\r\n```js\r\n{\r\n\tattributes: {\r\n\t\tcontent: {\r\n\t\t\ttype: 'string',\r\n\t\t},\r\n\t},\r\n\t...\r\n}\r\n```\r\n\r\nand ran into issues with html being escaped, such as bold text or multiline.\r\nI figured out I gotta use `<RichText.Content>` so I did.\r\n\r\n```js\r\n{\r\n\tattributes: {\r\n\t\tcontent: {\r\n\t\t\ttype: 'array',\r\n\t\t},\r\n\t},\r\n\tedit: ({attributes, setAttributes}) => {\r\n\t\treturn (\r\n\t\t\t<div className='custom-block'>\r\n\t\t\t\t<wp.editor.RichText\r\n\t\t\t\t\tvalue={attributes.content}\r\n\t\t\t\t\tonChange={value => setAttributes({content: value})}\r\n\t\t\t\t/>\r\n\t\t\t</div>\r\n\t\t)\r\n\t},\r\n\tsave: ({attributes}) => {\r\n\t\treturn (\r\n\t\t\t<div className='custom-block'>\r\n\t\t\t\t<wp.editor.RichText.Content value={attributes.content} />\r\n\t\t\t</div>\r\n\t\t)\r\n\t},\r\n}\r\n```\r\n\r\nThen I have a block that is basically a preset of blocks, so it looked something like this:\r\n\r\n```js\r\n{\r\n\tattributes: {},\r\n\tedit: ({attributes, setAttributes}) => {\r\n\t\treturn (\r\n\t\t\t<div className='my-other-block'>\r\n\t\t\t\t<wp.editor.InnerBlocks\r\n\t\t\t\t\ttemplate={[\r\n\t\t\t\t\t\t['custom/block', {\r\n\t\t\t\t\t\t\tcontent: ['Content'],\r\n\t\t\t\t\t\t}],\r\n\t\t\t\t\t]}\r\n\t\t\t\t/>\r\n\t\t\t</div>\r\n\t\t)\r\n\t},\r\n\tsave: ({attributes}) => {\r\n\t\treturn (\r\n\t\t\t<div className='my-other-block'>\r\n\t\t\t\t<wp.editor.InnerBlocks.Content />\r\n\t\t\t</div>\r\n\t\t)\r\n\t},\r\n}\r\n```\r\n\r\nNotice the content in the template is type `array`, the old format, but the block earlier used `string` value now. It will render the `InnerBlocks` fine when you insert the block, but after refresh the content attribute is gone from the `custom/block` block comments and I get an error (~`The block has been modified externally`).\r\n\r\nSo to solve that I removed the type from `custom/block`:\r\n\r\n```js\r\n{\r\n\tattributes: {\r\n\t\tcontent: {},\r\n\t},\r\n\t...\r\n}\r\n```\r\n\r\nNow it works. It can use string from `<RichText>` and array from old templates. That's how I reconciled 4.0.\r\n\r\nI'm not saying anything is bugged, this is just how it went down for me.\r\n\r\nNow I'm just wondering: \r\n\r\n1. Is it correct to have no type for the attribute?\r\n\r\n2. Do I keep the old array templates (of which I have about 20 different ones, 1200 lines)? Or do I need to convert them to string format.\r\n\r\n3. And if so, how does bold and `<br>` etc look like in the new string format? Are there examples?"}}
{"actor":{"display_login":"ktmn"}}