Skip to content

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

@manooweb

Description

@manooweb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Package] Notices/packages/notices[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions