Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: absorb format boundaries into RichText toTree #11322

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ exports[`core/button block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Add text…"
aria-multiline="true"
class="wp-block-button__link editor-rich-text__tinymce"
class="wp-block-button__link editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</div>
<div
class="editor-rich-text__tinymce wp-block-button__link"
class="editor-rich-text__editable wp-block-button__link"
>
Add text…
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ exports[`core/heading block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Write heading…"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</h2>
<h2
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
Write heading…
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ exports[`core/list block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Write list…"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<li>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</li>
</ul>
<ul
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
<li>
Write list…
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ exports[`core/paragraph block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Empty block; start writing or type forward slash to choose a block"
aria-multiline="true"
class="wp-block-paragraph editor-rich-text__tinymce"
class="wp-block-paragraph editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</p>
<p
class="editor-rich-text__tinymce wp-block-paragraph"
class="editor-rich-text__editable wp-block-paragraph"
>
Start writing or type / to choose a block
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ exports[`core/preformatted block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Write preformatted text…"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</pre>
<pre
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
Write preformatted text…
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ exports[`core/pullquote block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Write quote…"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<p>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</p>
</div>
<div
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
<p>
Write quote…
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ exports[`core/quote block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Write quote…"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<p>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</p>
</div>
<div
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
<p>
Write quote…
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ exports[`core/text-columns block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="New Column"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</p>
<p
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
New Column
</p>
Expand All @@ -53,17 +53,17 @@ exports[`core/text-columns block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="New Column"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</p>
<p
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
New Column
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ exports[`core/verse block edit matches snapshot 1`] = `
aria-autocomplete="list"
aria-label="Write…"
aria-multiline="true"
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
>
<br
data-mce-bogus="1"
data-rich-text-padding="true"
/>
</pre>
<pre
class="editor-rich-text__tinymce"
class="editor-rich-text__editable"
>
Write…
</pre>
Expand Down
15 changes: 11 additions & 4 deletions packages/dom/src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,21 @@ export function isHorizontalEdge( container, isReverse ) {
// If confirmed to be at extent, traverse up through DOM, verifying that
// the node is at first or last child for reverse or forward respectively.
// Continue until container is reached.
const order = isReverse ? 'first' : 'last';
const order = isReverse ? 'previous' : 'next';

while ( node !== container ) {
const parentNode = node.parentNode;
if ( parentNode[ `${ order }Child` ] !== node ) {
let next = node[ `${ order }Sibling` ];

// Skip over empty text nodes.
while ( next && next.nodeType === TEXT_NODE && next.data === '' ) {
next = next[ `${ order }Sibling` ];
}

if ( next ) {
return false;
}

node = parentNode;
node = node.parentNode;
}

// If reached, range is assumed to be at edge.
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/__snapshots__/undo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`undo should undo typing after a pause 2`] = `

exports[`undo should undo typing after non input change 1`] = `
"<!-- wp:paragraph -->
<p>before keyboard <strong>after keyboard</strong></p>
<p>before keyboard <strong>after keyboard</strong></p>
<!-- /wp:paragraph -->"
`;

Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
getEditedPostContent,
createNewPost,
pressKeyWithModifier,
pressKeyTimes,
insertBlock,
} from '@wordpress/e2e-test-utils';

Expand Down Expand Up @@ -244,7 +243,8 @@ describe( 'Links', () => {
it( 'can be edited with collapsed selection', async () => {
await createAndReselectLink();
// Make a collapsed selection inside the link
await pressKeyTimes( 'ArrowRight', 3 );
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.press( 'ArrowRight' );
await moveMouse();
await page.click( 'button[aria-label="Edit"]' );
await waitForAutoFocus();
Expand Down
Loading