@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":["__","postList","titleDate","titleExcerpt","titleDateExcerpt","imageDateTitle","QUERY_DEFAULT_ATTRIBUTES","query","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","variations","name","title","description","icon","attributes","scope","innerBlocks"],"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":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,kBAAkB;;AAE3C;AACA;AACA;AACA,SACCC,SAAS,EACTC,YAAY,EACZC,gBAAgB,EAChBC,cAAc,QACR,SAAS;AAEhB,MAAMC,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,EAAErB,EAAE,CAAE,YAAa,CAAC;EACzBsB,WAAW,EAAEtB,EAAE,CACd,mEACD,CAAC;EACDuB,IAAI,EAAEtB,QAAQ;EACduB,UAAU,EAAE;
|
|
1
|
+
{"version":3,"names":["__","postList","titleDate","titleExcerpt","titleDateExcerpt","imageDateTitle","QUERY_DEFAULT_ATTRIBUTES","query","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","variations","name","title","description","icon","attributes","namespace","scope","isActive","innerBlocks"],"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":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,kBAAkB;;AAE3C;AACA;AACA;AACA,SACCC,SAAS,EACTC,YAAY,EACZC,gBAAgB,EAChBC,cAAc,QACR,SAAS;AAEhB,MAAMC,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,EAAErB,EAAE,CAAE,YAAa,CAAC;EACzBsB,WAAW,EAAEtB,EAAE,CACd,mEACD,CAAC;EACDuB,IAAI,EAAEtB,QAAQ;EACduB,UAAU,EAAE;IACXC,SAAS,EAAE,iBAAiB;IAC5BlB,KAAK,EAAE;MACNC,OAAO,EAAE,CAAC;MACVC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;MACTC,QAAQ,EAAE,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B;EACtBoB,UAAU,EAAE;IAAE,GAAGlB;EAAyB,CAAC;EAC3CsB,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;EACDF,KAAK,EAAE,CAAE,OAAO;AACjB,CAAC,EACD;EACCN,IAAI,EAAE,kBAAkB;EACxBC,KAAK,EAAErB,EAAE,CAAE,sBAAuB,CAAC;EACnCuB,IAAI,EAAElB,cAAc;EACpBmB,UAAU,EAAE;IAAE,GAAGlB;EAAyB,CAAC;EAC3CsB,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;EACDF,KAAK,EAAE,CAAE,OAAO;AACjB,CAAC,CACD;AAED,eAAeP,UAAU"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { store, getContext, getElement
|
|
4
|
+
import { store, getContext, getElement } from '@wordpress/interactivity';
|
|
5
5
|
const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin;
|
|
6
6
|
const isValidEvent = event => event.button === 0 &&
|
|
7
7
|
// Left clicks only.
|
|
@@ -27,17 +27,22 @@ store('core/query', {
|
|
|
27
27
|
const {
|
|
28
28
|
ref
|
|
29
29
|
} = getElement();
|
|
30
|
-
const
|
|
30
|
+
const {
|
|
31
|
+
queryRef
|
|
32
|
+
} = ctx;
|
|
33
|
+
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
|
|
31
34
|
if (isValidLink(ref) && isValidEvent(event) && !isDisabled) {
|
|
32
35
|
event.preventDefault();
|
|
33
|
-
const id = ref.closest('[data-wp-navigation-id]').dataset.wpNavigationId;
|
|
34
36
|
|
|
35
37
|
// Don't announce the navigation immediately, wait 400 ms.
|
|
36
38
|
const timeout = setTimeout(() => {
|
|
37
39
|
ctx.message = ctx.loadingText;
|
|
38
40
|
ctx.animation = 'start';
|
|
39
41
|
}, 400);
|
|
40
|
-
|
|
42
|
+
const {
|
|
43
|
+
actions
|
|
44
|
+
} = yield import('@wordpress/interactivity-router');
|
|
45
|
+
yield actions.navigate(ref.href);
|
|
41
46
|
|
|
42
47
|
// Dismiss loading message if it hasn't been added yet.
|
|
43
48
|
clearTimeout(timeout);
|
|
@@ -50,17 +55,23 @@ store('core/query', {
|
|
|
50
55
|
ctx.url = ref.href;
|
|
51
56
|
|
|
52
57
|
// Focus the first anchor of the Query block.
|
|
53
|
-
const firstAnchor =
|
|
54
|
-
|
|
58
|
+
const firstAnchor = `.wp-block-post-template a[href]`;
|
|
59
|
+
queryRef.querySelector(firstAnchor)?.focus();
|
|
55
60
|
}
|
|
56
61
|
},
|
|
57
62
|
*prefetch() {
|
|
63
|
+
const {
|
|
64
|
+
queryRef
|
|
65
|
+
} = getContext();
|
|
58
66
|
const {
|
|
59
67
|
ref
|
|
60
68
|
} = getElement();
|
|
61
|
-
const isDisabled =
|
|
69
|
+
const isDisabled = queryRef?.dataset.wpNavigationDisabled;
|
|
62
70
|
if (isValidLink(ref) && !isDisabled) {
|
|
63
|
-
|
|
71
|
+
const {
|
|
72
|
+
actions
|
|
73
|
+
} = yield import('@wordpress/interactivity-router');
|
|
74
|
+
yield actions.prefetch(ref.href);
|
|
64
75
|
}
|
|
65
76
|
}
|
|
66
77
|
},
|
|
@@ -73,8 +84,18 @@ store('core/query', {
|
|
|
73
84
|
ref
|
|
74
85
|
} = getElement();
|
|
75
86
|
if (url && isValidLink(ref)) {
|
|
76
|
-
|
|
87
|
+
const {
|
|
88
|
+
actions
|
|
89
|
+
} = yield import('@wordpress/interactivity-router');
|
|
90
|
+
yield actions.prefetch(ref.href);
|
|
77
91
|
}
|
|
92
|
+
},
|
|
93
|
+
setQueryRef() {
|
|
94
|
+
const ctx = getContext();
|
|
95
|
+
const {
|
|
96
|
+
ref
|
|
97
|
+
} = getElement();
|
|
98
|
+
ctx.queryRef = ref;
|
|
78
99
|
}
|
|
79
100
|
}
|
|
80
101
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","getContext","getElement","
|
|
1
|
+
{"version":3,"names":["store","getContext","getElement","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","state","startAnimation","animation","finishAnimation","actions","navigate","ctx","queryRef","isDisabled","dataset","wpNavigationDisabled","preventDefault","timeout","setTimeout","message","loadingText","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":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,UAAU,EAAEC,UAAU,QAAQ,0BAA0B;AAExE,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAAG,CAACK,MAAM,KAAKJ,MAAM,CAACK,QAAQ,CAACD,MAAM;AAEtC,MAAME,YAAY,GAAKC,KAAK,IAC3BA,KAAK,CAACC,MAAM,KAAK,CAAC;AAAI;AACtB,CAAED,KAAK,CAACE,OAAO;AAAI;AACnB,CAAEF,KAAK,CAACG,OAAO;AAAI;AACnB,CAAEH,KAAK,CAACI,MAAM;AAAI;AAClB,CAAEJ,KAAK,CAACK,QAAQ,IAChB,CAAEL,KAAK,CAACM,gBAAgB;AAEzBlB,KAAK,CAAE,YAAY,EAAE;EACpBmB,KAAK,EAAE;IACN,IAAIC,cAAcA,CAAA,EAAG;MACpB,OAAOnB,UAAU,CAAC,CAAC,CAACoB,SAAS,KAAK,OAAO;IAC1C,CAAC;IACD,IAAIC,eAAeA,CAAA,EAAG;MACrB,OAAOrB,UAAU,CAAC,CAAC,CAACoB,SAAS,KAAK,QAAQ;IAC3C;EACD,CAAC;EACDE,OAAO,EAAE;IACR,CAACC,QAAQA,CAAEZ,KAAK,EAAG;MAClB,MAAMa,GAAG,GAAGxB,UAAU,CAAC,CAAC;M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IAAK1B,WAAW,CAAEC,GAAI,CAAC,IAAI,CAAEuB,UAAU,EAAG;QACzC,MAAM;UAAEJ;QAAQ,CAAC,GAAG,MAAM,MAAM,CAC/B,iCACD,CAAC;QACD,MAAMA,OAAO,CAACkB,QAAQ,CAAErC,GAAG,CAACG,IAAK,CAAC;MACnC;IACD;EACD,CAAC;EACDmC,SAAS,EAAE;IACV,CAACD,QAAQA,CAAA,EAAG;MACX,MAAM;QAAEJ;MAAI,CAAC,GAAGpC,UAAU,CAAC,CAAC;MAC5B,MAAM;QAAEG;MAAI,CAAC,GAAGF,UAAU,CAAC,CAAC;MAC5B,IAAKmC,GAAG,IAAIlC,WAAW,CAAEC,GAAI,CAAC,EAAG;QAChC,MAAM;UAAEmB;QAAQ,CAAC,GAAG,MAAM,MAAM,CAC/B,iCACD,CAAC;QACD,MAAMA,OAAO,CAACkB,QAAQ,CAAErC,GAAG,CAACG,IAAK,CAAC;MACnC;IACD,CAAC;IACDoC,WAAWA,CAAA,EAAG;MACb,MAAMlB,GAAG,GAAGxB,UAAU,CAAC,CAAC;MACxB,MAAM;QAAEG;MAAI,CAAC,GAAGF,UAAU,CAAC,CAAC;MAC5BuB,GAAG,CAACC,QAAQ,GAAGtB,GAAG;IACnB;EACD;AACD,CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","search","icon","initBlock","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":["__","search","icon","initBlock","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","edit","variations","settings","example","viewportWidth","init"],"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":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,IAAIC,IAAI,QAAQ,kBAAkB;;AAEjD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAF,IAAA;MAAA;IAAA;IAAAG,WAAA;MAAAH,IAAA;MAAA;MAAAC,kBAAA;IAAA;IAAAG,KAAA;MAAAJ,IAAA;IAAA;IAAAK,SAAA;MAAAL,IAAA;IAAA;IAAAM,UAAA;MAAAN,IAAA;MAAAC,kBAAA;IAAA;IA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{
|
|
|
17
17
|
getBlockAttributes,
|
|
18
18
|
getBlockName,
|
|
19
19
|
getClientIdsWithDescendants,
|
|
20
|
-
|
|
20
|
+
getBlocksByName
|
|
21
21
|
} = select(blockEditorStore);
|
|
22
22
|
|
|
23
23
|
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
@@ -27,7 +27,7 @@ function getLatestHeadings(select, clientId) {
|
|
|
27
27
|
// will be null, and the block's saved markup will lack permalinks.
|
|
28
28
|
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
29
29
|
const permalink = (_select$getPermalink = select('core/editor').getPermalink()) !== null && _select$getPermalink !== void 0 ? _select$getPermalink : null;
|
|
30
|
-
const isPaginated =
|
|
30
|
+
const isPaginated = getBlocksByName('core/nextpage').length !== 0;
|
|
31
31
|
const {
|
|
32
32
|
onlyIncludeCurrentPage
|
|
33
33
|
} = (_getBlockAttributes = getBlockAttributes(clientId)) !== null && _getBlockAttributes !== void 0 ? _getBlockAttributes : {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fastDeepEqual","useRegistry","__unstableStripHTML","stripHTML","useEffect","addQueryArgs","removeQueryArgs","store","blockEditorStore","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getClientIdsWithDescendants","
|
|
1
|
+
{"version":3,"names":["fastDeepEqual","useRegistry","__unstableStripHTML","stripHTML","useEffect","addQueryArgs","removeQueryArgs","store","blockEditorStore","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getClientIdsWithDescendants","getBlocksByName","permalink","getPermalink","isPaginated","length","onlyIncludeCurrentPage","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","latestHeadings","headingPage","headingPageLink","page","blockName","headingAttributes","canBeLinked","anchor","push","content","replace","level","link","observeCallback","dispatch","updateBlockAttributes","__unstableMarkNextChangeAsNotPersistent","attributes","headings","useObserveHeadings","registry","subscribe"],"sources":["@wordpress/block-library/src/table-of-contents/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useEffect } from '@wordpress/element';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction getLatestHeadings( select, clientId ) {\n\tconst {\n\t\tgetBlockAttributes,\n\t\tgetBlockName,\n\t\tgetClientIdsWithDescendants,\n\t\tgetBlocksByName,\n\t} = select( blockEditorStore );\n\n\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t// Blocks can be loaded into a *non-post* block editor, so to avoid\n\t// declaring @wordpress/editor as a dependency, we must access its\n\t// store by string. When the store is not available, editorSelectors\n\t// will be null, and the block's saved markup will lack permalinks.\n\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\tconst permalink = select( 'core/editor' ).getPermalink() ?? null;\n\n\tconst isPaginated = getBlocksByName( 'core/nextpage' ).length !== 0;\n\tconst { onlyIncludeCurrentPage } = getBlockAttributes( clientId ) ?? {};\n\n\t// Get the client ids of all blocks in the editor.\n\tconst allBlockClientIds = getClientIdsWithDescendants();\n\n\t// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.\n\tlet tocPage = 1;\n\n\tif ( isPaginated && onlyIncludeCurrentPage ) {\n\t\t// We can't use getBlockIndex because it only returns the index\n\t\t// relative to sibling blocks.\n\t\tconst tocIndex = allBlockClientIds.indexOf( clientId );\n\n\t\tfor ( const [\n\t\t\tblockIndex,\n\t\t\tblockClientId,\n\t\t] of allBlockClientIds.entries() ) {\n\t\t\t// If we've reached blocks after the Table of Contents, we've\n\t\t\t// finished calculating which page the block is on.\n\t\t\tif ( blockIndex >= tocIndex ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( getBlockName( blockClientId ) === 'core/nextpage' ) {\n\t\t\t\ttocPage++;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst latestHeadings = [];\n\n\t/** The page (of a paginated post) a heading will be part of. */\n\tlet headingPage = 1;\n\tlet headingPageLink = null;\n\n\t// If the core/editor store is available, we can add permalinks to the\n\t// generated table of contents.\n\tif ( typeof permalink === 'string' ) {\n\t\theadingPageLink = isPaginated\n\t\t\t? addQueryArgs( permalink, { page: headingPage } )\n\t\t\t: permalink;\n\t}\n\n\tfor ( const blockClientId of allBlockClientIds ) {\n\t\tconst blockName = getBlockName( blockClientId );\n\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\theadingPage++;\n\n\t\t\t// If we're only including headings from the current page (of\n\t\t\t// a paginated post), then exit the loop if we've reached the\n\t\t\t// pages after the one with the Table of Contents block.\n\t\t\tif ( onlyIncludeCurrentPage && headingPage > tocPage ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\theadingPageLink = addQueryArgs(\n\t\t\t\t\tremoveQueryArgs( permalink, [ 'page' ] ),\n\t\t\t\t\t{ page: headingPage }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// If we're including all headings or we've reached headings on\n\t\t// the same page as the Table of Contents block, add them to the\n\t\t// list.\n\t\telse if ( ! onlyIncludeCurrentPage || headingPage === tocPage ) {\n\t\t\tif ( blockName === 'core/heading' ) {\n\t\t\t\tconst headingAttributes = getBlockAttributes( blockClientId );\n\n\t\t\t\tconst canBeLinked =\n\t\t\t\t\ttypeof headingPageLink === 'string' &&\n\t\t\t\t\ttypeof headingAttributes.anchor === 'string' &&\n\t\t\t\t\theadingAttributes.anchor !== '';\n\n\t\t\t\tlatestHeadings.push( {\n\t\t\t\t\t// Convert line breaks to spaces, and get rid of HTML tags in the headings.\n\t\t\t\t\tcontent: stripHTML(\n\t\t\t\t\t\theadingAttributes.content.replace(\n\t\t\t\t\t\t\t/(<br *\\/?>)+/g,\n\t\t\t\t\t\t\t' '\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tlevel: headingAttributes.level,\n\t\t\t\t\tlink: canBeLinked\n\t\t\t\t\t\t? `${ headingPageLink }#${ headingAttributes.anchor }`\n\t\t\t\t\t\t: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn latestHeadings;\n}\n\nfunction observeCallback( select, dispatch, clientId ) {\n\tconst { getBlockAttributes } = select( blockEditorStore );\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tdispatch( blockEditorStore );\n\n\t/**\n\t * If the block no longer exists in the store, skip the update.\n\t * The \"undo\" action recreates the block and provides a new `clientId`.\n\t * The hook still might be observing the changes while the old block unmounts.\n\t */\n\tconst attributes = getBlockAttributes( clientId );\n\tif ( attributes === null ) {\n\t\treturn;\n\t}\n\n\tconst headings = getLatestHeadings( select, clientId );\n\tif ( ! fastDeepEqual( headings, attributes.headings ) ) {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( clientId, { headings } );\n\t}\n}\n\nexport function useObserveHeadings( clientId ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\t// Todo: Limit subscription to block editor store when data no longer depends on `getPermalink`.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45513\n\t\treturn registry.subscribe( () =>\n\t\t\tobserveCallback( registry.select, registry.dispatch, clientId )\n\t\t);\n\t}, [ registry, clientId ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,YAAY,EAAEC,eAAe,QAAQ,gBAAgB;AAC9D,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAE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AmB,CAAC,GAAGJ,MAAM,CAAEF,gBAAiB,CAAC;EACzD,MAAM;IAAEqC,qBAAqB;IAAEC;EAAwC,CAAC,GACvEF,QAAQ,CAAEpC,gBAAiB,CAAC;;EAE7B;AACD;AACA;AACA;AACA;EACC,MAAMuC,UAAU,GAAGjC,kBAAkB,CAAEH,QAAS,CAAC;EACjD,IAAKoC,UAAU,KAAK,IAAI,EAAG;IAC1B;EACD;EAEA,MAAMC,QAAQ,GAAGvC,iBAAiB,CAAEC,MAAM,EAAEC,QAAS,CAAC;EACtD,IAAK,CAAEX,aAAa,CAAEgD,QAAQ,EAAED,UAAU,CAACC,QAAS,CAAC,EAAG;IACvDF,uCAAuC,CAAC,CAAC;IACzCD,qBAAqB,CAAElC,QAAQ,EAAE;MAAEqC;IAAS,CAAE,CAAC;EAChD;AACD;AAEA,OAAO,SAASC,kBAAkBA,CAAEtC,QAAQ,EAAG;EAC9C,MAAMuC,QAAQ,GAAGjD,WAAW,CAAC,CAAC;EAC9BG,SAAS,CAAE,MAAM;IAChB;IACA;IACA,OAAO8C,QAAQ,CAACC,SAAS,CAAE,MAC1BR,eAAe,CAAEO,QAAQ,CAACxC,MAAM,EAAEwC,QAAQ,CAACN,QAAQ,EAAEjC,QAAS,CAC/D,CAAC;EACF,CAAC,EAAE,CAAEuC,QAAQ,EAAEvC,QAAQ,CAAG,CAAC;AAC5B"}
|
|
@@ -5,7 +5,6 @@ import { createElement, Fragment } from "react";
|
|
|
5
5
|
import { useEntityProp } from '@wordpress/core-data';
|
|
6
6
|
import { SelectControl, TextControl } from '@wordpress/components';
|
|
7
7
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
8
|
-
import { InspectorControls } from '@wordpress/block-editor';
|
|
9
8
|
import { useSelect } from '@wordpress/data';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -43,9 +42,7 @@ export function TemplatePartAdvancedControls({
|
|
|
43
42
|
label,
|
|
44
43
|
value: _area
|
|
45
44
|
}));
|
|
46
|
-
return createElement(
|
|
47
|
-
group: "advanced"
|
|
48
|
-
}, isEntityAvailable && createElement(Fragment, null, createElement(TextControl, {
|
|
45
|
+
return createElement(Fragment, null, isEntityAvailable && createElement(Fragment, null, createElement(TextControl, {
|
|
49
46
|
__nextHasNoMarginBottom: true,
|
|
50
47
|
label: __('Title'),
|
|
51
48
|
value: title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEntityProp","SelectControl","TextControl","sprintf","__","
|
|
1
|
+
{"version":3,"names":["useEntityProp","SelectControl","TextControl","sprintf","__","useSelect","TemplatePartImportControls","htmlElementMessages","header","main","section","article","aside","footer","TemplatePartAdvancedControls","tagName","setAttributes","isEntityAvailable","templatePartId","defaultWrapper","hasInnerBlocks","area","setArea","title","setTitle","definedAreas","select","__experimentalGetDefaultTemplatePartAreas","areaOptions","map","label","_area","value","createElement","Fragment","__nextHasNoMarginBottom","onChange","onFocus","event","target","labelPosition","options","__next40pxDefaultSize","help"],"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\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,sBAAsB;AACpD,SAASC,aAAa,EAAEC,WAAW,QAAQ,uBAAuB;AAClE,SAASC,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,0BAA0B,QAAQ,mBAAmB;AAE9D,MAAMC,mBAAmB,GAAG;EAC3BC,MAAM,EAAEJ,EAAE,CACT,qHACD,CAAC;EACDK,IAAI,EAAEL,EAAE,CACP,kFACD,CAAC;EACDM,OAAO,EAAEN,EAAE,CACV,kIACD,CAAC;EACDO,OAAO,EAAEP,EAAE,CACV,gGACD,C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ordpress/data';
|
|
6
|
-
import { BlockSettingsMenuControls, useBlockProps, Warning, store as blockEditorStore,
|
|
6
|
+
import { BlockSettingsMenuControls, useBlockProps, Warning, store as blockEditorStore, RecursionProvider, useHasRecursion, InspectorControls } from '@wordpress/block-editor';
|
|
7
7
|
import { Spinner, Modal, MenuItem } from '@wordpress/components';
|
|
8
8
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -18,6 +18,31 @@ import { TemplatePartAdvancedControls } from './advanced-controls';
|
|
|
18
18
|
import TemplatePartInnerBlocks from './inner-blocks';
|
|
19
19
|
import { createTemplatePartId } from './utils/create-template-part-id';
|
|
20
20
|
import { useAlternativeBlockPatterns, useAlternativeTemplateParts, useTemplatePartArea } from './utils/hooks';
|
|
21
|
+
function ReplaceButton({
|
|
22
|
+
isEntityAvailable,
|
|
23
|
+
area,
|
|
24
|
+
clientId,
|
|
25
|
+
templatePartId,
|
|
26
|
+
isTemplatePartSelectionOpen,
|
|
27
|
+
setIsTemplatePartSelectionOpen
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
templateParts
|
|
31
|
+
} = useAlternativeTemplateParts(area, templatePartId);
|
|
32
|
+
const blockPatterns = useAlternativeBlockPatterns(area, clientId);
|
|
33
|
+
const hasReplacements = !!templateParts.length || !!blockPatterns.length;
|
|
34
|
+
const canReplace = isEntityAvailable && hasReplacements && (area === 'header' || area === 'footer');
|
|
35
|
+
if (!canReplace) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return createElement(MenuItem, {
|
|
39
|
+
onClick: () => {
|
|
40
|
+
setIsTemplatePartSelectionOpen(true);
|
|
41
|
+
},
|
|
42
|
+
"aria-expanded": isTemplatePartSelectionOpen,
|
|
43
|
+
"aria-haspopup": "dialog"
|
|
44
|
+
}, __('Replace'));
|
|
45
|
+
}
|
|
21
46
|
export default function TemplatePartEdit({
|
|
22
47
|
attributes,
|
|
23
48
|
setAttributes,
|
|
@@ -61,17 +86,11 @@ export default function TemplatePartEdit({
|
|
|
61
86
|
area: _area
|
|
62
87
|
};
|
|
63
88
|
}, [templatePartId, attributes.area, clientId]);
|
|
64
|
-
const {
|
|
65
|
-
templateParts
|
|
66
|
-
} = useAlternativeTemplateParts(area, templatePartId);
|
|
67
|
-
const blockPatterns = useAlternativeBlockPatterns(area, clientId);
|
|
68
|
-
const hasReplacements = !!templateParts.length || !!blockPatterns.length;
|
|
69
89
|
const areaObject = useTemplatePartArea(area);
|
|
70
90
|
const blockProps = useBlockProps();
|
|
71
91
|
const isPlaceholder = !slug;
|
|
72
92
|
const isEntityAvailable = !isPlaceholder && !isMissing && isResolved;
|
|
73
93
|
const TagName = tagName || areaObject.tagName;
|
|
74
|
-
const canReplace = isEntityAvailable && hasReplacements && (area === 'header' || area === 'footer');
|
|
75
94
|
|
|
76
95
|
// We don't want to render a missing state if we have any inner blocks.
|
|
77
96
|
// A new template part is automatically created if we have any inner blocks but no entity.
|
|
@@ -88,6 +107,8 @@ export default function TemplatePartEdit({
|
|
|
88
107
|
}
|
|
89
108
|
return createElement(Fragment, null, createElement(RecursionProvider, {
|
|
90
109
|
uniqueId: templatePartId
|
|
110
|
+
}, createElement(InspectorControls, {
|
|
111
|
+
group: "advanced"
|
|
91
112
|
}, createElement(TemplatePartAdvancedControls, {
|
|
92
113
|
tagName: tagName,
|
|
93
114
|
setAttributes: setAttributes,
|
|
@@ -95,7 +116,7 @@ export default function TemplatePartEdit({
|
|
|
95
116
|
templatePartId: templatePartId,
|
|
96
117
|
defaultWrapper: areaObject.tagName,
|
|
97
118
|
hasInnerBlocks: innerBlocks.length > 0
|
|
98
|
-
}), isPlaceholder && createElement(TagName, {
|
|
119
|
+
})), isPlaceholder && createElement(TagName, {
|
|
99
120
|
...blockProps
|
|
100
121
|
}, createElement(TemplatePartPlaceholder, {
|
|
101
122
|
area: attributes.area,
|
|
@@ -103,7 +124,7 @@ export default function TemplatePartEdit({
|
|
|
103
124
|
clientId: clientId,
|
|
104
125
|
setAttributes: setAttributes,
|
|
105
126
|
onOpenSelectionModal: () => setIsTemplatePartSelectionOpen(true)
|
|
106
|
-
})),
|
|
127
|
+
})), createElement(BlockSettingsMenuControls, null, ({
|
|
107
128
|
selectedClientIds
|
|
108
129
|
}) => {
|
|
109
130
|
// Only enable for single selection that matches the current block.
|
|
@@ -111,13 +132,14 @@ export default function TemplatePartEdit({
|
|
|
111
132
|
if (!(selectedClientIds.length === 1 && clientId === selectedClientIds[0])) {
|
|
112
133
|
return null;
|
|
113
134
|
}
|
|
114
|
-
return createElement(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
return createElement(ReplaceButton, {
|
|
136
|
+
isEntityAvailable,
|
|
137
|
+
area,
|
|
138
|
+
clientId,
|
|
139
|
+
templatePartId,
|
|
140
|
+
isTemplatePartSelectionOpen,
|
|
141
|
+
setIsTemplatePartSelectionOpen
|
|
142
|
+
});
|
|
121
143
|
}), isEntityAvailable && createElement(TemplatePartInnerBlocks, {
|
|
122
144
|
tagName: TagName,
|
|
123
145
|
blockProps: blockProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","BlockSettingsMenuControls","useBlockProps","Warning","store","blockEditorStore","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Spinner","Modal","MenuItem","__","sprintf","coreStore","useState","TemplatePartPlaceholder","TemplatePartSelectionModal","TemplatePartAdvancedControls","TemplatePartInnerBlocks","createTemplatePartId","useAlternativeBlockPatterns","useAlternativeTemplateParts","useTemplatePartArea","TemplatePartEdit","attributes","setAttributes","clientId","currentTheme","select","getCurrentTheme","stylesheet","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","getEditedEntityRecord","hasFinishedResolution","getBlocks","getEntityArgs","entityRecord","_area","hasResolvedEntity","Object","keys","length","templateParts","blockPatterns","hasReplacements","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","canReplace","createElement","Fragment","uniqueId","defaultWrapper","hasInnerBlocks","onOpenSelectionModal","selectedClientIds","onClick","postId","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":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,yBAAyB,EACzBC,aAAa,EACbC,OAAO,EACPC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,QAC1C,yBAAyB;AAChC,SAASC,OAAO,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,uBAAuB;AAChE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASV,KAAK,IAAIW,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,eAAe;AACnD,OAAOC,0BAA0B,MAAM,mBAAmB;AAC1D,SAASC,4BAA4B,QAAQ,qBAAqB;AAClE,OAAOC,uBAAuB,MAAM,gBAAgB;AACpD,SAASC,oBAAo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AC;EAEb,CAC0B,CAC3B,EACCgD,iBAAiB,IAClBG,aAAA,CAAC5C,uBAAuB;IACvBe,OAAO,EAAG2B,OAAS;IACnBH,UAAU,EAAGA,UAAY;IACzBa,MAAM,EAAGnC,cAAgB;IACzB+B,cAAc,EAAG1B,WAAW,CAACY,MAAM,GAAG,CAAG;IACzClB,MAAM,EAAGA;EAAQ,CACjB,CACD,EACC,CAAEwB,aAAa,IAAI,CAAEnB,UAAU,IAChCuB,aAAA,CAACF,OAAO;IAAA,GAAMH;EAAU,GACvBK,aAAA,CAACtD,OAAO,MAAE,CACF,CAEQ,CAAC,EAClB6B,2BAA2B,IAC5ByB,aAAA,CAACrD,KAAK;IACL8D,gBAAgB,EAAC,6CAA6C;IAC9DC,KAAK,EAAG5D,OAAO;IACd;IACAD,EAAE,CAAE,aAAc,CAAC,EACnB6C,UAAU,CAACiB,KAAK,CAACC,WAAW,CAAC,CAC9B,CAAG;IACHC,cAAc,EAAGA,CAAA,KAChBrC,8BAA8B,CAAE,KAAM,CACtC;IACDsC,YAAY,EAAG;EAAM,GAErBd,aAAA,CAAC9C,0BAA0B;IAC1BmB,cAAc,EAAGA,cAAgB;IACjCT,QAAQ,EAAGA,QAAU;IACrBgB,IAAI,EAAGA,IAAM;IACbjB,aAAa,EAAGA,aAAe;IAC/BoD,OAAO,EAAGA,CAAA,KACTvC,8BAA8B,CAAE,KAAM;EACtC,CACD,CACK,CAEP,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["useSelect","BlockSettingsMenuControls","useBlockProps","Warning","store","blockEditorStore","RecursionProvider","useHasRecursion","InspectorControls","Spinner","Modal","MenuItem","__","sprintf","coreStore","useState","TemplatePartPlaceholder","TemplatePartSelectionModal","TemplatePartAdvancedControls","TemplatePartInnerBlocks","createTemplatePartId","useAlternativeBlockPatterns","useAlternativeTemplateParts","useTemplatePartArea","ReplaceButton","isEntityAvailable","area","clientId","templatePartId","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","templateParts","blockPatterns","hasReplacements","length","canReplace","createElement","onClick","TemplatePartEdit","attributes","setAttributes","currentTheme","select","getCurrentTheme","stylesheet","slug","theme","tagName","layout","hasAlreadyRendered","isResolved","innerBlocks","isMissing","getEditedEntityRecord","hasFinishedResolution","getBlocks","getEntityArgs","entityRecord","_area","hasResolvedEntity","Object","keys","areaObject","blockProps","isPlaceholder","TagName","Fragment","uniqueId","group","defaultWrapper","hasInnerBlocks","onOpenSelectionModal","selectedClientIds","postId","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":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,yBAAyB,EACzBC,aAAa,EACbC,OAAO,EACPC,KAAK,IAAIC,gBAAgB,EACzB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B,EAAC,6CAA6C;IAC9DC,KAAK,EAAG9D,OAAO;IACd;IACAD,EAAE,CAAE,aAAc,CAAC,EACnBkD,UAAU,CAACc,KAAK,CAACC,WAAW,CAAC,CAC9B,CAAG;IACHC,cAAc,EAAGA,CAAA,KAChBhD,8BAA8B,CAAE,KAAM,CACtC;IACDiD,YAAY,EAAG;EAAM,GAErB3C,aAAA,CAACnB,0BAA0B;IAC1BW,cAAc,EAAGA,cAAgB;IACjCD,QAAQ,EAAGA,QAAU;IACrBD,IAAI,EAAGA,IAAM;IACbc,aAAa,EAAGA,aAAe;IAC/BwC,OAAO,EAAGA,CAAA,KACTlD,8BAA8B,CAAE,KAAM;EACtC,CACD,CACK,CAEP,CAAC;AAEL"}
|
|
@@ -217,7 +217,8 @@ class VideoEdit extends Component {
|
|
|
217
217
|
} = this.props;
|
|
218
218
|
const {
|
|
219
219
|
id,
|
|
220
|
-
src
|
|
220
|
+
src,
|
|
221
|
+
guid
|
|
221
222
|
} = attributes;
|
|
222
223
|
const {
|
|
223
224
|
videoContainerHeight
|
|
@@ -238,7 +239,11 @@ class VideoEdit extends Component {
|
|
|
238
239
|
}));
|
|
239
240
|
}
|
|
240
241
|
});
|
|
241
|
-
|
|
242
|
+
|
|
243
|
+
// NOTE: `guid` is not part of the block's attribute definition. This case
|
|
244
|
+
// handled here is a temporary fix until a we find a better approach.
|
|
245
|
+
const isSourcePresent = src || guid && id;
|
|
246
|
+
if (!isSourcePresent) {
|
|
242
247
|
return createElement(View, {
|
|
243
248
|
style: {
|
|
244
249
|
flex: 1
|