@wordpress/block-library 8.26.0 → 8.27.1
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/avatar/edit.js +2 -2
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +76 -13
- package/build/block/edit.js.map +1 -1
- package/build/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/build/block/edit.native.js.map +1 -0
- package/build/block/index.js +5 -3
- package/build/block/index.js.map +1 -1
- package/build/button/edit.js +24 -6
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +3 -1
- package/build/button/save.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +13 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit.native.js +1 -0
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/index.js +3 -0
- package/build/cover/index.js.map +1 -1
- package/build/embed/edit.js +3 -2
- package/build/embed/edit.js.map +1 -1
- package/build/file/index.js +0 -1
- package/build/file/index.js.map +1 -1
- package/build/footnotes/edit.js +2 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +17 -19
- package/build/footnotes/format.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +2 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/edit.native.js +141 -0
- package/build/heading/edit.native.js.map +1 -0
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +33 -7
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -3
- package/build/image/index.js.map +1 -1
- package/build/more/index.js +4 -0
- package/build/more/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/paragraph/edit.js +2 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +1 -2
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -2
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-content/edit.js +2 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +43 -2
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +8 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/pullquote/index.js +4 -0
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -7
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +1 -2
- package/build/query/index.js.map +1 -1
- package/build/query/variations.js +8 -1
- package/build/query/variations.js.map +1 -1
- package/build/query/view.js +31 -12
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +0 -1
- package/build/search/index.js.map +1 -1
- package/build/table-of-contents/hooks.js +2 -2
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -4
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +39 -17
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/edit.native.js +7 -2
- package/build/video/edit.native.js.map +1 -1
- package/build/video/transforms.js +17 -0
- package/build/video/transforms.js.map +1 -1
- package/build-module/avatar/edit.js +2 -2
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +76 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/{v1/edit.native.js → edit.native.js} +3 -3
- package/build-module/block/edit.native.js.map +1 -0
- package/build-module/block/index.js +5 -3
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.js +25 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +4 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +14 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit.native.js +1 -0
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/index.js +3 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/edit.js +3 -2
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/file/index.js +0 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/footnotes/edit.js +2 -1
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +17 -19
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +3 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/edit.native.js +132 -0
- package/build-module/heading/edit.native.js.map +1 -0
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +33 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/more/index.js +4 -0
- package/build-module/more/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +1 -2
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -2
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +44 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +8 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/pullquote/index.js +4 -0
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +7 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +1 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/variations.js +8 -1
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query/view.js +30 -9
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +0 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +2 -2
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -4
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +38 -16
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/edit.native.js +7 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/transforms.js +17 -0
- package/build-module/video/transforms.js.map +1 -1
- package/build-style/common-rtl.css +4 -2
- package/build-style/common.css +4 -2
- package/build-style/cover/style-rtl.css +2 -4
- package/build-style/cover/style.css +2 -4
- package/build-style/editor-rtl.css +6 -4
- package/build-style/editor.css +6 -4
- package/build-style/gallery/style-rtl.css +2 -4
- package/build-style/gallery/style.css +2 -4
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/pullquote/style-rtl.css +10 -1
- package/build-style/pullquote/style.css +10 -1
- package/build-style/search/style-rtl.css +2 -1
- package/build-style/search/style.css +2 -1
- package/build-style/style-rtl.css +20 -13
- package/build-style/style.css +20 -13
- package/build-style/video/style-rtl.css +1 -2
- package/build-style/video/style.css +1 -2
- package/package.json +34 -32
- package/src/avatar/edit.js +16 -18
- package/src/block/block.json +3 -0
- package/src/block/edit.js +102 -20
- package/src/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/src/block/index.js +2 -3
- package/src/block/index.php +3 -31
- package/src/button/block.json +1 -0
- package/src/button/edit.js +76 -43
- package/src/button/save.js +3 -0
- package/src/buttons/test/__snapshots__/edit.native.js.snap +6 -0
- package/src/buttons/test/edit.native.js +49 -0
- package/src/cover/block.json +3 -0
- package/src/cover/edit/index.js +2 -1
- package/src/cover/edit/inspector-controls.js +14 -1
- package/src/cover/edit.native.js +1 -0
- package/src/cover/style.scss +2 -3
- package/src/embed/edit.js +3 -2
- package/src/file/block.json +0 -1
- package/src/file/index.php +11 -57
- package/src/footnotes/edit.js +2 -1
- package/src/footnotes/format.js +34 -31
- package/src/footnotes/index.php +20 -11
- package/src/gallery/index.php +0 -3
- package/src/group/block.json +1 -0
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +18 -14
- package/src/heading/edit.native.js +144 -0
- package/src/image/block.json +7 -3
- package/src/image/edit.js +19 -6
- package/src/image/editor.scss +6 -1
- package/src/image/image.js +101 -42
- package/src/image/index.js +6 -0
- package/src/image/index.php +14 -51
- package/src/more/index.js +6 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/index.php +777 -28
- package/src/navigation-link/index.php +78 -16
- package/src/page-list/editor.scss +0 -4
- package/src/paragraph/block.json +1 -2
- package/src/paragraph/edit.js +23 -19
- package/src/post-content/edit.js +2 -2
- package/src/post-date/edit.js +38 -33
- package/src/post-navigation-link/block.json +8 -0
- package/src/post-navigation-link/edit.js +63 -1
- package/src/post-navigation-link/index.php +17 -3
- package/src/post-terms/index.php +13 -4
- package/src/pullquote/block.json +4 -0
- package/src/pullquote/style.scss +13 -1
- package/src/query/block.json +1 -2
- package/src/query/edit/inspector-controls/index.js +137 -146
- package/src/query/edit/query-content.js +9 -7
- package/src/query/edit/query-placeholder.js +11 -11
- package/src/query/index.php +33 -71
- package/src/query/variations.js +4 -0
- package/src/query/view.js +24 -19
- package/src/search/block.json +0 -1
- package/src/search/index.php +18 -36
- package/src/table-of-contents/hooks.js +2 -2
- package/src/template-part/edit/advanced-controls.js +2 -3
- package/src/template-part/edit/index.js +77 -50
- package/src/template-part/index.php +2 -2
- package/src/video/edit.native.js +5 -2
- package/src/video/test/edit.native.js +38 -0
- package/src/video/transforms.js +32 -0
- package/tsconfig.json +1 -0
- package/build/block/v1/edit.js +0 -116
- package/build/block/v1/edit.js.map +0 -1
- package/build/block/v1/edit.native.js.map +0 -1
- package/build-module/block/v1/edit.js +0 -108
- package/build-module/block/v1/edit.js.map +0 -1
- package/build-module/block/v1/edit.native.js.map +0 -1
- package/src/block/v1/edit.js +0 -163
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_icons2","QUERY_DEFAULT_ATTRIBUTES","query","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","variations","name","title","__","description","icon","postList","attributes","scope","titleDate","innerBlocks","titleExcerpt","titleDateExcerpt","imageDateTitle","_default","exports","default"],"sources":["@wordpress/block-library/src/query/variations.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { postList } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\ttitleDate,\n\ttitleExcerpt,\n\ttitleDateExcerpt,\n\timageDateTitle,\n} from './icons';\n\nconst QUERY_DEFAULT_ATTRIBUTES = {\n\tquery: {\n\t\tperPage: 3,\n\t\tpages: 0,\n\t\toffset: 0,\n\t\tpostType: 'post',\n\t\torder: 'desc',\n\t\torderBy: 'date',\n\t\tauthor: '',\n\t\tsearch: '',\n\t\texclude: [],\n\t\tsticky: '',\n\t\tinherit: false,\n\t},\n};\n\nconst variations = [\n\t{\n\t\tname: 'posts-list',\n\t\ttitle: __( 'Posts List' ),\n\t\tdescription: __(\n\t\t\t'Display a list of your most recent posts, excluding sticky posts.'\n\t\t),\n\t\ticon: postList,\n\t\tattributes: {\n\t\t\tquery: {\n\t\t\t\tperPage: 4,\n\t\t\t\tpages: 1,\n\t\t\t\toffset: 0,\n\t\t\t\tpostType: 'post',\n\t\t\t\torder: 'desc',\n\t\t\t\torderBy: 'date',\n\t\t\t\tauthor: '',\n\t\t\t\tsearch: '',\n\t\t\t\tsticky: 'exclude',\n\t\t\t\tinherit: false,\n\t\t\t},\n\t\t},\n\t\tscope: [ 'inserter' ],\n\t},\n\t{\n\t\tname: 'title-date',\n\t\ttitle: __( 'Title & Date' ),\n\t\ticon: titleDate,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[ [ 'core/post-title' ], [ 'core/post-date' ] ],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n\t{\n\t\tname: 'title-excerpt',\n\t\ttitle: __( 'Title & Excerpt' ),\n\t\ticon: titleExcerpt,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[ [ 'core/post-title' ], [ 'core/post-excerpt' ] ],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n\t{\n\t\tname: 'title-date-excerpt',\n\t\ttitle: __( 'Title, Date, & Excerpt' ),\n\t\ticon: titleDateExcerpt,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[\n\t\t\t\t\t[ 'core/post-title' ],\n\t\t\t\t\t[ 'core/post-date' ],\n\t\t\t\t\t[ 'core/post-excerpt' ],\n\t\t\t\t],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n\t{\n\t\tname: 'image-date-title',\n\t\ttitle: __( 'Image, Date, & Title' ),\n\t\ticon: imageDateTitle,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[\n\t\t\t\t\t[ 'core/post-featured-image' ],\n\t\t\t\t\t[ 'core/post-date' ],\n\t\t\t\t\t[ 'core/post-title' ],\n\t\t\t\t],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n];\n\nexport default variations;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMG,wBAAwB,GAAG;EAChCC,KAAK,EAAE;IACNC,OAAO,EAAE,CAAC;IACVC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,QAAQ,EAAE,MAAM;IAChBC,KAAK,EAAE,MAAM;IACbC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE,EAAE;IACXC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE;EACV;AACD,CAAC;AAED,MAAMC,UAAU,GAAG,CAClB;EACCC,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,IAAAC,QAAE,EAAE,YAAa,CAAC;EACzBC,WAAW,EAAE,IAAAD,QAAE,EACd,mEACD,CAAC;EACDE,IAAI,EAAEC,eAAQ;EACdC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_icons2","QUERY_DEFAULT_ATTRIBUTES","query","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","variations","name","title","__","description","icon","postList","attributes","namespace","scope","isActive","titleDate","innerBlocks","titleExcerpt","titleDateExcerpt","imageDateTitle","_default","exports","default"],"sources":["@wordpress/block-library/src/query/variations.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { postList } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\ttitleDate,\n\ttitleExcerpt,\n\ttitleDateExcerpt,\n\timageDateTitle,\n} from './icons';\n\nconst QUERY_DEFAULT_ATTRIBUTES = {\n\tquery: {\n\t\tperPage: 3,\n\t\tpages: 0,\n\t\toffset: 0,\n\t\tpostType: 'post',\n\t\torder: 'desc',\n\t\torderBy: 'date',\n\t\tauthor: '',\n\t\tsearch: '',\n\t\texclude: [],\n\t\tsticky: '',\n\t\tinherit: false,\n\t},\n};\n\nconst variations = [\n\t{\n\t\tname: 'posts-list',\n\t\ttitle: __( 'Posts List' ),\n\t\tdescription: __(\n\t\t\t'Display a list of your most recent posts, excluding sticky posts.'\n\t\t),\n\t\ticon: postList,\n\t\tattributes: {\n\t\t\tnamespace: 'core/posts-list',\n\t\t\tquery: {\n\t\t\t\tperPage: 4,\n\t\t\t\tpages: 1,\n\t\t\t\toffset: 0,\n\t\t\t\tpostType: 'post',\n\t\t\t\torder: 'desc',\n\t\t\t\torderBy: 'date',\n\t\t\t\tauthor: '',\n\t\t\t\tsearch: '',\n\t\t\t\tsticky: 'exclude',\n\t\t\t\tinherit: false,\n\t\t\t},\n\t\t},\n\t\tscope: [ 'inserter' ],\n\t\tisActive: ( { namespace, query } ) => {\n\t\t\treturn namespace === 'core/posts-list' && query.postType === 'post';\n\t\t},\n\t},\n\t{\n\t\tname: 'title-date',\n\t\ttitle: __( 'Title & Date' ),\n\t\ticon: titleDate,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[ [ 'core/post-title' ], [ 'core/post-date' ] ],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n\t{\n\t\tname: 'title-excerpt',\n\t\ttitle: __( 'Title & Excerpt' ),\n\t\ticon: titleExcerpt,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[ [ 'core/post-title' ], [ 'core/post-excerpt' ] ],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n\t{\n\t\tname: 'title-date-excerpt',\n\t\ttitle: __( 'Title, Date, & Excerpt' ),\n\t\ticon: titleDateExcerpt,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[\n\t\t\t\t\t[ 'core/post-title' ],\n\t\t\t\t\t[ 'core/post-date' ],\n\t\t\t\t\t[ 'core/post-excerpt' ],\n\t\t\t\t],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n\t{\n\t\tname: 'image-date-title',\n\t\ttitle: __( 'Image, Date, & Title' ),\n\t\ticon: imageDateTitle,\n\t\tattributes: { ...QUERY_DEFAULT_ATTRIBUTES },\n\t\tinnerBlocks: [\n\t\t\t[\n\t\t\t\t'core/post-template',\n\t\t\t\t{},\n\t\t\t\t[\n\t\t\t\t\t[ 'core/post-featured-image' ],\n\t\t\t\t\t[ 'core/post-date' ],\n\t\t\t\t\t[ 'core/post-title' ],\n\t\t\t\t],\n\t\t\t],\n\t\t\t[ 'core/query-pagination' ],\n\t\t\t[ 'core/query-no-results' ],\n\t\t],\n\t\tscope: [ 'block' ],\n\t},\n];\n\nexport default variations;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMG,wBAAwB,GAAG;EAChCC,KAAK,EAAE;IACNC,OAAO,EAAE,CAAC;IACVC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACTC,QAAQ,EAAE,MAAM;IAChBC,KAAK,EAAE,MAAM;IACbC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE,EAAE;IACXC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE;EACV;AACD,CAAC;AAED,MAAMC,UAAU,GAAG,CAClB;EACCC,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,IAAAC,QAAE,EAAE,YAAa,CAAC;EACzBC,WAAW,EAAE,IAAAD,QAAE,EACd,mEACD,CAAC;EACDE,IAAI,EAAEC,eAAQ;EACdC,UAAU,EAAE;IACXC,SAAS,EAAE,iBAAiB;IAC5BpB,KAAK,EAAE;MACNC,OAAO,EAAE,CAAC;MACVC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;MACTC,QAAQ,EAA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AI,EAAES,wBAAgB;EACtBP,UAAU,EAAE;IAAE,GAAGpB;EAAyB,CAAC;EAC3CyB,WAAW,EAAE,CACZ,CACC,oBAAoB,EACpB,CAAC,CAAC,EACF,CACC,CAAE,iBAAiB,CAAE,EACrB,CAAE,gBAAgB,CAAE,EACpB,CAAE,mBAAmB,CAAE,CACvB,CACD,EACD,CAAE,uBAAuB,CAAE,EAC3B,CAAE,uBAAuB,CAAE,CAC3B;EACDH,KAAK,EAAE,CAAE,OAAO;AACjB,CAAC,EACD;EACCR,IAAI,EAAE,kBAAkB;EACxBC,KAAK,EAAE,IAAAC,QAAE,EAAE,sBAAuB,CAAC;EACnCE,IAAI,EAAEU,sBAAc;EACpBR,UAAU,EAAE;IAAE,GAAGpB;EAAyB,CAAC;EAC3CyB,WAAW,EAAE,CACZ,CACC,oBAAoB,EACpB,CAAC,CAAC,EACF,CACC,CAAE,0BAA0B,CAAE,EAC9B,CAAE,gBAAgB,CAAE,EACpB,CAAE,iBAAiB,CAAE,CACrB,CACD,EACD,CAAE,uBAAuB,CAAE,EAC3B,CAAE,uBAAuB,CAAE,CAC3B;EACDH,KAAK,EAAE,CAAE,OAAO;AACjB,CAAC,CACD;AAAC,IAAAO,QAAA,GAEahB,UAAU;AAAAiB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/build/query/view.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interactivity = require("@wordpress/interactivity");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
|
|
4
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
5
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
8
6
|
const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
|
|
9
7
|
const isValidEvent = event => event.button === 0 &&
|
|
10
8
|
// Left clicks only.
|
|
@@ -30,17 +28,22 @@ const isValidEvent = event => event.button === 0 &&
|
|
|
30
28
|
const {
|
|
31
29
|
ref
|
|
32
30
|
} = (0, _interactivity.getElement)();
|
|
33
|
-
const
|
|
31
|
+
const {
|
|
32
|
+
queryRef
|
|
33
|
+
} = ctx;
|
|
34
|
+
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
|
|
34
35
|
if (isValidLink(ref) && isValidEvent(event) && !isDisabled) {
|
|
35
36
|
event.preventDefault();
|
|
36
|
-
const id = ref.closest('[data-wp-navigation-id]').dataset.wpNavigationId;
|
|
37
37
|
|
|
38
38
|
// Don't announce the navigation immediately, wait 400 ms.
|
|
39
39
|
const timeout = setTimeout(() => {
|
|
40
40
|
ctx.message = ctx.loadingText;
|
|
41
41
|
ctx.animation = 'start';
|
|
42
42
|
}, 400);
|
|
43
|
-
|
|
43
|
+
const {
|
|
44
|
+
actions
|
|
45
|
+
} = yield Promise.resolve().then(() => _interopRequireWildcard(require('@wordpress/interactivity-router')));
|
|
46
|
+
yield actions.navigate(ref.href);
|
|
44
47
|
|
|
45
48
|
// Dismiss loading message if it hasn't been added yet.
|
|
46
49
|
clearTimeout(timeout);
|
|
@@ -53,17 +56,23 @@ const isValidEvent = event => event.button === 0 &&
|
|
|
53
56
|
ctx.url = ref.href;
|
|
54
57
|
|
|
55
58
|
// Focus the first anchor of the Query block.
|
|
56
|
-
const firstAnchor =
|
|
57
|
-
|
|
59
|
+
const firstAnchor = `.wp-block-post-template a[href]`;
|
|
60
|
+
queryRef.querySelector(firstAnchor)?.focus();
|
|
58
61
|
}
|
|
59
62
|
},
|
|
60
63
|
*prefetch() {
|
|
64
|
+
const {
|
|
65
|
+
queryRef
|
|
66
|
+
} = (0, _interactivity.getContext)();
|
|
61
67
|
const {
|
|
62
68
|
ref
|
|
63
69
|
} = (0, _interactivity.getElement)();
|
|
64
|
-
const isDisabled =
|
|
70
|
+
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
|
|
65
71
|
if (isValidLink(ref) && !isDisabled) {
|
|
66
|
-
|
|
72
|
+
const {
|
|
73
|
+
actions
|
|
74
|
+
} = yield Promise.resolve().then(() => _interopRequireWildcard(require('@wordpress/interactivity-router')));
|
|
75
|
+
yield actions.prefetch(ref.href);
|
|
67
76
|
}
|
|
68
77
|
}
|
|
69
78
|
},
|
|
@@ -76,8 +85,18 @@ const isValidEvent = event => event.button === 0 &&
|
|
|
76
85
|
ref
|
|
77
86
|
} = (0, _interactivity.getElement)();
|
|
78
87
|
if (url && isValidLink(ref)) {
|
|
79
|
-
|
|
88
|
+
const {
|
|
89
|
+
actions
|
|
90
|
+
} = yield Promise.resolve().then(() => _interopRequireWildcard(require('@wordpress/interactivity-router')));
|
|
91
|
+
yield actions.prefetch(ref.href);
|
|
80
92
|
}
|
|
93
|
+
},
|
|
94
|
+
setQueryRef() {
|
|
95
|
+
const ctx = (0, _interactivity.getContext)();
|
|
96
|
+
const {
|
|
97
|
+
ref
|
|
98
|
+
} = (0, _interactivity.getElement)();
|
|
99
|
+
ctx.queryRef = ref;
|
|
81
100
|
}
|
|
82
101
|
}
|
|
83
102
|
});
|
package/build/query/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_interactivity","require","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","store","state","startAnimation","getContext","animation","finishAnimation","actions","navigate","ctx","getElement","
|
|
1
|
+
{"version":3,"names":["_interactivity","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_interopRequireWildcard","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","store","state","startAnimation","getContext","animation","finishAnimation","actions","navigate","ctx","getElement","queryRef","isDisabled","dataset","wpNavigationDisabled","preventDefault","timeout","setTimeout","message","loadingText","Promise","resolve","then","clearTimeout","loadedText","url","firstAnchor","querySelector","focus","prefetch","callbacks","setQueryRef"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // Left clicks only.\n\t! event.metaKey && // Open in new tab (Mac).\n\t! event.ctrlKey && // Open in new tab (Windows).\n\t! event.altKey && // Download.\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( 'core/query', {\n\tstate: {\n\t\tget startAnimation() {\n\t\t\treturn getContext().animation === 'start';\n\t\t},\n\t\tget finishAnimation() {\n\t\t\treturn getContext().animation === 'finish';\n\t\t},\n\t},\n\tactions: {\n\t\t*navigate( event ) {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tconst { queryRef } = ctx;\n\t\t\tconst isDisabled = queryRef?.dataset.wpNavigationDisabled;\n\n\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) && ! isDisabled ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// Don't announce the navigation immediately, wait 400 ms.\n\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\tctx.message = ctx.loadingText;\n\t\t\t\t\tctx.animation = 'start';\n\t\t\t\t}, 400 );\n\n\t\t\t\tconst { actions } = yield import(\n\t\t\t\t\t'@wordpress/interactivity-router'\n\t\t\t\t);\n\t\t\t\tyield actions.navigate( ref.href );\n\n\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\tctx.message =\n\t\t\t\t\tctx.loadedText +\n\t\t\t\t\t( ctx.message === ctx.loadedText ? '\\u00A0' : '' );\n\n\t\t\t\tctx.animation = 'finish';\n\t\t\t\tctx.url = ref.href;\n\n\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\tconst firstAnchor = `.wp-block-post-template a[href]`;\n\t\t\t\tqueryRef.querySelector( firstAnchor )?.focus();\n\t\t\t}\n\t\t},\n\t\t*prefetch() {\n\t\t\tconst { queryRef } = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tconst isDisabled = queryRef?.dataset.wpNavigationDisabled;\n\t\t\tif ( isValidLink( ref ) && ! isDisabled ) {\n\t\t\t\tconst { actions } = yield import(\n\t\t\t\t\t'@wordpress/interactivity-router'\n\t\t\t\t);\n\t\t\t\tyield actions.prefetch( ref.href );\n\t\t\t}\n\t\t},\n\t},\n\tcallbacks: {\n\t\t*prefetch() {\n\t\t\tconst { url } = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tif ( url && isValidLink( ref ) ) {\n\t\t\t\tconst { actions } = yield import(\n\t\t\t\t\t'@wordpress/interactivity-router'\n\t\t\t\t);\n\t\t\t\tyield actions.prefetch( ref.href );\n\t\t\t}\n\t\t},\n\t\tsetQueryRef() {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tctx.queryRef = ref;\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAAyE,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAI,wBAAAC,GAAA,EAAAL,WAAA,SAAAA,WAAA,IAAAK,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAT,wBAAA,CAAAC,WAAA,OAAAQ,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK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C,MAAM;UAAEL;QAAQ,CAAC,GAAG,MAAAa,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAvD,uBAAA,CAAAN,OAAA,CACnB,iCAAiC,GACjC;QACD,MAAM8C,OAAO,CAACsB,QAAQ,CAAE3C,GAAG,CAACG,IAAK,CAAC;MACnC;IACD;EACD,CAAC;EACDyC,SAAS,EAAE;IACV,CAACD,QAAQA,CAAA,EAAG;MACX,MAAM;QAAEJ;MAAI,CAAC,GAAG,IAAArB,yBAAU,EAAC,CAAC;MAC5B,MAAM;QAAElB;MAAI,CAAC,GAAG,IAAAwB,yBAAU,EAAC,CAAC;MAC5B,IAAKe,GAAG,IAAIxC,WAAW,CAAEC,GAAI,CAAC,EAAG;QAChC,MAAM;UAAEqB;QAAQ,CAAC,GAAG,MAAAa,OAAA,CAAAC,OAAA,GAAAC,IAAA,OAAAvD,uBAAA,CAAAN,OAAA,CACnB,iCAAiC,GACjC;QACD,MAAM8C,OAAO,CAACsB,QAAQ,CAAE3C,GAAG,CAACG,IAAK,CAAC;MACnC;IACD,CAAC;IACD0C,WAAWA,CAAA,EAAG;MACb,MAAMtB,GAAG,GAAG,IAAAL,yBAAU,EAAC,CAAC;MACxB,MAAM;QAAElB;MAAI,CAAC,GAAG,IAAAwB,yBAAU,EAAC,CAAC;MAC5BD,GAAG,CAACE,QAAQ,GAAGzB,GAAG;IACnB;EACD;AACD,CAAE,CAAC"}
|
package/build/search/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_edit","_variations","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","label","type","__experimentalRole","showLabel","placeholder","width","widthUnit","buttonText","buttonPosition","buttonUseIcon","query","isSearchFieldHidden","supports","align","color","gradients","__experimentalSkipSerialization","__experimentalDefaultControls","background","text","interactivity","typography","__experimentalSelector","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalBorder","radius","html","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_edit","_variations","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","label","type","__experimentalRole","showLabel","placeholder","width","widthUnit","buttonText","buttonPosition","buttonUseIcon","query","isSearchFieldHidden","supports","align","color","gradients","__experimentalSkipSerialization","__experimentalDefaultControls","background","text","interactivity","typography","__experimentalSelector","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalBorder","radius","html","editorStyle","style","exports","settings","icon","example","__","viewportWidth","variations","edit","init","initBlock"],"sources":["@wordpress/block-library/src/search/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search 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 variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAF,sBAAA,CAAAH,OAAA;AAZA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAM,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA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KAAK,EAAE,IAAAwC,QAAE,EAAE,QAAS;IAAE,CAAC;IACjEC,aAAa,EAAE;EAChB,CAAC;EACDC,UAAU,EAAVA,mBAAU;EACVC,IAAI,EAAJA;AACD,CAAC;AAACP,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMO,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAEpD,IAAI;EAAEH,QAAQ;EAAE+C;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAQ,IAAA,GAAAA,IAAA"}
|
|
@@ -25,7 +25,7 @@ function getLatestHeadings(select, clientId) {
|
|
|
25
25
|
getBlockAttributes,
|
|
26
26
|
getBlockName,
|
|
27
27
|
getClientIdsWithDescendants,
|
|
28
|
-
|
|
28
|
+
getBlocksByName
|
|
29
29
|
} = select(_blockEditor.store);
|
|
30
30
|
|
|
31
31
|
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
@@ -35,7 +35,7 @@ function getLatestHeadings(select, clientId) {
|
|
|
35
35
|
// will be null, and the block's saved markup will lack permalinks.
|
|
36
36
|
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
37
37
|
const permalink = (_select$getPermalink = select('core/editor').getPermalink()) !== null && _select$getPermalink !== void 0 ? _select$getPermalink : null;
|
|
38
|
-
const isPaginated =
|
|
38
|
+
const isPaginated = getBlocksByName('core/nextpage').length !== 0;
|
|
39
39
|
const {
|
|
40
40
|
onlyIncludeCurrentPage
|
|
41
41
|
} = (_getBlockAttributes = getBlockAttributes(clientId)) !== null && _getBlockAttributes !== void 0 ? _getBlockAttributes : {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_es","_interopRequireDefault","require","_data","_dom","_element","_url","_blockEditor","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getClientIdsWithDescendants","
|
|
1
|
+
{"version":3,"names":["_es","_interopRequireDefault","require","_data","_dom","_element","_url","_blockEditor","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getClientIdsWithDescendants","getBlocksByName","blockEditorStore","permalink","getPermalink","isPaginated","length","onlyIncludeCurrentPage","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","latestHeadings","headingPage","headingPageLink","addQueryArgs","page","blockName","removeQueryArgs","headingAttributes","canBeLinked","anchor","push","content","stripHTML","replace","level","link","observeCallback","dispatch","updateBlockAttributes","__unstableMarkNextChangeAsNotPersistent","attributes","headings","fastDeepEqual","useObserveHeadings","registry","useRegistry","useEffect","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(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
@@ -8,7 +8,6 @@ var _react = require("react");
|
|
|
8
8
|
var _coreData = require("@wordpress/core-data");
|
|
9
9
|
var _components = require("@wordpress/components");
|
|
10
10
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
12
11
|
var _data = require("@wordpress/data");
|
|
13
12
|
var _importControls = require("./import-controls");
|
|
14
13
|
/**
|
|
@@ -50,9 +49,7 @@ function TemplatePartAdvancedControls({
|
|
|
50
49
|
label,
|
|
51
50
|
value: _area
|
|
52
51
|
}));
|
|
53
|
-
return (0, _react.createElement)(
|
|
54
|
-
group: "advanced"
|
|
55
|
-
}, isEntityAvailable && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.TextControl, {
|
|
52
|
+
return (0, _react.createElement)(_react.Fragment, null, isEntityAvailable && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.TextControl, {
|
|
56
53
|
__nextHasNoMarginBottom: true,
|
|
57
54
|
label: (0, _i18n.__)('Title'),
|
|
58
55
|
value: title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_components","_i18n","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_components","_i18n","_data","_importControls","htmlElementMessages","header","__","main","section","article","aside","footer","TemplatePartAdvancedControls","tagName","setAttributes","isEntityAvailable","templatePartId","defaultWrapper","hasInnerBlocks","area","setArea","useEntityProp","title","setTitle","definedAreas","useSelect","select","__experimentalGetDefaultTemplatePartAreas","areaOptions","map","label","_area","value","_react","createElement","Fragment","TextControl","__nextHasNoMarginBottom","onChange","onFocus","event","target","SelectControl","labelPosition","options","__next40pxDefaultSize","sprintf","help","TemplatePartImportControls"],"sources":["@wordpress/block-library/src/template-part/edit/advanced-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { SelectControl, TextControl } from '@wordpress/components';\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { TemplatePartImportControls } from './import-controls';\n\nconst htmlElementMessages = {\n\theader: __(\n\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t),\n\tmain: __(\n\t\t'The <main> element should be used for the primary content of your document only.'\n\t),\n\tsection: __(\n\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t),\n\tarticle: __(\n\t\t'The <article> element should represent a self-contained, syndicatable portion of the document.'\n\t),\n\taside: __(\n\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t),\n\tfooter: __(\n\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t),\n};\n\nexport function TemplatePartAdvancedControls( {\n\ttagName,\n\tsetAttributes,\n\tisEntityAvailable,\n\ttemplatePartId,\n\tdefaultWrapper,\n\thasInnerBlocks,\n} ) {\n\tconst [ area, setArea ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_template_part',\n\t\t'area',\n\t\ttemplatePartId\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_template_part',\n\t\t'title',\n\t\ttemplatePartId\n\t);\n\n\tconst definedAreas = useSelect( ( select ) => {\n\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t/* eslint-disable-next-line @wordpress/data-no-store-string-literals */\n\t\treturn select(\n\t\t\t'core/editor'\n\t\t).__experimentalGetDefaultTemplatePartAreas();\n\t}, [] );\n\n\tconst areaOptions = definedAreas.map( ( { label, area: _area } ) => ( {\n\t\tlabel,\n\t\tvalue: _area,\n\t} ) );\n\n\treturn (\n\t\t<>\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetTitle( value );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonFocus={ ( event ) => event.target.select() }\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\toptions={ areaOptions }\n\t\t\t\t\t\tvalue={ area }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<SelectControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\toptions={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: HTML tag based on area. */\n\t\t\t\t\t\t\t__( 'Default based on area (%s)' ),\n\t\t\t\t\t\t\t`<${ defaultWrapper }>`\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue: '',\n\t\t\t\t\t},\n\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t\t{ label: '<div>', value: 'div' },\n\t\t\t\t] }\n\t\t\t\tvalue={ tagName || '' }\n\t\t\t\tonChange={ ( value ) => setAttributes( { tagName: value } ) }\n\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t/>\n\t\t\t{ ! hasInnerBlocks && (\n\t\t\t\t<TemplatePartImportControls\n\t\t\t\t\tarea={ area }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\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AAE,WAAW;MAAEE,KAAK,EAAE;IAAU,CAAC,EACxC;MAAEF,KAAK,EAAE,SAAS;MAAEE,KAAK,EAAE;IAAQ,CAAC,EACpC;MAAEF,KAAK,EAAE,UAAU;MAAEE,KAAK,EAAE;IAAS,CAAC,EACtC;MAAEF,KAAK,EAAE,OAAO;MAAEE,KAAK,EAAE;IAAM,CAAC,CAC9B;IACHA,KAAK,EAAGnB,OAAO,IAAI,EAAI;IACvByB,QAAQ,EAAKN,KAAK,IAAMlB,aAAa,CAAE;MAAED,OAAO,EAAEmB;IAAM,CAAE,CAAG;IAC7De,IAAI,EAAG3C,mBAAmB,CAAES,OAAO;EAAI,CACvC,CAAC,EACA,CAAEK,cAAc,IACjB,IAAAe,MAAA,CAAAC,aAAA,EAAC/B,eAAA,CAAA6C,0BAA0B;IAC1B7B,IAAI,EAAGA,IAAM;IACbL,aAAa,EAAGA;EAAe,CAC/B,CAED,CAAC;AAEL"}
|
|
@@ -26,6 +26,31 @@ var _hooks = require("./utils/hooks");
|
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
+
function ReplaceButton({
|
|
30
|
+
isEntityAvailable,
|
|
31
|
+
area,
|
|
32
|
+
clientId,
|
|
33
|
+
templatePartId,
|
|
34
|
+
isTemplatePartSelectionOpen,
|
|
35
|
+
setIsTemplatePartSelectionOpen
|
|
36
|
+
}) {
|
|
37
|
+
const {
|
|
38
|
+
templateParts
|
|
39
|
+
} = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId);
|
|
40
|
+
const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
|
|
41
|
+
const hasReplacements = !!templateParts.length || !!blockPatterns.length;
|
|
42
|
+
const canReplace = isEntityAvailable && hasReplacements && (area === 'header' || area === 'footer');
|
|
43
|
+
if (!canReplace) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return (0, _react.createElement)(_components.MenuItem, {
|
|
47
|
+
onClick: () => {
|
|
48
|
+
setIsTemplatePartSelectionOpen(true);
|
|
49
|
+
},
|
|
50
|
+
"aria-expanded": isTemplatePartSelectionOpen,
|
|
51
|
+
"aria-haspopup": "dialog"
|
|
52
|
+
}, (0, _i18n.__)('Replace'));
|
|
53
|
+
}
|
|
29
54
|
function TemplatePartEdit({
|
|
30
55
|
attributes,
|
|
31
56
|
setAttributes,
|
|
@@ -39,7 +64,7 @@ function TemplatePartEdit({
|
|
|
39
64
|
layout = {}
|
|
40
65
|
} = attributes;
|
|
41
66
|
const templatePartId = (0, _createTemplatePartId.createTemplatePartId)(theme, slug);
|
|
42
|
-
const hasAlreadyRendered = (0, _blockEditor.
|
|
67
|
+
const hasAlreadyRendered = (0, _blockEditor.useHasRecursion)(templatePartId);
|
|
43
68
|
const [isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen] = (0, _element.useState)(false);
|
|
44
69
|
|
|
45
70
|
// Set the postId block attribute if it did not exist,
|
|
@@ -69,17 +94,11 @@ function TemplatePartEdit({
|
|
|
69
94
|
area: _area
|
|
70
95
|
};
|
|
71
96
|
}, [templatePartId, attributes.area, clientId]);
|
|
72
|
-
const {
|
|
73
|
-
templateParts
|
|
74
|
-
} = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId);
|
|
75
|
-
const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
|
|
76
|
-
const hasReplacements = !!templateParts.length || !!blockPatterns.length;
|
|
77
97
|
const areaObject = (0, _hooks.useTemplatePartArea)(area);
|
|
78
98
|
const blockProps = (0, _blockEditor.useBlockProps)();
|
|
79
99
|
const isPlaceholder = !slug;
|
|
80
100
|
const isEntityAvailable = !isPlaceholder && !isMissing && isResolved;
|
|
81
101
|
const TagName = tagName || areaObject.tagName;
|
|
82
|
-
const canReplace = isEntityAvailable && hasReplacements && (area === 'header' || area === 'footer');
|
|
83
102
|
|
|
84
103
|
// We don't want to render a missing state if we have any inner blocks.
|
|
85
104
|
// A new template part is automatically created if we have any inner blocks but no entity.
|
|
@@ -94,8 +113,10 @@ function TemplatePartEdit({
|
|
|
94
113
|
...blockProps
|
|
95
114
|
}, (0, _react.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Block cannot be rendered inside itself.')));
|
|
96
115
|
}
|
|
97
|
-
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_blockEditor.
|
|
116
|
+
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_blockEditor.RecursionProvider, {
|
|
98
117
|
uniqueId: templatePartId
|
|
118
|
+
}, (0, _react.createElement)(_blockEditor.InspectorControls, {
|
|
119
|
+
group: "advanced"
|
|
99
120
|
}, (0, _react.createElement)(_advancedControls.TemplatePartAdvancedControls, {
|
|
100
121
|
tagName: tagName,
|
|
101
122
|
setAttributes: setAttributes,
|
|
@@ -103,7 +124,7 @@ function TemplatePartEdit({
|
|
|
103
124
|
templatePartId: templatePartId,
|
|
104
125
|
defaultWrapper: areaObject.tagName,
|
|
105
126
|
hasInnerBlocks: innerBlocks.length > 0
|
|
106
|
-
}), isPlaceholder && (0, _react.createElement)(TagName, {
|
|
127
|
+
})), isPlaceholder && (0, _react.createElement)(TagName, {
|
|
107
128
|
...blockProps
|
|
108
129
|
}, (0, _react.createElement)(_placeholder.default, {
|
|
109
130
|
area: attributes.area,
|
|
@@ -111,7 +132,7 @@ function TemplatePartEdit({
|
|
|
111
132
|
clientId: clientId,
|
|
112
133
|
setAttributes: setAttributes,
|
|
113
134
|
onOpenSelectionModal: () => setIsTemplatePartSelectionOpen(true)
|
|
114
|
-
})),
|
|
135
|
+
})), (0, _react.createElement)(_blockEditor.BlockSettingsMenuControls, null, ({
|
|
115
136
|
selectedClientIds
|
|
116
137
|
}) => {
|
|
117
138
|
// Only enable for single selection that matches the current block.
|
|
@@ -119,13 +140,14 @@ function TemplatePartEdit({
|
|
|
119
140
|
if (!(selectedClientIds.length === 1 && clientId === selectedClientIds[0])) {
|
|
120
141
|
return null;
|
|
121
142
|
}
|
|
122
|
-
return (0, _react.createElement)(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
return (0, _react.createElement)(ReplaceButton, {
|
|
144
|
+
isEntityAvailable,
|
|
145
|
+
area,
|
|
146
|
+
clientId,
|
|
147
|
+
templatePartId,
|
|
148
|
+
isTemplatePartSelectionOpen,
|
|
149
|
+
setIsTemplatePartSelectionOpen
|
|
150
|
+
});
|
|
129
151
|
}), isEntityAvailable && (0, _react.createElement)(_innerBlocks.default, {
|
|
130
152
|
tagName: TagName,
|
|
131
153
|
blockProps: blockProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blockEditor","_components","_i18n","_coreData","_element","_placeholder","_interopRequireDefault","_selectionModal","_advancedControls","_innerBlocks","_createTemplatePartId","_hooks","TemplatePartEdit","attributes","setAttributes","clientId","currentTheme","useSelect","select","coreStore","getCurrentTheme","stylesheet","slug","theme","tagName","layout","templatePartId","createTemplatePartId","hasAlreadyRendered","useHasRecursion","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","useState","isResolved","innerBlocks","isMissing","area","getEditedEntityRecord","hasFinishedResolution","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","Object","keys","length","templateParts","useAlternativeTemplateParts","blockPatterns","useAlternativeBlockPatterns","hasReplacements","areaObject","useTemplatePartArea","blockProps","useBlockProps","isPlaceholder","isEntityAvailable","TagName","canReplace","_react","createElement","Warning","sprintf","__","Fragment","__experimentalRecursionProvider","uniqueId","TemplatePartAdvancedControls","defaultWrapper","hasInnerBlocks","default","onOpenSelectionModal","BlockSettingsMenuControls","selectedClientIds","MenuItem","onClick","postId","Spinner","Modal","overlayClassName","title","label","toLowerCase","onRequestClose","isFullScreen","onClose"],"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockProps,\n\tWarning,\n\tstore as blockEditorStore,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n} from '@wordpress/block-editor';\nimport { Spinner, Modal, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\tconst { slug, theme = currentTheme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst hasAlreadyRendered = useHasRecursion( templatePartId );\n\tconst [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =\n\t\tuseState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing:\n\t\t\t\t\thasResolvedEntity &&\n\t\t\t\t\t( ! entityRecord ||\n\t\t\t\t\t\tObject.keys( entityRecord ).length === 0 ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, attributes.area, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\tconst canReplace =\n\t\tisEntityAvailable &&\n\t\thasReplacements &&\n\t\t( area === 'header' || area === 'footer' );\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RecursionProvider uniqueId={ templatePartId }>\n\t\t\t\t<TemplatePartAdvancedControls\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t/>\n\t\t\t\t{ isPlaceholder && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t\t{ canReplace && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t\t\t// Only enable for single selection that matches the current block.\n\t\t\t\t\t\t\t// Ensures menu item doesn't render multiple times.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t! (\n\t\t\t\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\t\t\t\tclientId === selectedClientIds[ 0 ]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-expanded={\n\t\t\t\t\t\t\t\t\t\tisTemplatePartSelectionOpen\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t{ isEntityAvailable && (\n\t\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t</RecursionProvider>\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\toverlayClassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t\tisFullScreen={ true }\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,YAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,qBAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AAzBA;AACA;AACA;;AAeA;AACA;AACA;;AAYe,SAASa,gBAAgBA,CAAE;EACzCC,UAAU;EACVC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,YAAY,GAAG,IAAAC,eAAS,EAC3BC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACC,eAAe,CAAC,CAAC,EAAEC,UAAU,EAC/D,EACD,CAAC;EACD,MAAM;IAAEC,IAAI;IAAEC,KAAK,GAAGP,YAAY;IAAEQ,OAAO;IAAEC,MAAM,GAAG,CAAC;EAAE,CAAC,GAAGZ,UAAU;EACvE,MAAMa,cAAc,GAAG,IAAAC,0CAAoB,EAAEJ,KAAK,EAAED,IAAK,CAAC;EAC1D,MA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OAAO,EAAGmC,OAAS;IACnBJ,UAAU,EAAGA,UAAY;IACzBuB,MAAM,EAAGpD,cAAgB;IACzB6C,cAAc,EAAGrC,WAAW,CAACa,MAAM,GAAG,CAAG;IACzCtB,MAAM,EAAGA;EAAQ,CACjB,CACD,EACC,CAAEgC,aAAa,IAAI,CAAExB,UAAU,IAChC,IAAA4B,MAAA,CAAAC,aAAA,EAACH,OAAO;IAAA,GAAMJ;EAAU,GACvB,IAAAM,MAAA,CAAAC,aAAA,EAAC7D,WAAA,CAAA8E,OAAO,MAAE,CACF,CAEQ,CAAC,EAClBjD,2BAA2B,IAC5B,IAAA+B,MAAA,CAAAC,aAAA,EAAC7D,WAAA,CAAA+E,KAAK;IACLC,gBAAgB,EAAC,6CAA6C;IAC9DC,KAAK,EAAG,IAAAlB,aAAO;IACd;IACA,IAAAC,QAAE,EAAE,aAAc,CAAC,EACnBZ,UAAU,CAAC8B,KAAK,CAACC,WAAW,CAAC,CAC9B,CAAG;IACHC,cAAc,EAAGA,CAAA,KAChBtD,8BAA8B,CAAE,KAAM,CACtC;IACDuD,YAAY,EAAG;EAAM,GAErB,IAAAzB,MAAA,CAAAC,aAAA,EAACvD,eAAA,CAAAiE,OAA0B;IAC1B9C,cAAc,EAAGA,cAAgB;IACjCX,QAAQ,EAAGA,QAAU;IACrBqB,IAAI,EAAGA,IAAM;IACbtB,aAAa,EAAGA,aAAe;IAC/ByE,OAAO,EAAGA,CAAA,KACTxD,8BAA8B,CAAE,KAAM;EACtC,CACD,CACK,CAEP,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["_data","require","_blockEditor","_components","_i18n","_coreData","_element","_placeholder","_interopRequireDefault","_selectionModal","_advancedControls","_innerBlocks","_createTemplatePartId","_hooks","ReplaceButton","isEntityAvailable","area","clientId","templatePartId","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","templateParts","useAlternativeTemplateParts","blockPatterns","useAlternativeBlockPatterns","hasReplacements","length","canReplace","_react","createElement","MenuItem","onClick","__","TemplatePartEdit","attributes","setAttributes","currentTheme","useSelect","select","coreStore","getCurrentTheme","stylesheet","slug","theme","tagName","layout","createTemplatePartId","hasAlreadyRendered","useHasRecursion","useState","isResolved","innerBlocks","isMissing","getEditedEntityRecord","hasFinishedResolution","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","Object","keys","areaObject","useTemplatePartArea","blockProps","useBlockProps","isPlaceholder","TagName","Warning","sprintf","Fragment","RecursionProvider","uniqueId","InspectorControls","group","TemplatePartAdvancedControls","defaultWrapper","hasInnerBlocks","default","onOpenSelectionModal","BlockSettingsMenuControls","selectedClientIds","postId","Spinner","Modal","overlayClassName","title","label","toLowerCase","onRequestClose","isFullScreen","onClose"],"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tuseBlockProps,\n\tWarning,\n\tstore as blockEditorStore,\n\tRecursionProvider,\n\tuseHasRecursion,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { Spinner, Modal, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nfunction ReplaceButton( {\n\tisEntityAvailable,\n\tarea,\n\tclientId,\n\ttemplatePartId,\n\tisTemplatePartSelectionOpen,\n\tsetIsTemplatePartSelectionOpen,\n} ) {\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst canReplace =\n\t\tisEntityAvailable &&\n\t\thasReplacements &&\n\t\t( area === 'header' || area === 'footer' );\n\n\tif ( ! canReplace ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tsetIsTemplatePartSelectionOpen( true );\n\t\t\t} }\n\t\t\taria-expanded={ isTemplatePartSelectionOpen }\n\t\t\taria-haspopup=\"dialog\"\n\t\t>\n\t\t\t{ __( 'Replace' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\tconst { slug, theme = currentTheme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst hasAlreadyRendered = useHasRecursion( templatePartId );\n\tconst [ isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen ] =\n\t\tuseState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing:\n\t\t\t\t\thasResolvedEntity &&\n\t\t\t\t\t( ! entityRecord ||\n\t\t\t\t\t\tObject.keys( entityRecord ).length === 0 ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, attributes.area, clientId ]\n\t);\n\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RecursionProvider uniqueId={ templatePartId }>\n\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t<TemplatePartAdvancedControls\n\t\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t\t{ isPlaceholder && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t{ ( { selectedClientIds } ) => {\n\t\t\t\t\t\t// Only enable for single selection that matches the current block.\n\t\t\t\t\t\t// Ensures menu item doesn't render multiple times.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! (\n\t\t\t\t\t\t\t\tselectedClientIds.length === 1 &&\n\t\t\t\t\t\t\t\tclientId === selectedClientIds[ 0 ]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ReplaceButton\n\t\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t\tisEntityAvailable,\n\t\t\t\t\t\t\t\t\tarea,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\ttemplatePartId,\n\t\t\t\t\t\t\t\t\tisTemplatePartSelectionOpen,\n\t\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen,\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</BlockSettingsMenuControls>\n\t\t\t\t{ isEntityAvailable && (\n\t\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</TagName>\n\t\t\t\t) }\n\t\t\t</RecursionProvider>\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\toverlayClassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t\tisFullScreen={ true }\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,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B,IAClB,IAAAa,MAAA,CAAAC,aAAA,EAAClB,YAAA,CAAAoE,OAAuB;IACvBnC,OAAO,EAAGwB,OAAS;IACnBH,UAAU,EAAGA,UAAY;IACzBkB,MAAM,EAAGjE,cAAgB;IACzB4D,cAAc,EAAG3B,WAAW,CAACzB,MAAM,GAAG,CAAG;IACzCmB,MAAM,EAAGA;EAAQ,CACjB,CACD,EACC,CAAEsB,aAAa,IAAI,CAAEjB,UAAU,IAChC,IAAAtB,MAAA,CAAAC,aAAA,EAACuC,OAAO;IAAA,GAAMH;EAAU,GACvB,IAAArC,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAAiF,OAAO,MAAE,CACF,CAEQ,CAAC,EAClBjE,2BAA2B,IAC5B,IAAAS,MAAA,CAAAC,aAAA,EAAC1B,WAAA,CAAAkF,KAAK;IACLC,gBAAgB,EAAC,6CAA6C;IAC9DC,KAAK,EAAG,IAAAjB,aAAO;IACd;IACA,IAAAtC,QAAE,EAAE,aAAc,CAAC,EACnB+B,UAAU,CAACyB,KAAK,CAACC,WAAW,CAAC,CAC9B,CAAG;IACHC,cAAc,EAAGA,CAAA,KAChBtE,8BAA8B,CAAE,KAAM,CACtC;IACDuE,YAAY,EAAG;EAAM,GAErB,IAAA/D,MAAA,CAAAC,aAAA,EAACpB,eAAA,CAAAsE,OAA0B;IAC1B7D,cAAc,EAAGA,cAAgB;IACjCD,QAAQ,EAAGA,QAAU;IACrBD,IAAI,EAAGA,IAAM;IACbmB,aAAa,EAAGA,aAAe;IAC/ByD,OAAO,EAAGA,CAAA,KACTxE,8BAA8B,CAAE,KAAM;EACtC,CACD,CACK,CAEP,CAAC;AAEL"}
|
|
@@ -225,7 +225,8 @@ class VideoEdit extends _element.Component {
|
|
|
225
225
|
} = this.props;
|
|
226
226
|
const {
|
|
227
227
|
id,
|
|
228
|
-
src
|
|
228
|
+
src,
|
|
229
|
+
guid
|
|
229
230
|
} = attributes;
|
|
230
231
|
const {
|
|
231
232
|
videoContainerHeight
|
|
@@ -246,7 +247,11 @@ class VideoEdit extends _element.Component {
|
|
|
246
247
|
}));
|
|
247
248
|
}
|
|
248
249
|
});
|
|
249
|
-
|
|
250
|
+
|
|
251
|
+
// NOTE: `guid` is not part of the block's attribute definition. This case
|
|
252
|
+
// handled here is a temporary fix until a we find a better approach.
|
|
253
|
+
const isSourcePresent = src || guid && id;
|
|
254
|
+
if (!isSourcePresent) {
|
|
250
255
|
return (0, _react.createElement)(_reactNative.View, {
|
|
251
256
|
style: {
|
|
252
257
|
flex: 1
|