UNPKG

@wordpress/block-library

Version:
1 lines • 3.41 kB
{"version":3,"file":"edit.mjs","names":["ToolsPanel","ToolsPanelItem"],"sources":["../../src/more/edit.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToggleControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tPlainText,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { getDefaultBlockName, createBlock } from '@wordpress/blocks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst DEFAULT_TEXT = __( 'Read more' );\n\nexport default function MoreEdit( {\n\tattributes: { customText, noTeaser },\n\tinsertBlocksAfter,\n\tsetAttributes,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tnoTeaser: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Hide excerpt' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => noTeaser }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { noTeaser: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t'Hide the excerpt on the full content page'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tchecked={ !! noTeaser }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { noTeaser: ! noTeaser } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={ ( checked ) =>\n\t\t\t\t\t\t\t\tchecked\n\t\t\t\t\t\t\t\t\t? __( 'The excerpt is hidden.' )\n\t\t\t\t\t\t\t\t\t: __( 'The excerpt is visible.' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...useBlockProps() }>\n\t\t\t\t<PlainText\n\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\taria-label={ __( '\"Read more\" text' ) }\n\t\t\t\t\tvalue={ customText }\n\t\t\t\t\tplaceholder={ DEFAULT_TEXT }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { customText: value } )\n\t\t\t\t\t}\n\t\t\t\t\tdisableLineBreaks\n\t\t\t\t\t__unstableOnSplitAtEnd={\n\t\t\t\t\t\tinsertBlocksAfter\n\t\t\t\t\t\t\t? () =>\n\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAcA,MAAM,eAAe,GAAI,WAAY;AAErC,SAAwB,SAAU,EACjC,YAAY,EAAE,YAAY,YAC1B,mBACA,iBACG;CACH,MAAM,oBAAoB,+BAA+B;CAEzD,OACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,mBAAD,EAAA,UACC,oBAACA,0BAAD;EACC,OAAQ,GAAI,UAAW;EACvB,gBAAiB;GAChB,cAAe,EACd,UAAU,MACX,CAAE;EACH;EACoB;EAEpB,UAAA,oBAACC,8BAAD;GACC,OAAQ,GAAI,cAAe;GAC3B,kBAAA;GACA,gBAAiB;GACjB,kBACC,cAAe,EAAE,UAAU,MAAM,CAAE;GAGpC,UAAA,oBAAC,eAAD;IACC,OAAQ,GACP,2CACD;IACA,SAAU,CAAC,CAAE;IACb,gBACC,cAAe,EAAE,UAAU,CAAE,SAAS,CAAE;IAEzC,OAAS,YACR,UACG,GAAI,wBAAyB,IAC7B,GAAI,yBAA0B;GAElC,CAAA;EACc,CAAA;CACL,CAAA,EACM,CAAA,GACnB,oBAAC,OAAD;EAAK,GAAK,cAAc;EACvB,UAAA,oBAAC,WAAD;GACC,uBAAwB;GACxB,SAAQ;GACR,cAAa,GAAI,oBAAmB;GACpC,OAAQ;GACR,aAAc;GACd,WAAa,UACZ,cAAe,EAAE,YAAY,MAAM,CAAE;GAEtC,mBAAA;GACA,wBACC,0BAEG,kBACC,YAAa,oBAAoB,CAAE,CACpC,IACA,KAAA;EAEJ,CAAA;CACG,CAAA,CACJ,EAAA,CAAA;AAEJ"}