@wordpress/block-editor
Version:
8 lines (7 loc) • 2.42 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/rich-text/content.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { RawHTML } from '@wordpress/element';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport RichText from './';\n\n/**\n * Internal dependencies\n */\nimport { getMultilineTag } from './utils';\n\nexport function valueToHTMLString( value, multiline ) {\n\tif ( RichText.isEmpty( value ) ) {\n\t\tconst multilineTag = getMultilineTag( multiline );\n\t\treturn multilineTag ? `<${ multilineTag }></${ multilineTag }>` : '';\n\t}\n\n\tif ( Array.isArray( value ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\t\treturn childrenSource.toHTML( value );\n\t}\n\n\t// To do: deprecate string type.\n\tif ( typeof value === 'string' ) {\n\t\treturn value;\n\t}\n\n\t// To do: create a toReactComponent method on RichTextData, which we\n\t// might in the future also use for the editable tree. See\n\t// https://github.com/WordPress/gutenberg/pull/41655.\n\treturn value.toHTMLString();\n}\n\nexport function Content( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\tformat,\n\t...props\n} ) {\n\tvalue = <RawHTML>{ valueToHTMLString( value, multiline ) }</RawHTML>;\n\treturn Tag ? <Tag { ...props }>{ value }</Tag> : value;\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,oBAA2C;AAC3C,wBAAuB;AAKvB,eAAqB;AAKrB,mBAAgC;AAoCvB;AAlCF,SAAS,kBAAmB,OAAO,WAAY;AACrD,MAAK,SAAAA,QAAS,QAAS,KAAM,GAAI;AAChC,UAAM,mBAAe,8BAAiB,SAAU;AAChD,WAAO,eAAe,IAAK,YAAa,MAAO,YAAa,MAAM;AAAA,EACnE;AAEA,MAAK,MAAM,QAAS,KAAM,GAAI;AAC7B,0BAAAC,SAAY,uDAAuD;AAAA,MAClE,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM;AAAA,IACP,CAAE;AACF,WAAO,cAAAC,SAAe,OAAQ,KAAM;AAAA,EACrC;AAGA,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO;AAAA,EACR;AAKA,SAAO,MAAM,aAAa;AAC3B;AAEO,SAAS,QAAS;AAAA,EACxB;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,UAAQ,4CAAC,0BAAU,4BAAmB,OAAO,SAAU,GAAG;AAC1D,SAAO,MAAM,4CAAC,OAAM,GAAG,OAAU,iBAAO,IAAS;AAClD;",
"names": ["RichText", "deprecated", "childrenSource"]
}