@wordpress/block-library 8.17.0 → 8.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +19 -0
- package/build/cover/edit/index.js +3 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/shared.js +26 -21
- package/build/cover/shared.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +0 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/footnotes/init.js +13 -0
- package/build/footnotes/init.js.map +1 -0
- package/build/list/edit.js +2 -1
- package/build/list/edit.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +2 -1
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/query/edit/inspector-controls/index.js +28 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -1
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +9 -2
- package/build/query/index.js.map +1 -1
- package/build/query/view.js +75 -0
- package/build/query/view.js.map +1 -0
- package/build/query-pagination-next/index.js +1 -1
- package/build/query-pagination-numbers/edit.js +50 -5
- package/build/query-pagination-numbers/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +7 -1
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/query-pagination-previous/index.js +1 -1
- package/build/quote/edit.js +2 -1
- package/build/quote/edit.js.map +1 -1
- package/build/search/edit.js +3 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/utils.js +2 -4
- package/build/search/utils.js.map +1 -1
- package/build/social-link/edit.native.js +1 -3
- package/build/social-link/edit.native.js.map +1 -1
- package/build/template-part/edit/index.js +22 -15
- package/build/template-part/edit/index.js.map +1 -1
- package/build-module/cover/edit/index.js +3 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/shared.js +26 -21
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +0 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/footnotes/init.js +6 -0
- package/build-module/footnotes/init.js.map +1 -0
- package/build-module/list/edit.js +2 -1
- package/build-module/list/edit.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +2 -1
- package/build-module/navigation/edit/inner-blocks.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-template/index.js +1 -1
- package/build-module/query/edit/inspector-controls/index.js +29 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -1
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +9 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/view.js +72 -0
- package/build-module/query/view.js.map +1 -0
- package/build-module/query-pagination-next/index.js +1 -1
- package/build-module/query-pagination-numbers/edit.js +51 -6
- package/build-module/query-pagination-numbers/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +7 -1
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/query-pagination-previous/index.js +1 -1
- package/build-module/quote/edit.js +2 -1
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/search/edit.js +4 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/utils.js +0 -1
- package/build-module/search/utils.js.map +1 -1
- package/build-module/social-link/edit.native.js +1 -3
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/template-part/edit/index.js +22 -15
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-style/editor-rtl.css +2 -1
- package/build-style/editor.css +2 -1
- package/build-style/query/style-rtl.css +140 -0
- package/build-style/query/style.css +140 -0
- package/build-style/site-logo/style-rtl.css +1 -0
- package/build-style/site-logo/style.css +1 -0
- package/build-style/social-links/editor-rtl.css +2 -1
- package/build-style/social-links/editor.css +2 -1
- package/build-style/style-rtl.css +1 -0
- package/build-style/style.css +1 -0
- package/package.json +32 -32
- package/src/audio/test/__snapshots__/edit.native.js.snap +106 -78
- package/src/cover/edit/index.js +3 -1
- package/src/cover/shared.js +25 -20
- package/src/cover/test/edit.native.js +1 -5
- package/src/embed/embed-link-settings.native.js +0 -1
- package/src/embed/test/index.native.js +9 -9
- package/src/file/test/__snapshots__/edit.native.js.snap +218 -162
- package/src/footnotes/init.js +6 -0
- package/src/image/index.php +5 -0
- package/src/list/edit.js +1 -0
- package/src/navigation/edit/inner-blocks.js +1 -0
- package/src/post-content/edit.js +2 -2
- package/src/post-content/index.php +0 -6
- package/src/post-featured-image/index.php +0 -6
- package/src/post-navigation-link/index.php +2 -2
- package/src/post-template/block.json +2 -1
- package/src/post-template/index.php +19 -4
- package/src/query/block.json +9 -2
- package/src/query/edit/inspector-controls/index.js +46 -3
- package/src/query/edit/query-content.js +1 -0
- package/src/query/index.php +94 -1
- package/src/query/style.scss +63 -0
- package/src/query/view.js +82 -0
- package/src/query-no-results/index.php +1 -5
- package/src/query-pagination-next/block.json +7 -1
- package/src/query-pagination-next/index.php +20 -3
- package/src/query-pagination-numbers/block.json +7 -1
- package/src/query-pagination-numbers/edit.js +64 -16
- package/src/query-pagination-numbers/index.php +27 -4
- package/src/query-pagination-previous/block.json +7 -1
- package/src/query-pagination-previous/index.php +19 -2
- package/src/quote/edit.js +1 -0
- package/src/search/edit.js +8 -2
- package/src/search/test/__snapshots__/edit.native.js.snap +363 -265
- package/src/search/utils.js +0 -1
- package/src/site-logo/style.scss +1 -0
- package/src/social-link/edit.native.js +1 -1
- package/src/social-link/editor.native.scss +0 -4
- package/src/social-links/editor.scss +2 -1
- package/src/social-links/test/edit.native.js +30 -0
- package/src/template-part/edit/index.js +35 -22
- package/tsconfig.tsbuildinfo +1 -1
- package/src/social-link/test/index.native.js +0 -132
|
@@ -155,27 +155,32 @@ function retrieveFastAverageColor() {
|
|
|
155
155
|
export async function getCoverIsDark(url, dimRatio = 50, overlayColor) {
|
|
156
156
|
const overlay = colord(overlayColor).alpha(dimRatio / 100).toRgb();
|
|
157
157
|
if (url) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
158
|
+
try {
|
|
159
|
+
const imgCrossOrigin = applyFilters('media.crossOrigin', undefined, url);
|
|
160
|
+
const {
|
|
161
|
+
value: [r, g, b, a]
|
|
162
|
+
} = await retrieveFastAverageColor().getColorAsync(url, {
|
|
163
|
+
// Previously the default color was white, but that changed
|
|
164
|
+
// in v6.0.0 so it has to be manually set now.
|
|
165
|
+
defaultColor: [255, 255, 255, 255],
|
|
166
|
+
// Errors that come up don't reject the promise, so error
|
|
167
|
+
// logging has to be silenced with this option.
|
|
168
|
+
silent: process.env.NODE_ENV === 'production',
|
|
169
|
+
crossOrigin: imgCrossOrigin
|
|
170
|
+
});
|
|
171
|
+
// FAC uses 0-255 for alpha, but colord expects 0-1.
|
|
172
|
+
const media = {
|
|
173
|
+
r,
|
|
174
|
+
g,
|
|
175
|
+
b,
|
|
176
|
+
a: a / 255
|
|
177
|
+
};
|
|
178
|
+
const composite = compositeSourceOver(overlay, media);
|
|
179
|
+
return colord(composite).isDark();
|
|
180
|
+
} catch (error) {
|
|
181
|
+
// If there's an error, just assume the image is dark.
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
179
184
|
}
|
|
180
185
|
|
|
181
186
|
// Assume a white background because it isn't easy to get the actual
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FastAverageColor","colord","getBlobTypeByURL","isBlobURL","applyFilters","POSITION_CLASSNAMES","center","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","DEFAULT_FOCAL_POINT","x","y","ALLOWED_MEDIA_TYPES","mediaPosition","Math","round","dimRatioToClass","ratio","undefined","attributesFromMedia","setAttributes","dimRatio","media","isDark","url","id","type","mediaType","media_type","alt","backgroundType","focalPoint","hasParallax","isContentPositionCenter","contentPosition","getPositionClassName","compositeSourceOver","source","dest","r","a","g","b","retrieveFastAverageColor","fastAverageColor","getCoverIsDark","overlayColor","overlay","alpha","toRgb","imgCrossOrigin","value","getColorAsync","defaultColor","silent","process","env","NODE_ENV","crossOrigin","composite","background"],"sources":["@wordpress/block-library/src/cover/shared.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FastAverageColor } from 'fast-average-color';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\nimport { applyFilters } from '@wordpress/hooks';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ! ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( setAttributes, dimRatio ) {\n\treturn ( media, isDark ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( { url: undefined, id: undefined, isDark } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tmedia.type = getBlobTypeByURL( media.url );\n\t\t}\n\n\t\tlet mediaType;\n\t\t// For media selections originated from a file upload.\n\t\tif ( media.media_type ) {\n\t\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t\t} else {\n\t\t\t\t// only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t\t}\n\t\t} else {\n\t\t\t// For media selections originated from existing files in the media library.\n\t\t\tif (\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE &&\n\t\t\t\tmedia.type !== VIDEO_BACKGROUND_TYPE\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmediaType = media.type;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tisDark,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\turl: media.url,\n\t\t\tid: media.id,\n\t\t\talt: media?.alt,\n\t\t\tbackgroundType: mediaType,\n\t\t\tfocalPoint: undefined,\n\t\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t\t? { hasParallax: undefined }\n\t\t\t\t: {} ),\n\t\t} );\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) return '';\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n\n/**\n * Performs a Porter Duff composite source over operation on two rgba colors.\n *\n * @see https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_srcover\n *\n * @param {import('colord').RgbaColor} source Source color.\n * @param {import('colord').RgbaColor} dest Destination color.\n * @return {import('colord').RgbaColor} Composite color.\n */\nfunction compositeSourceOver( source, dest ) {\n\treturn {\n\t\tr: source.r * source.a + dest.r * dest.a * ( 1 - source.a ),\n\t\tg: source.g * source.a + dest.g * dest.a * ( 1 - source.a ),\n\t\tb: source.b * source.a + dest.b * dest.a * ( 1 - source.a ),\n\t\ta: source.a + dest.a * ( 1 - source.a ),\n\t};\n}\n\nfunction retrieveFastAverageColor() {\n\tif ( ! retrieveFastAverageColor.fastAverageColor ) {\n\t\tretrieveFastAverageColor.fastAverageColor = new FastAverageColor();\n\t}\n\treturn retrieveFastAverageColor.fastAverageColor;\n}\n\n/**\n * This method evaluates if the cover block's background is dark or not and this boolean\n * can then be applied to the relevant attribute to help ensure that text is visible by default.\n * This needs to be recalculated in all of the following Cover block scenarios:\n * - When an overlay image is added, changed or removed\n * - When the featured image is selected as the overlay image, or removed from the overlay\n * - When the overlay color is changed\n * - When the overlay color is removed\n * - When the dimRatio is changed\n *\n * See the comments below for more details about which aspects take priority when\n * calculating the relative darkness of the Cover.\n *\n * @param {string} url\n * @param {number} dimRatio\n * @param {string} overlayColor\n * @return {Promise<boolean>} True if cover should be considered to be dark.\n */\nexport async function getCoverIsDark( url, dimRatio = 50, overlayColor ) {\n\tconst overlay = colord( overlayColor )\n\t\t.alpha( dimRatio / 100 )\n\t\t.toRgb();\n\n\tif ( url ) {\n\t\tconst imgCrossOrigin = applyFilters(\n\t\t\t'media.crossOrigin',\n\t\t\tundefined,\n\t\t\turl\n\t\t);\n\t\tconst {\n\t\t\tvalue: [ r, g, b, a ],\n\t\t} = await retrieveFastAverageColor().getColorAsync( url, {\n\t\t\t// Previously the default color was white, but that changed\n\t\t\t// in v6.0.0 so it has to be manually set now.\n\t\t\tdefaultColor: [ 255, 255, 255, 255 ],\n\t\t\t// Errors that come up don't reject the promise, so error\n\t\t\t// logging has to be silenced with this option.\n\t\t\tsilent: process.env.NODE_ENV === 'production',\n\t\t\tcrossOrigin: imgCrossOrigin,\n\t\t} );\n\t\t// FAC uses 0-255 for alpha, but colord expects 0-1.\n\t\tconst media = { r, g, b, a: a / 255 };\n\t\tconst composite = compositeSourceOver( overlay, media );\n\t\treturn colord( composite ).isDark();\n\t}\n\n\t// Assume a white background because it isn't easy to get the actual\n\t// parent background color.\n\tconst background = { r: 255, g: 255, b: 255, a: 1 };\n\tconst composite = compositeSourceOver( overlay, background );\n\treturn colord( composite ).isDark();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,iBAAiB;AAC7D,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,MAAMC,mBAAmB,GAAG;EAC3B,UAAU,EAAE,sBAAsB;EAClC,YAAY,EAAE,wBAAwB;EACtC,WAAW,EAAE,uBAAuB;EACpC,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5CC,MAAM,EAAE,2BAA2B;EACnC,cAAc,EAAE,0BAA0B;EAC1C,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5C,cAAc,EAAE;AACjB,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG,OAAO;AAC5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EAAEF,CAAC;IACpB,CAAC,GAAG,MAAMG,wBAAwB,CAAC,CAAC,CAACS,aAAa,CAAE5B,GAAG,EAAE;MACxD;MACA;MACA6B,YAAY,EAAE,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;MACpC;MACA;MACAC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;MAC7CC,WAAW,EAAER;IACd,CAAE,CAAC;IACH;IACA,MAAM5B,KAAK,GAAG;MAAEiB,CAAC;MAAEE,CAAC;MAAEC,CAAC;MAAEF,CAAC,EAAEA,CAAC,GAAG;IAAI,CAAC;IACrC,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEzB,KAAM,CAAC;IACvD,OAAOxB,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;EACpC;;EAEA;EACA;EACA,MAAMqC,UAAU,GAAG;IAAErB,CAAC,EAAE,GAAG;IAAEE,CAAC,EAAE,GAAG;IAAEC,CAAC,EAAE,GAAG;IAAEF,CAAC,EAAE;EAAE,CAAC;EACnD,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEa,UAAW,CAAC;EAC5D,OAAO9D,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;AACpC"}
|
|
1
|
+
{"version":3,"names":["FastAverageColor","colord","getBlobTypeByURL","isBlobURL","applyFilters","POSITION_CLASSNAMES","center","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","DEFAULT_FOCAL_POINT","x","y","ALLOWED_MEDIA_TYPES","mediaPosition","Math","round","dimRatioToClass","ratio","undefined","attributesFromMedia","setAttributes","dimRatio","media","isDark","url","id","type","mediaType","media_type","alt","backgroundType","focalPoint","hasParallax","isContentPositionCenter","contentPosition","getPositionClassName","compositeSourceOver","source","dest","r","a","g","b","retrieveFastAverageColor","fastAverageColor","getCoverIsDark","overlayColor","overlay","alpha","toRgb","imgCrossOrigin","value","getColorAsync","defaultColor","silent","process","env","NODE_ENV","crossOrigin","composite","error","background"],"sources":["@wordpress/block-library/src/cover/shared.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { FastAverageColor } from 'fast-average-color';\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobTypeByURL, isBlobURL } from '@wordpress/blob';\nimport { applyFilters } from '@wordpress/hooks';\n\nconst POSITION_CLASSNAMES = {\n\t'top left': 'is-position-top-left',\n\t'top center': 'is-position-top-center',\n\t'top right': 'is-position-top-right',\n\t'center left': 'is-position-center-left',\n\t'center center': 'is-position-center-center',\n\tcenter: 'is-position-center-center',\n\t'center right': 'is-position-center-right',\n\t'bottom left': 'is-position-bottom-left',\n\t'bottom center': 'is-position-bottom-center',\n\t'bottom right': 'is-position-bottom-right',\n};\n\nexport const IMAGE_BACKGROUND_TYPE = 'image';\nexport const VIDEO_BACKGROUND_TYPE = 'video';\nexport const COVER_MIN_HEIGHT = 50;\nexport const COVER_MAX_HEIGHT = 1000;\nexport const COVER_DEFAULT_HEIGHT = 300;\nexport const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };\nexport const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];\n\nexport function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {\n\treturn `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;\n}\n\nexport function dimRatioToClass( ratio ) {\n\treturn ratio === 50 || ! ratio === undefined\n\t\t? null\n\t\t: 'has-background-dim-' + 10 * Math.round( ratio / 10 );\n}\n\nexport function attributesFromMedia( setAttributes, dimRatio ) {\n\treturn ( media, isDark ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( { url: undefined, id: undefined, isDark } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tmedia.type = getBlobTypeByURL( media.url );\n\t\t}\n\n\t\tlet mediaType;\n\t\t// For media selections originated from a file upload.\n\t\tif ( media.media_type ) {\n\t\t\tif ( media.media_type === IMAGE_BACKGROUND_TYPE ) {\n\t\t\t\tmediaType = IMAGE_BACKGROUND_TYPE;\n\t\t\t} else {\n\t\t\t\t// only images and videos are accepted so if the media_type is not an image we can assume it is a video.\n\t\t\t\t// Videos contain the media type of 'file' in the object returned from the rest api.\n\t\t\t\tmediaType = VIDEO_BACKGROUND_TYPE;\n\t\t\t}\n\t\t} else {\n\t\t\t// For media selections originated from existing files in the media library.\n\t\t\tif (\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE &&\n\t\t\t\tmedia.type !== VIDEO_BACKGROUND_TYPE\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmediaType = media.type;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tisDark,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\turl: media.url,\n\t\t\tid: media.id,\n\t\t\talt: media?.alt,\n\t\t\tbackgroundType: mediaType,\n\t\t\tfocalPoint: undefined,\n\t\t\t...( mediaType === VIDEO_BACKGROUND_TYPE\n\t\t\t\t? { hasParallax: undefined }\n\t\t\t\t: {} ),\n\t\t} );\n\t};\n}\n\n/**\n * Checks of the contentPosition is the center (default) position.\n *\n * @param {string} contentPosition The current content position.\n * @return {boolean} Whether the contentPosition is center.\n */\nexport function isContentPositionCenter( contentPosition ) {\n\treturn (\n\t\t! contentPosition ||\n\t\tcontentPosition === 'center center' ||\n\t\tcontentPosition === 'center'\n\t);\n}\n\n/**\n * Retrieves the className for the current contentPosition.\n * The default position (center) will not have a className.\n *\n * @param {string} contentPosition The current content position.\n * @return {string} The className assigned to the contentPosition.\n */\nexport function getPositionClassName( contentPosition ) {\n\t/*\n\t * Only render a className if the contentPosition is not center (the default).\n\t */\n\tif ( isContentPositionCenter( contentPosition ) ) return '';\n\n\treturn POSITION_CLASSNAMES[ contentPosition ];\n}\n\n/**\n * Performs a Porter Duff composite source over operation on two rgba colors.\n *\n * @see https://www.w3.org/TR/compositing-1/#porterduffcompositingoperators_srcover\n *\n * @param {import('colord').RgbaColor} source Source color.\n * @param {import('colord').RgbaColor} dest Destination color.\n * @return {import('colord').RgbaColor} Composite color.\n */\nfunction compositeSourceOver( source, dest ) {\n\treturn {\n\t\tr: source.r * source.a + dest.r * dest.a * ( 1 - source.a ),\n\t\tg: source.g * source.a + dest.g * dest.a * ( 1 - source.a ),\n\t\tb: source.b * source.a + dest.b * dest.a * ( 1 - source.a ),\n\t\ta: source.a + dest.a * ( 1 - source.a ),\n\t};\n}\n\nfunction retrieveFastAverageColor() {\n\tif ( ! retrieveFastAverageColor.fastAverageColor ) {\n\t\tretrieveFastAverageColor.fastAverageColor = new FastAverageColor();\n\t}\n\treturn retrieveFastAverageColor.fastAverageColor;\n}\n\n/**\n * This method evaluates if the cover block's background is dark or not and this boolean\n * can then be applied to the relevant attribute to help ensure that text is visible by default.\n * This needs to be recalculated in all of the following Cover block scenarios:\n * - When an overlay image is added, changed or removed\n * - When the featured image is selected as the overlay image, or removed from the overlay\n * - When the overlay color is changed\n * - When the overlay color is removed\n * - When the dimRatio is changed\n *\n * See the comments below for more details about which aspects take priority when\n * calculating the relative darkness of the Cover.\n *\n * @param {string} url\n * @param {number} dimRatio\n * @param {string} overlayColor\n * @return {Promise<boolean>} True if cover should be considered to be dark.\n */\nexport async function getCoverIsDark( url, dimRatio = 50, overlayColor ) {\n\tconst overlay = colord( overlayColor )\n\t\t.alpha( dimRatio / 100 )\n\t\t.toRgb();\n\n\tif ( url ) {\n\t\ttry {\n\t\t\tconst imgCrossOrigin = applyFilters(\n\t\t\t\t'media.crossOrigin',\n\t\t\t\tundefined,\n\t\t\t\turl\n\t\t\t);\n\t\t\tconst {\n\t\t\t\tvalue: [ r, g, b, a ],\n\t\t\t} = await retrieveFastAverageColor().getColorAsync( url, {\n\t\t\t\t// Previously the default color was white, but that changed\n\t\t\t\t// in v6.0.0 so it has to be manually set now.\n\t\t\t\tdefaultColor: [ 255, 255, 255, 255 ],\n\t\t\t\t// Errors that come up don't reject the promise, so error\n\t\t\t\t// logging has to be silenced with this option.\n\t\t\t\tsilent: process.env.NODE_ENV === 'production',\n\t\t\t\tcrossOrigin: imgCrossOrigin,\n\t\t\t} );\n\t\t\t// FAC uses 0-255 for alpha, but colord expects 0-1.\n\t\t\tconst media = { r, g, b, a: a / 255 };\n\t\t\tconst composite = compositeSourceOver( overlay, media );\n\t\t\treturn colord( composite ).isDark();\n\t\t} catch ( error ) {\n\t\t\t// If there's an error, just assume the image is dark.\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Assume a white background because it isn't easy to get the actual\n\t// parent background color.\n\tconst background = { r: 255, g: 255, b: 255, a: 1 };\n\tconst composite = compositeSourceOver( overlay, background );\n\treturn colord( composite ).isDark();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,iBAAiB;AAC7D,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,MAAMC,mBAAmB,GAAG;EAC3B,UAAU,EAAE,sBAAsB;EAClC,YAAY,EAAE,wBAAwB;EACtC,WAAW,EAAE,uBAAuB;EACpC,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5CC,MAAM,EAAE,2BAA2B;EACnC,cAAc,EAAE,0BAA0B;EAC1C,aAAa,EAAE,yBAAyB;EACxC,eAAe,EAAE,2BAA2B;EAC5C,cAAc,EAAE;AACjB,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAG,OAAO;AAC5C,OAAO,MAAMC,qBAAqB,GAAG,OAAO;AAC5C,OAAO,MAAMC,gBAAgB,GAAG,EAAE;AAClC,OAAO,MAAMC,gBAAgB,GAAG,IAAI;AACpC,OAAO,MA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,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE;QACpC;QACA;QACAC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;QAC7CC,WAAW,EAAER;MACd,CAAE,CAAC;MACH;MACA,MAAM5B,KAAK,GAAG;QAAEiB,CAAC;QAAEE,CAAC;QAAEC,CAAC;QAAEF,CAAC,EAAEA,CAAC,GAAG;MAAI,CAAC;MACrC,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEzB,KAAM,CAAC;MACvD,OAAOxB,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,OAAQqC,KAAK,EAAG;MACjB;MACA,OAAO,IAAI;IACZ;EACD;;EAEA;EACA;EACA,MAAMC,UAAU,GAAG;IAAEtB,CAAC,EAAE,GAAG;IAAEE,CAAC,EAAE,GAAG;IAAEC,CAAC,EAAE,GAAG;IAAEF,CAAC,EAAE;EAAE,CAAC;EACnD,MAAMmB,SAAS,GAAGvB,mBAAmB,CAAEW,OAAO,EAAEc,UAAW,CAAC;EAC5D,OAAO/D,MAAM,CAAE6D,SAAU,CAAC,CAACpC,MAAM,CAAC,CAAC;AACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","LinkSettingsNavigation","FooterMessageLink","isURL","useDispatch","store","noticesStore","useCallback","useEffect","useRef","useState","EmbedLinkSettings","autoFocus","value","label","isVisible","onClose","onSubmit","withBottomSheet","url","inputURL","setInputURL","createErrorNotice","linkSettingsOptions","placeholder","autoFill","footer","createElement","href","separatorType","onDismiss","current","performOnCloseOperations","onSetAttributes","attributes","setAttributes","options","
|
|
1
|
+
{"version":3,"names":["__","sprintf","LinkSettingsNavigation","FooterMessageLink","isURL","useDispatch","store","noticesStore","useCallback","useEffect","useRef","useState","EmbedLinkSettings","autoFocus","value","label","isVisible","onClose","onSubmit","withBottomSheet","url","inputURL","setInputURL","createErrorNotice","linkSettingsOptions","placeholder","autoFill","footer","createElement","href","separatorType","onDismiss","current","performOnCloseOperations","onSetAttributes","attributes","setAttributes","options","showIcon"],"sources":["@wordpress/block-library/src/embed/embed-link-settings.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tLinkSettingsNavigation,\n\tFooterMessageLink,\n} from '@wordpress/components';\nimport { isURL } from '@wordpress/url';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\nconst EmbedLinkSettings = ( {\n\tautoFocus,\n\tvalue,\n\tlabel,\n\tisVisible,\n\tonClose,\n\tonSubmit,\n\twithBottomSheet,\n} ) => {\n\tconst url = useRef( value );\n\tconst [ inputURL, setInputURL ] = useState( value );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tconst linkSettingsOptions = {\n\t\turl: {\n\t\t\tlabel: sprintf(\n\t\t\t\t// translators: %s: embed block variant's label e.g: \"Twitter\".\n\t\t\t\t__( '%s link' ),\n\t\t\t\tlabel\n\t\t\t),\n\t\t\tplaceholder: __( 'Add link' ),\n\t\t\tautoFocus,\n\t\t\tautoFill: true,\n\t\t},\n\t\tfooter: {\n\t\t\tlabel: (\n\t\t\t\t<FooterMessageLink\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/embeds/'\n\t\t\t\t\t) }\n\t\t\t\t\tvalue={ __( 'Learn more about embeds' ) }\n\t\t\t\t/>\n\t\t\t),\n\t\t\tseparatorType: 'topFullWidth',\n\t\t},\n\t};\n\n\tconst onDismiss = useCallback( () => {\n\t\tif ( ! isURL( url.current ) && url.current !== '' ) {\n\t\t\tcreateErrorNotice( __( 'Invalid URL. Please enter a valid URL.' ) );\n\t\t\t// If the URL was already defined, we submit it to stop showing the embed placeholder.\n\t\t\tonSubmit( value );\n\t\t\treturn;\n\t\t}\n\t\tonSubmit( url.current );\n\t}, [ onSubmit, value ] );\n\n\tuseEffect( () => {\n\t\turl.current = value;\n\t\tsetInputURL( value );\n\t}, [ value ] );\n\n\t/**\n\t * If the Embed Bottom Sheet component does not utilize a bottom sheet then the onDismiss action is not\n\t * called. Here we are wiring the onDismiss to the onClose callback that gets triggered when input is submitted.\n\t */\n\tconst performOnCloseOperations = useCallback( () => {\n\t\tif ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\n\t\tif ( ! withBottomSheet ) {\n\t\t\tonDismiss();\n\t\t}\n\t}, [ onClose ] );\n\n\tconst onSetAttributes = useCallback( ( attributes ) => {\n\t\turl.current = attributes.url;\n\t\tsetInputURL( attributes.url );\n\t}, [] );\n\n\treturn (\n\t\t<LinkSettingsNavigation\n\t\t\tisVisible={ isVisible }\n\t\t\turl={ inputURL }\n\t\t\tonClose={ performOnCloseOperations }\n\t\t\tonDismiss={ onDismiss }\n\t\t\tsetAttributes={ onSetAttributes }\n\t\t\toptions={ linkSettingsOptions }\n\t\t\twithBottomSheet={ withBottomSheet }\n\t\t\tshowIcon\n\t\t/>\n\t);\n};\n\nexport default EmbedLinkSettings;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,sBAAsB,EACtBC,iBAAiB,QACX,uBAAuB;AAC9B,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAE7E,MAAMC,iBAAiB,GAAGA,CAAE;EAC3BC,SAAS;EACTC,KAAK;EACLC,KAAK;EACLC,SAAS;EACTC,OAAO;EACPC,QAAQ;EACRC;AACD,CAAC,KAAM;EACN,MAAMC,GAAG,GAAGV,MAAM,CAAEI,KAAM,CAAC;EAC3B,MAAM,CAAE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;EACD,CAAC,EAAE,CAAEd,OAAO,CAAG,CAAC;EAEhB,MAAMiB,eAAe,GAAG1B,WAAW,CAAI2B,UAAU,IAAM;IACtDf,GAAG,CAACY,OAAO,GAAGG,UAAU,CAACf,GAAG;IAC5BE,WAAW,CAAEa,UAAU,CAACf,GAAI,CAAC;EAC9B,CAAC,EAAE,EAAG,CAAC;EAEP,OACCQ,aAAA,CAAC1B,sBAAsB;IACtBc,SAAS,EAAGA,SAAW;IACvBI,GAAG,EAAGC,QAAU;IAChBJ,OAAO,EAAGgB,wBAA0B;IACpCF,SAAS,EAAGA,SAAW;IACvBK,aAAa,EAAGF,eAAiB;IACjCG,OAAO,EAAGb,mBAAqB;IAC/BL,eAAe,EAAGA,eAAiB;IACnCmB,QAAQ;EAAA,CACR,CAAC;AAEJ,CAAC;AAED,eAAe1B,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["init"],"sources":["@wordpress/block-library/src/footnotes/init.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { init } from './';\n\nexport default init();\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,IAAI;AAEzB,eAAeA,IAAI,CAAC,CAAC"}
|
|
@@ -121,7 +121,8 @@ export default function Edit({
|
|
|
121
121
|
marginVertical: NATIVE_MARGIN_SPACING,
|
|
122
122
|
marginHorizontal: NATIVE_MARGIN_SPACING,
|
|
123
123
|
renderAppender: false
|
|
124
|
-
})
|
|
124
|
+
}),
|
|
125
|
+
__experimentalCaptureToolbars: true
|
|
125
126
|
});
|
|
126
127
|
useMigrateOnLoad(attributes, clientId);
|
|
127
128
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","ToolbarButton","useDispatch","useSelect","useRegistry","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","formatOutdent","formatOutdentRTL","createBlock","useCallback","useEffect","Platform","deprecated","OrderedListSettings","migrateToListV2","TagName","TEMPLATE","NATIVE_MARGIN_SPACING","useMigrateOnLoad","attributes","clientId","registry","updateBlockAttributes","replaceInnerBlocks","values","newAttributes","newInnerBlocks","since","version","alternative","batch","useOutdentList","canOutdent","innerSelect","getBlockRootClientId","getBlock","parentId","name","replaceBlocks","selectionChange","getBlockAttributes","parentBlockId","parentBlockAttributes","newParentBlock","innerBlocks","length","IndentUI","outdentList","createElement","Fragment","icon","title","describedBy","disabled","onClick","Edit","setAttributes","style","blockProps","isNative","innerBlocksProps","allowedBlocks","template","templateLock","templateInsertUpdatesSelection","marginVertical","marginHorizontal","renderAppender","ordered","type","reversed","start","controls","group","isActive"],"sources":["@wordpress/block-library/src/list/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n\tformatOutdent,\n\tformatOutdentRTL,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback, useEffect, Platform } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from './ordered-list-settings';\nimport { migrateToListV2 } from './utils';\nimport TagName from './tag-name';\n\nconst TEMPLATE = [ [ 'core/list-item' ] ];\nconst NATIVE_MARGIN_SPACING = 8;\n\n/**\n * At the moment, deprecations don't handle create blocks from attributes\n * (like when using CPT templates). For this reason, this hook is necessary\n * to avoid breaking templates using the old list block format.\n *\n * @param {Object} attributes Block attributes.\n * @param {string} clientId Block client ID.\n */\nfunction useMigrateOnLoad( attributes, clientId ) {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// As soon as the block is loaded, migrate it to the new version.\n\n\t\tif ( ! attributes.values ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );\n\n\t\tdeprecated( 'Value attribute on the list block', {\n\t\t\tsince: '6.0',\n\t\t\tversion: '6.5',\n\t\t\talternative: 'inner blocks',\n\t\t} );\n\n\t\tregistry.batch( () => {\n\t\t\tupdateBlockAttributes( clientId, newAttributes );\n\t\t\treplaceInnerBlocks( clientId, newInnerBlocks );\n\t\t} );\n\t}, [ attributes.values ] );\n}\n\nfunction useOutdentList( clientId ) {\n\tconst { canOutdent } = useSelect(\n\t\t( innerSelect ) => {\n\t\t\tconst { getBlockRootClientId, getBlock } =\n\t\t\t\tinnerSelect( blockEditorStore );\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tcanOutdent:\n\t\t\t\t\t!! parentId &&\n\t\t\t\t\tgetBlock( parentId ).name === 'core/list-item',\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockAttributes, getBlock } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn [\n\t\tcanOutdent,\n\t\tuseCallback( () => {\n\t\t\tconst parentBlockId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockAttributes = getBlockAttributes( parentBlockId );\n\t\t\t// Create a new parent block without the inner blocks.\n\t\t\tconst newParentBlock = createBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\tparentBlockAttributes\n\t\t\t);\n\t\t\tconst { innerBlocks } = getBlock( clientId );\n\t\t\t// Replace the parent block with a new parent block without inner blocks,\n\t\t\t// and make the inner blocks siblings of the parent.\n\t\t\treplaceBlocks(\n\t\t\t\t[ parentBlockId ],\n\t\t\t\t[ newParentBlock, ...innerBlocks ]\n\t\t\t);\n\t\t\t// Select the last child of the list being outdent.\n\t\t\tselectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );\n\t\t}, [ clientId ] ),\n\t];\n}\n\nfunction IndentUI( { clientId } ) {\n\tconst [ canOutdent, outdentList ] = useOutdentList( clientId );\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentList }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function Edit( { attributes, setAttributes, clientId, style } ) {\n\tconst blockProps = useBlockProps( {\n\t\t...( Platform.isNative && { style } ),\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list-item' ],\n\t\ttemplate: TEMPLATE,\n\t\ttemplateLock: false,\n\t\ttemplateInsertUpdatesSelection: true,\n\t\t...( Platform.isNative && {\n\t\t\tmarginVertical: NATIVE_MARGIN_SPACING,\n\t\t\tmarginHorizontal: NATIVE_MARGIN_SPACING,\n\t\t\trenderAppender: false,\n\t\t} ),\n\t} );\n\tuseMigrateOnLoad( attributes, clientId );\n\tconst { ordered, type, reversed, start } = attributes;\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<IndentUI clientId={ clientId } />\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\tordered={ ordered }\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\ttype={ type }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\t\t\t\t<OrderedListSettings\n\t\t\t\t\t{ ...{\n\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\treversed,\n\t\t\t\t\t\tstart,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,aAAa,EACbC,mBAAmB,EACnBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACrE,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;AAC3C,SACCC,iBAAiB,EACjBC,oBAAoB,EACpBC,kBAAkB,EAClBC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,QACV,kBAAkB;AACzB,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACrE,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,yBAAyB;AACzD,SAASC,eAAe,QAAQ,SAAS;AACzC,OAAOC,OAAO,MAAM,YAAY;AAEhC,MAAMC,QAAQ,GAA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IAC/CyE,QAAQ,EAAGN,OAAO,KAAK,IAAM;IAC7Bd,OAAO,EAAGA,CAAA,KAAM;MACfE,aAAa,CAAE;QAAEY,OAAO,EAAE;MAAK,CAAE,CAAC;IACnC;EAAG,CACH,CAAC,EACFpB,aAAA,CAACF,QAAQ;IAAC1B,QAAQ,EAAGA;EAAU,CAAE,CACnB,CACf;EAED,OACC4B,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACjC,OAAO;IACPqD,OAAO,EAAGA,OAAS;IACnBE,QAAQ,EAAGA,QAAU;IACrBC,KAAK,EAAGA,KAAO;IACfF,IAAI,EAAGA,IAAM;IAAA,GACRT;EAAgB,CACrB,CAAC,EACAY,QAAQ,EACRJ,OAAO,IACRpB,aAAA,CAACnC,mBAAmB;IAElB2C,aAAa;IACbc,QAAQ;IACRC,KAAK;IACLF;EAAI,CAEL,CAED,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["BlockControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","ToolbarButton","useDispatch","useSelect","useRegistry","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","formatOutdent","formatOutdentRTL","createBlock","useCallback","useEffect","Platform","deprecated","OrderedListSettings","migrateToListV2","TagName","TEMPLATE","NATIVE_MARGIN_SPACING","useMigrateOnLoad","attributes","clientId","registry","updateBlockAttributes","replaceInnerBlocks","values","newAttributes","newInnerBlocks","since","version","alternative","batch","useOutdentList","canOutdent","innerSelect","getBlockRootClientId","getBlock","parentId","name","replaceBlocks","selectionChange","getBlockAttributes","parentBlockId","parentBlockAttributes","newParentBlock","innerBlocks","length","IndentUI","outdentList","createElement","Fragment","icon","title","describedBy","disabled","onClick","Edit","setAttributes","style","blockProps","isNative","innerBlocksProps","allowedBlocks","template","templateLock","templateInsertUpdatesSelection","marginVertical","marginHorizontal","renderAppender","__experimentalCaptureToolbars","ordered","type","reversed","start","controls","group","isActive"],"sources":["@wordpress/block-library/src/list/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n\tformatOutdent,\n\tformatOutdentRTL,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback, useEffect, Platform } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from './ordered-list-settings';\nimport { migrateToListV2 } from './utils';\nimport TagName from './tag-name';\n\nconst TEMPLATE = [ [ 'core/list-item' ] ];\nconst NATIVE_MARGIN_SPACING = 8;\n\n/**\n * At the moment, deprecations don't handle create blocks from attributes\n * (like when using CPT templates). For this reason, this hook is necessary\n * to avoid breaking templates using the old list block format.\n *\n * @param {Object} attributes Block attributes.\n * @param {string} clientId Block client ID.\n */\nfunction useMigrateOnLoad( attributes, clientId ) {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// As soon as the block is loaded, migrate it to the new version.\n\n\t\tif ( ! attributes.values ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );\n\n\t\tdeprecated( 'Value attribute on the list block', {\n\t\t\tsince: '6.0',\n\t\t\tversion: '6.5',\n\t\t\talternative: 'inner blocks',\n\t\t} );\n\n\t\tregistry.batch( () => {\n\t\t\tupdateBlockAttributes( clientId, newAttributes );\n\t\t\treplaceInnerBlocks( clientId, newInnerBlocks );\n\t\t} );\n\t}, [ attributes.values ] );\n}\n\nfunction useOutdentList( clientId ) {\n\tconst { canOutdent } = useSelect(\n\t\t( innerSelect ) => {\n\t\t\tconst { getBlockRootClientId, getBlock } =\n\t\t\t\tinnerSelect( blockEditorStore );\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tcanOutdent:\n\t\t\t\t\t!! parentId &&\n\t\t\t\t\tgetBlock( parentId ).name === 'core/list-item',\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockAttributes, getBlock } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn [\n\t\tcanOutdent,\n\t\tuseCallback( () => {\n\t\t\tconst parentBlockId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockAttributes = getBlockAttributes( parentBlockId );\n\t\t\t// Create a new parent block without the inner blocks.\n\t\t\tconst newParentBlock = createBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\tparentBlockAttributes\n\t\t\t);\n\t\t\tconst { innerBlocks } = getBlock( clientId );\n\t\t\t// Replace the parent block with a new parent block without inner blocks,\n\t\t\t// and make the inner blocks siblings of the parent.\n\t\t\treplaceBlocks(\n\t\t\t\t[ parentBlockId ],\n\t\t\t\t[ newParentBlock, ...innerBlocks ]\n\t\t\t);\n\t\t\t// Select the last child of the list being outdent.\n\t\t\tselectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );\n\t\t}, [ clientId ] ),\n\t];\n}\n\nfunction IndentUI( { clientId } ) {\n\tconst [ canOutdent, outdentList ] = useOutdentList( clientId );\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentList }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function Edit( { attributes, setAttributes, clientId, style } ) {\n\tconst blockProps = useBlockProps( {\n\t\t...( Platform.isNative && { style } ),\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list-item' ],\n\t\ttemplate: TEMPLATE,\n\t\ttemplateLock: false,\n\t\ttemplateInsertUpdatesSelection: true,\n\t\t...( Platform.isNative && {\n\t\t\tmarginVertical: NATIVE_MARGIN_SPACING,\n\t\t\tmarginHorizontal: NATIVE_MARGIN_SPACING,\n\t\t\trenderAppender: false,\n\t\t} ),\n\t\t__experimentalCaptureToolbars: true,\n\t} );\n\tuseMigrateOnLoad( attributes, clientId );\n\tconst { ordered, type, reversed, start } = attributes;\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<IndentUI clientId={ clientId } />\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\tordered={ ordered }\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\ttype={ type }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\t\t\t\t<OrderedListSettings\n\t\t\t\t\t{ ...{\n\t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a,QAAQ,EACRJ,OAAO,IACRrB,aAAA,CAACnC,mBAAmB;IAElB2C,aAAa;IACbe,QAAQ;IACRC,KAAK;IACLF;EAAI,CAEL,CAED,CAAC;AAEL"}
|
|
@@ -74,7 +74,8 @@ export default function NavigationInnerBlocks({
|
|
|
74
74
|
renderAppender: isSelected || isImmediateParentOfSelectedBlock && !selectedBlockHasChildren ||
|
|
75
75
|
// Show the appender while dragging to allow inserting element between item and the appender.
|
|
76
76
|
parentOrChildHasSelection ? InnerBlocks.ButtonBlockAppender : false,
|
|
77
|
-
placeholder: showPlaceholder ? placeholder : undefined
|
|
77
|
+
placeholder: showPlaceholder ? placeholder : undefined,
|
|
78
|
+
__experimentalCaptureToolbars: true
|
|
78
79
|
});
|
|
79
80
|
return createElement("div", {
|
|
80
81
|
...innerBlocksProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEntityBlockEditor","useInnerBlocksProps","InnerBlocks","store","blockEditorStore","useSelect","useMemo","PlaceholderPreview","DEFAULT_BLOCK","ALLOWED_BLOCKS","PRIORITIZED_INSERTER_BLOCKS","NavigationInnerBlocks","clientId","hasCustomPlaceholder","orientation","templateLock","isImmediateParentOfSelectedBlock","selectedBlockHasChildren","isSelected","select","getBlockCount","hasSelectedInnerBlock","getSelectedBlockClientId","selectedBlockId","blocks","onInput","onChange","shouldDirectInsert","every","name","parentOrChildHasSelection","placeholder","createElement","hasMenuItems","length","showPlaceholder","innerBlocksProps","className","value","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","renderAppender","ButtonBlockAppender","undefined"],"sources":["@wordpress/block-library/src/navigation/edit/inner-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tuseInnerBlocksProps,\n\tInnerBlocks,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PlaceholderPreview from './placeholder/placeholder-preview';\nimport {\n\tDEFAULT_BLOCK,\n\tALLOWED_BLOCKS,\n\tPRIORITIZED_INSERTER_BLOCKS,\n} from '../constants';\n\nexport default function NavigationInnerBlocks( {\n\tclientId,\n\thasCustomPlaceholder,\n\torientation,\n\ttemplateLock,\n} ) {\n\tconst {\n\t\tisImmediateParentOfSelectedBlock,\n\t\tselectedBlockHasChildren,\n\t\tisSelected,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\tselectedBlockHasChildren: !! getBlockCount( selectedBlockId ),\n\n\t\t\t\t// This prop is already available but computing it here ensures it's\n\t\t\t\t// fresh compared to isImmediateParentOfSelectedBlock.\n\t\t\t\tisSelected: selectedBlockId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation'\n\t);\n\n\tconst shouldDirectInsert = useMemo(\n\t\t() =>\n\t\t\tblocks.every(\n\t\t\t\t( { name } ) =>\n\t\t\t\t\tname === 'core/navigation-link' ||\n\t\t\t\t\tname === 'core/navigation-submenu' ||\n\t\t\t\t\tname === 'core/page-list'\n\t\t\t),\n\t\t[ blocks ]\n\t);\n\n\t// When the block is selected itself or has a top level item selected that\n\t// doesn't itself have children, show the standard appender. Else show no\n\t// appender.\n\tconst parentOrChildHasSelection =\n\t\tisSelected ||\n\t\t( isImmediateParentOfSelectedBlock && ! selectedBlockHasChildren );\n\n\tconst placeholder = useMemo( () => <PlaceholderPreview />, [] );\n\n\tconst hasMenuItems = !! blocks?.length;\n\n\t// If there is a `ref` attribute pointing to a `wp_navigation` but\n\t// that menu has no **items** (i.e. empty) then show a placeholder.\n\t// The block must also be selected else the placeholder will display\n\t// alongside the appender.\n\tconst showPlaceholder =\n\t\t! hasCustomPlaceholder && ! hasMenuItems && ! isSelected;\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-navigation__container',\n\t\t},\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\t\tprioritizedInserterBlocks: PRIORITIZED_INSERTER_BLOCKS,\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: shouldDirectInsert,\n\t\t\torientation,\n\t\t\ttemplateLock,\n\n\t\t\t// As an exception to other blocks which feature nesting, show\n\t\t\t// the block appender even when a child block is selected.\n\t\t\t// This should be a temporary fix, to be replaced by improvements to\n\t\t\t// the sibling inserter.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/37572.\n\t\t\trenderAppender:\n\t\t\t\tisSelected ||\n\t\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\t\tparentOrChildHasSelection\n\t\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t\t: false,\n\t\t\tplaceholder: showPlaceholder ? placeholder : undefined,\n\t\t}\n\t);\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,oBAAoB,QAAQ,sBAAsB;AAC3D,SACCC,mBAAmB,EACnBC,WAAW,EACXC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,OAAOC,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AMC,eAAe,GACpB,CAAEtB,oBAAoB,IAAI,CAAEoB,YAAY,IAAI,CAAEf,UAAU;EAEzD,MAAMkB,gBAAgB,GAAGnC,mBAAmB,CAC3C;IACCoC,SAAS,EAAE;EACZ,CAAC,EACD;IACCC,KAAK,EAAEd,MAAM;IACbC,OAAO;IACPC,QAAQ;IACRa,aAAa,EAAE9B,cAAc;IAC7B+B,yBAAyB,EAAE9B,2BAA2B;IACtD+B,YAAY,EAAEjC,aAAa;IAC3BkC,YAAY,EAAEf,kBAAkB;IAChCb,WAAW;IACXC,YAAY;IAEZ;IACA;IACA;IACA;IACA;IACA4B,cAAc,EACbzB,UAAU,IACRF,gCAAgC,IACjC,CAAEC,wBAA0B;IAC7B;IACAa,yBAAyB,GACtB5B,WAAW,CAAC0C,mBAAmB,GAC/B,KAAK;IACTb,WAAW,EAAEI,eAAe,GAAGJ,WAAW,GAAGc;
|
|
1
|
+
{"version":3,"names":["useEntityBlockEditor","useInnerBlocksProps","InnerBlocks","store","blockEditorStore","useSelect","useMemo","PlaceholderPreview","DEFAULT_BLOCK","ALLOWED_BLOCKS","PRIORITIZED_INSERTER_BLOCKS","NavigationInnerBlocks","clientId","hasCustomPlaceholder","orientation","templateLock","isImmediateParentOfSelectedBlock","selectedBlockHasChildren","isSelected","select","getBlockCount","hasSelectedInnerBlock","getSelectedBlockClientId","selectedBlockId","blocks","onInput","onChange","shouldDirectInsert","every","name","parentOrChildHasSelection","placeholder","createElement","hasMenuItems","length","showPlaceholder","innerBlocksProps","className","value","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","renderAppender","ButtonBlockAppender","undefined","__experimentalCaptureToolbars"],"sources":["@wordpress/block-library/src/navigation/edit/inner-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tuseInnerBlocksProps,\n\tInnerBlocks,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PlaceholderPreview from './placeholder/placeholder-preview';\nimport {\n\tDEFAULT_BLOCK,\n\tALLOWED_BLOCKS,\n\tPRIORITIZED_INSERTER_BLOCKS,\n} from '../constants';\n\nexport default function NavigationInnerBlocks( {\n\tclientId,\n\thasCustomPlaceholder,\n\torientation,\n\ttemplateLock,\n} ) {\n\tconst {\n\t\tisImmediateParentOfSelectedBlock,\n\t\tselectedBlockHasChildren,\n\t\tisSelected,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\tselectedBlockHasChildren: !! getBlockCount( selectedBlockId ),\n\n\t\t\t\t// This prop is already available but computing it here ensures it's\n\t\t\t\t// fresh compared to isImmediateParentOfSelectedBlock.\n\t\t\t\tisSelected: selectedBlockId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation'\n\t);\n\n\tconst shouldDirectInsert = useMemo(\n\t\t() =>\n\t\t\tblocks.every(\n\t\t\t\t( { name } ) =>\n\t\t\t\t\tname === 'core/navigation-link' ||\n\t\t\t\t\tname === 'core/navigation-submenu' ||\n\t\t\t\t\tname === 'core/page-list'\n\t\t\t),\n\t\t[ blocks ]\n\t);\n\n\t// When the block is selected itself or has a top level item selected that\n\t// doesn't itself have children, show the standard appender. Else show no\n\t// appender.\n\tconst parentOrChildHasSelection =\n\t\tisSelected ||\n\t\t( isImmediateParentOfSelectedBlock && ! selectedBlockHasChildren );\n\n\tconst placeholder = useMemo( () => <PlaceholderPreview />, [] );\n\n\tconst hasMenuItems = !! blocks?.length;\n\n\t// If there is a `ref` attribute pointing to a `wp_navigation` but\n\t// that menu has no **items** (i.e. empty) then show a placeholder.\n\t// The block must also be selected else the placeholder will display\n\t// alongside the appender.\n\tconst showPlaceholder =\n\t\t! hasCustomPlaceholder && ! hasMenuItems && ! isSelected;\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-navigation__container',\n\t\t},\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\t\tprioritizedInserterBlocks: PRIORITIZED_INSERTER_BLOCKS,\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: shouldDirectInsert,\n\t\t\torientation,\n\t\t\ttemplateLock,\n\n\t\t\t// As an exception to other blocks which feature nesting, show\n\t\t\t// the block appender even when a child block is selected.\n\t\t\t// This should be a temporary fix, to be replaced by improvements to\n\t\t\t// the sibling inserter.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/37572.\n\t\t\trenderAppender:\n\t\t\t\tisSelected ||\n\t\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\t\tparentOrChildHasSelection\n\t\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t\t: false,\n\t\t\tplaceholder: showPlaceholder ? placeholder : undefined,\n\t\t\t__experimentalCaptureToolbars: true,\n\t\t}\n\t);\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,oBAAoB,QAAQ,sBAAsB;AAC3D,SACCC,mBAAmB,EACnBC,WAAW,EACXC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,QAAQ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,YAAY,GAAG,CAAC,CAAET,MAAM,EAAEU,MAAM;;EAEtC;EACA;EACA;EACA;EACA,MAAMC,eAAe,GACpB,CAAEtB,oBAAoB,IAAI,CAAEoB,YAAY,IAAI,CAAEf,UAAU;EAEzD,MAAMkB,gBAAgB,GAAGnC,mBAAmB,CAC3C;IACCoC,SAAS,EAAE;EACZ,CAAC,EACD;IACCC,KAAK,EAAEd,MAAM;IACbC,OAAO;IACPC,QAAQ;IACRa,aAAa,EAAE9B,cAAc;IAC7B+B,yBAAyB,EAAE9B,2BAA2B;IACtD+B,YAAY,EAAEjC,aAAa;IAC3BkC,YAAY,EAAEf,kBAAkB;IAChCb,WAAW;IACXC,YAAY;IAEZ;IACA;IACA;IACA;IACA;IACA4B,cAAc,EACbzB,UAAU,IACRF,gCAAgC,IACjC,CAAEC,wBAA0B;IAC7B;IACAa,yBAAyB,GACtB5B,WAAW,CAAC0C,mBAAmB,GAC/B,KAAK;IACTb,WAAW,EAAEI,eAAe,GAAGJ,WAAW,GAAGc,SAAS;IACtDC,6BAA6B,EAAE;EAChC,CACD,CAAC;EAED,OAAOd,aAAA;IAAA,GAAUI;EAAgB,CAAI,CAAC;AACvC"}
|
|
@@ -83,7 +83,7 @@ function Placeholder({
|
|
|
83
83
|
});
|
|
84
84
|
return createElement("div", {
|
|
85
85
|
...blockProps
|
|
86
|
-
}, createElement("p", null, __('This is the
|
|
86
|
+
}, createElement("p", null, __('This is the Content block, it will display all the blocks in any single post or page.')), createElement("p", null, __('That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.')), createElement("p", null, __('If there are any Custom Post Types registered at your site, the Content block can display the contents of those entries as well.')));
|
|
87
87
|
}
|
|
88
88
|
function RecursionError() {
|
|
89
89
|
const blockProps = useBlockProps();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useBlockProps","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Warning","useEntityProp","useEntityBlockEditor","store","coreStore","useSelect","useCanEditEntity","ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","createElement","dangerouslySetInnerHTML","__html","rendered","EditableContent","context","blocks","onInput","onChange","id","entityRecord","select","getEntityRecord","hasInnerBlocks","raw","length","initialInnerBlocks","props","className","value","template","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","layoutClassNames","RecursionError","PostContentEdit","attributes","__unstableLayoutClassNames","contextPostId","contextPostType","layout","hasAlreadyRendered","uniqueId"],"sources":["@wordpress/block-library/src/post-content/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tWarning,\n} from '@wordpress/block-editor';\nimport {\n\tuseEntityProp,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { context = {} } ) {\n\tconst { postType, postId } = context;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst entityRecord = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst hasInnerBlocks = !! entityRecord?.content?.raw || blocks?.length;\n\n\tconst initialInnerBlocks = [ [ 'core/paragraph' ] ];\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplate: ! hasInnerBlocks ? initialInnerBlocks : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tif ( userCanEdit === undefined ) {\n\t\treturn null;\n\t}\n\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder( { layoutClassNames } ) {\n\tconst blockProps = useBlockProps( { className: layoutClassNames } );\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the
|
|
1
|
+
{"version":3,"names":["__","useBlockProps","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","Warning","useEntityProp","useEntityBlockEditor","store","coreStore","useSelect","useCanEditEntity","ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","createElement","dangerouslySetInnerHTML","__html","rendered","EditableContent","context","blocks","onInput","onChange","id","entityRecord","select","getEntityRecord","hasInnerBlocks","raw","length","initialInnerBlocks","props","className","value","template","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","layoutClassNames","RecursionError","PostContentEdit","attributes","__unstableLayoutClassNames","contextPostId","contextPostType","layout","hasAlreadyRendered","uniqueId"],"sources":["@wordpress/block-library/src/post-content/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tWarning,\n} from '@wordpress/block-editor';\nimport {\n\tuseEntityProp,\n\tuseEntityBlockEditor,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { context = {} } ) {\n\tconst { postType, postId } = context;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst entityRecord = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst hasInnerBlocks = !! entityRecord?.content?.raw || blocks?.length;\n\n\tconst initialInnerBlocks = [ [ 'core/paragraph' ] ];\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplate: ! hasInnerBlocks ? initialInnerBlocks : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tif ( userCanEdit === undefined ) {\n\t\treturn null;\n\t}\n\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder( { layoutClassNames } ) {\n\tconst blockProps = useBlockProps( { className: layoutClassNames } );\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( {\n\tcontext,\n\tattributes,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder layoutClassNames={ layoutClassNames } />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,mBAAmB,EACnBC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,EAChDC,OAAO,QACD,yBAAyB;AAChC,SACCC,aAAa,EACbC,oBAAoB,EACpBC,KAAK,IAAIC,SAAS,QACZ,sBAAsB;AAC7B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,gBAAgB;AAEjD,SAASC,eAAeA,CAAE;EAAEC,WAAW;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC7D,MAAM,IAAMC,OAAO,CAAE,GAAGV,aAAa,CACpC,UAAU,EACVQ,QAAQ,EACR,SAAS,EACTC,MACD,CAAC;EACD,MAAME,UAAU,GAAGlB,aAAa,CAAC,CAAC;EAClC,OAAOiB,OAAO,EAAEE,SAAS,IAAI,CAAEL,WAAW,GACzCM,aAAA;IAAA,GAAUF;EAAU,GACnBE,aAAA,CAACd,OAAO,QAAGP,EAAE,CAAE,qCAAsC,CAAY,CAC7D,CAAC,GAENqB,aAAA;IAAA,GACMF,UAAU;IACfG,uBAAuB,EAAG;MAAEC,MAAM,EAAEL,OAAO,EAAEM;IAAS;EAAG,CACpD,CACN;AACF;A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,CAAC8B,cAAc,MAAE,CAAC;EAC1B;EAEA,OACC9B,aAAA,CAACjB,iBAAiB;IAACuD,QAAQ,EAAGJ;EAAe,GAC1CA,aAAa,IAAIC,eAAe,GACjCnC,aAAA,CAACsB,OAAO;IAACjB,OAAO,EAAGA,OAAS;IAAC+B,MAAM,EAAGA;EAAQ,CAAE,CAAC,GAEjDpC,aAAA,CAAC4B,WAAW;IAACC,gBAAgB,EAAGA;EAAkB,CAAE,CAEnC,CAAC;AAEtB"}
|
|
@@ -16,7 +16,7 @@ const metadata = {
|
|
|
16
16
|
parent: ["core/query"],
|
|
17
17
|
description: "Contains the block elements used to render a post, like the title, date, featured image, content or excerpt, and more.",
|
|
18
18
|
textdomain: "default",
|
|
19
|
-
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug", "previewPostType"],
|
|
19
|
+
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug", "previewPostType", "enhancedPagination"],
|
|
20
20
|
supports: {
|
|
21
21
|
reusable: false,
|
|
22
22
|
html: false,
|
|
@@ -6,7 +6,8 @@ import { PanelBody, TextControl, SelectControl, RangeControl, ToggleControl, Not
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { InspectorControls, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
8
8
|
import { debounce } from '@wordpress/compose';
|
|
9
|
-
import { useEffect, useState, useCallback } from '@wordpress/element';
|
|
9
|
+
import { useEffect, useState, useCallback, useRef } from '@wordpress/element';
|
|
10
|
+
import { speak } from '@wordpress/a11y';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -26,11 +27,13 @@ export default function QueryInspectorControls(props) {
|
|
|
26
27
|
const {
|
|
27
28
|
attributes,
|
|
28
29
|
setQuery,
|
|
29
|
-
setDisplayLayout
|
|
30
|
+
setDisplayLayout,
|
|
31
|
+
setAttributes
|
|
30
32
|
} = props;
|
|
31
33
|
const {
|
|
32
34
|
query,
|
|
33
|
-
displayLayout
|
|
35
|
+
displayLayout,
|
|
36
|
+
enhancedPagination
|
|
34
37
|
} = attributes;
|
|
35
38
|
const {
|
|
36
39
|
order,
|
|
@@ -96,6 +99,14 @@ export default function QueryInspectorControls(props) {
|
|
|
96
99
|
const showAuthorControl = isControlAllowed(allowedControls, 'author');
|
|
97
100
|
const showSearchControl = isControlAllowed(allowedControls, 'search');
|
|
98
101
|
const showParentControl = isControlAllowed(allowedControls, 'parents') && isPostTypeHierarchical;
|
|
102
|
+
const enhancedPaginationNotice = __('Enhanced Pagination might cause interactive blocks within the Post Template to stop working. Disable it if you experience any issues.');
|
|
103
|
+
const isFirstRender = useRef(true); // Don't speak on first render.
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!isFirstRender.current && enhancedPagination) {
|
|
106
|
+
speak(enhancedPaginationNotice);
|
|
107
|
+
}
|
|
108
|
+
isFirstRender.current = false;
|
|
109
|
+
}, [enhancedPagination, enhancedPaginationNotice]);
|
|
99
110
|
const showFiltersPanel = showTaxControl || showAuthorControl || showSearchControl || showParentControl;
|
|
100
111
|
return createElement(Fragment, null, createElement(BlockInfo, null, createElement(CreateNewPostLink, {
|
|
101
112
|
...props
|
|
@@ -186,6 +197,20 @@ export default function QueryInspectorControls(props) {
|
|
|
186
197
|
parents: parents,
|
|
187
198
|
postType: postType,
|
|
188
199
|
onChange: setQuery
|
|
189
|
-
}))))
|
|
200
|
+
})))), createElement(InspectorControls, null, createElement(PanelBody, {
|
|
201
|
+
title: __('User Experience'),
|
|
202
|
+
initialOpen: false
|
|
203
|
+
}, createElement(ToggleControl, {
|
|
204
|
+
label: __('Enhanced pagination'),
|
|
205
|
+
help: __("Don't refresh the page when paginating to another page."),
|
|
206
|
+
checked: !!enhancedPagination,
|
|
207
|
+
onChange: value => setAttributes({
|
|
208
|
+
enhancedPagination: !!value
|
|
209
|
+
})
|
|
210
|
+
}), enhancedPagination && createElement("div", null, createElement(Notice, {
|
|
211
|
+
spokenMessage: null,
|
|
212
|
+
status: "warning",
|
|
213
|
+
isDismissible: false
|
|
214
|
+
}, enhancedPaginationNotice)))));
|
|
190
215
|
}
|
|
191
216
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PanelBody","TextControl","SelectControl","RangeControl","ToggleControl","Notice","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","InspectorControls","privateApis","blockEditorPrivateApis","debounce","useEffect","useState","useCallback","OrderControl","AuthorControl","ParentControl","TaxonomyControls","StickyControl","CreateNewPostLink","unlock","usePostTypes","useIsPostTypeHierarchical","useAllowedControls","isControlAllowed","useTaxonomies","BlockInfo","QueryInspectorControls","props","attributes","setQuery","setDisplayLayout","query","displayLayout","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomies","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","showOrderControl","showStickyControl","showSettingsPanel","showTaxControl","showAuthorControl","showSearchControl","showParentControl","showFiltersPanel","createElement","Fragment","title","__nextHasNoMarginBottom","label","help","checked","onChange","value","options","columns","min","max","Math","status","isDismissible","className","resetAll","hasValue","values","some","onDeselect"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport CreateNewPostLink from './create-new-post-link';\nimport { unlock } from '../../../lock-unlock';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n\tuseTaxonomies,\n} from '../../utils';\n\nconst { BlockInfo } = unlock( blockEditorPrivateApis );\n\nexport default function QueryInspectorControls( props ) {\n\tconst { attributes, setQuery, setDisplayLayout } = props;\n\tconst { query, displayLayout } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomies = useTaxonomies( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = false;\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\tconst showTaxControl =\n\t\t!! taxonomies?.length &&\n\t\tisControlAllowed( allowedControls, 'taxQuery' );\n\tconst showAuthorControl = isControlAllowed( allowedControls, 'author' );\n\tconst showSearchControl = isControlAllowed( allowedControls, 'search' );\n\tconst showParentControl =\n\t\tisControlAllowed( allowedControls, 'parents' ) &&\n\t\tisPostTypeHierarchical;\n\n\tconst showFiltersPanel =\n\t\tshowTaxControl ||\n\t\tshowAuthorControl ||\n\t\tshowSearchControl ||\n\t\tshowParentControl;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockInfo>\n\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t</BlockInfo>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\t\t\tcolumns: value,\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\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && showFiltersPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTaxControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\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\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showAuthorControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showSearchControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showParentControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,QAAQ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AEM,MAAM,EAAE;IAAG,CAAE;EAAG,GAE/C6C,aAAA,CAAClE,aAAa;IACb0E,KAAK,EAAGpD,SAAW;IACnBmD,QAAQ,EAAG1D;EAAU,CACrB,CACc,CAChB,EACCgD,iBAAiB,IAClBG,aAAA,CAAC5E,cAAc;IACd8F,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAElC,WAAa;IACjCoB,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBgG,UAAU,EAAGA,CAAA,KAAMpC,cAAc,CAAE,EAAG;EAAG,GAEzCe,aAAA,CAACpF,WAAW;IACXuF,uBAAuB;IACvBC,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBmF,KAAK,EAAGxB,WAAa;IACrBuB,QAAQ,EAAGtB;EAAgB,CAC3B,CACc,CAChB,EACCa,iBAAiB,IAClBE,aAAA,CAAC5E,cAAc;IACd8F,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAEzD,OAAO,EAAEqB,MAAQ;IACrCsB,KAAK,EAAG/E,EAAE,CAAE,SAAU,CAAG;IACzBgG,UAAU,EAAGA,CAAA,KAAMxE,QAAQ,CAAE;MAAEY,OAAO,EAAE;IAAG,CAAE;EAAG,GAEhDuC,aAAA,CAACjE,aAAa;IACb0B,OAAO,EAAGA,OAAS;IACnBJ,QAAQ,EAAGA,QAAU;IACrBkD,QAAQ,EAAG1D;EAAU,CACrB,CACc,CAEN,CACM,CAEnB,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["PanelBody","TextControl","SelectControl","RangeControl","ToggleControl","Notice","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","__","InspectorControls","privateApis","blockEditorPrivateApis","debounce","useEffect","useState","useCallback","useRef","speak","OrderControl","AuthorControl","ParentControl","TaxonomyControls","StickyControl","CreateNewPostLink","unlock","usePostTypes","useIsPostTypeHierarchical","useAllowedControls","isControlAllowed","useTaxonomies","BlockInfo","QueryInspectorControls","props","attributes","setQuery","setDisplayLayout","setAttributes","query","displayLayout","enhancedPagination","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomies","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","showOrderControl","showStickyControl","showSettingsPanel","showTaxControl","showAuthorControl","showSearchControl","showParentControl","enhancedPaginationNotice","isFirstRender","current","showFiltersPanel","createElement","Fragment","title","__nextHasNoMarginBottom","label","help","checked","onChange","value","options","columns","min","max","Math","status","isDismissible","className","resetAll","hasValue","values","some","onDeselect","initialOpen","spokenMessage"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport CreateNewPostLink from './create-new-post-link';\nimport { unlock } from '../../../lock-unlock';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n\tuseTaxonomies,\n} from '../../utils';\n\nconst { BlockInfo } = unlock( blockEditorPrivateApis );\n\nexport default function QueryInspectorControls( props ) {\n\tconst { attributes, setQuery, setDisplayLayout, setAttributes } = props;\n\tconst { query, displayLayout, enhancedPagination } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomies = useTaxonomies( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = false;\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\tconst showTaxControl =\n\t\t!! taxonomies?.length &&\n\t\tisControlAllowed( allowedControls, 'taxQuery' );\n\tconst showAuthorControl = isControlAllowed( allowedControls, 'author' );\n\tconst showSearchControl = isControlAllowed( allowedControls, 'search' );\n\tconst showParentControl =\n\t\tisControlAllowed( allowedControls, 'parents' ) &&\n\t\tisPostTypeHierarchical;\n\n\tconst enhancedPaginationNotice = __(\n\t\t'Enhanced Pagination might cause interactive blocks within the Post Template to stop working. Disable it if you experience any issues.'\n\t);\n\n\tconst isFirstRender = useRef( true ); // Don't speak on first render.\n\tuseEffect( () => {\n\t\tif ( ! isFirstRender.current && enhancedPagination ) {\n\t\t\tspeak( enhancedPaginationNotice );\n\t\t}\n\t\tisFirstRender.current = false;\n\t}, [ enhancedPagination, enhancedPaginationNotice ] );\n\n\tconst showFiltersPanel =\n\t\tshowTaxControl ||\n\t\tshowAuthorControl ||\n\t\tshowSearchControl ||\n\t\tshowParentControl;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockInfo>\n\t\t\t\t<CreateNewPostLink { ...props } />\n\t\t\t</BlockInfo>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( {\n\t\t\t\t\t\t\t\t\t\t\tcolumns: value,\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\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && showFiltersPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTaxControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\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\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showAuthorControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showSearchControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showParentControl && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'User Experience' ) }\n\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Enhanced pagination' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\"Don't refresh the page when paginating to another page.\"\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tchecked={ !! enhancedPagination }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tenhancedPagination: !! value,\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\t{ enhancedPagination && (\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tspokenMessage={ null }\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ enhancedPaginationNotice }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,EACNC,wBAAwB,IAAIC,UAAU,EACtCC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AAC7E,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SACCC,YAAY,EACZC,yBAAyB,EACzBC,kBAAkB,EAClBC,gBAAgB,EAChBC,aAAa,QACP,aAAa;AAEpB,MAAM;EAAEC;AAAU,CAAC,GAAGN,MA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AAA,cACCA,aAAA,CAACvF,MAAM;IACN8G,aAAa,EAAG,IAAM;IACtBT,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG;EAAO,GAErBnB,wBACK,CACJ,CAEI,CACO,CAClB,CAAC;AAEL"}
|
|
@@ -109,7 +109,8 @@ export default function QueryContent({
|
|
|
109
109
|
return createElement(Fragment, null, createElement(QueryInspectorControls, {
|
|
110
110
|
attributes: attributes,
|
|
111
111
|
setQuery: updateQuery,
|
|
112
|
-
setDisplayLayout: updateDisplayLayout
|
|
112
|
+
setDisplayLayout: updateDisplayLayout,
|
|
113
|
+
setAttributes: setAttributes
|
|
113
114
|
}), createElement(BlockControls, null, createElement(QueryToolbar, {
|
|
114
115
|
name: name,
|
|
115
116
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","QueryToolbar","QueryInspectorControls","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","inherit","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","canUser","settingPerPage","posts_per_page","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","createElement","Fragment","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, canUser } = select( coreStore );\n\t\tconst settingPerPage = canUser( 'read', 'settings' )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\t\treturn {\n\t\t\tpostsPerPage: settingPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage, postsPerPage, inherit ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\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\t),\n\t};\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASJ,KAAK,IAAIK,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,sBAAsB,MAAM,sBAAsB;AAEzD,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,QAAQ,GAAG,CAAE,CAAE,oBAAoB,CAAE,CAAE;AAC7C,eAAe,SAASC,YAAYA,CAAE;EACrCC,UAAU;EACVC,aAAa;EACbC,yBAAyB;EACzBC,IAAI;EACJC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,OAAO;IACPC,KAAK;IACLC,aAAa;IACbC,OAAO,EAAEC,OAAO,GAAG,KAAK;IACxBH,KAAK,EAAE;MAAEI;IAAQ,CAA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W,CAAEL,QAAS,CAAC;IACxB;EACD,CAAC,EAAE,CAAEjB,KAAK,CAACkB,OAAO,EAAER,YAAY,EAAEN,OAAO,CAAG,CAAC;EAC7C;EACA;EACAzB,SAAS,CAAE,MAAM;IAChB,IAAK,CAAE4C,MAAM,CAACC,QAAQ,CAAEzB,OAAQ,CAAC,EAAG;MACnCM,uCAAuC,CAAC,CAAC;MACzCV,aAAa,CAAE;QAAEI,OAAO,EAAEO;MAAW,CAAE,CAAC;IACzC;EACD,CAAC,EAAE,CAAEP,OAAO,EAAEO,UAAU,CAAG,CAAC;EAC5B,MAAMgB,WAAW,GAAKL,QAAQ,IAC7BtB,aAAa,CAAE;IAAEK,KAAK,EAAE;MAAE,GAAGA,KAAK;MAAE,GAAGiB;IAAS;EAAE,CAAE,CAAC;EACtD,MAAMQ,mBAAmB,GAAKC,gBAAgB,IAC7C/B,aAAa,CAAE;IACdM,aAAa,EAAE;MAAE,GAAGA,aAAa;MAAE,GAAGyB;IAAiB;EACxD,CAAE,CAAC;EACJ,MAAMC,mBAAmB,GAAG;IAC3BC,IAAI,EAAEzC,EAAE,CACP,mFACD,CAAC;IACD0C,OAAO,EAAE1C,EAAE,CACV,kIACD,CAAC;IACD2C,KAAK,EAAE3C,EAAE,CACR,uIACD;EACD,CAAC;EACD,OACC4C,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACzC,sBAAsB;IACtBI,UAAU,EAAGA,UAAY;IACzBuC,QAAQ,EAAGX,WAAa;IACxBY,gBAAgB,EAAGT;
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","QueryToolbar","QueryInspectorControls","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","inherit","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","canUser","settingPerPage","posts_per_page","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","createElement","Fragment","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, canUser } = select( coreStore );\n\t\tconst settingPerPage = canUser( 'read', 'settings' )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\t\treturn {\n\t\t\tpostsPerPage: settingPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage, postsPerPage, inherit ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\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\t),\n\t};\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ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