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

Is there a way to introduce HTML in notice message? #59546

Open
manooweb opened this issue Mar 4, 2024 · 0 comments
Open

Is there a way to introduce HTML in notice message? #59546

manooweb opened this issue Mar 4, 2024 · 0 comments
Labels
[Package] Notices /packages/notices [Type] Bug An existing feature does not function as intended

Comments

@manooweb
Copy link
Contributor

manooweb commented Mar 4, 2024

Description

In classic editor we can introduce some limited HTML tags (<br>, <code>, <a>) by using wp_kses() function for example

image

In block editor these tags are always converted to text.

image

Is there a way to do that correctly in block editor or is it something that will be never possible?

Step-by-step reproduction instructions

  1. create a React component which create a warning notice for example
import { useDispatch } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices';

const DisplayNotice = ( { notice } ) => {


	const { createWarningNotice } = useDispatch( noticesStore );

	createWarningNotice(
		notice,
		{
			explicitDismiss: true,
		}
	);

	/**
	 * Renderless component.
	 */
	return( null );
}

export default DisplayNotice;
  1. Use the component somewhere in the block editor code by passing a notice message containing HTML tags
const notice =
`አማርኛ (<code>am</code>) is not available as target language with DeepL.<br>
Afrikaans (<code>af</code>) is not available as target language with DeepL.`;
 
...

<DisplayNotice notice={ notice } />
  1. The notice should be displayed like this
    image

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

No

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@manooweb manooweb added the [Type] Bug An existing feature does not function as intended label Mar 4, 2024
@manooweb manooweb changed the title Is there a way to introduced HTML in notice message? Mar 4, 2024
@t-hamano t-hamano added [Package] Components /packages/components [Package] Notices /packages/notices and removed [Package] Components /packages/components labels Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Notices /packages/notices [Type] Bug An existing feature does not function as intended
2 participants