@wordpress/block-library 8.22.0 → 8.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/block/edit.js +11 -13
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +3 -4
- package/build/block/edit.native.js.map +1 -1
- package/build/button/edit.js +61 -9
- package/build/button/edit.js.map +1 -1
- package/build/code/transforms.js +20 -7
- package/build/code/transforms.js.map +1 -1
- package/build/column/edit.js +1 -1
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +1 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/comments/edit/comments-inspector-controls.js +1 -0
- package/build/comments/edit/comments-inspector-controls.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 +1 -0
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/edit.js +1 -2
- package/build/details/edit.js.map +1 -1
- package/build/file/edit.js +8 -9
- package/build/file/edit.js.map +1 -1
- package/build/file/view.js +4 -6
- package/build/file/view.js.map +1 -1
- package/build/form/index.js +1 -1
- package/build/form/index.js.map +1 -1
- package/build/form-submit-button/edit.js +2 -1
- package/build/form-submit-button/edit.js.map +1 -1
- package/build/gallery/gap-styles.js +12 -7
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/group/edit.js +4 -7
- package/build/group/edit.js.map +1 -1
- package/build/html/transforms.js +7 -2
- package/build/html/transforms.js.map +1 -1
- package/build/image/deprecated.js +8 -0
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +17 -18
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +22 -15
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +35 -27
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -3
- package/build/image/index.js.map +1 -1
- package/build/image/view.js +234 -266
- package/build/image/view.js.map +1 -1
- package/build/missing/index.js +1 -1
- package/build/navigation/edit/overlay-menu-preview.js +1 -1
- package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build/navigation/use-template-part-area-label.js +2 -1
- package/build/navigation/use-template-part-area-label.js.map +1 -1
- package/build/navigation/view.js +153 -176
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +1 -1
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +2 -1
- package/build/navigation-link/index.js.map +1 -1
- package/build/pattern/edit.js +2 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/post-author/edit.js +0 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +21 -6
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +2 -8
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-terms/edit.js +0 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/preformatted/transforms.js +1 -4
- package/build/preformatted/transforms.js.map +1 -1
- package/build/query/edit/query-content.js +1 -0
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/view.js +52 -60
- package/build/query/view.js.map +1 -1
- package/build/quote/index.js +6 -0
- package/build/quote/index.js.map +1 -1
- package/build/search/view.js +66 -74
- package/build/search/view.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -0
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +3 -7
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/index.js +6 -2
- package/build/template-part/index.js.map +1 -1
- package/build/template-part/variations.js +5 -1
- package/build/template-part/variations.js.map +1 -1
- package/build/utils/remove-anchor-tag.js +17 -0
- package/build/utils/remove-anchor-tag.js.map +1 -0
- package/build-module/block/edit.js +11 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +3 -4
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/button/edit.js +65 -13
- package/build-module/button/edit.js.map +1 -1
- package/build-module/code/transforms.js +20 -7
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/column/edit.js +1 -1
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +1 -1
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/comments/edit/comments-inspector-controls.js +1 -0
- package/build-module/comments/edit/comments-inspector-controls.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 +1 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/edit.js +1 -2
- package/build-module/details/edit.js.map +1 -1
- package/build-module/file/edit.js +8 -9
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/view.js +5 -7
- package/build-module/file/view.js.map +1 -1
- package/build-module/form/index.js +1 -1
- package/build-module/form/index.js.map +1 -1
- package/build-module/form-submit-button/edit.js +2 -1
- package/build-module/form-submit-button/edit.js.map +1 -1
- package/build-module/gallery/gap-styles.js +13 -8
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/group/edit.js +4 -7
- package/build-module/group/edit.js.map +1 -1
- package/build-module/html/transforms.js +7 -2
- package/build-module/html/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +8 -0
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +18 -19
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +23 -16
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +36 -28
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/view.js +235 -267
- package/build-module/image/view.js.map +1 -1
- package/build-module/missing/index.js +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build-module/navigation/use-template-part-area-label.js +2 -1
- package/build-module/navigation/use-template-part-area-label.js.map +1 -1
- package/build-module/navigation/view.js +154 -177
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +2 -2
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +2 -1
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/pattern/edit.js +2 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-author/edit.js +0 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +21 -6
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +2 -8
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-terms/edit.js +0 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/preformatted/transforms.js +1 -4
- package/build-module/preformatted/transforms.js.map +1 -1
- package/build-module/query/edit/query-content.js +1 -0
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/view.js +53 -61
- package/build-module/query/view.js.map +1 -1
- package/build-module/quote/index.js +6 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/search/view.js +67 -75
- package/build-module/search/view.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -0
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +5 -9
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/index.js +6 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/template-part/variations.js +5 -1
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/utils/remove-anchor-tag.js +11 -0
- package/build-module/utils/remove-anchor-tag.js.map +1 -0
- package/build-style/cover/style-rtl.css +14 -14
- package/build-style/cover/style.css +14 -14
- package/build-style/editor-rtl.css +15 -6
- package/build-style/editor.css +15 -6
- package/build-style/gallery/style-rtl.css +28 -0
- package/build-style/gallery/style.css +28 -0
- package/build-style/image/style-rtl.css +19 -13
- package/build-style/image/style.css +19 -13
- package/build-style/post-featured-image/editor-rtl.css +9 -0
- package/build-style/post-featured-image/editor.css +9 -0
- package/build-style/quote/style-rtl.css +3 -0
- package/build-style/quote/style.css +3 -0
- package/build-style/read-more/style-rtl.css +2 -2
- package/build-style/read-more/style.css +2 -2
- package/build-style/style-rtl.css +66 -29
- package/build-style/style.css +66 -29
- package/package.json +32 -32
- package/src/block/edit.js +20 -20
- package/src/block/edit.native.js +5 -13
- package/src/button/edit.js +76 -10
- package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -6
- package/src/buttons/test/edit.native.js +0 -27
- package/src/code/transforms.js +14 -8
- package/src/column/edit.js +1 -1
- package/src/column/edit.native.js +1 -1
- package/src/comments/edit/comments-inspector-controls.js +1 -0
- package/src/cover/edit/index.js +1 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/cover/style.scss +1 -1
- package/src/cover/test/edit.js +1 -1
- package/src/details/edit.js +0 -1
- package/src/editor.scss +6 -6
- package/src/file/edit.js +11 -10
- package/src/file/index.php +30 -11
- package/src/file/view.js +5 -7
- package/src/form/index.js +1 -1
- package/src/form-submit-button/edit.js +1 -0
- package/src/gallery/gap-styles.js +10 -9
- package/src/gallery/style.scss +1 -0
- package/src/group/edit.js +4 -11
- package/src/heading/test/__snapshots__/index.native.js.snap +6 -0
- package/src/heading/test/index.native.js +40 -0
- package/src/html/transforms.js +5 -2
- package/src/image/block.json +2 -3
- package/src/image/deprecated.js +8 -0
- package/src/image/edit.js +16 -21
- package/src/image/edit.native.js +17 -18
- package/src/image/image.js +48 -51
- package/src/image/index.php +57 -49
- package/src/image/style.scss +18 -13
- package/src/image/view.js +281 -324
- package/src/missing/block.json +1 -1
- package/src/navigation/edit/overlay-menu-preview.js +1 -1
- package/src/navigation/index.php +46 -402
- package/src/navigation/use-template-part-area-label.js +4 -2
- package/src/navigation/view.js +159 -192
- package/src/navigation-link/block.json +2 -1
- package/src/navigation-link/edit.js +2 -2
- package/src/navigation-link/index.php +57 -0
- package/src/paragraph/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/paragraph/test/edit.native.js +37 -1
- package/src/paragraph/test/transforms.native.js +1 -0
- package/src/pattern/edit.js +7 -4
- package/src/pattern/index.php +6 -1
- package/src/post-author/edit.js +0 -1
- package/src/post-featured-image/edit.js +38 -5
- package/src/post-featured-image/editor.scss +19 -0
- package/src/post-template/block.json +0 -1
- package/src/post-template/edit.js +1 -5
- package/src/post-terms/edit.js +0 -2
- package/src/preformatted/transforms.js +1 -4
- package/src/query/edit/query-content.js +1 -0
- package/src/query/index.php +42 -24
- package/src/query/view.js +58 -65
- package/src/query-pagination-next/index.php +3 -3
- package/src/query-pagination-numbers/index.php +1 -1
- package/src/query-pagination-previous/index.php +3 -3
- package/src/quote/block.json +6 -0
- package/src/quote/style.scss +4 -0
- package/src/read-more/style.scss +1 -1
- package/src/search/index.php +40 -40
- package/src/search/view.js +58 -63
- package/src/template-part/edit/advanced-controls.js +1 -0
- package/src/template-part/edit/index.js +7 -14
- package/src/template-part/index.js +4 -3
- package/src/template-part/index.php +4 -4
- package/src/template-part/variations.js +4 -2
- package/src/utils/remove-anchor-tag.js +10 -0
- package/tsconfig.json +1 -0
package/build/quote/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_deprecated","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","value","type","source","selector","multiline","__experimentalRole","citation","align","supports","anchor","html","__experimentalOnEnter","__experimentalOnMerge","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","fontAppearance","color","gradients","heading","link","background","text","styles","label","isDefault","editorStyle","style","exports","settings","icon","example","innerBlocks","content","__","transforms","edit","save","deprecated","init","initBlock"],"sources":["@wordpress/block-library/src/quote/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { quote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcitation: 'Julio Cortázar',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( 'In quoting others, we cite ourselves.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\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;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,WAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAdA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAQ,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAAC,SAAA;MAAA;MAAAC,kBAAA;IAAA;IAAAC,QAAA;MAAAL,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAA;MAAAE,kBAAA;IAAA;IAAAE,KAAA;MAAAN,IAAA;IAAA;EAAA;EAAAO,QAAA;IAAAC,MAAA;IAAAC,IAAA;IAAAC,qBAAA;IAAAC,qBAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAC,6BAAA;QAAAR,QAAA;QAAAS,cAAA;MAAA;IAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,OAAA;MAAAC,IAAA;MAAAL,6BAAA;QAAAM,UAAA;QAAAC,IAAA;MAAA;IAAA;EAAA;EAAAC,MAAA;
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_deprecated","_edit","_save","_transforms","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","value","type","source","selector","multiline","__experimentalRole","citation","align","supports","anchor","html","__experimentalOnEnter","__experimentalOnMerge","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","fontAppearance","color","gradients","heading","link","background","text","layout","allowEditing","spacing","blockGap","styles","label","isDefault","editorStyle","style","exports","settings","icon","example","innerBlocks","content","__","transforms","edit","save","deprecated","init","initBlock"],"sources":["@wordpress/block-library/src/quote/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { quote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcitation: 'Julio Cortázar',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( 'In quoting others, we cite ourselves.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttrans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IAAAC,SAAA;EAAA;IAAA3C,IAAA;IAAA0C,KAAA;EAAA;EAAAE,WAAA;EAAAC,KAAA;AAAA;AAAAC,OAAA,CAAAjD,QAAA,GAAAA,QAAA;AAUA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAACiD,OAAA,CAAA9C,IAAA,GAAAA,IAAA;AAInB,MAAM+C,QAAQ,GAAG;EACvBC,IAAI,EAAJA,YAAI;EACJC,OAAO,EAAE;IACR3C,UAAU,EAAE;MACXO,QAAQ,EAAE;IACX,CAAC;IACDqC,WAAW,EAAE,CACZ;MACClD,IAAI,EAAE,gBAAgB;MACtBM,UAAU,EAAE;QACX6C,OAAO,EAAE,IAAAC,QAAE,EAAE,uCAAwC;MACtD;IACD,CAAC;EAEH,CAAC;EACDC,UAAU,EAAVA,mBAAU;EACVC,IAAI,EAAJA,aAAI;EACJC,IAAI,EAAJA,aAAI;EACJC,UAAU,EAAVA;AACD,CAAC;AAACV,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMU,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAE1D,IAAI;EAAEH,QAAQ;EAAEkD;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAW,IAAA,GAAAA,IAAA"}
|
package/build/search/view.js
CHANGED
|
@@ -5,83 +5,75 @@ var _interactivity = require("@wordpress/interactivity");
|
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
8
|
+
const {
|
|
9
|
+
actions
|
|
10
|
+
} = (0, _interactivity.store)('core/search', {
|
|
11
|
+
state: {
|
|
12
|
+
get ariaLabel() {
|
|
13
|
+
const {
|
|
14
|
+
isSearchInputVisible,
|
|
15
|
+
ariaLabelCollapsed,
|
|
16
|
+
ariaLabelExpanded
|
|
17
|
+
} = (0, _interactivity.getContext)();
|
|
18
|
+
return isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
|
|
19
|
+
},
|
|
20
|
+
get ariaControls() {
|
|
21
|
+
const {
|
|
22
|
+
isSearchInputVisible,
|
|
23
|
+
inputId
|
|
24
|
+
} = (0, _interactivity.getContext)();
|
|
25
|
+
return isSearchInputVisible ? null : inputId;
|
|
26
|
+
},
|
|
27
|
+
get type() {
|
|
28
|
+
const {
|
|
29
|
+
isSearchInputVisible
|
|
30
|
+
} = (0, _interactivity.getContext)();
|
|
31
|
+
return isSearchInputVisible ? 'submit' : 'button';
|
|
32
|
+
},
|
|
33
|
+
get tabindex() {
|
|
34
|
+
const {
|
|
35
|
+
isSearchInputVisible
|
|
36
|
+
} = (0, _interactivity.getContext)();
|
|
37
|
+
return isSearchInputVisible ? '0' : '-1';
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
40
|
actions: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// If focus is outside search form, and in the document, close menu
|
|
77
|
-
// event.target === The element losing focus
|
|
78
|
-
// event.relatedTarget === The element receiving focus (if any)
|
|
79
|
-
// When focusout is outside the document,
|
|
80
|
-
// `window.document.activeElement` doesn't change.
|
|
81
|
-
if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
|
|
82
|
-
actions.core.search.closeSearchInput(store);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
41
|
+
openSearchInput(event) {
|
|
42
|
+
const ctx = (0, _interactivity.getContext)();
|
|
43
|
+
const {
|
|
44
|
+
ref
|
|
45
|
+
} = (0, _interactivity.getElement)();
|
|
46
|
+
if (!ctx.isSearchInputVisible) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
ctx.isSearchInputVisible = true;
|
|
49
|
+
ref.parentElement.querySelector('input').focus();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
closeSearchInput() {
|
|
53
|
+
const ctx = (0, _interactivity.getContext)();
|
|
54
|
+
ctx.isSearchInputVisible = false;
|
|
55
|
+
},
|
|
56
|
+
handleSearchKeydown(event) {
|
|
57
|
+
const {
|
|
58
|
+
ref
|
|
59
|
+
} = (0, _interactivity.getElement)();
|
|
60
|
+
// If Escape close the menu.
|
|
61
|
+
if (event?.key === 'Escape') {
|
|
62
|
+
actions.closeSearchInput();
|
|
63
|
+
ref.querySelector('button').focus();
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
handleSearchFocusout(event) {
|
|
67
|
+
const {
|
|
68
|
+
ref
|
|
69
|
+
} = (0, _interactivity.getElement)();
|
|
70
|
+
// If focus is outside search form, and in the document, close menu
|
|
71
|
+
// event.target === The element losing focus
|
|
72
|
+
// event.relatedTarget === The element receiving focus (if any)
|
|
73
|
+
// When focusout is outside the document,
|
|
74
|
+
// `window.document.activeElement` doesn't change.
|
|
75
|
+
if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
|
|
76
|
+
actions.closeSearchInput();
|
|
85
77
|
}
|
|
86
78
|
}
|
|
87
79
|
}
|
package/build/search/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_interactivity","require","
|
|
1
|
+
{"version":3,"names":["_interactivity","require","actions","store","state","ariaLabel","isSearchInputVisible","ariaLabelCollapsed","ariaLabelExpanded","getContext","ariaControls","inputId","type","tabindex","openSearchInput","event","ctx","ref","getElement","preventDefault","parentElement","querySelector","focus","closeSearchInput","handleSearchKeydown","key","handleSearchFocusout","contains","relatedTarget","target","window","document","activeElement"],"sources":["@wordpress/block-library/src/search/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nconst { actions } = store( 'core/search', {\n\tstate: {\n\t\tget ariaLabel() {\n\t\t\tconst {\n\t\t\t\tisSearchInputVisible,\n\t\t\t\tariaLabelCollapsed,\n\t\t\t\tariaLabelExpanded,\n\t\t\t} = getContext();\n\t\t\treturn isSearchInputVisible\n\t\t\t\t? ariaLabelExpanded\n\t\t\t\t: ariaLabelCollapsed;\n\t\t},\n\t\tget ariaControls() {\n\t\t\tconst { isSearchInputVisible, inputId } = getContext();\n\t\t\treturn isSearchInputVisible ? null : inputId;\n\t\t},\n\t\tget type() {\n\t\t\tconst { isSearchInputVisible } = getContext();\n\t\t\treturn isSearchInputVisible ? 'submit' : 'button';\n\t\t},\n\t\tget tabindex() {\n\t\t\tconst { isSearchInputVisible } = getContext();\n\t\t\treturn isSearchInputVisible ? '0' : '-1';\n\t\t},\n\t},\n\tactions: {\n\t\topenSearchInput( event ) {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tif ( ! ctx.isSearchInputVisible ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tctx.isSearchInputVisible = true;\n\t\t\t\tref.parentElement.querySelector( 'input' ).focus();\n\t\t\t}\n\t\t},\n\t\tcloseSearchInput() {\n\t\t\tconst ctx = getContext();\n\t\t\tctx.isSearchInputVisible = false;\n\t\t},\n\t\thandleSearchKeydown( event ) {\n\t\t\tconst { ref } = getElement();\n\t\t\t// If Escape close the menu.\n\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\tactions.closeSearchInput();\n\t\t\t\tref.querySelector( 'button' ).focus();\n\t\t\t}\n\t\t},\n\t\thandleSearchFocusout( event ) {\n\t\t\tconst { ref } = getElement();\n\t\t\t// If focus is outside search form, and in the document, close menu\n\t\t\t// event.target === The element losing focus\n\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t// When focusout is outside the document,\n\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\tif (\n\t\t\t\t! ref.contains( event.relatedTarget ) &&\n\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t) {\n\t\t\t\tactions.closeSearchInput();\n\t\t\t}\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAM;EAAEC;AAAQ,CAAC,GAAG,IAAAC,oBAAK,EAAE,aAAa,EAAE;EACzCC,KAAK,EAAE;IACN,IAAIC,SAASA,CAAA,EAAG;MACf,MAAM;QACLC,oBAAoB;QACpBC,kBAAkB;QAClBC;MACD,CAAC,GAAG,IAAAC,yBAAU,EAAC,CAAC;MAChB,OAAOH,oBAAoB,GACxBE,iBAAiB,GACjBD,kBAAkB;IACtB,CAAC;IACD,IAAIG,YAAYA,CAAA,EAAG;MAClB,MAAM;QAAEJ,oBAAoB;QAAEK;MAAQ,CAAC,GAAG,IAAAF,yBAAU,EAAC,CAAC;MACtD,OAAOH,oBAAoB,GAAG,IAAI,GAAGK,OAAO;IAC7C,CAAC;IACD,IAAIC,IAAIA,CAAA,EAAG;MACV,MAAM;QAAEN;MAAqB,CAAC,GAAG,IAAAG,yBAAU,EAAC,CAAC;MAC7C,OAAOH,oBAAoB,GAAG,QAAQ,GAAG,QAAQ;IAClD,CAAC;IACD,IAAIO,QAAQA,CAA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AAgB,CAAC,CAAC;MAC3B;IACD;EACD;AACD,CAAE,CAAC"}
|
|
@@ -69,6 +69,7 @@ function TemplatePartAdvancedControls({
|
|
|
69
69
|
onChange: setArea
|
|
70
70
|
})), (0, _react.createElement)(_components.SelectControl, {
|
|
71
71
|
__nextHasNoMarginBottom: true,
|
|
72
|
+
__next40pxDefaultSize: true,
|
|
72
73
|
label: (0, _i18n.__)('HTML element'),
|
|
73
74
|
options: [{
|
|
74
75
|
label: (0, _i18n.sprintf)( /* translators: %s: HTML tag based on area. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_components","_i18n","_blockEditor","_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","InspectorControls","group","Fragment","TextControl","__nextHasNoMarginBottom","onChange","onFocus","event","target","SelectControl","labelPosition","options","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 { InspectorControls } from '@wordpress/block-editor';\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<InspectorControls group=\"advanced\">\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\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</InspectorControls>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,eAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA,MAAMM,mBAAmB,GAAG;EAC3BC,MAAM,EAAE,IAAAC,QAAE,EACT,qH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AAG;IACvB0B,KAAK,EAAGV,KAAO;IACfkB,QAAQ,EAAKR,KAAK,IAAM;MACvBT,QAAQ,CAAES,KAAM,CAAC;IAClB,CAAG;IACHS,OAAO,EAAKC,KAAK,IAAMA,KAAK,CAACC,MAAM,CAACjB,MAAM,CAAC;EAAG,CAC9C,CAAC,EAEF,IAAAO,MAAA,CAAAC,aAAA,EAACnC,WAAA,CAAA6C,aAAa;IACbL,uBAAuB;IACvBT,KAAK,EAAG,IAAAxB,QAAE,EAAE,MAAO,CAAG;IACtBuC,aAAa,EAAC,KAAK;IACnBC,OAAO,EAAGlB,WAAa;IACvBI,KAAK,EAAGb,IAAM;IACdqB,QAAQ,EAAGpB;EAAS,CACpB,CACA,CACF,EACD,IAAAa,MAAA,CAAAC,aAAA,EAACnC,WAAA,CAAA6C,aAAa;IACbL,uBAAuB;
|
|
1
|
+
{"version":3,"names":["_coreData","require","_components","_i18n","_blockEditor","_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","InspectorControls","group","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 { InspectorControls } from '@wordpress/block-editor';\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<InspectorControls group=\"advanced\">\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</InspectorControls>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,G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,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;IACvB2B,QAAQ,EAAKR,KAAK,IAAMlB,aAAa,CAAE;MAAED,OAAO,EAAEmB;IAAM,CAAE,CAAG;IAC7DiB,IAAI,EAAG7C,mBAAmB,CAAES,OAAO;EAAI,CACvC,CAAC,EACA,CAAEK,cAAc,IACjB,IAAAe,MAAA,CAAAC,aAAA,EAAC/B,eAAA,CAAA+C,0BAA0B;IAC1B/B,IAAI,EAAGA,IAAM;IACbL,aAAa,EAAGA;EAAe,CAC/B,CAEgB,CAAC;AAEtB"}
|
|
@@ -31,9 +31,10 @@ function TemplatePartEdit({
|
|
|
31
31
|
setAttributes,
|
|
32
32
|
clientId
|
|
33
33
|
}) {
|
|
34
|
+
const currentTheme = (0, _data.useSelect)(select => select(_coreData.store).getCurrentTheme()?.stylesheet, []);
|
|
34
35
|
const {
|
|
35
36
|
slug,
|
|
36
|
-
theme,
|
|
37
|
+
theme = currentTheme,
|
|
37
38
|
tagName,
|
|
38
39
|
layout = {}
|
|
39
40
|
} = attributes;
|
|
@@ -124,12 +125,7 @@ function TemplatePartEdit({
|
|
|
124
125
|
},
|
|
125
126
|
"aria-expanded": isTemplatePartSelectionOpen,
|
|
126
127
|
"aria-haspopup": "dialog"
|
|
127
|
-
}, (0,
|
|
128
|
-
BlockTitle: (0, _react.createElement)(_blockEditor.BlockTitle, {
|
|
129
|
-
clientId: clientId,
|
|
130
|
-
maximumLength: 25
|
|
131
|
-
})
|
|
132
|
-
}));
|
|
128
|
+
}, (0, _i18n.__)('Replace'));
|
|
133
129
|
}), isEntityAvailable && (0, _react.createElement)(_innerBlocks.default, {
|
|
134
130
|
tagName: TagName,
|
|
135
131
|
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","slug","theme","tagName","layout","templatePartId","createTemplatePartId","hasAlreadyRendered","useHasRecursion","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","useState","isResolved","innerBlocks","isMissing","area","useSelect","select","getEditedEntityRecord","hasFinishedResolution","coreStore","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","createInterpolateElement","BlockTitle","maximumLength","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\tBlockTitle,\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, createInterpolateElement } 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 { slug, theme, 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{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t__( 'Replace <BlockTitle />' ),\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tBlockTitle: (\n\t\t\t\t\t\t\t\t\t\t\t\t<BlockTitle\n\t\t\t\t\t\t\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t\t\t\t\t\t\tmaximumLength={ 25 }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t) }\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;AASA,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;AA1BA;AACA;AACA;;AAgBA;AACA;AACA;;AAYe,SAASa,gBAAgBA,CAAE;EACzCC,UAAU;EACVC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC,OAAO;IAAEC,MAAM,GAAG,CAAC;EAAE,CAAC,GAAGN,UAAU;EACxD,MAAMO,cAAc,GAAG,IAAAC,0CAAoB,EAAEJ,KAAK,EAAED,IAAK,CAAC;EAC1D,MAAMM,kBAAkB,GAAG,IAAAC,0CAAe,EAAEH,cAAe,CAAC;EAC5D,MAAM,CAAEI,2BAA2B,EAAEC,8BAA8B,CAAE,GACpE,IAAAC,iBAAQ,EAAE,KAAM,CAAC;;EAElB;EACA;EACA;EACA,MAAM;IAAEC,UAAU;IAAEC,WAAW;IAAEC,SAAS;IAAEC;EA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GA,UAAY;IACzB0B,MAAM,EAAG1D,cAAgB;IACzBgD,cAAc,EAAGxC,WAAW,CAACgB,MAAM,GAAG,CAAG;IACzCzB,MAAM,EAAGA;EAAQ,CACjB,CACD,EACC,CAAEmC,aAAa,IAAI,CAAE3B,UAAU,IAChC,IAAA+B,MAAA,CAAAC,aAAA,EAACH,OAAO;IAAA,GAAMJ;EAAU,GACvB,IAAAM,MAAA,CAAAC,aAAA,EAAC1D,WAAA,CAAA8E,OAAO,MAAE,CACF,CAEQ,CAAC,EAClBvD,2BAA2B,IAC5B,IAAAkC,MAAA,CAAAC,aAAA,EAAC1D,WAAA,CAAA+E,KAAK;IACLC,gBAAgB,EAAC,6CAA6C;IAC9DC,KAAK,EAAG,IAAArB,aAAO;IACd;IACA,IAAAC,QAAE,EAAE,aAAc,CAAC,EACnBZ,UAAU,CAACiC,KAAK,CAACC,WAAW,CAAC,CAC9B,CAAG;IACHC,cAAc,EAAGA,CAAA,KAChB5D,8BAA8B,CAAE,KAAM,CACtC;IACD6D,YAAY,EAAG;EAAM,GAErB,IAAA5B,MAAA,CAAAC,aAAA,EAACpD,eAAA,CAAA8D,OAA0B;IAC1BjD,cAAc,EAAGA,cAAgB;IACjCL,QAAQ,EAAGA,QAAU;IACrBe,IAAI,EAAGA,IAAM;IACbhB,aAAa,EAAGA,aAAe;IAC/ByE,OAAO,EAAGA,CAAA,KACT9D,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","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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AC,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"}
|
|
@@ -69,7 +69,11 @@ const settings = {
|
|
|
69
69
|
if (!slug) {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const {
|
|
73
|
+
getCurrentTheme,
|
|
74
|
+
getEntityRecord
|
|
75
|
+
} = (0, _data.select)(_coreData.store);
|
|
76
|
+
const entity = getEntityRecord('postType', 'wp_template_part', (theme || getCurrentTheme()?.stylesheet) + '//' + slug);
|
|
73
77
|
if (!entity) {
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
@@ -83,7 +87,7 @@ const init = () => {
|
|
|
83
87
|
|
|
84
88
|
// Prevent adding template parts inside post templates.
|
|
85
89
|
const DISALLOWED_PARENTS = ['core/post-template', 'core/post-content'];
|
|
86
|
-
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromPostTemplates', (canInsert, blockType, rootClientId, {
|
|
90
|
+
(0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'core/block-library/removeTemplatePartsFromPostTemplates', (canInsert, blockType, rootClientId, {
|
|
87
91
|
getBlock,
|
|
88
92
|
getBlockParentsByBlockName
|
|
89
93
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_changeCase","require","_coreData","_data","_icons","_hooks","_htmlEntities","_initBlock","_interopRequireDefault","_edit","_variations","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","slug","type","theme","tagName","area","supports","align","html","reusable","renaming","editorStyle","exports","settings","icon","symbolFilled","__experimentalLabel","
|
|
1
|
+
{"version":3,"names":["_changeCase","require","_coreData","_data","_icons","_hooks","_htmlEntities","_initBlock","_interopRequireDefault","_edit","_variations","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","slug","type","theme","tagName","area","supports","align","html","reusable","renaming","editorStyle","exports","settings","icon","symbolFilled","__experimentalLabel","getCurrentTheme","getEntityRecord","select","coreDataStore","entity","stylesheet","decodeEntities","rendered","capitalCase","edit","init","addFilter","enhanceTemplatePartVariations","DISALLOWED_PARENTS","canInsert","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length","initBlock"],"sources":["@wordpress/block-library/src/template-part/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getCurrentTheme, getEntityRecord } = select( coreDataStore );\n\t\tconst entity = getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t( theme || getCurrentTheme()?.stylesheet ) + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title?.rendered ) ||\n\t\t\tcapitalCase( entity.slug )\n\t\t);\n\t},\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceTemplatePartVariations\n\t);\n\n\t// Prevent adding template parts inside post templates.\n\tconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'core/block-library/removeTemplatePartsFromPostTemplates',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlock, getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\t\treturn canInsert;\n\t\t\t}\n\n\t\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\t\tconst hasDisallowedParent =\n\t\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tdisallowedParentType\n\t\t\t\t\t).length;\n\t\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AApBA;AACA;AACA;AAGA;AACA;AACA;AAOA;AACA;AACA;AAFA,MAAAU,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,IAAA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CACCG,SAAS,EACTC,SAAS,EACTC,YAAY,EACZ;IAAEC,QAAQ;IAAEC;EAA2B,CAAC,KACpC;IACJ,IAAKH,SAAS,CAACrC,IAAI,KAAK,oBAAoB,EAAG;MAC9C,OAAOoC,SAAS;IACjB;IAEA,KAAM,MAAMK,oBAAoB,IAAIN,kBAAkB,EAAG;MACxD,MAAMO,mBAAmB,GACxBH,QAAQ,CAAED,YAAa,CAAC,EAAEtC,IAAI,KAAKyC,oBAAoB,IACvDD,0BAA0B,CACzBF,YAAY,EACZG,oBACD,CAAC,CAACE,MAAM;MACT,IAAKD,mBAAmB,EAAG;QAC1B,OAAO,KAAK;MACb;IACD;IACA,OAAO,IAAI;EACZ,CACD,CAAC;EAED,OAAO,IAAAE,kBAAS,EAAE;IAAE5C,IAAI;IAAEH,QAAQ;IAAEqB;EAAS,CAAE,CAAC;AACjD,CAAC;AAACD,OAAA,CAAAe,IAAA,GAAAA,IAAA"}
|
|
@@ -38,7 +38,11 @@ function enhanceTemplatePartVariations(settings, name) {
|
|
|
38
38
|
// Find a matching variation from the created template part
|
|
39
39
|
// by checking the entity's `area` property.
|
|
40
40
|
if (!slug) return false;
|
|
41
|
-
const
|
|
41
|
+
const {
|
|
42
|
+
getCurrentTheme,
|
|
43
|
+
getEntityRecord
|
|
44
|
+
} = (0, _data.select)(_coreData.store);
|
|
45
|
+
const entity = getEntityRecord('postType', 'wp_template_part', `${theme || getCurrentTheme()?.stylesheet}//${slug}`);
|
|
42
46
|
if (entity?.slug) {
|
|
43
47
|
return entity.slug === variationAttributes.slug;
|
|
44
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_data","_icons","getTemplatePartIcon","iconName","headerIcon","footerIcon","sidebarIcon","symbolFilledIcon","enhanceTemplatePartVariations","settings","name","variations","isActive","blockAttributes","variationAttributes","area","theme","slug","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_data","_icons","getTemplatePartIcon","iconName","headerIcon","footerIcon","sidebarIcon","symbolFilledIcon","enhanceTemplatePartVariations","settings","name","variations","isActive","blockAttributes","variationAttributes","area","theme","slug","getCurrentTheme","getEntityRecord","select","coreDataStore","entity","stylesheet","map","variation","icon"],"sources":["@wordpress/block-library/src/template-part/variations.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport {\n\theader as headerIcon,\n\tfooter as footerIcon,\n\tsidebar as sidebarIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\n\nfunction getTemplatePartIcon( iconName ) {\n\tif ( 'header' === iconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === iconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === iconName ) {\n\t\treturn sidebarIcon;\n\t}\n\treturn symbolFilledIcon;\n}\n\nexport function enhanceTemplatePartVariations( settings, name ) {\n\tif ( name !== 'core/template-part' ) {\n\t\treturn settings;\n\t}\n\n\tif ( settings.variations ) {\n\t\tconst isActive = ( blockAttributes, variationAttributes ) => {\n\t\t\tconst { area, theme, slug } = blockAttributes;\n\t\t\t// We first check the `area` block attribute which is set during insertion.\n\t\t\t// This property is removed on the creation of a template part.\n\t\t\tif ( area ) return area === variationAttributes.area;\n\t\t\t// Find a matching variation from the created template part\n\t\t\t// by checking the entity's `area` property.\n\t\t\tif ( ! slug ) return false;\n\t\t\tconst { getCurrentTheme, getEntityRecord } =\n\t\t\t\tselect( coreDataStore );\n\t\t\tconst entity = getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t`${ theme || getCurrentTheme()?.stylesheet }//${ slug }`\n\t\t\t);\n\n\t\t\tif ( entity?.slug ) {\n\t\t\t\treturn entity.slug === variationAttributes.slug;\n\t\t\t}\n\t\t\treturn entity?.area === variationAttributes.area;\n\t\t};\n\n\t\tconst variations = settings.variations.map( ( variation ) => {\n\t\t\treturn {\n\t\t\t\t...variation,\n\t\t\t\t...( ! variation.isActive && { isActive } ),\n\t\t\t\t...( typeof variation.icon === 'string' && {\n\t\t\t\t\ticon: getTemplatePartIcon( variation.icon ),\n\t\t\t\t} ),\n\t\t\t};\n\t\t} );\n\n\t\treturn {\n\t\t\t...settings,\n\t\t\tvariations,\n\t\t};\n\t}\n\treturn settings;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAUA,SAASG,mBAAmBA,CAAEC,QAAQ,EAAG;EACxC,IAAK,QAAQ,KAAKA,QAAQ,EAAG;IAC5B,OAAOC,aAAU;EAClB,CAAC,MAAM,IAAK,QAAQ,KAAKD,QAAQ,EAAG;IACnC,OAAOE,aAAU;EAClB,CAAC,MAAM,IAAK,SAAS,KAAKF,QAAQ,EAAG;IACpC,OAAOG,cAAW;EACnB;EACA,OAAOC,mBAAgB;AACxB;AAEO,SAASC,6BAA6BA,CAAEC,QAAQ,EAAEC,IAAI,EAAG;EAC/D,IAAKA,IAAI,KAAK,oBAAoB,EAAG;IACpC,OAAOD,QAAQ;EAChB;EAEA,IAAKA,QAAQ,CAACE,UAAU,EAAG;IAC1B,MAAMC,QAAQ,GAAGA,CAAEC,eAAe,EAAEC,mBAAmB,KAAM;MAC5D,MAAM;QAAEC,IAAI;QAAEC,KAAK;QAAEC;MAAK,CAAC,GAAGJ,eAAe;MAC7C;MACA;MACA,IAAKE,IAAI,EAAG,OAAOA,IAAI,KAAKD,mBAAmB,CAACC,IAAI;MACpD;MACA;MACA,IAAK,CAAEE,IAAI,EAAG,OAAO,KAAK;MAC1B,MAAM;QAAEC,eAAe;QAAEC;MAAgB,CAAC,GACzC,IAAAC,YAAM,EAAEC,eAAc,CAAC;MACxB,MAAMC,MAAM,GAAGH,eAAe,CAC7B,UAAU,EACV,kBAAkB,EACjB,GAAGH,KAAK,IAAIE,eAAe,CAAC,CAAC,EAAEK,UAAY,KAAKN,IAAM,EACxD,CAAC;MAED,IAAKK,MAAM,EAAEL,IAAI,EAAG;QACnB,OAAOK,MAAM,CAACL,IAAI,KAAKH,mBAAmB,CAACG,IAAI;MAChD;MACA,OAAOK,MAAM,EAAEP,IAAI,KAAKD,mBAAmB,CAACC,IAAI;IACjD,CAAC;IAED,MAAMJ,UAAU,GAAGF,QAAQ,CAACE,UAAU,CAACa,GAAG,CAAIC,SAAS,IAAM;MAC5D,OAAO;QACN,GAAGA,SAAS;QACZ,IAAK,CAAEA,SAAS,CAACb,QAAQ,IAAI;UAAEA;QAAS,CAAC,CAAE;QAC3C,IAAK,OAAOa,SAAS,CAACC,IAAI,KAAK,QAAQ,IAAI;UAC1CA,IAAI,EAAExB,mBAAmB,CAAEuB,SAAS,CAACC,IAAK;QAC3C,CAAC;MACF,CAAC;IACF,CAAE,CAAC;IAEH,OAAO;MACN,GAAGjB,QAAQ;MACXE;IACD,CAAC;EACF;EACA,OAAOF,QAAQ;AAChB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = removeAnchorTag;
|
|
7
|
+
/**
|
|
8
|
+
* Removes anchor tags from a string.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} value The value to remove anchor tags from.
|
|
11
|
+
*
|
|
12
|
+
* @return {string} The value with anchor tags removed.
|
|
13
|
+
*/
|
|
14
|
+
function removeAnchorTag(value) {
|
|
15
|
+
return value.replace(/<\/?a[^>]*>/g, '');
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=remove-anchor-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["removeAnchorTag","value","replace"],"sources":["@wordpress/block-library/src/utils/remove-anchor-tag.js"],"sourcesContent":["/**\n * Removes anchor tags from a string.\n *\n * @param {string} value The value to remove anchor tags from.\n *\n * @return {string} The value with anchor tags removed.\n */\nexport default function removeAnchorTag( value ) {\n\treturn value.replace( /<\\/?a[^>]*>/g, '' );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAeA,CAAEC,KAAK,EAAG;EAChD,OAAOA,KAAK,CAACC,OAAO,CAAE,cAAc,EAAE,EAAG,CAAC;AAC3C"}
|
|
@@ -81,30 +81,28 @@ export default function ReusableBlockEdit({
|
|
|
81
81
|
onChange,
|
|
82
82
|
renderAppender: blocks?.length ? undefined : InnerBlocks.ButtonBlockAppender
|
|
83
83
|
});
|
|
84
|
+
let children = null;
|
|
84
85
|
if (hasAlreadyRendered) {
|
|
85
|
-
|
|
86
|
-
...blockProps
|
|
87
|
-
}, createElement(Warning, null, __('Block cannot be rendered inside itself.')));
|
|
86
|
+
children = createElement(Warning, null, __('Block cannot be rendered inside itself.'));
|
|
88
87
|
}
|
|
89
88
|
if (isMissing) {
|
|
90
|
-
|
|
91
|
-
...blockProps
|
|
92
|
-
}, createElement(Warning, null, __('Block has been deleted or is unavailable.')));
|
|
89
|
+
children = createElement(Warning, null, __('Block has been deleted or is unavailable.'));
|
|
93
90
|
}
|
|
94
91
|
if (!hasResolved) {
|
|
95
|
-
|
|
96
|
-
...blockProps
|
|
97
|
-
}, createElement(Placeholder, null, createElement(Spinner, null)));
|
|
92
|
+
children = createElement(Placeholder, null, createElement(Spinner, null));
|
|
98
93
|
}
|
|
99
94
|
return createElement(RecursionProvider, {
|
|
100
95
|
uniqueId: ref
|
|
101
96
|
}, createElement(InspectorControls, null, createElement(PanelBody, null, createElement(TextControl, {
|
|
102
|
-
__nextHasNoMarginBottom: true,
|
|
103
97
|
label: __('Name'),
|
|
104
98
|
value: title,
|
|
105
|
-
onChange: setTitle
|
|
106
|
-
|
|
99
|
+
onChange: setTitle,
|
|
100
|
+
__nextHasNoMarginBottom: true,
|
|
101
|
+
__next40pxDefaultSize: true
|
|
102
|
+
}))), children === null ? createElement("div", {
|
|
107
103
|
...innerBlocksProps
|
|
108
|
-
})
|
|
104
|
+
}) : createElement("div", {
|
|
105
|
+
...blockProps
|
|
106
|
+
}, children));
|
|
109
107
|
}
|
|
110
108
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useEntityBlockEditor","useEntityProp","useEntityRecord","Placeholder","Spinner","TextControl","PanelBody","__","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","InspectorControls","useBlockProps","Warning","privateApis","blockEditorPrivateApis","useRef","useMemo","unlock","useLayoutClasses","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","some","block","includes","attributes","align","layout","ReusableBlockEdit","name","ref","__unstableParentLayout","hasAlreadyRendered","record","hasResolved","isMissing","onInput","onChange","id","title","setTitle","layoutClasses","blockProps","className","innerBlocksProps","value","renderAppender","ButtonBlockAppender","createElement","uniqueId","__nextHasNoMarginBottom","
|
|
1
|
+
{"version":3,"names":["classnames","useEntityBlockEditor","useEntityProp","useEntityRecord","Placeholder","Spinner","TextControl","PanelBody","__","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","InspectorControls","useBlockProps","Warning","privateApis","blockEditorPrivateApis","useRef","useMemo","unlock","useLayoutClasses","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","some","block","includes","attributes","align","layout","ReusableBlockEdit","name","ref","__unstableParentLayout","hasAlreadyRendered","record","hasResolved","isMissing","onInput","onChange","id","title","setTitle","layoutClasses","blockProps","className","innerBlocksProps","value","renderAppender","ButtonBlockAppender","children","createElement","uniqueId","label","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/block/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tuseEntityRecord,\n} from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tTextControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useRef, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref },\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_block',\n\t\t'title',\n\t\tref\n\t);\n\n\tconst { alignment, layout } = useInferredLayout( blocks, parentLayout );\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tvalue: blocks,\n\t\tlayout,\n\t\tonInput,\n\t\tonChange,\n\t\trenderAppender: blocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\tlet children = null;\n\tif ( hasAlreadyRendered ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\tchildren = (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ children === null ? (\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t) : (\n\t\t\t\t<div { ...blockProps }>{ children }</div>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,QACT,sBAAsB;AAC7B,SACCC,WAAW,EACXC,OAAO,EACPC,WAAW,EACXC,SAAS,QACH,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,mBAAmB,EACnBC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,EAChDC,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,OAAO,EACPC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,MAAM,EAAEC,OAAO,QAAQ,oBAAoB;;AAEpD;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAM;EAAEC;AAAiB,CAAC,GAAGD,MAAM,CAAEH,sBAAuB,CAAC;AAC7D,MAAMK,cAAc,GAAG,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAE;AAE1D,MAAMC,iBAAiB,GAAGA,CAAEC,MAAM,EAAEC,YAAY,KAAM;EACrD,MAAMC,2BAA2B,GAAGR,MAAM,CAAC,CAAC;EAE5C,OAAOC,OAAO,CAAE,MAAM;IACrB;IACA,IAAK,CAAEK,MAAM,EAAEG,MAAM,EAAG;MACvB,OAAO,CAAC,CAAC;IACV;IAEA,IAAIC,SAAS,GAAGF,2BAA2B,CAACG,OAAO;;IAEnD;IACA;IACA,IAAKD,SAAS,KAAKE,SAAS,EAAG;MAC9B,MAAMC,aAAa,GAAGN,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,8 +42,7 @@ export default function ReusableBlockEdit({
|
|
|
42
42
|
const {
|
|
43
43
|
hasResolved,
|
|
44
44
|
isEditing,
|
|
45
|
-
isMissing
|
|
46
|
-
innerBlockCount
|
|
45
|
+
isMissing
|
|
47
46
|
} = useSelect(select => {
|
|
48
47
|
const persistedBlock = select(coreStore).getEntityRecord('postType', 'wp_block', ref);
|
|
49
48
|
const hasResolvedBlock = select(coreStore).hasFinishedResolution('getEntityRecord', ['postType', 'wp_block', ref]);
|
|
@@ -104,8 +103,8 @@ export default function ReusableBlockEdit({
|
|
|
104
103
|
style: [infoTextStyle, infoTitleStyle]
|
|
105
104
|
}, infoTitle), createElement(Text, {
|
|
106
105
|
style: [infoTextStyle, infoDescriptionStyle]
|
|
107
|
-
},
|
|
108
|
-
label:
|
|
106
|
+
}, __('Alternatively, you can detach and edit this block separately by tapping “Detach”.')), createElement(TextControl, {
|
|
107
|
+
label: __('Detach'),
|
|
109
108
|
separatorType: "topFullWidth",
|
|
110
109
|
onPress: onConvertToRegularBlocks,
|
|
111
110
|
labelStyle: actionButtonStyle
|