From 1ccfe6f195d3f5f09515400ee19c33c60d34fe27 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 19 Oct 2018 14:07:04 -0600 Subject: [PATCH 01/39] Adjust document outline to use an a tag vs button --- packages/editor/src/components/document-outline/item.js | 5 +++-- packages/editor/src/components/document-outline/style.scss | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index 3db43383c5a5f..8167fb247ea2a 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -29,7 +29,8 @@ const TableOfContentsItem = ( { } ) } > - + ); diff --git a/packages/editor/src/components/document-outline/style.scss b/packages/editor/src/components/document-outline/style.scss index 336f53d196687..5cd918301dffc 100644 --- a/packages/editor/src/components/document-outline/style.scss +++ b/packages/editor/src/components/document-outline/style.scss @@ -11,6 +11,10 @@ display: flex; margin: 4px 0; + a { + text-decoration: none; + } + .document-outline__emdash::before { color: $light-gray-500; margin-right: 4px; From 474535f64b8353f284059a46be3b98eeb09fea16 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sun, 28 Oct 2018 08:33:54 -0600 Subject: [PATCH 02/39] target href links directly to page anchors, remove onClick handler --- .../src/components/document-outline/index.js | 15 +++------------ .../src/components/document-outline/item.js | 5 ++--- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index ad2ca5c2b6181..764405582df4f 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -8,7 +8,7 @@ import { countBy, flatMap, get } from 'lodash'; */ import { __ } from '@wordpress/i18n'; import { compose } from '@wordpress/compose'; -import { withSelect, withDispatch } from '@wordpress/data'; +import { withSelect } from '@wordpress/data'; /** * Internal dependencies @@ -61,7 +61,7 @@ const computeOutlineHeadings = ( blocks = [], path = [] ) => { const isEmptyHeading = ( heading ) => ! heading.attributes.content || heading.attributes.content.length === 0; -export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupported } ) => { +export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { const headings = computeOutlineHeadings( blocks ); if ( headings.length < 1 ) { @@ -70,9 +70,6 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte let prevHeadingLevel = 1; - // Select the corresponding block in the main editor - // when clicking on a heading item from the list. - const onSelectHeading = ( clientId ) => onSelect( clientId ); const focusTitle = () => { // Not great but it's the simplest way to focus the title right now. const titleNode = document.querySelector( '.editor-post-title__input' ); @@ -115,8 +112,8 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte key={ index } level={ `H${ item.level }` } isValid={ isValid } - onClick={ () => onSelectHeading( item.clientId ) } path={ item.path } + target={ item.clientId } > { item.isEmpty ? emptyHeadingContent : @@ -147,11 +144,5 @@ export default compose( blocks: getBlocks(), isTitleSupported: get( postType, [ 'supports', 'title' ], false ), }; - } ), - withDispatch( ( dispatch ) => { - const { selectBlock } = dispatch( 'core/editor' ); - return { - onSelect: selectBlock, - }; } ) )( DocumentOutline ); diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index 8167fb247ea2a..83ec0ba14db7d 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -17,8 +17,8 @@ const TableOfContentsItem = ( { children, isValid, level, - onClick, path = [], + target, } ) => (
  • { From da9311c52fd3f396ecf56d0638fd3fe366e61083 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Tue, 30 Oct 2018 08:16:05 -0600 Subject: [PATCH 03/39] update test snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 a038d12930951..28a953c4b0750 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 @@ -9,8 +9,8 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` isValid={true} key="0" level="H2" - onClick={[Function]} path={Array []} + target="3fc15d2e-5d52-40b0-9f54-9b9562adeac0" > Date: Sat, 3 Nov 2018 22:28:13 -0600 Subject: [PATCH 04/39] update snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 28a953c4b0750..ffd73686aa13c 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="3fc15d2e-5d52-40b0-9f54-9b9562adeac0" + target="765e36f0-afeb-4554-87d2-ae1f634dadee" > Date: Sat, 3 Nov 2018 22:39:03 -0600 Subject: [PATCH 05/39] better titleNode targeting --- .../src/components/document-outline/index.js | 14 ++++---------- .../editor/src/components/document-outline/item.js | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 764405582df4f..b876c1f17eef9 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -70,14 +70,8 @@ export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { let prevHeadingLevel = 1; - const focusTitle = () => { - // Not great but it's the simplest way to focus the title right now. - const titleNode = document.querySelector( '.editor-post-title__input' ); - if ( titleNode ) { - titleNode.focus(); - } - }; - + // Not great but it's the simplest way to locate the title right now. + const titleNode = document.querySelector( '.editor-post-title__input' ); const hasTitle = isTitleSupported && title; const countByLevel = countBy( headings, 'level' ); const hasMultipleH1 = countByLevel[ 1 ] > 1; @@ -89,7 +83,7 @@ export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { { title } @@ -113,7 +107,7 @@ export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { level={ `H${ item.level }` } isValid={ isValid } path={ item.path } - target={ item.clientId } + target={ '#block-' + item.clientId } > { item.isEmpty ? emptyHeadingContent : diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index 83ec0ba14db7d..e00fc08c4272c 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -30,7 +30,7 @@ const TableOfContentsItem = ( { ) } > From 3c2a50094a46891d05bb81f62583fd36e6822f53 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sat, 3 Nov 2018 22:39:57 -0600 Subject: [PATCH 06/39] update snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 ffd73686aa13c..a7f2393e5d888 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="765e36f0-afeb-4554-87d2-ae1f634dadee" + target="#block-29532918-0ff3-42da-b8c7-455f7af120ea" > Date: Sun, 4 Nov 2018 10:27:00 -0700 Subject: [PATCH 07/39] update snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 a7f2393e5d888..40ba3e1c79e4f 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="#block-29532918-0ff3-42da-b8c7-455f7af120ea" + target="#block-7033e374-b102-4ec5-a340-623f9c433e3f" > Date: Sat, 17 Nov 2018 22:33:16 -0700 Subject: [PATCH 08/39] Close the table of contents panel when a link is clicked --- packages/editor/src/components/document-outline/index.js | 4 +++- packages/editor/src/components/document-outline/item.js | 2 ++ packages/editor/src/components/table-of-contents/index.js | 2 +- packages/editor/src/components/table-of-contents/panel.js | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index b876c1f17eef9..25cf5c58b8b90 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -61,7 +61,7 @@ const computeOutlineHeadings = ( blocks = [], path = [] ) => { const isEmptyHeading = ( heading ) => ! heading.attributes.content || heading.attributes.content.length === 0; -export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { +export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } ) => { const headings = computeOutlineHeadings( blocks ); if ( headings.length < 1 ) { @@ -83,6 +83,7 @@ export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { { title } @@ -107,6 +108,7 @@ export const DocumentOutline = ( { blocks = [], title, isTitleSupported } ) => { level={ `H${ item.level }` } isValid={ isValid } path={ item.path } + close={ close } target={ '#block-' + item.clientId } > { item.isEmpty ? diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index e00fc08c4272c..fb20638d3c968 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -19,6 +19,7 @@ const TableOfContentsItem = ( { level, path = [], target, + close, } ) => (
  • { diff --git a/packages/editor/src/components/table-of-contents/index.js b/packages/editor/src/components/table-of-contents/index.js index 7930b33276b25..14f40c8266726 100644 --- a/packages/editor/src/components/table-of-contents/index.js +++ b/packages/editor/src/components/table-of-contents/index.js @@ -25,7 +25,7 @@ function TableOfContents( { hasBlocks } ) { disabled={ ! hasBlocks } /> ) } - renderContent={ () => } + renderContent={ ( { onClose } ) => } /> ); } diff --git a/packages/editor/src/components/table-of-contents/panel.js b/packages/editor/src/components/table-of-contents/panel.js index e9f2cc188fd4e..634fab7ba7556 100644 --- a/packages/editor/src/components/table-of-contents/panel.js +++ b/packages/editor/src/components/table-of-contents/panel.js @@ -11,7 +11,7 @@ import { withSelect } from '@wordpress/data'; import WordCount from '../word-count'; import DocumentOutline from '../document-outline'; -function TableOfContentsPanel( { headingCount, paragraphCount, numberOfBlocks } ) { +function TableOfContentsPanel( { headingCount, paragraphCount, numberOfBlocks, close } ) { return (
    { __( 'Document Outline' ) } - + ) } From 841bf0f8a624672c30e8856db889f5077eab0506 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sat, 17 Nov 2018 22:37:47 -0700 Subject: [PATCH 09/39] add deterministic block id to tests --- .../editor/src/components/document-outline/test/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/components/document-outline/test/index.js b/packages/editor/src/components/document-outline/test/index.js index a3fe67f9eab94..88e5e50d3a129 100644 --- a/packages/editor/src/components/document-outline/test/index.js +++ b/packages/editor/src/components/document-outline/test/index.js @@ -78,7 +78,11 @@ describe( 'DocumentOutline', () => { } ); it( 'should not render when no heading blocks provided', () => { - const blocks = [ paragraph ]; + const blocks = [ paragraph ].map( ( block, index ) => { + // Change client IDs to a predictable value + block.clientId = '_clientId_' + index; + return block; + } ); const wrapper = shallow( ); expect( wrapper.html() ).toBe( null ); From 9082baaa15233e6aecd4ebe10854db8f10429f5d Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sat, 17 Nov 2018 22:39:39 -0700 Subject: [PATCH 10/39] remove redundant screen reader text --- packages/editor/src/components/document-outline/item.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index fb20638d3c968..5847ea4c86ea7 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -3,11 +3,6 @@ */ import classnames from 'classnames'; -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - /** * Internal dependencies */ @@ -51,7 +46,6 @@ const TableOfContentsItem = ( { { children } - { __( '(Click to focus this heading)' ) }
  • ); From b64b2ed2c42a1e7635f8ce5da5649b6feb99555e Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Tue, 20 Nov 2018 08:03:23 -0700 Subject: [PATCH 11/39] Adjust map to avoid mutating original object --- .../editor/src/components/document-outline/test/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/components/document-outline/test/index.js b/packages/editor/src/components/document-outline/test/index.js index 88e5e50d3a129..66941043c9c23 100644 --- a/packages/editor/src/components/document-outline/test/index.js +++ b/packages/editor/src/components/document-outline/test/index.js @@ -79,9 +79,8 @@ describe( 'DocumentOutline', () => { it( 'should not render when no heading blocks provided', () => { const blocks = [ paragraph ].map( ( block, index ) => { - // Change client IDs to a predictable value - block.clientId = '_clientId_' + index; - return block; + // Set client IDs to a predictable value. + return { ...block, clientId: '_clientId_' + index }; } ); const wrapper = shallow( ); From e4cc7cf2c8c75e30592b77e5fb898eb20fed7e05 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Tue, 20 Nov 2018 09:29:08 -0700 Subject: [PATCH 12/39] update snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 40ba3e1c79e4f..c115e51e380ff 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="#block-7033e374-b102-4ec5-a340-623f9c433e3f" + target="#block-c227357f-e92c-4369-83f5-9cf907fe3610" > Date: Tue, 20 Nov 2018 12:59:11 -0700 Subject: [PATCH 13/39] Update packages/editor/src/components/document-outline/index.js Co-Authored-By: adamsilverstein --- packages/editor/src/components/document-outline/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 25cf5c58b8b90..6e1e6dcb5d954 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -109,7 +109,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } isValid={ isValid } path={ item.path } close={ close } - target={ '#block-' + item.clientId } + target={ `'#block-${ item.clientId }` } > { item.isEmpty ? emptyHeadingContent : From 46e4e1f6a375f7c5ce212f409e4156ce3f5187b7 Mon Sep 17 00:00:00 2001 From: Matthew Riley MacPherson Date: Tue, 20 Nov 2018 12:59:39 -0700 Subject: [PATCH 14/39] Update packages/editor/src/components/document-outline/test/index.js remove leading _ Co-Authored-By: adamsilverstein --- packages/editor/src/components/document-outline/test/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/components/document-outline/test/index.js b/packages/editor/src/components/document-outline/test/index.js index 66941043c9c23..b5853defca183 100644 --- a/packages/editor/src/components/document-outline/test/index.js +++ b/packages/editor/src/components/document-outline/test/index.js @@ -80,7 +80,7 @@ describe( 'DocumentOutline', () => { it( 'should not render when no heading blocks provided', () => { const blocks = [ paragraph ].map( ( block, index ) => { // Set client IDs to a predictable value. - return { ...block, clientId: '_clientId_' + index }; + return { ...block, clientId: `clientId_${ index }` }; } ); const wrapper = shallow( ); From 0aaaaa0f3b5131879fd4ed8fad5705ed9235c39e Mon Sep 17 00:00:00 2001 From: Matthew Riley MacPherson Date: Tue, 20 Nov 2018 13:00:06 -0700 Subject: [PATCH 15/39] Update packages/editor/src/components/document-outline/index.js Co-Authored-By: adamsilverstein --- packages/editor/src/components/document-outline/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 6e1e6dcb5d954..f28078b6b22ce 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -84,7 +84,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } level={ __( 'Title' ) } isValid close={ close } - target={ '#' + titleNode.id } + target={ `#${ titleNode.id }` } > { title } From 273c7b481f52c0ef723c291df97704306da86f8c Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Mon, 26 Nov 2018 22:08:41 -0700 Subject: [PATCH 16/39] update snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 39ad92de72124..d8b8e5c30ee0e 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="#block-c227357f-e92c-4369-83f5-9cf907fe3610" + target="#block-891b5b38-c315-4f58-8af3-e20d65a11077" > Heading parent @@ -19,7 +19,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="1" level="H3" path={Array []} - target="#block-2fcca4f2-1b36-4c26-84ab-d82d0df58ee6" + target="#block-47c5ce02-fbce-4afe-b56d-74dfa2fdc301" > Heading child @@ -37,7 +37,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip key="0" level="H1" path={Array []} - target="#block-a0d34688-bc48-466e-956e-d7117e460a1c" + target="#block-c2795353-f8d9-43c5-b358-676ad51651af" > Heading 1
    Heading 1
    Date: Mon, 26 Nov 2018 22:13:43 -0700 Subject: [PATCH 17/39] update snapshots --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 d8b8e5c30ee0e..93a874c326a5b 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="#block-891b5b38-c315-4f58-8af3-e20d65a11077" + target="'#block-df1b3f2f-3137-4775-b687-5081bf737d57" > Heading parent @@ -19,7 +19,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="1" level="H3" path={Array []} - target="#block-47c5ce02-fbce-4afe-b56d-74dfa2fdc301" + target="'#block-d1c439fc-6fed-42e8-b2da-721989ba41ec" > Heading child @@ -37,7 +37,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip key="0" level="H1" path={Array []} - target="#block-c2795353-f8d9-43c5-b358-676ad51651af" + target="'#block-dc1ed171-ad8a-4474-baba-f8b128f1066a" > Heading 1
    Heading 1
    Date: Sun, 2 Dec 2018 22:24:38 -0700 Subject: [PATCH 18/39] update snapshot --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 93a874c326a5b..d4e501a501a2b 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="'#block-df1b3f2f-3137-4775-b687-5081bf737d57" + target="'#block-97a79701-9cef-49b2-af29-b6906c66ac4b" > Heading parent @@ -19,7 +19,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="1" level="H3" path={Array []} - target="'#block-d1c439fc-6fed-42e8-b2da-721989ba41ec" + target="'#block-b08cbcd6-452d-45ec-ad30-80ee9d56631d" > Heading child @@ -37,7 +37,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip key="0" level="H1" path={Array []} - target="'#block-dc1ed171-ad8a-4474-baba-f8b128f1066a" + target="'#block-5fcd0825-155b-4694-971f-b3c75bcc6b5b" > Heading 1
    Heading 1
    Date: Tue, 4 Dec 2018 13:46:16 -0700 Subject: [PATCH 19/39] update snapshots --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 d4e501a501a2b..15d697ed24074 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="'#block-97a79701-9cef-49b2-af29-b6906c66ac4b" + target="'#block-4831ae77-9be2-4794-9510-b4d6db6cd5ea" > Heading parent @@ -19,7 +19,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="1" level="H3" path={Array []} - target="'#block-b08cbcd6-452d-45ec-ad30-80ee9d56631d" + target="'#block-e0ef6a1e-3bce-46d4-93cb-2955d6913591" > Heading child @@ -37,7 +37,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip key="0" level="H1" path={Array []} - target="'#block-5fcd0825-155b-4694-971f-b3c75bcc6b5b" + target="'#block-b56e0f74-0285-4453-8b43-e524cd0bf933" > Heading 1
    Heading 1
    Date: Tue, 4 Dec 2018 15:26:35 -0700 Subject: [PATCH 20/39] fix up e2e tests --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- .../src/components/document-outline/test/index.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) 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 15d697ed24074..ee4b1bfbac4f7 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="'#block-4831ae77-9be2-4794-9510-b4d6db6cd5ea" + target="'#block-clientId_0" > Heading parent @@ -19,7 +19,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="1" level="H3" path={Array []} - target="'#block-e0ef6a1e-3bce-46d4-93cb-2955d6913591" + target="'#block-clientId_1" > Heading child @@ -37,7 +37,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip key="0" level="H1" path={Array []} - target="'#block-b56e0f74-0285-4453-8b43-e524cd0bf933" + target="'#block-clientId_0" > Heading 1
    Heading 1
    { describe( 'header blocks present', () => { it( 'should match snapshot', () => { - const blocks = [ headingParent, headingChild ]; + const blocks = [ headingParent, headingChild ].map( ( block, index ) => { + // Set client IDs to a predictable value. + return { ...block, clientId: `clientId_${ index }` }; + } ); const wrapper = shallow( ); expect( wrapper ).toMatchSnapshot(); @@ -111,7 +114,10 @@ describe( 'DocumentOutline', () => { } ); it( 'should render warnings for multiple h1 headings', () => { - const blocks = [ headingH1, paragraph, headingH1, paragraph ]; + const blocks = [ headingH1, paragraph, headingH1, paragraph ].map( ( block, index ) => { + // Set client IDs to a predictable value. + return { ...block, clientId: `clientId_${ index }` }; + } ); const wrapper = shallow( ); expect( wrapper ).toMatchSnapshot(); From e8aa8d2192befd30cecae94079fcaea13959542c Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Sun, 9 Dec 2018 10:34:53 -0600 Subject: [PATCH 21/39] Fix snapshots by removing single quotes from outline links --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 ee4b1bfbac4f7..96d50d7b8aa6e 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 @@ -10,7 +10,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="0" level="H2" path={Array []} - target="'#block-clientId_0" + target="#block-clientId_0" > Heading parent @@ -19,7 +19,7 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` key="1" level="H3" path={Array []} - target="'#block-clientId_1" + target="#block-clientId_1" > Heading child @@ -37,7 +37,7 @@ exports[`DocumentOutline header blocks present should render warnings for multip key="0" level="H1" path={Array []} - target="'#block-clientId_0" + target="#block-clientId_0" > Heading 1
    Heading 1
    Date: Sun, 9 Dec 2018 11:11:52 -0600 Subject: [PATCH 22/39] Update packages/editor/src/components/document-outline/index.js Co-Authored-By: adamsilverstein --- packages/editor/src/components/document-outline/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index c6b318e81e6a9..28ecb3fcbc362 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -112,7 +112,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } isValid={ isValid } path={ item.path } close={ close } - target={ `'#block-${ item.clientId }` } + target={ `#block-${ item.clientId }` } > { item.isEmpty ? emptyHeadingContent : From b85b4c9c942fe618b60b13baebdf2321d602b801 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sun, 9 Dec 2018 16:20:16 -0600 Subject: [PATCH 23/39] change target to href --- packages/editor/src/components/document-outline/index.js | 4 ++-- packages/editor/src/components/document-outline/item.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 28ecb3fcbc362..7148315e5e48a 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -87,7 +87,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } level={ __( 'Title' ) } isValid close={ close } - target={ `#${ titleNode.id }` } + href={ `#${ titleNode.id }` } > { title } @@ -112,7 +112,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } isValid={ isValid } path={ item.path } close={ close } - target={ `#block-${ item.clientId }` } + href={ `#block-${ item.clientId }` } > { item.isEmpty ? emptyHeadingContent : diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index 5847ea4c86ea7..d924d249ede74 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -13,7 +13,7 @@ const TableOfContentsItem = ( { isValid, level, path = [], - target, + href, close, } ) => (
  • From f0afad5aec0a4429e80212767130e6505d032f8f Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Sun, 9 Dec 2018 21:06:20 -0600 Subject: [PATCH 24/39] rename close -> closeOutline --- packages/editor/src/components/document-outline/index.js | 4 ++-- packages/editor/src/components/document-outline/item.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 7148315e5e48a..87d8c10642e76 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -86,7 +86,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } { title } @@ -111,7 +111,7 @@ export const DocumentOutline = ( { blocks = [], title, close, isTitleSupported } level={ `H${ item.level }` } isValid={ isValid } path={ item.path } - close={ close } + closeOutline={ close } href={ `#block-${ item.clientId }` } > { item.isEmpty ? diff --git a/packages/editor/src/components/document-outline/item.js b/packages/editor/src/components/document-outline/item.js index d924d249ede74..1c49f01350b8e 100644 --- a/packages/editor/src/components/document-outline/item.js +++ b/packages/editor/src/components/document-outline/item.js @@ -14,7 +14,7 @@ const TableOfContentsItem = ( { level, path = [], href, - close, + closeOutline, } ) => (
  • { From dd3f8b394ed27ae6ee5096c4f95e9b5148143c81 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 14 Dec 2018 09:49:03 -0700 Subject: [PATCH 25/39] update snapshots after property name changes --- .../document-outline/test/__snapshots__/index.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 96d50d7b8aa6e..8f79943b2f5d9 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 @@ -6,20 +6,20 @@ exports[`DocumentOutline header blocks present should match snapshot 1`] = ` >