@wordpress/block-editor
Version:
8 lines (7 loc) • 2.29 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/hooks/line-height.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LineHeightControl from '../components/line-height-control';\nimport { cleanEmptyObject } from './utils';\nimport { useSettings } from '../components/use-settings';\n\nexport const LINE_HEIGHT_SUPPORT_KEY = 'typography.lineHeight';\n\n/**\n * Inspector control panel containing the line height related configuration\n *\n * @param {Object} props\n *\n * @return {Element} Line height edit element.\n */\nexport function LineHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newLineHeightValue ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tlineHeight: newLineHeightValue,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\treturn (\n\t\t<LineHeightControl\n\t\t\t__unstableInputWidth=\"100%\"\n\t\t\tvalue={ style?.typography?.lineHeight }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if line-height settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsLineHeightDisabled( { name: blockName } = {} ) {\n\tconst [ isEnabled ] = useSettings( 'typography.lineHeight' );\n\n\treturn (\n\t\t! isEnabled || ! hasBlockSupport( blockName, LINE_HEIGHT_SUPPORT_KEY )\n\t);\n}\n"],
"mappings": ";AAGA,SAAS,uBAAuB;AAKhC,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AA6B1B;AA3BK,IAAM,0BAA0B;AAShC,SAAS,eAAgB,OAAQ;AACvC,QAAM;AAAA,IACL,YAAY,EAAE,MAAM;AAAA,IACpB;AAAA,EACD,IAAI;AAEJ,QAAM,WAAW,CAAE,uBAAwB;AAC1C,UAAM,WAAW;AAAA,MAChB,GAAG;AAAA,MACH,YAAY;AAAA,QACX,GAAG,OAAO;AAAA,QACV,YAAY;AAAA,MACb;AAAA,IACD;AAEA,kBAAe,EAAE,OAAO,iBAAkB,QAAS,EAAE,CAAE;AAAA,EACxD;AACA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,sBAAqB;AAAA,MACrB,OAAQ,OAAO,YAAY;AAAA,MAC3B;AAAA,MACA,MAAK;AAAA;AAAA,EACN;AAEF;AAQO,SAAS,wBAAyB,EAAE,MAAM,UAAU,IAAI,CAAC,GAAI;AACnE,QAAM,CAAE,SAAU,IAAI,YAAa,uBAAwB;AAE3D,SACC,CAAE,aAAa,CAAE,gBAAiB,WAAW,uBAAwB;AAEvE;",
"names": []
}