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

[RNMobile] Highlight text: Check if style attribute value is defined during filtering #38670

Merged
merged 3 commits into from
Feb 9, 2022
Merged
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
2 changes: 1 addition & 1 deletion packages/format-library/src/text-color/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const textColor = {
__unstableFilterAttributeValue( key, value ) {
if ( key !== 'style' ) return value;
// We need to remove the extra spaces within the styles on mobile
const newValue = value.replace( / /g, '' );
const newValue = value?.replace( / /g, '' );
// We should not add a background-color if it's already set
if ( newValue && newValue.includes( 'background-color' ) )
return newValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ exports[`Text color creates a paragraph block with the text color format 1`] = `
<p>Hello <mark style=\\"background-color:rgba(0,0,0,0);color:#cf2e2e\\" class=\\"has-inline-color has-vivid-red-color\\">this is a test</mark></p>
<!-- /wp:paragraph -->"
`;

exports[`Text color supports old text color format using "span" tag 1`] = `
"<!-- wp:paragraph -->
<p>this <span class=\\"has-inline-color has-green-color\\">is</span> <span class=\\"has-inline-color has-red-color\\">test</span></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><span style=\\"color:#08a5e9\\" class=\\"has-inline-color\\">this is a test</span></p>
<!-- /wp:paragraph -->"
`;
14 changes: 14 additions & 0 deletions packages/format-library/src/text-color/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,18 @@ describe( 'Text color', () => {

expect( getEditorHtml() ).toMatchSnapshot();
} );

it( 'supports old text color format using "span" tag', async () => {
await initializeEditor( {
initialHtml: `<!-- wp:paragraph -->
<p>this <span class="has-inline-color has-green-color">is</span> <span class="has-inline-color has-red-color">test</span></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><span style="color:#08a5e9" class="has-inline-color">this is a test</span></p>
<!-- /wp:paragraph -->`,
} );

expect( getEditorHtml() ).toMatchSnapshot();
} );
} );
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For each user feature we should also add a importance categorization label to i

- [*] Image block: Replacing the media for an image set as featured prompts to update the featured image [#34666]
- [***] Font size and line-height support for text-based blocks used in block-based themes [#38205]
- [*] Highlight text: Check if style attribute value is defined during filtering [#38670]

## 1.70.2

Expand Down