@wordpress/block-library
Version:
Block library for the WordPress editor.
8 lines (7 loc) • 2.94 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/list-item/index.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { listItem as icon } from '@wordpress/icons';\nimport { privateApis } from '@wordpress/block-editor';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\ttransforms,\n\t[ unlock( privateApis ).requiresWrapperOnCopy ]: true,\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'breadcrumb' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\t},\n};\n\nif ( window.__experimentalContentOnlyInspectorFields ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'content',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'text',\n\t\t\tEdit: 'rich-text', // TODO: replace with custom component\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'content' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,YAAY,YAAY;AACjC,SAAS,mBAAmB;AAC5B,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,GAAG;AAAA,MACH,SAAS,WAAW,UAAU,kBAAkB;AAAA,IACjD;AAAA,EACD;AAAA,EACA;AAAA,EACA,CAAE,OAAQ,WAAY,EAAE,qBAAsB,GAAG;AAAA,EACjD,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,QAAQ,IAAI;AAEpB,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,gBAAgB,YAAa;AAC7C,aAAO;AAAA,IACR;AAAA,EACD;AACD;AAEA,IAAK,OAAO,0CAA2C;AACtD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,SAAU;AAAA,MACrB,MAAM;AAAA,MACN,MAAM;AAAA;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,SAAU;AAAA,EACrB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
"names": []
}