@wordpress/block-library 9.29.1-next.f34ab90e9.0 → 9.30.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 +2 -0
- package/build/accordion/edit.js +18 -1
- package/build/accordion/edit.js.map +1 -1
- package/build/accordion/index.js +0 -3
- package/build/accordion/index.js.map +1 -1
- package/build/accordion-content/index.js +0 -4
- package/build/accordion-content/index.js.map +1 -1
- package/build/accordion-header/index.js +0 -4
- package/build/accordion-header/index.js.map +1 -1
- package/build/accordion-panel/edit.js +5 -30
- package/build/accordion-panel/edit.js.map +1 -1
- package/build/accordion-panel/index.js +0 -4
- package/build/accordion-panel/index.js.map +1 -1
- package/build/accordion-panel/save.js +3 -29
- package/build/accordion-panel/save.js.map +1 -1
- package/build/audio/edit.js +3 -1
- package/build/audio/edit.js.map +1 -1
- package/build/gallery/index.js +2 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/variations.js +0 -12
- package/build/group/variations.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/navigation-link/link-ui.js +5 -1
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/query-content.js +7 -6
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +30 -9
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/edit/query-toolbar.js +4 -2
- package/build/query/edit/query-toolbar.js.map +1 -1
- package/build/template-part/edit/placeholder.js +2 -1
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/video/edit.js +3 -1
- package/build/video/edit.js.map +1 -1
- package/build-module/accordion/edit.js +20 -3
- package/build-module/accordion/edit.js.map +1 -1
- package/build-module/accordion/index.js +0 -3
- package/build-module/accordion/index.js.map +1 -1
- package/build-module/accordion-content/index.js +0 -4
- package/build-module/accordion-content/index.js.map +1 -1
- package/build-module/accordion-header/index.js +0 -4
- package/build-module/accordion-header/index.js.map +1 -1
- package/build-module/accordion-panel/edit.js +6 -29
- package/build-module/accordion-panel/edit.js.map +1 -1
- package/build-module/accordion-panel/index.js +0 -4
- package/build-module/accordion-panel/index.js.map +1 -1
- package/build-module/accordion-panel/save.js +4 -28
- package/build-module/accordion-panel/save.js.map +1 -1
- package/build-module/audio/edit.js +4 -2
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/gallery/index.js +2 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/variations.js +0 -12
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/image.js +1 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +6 -2
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +8 -7
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +30 -10
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/edit/query-toolbar.js +4 -2
- package/build-module/query/edit/query-toolbar.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +2 -1
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/video/edit.js +4 -2
- package/build-module/video/edit.js.map +1 -1
- package/build-style/accordion/style-rtl.css +4 -13
- package/build-style/accordion/style.css +4 -13
- package/build-style/editor-rtl.css +4 -0
- package/build-style/editor.css +4 -0
- package/build-style/query/editor-rtl.css +4 -0
- package/build-style/query/editor.css +4 -0
- package/build-style/style-rtl.css +4 -14
- package/build-style/style.css +4 -14
- package/package.json +35 -35
- package/src/accordion/block.json +0 -3
- package/src/accordion/edit.js +20 -0
- package/src/accordion/style.scss +7 -16
- package/src/accordion-content/block.json +0 -3
- package/src/accordion-content/index.js +0 -1
- package/src/accordion-header/block.json +0 -3
- package/src/accordion-header/index.js +0 -1
- package/src/accordion-panel/block.json +0 -3
- package/src/accordion-panel/edit.js +11 -51
- package/src/accordion-panel/index.js +0 -1
- package/src/accordion-panel/save.js +4 -45
- package/src/audio/edit.js +6 -1
- package/src/gallery/block.json +2 -1
- package/src/gallery/index.php +1 -1
- package/src/gallery/test/helpers.native.js +3 -3
- package/src/group/variations.js +0 -12
- package/src/image/image.js +2 -1
- package/src/navigation-link/link-ui.js +7 -1
- package/src/post-date/index.php +2 -1
- package/src/query/edit/index.js +1 -0
- package/src/query/edit/query-content.js +8 -4
- package/src/query/edit/query-placeholder.js +47 -17
- package/src/query/edit/query-toolbar.js +10 -2
- package/src/query/editor.scss +6 -1
- package/src/template-part/edit/placeholder.js +2 -1
- package/src/video/edit.js +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_compose","_element","_blockEditor","_i18n","_coreData","_enhancedPaginationControl","_interopRequireDefault","_lockUnlock","_inspectorControls","_enhancedPaginationModal","_utils","_queryToolbar","_jsxRuntime","HTMLElementControl","unlock","blockEditorPrivateApis","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","clientId","context","name","queryId","query","enhancedPagination","tagName","TagName","inherit","templateSlug","isSingular","getQueryContextFromTemplate","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","instanceId","useInstanceId","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","template","postsPerPage","useSelect","select","getSettings","getEntityRecord","getEntityRecordEdits","canUser","coreStore","settingPerPage","kind","posts_per_page","editedSettingPerPage","updateQuery","useCallback","newQuery","prevAttributes","useEffect","perPage","Object","keys","length","Number","isFinite","jsxs","Fragment","children","jsx","default","InspectorControls","setQuery","BlockControls","group","onChange","value","options","label","__"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useCallback } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EnhancedPaginationControl from './inspector-controls/enhanced-pagination-control';\nimport { unlock } from '../../lock-unlock';\nimport QueryInspectorControls from './inspector-controls';\nimport EnhancedPaginationModal from './enhanced-pagination-modal';\nimport { getQueryContextFromTemplate } from '../utils';\nimport QueryToolbar from './query-toolbar';\n\nconst { HTMLElementControl } = unlock( blockEditorPrivateApis );\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tcontext,\n\tname,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tenhancedPagination,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { templateSlug } = context;\n\tconst { isSingular } = getQueryContextFromTemplate( templateSlug );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, getEntityRecordEdits, canUser } =\n\t\t\tselect( coreStore );\n\t\tconst settingPerPage = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\n\t\t// Gets changes made via the template area posts per page setting. These won't be saved\n\t\t// until the page is saved, but we should reflect this setting within the query loops\n\t\t// that inherit it.\n\t\tconst editedSettingPerPage = +getEntityRecordEdits( 'root', 'site' )\n\t\t\t?.posts_per_page;\n\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\teditedSettingPerPage ||\n\t\t\t\tsettingPerPage ||\n\t\t\t\tDEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tconst updateQuery = useCallback(\n\t\t( newQuery ) =>\n\t\t\tsetAttributes( ( prevAttributes ) => ( {\n\t\t\t\tquery: { ...prevAttributes.query, ...newQuery },\n\t\t\t} ) ),\n\t\t[ setAttributes ]\n\t);\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [\n\t\tquery.perPage,\n\t\tinherit,\n\t\tpostsPerPage,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tupdateQuery,\n\t] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [\n\t\tqueryId,\n\t\tinstanceId,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetAttributes,\n\t] );\n\n\treturn (\n\t\t<>\n\t\t\t<EnhancedPaginationModal\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tclientId={ clientId }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<QueryInspectorControls\n\t\t\t\t\tname={ name }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSingular={ isSingular }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar attributes={ attributes } clientId={ clientId } />\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<HTMLElementControl\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t\t<EnhancedPaginationControl\n\t\t\t\t\tenhancedPagination={ enhancedPagination }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAA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EAAGA;MAAU,CAAE;IAAC,CAClD,CAAC,eAChB,IAAAT,WAAA,CAAAsD,IAAA,EAAChE,YAAA,CAAAqE,iBAAiB;MAACG,KAAK,EAAC,UAAU;MAAAN,QAAA,gBAClC,IAAAxD,WAAA,CAAAyD,GAAA,EAACxD,kBAAkB;QAClBc,OAAO,EAAGC,OAAS;QACnB+C,QAAQ,EAAKC,KAAK,IACjBxD,aAAa,CAAE;UAAEO,OAAO,EAAEiD;QAAM,CAAE,CAClC;QACDvD,QAAQ,EAAGA,QAAU;QACrBwD,OAAO,EAAG,CACT;UAAEC,KAAK,EAAE,IAAAC,QAAE,EAAE,iBAAkB,CAAC;UAAEH,KAAK,EAAE;QAAM,CAAC,EAChD;UAAEE,KAAK,EAAE,QAAQ;UAAEF,KAAK,EAAE;QAAO,CAAC,EAClC;UAAEE,KAAK,EAAE,WAAW;UAAEF,KAAK,EAAE;QAAU,CAAC,EACxC;UAAEE,KAAK,EAAE,SAAS;UAAEF,KAAK,EAAE;QAAQ,CAAC;MAClC,CACH,CAAC,eACF,IAAAhE,WAAA,CAAAyD,GAAA,EAAChE,0BAAA,CAAAiE,OAAyB;QACzB5C,kBAAkB,EAAGA,kBAAoB;QACzCN,aAAa,EAAGA,aAAe;QAC/BC,QAAQ,EAAGA;MAAU,CACrB,CAAC;IAAA,CACgB,CAAC,eACpB,IAAAT,WAAA,CAAAyD,GAAA,EAACzC,OAAO;MAAA,GAAMY;IAAgB,CAAI,CAAC;EAAA,CAClC,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_data","require","_compose","_element","_blockEditor","_i18n","_coreData","_enhancedPaginationControl","_interopRequireDefault","_lockUnlock","_inspectorControls","_enhancedPaginationModal","_utils","_queryToolbar","_jsxRuntime","HTMLElementControl","unlock","blockEditorPrivateApis","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","clientId","context","name","queryId","query","enhancedPagination","tagName","TagName","inherit","templateSlug","isSingular","getQueryContextFromTemplate","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","instanceId","useInstanceId","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","template","postsPerPage","useSelect","select","getSettings","getEntityRecord","getEntityRecordEdits","canUser","coreStore","settingPerPage","kind","posts_per_page","editedSettingPerPage","updateQuery","useCallback","newQuery","prevAttributes","useEffect","perPage","Object","keys","length","Number","isFinite","jsxs","Fragment","children","jsx","BlockControls","default","hasInnerBlocks","InspectorControls","setQuery","group","onChange","value","options","label","__"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect, useCallback } from '@wordpress/element';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n\tprivateApis as blockEditorPrivateApis,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport EnhancedPaginationControl from './inspector-controls/enhanced-pagination-control';\nimport { unlock } from '../../lock-unlock';\nimport QueryInspectorControls from './inspector-controls';\nimport EnhancedPaginationModal from './enhanced-pagination-modal';\nimport { getQueryContextFromTemplate } from '../utils';\nimport QueryToolbar from './query-toolbar';\n\nconst { HTMLElementControl } = unlock( blockEditorPrivateApis );\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tcontext,\n\tname,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tenhancedPagination,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { templateSlug } = context;\n\tconst { isSingular } = getQueryContextFromTemplate( templateSlug );\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, getEntityRecordEdits, canUser } =\n\t\t\tselect( coreStore );\n\t\tconst settingPerPage = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\n\t\t// Gets changes made via the template area posts per page setting. These won't be saved\n\t\t// until the page is saved, but we should reflect this setting within the query loops\n\t\t// that inherit it.\n\t\tconst editedSettingPerPage = +getEntityRecordEdits( 'root', 'site' )\n\t\t\t?.posts_per_page;\n\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\teditedSettingPerPage ||\n\t\t\t\tsettingPerPage ||\n\t\t\t\tDEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tconst updateQuery = useCallback(\n\t\t( newQuery ) =>\n\t\t\tsetAttributes( ( prevAttributes ) => ( {\n\t\t\t\tquery: { ...prevAttributes.query, ...newQuery },\n\t\t\t} ) ),\n\t\t[ setAttributes ]\n\t);\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [\n\t\tquery.perPage,\n\t\tinherit,\n\t\tpostsPerPage,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tupdateQuery,\n\t] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [\n\t\tqueryId,\n\t\tinstanceId,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tsetAttributes,\n\t] );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\thasInnerBlocks\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<EnhancedPaginationModal\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tclientId={ clientId }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<QueryInspectorControls\n\t\t\t\t\tname={ name }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSingular={ isSingular }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<HTMLElementControl\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t\t<EnhancedPaginationControl\n\t\t\t\t\tenhancedPagination={ enhancedPagination }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,0BAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,kBAAA,GAAAF,sBAAA,CAAAP,OAAA;AACA,IAAAU,wBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,aAAA,GAAAL,sBAAA,CAAAP,OAAA;AAA2C,IAAAa,WAAA,GAAAb,OAAA;AAzB3C;AACA;AACA;;AAeA;AACA;AACA;;AAQA,MAAM;EAAEc;AAAmB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAE/D,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,QAAQ,GAAG,CAAE,CAAE,oBAAoB,CAAE,CAAE;AAC9B,SAASC,YAAYA,CAAE;EACrCC,UAAU;EACVC,aAAa;EACbC,QAAQ;EACRC,OAAO;EACPC;AACD,CAAC,EAA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AE,SAAS;UAAEF,KAAK,EAAE;QAAQ,CAAC;MAClC,CACH,CAAC,eACF,IAAAjE,WAAA,CAAAyD,GAAA,EAAChE,0BAAA,CAAAkE,OAAyB;QACzB7C,kBAAkB,EAAGA,kBAAoB;QACzCN,aAAa,EAAGA,aAAe;QAC/BC,QAAQ,EAAGA;MAAU,CACrB,CAAC;IAAA,CACgB,CAAC,eACpB,IAAAT,WAAA,CAAAyD,GAAA,EAACzC,OAAO;MAAA,GAAMY;IAAgB,CAAI,CAAC;EAAA,CAClC,CAAC;AAEL","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -10,8 +11,10 @@ var _element = require("@wordpress/element");
|
|
|
10
11
|
var _blockEditor = require("@wordpress/block-editor");
|
|
11
12
|
var _components = require("@wordpress/components");
|
|
12
13
|
var _i18n = require("@wordpress/i18n");
|
|
14
|
+
var _compose = require("@wordpress/compose");
|
|
13
15
|
var _utils = require("../utils");
|
|
14
16
|
var _patternSelection = require("./pattern-selection");
|
|
17
|
+
var _queryToolbar = _interopRequireDefault(require("./query-toolbar"));
|
|
15
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
19
|
/**
|
|
17
20
|
* WordPress dependencies
|
|
@@ -28,7 +31,14 @@ function QueryPlaceholder({
|
|
|
28
31
|
openPatternSelectionModal
|
|
29
32
|
}) {
|
|
30
33
|
const [isStartingBlank, setIsStartingBlank] = (0, _element.useState)(false);
|
|
31
|
-
const
|
|
34
|
+
const [containerWidth, setContainerWidth] = (0, _element.useState)(0);
|
|
35
|
+
|
|
36
|
+
// Use ResizeObserver to monitor container width.
|
|
37
|
+
const resizeObserverRef = (0, _compose.useResizeObserver)(([entry]) => {
|
|
38
|
+
setContainerWidth(entry.contentRect.width);
|
|
39
|
+
});
|
|
40
|
+
const SMALL_CONTAINER_BREAKPOINT = 160;
|
|
41
|
+
const isSmallContainer = containerWidth > 0 && containerWidth < SMALL_CONTAINER_BREAKPOINT;
|
|
32
42
|
const {
|
|
33
43
|
blockType,
|
|
34
44
|
activeBlockVariation
|
|
@@ -45,6 +55,9 @@ function QueryPlaceholder({
|
|
|
45
55
|
const hasPatterns = !!(0, _patternSelection.useBlockPatterns)(clientId, attributes).length;
|
|
46
56
|
const icon = activeBlockVariation?.icon?.src || activeBlockVariation?.icon || blockType?.icon?.src;
|
|
47
57
|
const label = activeBlockVariation?.title || blockType?.title;
|
|
58
|
+
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
59
|
+
ref: resizeObserverRef
|
|
60
|
+
});
|
|
48
61
|
if (isStartingBlank) {
|
|
49
62
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(QueryVariationPicker, {
|
|
50
63
|
clientId: clientId,
|
|
@@ -53,18 +66,26 @@ function QueryPlaceholder({
|
|
|
53
66
|
label: label
|
|
54
67
|
});
|
|
55
68
|
}
|
|
56
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
57
70
|
...blockProps,
|
|
58
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockControls, {
|
|
72
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_queryToolbar.default, {
|
|
73
|
+
clientId: clientId,
|
|
74
|
+
attributes: attributes,
|
|
75
|
+
hasInnerBlocks: false
|
|
76
|
+
})
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Placeholder, {
|
|
78
|
+
className: "block-editor-media-placeholder",
|
|
79
|
+
icon: !isSmallContainer && icon,
|
|
80
|
+
label: !isSmallContainer && label,
|
|
81
|
+
instructions: !isSmallContainer && (0, _i18n.__)('Choose a pattern for the query loop or start blank.'),
|
|
82
|
+
withIllustration: isSmallContainer,
|
|
83
|
+
children: [!!hasPatterns && !isSmallContainer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
63
84
|
__next40pxDefaultSize: true,
|
|
64
85
|
variant: "primary",
|
|
65
86
|
onClick: openPatternSelectionModal,
|
|
66
87
|
children: (0, _i18n.__)('Choose')
|
|
67
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
88
|
+
}), !isSmallContainer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
68
89
|
__next40pxDefaultSize: true,
|
|
69
90
|
variant: "secondary",
|
|
70
91
|
onClick: () => {
|
|
@@ -72,7 +93,7 @@ function QueryPlaceholder({
|
|
|
72
93
|
},
|
|
73
94
|
children: (0, _i18n.__)('Start blank')
|
|
74
95
|
})]
|
|
75
|
-
})
|
|
96
|
+
})]
|
|
76
97
|
});
|
|
77
98
|
}
|
|
78
99
|
function QueryVariationPicker({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blocks","_element","_blockEditor","_components","_i18n","_utils","_patternSelection","_jsxRuntime","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","isStartingBlank","setIsStartingBlank","useState","
|
|
1
|
+
{"version":3,"names":["_data","require","_blocks","_element","_blockEditor","_components","_i18n","_compose","_utils","_patternSelection","_queryToolbar","_interopRequireDefault","_jsxRuntime","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","isStartingBlank","setIsStartingBlank","useState","containerWidth","setContainerWidth","resizeObserverRef","useResizeObserver","entry","contentRect","width","SMALL_CONTAINER_BREAKPOINT","isSmallContainer","blockType","activeBlockVariation","useSelect","select","getActiveBlockVariation","getBlockType","blocksStore","hasPatterns","useBlockPatterns","length","icon","src","label","title","blockProps","useBlockProps","ref","jsx","QueryVariationPicker","jsxs","children","BlockControls","default","hasInnerBlocks","Placeholder","className","instructions","__","withIllustration","Button","__next40pxDefaultSize","variant","onClick","scopeVariations","useScopedBlockVariations","replaceInnerBlocks","useDispatch","blockEditorStore","__experimentalBlockVariationPicker","variations","onSelect","variation","innerBlocks","createBlocksFromInnerBlocksTemplate"],"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n\tBlockControls,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useScopedBlockVariations } from '../utils';\nimport { useBlockPatterns } from './pattern-selection';\nimport QueryToolbar from './query-toolbar';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst [ containerWidth, setContainerWidth ] = useState( 0 );\n\n\t// Use ResizeObserver to monitor container width.\n\tconst resizeObserverRef = useResizeObserver( ( [ entry ] ) => {\n\t\tsetContainerWidth( entry.contentRect.width );\n\t} );\n\n\tconst SMALL_CONTAINER_BREAKPOINT = 160;\n\n\tconst isSmallContainer =\n\t\tcontainerWidth > 0 && containerWidth < SMALL_CONTAINER_BREAKPOINT;\n\n\tconst { blockType, activeBlockVariation } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockType } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tattributes\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ name, attributes ]\n\t);\n\tconst hasPatterns = !! useBlockPatterns( clientId, attributes ).length;\n\tconst icon =\n\t\tactiveBlockVariation?.icon?.src ||\n\t\tactiveBlockVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = activeBlockVariation?.title || blockType?.title;\n\tconst blockProps = useBlockProps( {\n\t\tref: resizeObserverRef,\n\t} );\n\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\thasInnerBlocks={ false }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\ticon={ ! isSmallContainer && icon }\n\t\t\t\tlabel={ ! isSmallContainer && label }\n\t\t\t\tinstructions={\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t__( 'Choose a pattern for the query loop or start blank.' )\n\t\t\t\t}\n\t\t\t\twithIllustration={ isSmallContainer }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && ! isSmallContainer && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t{ ! isSmallContainer && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( { clientId, attributes, icon, label } ) {\n\tconst scopeVariations = useScopedBlockVariations( attributes );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( variation ) => {\n\t\t\t\t\tif ( variation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tvariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAIA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAMA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAC,sBAAA,CAAAV,OAAA;AAA2C,IAAAW,WAAA,GAAAX,OAAA;AAxB3C;AACA;AACA;;AAiBA;AACA;AACA;;AAKe,SAASY,gBAAg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C,OAAO,EAAGA,CAAA,KAAM;UACf3C,kBAAkB,CAAE,IAAK,CAAC;QAC3B,CAAG;QAAA+B,QAAA,EAED,IAAAO,QAAE,EAAE,aAAc;MAAC,CACd,CACR;IAAA,CACW,CAAC;EAAA,CACV,CAAC;AAER;AAEA,SAAST,oBAAoBA,CAAE;EAAEjC,QAAQ;EAAED,UAAU;EAAE0B,IAAI;EAAEE;AAAM,CAAC,EAAG;EACtE,MAAMqB,eAAe,GAAG,IAAAC,+BAAwB,EAAElD,UAAW,CAAC;EAC9D,MAAM;IAAEmD;EAAmB,CAAC,GAAG,IAAAC,iBAAW,EAAEC,kBAAiB,CAAC;EAC9D,MAAMvB,UAAU,GAAG,IAAAC,0BAAa,EAAC,CAAC;EAClC,oBACC,IAAAjC,WAAA,CAAAmC,GAAA;IAAA,GAAUH,UAAU;IAAAM,QAAA,eACnB,IAAAtC,WAAA,CAAAmC,GAAA,EAAC3C,YAAA,CAAAgE,kCAAkC;MAClC5B,IAAI,EAAGA,IAAM;MACbE,KAAK,EAAGA,KAAO;MACf2B,UAAU,EAAGN,eAAiB;MAC9BO,QAAQ,EAAKC,SAAS,IAAM;QAC3B,IAAKA,SAAS,CAACC,WAAW,EAAG;UAC5BP,kBAAkB,CACjBlD,QAAQ,EACR,IAAA0D,2CAAmC,EAClCF,SAAS,CAACC,WACX,CAAC,EACD,KACD,CAAC;QACF;MACD;IAAG,CACH;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
@@ -20,12 +20,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
20
20
|
|
|
21
21
|
function QueryToolbar({
|
|
22
22
|
clientId,
|
|
23
|
-
attributes
|
|
23
|
+
attributes,
|
|
24
|
+
hasInnerBlocks
|
|
24
25
|
}) {
|
|
25
26
|
const hasPatterns = (0, _patternSelection.useBlockPatterns)(clientId, attributes).length;
|
|
26
27
|
if (!hasPatterns) {
|
|
27
28
|
return null;
|
|
28
29
|
}
|
|
30
|
+
const buttonLabel = hasInnerBlocks ? (0, _i18n.__)('Change design') : (0, _i18n.__)('Choose pattern');
|
|
29
31
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarGroup, {
|
|
30
32
|
className: "wp-block-template-part__block-control-group",
|
|
31
33
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalDropdownContentWrapper, {
|
|
@@ -40,7 +42,7 @@ function QueryToolbar({
|
|
|
40
42
|
"aria-haspopup": "true",
|
|
41
43
|
"aria-expanded": isOpen,
|
|
42
44
|
onClick: onToggle,
|
|
43
|
-
children:
|
|
45
|
+
children: buttonLabel
|
|
44
46
|
}),
|
|
45
47
|
renderContent: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_patternSelection.default, {
|
|
46
48
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_patternSelection","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","QueryToolbar","clientId","attributes","hasPatterns","useBlockPatterns","length","jsx","ToolbarGroup","className","children","__experimentalDropdownContentWrapper","Dropdown","contentClassName","focusOnMount","expandOnMobile","renderToggle","isOpen","onToggle","ToolbarButton","onClick","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_patternSelection","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","QueryToolbar","clientId","attributes","hasInnerBlocks","hasPatterns","useBlockPatterns","length","buttonLabel","__","jsx","ToolbarGroup","className","children","__experimentalDropdownContentWrapper","Dropdown","contentClassName","focusOnMount","expandOnMobile","renderToggle","isOpen","onToggle","ToolbarButton","onClick","renderContent","showSearch","showTitlesAsTooltip"],"sources":["@wordpress/block-library/src/query/edit/query-toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tDropdown,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternSelection, { useBlockPatterns } from './pattern-selection';\n\nexport default function QueryToolbar( {\n\tclientId,\n\tattributes,\n\thasInnerBlocks,\n} ) {\n\tconst hasPatterns = useBlockPatterns( clientId, attributes ).length;\n\tif ( ! hasPatterns ) {\n\t\treturn null;\n\t}\n\n\tconst buttonLabel = hasInnerBlocks\n\t\t? __( 'Change design' )\n\t\t: __( 'Choose pattern' );\n\n\treturn (\n\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t<DropdownContentWrapper>\n\t\t\t\t<Dropdown\n\t\t\t\t\tcontentClassName=\"block-editor-block-settings-menu__popover\"\n\t\t\t\t\tfocusOnMount=\"firstElement\"\n\t\t\t\t\texpandOnMobile\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ buttonLabel }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\tshowSearch={ false }\n\t\t\t\t\t\t\tshowTitlesAsTooltip\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</DropdownContentWrapper>\n\t\t</ToolbarGroup>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,I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YA,CAAE;EACrCC,QAAQ;EACRC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,MAAMC,WAAW,GAAG,IAAAC,kCAAgB,EAAEJ,QAAQ,EAAEC,UAAW,CAAC,CAACI,MAAM;EACnE,IAAK,CAAEF,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,MAAMG,WAAW,GAAGJ,cAAc,GAC/B,IAAAK,QAAE,EAAE,eAAgB,CAAC,GACrB,IAAAA,QAAE,EAAE,gBAAiB,CAAC;EAEzB,oBACC,IAAA7B,WAAA,CAAA8B,GAAA,EAACnC,WAAA,CAAAoC,YAAY;IAACC,SAAS,EAAC,6CAA6C;IAAAC,QAAA,eACpE,IAAAjC,WAAA,CAAA8B,GAAA,EAACnC,WAAA,CAAAuC,oCAAsB;MAAAD,QAAA,eACtB,IAAAjC,WAAA,CAAA8B,GAAA,EAACnC,WAAA,CAAAwC,QAAQ;QACRC,gBAAgB,EAAC,2CAA2C;QAC5DC,YAAY,EAAC,cAAc;QAC3BC,cAAc;QACdC,YAAY,EAAGA,CAAE;UAAEC,MAAM;UAAEC;QAAS,CAAC,kBACpC,IAAAzC,WAAA,CAAA8B,GAAA,EAACnC,WAAA,CAAA+C,aAAa;UACb,iBAAc,MAAM;UACpB,iBAAgBF,MAAQ;UACxBG,OAAO,EAAGF,QAAU;UAAAR,QAAA,EAElBL;QAAW,CACC,CACb;QACHgB,aAAa,EAAGA,CAAA,kBACf,IAAA5C,WAAA,CAAA8B,GAAA,EAAChC,iBAAA,CAAAS,OAAgB;UAChBe,QAAQ,EAAGA,QAAU;UACrBC,UAAU,EAAGA,UAAY;UACzBsB,UAAU,EAAG,KAAO;UACpBC,mBAAmB;QAAA,CACnB;MACC,CACH;IAAC,CACqB;EAAC,CACZ,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ var _data = require("@wordpress/data");
|
|
|
12
12
|
var _coreData = require("@wordpress/core-data");
|
|
13
13
|
var _hooks = require("./utils/hooks");
|
|
14
14
|
var _titleModal = _interopRequireDefault(require("./title-modal"));
|
|
15
|
+
var _getTemplatePartIcon = require("./utils/get-template-part-icon");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
/**
|
|
17
18
|
* WordPress dependencies
|
|
@@ -53,7 +54,7 @@ function TemplatePartPlaceholder({
|
|
|
53
54
|
const areaObject = (0, _hooks.useTemplatePartArea)(area);
|
|
54
55
|
const createFromBlocks = (0, _hooks.useCreateTemplatePartFromBlocks)(area, setAttributes);
|
|
55
56
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Placeholder, {
|
|
56
|
-
icon: areaObject.icon,
|
|
57
|
+
icon: (0, _getTemplatePartIcon.getTemplatePartIcon)(areaObject.icon),
|
|
57
58
|
label: areaObject.label,
|
|
58
59
|
instructions: isBlockBasedTheme ? (0, _i18n.sprintf)(
|
|
59
60
|
// Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_element","_data","_coreData","_hooks","_titleModal","_interopRequireDefault","_jsxRuntime","TemplatePartPlaceholder","area","clientId","templatePartId","onOpenSelectionModal","setAttributes","templateParts","isResolving","useAlternativeTemplateParts","blockPatterns","useAlternativeBlockPatterns","isBlockBasedTheme","canCreateTemplatePart","useSelect","select","getCurrentTheme","canUser","coreStore","is_block_theme","kind","name","showTitleModal","setShowTitleModal","useState","areaObject","useTemplatePartArea","createFromBlocks","useCreateTemplatePartFromBlocks","jsxs","Placeholder","icon","label","instructions","sprintf","__","toLowerCase","children","jsx","Spinner","length","Button","__next40pxDefaultSize","variant","onClick","default","areaLabel","onClose","onSubmit","title"],"sources":["@wordpress/block-library/src/template-part/edit/placeholder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, Button, Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n\tuseTemplatePartArea,\n} from './utils/hooks';\nimport TitleModal from './title-modal';\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\ttemplatePartId,\n\tonOpenSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst { templateParts, isResolving } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\n\tconst { isBlockBasedTheme, canCreateTemplatePart } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentTheme, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\t\tcanCreateTemplatePart: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template_part',\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst [ showTitleModal, setShowTitleModal ] = useState( false );\n\tconst areaObject = useTemplatePartArea( area );\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ areaObject.icon }\n\t\t\tlabel={ areaObject.label }\n\t\t\tinstructions={\n\t\t\t\tisBlockBasedTheme\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t__( 'Choose an existing %s or create a new one.' ),\n\t\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t__( 'Choose an existing %s.' ),\n\t\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t )\n\t\t\t}\n\t\t>\n\t\t\t{ isResolving && <Spinner /> }\n\n\t\t\t{ ! isResolving &&\n\t\t\t\t!! ( templateParts.length || blockPatterns.length ) && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onOpenSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t{ ! isResolving && isBlockBasedTheme && canCreateTemplatePart && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowTitleModal( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showTitleModal && (\n\t\t\t\t<TitleModal\n\t\t\t\t\tareaLabel={ areaObject.label }\n\t\t\t\t\tonClose={ () => setShowTitleModal( false ) }\n\t\t\t\t\tonSubmit={ ( title ) => {\n\t\t\t\t\t\tcreateFromBlocks( [], title );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Placeholder>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAMA,IAAAM,WAAA,GAAAC,sBAAA,CAAAP,OAAA;
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_element","_data","_coreData","_hooks","_titleModal","_interopRequireDefault","_getTemplatePartIcon","_jsxRuntime","TemplatePartPlaceholder","area","clientId","templatePartId","onOpenSelectionModal","setAttributes","templateParts","isResolving","useAlternativeTemplateParts","blockPatterns","useAlternativeBlockPatterns","isBlockBasedTheme","canCreateTemplatePart","useSelect","select","getCurrentTheme","canUser","coreStore","is_block_theme","kind","name","showTitleModal","setShowTitleModal","useState","areaObject","useTemplatePartArea","createFromBlocks","useCreateTemplatePartFromBlocks","jsxs","Placeholder","icon","getTemplatePartIcon","label","instructions","sprintf","__","toLowerCase","children","jsx","Spinner","length","Button","__next40pxDefaultSize","variant","onClick","default","areaLabel","onClose","onSubmit","title"],"sources":["@wordpress/block-library/src/template-part/edit/placeholder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, Button, Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n\tuseTemplatePartArea,\n} from './utils/hooks';\nimport TitleModal from './title-modal';\nimport { getTemplatePartIcon } from './utils/get-template-part-icon';\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\ttemplatePartId,\n\tonOpenSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst { templateParts, isResolving } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\n\tconst { isBlockBasedTheme, canCreateTemplatePart } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentTheme, canUser } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\t\tcanCreateTemplatePart: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template_part',\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst [ showTitleModal, setShowTitleModal ] = useState( false );\n\tconst areaObject = useTemplatePartArea( area );\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ getTemplatePartIcon( areaObject.icon ) }\n\t\t\tlabel={ areaObject.label }\n\t\t\tinstructions={\n\t\t\t\tisBlockBasedTheme\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t__( 'Choose an existing %s or create a new one.' ),\n\t\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t__( 'Choose an existing %s.' ),\n\t\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t )\n\t\t\t}\n\t\t>\n\t\t\t{ isResolving && <Spinner /> }\n\n\t\t\t{ ! isResolving &&\n\t\t\t\t!! ( templateParts.length || blockPatterns.length ) && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ onOpenSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t{ ! isResolving && isBlockBasedTheme && canCreateTemplatePart && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowTitleModal( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showTitleModal && (\n\t\t\t\t<TitleModal\n\t\t\t\t\tareaLabel={ areaObject.label }\n\t\t\t\t\tonClose={ () => setShowTitleModal( false ) }\n\t\t\t\t\tonSubmit={ ( title ) => {\n\t\t\t\t\t\tcreateFromBlocks( [], title );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Placeholder>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAMA,IAAAM,WAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAR,OAAA;AAAqE,IAAAS,WAAA,GAAAT,OAAA;AAnBrE;AACA;AACA;;AAOA;AACA;AACA;;AAUe,SAASU,uBAAuBA,CAAE;EAChDC,IAAI;EACJC,QAAQ;EACRC,cAAc;EACdC,oBAAoB;EACpBC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,aAAa;IAAEC;EAAY,CAAC,GAAG,IAAAC,kCAA2B,EACjEP,IAAI,EACJE,cACD,CAAC;EACD,MAAMM,aAAa,GAAG,IAAAC,kCAA2B,EAAET,IAAI,EAAEC,QAAS,CAAC;EAEnE,MAAM;IAAES,iBAAiB;IAAEC;EAAsB,CAAC,GAAG,IAAAC,eAAS,EAC3DC,MAAM,IAAM;IACb,MAAM;MAAEC,eAAe;MAAEC;IAAQ,CAAC,GAAGF,MAAM,CAAEG,eAAU,CAAC;IACxD,OAAO;MACNN,iBAAiB,EAAEI,eAAe,CAAC,CAAC,EAAEG,cAAc;MACpDN,qBAAqB,EAAEI,OAAO,CAAE,QAAQ,EAAE;QACzCG,IAAI,EAAE,UAAU;QAChBC,IAAI,EAAE;MACP,CAAE;IACH,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,MAAM,CAAEC,cAAc,EA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B,CAAE,IAAK,CAAC;MAC1B,CAAG;MAAAe,QAAA,EAED,IAAAF,QAAE,EAAE,aAAc;IAAC,CACd,CACR,EACCd,cAAc,iBACf,IAAAtB,WAAA,CAAAuC,GAAA,EAAC1C,WAAA,CAAAiD,OAAU;MACVC,SAAS,EAAGtB,UAAU,CAACQ,KAAO;MAC9Be,OAAO,EAAGA,CAAA,KAAMzB,iBAAiB,CAAE,KAAM,CAAG;MAC5C0B,QAAQ,EAAKC,KAAK,IAAM;QACvBvB,gBAAgB,CAAE,EAAE,EAAEuB,KAAM,CAAC;MAC9B;IAAG,CACH,CACD;EAAA,CACW,CAAC;AAEhB","ignoreList":[]}
|
package/build/video/edit.js
CHANGED
|
@@ -53,6 +53,8 @@ function VideoEdit({
|
|
|
53
53
|
} = attributes;
|
|
54
54
|
const [temporaryURL, setTemporaryURL] = (0, _element.useState)(attributes.blob);
|
|
55
55
|
const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)();
|
|
56
|
+
const blockEditingMode = (0, _blockEditor.useBlockEditingMode)();
|
|
57
|
+
const hasNonContentControls = blockEditingMode === 'default';
|
|
56
58
|
(0, _hooks.useUploadMediaFromBlobURL)({
|
|
57
59
|
url: temporaryURL,
|
|
58
60
|
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
@@ -230,7 +232,7 @@ function VideoEdit({
|
|
|
230
232
|
isSelected: isSingleSelected,
|
|
231
233
|
insertBlocksAfter: insertBlocksAfter,
|
|
232
234
|
label: (0, _i18n.__)('Video caption text'),
|
|
233
|
-
showToolbarButton: isSingleSelected
|
|
235
|
+
showToolbarButton: isSingleSelected && hasNonContentControls
|
|
234
236
|
})]
|
|
235
237
|
})]
|
|
236
238
|
});
|
package/build/video/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_blob","_components","_blockEditor","_element","_i18n","_data","_icons","_notices","_util","_hooks","_editCommonSettings","_tracksEditor","_tracks","_caption","_posterImage","_jsxRuntime","ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","isSingleSelected","attributes","className","setAttributes","insertBlocksAfter","onReplace","videoPlayer","useRef","id","controls","poster","src","tracks","temporaryURL","setTemporaryURL","useState","blob","dropdownMenuProps","useToolsPanelDropdownMenuProps","useUploadMediaFromBlobURL","url","allowedTypes","onChange","onSelectVideo","onError","onUploadError","useEffect","current","load","media","undefined","caption","isBlobURL","image","icon","onSelectURL","newSrc","embedBlock","createUpgradedEmbedBlock","createErrorNotice","useDispatch","noticesStore","message","type","placeholder","content","jsx","Placeholder","withIllustration","label","__","instructions","children","classes","clsx","blockProps","useBlockProps","MediaPlaceholder","BlockIcon","onSelect","accept","value","jsxs","Fragment","BlockControls","default","newTracks","group","MediaReplaceFlow","mediaId","mediaURL","onReset","InspectorControls","__experimentalToolsPanel","resetAll","autoplay","loop","muted","playsInline","preload","posterImage","Disabled","isDisabled","ref","Spinner","Caption","showToolbarButton","_default","exports"],"sources":["@wordpress/block-library/src/video/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tSpinner,\n\tPlaceholder,\n\t__experimentalToolsPanel as ToolsPanel,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport {\n\tuseUploadMediaFromBlobURL,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\nimport { Caption } from '../utils/caption';\nimport PosterImage from '../utils/poster-image';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\n\nfunction VideoEdit( {\n\tisSelected: isSingleSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst videoPlayer = useRef();\n\tconst { id, controls, poster, src, tracks } = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectVideo,\n\t\tonError: onUploadError,\n\t} );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\t// TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tsrc: newSrc,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\twithIllustration={ ! isSingleSelected }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Video' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<TracksEditor\n\t\t\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\tonReset={ () => onSelectVideo( undefined ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\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\tautoplay: false,\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t\tloop: false,\n\t\t\t\t\t\t\tmuted: false,\n\t\t\t\t\t\t\tplaysInline: false,\n\t\t\t\t\t\t\tpreload: 'metadata',\n\t\t\t\t\t\t\tposter: undefined,\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<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<PosterImage\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tonChange={ ( posterImage ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tposter: posterImage?.url,\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</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n Disable the video tag if the block is not selected\n so the user clicking on it won't play the\n video when the controls are enabled.\n */ }\n\t\t\t\t<Disabled isDisabled={ ! isSingleSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src || temporaryURL }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Video caption text' ) }\n\t\t\t\t\tshowToolbarButton={ isSingleSelected }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAQA,IAAAI,QAAA,GAAAJ,OA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,CAAC,CAAEC,YAAY,iBAAI,IAAAjB,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAsG,OAAO,IAAE,CAAC,eAChC,IAAAxF,WAAA,CAAAkD,GAAA,EAACpD,QAAA,CAAA2F,OAAO;QACPpF,UAAU,EAAGA,UAAY;QACzBE,aAAa,EAAGA,aAAe;QAC/BJ,UAAU,EAAGC,gBAAkB;QAC/BI,iBAAiB,EAAGA,iBAAmB;QACvC6C,KAAK,EAAG,IAAAC,QAAE,EAAE,oBAAqB,CAAG;QACpCoC,iBAAiB,EAAGtF;MAAkB,CACtC,CAAC;IAAA,CACK,CAAC;EAAA,CACR,CAAC;AAEL;AAAC,IAAAuF,QAAA,GAAAC,OAAA,CAAAvB,OAAA,GAEcnE,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_blob","_components","_blockEditor","_element","_i18n","_data","_icons","_notices","_util","_hooks","_editCommonSettings","_tracksEditor","_tracks","_caption","_posterImage","_jsxRuntime","ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","isSingleSelected","attributes","className","setAttributes","insertBlocksAfter","onReplace","videoPlayer","useRef","id","controls","poster","src","tracks","temporaryURL","setTemporaryURL","useState","blob","dropdownMenuProps","useToolsPanelDropdownMenuProps","blockEditingMode","useBlockEditingMode","hasNonContentControls","useUploadMediaFromBlobURL","url","allowedTypes","onChange","onSelectVideo","onError","onUploadError","useEffect","current","load","media","undefined","caption","isBlobURL","image","icon","onSelectURL","newSrc","embedBlock","createUpgradedEmbedBlock","createErrorNotice","useDispatch","noticesStore","message","type","placeholder","content","jsx","Placeholder","withIllustration","label","__","instructions","children","classes","clsx","blockProps","useBlockProps","MediaPlaceholder","BlockIcon","onSelect","accept","value","jsxs","Fragment","BlockControls","default","newTracks","group","MediaReplaceFlow","mediaId","mediaURL","onReset","InspectorControls","__experimentalToolsPanel","resetAll","autoplay","loop","muted","playsInline","preload","posterImage","Disabled","isDisabled","ref","Spinner","Caption","showToolbarButton","_default","exports"],"sources":["@wordpress/block-library/src/video/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tSpinner,\n\tPlaceholder,\n\t__experimentalToolsPanel as ToolsPanel,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport {\n\tuseUploadMediaFromBlobURL,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\nimport { Caption } from '../utils/caption';\nimport PosterImage from '../utils/poster-image';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\n\nfunction VideoEdit( {\n\tisSelected: isSingleSelected,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n} ) {\n\tconst videoPlayer = useRef();\n\tconst { id, controls, poster, src, tracks } = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst hasNonContentControls = blockEditingMode === 'default';\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectVideo,\n\t\tonError: onUploadError,\n\t} );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\t// TODO: Whether the video was obtained from the media library or was provided by URL, obtain the `videoWidth` and `videoHeight` of the video once its metadata has loaded and persist in the block attributes.\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t\tcaption: media.caption,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\tsrc: newSrc,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t}\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\t\twithIllustration={ ! isSingleSelected }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ __( 'Video' ) }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Drag and drop a video, upload, or choose from your library.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src && ! temporaryURL ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<TracksEditor\n\t\t\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\t\tmediaId={ id }\n\t\t\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\t\tonReset={ () => onSelectVideo( undefined ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\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\tautoplay: false,\n\t\t\t\t\t\t\tcontrols: true,\n\t\t\t\t\t\t\tloop: false,\n\t\t\t\t\t\t\tmuted: false,\n\t\t\t\t\t\t\tplaysInline: false,\n\t\t\t\t\t\t\tpreload: 'metadata',\n\t\t\t\t\t\t\tposter: undefined,\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<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<PosterImage\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tonChange={ ( posterImage ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tposter: posterImage?.url,\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</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n Disable the video tag if the block is not selected\n so the user clicking on it won't play the\n video when the controls are enabled.\n */ }\n\t\t\t\t<Disabled isDisabled={ ! isSingleSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src || temporaryURL }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ !! temporaryURL && <Spinner /> }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tlabel={ __( 'Video caption text' ) }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\tisSingleSelected && hasNonContentControls\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default VideoEdit;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AASA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,KAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAIA,IAAAW,mBAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,aAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,OAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,QAAA,GAAAd,OAAA;AACA,IAAAe,YAAA,GAAAhB,sBAAA,CAAAC,OAAA;AAAgD,IAAAgB,WAAA,GAAAhB,OAAA;AA1ChD;AACA;AACA;;AA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MACpB,CACD,CAAC;IAAA,CACK,CAAC;EAAA,CACR,CAAC;AAEL;AAAC,IAAAqE,QAAA,GAAAC,OAAA,CAAAvB,OAAA,GAEctE,SAAS","ignoreList":[]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useBlockProps, useInnerBlocksProps, InspectorControls } from '@wordpress/block-editor';
|
|
4
|
+
import { useBlockProps, useInnerBlocksProps, InspectorControls, BlockControls, store as blockEditorStore } from '@wordpress/block-editor';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
6
|
+
import { ToggleControl, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, ToolbarButton } from '@wordpress/components';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
|
+
import { createBlock } from '@wordpress/blocks';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Internal dependencies
|
|
@@ -20,18 +22,33 @@ export default function Edit({
|
|
|
20
22
|
iconPosition,
|
|
21
23
|
showIcon
|
|
22
24
|
},
|
|
25
|
+
clientId,
|
|
23
26
|
setAttributes
|
|
24
27
|
}) {
|
|
25
28
|
const blockProps = useBlockProps();
|
|
26
29
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
30
|
+
const {
|
|
31
|
+
insertBlock
|
|
32
|
+
} = useDispatch(blockEditorStore);
|
|
27
33
|
const innerBlocksProps = useInnerBlocksProps(blockProps, {
|
|
28
34
|
template: [[ACCORDION_BLOCK_NAME], [ACCORDION_BLOCK_NAME]],
|
|
29
35
|
defaultBlock: ACCORDION_BLOCK,
|
|
30
36
|
directInsert: true,
|
|
31
37
|
templateInsertUpdatesSelection: true
|
|
32
38
|
});
|
|
39
|
+
const addAccordionContentBlock = () => {
|
|
40
|
+
const newAccordionContent = createBlock(ACCORDION_BLOCK_NAME);
|
|
41
|
+
insertBlock(newAccordionContent, undefined, clientId);
|
|
42
|
+
};
|
|
33
43
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
34
|
-
children: [/*#__PURE__*/_jsx(
|
|
44
|
+
children: [/*#__PURE__*/_jsx(BlockControls, {
|
|
45
|
+
group: "other",
|
|
46
|
+
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
47
|
+
label: __('Add accordion content block'),
|
|
48
|
+
onClick: addAccordionContentBlock,
|
|
49
|
+
children: __('Add')
|
|
50
|
+
})
|
|
51
|
+
}), /*#__PURE__*/_jsx(InspectorControls, {
|
|
35
52
|
children: /*#__PURE__*/_jsxs(ToolsPanel, {
|
|
36
53
|
label: __('Settings'),
|
|
37
54
|
resetAll: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useBlockProps","useInnerBlocksProps","InspectorControls","__","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useToolsPanelDropdownMenuProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ACCORDION_BLOCK_NAME","ACCORDION_BLOCK","name","Edit","attributes","autoclose","iconPosition","showIcon","setAttributes","blockProps","dropdownMenuProps","innerBlocksProps","template","defaultBlock","directInsert","templateInsertUpdatesSelection","children","label","resetAll","isShownByDefault","hasValue","onDeselect","isBlock","__nextHasNoMarginBottom","onChange","value","checked","help","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/accordion/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-content';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: { autoclose, iconPosition, showIcon },\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ], [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: 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\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\tlabel={ __( 'Right' ) }\n\t\t\t\t\t\t\t\tvalue=\"right\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,mBAAmB,EACnBC,iBAAiB,
|
|
1
|
+
{"version":3,"names":["useBlockProps","useInnerBlocksProps","InspectorControls","BlockControls","store","blockEditorStore","__","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","ToolbarButton","useDispatch","createBlock","useToolsPanelDropdownMenuProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ACCORDION_BLOCK_NAME","ACCORDION_BLOCK","name","Edit","attributes","autoclose","iconPosition","showIcon","clientId","setAttributes","blockProps","dropdownMenuProps","insertBlock","innerBlocksProps","template","defaultBlock","directInsert","templateInsertUpdatesSelection","addAccordionContentBlock","newAccordionContent","undefined","children","group","label","onClick","resetAll","isShownByDefault","hasValue","onDeselect","isBlock","__nextHasNoMarginBottom","onChange","value","checked","help","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/accordion/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tToolbarButton,\n} from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst ACCORDION_BLOCK_NAME = 'core/accordion-content';\nconst ACCORDION_BLOCK = {\n\tname: ACCORDION_BLOCK_NAME,\n};\n\nexport default function Edit( {\n\tattributes: { autoclose, iconPosition, showIcon },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { insertBlock } = useDispatch( blockEditorStore );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: [ [ ACCORDION_BLOCK_NAME ], [ ACCORDION_BLOCK_NAME ] ],\n\t\tdefaultBlock: ACCORDION_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplateInsertUpdatesSelection: true,\n\t} );\n\n\tconst addAccordionContentBlock = () => {\n\t\tconst newAccordionContent = createBlock( ACCORDION_BLOCK_NAME );\n\t\tinsertBlock( newAccordionContent, undefined, clientId );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tlabel={ __( 'Add accordion content block' ) }\n\t\t\t\t\tonClick={ addAccordionContentBlock }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls key=\"setting\">\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\tautoclose: false,\n\t\t\t\t\t\t\tshowIcon: true,\n\t\t\t\t\t\t\ticonPosition: 'right',\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={ __( 'Auto-close' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => !! autoclose }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { autoclose: 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\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Auto-close' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tautoclose: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ autoclose }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Automatically close accordions when a new one is opened.'\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\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showIcon }\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { showIcon: true } ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show icon' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowIcon: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tchecked={ showIcon }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Display a plus icon next to the accordion header.'\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\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => iconPosition !== 'right' }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { iconPosition: 'right' } )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tlabel={ __( 'Icon Position' ) }\n\t\t\t\t\t\t\tvalue={ iconPosition }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { iconPosition: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\tlabel={ __( 'Left' ) }\n\t\t\t\t\t\t\t\tvalue=\"left\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\t\tlabel={ __( 'Right' ) }\n\t\t\t\t\t\t\t\tvalue=\"right\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,mBAAmB,EACnBC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,EAC9CC,aAAa,QACP,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,SAASC,8BAA8B,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAEhE,MAAMC,oBAAoB,GAAG,wBAAwB;AACrD,MAAMC,eAAe,GAAG;EACvBC,IAAI,EAAEF;AACP,CAAC;AAED,eAAe,SAASG,IAAIA,CAAE;EAC7BC,UAAU,EAAE;IAAEC,SAAS;IAAEC,YAAY;IAAEC;EAAS,CAAC;EACjDC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAMC,UAAU,GAAGpC,aAAa,CAAC,CAAC;EAClC,MAAMqC,iBAAiB,GAAGlB,8BAA8B,CAAC,CAAC;EAC1D,MAAM;IAAEmB;EAAY,CAAC,GAAGrB,WAAW,CAAEZ,gB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E,eAAgB,CAAG;YAC/BoD,KAAK,EAAG1B,YAAc;YACtByB,QAAQ,EAAKC,KAAK,IAAM;cACvBvB,aAAa,CAAE;gBAAEH,YAAY,EAAE0B;cAAM,CAAE,CAAC;YACzC,CAAG;YAAAX,QAAA,gBAEH1B,IAAA,CAACV,wBAAwB;cACxBsC,KAAK,EAAG3C,EAAE,CAAE,MAAO,CAAG;cACtBoD,KAAK,EAAC;YAAM,CACZ,CAAC,eACFrC,IAAA,CAACV,wBAAwB;cACxBsC,KAAK,EAAG3C,EAAE,CAAE,OAAQ,CAAG;cACvBoD,KAAK,EAAC;YAAO,CACb,CAAC;UAAA,CACiB;QAAC,CACN,CAAC;MAAA,CACN;IAAC,GApFS,SAqFJ,CAAC,eACpBrC,IAAA;MAAA,GAAUkB;IAAgB,CAAI,CAAC;EAAA,CAC9B,CAAC;AAEL","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["edit","save","metadata","$schema","apiVersion","name","title","category","description","example","__experimental","supports","html","align","background","backgroundImage","backgroundSize","__experimentalDefaultControls","color","gradient","__experimentalBorder","radius","style","width","spacing","padding","margin","blockGap","shadow","layout","interactivity","attributes","iconPosition","type","showIcon","autoclose","
|
|
1
|
+
{"version":3,"names":["edit","save","metadata","$schema","apiVersion","name","title","category","description","example","__experimental","supports","html","align","background","backgroundImage","backgroundSize","__experimentalDefaultControls","color","gradient","__experimentalBorder","radius","style","width","spacing","padding","margin","blockGap","shadow","layout","interactivity","attributes","iconPosition","type","showIcon","autoclose","providesContext","allowedBlocks","textdomain","initBlock","icon","settings","init"],"sources":["@wordpress/block-library/src/accordion/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport save from './save';\nimport metadata from './block.json';\nimport initBlock from '../utils/init-block';\nimport icon from './icon';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( {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ignoreList":[]}
|
|
@@ -7,16 +7,13 @@ const metadata = {
|
|
|
7
7
|
$schema: "https://schemas.wp.org/trunk/block.json",
|
|
8
8
|
apiVersion: 3,
|
|
9
9
|
name: "core/accordion-content",
|
|
10
|
-
version: "0.1.0",
|
|
11
10
|
title: "Accordion Content",
|
|
12
11
|
category: "design",
|
|
13
12
|
description: "Displays a section of content in an accordion, including a header and expandable content.",
|
|
14
|
-
example: {},
|
|
15
13
|
__experimental: true,
|
|
16
14
|
parent: ["core/accordion"],
|
|
17
15
|
allowedBlocks: ["core/accordion-header", "core/accordion-panel"],
|
|
18
16
|
supports: {
|
|
19
|
-
align: ["wide", "full"],
|
|
20
17
|
color: {
|
|
21
18
|
background: true,
|
|
22
19
|
gradient: true
|
|
@@ -56,7 +53,6 @@ const {
|
|
|
56
53
|
export { metadata, name };
|
|
57
54
|
export const settings = {
|
|
58
55
|
icon,
|
|
59
|
-
example: {},
|
|
60
56
|
edit,
|
|
61
57
|
save
|
|
62
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["edit","save","metadata","$schema","apiVersion","name","
|
|
1
|
+
{"version":3,"names":["edit","save","metadata","$schema","apiVersion","name","title","category","description","__experimental","parent","allowedBlocks","supports","color","background","gradient","interactivity","spacing","margin","blockGap","__experimentalBorder","radius","style","width","__experimentalDefaultControls","shadow","attributes","openByDefault","type","textdomain","initBlock","icon","settings","init"],"sources":["@wordpress/block-library/src/accordion-content/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport save from './save';\nimport metadata from './block.json';\nimport initBlock from '../utils/init-block';\nimport icon from './icon';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,QAAQ;AACzB,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,cAAA;EAAAC,MAAA;EAAAC,aAAA;EAAAC,QAAA;IAAAC,KAAA;MAAAC,UAAA;MAAAC,QAAA;IAAA;IAAAC,aAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,QAAA;IAAA;IAAAC,oBAAA;MAAAP,KAAA;MAAAQ,MAAA;MAAAC,KAAA;MAAAC,KAAA;MAAAC,6BAAA;QAAAX,KAAA;QAAAQ,MAAA;QAAAC,KAAA;QAAAC,KAAA;MAAA;IAAA;IAAAE,MAAA;EAAA;EAAAC,UAAA;IAAAC,aAAA;MAAAC,IAAA;MAAA;IAAA;EAAA;EAAAC,UAAA;AAAA;AAE1B,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAE1B;AAAK,CAAC,GAAGH,QAAQ;AAEzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM2B,QAAQ,GAAG;EACvBD,IAAI;EACJ/B,IAAI;EACJC;AACD,CAAC;AAED,OAAO,MAAMgC,IAAI,GAAGA,CAAA,KAAMH,SAAS,CAAE;EAAEzB,IAAI;EAAEH,QAAQ;EAAE8B;AAAS,CAAE,CAAC","ignoreList":[]}
|
|
@@ -7,11 +7,9 @@ const metadata = {
|
|
|
7
7
|
$schema: "https://schemas.wp.org/trunk/block.json",
|
|
8
8
|
apiVersion: 3,
|
|
9
9
|
name: "core/accordion-header",
|
|
10
|
-
version: "0.1.0",
|
|
11
10
|
title: "Accordion Header",
|
|
12
11
|
category: "design",
|
|
13
12
|
description: "Displays an accordion header.",
|
|
14
|
-
example: {},
|
|
15
13
|
__experimental: true,
|
|
16
14
|
parent: ["core/accordion-content"],
|
|
17
15
|
usesContext: ["core/accordion-icon-position", "core/accordion-show-icon"],
|
|
@@ -22,7 +20,6 @@ const metadata = {
|
|
|
22
20
|
gradient: true
|
|
23
21
|
},
|
|
24
22
|
align: false,
|
|
25
|
-
border: true,
|
|
26
23
|
interactivity: true,
|
|
27
24
|
spacing: {
|
|
28
25
|
padding: true,
|
|
@@ -101,7 +98,6 @@ const {
|
|
|
101
98
|
export { metadata, name };
|
|
102
99
|
export const settings = {
|
|
103
100
|
icon,
|
|
104
|
-
example: {},
|
|
105
101
|
edit,
|
|
106
102
|
save
|
|
107
103
|
};
|