diff --git a/core-blocks/test/fixtures/core__freeform__undelimited.json b/core-blocks/test/fixtures/core__freeform__undelimited.json
index 72341f093f2fbc..1fd82536ad6ad0 100644
--- a/core-blocks/test/fixtures/core__freeform__undelimited.json
+++ b/core-blocks/test/fixtures/core__freeform__undelimited.json
@@ -4,7 +4,7 @@
"name": "core/freeform",
"isValid": true,
"attributes": {
- "content": "
"
diff --git a/core-blocks/test/fixtures/core__freeform__undelimited.serialized.html b/core-blocks/test/fixtures/core__freeform__undelimited.serialized.html
index 4fed04550b031c..311563acb4aa3f 100644
--- a/core-blocks/test/fixtures/core__freeform__undelimited.serialized.html
+++ b/core-blocks/test/fixtures/core__freeform__undelimited.serialized.html
@@ -1,4 +1,4 @@
+
HTML content
diff --git a/core-blocks/test/fixtures/core__paragraph__deprecated.json b/core-blocks/test/fixtures/core__paragraph__deprecated.json
index 4279147742265d..daf5da7008a224 100644
--- a/core-blocks/test/fixtures/core__paragraph__deprecated.json
+++ b/core-blocks/test/fixtures/core__paragraph__deprecated.json
@@ -4,17 +4,56 @@
"name": "core/paragraph",
"isValid": true,
"attributes": {
- "content": [
- {
- "key": "html",
- "ref": null,
- "props": {
- "children": "Unwrapped is
still valid."
- },
- "_owner": null,
- "_store": {}
- }
- ],
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ [
+ {
+ "type": "em"
+ }
+ ],
+ [
+ {
+ "type": "em"
+ }
+ ],
+ [
+ {
+ "type": "em"
+ }
+ ],
+ [
+ {
+ "type": "em"
+ }
+ ],
+ [
+ {
+ "type": "em"
+ }
+ ],
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Unwrapped is still valid."
+ },
"dropCap": false
},
"innerBlocks": [],
diff --git a/core-blocks/test/fixtures/core__table-cell.html b/core-blocks/test/fixtures/core__table-cell.html
new file mode 100644
index 00000000000000..3c61dc8dae08a0
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-cell.html
@@ -0,0 +1,3 @@
+
+
Version |
+
diff --git a/core-blocks/test/fixtures/core__table-cell.json b/core-blocks/test/fixtures/core__table-cell.json
new file mode 100644
index 00000000000000..6aefa8ae829fc9
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-cell.json
@@ -0,0 +1,23 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Version"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Version | "
+ }
+]
diff --git a/core-blocks/test/fixtures/core__table-cell.parsed.json b/core-blocks/test/fixtures/core__table-cell.parsed.json
new file mode 100644
index 00000000000000..8d00a0bca8050c
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-cell.parsed.json
@@ -0,0 +1,12 @@
+[
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n
Version | \n"
+ },
+ {
+ "attrs": {},
+ "innerHTML": "\n"
+ }
+]
diff --git a/core-blocks/test/fixtures/core__table-cell.serialized.html b/core-blocks/test/fixtures/core__table-cell.serialized.html
new file mode 100644
index 00000000000000..3c61dc8dae08a0
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-cell.serialized.html
@@ -0,0 +1,3 @@
+
+
Version |
+
diff --git a/core-blocks/test/fixtures/core__table-row.html b/core-blocks/test/fixtures/core__table-row.html
new file mode 100644
index 00000000000000..8492c2f390da2b
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-row.html
@@ -0,0 +1,15 @@
+
+
+
+ Version |
+
+
+
+ Musician |
+
+
+
+ Date |
+
+
+
diff --git a/core-blocks/test/fixtures/core__table-row.json b/core-blocks/test/fixtures/core__table-row.json
new file mode 100644
index 00000000000000..d2e7025a45528a
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-row.json
@@ -0,0 +1,72 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-row",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Version"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Version | "
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Musician"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Musician | "
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Date"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Date | "
+ }
+ ],
+ "originalContent": "
\n\t\n\n\t\n\n\t\n
"
+ }
+]
diff --git a/core-blocks/test/fixtures/core__table-row.parsed.json b/core-blocks/test/fixtures/core__table-row.parsed.json
new file mode 100644
index 00000000000000..218d47cf028568
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-row.parsed.json
@@ -0,0 +1,31 @@
+[
+ {
+ "blockName": "core/table-row",
+ "attrs": null,
+ "innerBlocks": [
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t
Version | \n\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t
Musician | \n\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t
Date | \n\t"
+ }
+ ],
+ "innerHTML": "\n
\n\t\n\n\t\n\n\t\n
\n"
+ },
+ {
+ "attrs": {},
+ "innerHTML": "\n"
+ }
+]
diff --git a/core-blocks/test/fixtures/core__table-row.serialized.html b/core-blocks/test/fixtures/core__table-row.serialized.html
new file mode 100644
index 00000000000000..1f6bfbaa17b9fe
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table-row.serialized.html
@@ -0,0 +1,13 @@
+
+
+Version |
+
+
+
+Musician |
+
+
+
+Date |
+
+
diff --git a/core-blocks/test/fixtures/core__table.html b/core-blocks/test/fixtures/core__table.html
index b9b41659e835aa..0144aeba894d29 100644
--- a/core-blocks/test/fixtures/core__table.html
+++ b/core-blocks/test/fixtures/core__table.html
@@ -1,3 +1,69 @@
-
Version | Musician | Date |
---|
.70 | No musician chosen. | May 27, 2003 |
1.0 | Miles Davis | January 3, 2004 |
Lots of versions skipped, see the full list | … | … |
4.4 | Clifford Brown | December 8, 2015 |
4.5 | Coleman Hawkins | April 12, 2016 |
4.6 | Pepper Adams | August 16, 2016 |
4.7 | Sarah Vaughan | December 6, 2016 |
+
+
+
+
+
+ Version |
+
+
+
+ Musician |
+
+
+
+ Date |
+
+
+
+
+
+
+
+ .70 |
+
+
+
+ No musician chosen. |
+
+
+
+ May 27, 2003 |
+
+
+
+
+
+
+
+ 1.0 |
+
+
+
+ Miles Davis |
+
+
+
+ January 3, 2004 |
+
+
+
+
+
+
+
+ Lots of versions skipped, see the full list |
+
+
+
+ … |
+
+
+
+ … |
+
+
+
+
+
diff --git a/core-blocks/test/fixtures/core__table.json b/core-blocks/test/fixtures/core__table.json
new file mode 100644
index 00000000000000..12e654b9039861
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table.json
@@ -0,0 +1,477 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table",
+ "isValid": true,
+ "attributes": {
+ "hasFixedLayout": false
+ },
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-row",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Version"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Version | "
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Musician"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Musician | "
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Date"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Date | "
+ }
+ ],
+ "originalContent": "
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
"
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/table-row",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://wordpress.org/news/2003/05/wordpress-now-available/"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://wordpress.org/news/2003/05/wordpress-now-available/"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://wordpress.org/news/2003/05/wordpress-now-available/"
+ }
+ }
+ ]
+ ],
+ "text": ".70"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
.70 | "
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "No musician chosen."
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
No musician chosen. | "
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "May 27, 2003"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
May 27, 2003 | "
+ }
+ ],
+ "originalContent": "
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
"
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/table-row",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://wordpress.org/news/2004/01/wordpress-10/"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://wordpress.org/news/2004/01/wordpress-10/"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://wordpress.org/news/2004/01/wordpress-10/"
+ }
+ }
+ ]
+ ],
+ "text": "1.0"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
1.0 | "
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "Miles Davis"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Miles Davis | "
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "text": "January 3, 2004"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
January 3, 2004 | "
+ }
+ ],
+ "originalContent": "
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
"
+ },
+ {
+ "clientId": "_clientId_3",
+ "name": "core/table-row",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ],
+ [
+ {
+ "type": "a",
+ "attributes": {
+ "href": "https://codex.wordpress.org/WordPress_Versions"
+ }
+ }
+ ]
+ ],
+ "text": "Lots of versions skipped, see the full list"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
Lots of versions skipped, see the full list | "
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null
+ ],
+ "text": "…"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
… | "
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/table-cell",
+ "isValid": true,
+ "attributes": {
+ "content": {
+ "formats": [
+ null
+ ],
+ "text": "…"
+ }
+ },
+ "innerBlocks": [],
+ "originalContent": "
… | "
+ }
+ ],
+ "originalContent": "
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
"
+ }
+ ],
+ "originalContent": "
\n\t\n\t\t\n\n\t\t\n\n\t\t\n\n\t\t\n\t\n
"
+ }
+]
diff --git a/core-blocks/test/fixtures/core__table.parsed.json b/core-blocks/test/fixtures/core__table.parsed.json
index 737ac5ea49098c..6c6c36f7817d44 100644
--- a/core-blocks/test/fixtures/core__table.parsed.json
+++ b/core-blocks/test/fixtures/core__table.parsed.json
@@ -2,8 +2,109 @@
{
"blockName": "core/table",
"attrs": null,
- "innerBlocks": [],
- "innerHTML": "\n
Version | Musician | Date |
---|
.70 | No musician chosen. | May 27, 2003 |
1.0 | Miles Davis | January 3, 2004 |
Lots of versions skipped, see the full list | … | … |
4.4 | Clifford Brown | December 8, 2015 |
4.5 | Coleman Hawkins | April 12, 2016 |
4.6 | Pepper Adams | August 16, 2016 |
4.7 | Sarah Vaughan | December 6, 2016 |
\n"
+ "innerBlocks": [
+ {
+ "blockName": "core/table-row",
+ "attrs": null,
+ "innerBlocks": [
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
Version | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
Musician | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
Date | \n\t\t\t"
+ }
+ ],
+ "innerHTML": "\n\t\t
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
\n\t\t"
+ },
+ {
+ "blockName": "core/table-row",
+ "attrs": null,
+ "innerBlocks": [
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
.70 | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
No musician chosen. | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
May 27, 2003 | \n\t\t\t"
+ }
+ ],
+ "innerHTML": "\n\t\t
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
\n\t\t"
+ },
+ {
+ "blockName": "core/table-row",
+ "attrs": null,
+ "innerBlocks": [
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
1.0 | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
Miles Davis | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
January 3, 2004 | \n\t\t\t"
+ }
+ ],
+ "innerHTML": "\n\t\t
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
\n\t\t"
+ },
+ {
+ "blockName": "core/table-row",
+ "attrs": null,
+ "innerBlocks": [
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
Lots of versions skipped, see the full list | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
… | \n\t\t\t"
+ },
+ {
+ "blockName": "core/table-cell",
+ "attrs": null,
+ "innerBlocks": [],
+ "innerHTML": "\n\t\t\t
… | \n\t\t\t"
+ }
+ ],
+ "innerHTML": "\n\t\t
\n\t\t\t\n\n\t\t\t\n\n\t\t\t\n\t\t
\n\t\t"
+ }
+ ],
+ "innerHTML": "\n
\n\t\n\t\t\n\n\t\t\n\n\t\t\n\n\t\t\n\t\n
\n"
},
{
"attrs": {},
diff --git a/core-blocks/test/fixtures/core__table.serialized.html b/core-blocks/test/fixtures/core__table.serialized.html
new file mode 100644
index 00000000000000..45891d295ff9fb
--- /dev/null
+++ b/core-blocks/test/fixtures/core__table.serialized.html
@@ -0,0 +1,57 @@
+
+
+
+Version |
+
+
+
+Musician |
+
+
+
+Date |
+
+
+
+
+
+.70 |
+
+
+
+No musician chosen. |
+
+
+
+May 27, 2003 |
+
+
+
+
+
+1.0 |
+
+
+
+Miles Davis |
+
+
+
+January 3, 2004 |
+
+
+
+
+
+Lots of versions skipped, see the full list |
+
+
+
+… |
+
+
+
+… |
+
+
+
diff --git a/core-blocks/text-columns/index.js b/core-blocks/text-columns/index.js
index 103d7f51121be5..1e967f9f35741f 100644
--- a/core-blocks/text-columns/index.js
+++ b/core-blocks/text-columns/index.js
@@ -49,7 +49,20 @@ export const settings = {
source: 'rich-text',
},
},
- default: [ {}, {} ],
+ default: [
+ {
+ children: {
+ text: '',
+ formats: [],
+ },
+ },
+ {
+ children: {
+ text: '',
+ formats: [],
+ },
+ },
+ ],
},
columns: {
type: 'number',
diff --git a/packages/blocks/src/api/index.js b/packages/blocks/src/api/index.js
index 95bb39f7f5b1d7..0f8ac42ce9098d 100644
--- a/packages/blocks/src/api/index.js
+++ b/packages/blocks/src/api/index.js
@@ -13,7 +13,7 @@ export {
getBlockAttributes,
parseWithAttributeSchema,
} from './parser';
-export { default as rawHandler, getPhrasingContentSchema } from './raw-handling';
+export { default as rawHandler, getPhrasingContentSchema, htmlToBlocks } from './raw-handling';
export {
default as serialize,
getBlockContent,
diff --git a/packages/blocks/src/api/parser.js b/packages/blocks/src/api/parser.js
index dcb01e11c16cd3..7c4d24b33b05bf 100644
--- a/packages/blocks/src/api/parser.js
+++ b/packages/blocks/src/api/parser.js
@@ -133,7 +133,15 @@ export function matcherFromSource( sourceConfig ) {
* @return {*} Attribute value.
*/
export function parseWithAttributeSchema( innerHTML, attributeSchema ) {
- return hpqParse( innerHTML, matcherFromSource( attributeSchema ) );
+ if ( attributeSchema.source === 'html' && ! attributeSchema.selector ) {
+ return innerHTML;
+ }
+
+ const template = document.createElement( 'template' );
+
+ template.innerHTML = innerHTML;
+
+ return hpqParse( template.content, matcherFromSource( attributeSchema ) );
}
/**
diff --git a/packages/blocks/src/api/rich-text-structure.js b/packages/blocks/src/api/rich-text-structure.js
index 1031f134d2cece..b4ddfa522ba9aa 100644
--- a/packages/blocks/src/api/rich-text-structure.js
+++ b/packages/blocks/src/api/rich-text-structure.js
@@ -6,7 +6,19 @@ import { find } from 'lodash';
const { TEXT_NODE, ELEMENT_NODE } = window.Node;
+function createElement( html ) {
+ const doc = document.implementation.createHTMLDocument( '' );
+
+ doc.body.innerHTML = html;
+
+ return doc.body;
+}
+
export function createWithSelection( element, range, multiline, settings ) {
+ if ( typeof element === 'string' ) {
+ element = createElement( element );
+ }
+
if ( ! multiline ) {
return createRecord( element, range, settings );
}
@@ -67,6 +79,8 @@ function createRecord( element, range, settings = {} ) {
filterString = ( string ) => string,
} = settings;
+ const filterStringComplete = ( string ) => filterString( string.replace( '\n', '' ) );
+
if (
element.nodeName === 'BR' &&
! removeNodeMatch( element ) &&
@@ -97,15 +111,15 @@ function createRecord( element, range, settings = {} ) {
if ( node.nodeType === TEXT_NODE ) {
if ( range ) {
if ( node === range.startContainer ) {
- accumulator.selection.start = accumulator.value.text.length + filterString( node.nodeValue.slice( 0, range.startOffset ) ).length;
+ accumulator.selection.start = accumulator.value.text.length + filterStringComplete( node.nodeValue.slice( 0, range.startOffset ) ).length;
}
if ( node === range.endContainer ) {
- accumulator.selection.end = accumulator.value.text.length + filterString( node.nodeValue.slice( 0, range.endOffset ) ).length;
+ accumulator.selection.end = accumulator.value.text.length + filterStringComplete( node.nodeValue.slice( 0, range.endOffset ) ).length;
}
}
- const text = filterString( node.nodeValue, accumulator.selection );
+ const text = filterStringComplete( node.nodeValue, accumulator.selection );
accumulator.value.text += text;
formats.push( ...Array( text.length ) );
} else if ( node.nodeType === ELEMENT_NODE ) {
diff --git a/packages/editor/src/components/document-outline/test/__snapshots__/index.js.snap b/packages/editor/src/components/document-outline/test/__snapshots__/index.js.snap
index b0d595e5d3e90b..4b2478e939a7a1 100644
--- a/packages/editor/src/components/document-outline/test/__snapshots__/index.js.snap
+++ b/packages/editor/src/components/document-outline/test/__snapshots__/index.js.snap
@@ -15,7 +15,12 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = `
@@ -50,7 +60,12 @@ exports[`DocumentOutline header blocks present should render warnings for multip
{
paragraph = createBlock( 'core/paragraph' );
headingH1 = createBlock( 'core/heading', {
- content: 'Heading 1',
+ content: {
+ formats: [],
+ text: 'Heading 1',
+ },
level: 1,
} );
headingParent = createBlock( 'core/heading', {
- content: 'Heading parent',
+ content: {
+ formats: [],
+ text: 'Heading parent',
+ },
level: 2,
} );
headingChild = createBlock( 'core/heading', {
- content: 'Heading child',
+ content: {
+ formats: [],
+ text: 'Heading child',
+ },
level: 3,
} );
diff --git a/test/integration/fixtures/apple-out.html b/test/integration/fixtures/apple-out.html
index 530bf8d34140c2..a7845c75a6a50c 100644
--- a/test/integration/fixtures/apple-out.html
+++ b/test/integration/fixtures/apple-out.html
@@ -19,25 +19,47 @@
-
-One
- |
-Two
- |
-Three
- |
-1
- |
-2
- |
-3
- |
-I
- |
-II
- |
-III
- |
+
+
+One
|
+
+
+
+Two
|
+
+
+
+Three
|
+
+
+
+
+
+1
|
+
+
+
+2
|
+
+
+
+3
|
+
+
+
+
+
+I
|
+
+
+
+II
|
+
+
+
+III
|
+
+
diff --git a/test/integration/fixtures/evernote-out.html b/test/integration/fixtures/evernote-out.html
index 4d8c6c43b9c99e..fe7fa0b93e5d44 100644
--- a/test/integration/fixtures/evernote-out.html
+++ b/test/integration/fixtures/evernote-out.html
@@ -1,7 +1,5 @@
-
This is a paragraph.
-
This is a link.
-
+
This is a paragraph.
This is a link.
@@ -17,13 +15,33 @@
-
One
- | Two
- | Three
- |
Four
- | Five
- | Six
- |
+
+
+One |
+
+
+
+Two |
+
+
+
+Three |
+
+
+
+
+
+Four |
+
+
+
+Five |
+
+
+
+Six |
+
+
diff --git a/test/integration/fixtures/google-docs-out.html b/test/integration/fixtures/google-docs-out.html
index a8d31000403d60..3411d19896ac1c 100644
--- a/test/integration/fixtures/google-docs-out.html
+++ b/test/integration/fixtures/google-docs-out.html
@@ -19,7 +19,47 @@
This is a heading
-
+
+
+One |
+
+
+
+Two |
+
+
+
+Three |
+
+
+
+
+
+1 |
+
+
+
+2 |
+
+
+
+3 |
+
+
+
+
+
+I |
+
+
+
+II |
+
+
+
+III |
+
+
diff --git a/test/integration/fixtures/markdown-out.html b/test/integration/fixtures/markdown-out.html
index cf83cf40050c4a..56529c2e02c070 100644
--- a/test/integration/fixtures/markdown-out.html
+++ b/test/integration/fixtures/markdown-out.html
@@ -7,8 +7,7 @@
This is a heading with italic
-
Preserve
-line breaks please.
+
Preserve
line breaks please.
@@ -28,7 +27,35 @@
Table
-
First Header | Second Header |
---|
Content from cell 1 | Content from cell 2 |
Content in the first column | Content in the second column |
+
+
+First Header |
+
+
+
+Second Header |
+
+
+
+
+
+Content from cell 1 |
+
+
+
+Content from cell 2 |
+
+
+
+
+
+Content in the first column |
+
+
+
+Content in the second column |
+
+
diff --git a/test/integration/fixtures/ms-word-online-out.html b/test/integration/fixtures/ms-word-online-out.html
index 7de40b0e330ef0..88d6a01904956e 100644
--- a/test/integration/fixtures/ms-word-online-out.html
+++ b/test/integration/fixtures/ms-word-online-out.html
@@ -3,7 +3,7 @@
-
This is a paragraph with a link.
+
This is a paragraph with a link.
@@ -15,7 +15,47 @@
-
One | Two | Three |
1 | 2 | 3 |
I | II | III |
+
+
+One |
+
+
+
+Two |
+
+
+
+Three |
+
+
+
+
+
+1 |
+
+
+
+2 |
+
+
+
+3 |
+
+
+
+
+
+I |
+
+
+
+II |
+
+
+
+III |
+
+
diff --git a/test/integration/fixtures/ms-word-out.html b/test/integration/fixtures/ms-word-out.html
index c53c5aaeba2e97..1b0b4b02b54d2a 100644
--- a/test/integration/fixtures/ms-word-out.html
+++ b/test/integration/fixtures/ms-word-out.html
@@ -1,11 +1,9 @@
-
This is a
-title
+
This is atitle
-
This is a
-subtitle
+
This is asubtitle
@@ -29,25 +27,47 @@
This is a heading level 2
-
- One
- |
- Two
- |
- Three
- |
- 1
- |
- 2
- |
- 3
- |
- I
- |
- II
- |
- III
- |
+
+
+ One |
+
+
+
+ Two |
+
+
+
+ Three |
+
+
+
+
+
+ 1 |
+
+
+
+ 2 |
+
+
+
+ 3 |
+
+
+
+
+
+ I |
+
+
+
+ II |
+
+
+
+ III |
+
+