schlechtenburg/packages/rich-text/lib/get-text-content.ts
2024-10-08 09:15:26 +02:00

18 lines
464 B
TypeScript

/**
* Internal dependencies
*/
import { OBJECT_REPLACEMENT_CHARACTER } from './special-characters';
import { RichTextValue } from './types';
/**
* Get the textual content of a Rich Text value. This is similar to
* `Element.textContent`.
*
* @param {RichTextValue} value Value to use.
*
* @return {string} The text content.
*/
export function getTextContent( { text }: RichTextValue ): string {
return text.replace( OBJECT_REPLACEMENT_CHARACTER, '' );
}