@wordpress/block-library 9.19.2 → 9.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/archives/edit.js +2 -2
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +66 -33
- package/build/audio/edit.js.map +1 -1
- package/build/avatar/index.js +8 -3
- package/build/avatar/index.js.map +1 -1
- package/build/button/edit.js +43 -16
- package/build/button/edit.js.map +1 -1
- package/build/categories/edit.js +3 -3
- package/build/categories/edit.js.map +1 -1
- package/build/comment-template/hooks.js +6 -0
- package/build/comment-template/hooks.js.map +1 -1
- package/build/cover/index.js +8 -1
- package/build/cover/index.js.map +1 -1
- package/build/embed/edit.js +4 -1
- package/build/embed/edit.js.map +1 -1
- package/build/image/constants.js +2 -1
- package/build/image/constants.js.map +1 -1
- package/build/image/edit.js +3 -2
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +98 -80
- package/build/image/image.js.map +1 -1
- package/build/navigation/edit/index.js +8 -4
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation-link/edit.js +27 -8
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-author/index.js +8 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/rss/edit.js +21 -1
- package/build/rss/edit.js.map +1 -1
- package/build/rss/index.js +7 -0
- package/build/rss/index.js.map +1 -1
- package/build/site-logo/index.js +8 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-title/edit.js +1 -1
- package/build/site-title/edit.js.map +1 -1
- package/build/social-links/index.js +1 -0
- package/build/social-links/index.js.map +1 -1
- package/build/table-of-contents/edit.js +50 -8
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +13 -4
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/table-of-contents/index.js +3 -0
- package/build/table-of-contents/index.js.map +1 -1
- package/build-module/archives/edit.js +2 -2
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +68 -35
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/avatar/index.js +8 -3
- package/build-module/avatar/index.js.map +1 -1
- package/build-module/button/edit.js +44 -17
- package/build-module/button/edit.js.map +1 -1
- package/build-module/categories/edit.js +3 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +6 -0
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/cover/index.js +8 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/edit.js +4 -1
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/image/constants.js +1 -0
- package/build-module/image/constants.js.map +1 -1
- package/build-module/image/edit.js +3 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +102 -84
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation/edit/index.js +8 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +28 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-author/index.js +8 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/rss/edit.js +22 -2
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/rss/index.js +7 -0
- package/build-module/rss/index.js.map +1 -1
- package/build-module/site-logo/index.js +8 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-title/edit.js +1 -1
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/social-links/index.js +1 -0
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table-of-contents/edit.js +52 -10
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +13 -4
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/table-of-contents/index.js +3 -0
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-style/editor-rtl.css +0 -9
- package/build-style/editor.css +0 -9
- package/build-style/image/editor-rtl.css +0 -9
- package/build-style/image/editor.css +0 -9
- package/package.json +35 -35
- package/src/archives/edit.js +2 -2
- package/src/audio/edit.js +84 -33
- package/src/avatar/block.json +8 -3
- package/src/button/edit.js +69 -24
- package/src/categories/edit.js +3 -3
- package/src/comment-template/hooks.js +14 -6
- package/src/cover/block.json +8 -1
- package/src/embed/edit.js +7 -1
- package/src/image/constants.js +1 -0
- package/src/image/edit.js +3 -3
- package/src/image/editor.scss +0 -13
- package/src/image/image.js +124 -134
- package/src/navigation/edit/index.js +4 -0
- package/src/navigation-link/edit.js +45 -11
- package/src/post-author/block.json +8 -1
- package/src/post-featured-image/edit.js +2 -1
- package/src/rss/block.json +7 -0
- package/src/rss/edit.js +21 -0
- package/src/rss/index.php +27 -9
- package/src/site-logo/block.json +8 -1
- package/src/site-title/edit.js +1 -1
- package/src/site-title/index.php +1 -1
- package/src/social-links/block.json +1 -0
- package/src/table-of-contents/block.json +3 -0
- package/src/table-of-contents/edit.js +45 -4
- package/src/table-of-contents/hooks.js +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockControls","BlockIcon","InspectorControls","store","blockEditorStore","useBlockProps","createBlock","Placeholder","ToggleControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useDispatch","useSelect","renderToString","__","useInstanceId","noticeStore","tableOfContents","icon","TableOfContentsList","linearToNestedHeadingList","useObserveHeadings","useToolsPanelDropdownMenuProps","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","TableOfContentsEdit","attributes","headings","onlyIncludeCurrentPage","clientId","setAttributes","blockProps","instanceId","createWarningNotice","showRedirectionPreventedNotice","event","preventDefault","id","type","canInsertList","select","getBlockRootClientId","canInsertBlockType","rootClientId","replaceBlocks","dropdownMenuProps","headingTree","toolbarControls","children","onClick","ordered","values","nestedHeadingList","inspectorControls","label","resetAll","hasValue","onDeselect","isShownByDefault","__nextHasNoMarginBottom","checked","onChange","value","help","length","instructions","disableLinkActivation"],"sources":["@wordpress/block-library/src/table-of-contents/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPlaceholder,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as noticeStore } from '@wordpress/notices';\nimport { tableOfContents as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {string} props.clientId\n * @param {(attributes: Object) => void} props.setAttributes\n *\n * @return {Component} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: { headings = [], onlyIncludeCurrentPage },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tuseObserveHeadings( clientId );\n\n\tconst blockProps = useBlockProps();\n\tconst instanceId = useInstanceId(\n\t\tTableOfContentsEdit,\n\t\t'table-of-contents'\n\t);\n\n\t// If a user clicks to a link prevent redirection and show a warning.\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = canInsertList && (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\tordered: true,\n\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tonlyIncludeCurrentPage: false,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! onlyIncludeCurrentPage }\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Include headings from all pages (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\tlabel={ __( 'Table of Contents' ) }\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ol>\n\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\tdisableLinkActivation\n\t\t\t\t\t\tonClick={ showRedirectionPreventedNotice }\n\t\t\t\t\t/>\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,SAAS,EACTC,iBAAiB,EACjBC,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SACCC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAAShB,KAAK,IAAIiB,WAAW,QAAQ,oBAAoB;AACzD,SAASC,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,QAAQ;AACxC,SAASC,yBAAyB,QAAQ,SAAS;AACnD,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,8BAA8B,QAAQ,gBAAgB;;AAE/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAY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IAC5B,oBACCxC,KAAA,CAAAF,SAAA;MAAA0B,QAAA,gBACC5B,IAAA;QAAA,GAAUW,UAAU;QAAAiB,QAAA,eACnB5B,IAAA,CAACrB,WAAW;UACXe,IAAI,eAAGM,IAAA,CAAC3B,SAAS;YAACqB,IAAI,EAAGA;UAAM,CAAE,CAAG;UACpCwC,KAAK,EAAG5C,EAAE,CAAE,mBAAoB,CAAG;UACnCuD,YAAY,EAAGvD,EAAE,CAChB,4GACD;QAAG,CACH;MAAC,CACE,CAAC,EACJ2C,iBAAiB;IAAA,CAClB,CAAC;EAEL;EAEA,oBACC7B,KAAA,CAAAF,SAAA;IAAA0B,QAAA,gBACC5B,IAAA;MAAA,GAAUW,UAAU;MAAAiB,QAAA,eACnB5B,IAAA;QAAA4B,QAAA,eACC5B,IAAA,CAACL,mBAAmB;UACnBqC,iBAAiB,EAAGN,WAAa;UACjCoB,qBAAqB;UACrBjB,OAAO,EAAGf;QAAgC,CAC1C;MAAC,CACC;IAAC,CACD,CAAC,EACJa,eAAe,EACfM,iBAAiB;EAAA,CAClB,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BlockControls","BlockIcon","InspectorControls","store","blockEditorStore","useBlockProps","createBlock","Placeholder","ToggleControl","SelectControl","ToolbarButton","ToolbarGroup","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useDispatch","useSelect","renderToString","__","useInstanceId","noticeStore","tableOfContents","icon","TableOfContentsList","linearToNestedHeadingList","useObserveHeadings","useToolsPanelDropdownMenuProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","TableOfContentsEdit","attributes","headings","onlyIncludeCurrentPage","maxLevel","clientId","setAttributes","blockProps","instanceId","createWarningNotice","showRedirectionPreventedNotice","event","preventDefault","id","type","canInsertList","select","getBlockRootClientId","canInsertBlockType","rootClientId","replaceBlocks","dropdownMenuProps","headingTree","toolbarControls","children","onClick","ordered","values","nestedHeadingList","inspectorControls","label","resetAll","undefined","hasValue","onDeselect","isShownByDefault","__nextHasNoMarginBottom","checked","onChange","value","help","__next40pxDefaultSize","options","parseInt","length","instructions","disableLinkActivation"],"sources":["@wordpress/block-library/src/table-of-contents/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPlaceholder,\n\tToggleControl,\n\tSelectControl,\n\tToolbarButton,\n\tToolbarGroup,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as noticeStore } from '@wordpress/notices';\nimport { tableOfContents as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings The list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {number|undefined} props.attributes.maxLevel The maximum heading level to include, or null to include all levels.\n * @param {string} props.clientId The client id.\n * @param {(attributes: Object) => void} props.setAttributes The set attributes function.\n *\n * @return {Component} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: { headings = [], onlyIncludeCurrentPage, maxLevel },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tuseObserveHeadings( clientId );\n\n\tconst blockProps = useBlockProps();\n\tconst instanceId = useInstanceId(\n\t\tTableOfContentsEdit,\n\t\t'table-of-contents'\n\t);\n\n\t// If a user clicks to a link prevent redirection and show a warning.\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = canInsertList && (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\tordered: true,\n\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\tresetAll={ () => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tonlyIncludeCurrentPage: false,\n\t\t\t\t\t\tmaxLevel: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! onlyIncludeCurrentPage }\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: false } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Include headings from all pages (if the post is paginated).'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => !! maxLevel }\n\t\t\t\t\tlabel={ __( 'Limit heading levels' ) }\n\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\tsetAttributes( { maxLevel: undefined } )\n\t\t\t\t\t}\n\t\t\t\t\tisShownByDefault\n\t\t\t\t>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Include headings down to level' ) }\n\t\t\t\t\t\tvalue={ maxLevel || '' }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'All levels' ) },\n\t\t\t\t\t\t\t{ value: '1', label: __( 'Heading 1' ) },\n\t\t\t\t\t\t\t{ value: '2', label: __( 'Heading 2' ) },\n\t\t\t\t\t\t\t{ value: '3', label: __( 'Heading 3' ) },\n\t\t\t\t\t\t\t{ value: '4', label: __( 'Heading 4' ) },\n\t\t\t\t\t\t\t{ value: '5', label: __( 'Heading 5' ) },\n\t\t\t\t\t\t\t{ value: '6', label: __( 'Heading 6' ) },\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tmaxLevel: value ? parseInt( value ) : undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\tmaxLevel\n\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t'Including all heading levels in the table of contents.'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t'Only include headings up to and including this level.'\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\tlabel={ __( 'Table of Contents' ) }\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ol>\n\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\tdisableLinkActivation\n\t\t\t\t\t\tonClick={ showRedirectionPreventedNotice }\n\t\t\t\t\t/>\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,SAAS,EACTC,iBAAiB,EACjBC,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SACCC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASjB,KAAK,IAAIkB,WAAW,QAAQ,oBAAoB;AACzD,SAASC,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,QAAQ;AACxC,SAASC,yBAAyB,QAAQ,SAAS;AACnD,SAASC,kBAAkB,QAAQ,SAAS;AAC5C,SAASC,8BAA8B,QAAQ,gBAAgB;;AAE/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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E,CACF,wDACA,CAAC,GACDA,EAAE,CACF,uDACA;QACH,CACD;MAAC,CACa,CAAC;IAAA,CACN;EAAC,CACK,CACnB;;EAED;EACA;EACA;EACA,IAAKiB,QAAQ,CAAC0C,MAAM,KAAK,CAAC,EAAG;IAC5B,oBACC/C,KAAA,CAAAE,SAAA;MAAAyB,QAAA,gBACC7B,IAAA;QAAA,GAAUY,UAAU;QAAAiB,QAAA,eACnB7B,IAAA,CAACtB,WAAW;UACXgB,IAAI,eAAGM,IAAA,CAAC5B,SAAS;YAACsB,IAAI,EAAGA;UAAM,CAAE,CAAG;UACpCyC,KAAK,EAAG7C,EAAE,CAAE,mBAAoB,CAAG;UACnC4D,YAAY,EAAG5D,EAAE,CAChB,4GACD;QAAG,CACH;MAAC,CACE,CAAC,EACJ4C,iBAAiB;IAAA,CAClB,CAAC;EAEL;EAEA,oBACChC,KAAA,CAAAE,SAAA;IAAAyB,QAAA,gBACC7B,IAAA;MAAA,GAAUY,UAAU;MAAAiB,QAAA,eACnB7B,IAAA;QAAA6B,QAAA,eACC7B,IAAA,CAACL,mBAAmB;UACnBsC,iBAAiB,EAAGN,WAAa;UACjCwB,qBAAqB;UACrBrB,OAAO,EAAGf;QAAgC,CAC1C;MAAC,CACC;IAAC,CACD,CAAC,EACJa,eAAe,EACfM,iBAAiB;EAAA,CAClB,CAAC;AAEL","ignoreList":[]}
|
|
@@ -16,8 +16,8 @@ function getLatestHeadings(select, clientId) {
|
|
|
16
16
|
const {
|
|
17
17
|
getBlockAttributes,
|
|
18
18
|
getBlockName,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
getBlocksByName,
|
|
20
|
+
getClientIdsOfDescendants
|
|
21
21
|
} = select(blockEditorStore);
|
|
22
22
|
|
|
23
23
|
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
@@ -29,11 +29,15 @@ function getLatestHeadings(select, clientId) {
|
|
|
29
29
|
const permalink = (_select$getPermalink = select('core/editor').getPermalink()) !== null && _select$getPermalink !== void 0 ? _select$getPermalink : null;
|
|
30
30
|
const isPaginated = getBlocksByName('core/nextpage').length !== 0;
|
|
31
31
|
const {
|
|
32
|
-
onlyIncludeCurrentPage
|
|
32
|
+
onlyIncludeCurrentPage,
|
|
33
|
+
maxLevel
|
|
33
34
|
} = (_getBlockAttributes = getBlockAttributes(clientId)) !== null && _getBlockAttributes !== void 0 ? _getBlockAttributes : {};
|
|
34
35
|
|
|
36
|
+
// Get post-content block client ID.
|
|
37
|
+
const [postContentClientId = ''] = getBlocksByName('core/post-content');
|
|
38
|
+
|
|
35
39
|
// Get the client ids of all blocks in the editor.
|
|
36
|
-
const allBlockClientIds =
|
|
40
|
+
const allBlockClientIds = getClientIdsOfDescendants(postContentClientId);
|
|
37
41
|
|
|
38
42
|
// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.
|
|
39
43
|
let tocPage = 1;
|
|
@@ -88,6 +92,11 @@ function getLatestHeadings(select, clientId) {
|
|
|
88
92
|
else if (!onlyIncludeCurrentPage || headingPage === tocPage) {
|
|
89
93
|
if (blockName === 'core/heading') {
|
|
90
94
|
const headingAttributes = getBlockAttributes(blockClientId);
|
|
95
|
+
|
|
96
|
+
// Skip headings that are deeper than maxLevel
|
|
97
|
+
if (maxLevel && headingAttributes.level > maxLevel) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
91
100
|
const canBeLinked = typeof headingPageLink === 'string' && typeof headingAttributes.anchor === 'string' && headingAttributes.anchor !== '';
|
|
92
101
|
latestHeadings.push({
|
|
93
102
|
// Convert line breaks to spaces, and get rid of HTML tags in the headings.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fastDeepEqual","useRegistry","__unstableStripHTML","stripHTML","useEffect","addQueryArgs","removeQueryArgs","store","blockEditorStore","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getClientIdsWithDescendants","getBlocksByName","permalink","getPermalink","isPaginated","length","onlyIncludeCurrentPage","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","latestHeadings","headingPage","headingPageLink","page","blockName","headingAttributes","canBeLinked","anchor","push","content","replace","level","link","observeCallback","dispatch","updateBlockAttributes","__unstableMarkNextChangeAsNotPersistent","attributes","headings","useObserveHeadings","registry","subscribe"],"sources":["@wordpress/block-library/src/table-of-contents/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useEffect } from '@wordpress/element';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction getLatestHeadings( select, clientId ) {\n\tconst {\n\t\tgetBlockAttributes,\n\t\tgetBlockName,\n\t\tgetClientIdsWithDescendants,\n\t\tgetBlocksByName,\n\t} = select( blockEditorStore );\n\n\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t// Blocks can be loaded into a *non-post* block editor, so to avoid\n\t// declaring @wordpress/editor as a dependency, we must access its\n\t// store by string. When the store is not available, editorSelectors\n\t// will be null, and the block's saved markup will lack permalinks.\n\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\tconst permalink = select( 'core/editor' ).getPermalink() ?? null;\n\n\tconst isPaginated = getBlocksByName( 'core/nextpage' ).length !== 0;\n\tconst { onlyIncludeCurrentPage } = getBlockAttributes( clientId ) ?? {};\n\n\t// Get the client ids of all blocks in the editor.\n\tconst allBlockClientIds = getClientIdsWithDescendants();\n\n\t// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.\n\tlet tocPage = 1;\n\n\tif ( isPaginated && onlyIncludeCurrentPage ) {\n\t\t// We can't use getBlockIndex because it only returns the index\n\t\t// relative to sibling blocks.\n\t\tconst tocIndex = allBlockClientIds.indexOf( clientId );\n\n\t\tfor ( const [\n\t\t\tblockIndex,\n\t\t\tblockClientId,\n\t\t] of allBlockClientIds.entries() ) {\n\t\t\t// If we've reached blocks after the Table of Contents, we've\n\t\t\t// finished calculating which page the block is on.\n\t\t\tif ( blockIndex >= tocIndex ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( getBlockName( blockClientId ) === 'core/nextpage' ) {\n\t\t\t\ttocPage++;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst latestHeadings = [];\n\n\t/** The page (of a paginated post) a heading will be part of. */\n\tlet headingPage = 1;\n\tlet headingPageLink = null;\n\n\t// If the core/editor store is available, we can add permalinks to the\n\t// generated table of contents.\n\tif ( typeof permalink === 'string' ) {\n\t\theadingPageLink = isPaginated\n\t\t\t? addQueryArgs( permalink, { page: headingPage } )\n\t\t\t: permalink;\n\t}\n\n\tfor ( const blockClientId of allBlockClientIds ) {\n\t\tconst blockName = getBlockName( blockClientId );\n\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\theadingPage++;\n\n\t\t\t// If we're only including headings from the current page (of\n\t\t\t// a paginated post), then exit the loop if we've reached the\n\t\t\t// pages after the one with the Table of Contents block.\n\t\t\tif ( onlyIncludeCurrentPage && headingPage > tocPage ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\theadingPageLink = addQueryArgs(\n\t\t\t\t\tremoveQueryArgs( permalink, [ 'page' ] ),\n\t\t\t\t\t{ page: headingPage }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// If we're including all headings or we've reached headings on\n\t\t// the same page as the Table of Contents block, add them to the\n\t\t// list.\n\t\telse if ( ! onlyIncludeCurrentPage || headingPage === tocPage ) {\n\t\t\tif ( blockName === 'core/heading' ) {\n\t\t\t\tconst headingAttributes = getBlockAttributes( blockClientId );\n\n\t\t\t\tconst canBeLinked =\n\t\t\t\t\ttypeof headingPageLink === 'string' &&\n\t\t\t\t\ttypeof headingAttributes.anchor === 'string' &&\n\t\t\t\t\theadingAttributes.anchor !== '';\n\n\t\t\t\tlatestHeadings.push( {\n\t\t\t\t\t// Convert line breaks to spaces, and get rid of HTML tags in the headings.\n\t\t\t\t\tcontent: stripHTML(\n\t\t\t\t\t\theadingAttributes.content.replace(\n\t\t\t\t\t\t\t/(<br *\\/?>)+/g,\n\t\t\t\t\t\t\t' '\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tlevel: headingAttributes.level,\n\t\t\t\t\tlink: canBeLinked\n\t\t\t\t\t\t? `${ headingPageLink }#${ headingAttributes.anchor }`\n\t\t\t\t\t\t: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn latestHeadings;\n}\n\nfunction observeCallback( select, dispatch, clientId ) {\n\tconst { getBlockAttributes } = select( blockEditorStore );\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tdispatch( blockEditorStore );\n\n\t/**\n\t * If the block no longer exists in the store, skip the update.\n\t * The \"undo\" action recreates the block and provides a new `clientId`.\n\t * The hook still might be observing the changes while the old block unmounts.\n\t */\n\tconst attributes = getBlockAttributes( clientId );\n\tif ( attributes === null ) {\n\t\treturn;\n\t}\n\n\tconst headings = getLatestHeadings( select, clientId );\n\tif ( ! fastDeepEqual( headings, attributes.headings ) ) {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( clientId, { headings } );\n\t}\n}\n\nexport function useObserveHeadings( clientId ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\t// Todo: Limit subscription to block editor store when data no longer depends on `getPermalink`.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45513\n\t\treturn registry.subscribe( () =>\n\t\t\tobserveCallback( registry.select, registry.dispatch, clientId )\n\t\t);\n\t}, [ registry, clientId ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AAC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N,WAAW,GACd,GAAIJ,eAAe,IAAMG,iBAAiB,CAACE,MAAM,EAAG,GACpD;QACJ,CAAE,CAAC;MACJ;IACD;EACD;EAEA,OAAOP,cAAc;AACtB;AAEA,SAASa,eAAeA,CAAEjC,MAAM,EAAEkC,QAAQ,EAAEjC,QAAQ,EAAG;EACtD,MAAM;IAAEG;EAAmB,CAAC,GAAGJ,MAAM,CAAEF,gBAAiB,CAAC;EACzD,MAAM;IAAEqC,qBAAqB;IAAEC;EAAwC,CAAC,GACvEF,QAAQ,CAAEpC,gBAAiB,CAAC;;EAE7B;AACD;AACA;AACA;AACA;EACC,MAAMuC,UAAU,GAAGjC,kBAAkB,CAAEH,QAAS,CAAC;EACjD,IAAKoC,UAAU,KAAK,IAAI,EAAG;IAC1B;EACD;EAEA,MAAMC,QAAQ,GAAGvC,iBAAiB,CAAEC,MAAM,EAAEC,QAAS,CAAC;EACtD,IAAK,CAAEX,aAAa,CAAEgD,QAAQ,EAAED,UAAU,CAACC,QAAS,CAAC,EAAG;IACvDF,uCAAuC,CAAC,CAAC;IACzCD,qBAAqB,CAAElC,QAAQ,EAAE;MAAEqC;IAAS,CAAE,CAAC;EAChD;AACD;AAEA,OAAO,SAASC,kBAAkBA,CAAEtC,QAAQ,EAAG;EAC9C,MAAMuC,QAAQ,GAAGjD,WAAW,CAAC,CAAC;EAC9BG,SAAS,CAAE,MAAM;IAChB;IACA;IACA,OAAO8C,QAAQ,CAACC,SAAS,CAAE,MAC1BR,eAAe,CAAEO,QAAQ,CAACxC,MAAM,EAAEwC,QAAQ,CAACN,QAAQ,EAAEjC,QAAS,CAC/D,CAAC;EACF,CAAC,EAAE,CAAEuC,QAAQ,EAAEvC,QAAQ,CAAG,CAAC;AAC5B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["fastDeepEqual","useRegistry","__unstableStripHTML","stripHTML","useEffect","addQueryArgs","removeQueryArgs","store","blockEditorStore","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getBlocksByName","getClientIdsOfDescendants","permalink","getPermalink","isPaginated","length","onlyIncludeCurrentPage","maxLevel","postContentClientId","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","latestHeadings","headingPage","headingPageLink","page","blockName","headingAttributes","level","canBeLinked","anchor","push","content","replace","link","observeCallback","dispatch","updateBlockAttributes","__unstableMarkNextChangeAsNotPersistent","attributes","headings","useObserveHeadings","registry","subscribe"],"sources":["@wordpress/block-library/src/table-of-contents/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useEffect } from '@wordpress/element';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction getLatestHeadings( select, clientId ) {\n\tconst {\n\t\tgetBlockAttributes,\n\t\tgetBlockName,\n\t\tgetBlocksByName,\n\t\tgetClientIdsOfDescendants,\n\t} = select( blockEditorStore );\n\n\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t// Blocks can be loaded into a *non-post* block editor, so to avoid\n\t// declaring @wordpress/editor as a dependency, we must access its\n\t// store by string. When the store is not available, editorSelectors\n\t// will be null, and the block's saved markup will lack permalinks.\n\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\tconst permalink = select( 'core/editor' ).getPermalink() ?? null;\n\n\tconst isPaginated = getBlocksByName( 'core/nextpage' ).length !== 0;\n\tconst { onlyIncludeCurrentPage, maxLevel } =\n\t\tgetBlockAttributes( clientId ) ?? {};\n\n\t// Get post-content block client ID.\n\tconst [ postContentClientId = '' ] = getBlocksByName( 'core/post-content' );\n\n\t// Get the client ids of all blocks in the editor.\n\tconst allBlockClientIds = getClientIdsOfDescendants( postContentClientId );\n\n\t// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.\n\tlet tocPage = 1;\n\n\tif ( isPaginated && onlyIncludeCurrentPage ) {\n\t\t// We can't use getBlockIndex because it only returns the index\n\t\t// relative to sibling blocks.\n\t\tconst tocIndex = allBlockClientIds.indexOf( clientId );\n\n\t\tfor ( const [\n\t\t\tblockIndex,\n\t\t\tblockClientId,\n\t\t] of allBlockClientIds.entries() ) {\n\t\t\t// If we've reached blocks after the Table of Contents, we've\n\t\t\t// finished calculating which page the block is on.\n\t\t\tif ( blockIndex >= tocIndex ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( getBlockName( blockClientId ) === 'core/nextpage' ) {\n\t\t\t\ttocPage++;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst latestHeadings = [];\n\n\t/** The page (of a paginated post) a heading will be part of. */\n\tlet headingPage = 1;\n\tlet headingPageLink = null;\n\n\t// If the core/editor store is available, we can add permalinks to the\n\t// generated table of contents.\n\tif ( typeof permalink === 'string' ) {\n\t\theadingPageLink = isPaginated\n\t\t\t? addQueryArgs( permalink, { page: headingPage } )\n\t\t\t: permalink;\n\t}\n\n\tfor ( const blockClientId of allBlockClientIds ) {\n\t\tconst blockName = getBlockName( blockClientId );\n\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\theadingPage++;\n\n\t\t\t// If we're only including headings from the current page (of\n\t\t\t// a paginated post), then exit the loop if we've reached the\n\t\t\t// pages after the one with the Table of Contents block.\n\t\t\tif ( onlyIncludeCurrentPage && headingPage > tocPage ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\theadingPageLink = addQueryArgs(\n\t\t\t\t\tremoveQueryArgs( permalink, [ 'page' ] ),\n\t\t\t\t\t{ page: headingPage }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// If we're including all headings or we've reached headings on\n\t\t// the same page as the Table of Contents block, add them to the\n\t\t// list.\n\t\telse if ( ! onlyIncludeCurrentPage || headingPage === tocPage ) {\n\t\t\tif ( blockName === 'core/heading' ) {\n\t\t\t\tconst headingAttributes = getBlockAttributes( blockClientId );\n\n\t\t\t\t// Skip headings that are deeper than maxLevel\n\t\t\t\tif ( maxLevel && headingAttributes.level > maxLevel ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst canBeLinked =\n\t\t\t\t\ttypeof headingPageLink === 'string' &&\n\t\t\t\t\ttypeof headingAttributes.anchor === 'string' &&\n\t\t\t\t\theadingAttributes.anchor !== '';\n\n\t\t\t\tlatestHeadings.push( {\n\t\t\t\t\t// Convert line breaks to spaces, and get rid of HTML tags in the headings.\n\t\t\t\t\tcontent: stripHTML(\n\t\t\t\t\t\theadingAttributes.content.replace(\n\t\t\t\t\t\t\t/(<br *\\/?>)+/g,\n\t\t\t\t\t\t\t' '\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tlevel: headingAttributes.level,\n\t\t\t\t\tlink: canBeLinked\n\t\t\t\t\t\t? `${ headingPageLink }#${ headingAttributes.anchor }`\n\t\t\t\t\t\t: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn latestHeadings;\n}\n\nfunction observeCallback( select, dispatch, clientId ) {\n\tconst { getBlockAttributes } = select( blockEditorStore );\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tdispatch( blockEditorStore );\n\n\t/**\n\t * If the block no longer exists in the store, skip the update.\n\t * The \"undo\" action recreates the block and provides a new `clientId`.\n\t * The hook still might be observing the changes while the old block unmounts.\n\t */\n\tconst attributes = getBlockAttributes( clientId );\n\tif ( attributes === null ) {\n\t\treturn;\n\t}\n\n\tconst headings = getLatestHeadings( select, clientId );\n\tif ( ! fastDeepEqual( headings, attributes.headings ) ) {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( clientId, { headings } );\n\t}\n}\n\nexport function useObserveHeadings( clientId ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\t// Todo: Limit subscription to block editor store when data no longer depends on `getPermalink`.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45513\n\t\treturn registry.subscribe( () =>\n\t\t\tobserveCallback( registry.select, registry.dispatch, clientId )\n\t\t);\n\t}, [ registry, clientId ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,YAAY,EAAEC,eAAe,QAAQ,gBAAgB;AAC9D,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,SAASC,iBAAiBA,CAAEC,MAAM,EAAEC,QAAQ,EAAG;EAAA,IAAAC,oBAAA,EAAAC,mBAAA;EAC9C,MAAM;IACLC,kBAAkB;IAClBC,YAAY;IACZC,eAAe;IACfC;EACD,CAAC,GAAGP,MAAM,CAAEF,gBAAiB,CAAC;;EAE9B;EACA;EACA;EACA;EACA;EACA;EACA,MAAMU,SAAS,IAAAN,oBAAA,GAAGF,MAAM,CAAE,aAAc,CAAC,CAACS,YAAY,CAAC,CAAC,cAAAP,oBAAA,cAAAA,oBAAA,GAAI,IAAI;EAEhE,MAAMQ,WAAW,GAAGJ,eAAe,CAAE,eAAgB,CAAC,CAACK,MAAM,KAAK,CAAC;EACnE,MAAM;IAAEC,sBAAsB;IAAEC;EAAS,CAAC,IAAAV,mBAAA,GACzCC,kBAAkB,CAAEH,QAAS,CAAC,cAAAE,mBAAA,cAAAA,mBAAA,GAAI,CAAC,CAAC;;EAErC;EACA,MAAM,CAAEW,mBAAmB,GAAG,EAAE,CAAE,GAAGR,eAAe,CAAE,mBAAoB,CAAC;;EAE3E;EACA,MAAMS,iBAAiB,GAAGR,yBAAyB,CAAEO,mBAAoB,CAAC;;EAE1E;EACA,I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,QAAQ,EAAG;EAC9C,MAAMyC,QAAQ,GAAGnD,WAAW,CAAC,CAAC;EAC9BG,SAAS,CAAE,MAAM;IAChB;IACA;IACA,OAAOgD,QAAQ,CAACC,SAAS,CAAE,MAC1BR,eAAe,CAAEO,QAAQ,CAAC1C,MAAM,EAAE0C,QAAQ,CAACN,QAAQ,EAAEnC,QAAS,CAC/D,CAAC;EACF,CAAC,EAAE,CAAEyC,QAAQ,EAAEzC,QAAQ,CAAG,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","tableOfContents","icon","initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","keywords","textdomain","attributes","headings","type","items","onlyIncludeCurrentPage","supports","html","color","text","background","gradients","link","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","interactivity","clientNavigation","__experimentalBorder","radius","width","style","edit","save","settings","example","innerBlocks","level","content","init"],"sources":["@wordpress/block-library/src/table-of-contents/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { tableOfContents as icon } from '@wordpress/icons';\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';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\texample: {\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 2,\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 3,\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 2,\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 3,\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tattributes: {\n\t\t\theadings: [\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t\tlevel: 2,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t\tlevel: 3,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t\tlevel: 2,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t\tlevel: 3,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,IAAIC,IAAI,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,QAAA;MAAAC,IAAA;MAAAC,KAAA;QAAAD,IAAA;MAAA;MAAA;IAAA;IAAAE,sBAAA;MAAAF,IAAA;MAAA;IAAA;EAAA;
|
|
1
|
+
{"version":3,"names":["__","tableOfContents","icon","initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","keywords","textdomain","attributes","headings","type","items","onlyIncludeCurrentPage","maxLevel","supports","html","color","text","background","gradients","link","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","interactivity","clientNavigation","__experimentalBorder","radius","width","style","edit","save","settings","example","innerBlocks","level","content","init"],"sources":["@wordpress/block-library/src/table-of-contents/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { tableOfContents as icon } from '@wordpress/icons';\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';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\texample: {\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 2,\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 3,\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 2,\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/heading',\n\t\t\t\tattributes: {\n\t\t\t\t\tlevel: 3,\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tattributes: {\n\t\t\theadings: [\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Heading' ),\n\t\t\t\t\tlevel: 2,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcontent: __( 'Subheading' ),\n\t\t\t\t\tlevel: 3,\n\t\t\t\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AAE4C;AAAS,CAAE,CAAC","ignoreList":[]}
|
|
@@ -1206,15 +1206,6 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
1206
1206
|
opacity: 0.1;
|
|
1207
1207
|
}
|
|
1208
1208
|
|
|
1209
|
-
.wp-block-image .components-resizable-box__container {
|
|
1210
|
-
display: table;
|
|
1211
|
-
}
|
|
1212
|
-
.wp-block-image .components-resizable-box__container img {
|
|
1213
|
-
display: block;
|
|
1214
|
-
width: inherit;
|
|
1215
|
-
height: inherit;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
1209
|
.block-editor-block-list__block[data-type="core/image"] .block-editor-block-toolbar .block-editor-url-input__button-modal {
|
|
1219
1210
|
position: absolute;
|
|
1220
1211
|
right: 0;
|
package/build-style/editor.css
CHANGED
|
@@ -1215,15 +1215,6 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
1215
1215
|
opacity: 0.1;
|
|
1216
1216
|
}
|
|
1217
1217
|
|
|
1218
|
-
.wp-block-image .components-resizable-box__container {
|
|
1219
|
-
display: table;
|
|
1220
|
-
}
|
|
1221
|
-
.wp-block-image .components-resizable-box__container img {
|
|
1222
|
-
display: block;
|
|
1223
|
-
width: inherit;
|
|
1224
|
-
height: inherit;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
1218
|
.block-editor-block-list__block[data-type="core/image"] .block-editor-block-toolbar .block-editor-url-input__button-modal {
|
|
1228
1219
|
position: absolute;
|
|
1229
1220
|
left: 0;
|
|
@@ -134,15 +134,6 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
134
134
|
opacity: 0.1;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
.wp-block-image .components-resizable-box__container {
|
|
138
|
-
display: table;
|
|
139
|
-
}
|
|
140
|
-
.wp-block-image .components-resizable-box__container img {
|
|
141
|
-
display: block;
|
|
142
|
-
width: inherit;
|
|
143
|
-
height: inherit;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
137
|
.block-editor-block-list__block[data-type="core/image"] .block-editor-block-toolbar .block-editor-url-input__button-modal {
|
|
147
138
|
position: absolute;
|
|
148
139
|
right: 0;
|
|
@@ -134,15 +134,6 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
134
134
|
opacity: 0.1;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
.wp-block-image .components-resizable-box__container {
|
|
138
|
-
display: table;
|
|
139
|
-
}
|
|
140
|
-
.wp-block-image .components-resizable-box__container img {
|
|
141
|
-
display: block;
|
|
142
|
-
width: inherit;
|
|
143
|
-
height: inherit;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
137
|
.block-editor-block-list__block[data-type="core/image"] .block-editor-block-toolbar .block-editor-url-input__button-modal {
|
|
147
138
|
position: absolute;
|
|
148
139
|
left: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.21.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -41,39 +41,39 @@
|
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/runtime": "7.25.7",
|
|
44
|
-
"@wordpress/a11y": "^4.
|
|
45
|
-
"@wordpress/api-fetch": "^7.
|
|
46
|
-
"@wordpress/autop": "^4.
|
|
47
|
-
"@wordpress/blob": "^4.
|
|
48
|
-
"@wordpress/block-editor": "^14.
|
|
49
|
-
"@wordpress/blocks": "^14.
|
|
50
|
-
"@wordpress/components": "^29.
|
|
51
|
-
"@wordpress/compose": "^7.
|
|
52
|
-
"@wordpress/core-data": "^7.
|
|
53
|
-
"@wordpress/data": "^10.
|
|
54
|
-
"@wordpress/date": "^5.
|
|
55
|
-
"@wordpress/deprecated": "^4.
|
|
56
|
-
"@wordpress/dom": "^4.
|
|
57
|
-
"@wordpress/element": "^6.
|
|
58
|
-
"@wordpress/escape-html": "^3.
|
|
59
|
-
"@wordpress/hooks": "^4.
|
|
60
|
-
"@wordpress/html-entities": "^4.
|
|
61
|
-
"@wordpress/i18n": "^5.
|
|
62
|
-
"@wordpress/icons": "^10.
|
|
63
|
-
"@wordpress/interactivity": "^6.
|
|
64
|
-
"@wordpress/interactivity-router": "^2.
|
|
65
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
66
|
-
"@wordpress/keycodes": "^4.
|
|
67
|
-
"@wordpress/notices": "^5.
|
|
68
|
-
"@wordpress/patterns": "^2.
|
|
69
|
-
"@wordpress/primitives": "^4.
|
|
70
|
-
"@wordpress/private-apis": "^1.
|
|
71
|
-
"@wordpress/reusable-blocks": "^5.
|
|
72
|
-
"@wordpress/rich-text": "^7.
|
|
73
|
-
"@wordpress/server-side-render": "^5.
|
|
74
|
-
"@wordpress/url": "^4.
|
|
75
|
-
"@wordpress/viewport": "^6.
|
|
76
|
-
"@wordpress/wordcount": "^4.
|
|
44
|
+
"@wordpress/a11y": "^4.21.0",
|
|
45
|
+
"@wordpress/api-fetch": "^7.21.0",
|
|
46
|
+
"@wordpress/autop": "^4.21.0",
|
|
47
|
+
"@wordpress/blob": "^4.21.0",
|
|
48
|
+
"@wordpress/block-editor": "^14.16.0",
|
|
49
|
+
"@wordpress/blocks": "^14.10.0",
|
|
50
|
+
"@wordpress/components": "^29.7.0",
|
|
51
|
+
"@wordpress/compose": "^7.21.0",
|
|
52
|
+
"@wordpress/core-data": "^7.21.0",
|
|
53
|
+
"@wordpress/data": "^10.21.0",
|
|
54
|
+
"@wordpress/date": "^5.21.0",
|
|
55
|
+
"@wordpress/deprecated": "^4.21.0",
|
|
56
|
+
"@wordpress/dom": "^4.21.0",
|
|
57
|
+
"@wordpress/element": "^6.21.0",
|
|
58
|
+
"@wordpress/escape-html": "^3.21.0",
|
|
59
|
+
"@wordpress/hooks": "^4.21.0",
|
|
60
|
+
"@wordpress/html-entities": "^4.21.0",
|
|
61
|
+
"@wordpress/i18n": "^5.21.0",
|
|
62
|
+
"@wordpress/icons": "^10.21.0",
|
|
63
|
+
"@wordpress/interactivity": "^6.21.0",
|
|
64
|
+
"@wordpress/interactivity-router": "^2.21.0",
|
|
65
|
+
"@wordpress/keyboard-shortcuts": "^5.21.0",
|
|
66
|
+
"@wordpress/keycodes": "^4.21.0",
|
|
67
|
+
"@wordpress/notices": "^5.21.0",
|
|
68
|
+
"@wordpress/patterns": "^2.21.0",
|
|
69
|
+
"@wordpress/primitives": "^4.21.0",
|
|
70
|
+
"@wordpress/private-apis": "^1.21.0",
|
|
71
|
+
"@wordpress/reusable-blocks": "^5.21.0",
|
|
72
|
+
"@wordpress/rich-text": "^7.21.0",
|
|
73
|
+
"@wordpress/server-side-render": "^5.21.0",
|
|
74
|
+
"@wordpress/url": "^4.21.0",
|
|
75
|
+
"@wordpress/viewport": "^6.21.0",
|
|
76
|
+
"@wordpress/wordcount": "^4.21.0",
|
|
77
77
|
"change-case": "^4.1.2",
|
|
78
78
|
"clsx": "^2.1.1",
|
|
79
79
|
"colord": "^2.7.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "104af00f9abcd7a4d36b87e648f148c72cc4ea5f"
|
|
95
95
|
}
|
package/src/archives/edit.js
CHANGED
|
@@ -30,7 +30,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
|
|
|
30
30
|
resetAll={ () => {
|
|
31
31
|
setAttributes( {
|
|
32
32
|
displayAsDropdown: false,
|
|
33
|
-
showLabel:
|
|
33
|
+
showLabel: true,
|
|
34
34
|
showPostCounts: false,
|
|
35
35
|
type: 'monthly',
|
|
36
36
|
} );
|
|
@@ -63,7 +63,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
|
|
|
63
63
|
isShownByDefault
|
|
64
64
|
hasValue={ () => ! showLabel }
|
|
65
65
|
onDeselect={ () =>
|
|
66
|
-
setAttributes( { showLabel:
|
|
66
|
+
setAttributes( { showLabel: true } )
|
|
67
67
|
}
|
|
68
68
|
>
|
|
69
69
|
<ToggleControl
|
package/src/audio/edit.js
CHANGED
|
@@ -9,10 +9,11 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { isBlobURL } from '@wordpress/blob';
|
|
10
10
|
import {
|
|
11
11
|
Disabled,
|
|
12
|
-
PanelBody,
|
|
13
12
|
SelectControl,
|
|
14
13
|
Spinner,
|
|
15
14
|
ToggleControl,
|
|
15
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
16
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
16
17
|
} from '@wordpress/components';
|
|
17
18
|
import {
|
|
18
19
|
BlockControls,
|
|
@@ -32,7 +33,10 @@ import { useState } from '@wordpress/element';
|
|
|
32
33
|
* Internal dependencies
|
|
33
34
|
*/
|
|
34
35
|
import { createUpgradedEmbedBlock } from '../embed/util';
|
|
35
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
useUploadMediaFromBlobURL,
|
|
38
|
+
useToolsPanelDropdownMenuProps,
|
|
39
|
+
} from '../utils/hooks';
|
|
36
40
|
import { Caption } from '../utils/caption';
|
|
37
41
|
|
|
38
42
|
const ALLOWED_MEDIA_TYPES = [ 'audio' ];
|
|
@@ -126,6 +130,7 @@ function AudioEdit( {
|
|
|
126
130
|
const blockProps = useBlockProps( {
|
|
127
131
|
className: classes,
|
|
128
132
|
} );
|
|
133
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
129
134
|
|
|
130
135
|
if ( ! src && ! temporaryURL ) {
|
|
131
136
|
return (
|
|
@@ -160,42 +165,88 @@ function AudioEdit( {
|
|
|
160
165
|
</BlockControls>
|
|
161
166
|
) }
|
|
162
167
|
<InspectorControls>
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
<ToolsPanel
|
|
169
|
+
label={ __( 'Settings' ) }
|
|
170
|
+
resetAll={ () => {
|
|
171
|
+
setAttributes( {
|
|
172
|
+
autoplay: false,
|
|
173
|
+
loop: false,
|
|
174
|
+
preload: undefined,
|
|
175
|
+
} );
|
|
176
|
+
} }
|
|
177
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
178
|
+
>
|
|
179
|
+
<ToolsPanelItem
|
|
166
180
|
label={ __( 'Autoplay' ) }
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
isShownByDefault
|
|
182
|
+
hasValue={ () => !! autoplay }
|
|
183
|
+
onDeselect={ () =>
|
|
184
|
+
setAttributes( {
|
|
185
|
+
autoplay: false,
|
|
186
|
+
} )
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
<ToggleControl
|
|
190
|
+
__nextHasNoMarginBottom
|
|
191
|
+
label={ __( 'Autoplay' ) }
|
|
192
|
+
onChange={ toggleAttribute( 'autoplay' ) }
|
|
193
|
+
checked={ !! autoplay }
|
|
194
|
+
help={ getAutoplayHelp }
|
|
195
|
+
/>
|
|
196
|
+
</ToolsPanelItem>
|
|
197
|
+
<ToolsPanelItem
|
|
173
198
|
label={ __( 'Loop' ) }
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
<SelectControl
|
|
178
|
-
__next40pxDefaultSize
|
|
179
|
-
__nextHasNoMarginBottom
|
|
180
|
-
label={ _x( 'Preload', 'noun; Audio block parameter' ) }
|
|
181
|
-
value={ preload || '' }
|
|
182
|
-
// `undefined` is required for the preload attribute to be unset.
|
|
183
|
-
onChange={ ( value ) =>
|
|
199
|
+
isShownByDefault
|
|
200
|
+
hasValue={ () => !! loop }
|
|
201
|
+
onDeselect={ () =>
|
|
184
202
|
setAttributes( {
|
|
185
|
-
|
|
203
|
+
loop: false,
|
|
186
204
|
} )
|
|
187
205
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
>
|
|
207
|
+
<ToggleControl
|
|
208
|
+
__nextHasNoMarginBottom
|
|
209
|
+
label={ __( 'Loop' ) }
|
|
210
|
+
onChange={ toggleAttribute( 'loop' ) }
|
|
211
|
+
checked={ !! loop }
|
|
212
|
+
/>
|
|
213
|
+
</ToolsPanelItem>
|
|
214
|
+
<ToolsPanelItem
|
|
215
|
+
label={ __( 'Preload' ) }
|
|
216
|
+
isShownByDefault
|
|
217
|
+
hasValue={ () => !! preload }
|
|
218
|
+
onDeselect={ () =>
|
|
219
|
+
setAttributes( {
|
|
220
|
+
preload: undefined,
|
|
221
|
+
} )
|
|
222
|
+
}
|
|
223
|
+
>
|
|
224
|
+
<SelectControl
|
|
225
|
+
__next40pxDefaultSize
|
|
226
|
+
__nextHasNoMarginBottom
|
|
227
|
+
label={ _x(
|
|
228
|
+
'Preload',
|
|
229
|
+
'noun; Audio block parameter'
|
|
230
|
+
) }
|
|
231
|
+
value={ preload || '' }
|
|
232
|
+
// `undefined` is required for the preload attribute to be unset.
|
|
233
|
+
onChange={ ( value ) =>
|
|
234
|
+
setAttributes( {
|
|
235
|
+
preload: value || undefined,
|
|
236
|
+
} )
|
|
237
|
+
}
|
|
238
|
+
options={ [
|
|
239
|
+
{ value: '', label: __( 'Browser default' ) },
|
|
240
|
+
{ value: 'auto', label: __( 'Auto' ) },
|
|
241
|
+
{ value: 'metadata', label: __( 'Metadata' ) },
|
|
242
|
+
{
|
|
243
|
+
value: 'none',
|
|
244
|
+
label: _x( 'None', 'Preload value' ),
|
|
245
|
+
},
|
|
246
|
+
] }
|
|
247
|
+
/>
|
|
248
|
+
</ToolsPanelItem>
|
|
249
|
+
</ToolsPanel>
|
|
199
250
|
</InspectorControls>
|
|
200
251
|
<figure { ...blockProps }>
|
|
201
252
|
{ /*
|
package/src/avatar/block.json
CHANGED
|
@@ -48,15 +48,20 @@
|
|
|
48
48
|
},
|
|
49
49
|
"color": {
|
|
50
50
|
"text": false,
|
|
51
|
-
"background": false
|
|
52
|
-
|
|
51
|
+
"background": false
|
|
52
|
+
},
|
|
53
|
+
"filter": {
|
|
54
|
+
"duotone": true
|
|
53
55
|
},
|
|
54
56
|
"interactivity": {
|
|
55
57
|
"clientNavigation": true
|
|
56
58
|
}
|
|
57
59
|
},
|
|
58
60
|
"selectors": {
|
|
59
|
-
"border": ".wp-block-avatar img"
|
|
61
|
+
"border": ".wp-block-avatar img",
|
|
62
|
+
"filter": {
|
|
63
|
+
"duotone": ".wp-block-avatar img"
|
|
64
|
+
}
|
|
60
65
|
},
|
|
61
66
|
"editorStyle": "wp-block-avatar-editor",
|
|
62
67
|
"style": "wp-block-avatar"
|