@wordpress/block-editor
Version:
8 lines (7 loc) • 2.29 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/rich-text/utils.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport { createBlock } from '@wordpress/blocks';\n\nexport function addActiveFormats( value, activeFormats ) {\n\tif ( activeFormats?.length ) {\n\t\tlet index = value.formats.length;\n\n\t\twhile ( index-- ) {\n\t\t\tvalue.formats[ index ] = [\n\t\t\t\t...activeFormats,\n\t\t\t\t...( value.formats[ index ] || [] ),\n\t\t\t];\n\t\t}\n\t}\n}\n\n/**\n * Get the multiline tag based on the multiline prop.\n *\n * @param {?(string|boolean)} multiline The multiline prop.\n *\n * @return {string | undefined} The multiline tag.\n */\nexport function getMultilineTag( multiline ) {\n\tif ( multiline !== true && multiline !== 'p' && multiline !== 'li' ) {\n\t\treturn;\n\t}\n\n\treturn multiline === true ? 'p' : multiline;\n}\n\nexport function getAllowedFormats( { allowedFormats, disableFormats } ) {\n\tif ( disableFormats ) {\n\t\treturn getAllowedFormats.EMPTY_ARRAY;\n\t}\n\n\treturn allowedFormats;\n}\n\ngetAllowedFormats.EMPTY_ARRAY = [];\n\n/**\n * Creates a link from pasted URL.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function createLinkInParagraph( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n"],
"mappings": ";AAGA,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAgDd;AA9CP,SAAS,iBAAkB,OAAO,eAAgB;AACxD,MAAK,eAAe,QAAS;AAC5B,QAAI,QAAQ,MAAM,QAAQ;AAE1B,WAAQ,SAAU;AACjB,YAAM,QAAS,KAAM,IAAI;AAAA,QACxB,GAAG;AAAA,QACH,GAAK,MAAM,QAAS,KAAM,KAAK,CAAC;AAAA,MACjC;AAAA,IACD;AAAA,EACD;AACD;AASO,SAAS,gBAAiB,WAAY;AAC5C,MAAK,cAAc,QAAQ,cAAc,OAAO,cAAc,MAAO;AACpE;AAAA,EACD;AAEA,SAAO,cAAc,OAAO,MAAM;AACnC;AAEO,SAAS,kBAAmB,EAAE,gBAAgB,eAAe,GAAI;AACvE,MAAK,gBAAiB;AACrB,WAAO,kBAAkB;AAAA,EAC1B;AAEA,SAAO;AACR;AAEA,kBAAkB,cAAc,CAAC;AAS1B,SAAS,sBAAuB,KAAK,WAAY;AACvD,QAAM,OAAO,oBAAC,OAAE,MAAO,KAAQ,eAAK;AACpC;AAAA,IACC,YAAa,kBAAkB,EAAE,SAAS,eAAgB,IAAK,EAAE,CAAE;AAAA,EACpE;AACD;",
"names": []
}