Skip to content

Commit

Permalink
Rich Text: Formalize RichText children value abstraction (#7934)
Browse files Browse the repository at this point in the history
* Element: Support plain-string style prop

* Rich Text: Formalize RichText children value abstraction

* Testing: Add E2E case to ensure cleaned TinyMCE content
  • Loading branch information
aduth authored Jul 20, 2018
1 parent 6cee18e commit 1a0a3ba
Show file tree
Hide file tree
Showing 31 changed files with 1,066 additions and 343 deletions.
7 changes: 5 additions & 2 deletions core-blocks/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { omit } from 'lodash';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { concatChildren } from '@wordpress/element';
import {
createBlock,
getPhrasingContentSchema,
getBlockAttributes,
getBlockType,
children,
} from '@wordpress/blocks';
import { RichText } from '@wordpress/editor';

Expand Down Expand Up @@ -167,7 +167,10 @@ export const settings = {

merge( attributes, attributesToMerge ) {
return {
content: concatChildren( attributes.content, attributesToMerge.content ),
content: children.concat(
attributes.content,
attributesToMerge.content
),
};
},

Expand Down
12 changes: 9 additions & 3 deletions core-blocks/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { isFinite, find, omit } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import {
concatChildren,
Component,
Fragment,
RawHTML,
Expand All @@ -30,7 +29,11 @@ import {
PanelColor,
RichText,
} from '@wordpress/editor';
import { createBlock, getPhrasingContentSchema } from '@wordpress/blocks';
import {
createBlock,
getPhrasingContentSchema,
children,
} from '@wordpress/blocks';
import { compose } from '@wordpress/compose';

/**
Expand Down Expand Up @@ -470,7 +473,10 @@ export const settings = {

merge( attributes, attributesToMerge ) {
return {
content: concatChildren( attributes.content, attributesToMerge.content ),
content: children.concat(
attributes.content,
attributesToMerge.content
),
};
},

Expand Down
4 changes: 3 additions & 1 deletion core-blocks/test/fixtures/core__heading__h2-em.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"The ",
{
"type": "em",
"children": "Inserter"
"children": [
"Inserter"
]
},
" Tool"
],
Expand Down
24 changes: 18 additions & 6 deletions core-blocks/test/fixtures/core__list__ul.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,43 @@
"values": [
{
"type": "li",
"children": "Text & Headings"
"children": [
"Text & Headings"
]
},
{
"type": "li",
"children": "Images & Videos"
"children": [
"Images & Videos"
]
},
{
"type": "li",
"children": "Galleries"
"children": [
"Galleries"
]
},
{
"type": "li",
"children": "Embeds, like YouTube, Tweets, or other WordPress posts."
"children": [
"Embeds, like YouTube, Tweets, or other WordPress posts."
]
},
{
"type": "li",
"children": "Layout blocks, like Buttons, Hero Images, Separators, etc."
"children": [
"Layout blocks, like Buttons, Hero Images, Separators, etc."
]
},
{
"type": "li",
"children": [
"And ",
{
"type": "em",
"children": "Lists"
"children": [
"Lists"
]
},
" like this one of course :)"
]
Expand Down
7 changes: 5 additions & 2 deletions core-blocks/test/fixtures/core__preformatted.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
"Some ",
{
"type": "em",
"children": "preformatted"
"children": [
"preformatted"
]
},
" text...",
{
"type": "br"
"type": "br",
"children": []
},
"And more!"
]
Expand Down
10 changes: 4 additions & 6 deletions core-blocks/test/fixtures/core__pullquote.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
{
"children": {
"type": "p",
"key": null,
"ref": null,
"props": {
"children": "Testing pullquote block..."
},
"_owner": null,
"_store": {}
"children": [
"Testing pullquote block..."
]
}
}
}
],
Expand Down
26 changes: 9 additions & 17 deletions core-blocks/test/fixtures/core__pullquote__multi-paragraph.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,29 @@
{
"children": {
"type": "p",
"key": null,
"ref": null,
"props": {
"children": [
"Paragraph ",
{
"type": "strong",
"key": "_domReact73",
"ref": null,
"props": {
"children": "one"
},
"_owner": null,
"_store": {}
"children": [
"one"
]
}
}
]
},
"_owner": null,
"_store": {}
}
}
},
{
"children": {
"type": "p",
"key": null,
"ref": null,
"props": {
"children": "Paragraph two"
},
"_owner": null,
"_store": {}
"children": [
"Paragraph two"
]
}
}
}
],
Expand Down
10 changes: 4 additions & 6 deletions core-blocks/test/fixtures/core__quote__style-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
{
"children": {
"type": "p",
"key": null,
"ref": null,
"props": {
"children": "The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery."
},
"_owner": null,
"_store": {}
"children": [
"The editor will endeavour to create a new page and post building experience that makes writing rich posts effortless, and has “blocks” to make it easy what today might take shortcodes, custom HTML, or “mystery meat” embed discovery."
]
}
}
}
],
Expand Down
10 changes: 4 additions & 6 deletions core-blocks/test/fixtures/core__quote__style-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
{
"children": {
"type": "p",
"key": null,
"ref": null,
"props": {
"children": "There is no greater agony than bearing an untold story inside you."
},
"_owner": null,
"_store": {}
"children": [
"There is no greater agony than bearing an untold story inside you."
]
}
}
}
],
Expand Down
4 changes: 3 additions & 1 deletion core-blocks/test/fixtures/core__subhead.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"This is a ",
{
"type": "em",
"children": "subhead"
"children": [
"subhead"
]
},
"."
]
Expand Down
Loading

0 comments on commit 1a0a3ba

Please sign in to comment.