-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Table Block: Support rowspan attribute in table HTML, including when …
…pasting (#46629) * Table Block: Support rowspan attribute in table HTML, including when pasting * Updated normalize function and add unit tests * Move colspan test to integration tests * Revert unit test for colspan * Add unit test for rowspan * Add integration test for rowspan * Update integration test file name * remove space * Update cell text on unit test * Normalize rowspan/colspan in transforms * Fix unit test and utils * fix unit test
- Loading branch information
Showing
13 changed files
with
229 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { normalizeRowColSpan } from '../utils'; | ||
|
||
describe( 'normalizeRowColSpan', () => { | ||
it( 'should convert a value to a string', () => { | ||
expect( normalizeRowColSpan( 2 ) ).toBe( '2' ); | ||
expect( normalizeRowColSpan( '2' ) ).toBe( '2' ); | ||
expect( normalizeRowColSpan( 2.55 ) ).toBe( '2' ); | ||
expect( normalizeRowColSpan( '2.55' ) ).toBe( '2' ); | ||
} ); | ||
|
||
it( 'should return undefined for values not allowed as the rowspan/colspan attributes', () => { | ||
expect( normalizeRowColSpan( -2 ) ).toBe( undefined ); | ||
expect( normalizeRowColSpan( '-2' ) ).toBe( undefined ); | ||
expect( normalizeRowColSpan( 1 ) ).toBe( undefined ); | ||
expect( normalizeRowColSpan( '1' ) ).toBe( undefined ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Normalize the rowspan/colspan value. | ||
* Returns undefined if the parameter is not a positive number | ||
* or the default value (1) for rowspan/colspan. | ||
* | ||
* @param {number|undefined} rowColSpan rowspan/colspan value. | ||
* | ||
* @return {string|undefined} normalized rowspan/colspan value. | ||
*/ | ||
export function normalizeRowColSpan( rowColSpan ) { | ||
const parsedValue = parseInt( rowColSpan, 10 ); | ||
if ( ! Number.isInteger( parsedValue ) ) { | ||
return undefined; | ||
} | ||
return parsedValue < 0 || parsedValue === 1 | ||
? undefined | ||
: parsedValue.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
aa64669
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in aa64669.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4063026587
📝 Reported issues:
specs/editor/various/multi-block-selection.test.js
specs/editor/various/multi-block-selection.test.js
specs/editor/various/inserting-blocks.test.js
specs/editor/various/block-hierarchy-navigation.test.js