@wordpress/block-library 7.3.0 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/archives/edit.js +1 -1
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +2 -2
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +1 -1
- package/build/audio/edit.native.js.map +1 -1
- package/build/categories/edit.js +8 -3
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +4 -0
- package/build/categories/index.js.map +1 -1
- package/build/column/index.js +10 -0
- package/build/column/index.js.map +1 -1
- package/build/comment-template/edit.js +3 -1
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +14 -4
- package/build/comment-template/hooks.js.map +1 -1
- package/build/comments-pagination/edit.js +18 -1
- package/build/comments-pagination/edit.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -1
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-title/edit.js +149 -0
- package/build/comments-title/edit.js.map +1 -0
- package/build/comments-title/index.js +101 -0
- package/build/comments-title/index.js.map +1 -0
- package/build/cover/transforms.js +33 -32
- package/build/cover/transforms.js.map +1 -1
- package/build/embed/edit.js +12 -18
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +1 -7
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/util.js +29 -4
- package/build/embed/util.js.map +1 -1
- package/build/file/inspector.js +2 -4
- package/build/file/inspector.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/v1/edit.js +1 -1
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/html/edit.js +2 -2
- package/build/html/edit.js.map +1 -1
- package/build/image/edit.js +4 -6
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/index.js +5 -3
- package/build/index.js.map +1 -1
- package/build/index.native.js +14 -3
- package/build/index.native.js.map +1 -1
- package/build/latest-comments/edit.js +1 -1
- package/build/latest-comments/edit.js.map +1 -1
- package/build/list/index.js +13 -2
- package/build/list/index.js.map +1 -1
- package/build/loginout/edit.js +1 -1
- package/build/loginout/edit.js.map +1 -1
- package/build/media-text/edit.js +1 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/edit.native.js +1 -1
- package/build/media-text/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +17 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +7 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/index.js +1 -1
- package/build/navigation/view-modal.js +37 -0
- package/build/navigation/view-modal.js.map +1 -0
- package/build/navigation/view.js +1 -34
- package/build/navigation/view.js.map +1 -1
- package/build/paragraph/edit.native.js +6 -2
- package/build/paragraph/edit.native.js.map +1 -1
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-comments/index.js +4 -3
- package/build/post-comments/index.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +19 -7
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/edit/index.js +84 -22
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/query-placeholder.js +7 -14
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/edit/query-toolbar.js +6 -1
- package/build/query/edit/query-toolbar.js.map +1 -1
- package/build/quote/index.js +19 -2
- package/build/quote/index.js.map +1 -1
- package/build/quote/v2/edit.js +11 -3
- package/build/quote/v2/edit.js.map +1 -1
- package/build/rss/edit.js +1 -1
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +11 -9
- package/build/search/edit.js.map +1 -1
- package/build/spacer/constants.js +9 -0
- package/build/spacer/constants.js.map +1 -0
- package/build/spacer/controls.js +3 -3
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +2 -2
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +5 -6
- package/build/spacer/edit.js.map +1 -1
- package/build/table/edit.js +8 -2
- package/build/table/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +1 -1
- package/build/video/edit.native.js.map +1 -1
- package/build-module/archives/edit.js +1 -1
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -2
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +1 -1
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/categories/edit.js +8 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +4 -0
- package/build-module/categories/index.js.map +1 -1
- package/build-module/column/index.js +10 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/comment-template/edit.js +3 -1
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +14 -4
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/comments-pagination/edit.js +19 -2
- package/build-module/comments-pagination/edit.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +1 -1
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-title/edit.js +133 -0
- package/build-module/comments-title/edit.js.map +1 -0
- package/build-module/comments-title/index.js +88 -0
- package/build-module/comments-title/index.js.map +1 -0
- package/build-module/cover/transforms.js +33 -32
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/embed/edit.js +13 -19
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +2 -8
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/util.js +25 -3
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/inspector.js +2 -4
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/v1/edit.js +1 -1
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/html/edit.js +2 -2
- package/build-module/html/edit.js.map +1 -1
- package/build-module/image/edit.js +4 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +1 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +4 -3
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +14 -3
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-comments/edit.js +1 -1
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/list/index.js +9 -3
- package/build-module/list/index.js.map +1 -1
- package/build-module/loginout/edit.js +1 -1
- package/build-module/loginout/edit.js.map +1 -1
- package/build-module/media-text/edit.js +1 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/edit.native.js +1 -1
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +1 -1
- package/build-module/navigation/view-modal.js +32 -0
- package/build-module/navigation/view-modal.js.map +1 -0
- package/build-module/navigation/view.js +1 -30
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/paragraph/edit.native.js +6 -2
- package/build-module/paragraph/edit.native.js.map +1 -1
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-comments/index.js +4 -3
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +19 -7
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/edit/index.js +87 -26
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +8 -15
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/edit/query-toolbar.js +6 -1
- package/build-module/query/edit/query-toolbar.js.map +1 -1
- package/build-module/quote/index.js +10 -4
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/v2/edit.js +10 -3
- package/build-module/quote/v2/edit.js.map +1 -1
- package/build-module/rss/edit.js +1 -1
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +11 -9
- package/build-module/search/edit.js.map +1 -1
- package/build-module/spacer/constants.js +2 -0
- package/build-module/spacer/constants.js.map +1 -0
- package/build-module/spacer/controls.js +2 -2
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +1 -1
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +1 -1
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table/edit.js +9 -3
- package/build-module/table/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -1
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +1 -1
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/comments-title/editor-rtl.css +79 -0
- package/build-style/comments-title/editor.css +79 -0
- package/build-style/common-rtl.css +32 -0
- package/build-style/common.css +32 -0
- package/build-style/editor-rtl.css +51 -0
- package/build-style/editor.css +51 -0
- package/build-style/post-comments-form/style-rtl.css +9 -0
- package/build-style/post-comments-form/style.css +9 -0
- package/build-style/query/editor-rtl.css +39 -0
- package/build-style/query/editor.css +39 -0
- package/build-style/style-rtl.css +79 -0
- package/build-style/style.css +79 -0
- package/build-style/table/editor-rtl.css +8 -0
- package/build-style/table/editor.css +8 -0
- package/build-style/table/style-rtl.css +38 -0
- package/build-style/table/style.css +38 -0
- package/package.json +28 -28
- package/src/archives/edit.js +1 -1
- package/src/audio/edit.js +2 -2
- package/src/audio/edit.native.js +1 -1
- package/src/categories/block.json +4 -0
- package/src/categories/edit.js +8 -2
- package/src/categories/index.php +1 -0
- package/src/column/block.json +10 -0
- package/src/comment-template/edit.js +5 -2
- package/src/comment-template/hooks.js +15 -2
- package/src/comment-template/index.php +23 -2
- package/src/comments-pagination/edit.js +23 -0
- package/src/comments-query-loop/edit.js +1 -0
- package/src/comments-title/block.json +70 -0
- package/src/comments-title/edit.js +197 -0
- package/src/comments-title/editor.scss +4 -0
- package/src/comments-title/index.js +18 -0
- package/src/comments-title/index.php +68 -0
- package/src/common.scss +24 -1
- package/src/cover/transforms.js +51 -28
- package/src/editor.scss +1 -0
- package/src/embed/edit.js +19 -24
- package/src/embed/edit.native.js +9 -14
- package/src/embed/util.js +34 -2
- package/src/file/inspector.js +1 -3
- package/src/gallery/edit.js +1 -1
- package/src/gallery/v1/edit.js +1 -1
- package/src/html/edit.js +2 -2
- package/src/image/edit.js +2 -4
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +1 -1
- package/src/index.js +7 -1
- package/src/index.native.js +12 -2
- package/src/latest-comments/edit.js +1 -1
- package/src/list/index.js +7 -3
- package/src/loginout/edit.js +1 -1
- package/src/media-text/edit.js +1 -2
- package/src/media-text/edit.native.js +1 -1
- package/src/navigation/block.json +1 -1
- package/src/navigation/edit/index.js +24 -0
- package/src/navigation/edit/navigation-menu-selector.js +15 -9
- package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
- package/src/navigation/index.php +5 -0
- package/src/navigation/view-modal.js +36 -0
- package/src/navigation/view.js +0 -35
- package/src/paragraph/edit.native.js +13 -1
- package/src/post-author/edit.js +1 -1
- package/src/post-comments/block.json +4 -3
- package/src/post-comments-form/index.php +12 -4
- package/src/post-comments-form/style.scss +11 -0
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-featured-image/edit.js +24 -12
- package/src/query/edit/index.js +125 -26
- package/src/query/edit/query-placeholder.js +3 -13
- package/src/query/edit/query-toolbar.js +6 -0
- package/src/query/editor.scss +38 -0
- package/src/quote/index.js +8 -4
- package/src/quote/v2/edit.js +3 -0
- package/src/rss/edit.js +1 -1
- package/src/search/edit.js +13 -7
- package/src/search/index.php +84 -33
- package/src/spacer/constants.js +1 -0
- package/src/spacer/controls.js +2 -2
- package/src/spacer/controls.native.js +1 -1
- package/src/spacer/edit.js +1 -2
- package/src/table/edit.js +11 -2
- package/src/table/editor.scss +13 -0
- package/src/table/style.scss +52 -0
- package/src/tag-cloud/edit.js +1 -1
- package/src/video/edit.js +1 -1
- package/src/video/edit.native.js +1 -1
package/CHANGELOG.md
CHANGED
package/build/archives/edit.js
CHANGED
|
@@ -31,7 +31,7 @@ function ArchivesEdit(_ref) {
|
|
|
31
31
|
type
|
|
32
32
|
} = attributes;
|
|
33
33
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
34
|
-
title: (0, _i18n.__)('
|
|
34
|
+
title: (0, _i18n.__)('Settings')
|
|
35
35
|
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
36
36
|
label: (0, _i18n.__)('Display as dropdown'),
|
|
37
37
|
checked: displayAsDropdown,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/archives/edit.js"],"names":["ArchivesEdit","attributes","setAttributes","showPostCounts","displayAsDropdown","type","label","value"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;AAWe,SAASA,YAAT,OAAuD;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AACrE,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,iBAAlB;AAAqCC,IAAAA;AAArC,MAA8CJ,UAApD;AAEA,SACC,qDACC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/archives/edit.js"],"names":["ArchivesEdit","attributes","setAttributes","showPostCounts","displayAsDropdown","type","label","value"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;AAWe,SAASA,YAAT,OAAuD;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AACrE,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,iBAAlB;AAAqCC,IAAAA;AAArC,MAA8CJ,UAApD;AAEA,SACC,qDACC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,UAAJ;AAAnB,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CADT;AAEC,IAAA,OAAO,EAAGG,iBAFX;AAGC,IAAA,QAAQ,EAAG,MACVF,aAAa,CAAE;AACdE,MAAAA,iBAAiB,EAAE,CAAEA;AADP,KAAF;AAJf,IADD,EAUC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CADT;AAEC,IAAA,OAAO,EAAGD,cAFX;AAGC,IAAA,QAAQ,EAAG,MACVD,aAAa,CAAE;AACdC,MAAAA,cAAc,EAAE,CAAEA;AADJ,KAAF;AAJf,IAVD,EAmBC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,WAAJ,CADT;AAEC,IAAA,OAAO,EAAG,CACT;AAAEG,MAAAA,KAAK,EAAE,cAAI,MAAJ,CAAT;AAAuBC,MAAAA,KAAK,EAAE;AAA9B,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,cAAI,OAAJ,CAAT;AAAwBC,MAAAA,KAAK,EAAE;AAA/B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,cAAI,MAAJ,CAAT;AAAuBC,MAAAA,KAAK,EAAE;AAA9B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAE,cAAI,KAAJ,CAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAGF,IART;AASC,IAAA,QAAQ,EAAKE,KAAF,IACVL,aAAa,CAAE;AAAEG,MAAAA,IAAI,EAAEE;AAAR,KAAF;AAVf,IAnBD,CADD,CADD,EAoCC,mCAAU,iCAAV,EACC,4BAAC,oBAAD,QACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAC,eADP;AAEC,IAAA,UAAU,EAAGN;AAFd,IADD,CADD,CApCD,CADD;AA+CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tToggleControl,\n\tSelectControl,\n\tDisabled,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport ServerSideRender from '@wordpress/server-side-render';\n\nexport default function ArchivesEdit( { attributes, setAttributes } ) {\n\tconst { showPostCounts, displayAsDropdown, type } = attributes;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayAsDropdown: ! displayAsDropdown,\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<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowPostCounts: ! showPostCounts,\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<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Group by:' ) }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ label: __( 'Year' ), value: 'yearly' },\n\t\t\t\t\t\t\t{ label: __( 'Month' ), value: 'monthly' },\n\t\t\t\t\t\t\t{ label: __( 'Week' ), value: 'weekly' },\n\t\t\t\t\t\t\t{ label: __( 'Day' ), value: 'daily' },\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { type: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...useBlockProps() }>\n\t\t\t\t<Disabled>\n\t\t\t\t\t<ServerSideRender\n\t\t\t\t\t\tblock=\"core/archives\"\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
package/build/audio/edit.js
CHANGED
|
@@ -188,7 +188,7 @@ function AudioEdit(_ref) {
|
|
|
188
188
|
onSelectURL: onSelectURL,
|
|
189
189
|
onError: onUploadError
|
|
190
190
|
})), (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
191
|
-
title: (0, _i18n.__)('
|
|
191
|
+
title: (0, _i18n.__)('Settings')
|
|
192
192
|
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
193
193
|
label: (0, _i18n.__)('Autoplay'),
|
|
194
194
|
onChange: toggleAttribute('autoplay'),
|
|
@@ -216,7 +216,7 @@ function AudioEdit(_ref) {
|
|
|
216
216
|
label: (0, _i18n.__)('Metadata')
|
|
217
217
|
}, {
|
|
218
218
|
value: 'none',
|
|
219
|
-
label: (0, _i18n._x)('None', '
|
|
219
|
+
label: (0, _i18n._x)('None', 'Preload value')
|
|
220
220
|
}]
|
|
221
221
|
}))), (0, _element.createElement)("figure", blockProps, (0, _element.createElement)(_components.Disabled, {
|
|
222
222
|
isDisabled: !isSelected
|
package/build/audio/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/audio/edit.js"],"names":["ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","noticeOperations","setAttributes","onReplace","isSelected","noticeUI","insertBlocksAfter","id","autoplay","caption","loop","preload","src","isTemporaryAudio","mediaUpload","select","getSettings","blockEditorStore","file","filesList","onFileChange","mediaId","url","onError","e","undefined","createErrorNotice","allowedTypes","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","onUploadError","message","removeAllNotices","getAutoplayHelp","checked","onSelectAudio","media","classes","blockProps","icon","value","label","RichText","isEmpty"],"mappings":";;;;;;;;;AA2BA;;AAxBA;;AAKA;;AACA;;AAQA;;AAWA;;AACA;;AACA;;AACA;;AAKA;;AApCA;AACA;AACA;;AAGA;AACA;AACA;;AA0BA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OASI;AAAA,MATgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,SAFmB;AAGnBC,IAAAA,gBAHmB;AAInBC,IAAAA,aAJmB;AAKnBC,IAAAA,SALmB;AAMnBC,IAAAA,UANmB;AAOnBC,IAAAA,QAPmB;AAQnBC,IAAAA;AARmB,GAShB;AACH,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,QAAN;AAAgBC,IAAAA,OAAhB;AAAyBC,IAAAA,IAAzB;AAA+BC,IAAAA,OAA/B;AAAwCC,IAAAA;AAAxC,MAAgDb,UAAtD;AACA,QAAMc,gBAAgB,GAAG,CAAEN,EAAF,IAAQ,qBAAWK,GAAX,CAAjC;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AK,IAAInB;AADJ,KAAF,CALf;AASC,IAAA,OAAO,EAAG,CACT;AAAEmB,MAAAA,KAAK,EAAE,EAAT;AAAaC,MAAAA,KAAK,EAAE,cAAI,iBAAJ;AAApB,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,MAAT;AAAiBC,MAAAA,KAAK,EAAE,cAAI,MAAJ;AAAxB,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,UAAT;AAAqBC,MAAAA,KAAK,EAAE,cAAI,UAAJ;AAA5B,KAHS,EAIT;AACCD,MAAAA,KAAK,EAAE,MADR;AAECC,MAAAA,KAAK,EAAE,cAAI,MAAJ,EAAY,iBAAZ;AAFR,KAJS;AATX,IAZD,CADD,CAZD,EA8CC,sCAAaH,UAAb,EAMC,4BAAC,oBAAD;AAAU,IAAA,UAAU,EAAG,CAAEtC;AAAzB,KACC;AAAO,IAAA,QAAQ,EAAC,UAAhB;AAA2B,IAAA,GAAG,EAAGQ;AAAjC,IADD,CAND,EASGC,gBAAgB,IAAI,4BAAC,mBAAD,OATvB,EAUG,CAAE,CAAEiC,sBAASC,OAAT,CAAkBtC,OAAlB,CAAF,IAAiCL,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAa,cAAI,oBAAJ,CAFd;AAGC,IAAA,WAAW,EAAG,cAAI,aAAJ,CAHf;AAIC,IAAA,KAAK,EAAGK,OAJT;AAKC,IAAA,QAAQ,EAAKmC,KAAF,IACV1C,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAEmC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxBtC,iBAAiB,CAAE,yBAAa,gBAAb,CAAF;AAVnB,IAXF,CA9CD,CADD;AA2EA;;eACc,6BAAaR,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { audio as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tclassName,\n\tnoticeOperations,\n\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tnoticeUI,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, caption, loop, preload, src } = attributes;\n\tconst isTemporaryAudio = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { id: mediaId, url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { id: mediaId, src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( e ) => {\n\t\t\t\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( e );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\t// Set the block's src from the edit component's state, and switch off\n\t\t// the editing UI.\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tfunction getAutoplayHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Autoplay may cause usability issues for some users.' )\n\t\t\t: null;\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryAudio,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Audio settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\thelp={ getAutoplayHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ _x( 'Preload', 'noun; Audio block parameter' ) }\n\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" 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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the audio tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tfile or change the position slider when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<audio controls=\"controls\" src={ src } />\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryAudio && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Audio caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\nexport default withNotices( AudioEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/audio/edit.js"],"names":["ALLOWED_MEDIA_TYPES","AudioEdit","attributes","className","noticeOperations","setAttributes","onReplace","isSelected","noticeUI","insertBlocksAfter","id","autoplay","caption","loop","preload","src","isTemporaryAudio","mediaUpload","select","getSettings","blockEditorStore","file","filesList","onFileChange","mediaId","url","onError","e","undefined","createErrorNotice","allowedTypes","toggleAttribute","attribute","newValue","onSelectURL","newSrc","embedBlock","onUploadError","message","removeAllNotices","getAutoplayHelp","checked","onSelectAudio","media","classes","blockProps","icon","value","label","RichText","isEmpty"],"mappings":";;;;;;;;;AA2BA;;AAxBA;;AAKA;;AACA;;AAQA;;AAWA;;AACA;;AACA;;AACA;;AAKA;;AApCA;AACA;AACA;;AAGA;AACA;AACA;;AA0BA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OASI;AAAA,MATgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,SAFmB;AAGnBC,IAAAA,gBAHmB;AAInBC,IAAAA,aAJmB;AAKnBC,IAAAA,SALmB;AAMnBC,IAAAA,UANmB;AAOnBC,IAAAA,QAPmB;AAQnBC,IAAAA;AARmB,GAShB;AACH,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,QAAN;AAAgBC,IAAAA,OAAhB;AAAyBC,IAAAA,IAAzB;AAA+BC,IAAAA,OAA/B;AAAwCC,IAAAA;AAAxC,MAAgDb,UAAtD;AACA,QAAMc,gBAAgB,GAAG,CAAEN,EAAF,IAAQ,qBAAWK,GAAX,CAAjC;AACA,QAAME,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAC5C,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,WAAOD,WAAW,GAAGF,WAArB;AACA,GAHmB,EAGjB,EAHiB,CAApB;AAKA,0BAAW,MAAM;AAChB,QAAK,CAAEP,EAAF,IAAQ,qBAAWK,GAAX,CAAb,EAAgC;AAC/B,YAAMM,IAAI,GAAG,wBAAcN,GAAd,CAAb;;AAEA,UAAKM,IAAL,EAAY;AACXJ,QAAAA,WAAW,CAAE;AACZK,UAAAA,SAAS,EAAE,CAAED,IAAF,CADC;AAEZE,UAAAA,YAAY,EAAE,SAAgC;AAAA,gBAA9B,CAAE;AAAE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,UAAb,EAMC,4BAAC,oBAAD;AAAU,IAAA,UAAU,EAAG,CAAEtC;AAAzB,KACC;AAAO,IAAA,QAAQ,EAAC,UAAhB;AAA2B,IAAA,GAAG,EAAGQ;AAAjC,IADD,CAND,EASGC,gBAAgB,IAAI,4BAAC,mBAAD,OATvB,EAUG,CAAE,CAAEiC,sBAASC,OAAT,CAAkBtC,OAAlB,CAAF,IAAiCL,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAa,cAAI,oBAAJ,CAFd;AAGC,IAAA,WAAW,EAAG,cAAI,aAAJ,CAHf;AAIC,IAAA,KAAK,EAAGK,OAJT;AAKC,IAAA,QAAQ,EAAKmC,KAAF,IACV1C,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAEmC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxBtC,iBAAiB,CAAE,yBAAa,gBAAb,CAAF;AAVnB,IAXF,CA9CD,CADD;AA2EA;;eACc,6BAAaR,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tDisabled,\n\tPanelBody,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { audio as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tclassName,\n\tnoticeOperations,\n\tsetAttributes,\n\tonReplace,\n\tisSelected,\n\tnoticeUI,\n\tinsertBlocksAfter,\n} ) {\n\tconst { id, autoplay, caption, loop, preload, src } = attributes;\n\tconst isTemporaryAudio = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().mediaUpload;\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { id: mediaId, url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { id: mediaId, src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( e ) => {\n\t\t\t\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( e );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\t// Set the block's src from the edit component's state, and switch off\n\t\t// the editing UI.\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock && onReplace ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tfunction getAutoplayHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Autoplay may cause usability issues for some users.' )\n\t\t\t: null;\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryAudio,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\thelp={ getAutoplayHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ _x( 'Preload', 'noun; Audio block parameter' ) }\n\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\tlabel: _x( 'None', 'Preload 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</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the audio tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tfile or change the position slider when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<audio controls=\"controls\" src={ src } />\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryAudio && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Audio caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\nexport default withNotices( AudioEdit );\n"]}
|
|
@@ -186,7 +186,7 @@ function AudioEdit(_ref) {
|
|
|
186
186
|
onPress: onAudioPress,
|
|
187
187
|
disabled: !isSelected
|
|
188
188
|
}, (0, _element.createElement)(_primitives.View, null, (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
189
|
-
title: (0, _i18n.__)('
|
|
189
|
+
title: (0, _i18n.__)('Settings')
|
|
190
190
|
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
191
191
|
label: (0, _i18n.__)('Autoplay'),
|
|
192
192
|
onChange: toggleAttribute('autoplay'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/audio/edit.native.js"],"names":["ALLOWED_MEDIA_TYPES","AudioEdit","attributes","setAttributes","isSelected","insertBlocksAfter","onFocus","onBlur","clientId","id","autoplay","loop","preload","src","isCaptionSelected","setIsCaptionSelected","onFileChange","mediaId","mediaUrl","wasBlockJustInserted","select","blockEditorStore","createErrorNotice","noticesStore","toggleAttribute","attribute","newValue","onSelectURL","newSrc","undefined","onSelectAudio","media","url","onAudioPress","onFocusCaption","icon","getBlockControls","open","replace","getBlockUI","getMediaOptions","styles","progressContainer","progressBar","spinner","isUploadInProgress","isUploadFailed","retryMessage","value","label","caption"],"mappings":";;;;;;;;;AA8BA;;AA3BA;;AACA;;AAKA;;AACA;;AAQA;;AAUA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AAtCA;AACA;AACA;;AAIA;AACA;AACA;;AA2BA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OAQI;AAAA,MARgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,aAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,iBAJmB;AAKnBC,IAAAA,OALmB;AAMnBC,IAAAA,MANmB;AAOnBC,IAAAA;AAPmB,GAQhB;AACH,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,QAAN;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA,OAAtB;AAA+BC,IAAAA;AAA/B,MAAuCX,UAA7C;AAEA,QAAM,CAAEY,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;;AAEA,QAAMC,YAAY,GAAG,SAA6B;AAAA,QAA3B;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,KAA2B;AACjDf,IAAAA,aAAa,CAAE;AAAEM,MAAAA,EAAE,EAAEQ,OAAN;AAAeJ,MAAAA,GAAG,EAAEK;AAApB,KAAF,CAAb;AACA,GAFD;;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,qBAAaC,MAAF,KAAgB;AAC3DD,IAAAA,oBAAoB,EAAEC,MAAM,CAAEC,kBAAF,CAAN,CAA2BF,oBAA3B,CACrBX,QADqB,EAErB,eAFqB;AADqC,GAAhB,CAAX,CAAjC;AAOA,QAAM;AAAEc,IAAAA;AAAF,MAAwB,uBAAaC,cAAb,CAA9B;;AAEA,WAASC,eAAT,CAA0BC,SAA1B,EAAsC;AACrC,WAASC,QAAF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AGjD,mBADhB;AAEC,IAAA,gBAAgB,EAAG,IAFpB;AAGC,IAAA,QAAQ,EAAG8B,aAHZ;AAIC,IAAA,WAAW,EAAGH,WAJf;AAKC,IAAA,MAAM,EAAG,SAAiC;AAAA,UAA/B;AAAEU,QAAAA,IAAF;AAAQG,QAAAA;AAAR,OAA+B;AACzC,aAAOD,UAAU,CAAEF,IAAF,EAAQG,eAAR,CAAjB;AACA;AAPF,IAzCD,EAkDC,4BAAC,yBAAD;AACC,IAAA,UAAU,EAAG,IADd;AAEC,IAAA,yBAAyB,EAAKU,OAAF,IAC3B,qBAASA,OAAT;AACG;AACA,kBAAI,sBAAJ,CAFH,GAGG;AACA;AACA,kBAAI,mBAAJ,CAFA,EAGAA,OAHA,CANL;AAYC,IAAA,QAAQ,EAAG1C,QAZZ;AAaC,IAAA,UAAU,EAAGM,iBAbd;AAcC,IAAA,OAAO,EAAGoB,cAdX;AAeC,IAAA,MAAM,EAAG3B,MAfV;AAgBC,IAAA,iBAAiB,EAAGF;AAhBrB,IAlDD,CALD,CADD;AA6EA;;eACcJ,S","sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { View } from '@wordpress/primitives';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\tAudioPlayer,\n} from '@wordpress/components';\nimport {\n\tBlockCaption,\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { audio as icon, replace } from '@wordpress/icons';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonFocus,\n\tonBlur,\n\tclientId,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\n\tconst onFileChange = ( { mediaId, mediaUrl } ) => {\n\t\tsetAttributes( { id: mediaId, src: mediaUrl } );\n\t};\n\n\tconst { wasBlockJustInserted } = useSelect( ( select ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tif ( isURL( newSrc ) ) {\n\t\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t\t} else {\n\t\t\t\tcreateErrorNotice( __( 'Invalid URL. Audio file not found.' ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tfunction onAudioPress() {\n\t\tsetIsCaptionSelected( false );\n\t}\n\n\tfunction onFocusCaption() {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t}\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tautoOpenMediaUpload={ isSelected && wasBlockJustInserted }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\tfunction getBlockControls( open ) {\n\t\treturn (\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Replace audio' ) }\n\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t);\n\t}\n\n\tfunction getBlockUI( open, getMediaOptions ) {\n\t\treturn (\n\t\t\t<MediaUploadProgress\n\t\t\t\tmediaId={ id }\n\t\t\t\tonFinishMediaUploadWithSuccess={ onFileChange }\n\t\t\t\tonMediaUploadStateReset={ onFileChange }\n\t\t\t\tcontainerStyle={ styles.progressContainer }\n\t\t\t\tprogressBarStyle={ styles.progressBar }\n\t\t\t\tspinnerStyle={ styles.spinner }\n\t\t\t\trenderContent={ ( {\n\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\tisUploadFailed,\n\t\t\t\t\tretryMessage,\n\t\t\t\t} ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isCaptionSelected &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\tgetBlockControls( open ) }\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<AudioPlayer\n\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\tisUploadFailed={ isUploadFailed }\n\t\t\t\t\t\t\t\tretryMessage={ retryMessage }\n\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\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} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isSelected }\n\t\t\tonPress={ onAudioPress }\n\t\t\tdisabled={ ! isSelected }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Audio settings' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Autoplay may cause usability issues for some users.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Preload',\n\t\t\t\t\t\t\t\t'noun; Audio block parameter'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" 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\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ true }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\t\treturn getBlockUI( open, getMediaOptions );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<BlockCaption\n\t\t\t\t\taccessible={ true }\n\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\tisEmpty( caption )\n\t\t\t\t\t\t\t? /* translators: accessibility text. Empty Audio caption. */\n\t\t\t\t\t\t\t __( 'Audio caption. Empty' )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: Audio caption. */\n\t\t\t\t\t\t\t\t\t__( 'Audio caption. %s' ),\n\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\t\tonFocus={ onFocusCaption }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\nexport default AudioEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/audio/edit.native.js"],"names":["ALLOWED_MEDIA_TYPES","AudioEdit","attributes","setAttributes","isSelected","insertBlocksAfter","onFocus","onBlur","clientId","id","autoplay","loop","preload","src","isCaptionSelected","setIsCaptionSelected","onFileChange","mediaId","mediaUrl","wasBlockJustInserted","select","blockEditorStore","createErrorNotice","noticesStore","toggleAttribute","attribute","newValue","onSelectURL","newSrc","undefined","onSelectAudio","media","url","onAudioPress","onFocusCaption","icon","getBlockControls","open","replace","getBlockUI","getMediaOptions","styles","progressContainer","progressBar","spinner","isUploadInProgress","isUploadFailed","retryMessage","value","label","caption"],"mappings":";;;;;;;;;AA8BA;;AA3BA;;AACA;;AAKA;;AACA;;AAQA;;AAUA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AAtCA;AACA;AACA;;AAIA;AACA;AACA;;AA2BA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,SAAT,OAQI;AAAA,MARgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,aAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,iBAJmB;AAKnBC,IAAAA,OALmB;AAMnBC,IAAAA,MANmB;AAOnBC,IAAAA;AAPmB,GAQhB;AACH,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,QAAN;AAAgBC,IAAAA,IAAhB;AAAsBC,IAAAA,OAAtB;AAA+BC,IAAAA;AAA/B,MAAuCX,UAA7C;AAEA,QAAM,CAAEY,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;;AAEA,QAAMC,YAAY,GAAG,SAA6B;AAAA,QAA3B;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,KAA2B;AACjDf,IAAAA,aAAa,CAAE;AAAEM,MAAAA,EAAE,EAAEQ,OAAN;AA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A,KAAK,EAAE,MAAT;AAAiBC,MAAAA,KAAK,EAAE,cAAI,MAAJ;AAAxB,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,UAAT;AAAqBC,MAAAA,KAAK,EAAE,cAAI,UAAJ;AAA5B,KAHS,EAIT;AACCD,MAAAA,KAAK,EAAE,MADR;AAECC,MAAAA,KAAK,EAAE,cAAI,MAAJ,EAAY,iBAAZ;AAFR,KAJS,CAZX;AAqBC,IAAA,gBAAgB,EAAG;AArBpB,IAdD,CADD,CADD,EAyCC,4BAAC,wBAAD;AACC,IAAA,YAAY,EAAGjD,mBADhB;AAEC,IAAA,gBAAgB,EAAG,IAFpB;AAGC,IAAA,QAAQ,EAAG8B,aAHZ;AAIC,IAAA,WAAW,EAAGH,WAJf;AAKC,IAAA,MAAM,EAAG,SAAiC;AAAA,UAA/B;AAAEU,QAAAA,IAAF;AAAQG,QAAAA;AAAR,OAA+B;AACzC,aAAOD,UAAU,CAAEF,IAAF,EAAQG,eAAR,CAAjB;AACA;AAPF,IAzCD,EAkDC,4BAAC,yBAAD;AACC,IAAA,UAAU,EAAG,IADd;AAEC,IAAA,yBAAyB,EAAKU,OAAF,IAC3B,qBAASA,OAAT;AACG;AACA,kBAAI,sBAAJ,CAFH,GAGG;AACA;AACA,kBAAI,mBAAJ,CAFA,EAGAA,OAHA,CANL;AAYC,IAAA,QAAQ,EAAG1C,QAZZ;AAaC,IAAA,UAAU,EAAGM,iBAbd;AAcC,IAAA,OAAO,EAAGoB,cAdX;AAeC,IAAA,MAAM,EAAG3B,MAfV;AAgBC,IAAA,iBAAiB,EAAGF;AAhBrB,IAlDD,CALD,CADD;AA6EA;;eACcJ,S","sourcesContent":["/**\n * External dependencies\n */\nimport { TouchableWithoutFeedback } from 'react-native';\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { View } from '@wordpress/primitives';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n\tAudioPlayer,\n} from '@wordpress/components';\nimport {\n\tBlockCaption,\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadProgress,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { audio as icon, replace } from '@wordpress/icons';\nimport { useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst ALLOWED_MEDIA_TYPES = [ 'audio' ];\n\nfunction AudioEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tonFocus,\n\tonBlur,\n\tclientId,\n} ) {\n\tconst { id, autoplay, loop, preload, src } = attributes;\n\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\n\tconst onFileChange = ( { mediaId, mediaUrl } ) => {\n\t\tsetAttributes( { id: mediaId, src: mediaUrl } );\n\t};\n\n\tconst { wasBlockJustInserted } = useSelect( ( select ) => ( {\n\t\twasBlockJustInserted: select( blockEditorStore ).wasBlockJustInserted(\n\t\t\tclientId,\n\t\t\t'inserter_menu'\n\t\t),\n\t} ) );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tfunction toggleAttribute( attribute ) {\n\t\treturn ( newValue ) => {\n\t\t\tsetAttributes( { [ attribute ]: newValue } );\n\t\t};\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\tif ( isURL( newSrc ) ) {\n\t\t\t\tsetAttributes( { src: newSrc, id: undefined } );\n\t\t\t} else {\n\t\t\t\tcreateErrorNotice( __( 'Invalid URL. Audio file not found.' ) );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectAudio( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error and we should continue in the editing state\n\t\t\t// previous attributes should be removed because they may be temporary blob urls.\n\t\t\tsetAttributes( { src: undefined, id: undefined } );\n\t\t\treturn;\n\t\t}\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media, then switches off the editing UI.\n\t\tsetAttributes( { src: media.url, id: media.id } );\n\t}\n\n\tfunction onAudioPress() {\n\t\tsetIsCaptionSelected( false );\n\t}\n\n\tfunction onFocusCaption() {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t}\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"audio/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tautoOpenMediaUpload={ isSelected && wasBlockJustInserted }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\tfunction getBlockControls( open ) {\n\t\treturn (\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Replace audio' ) }\n\t\t\t\t\t\ticon={ replace }\n\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t);\n\t}\n\n\tfunction getBlockUI( open, getMediaOptions ) {\n\t\treturn (\n\t\t\t<MediaUploadProgress\n\t\t\t\tmediaId={ id }\n\t\t\t\tonFinishMediaUploadWithSuccess={ onFileChange }\n\t\t\t\tonMediaUploadStateReset={ onFileChange }\n\t\t\t\tcontainerStyle={ styles.progressContainer }\n\t\t\t\tprogressBarStyle={ styles.progressBar }\n\t\t\t\tspinnerStyle={ styles.spinner }\n\t\t\t\trenderContent={ ( {\n\t\t\t\t\tisUploadInProgress,\n\t\t\t\t\tisUploadFailed,\n\t\t\t\t\tretryMessage,\n\t\t\t\t} ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isCaptionSelected &&\n\t\t\t\t\t\t\t\t! isUploadInProgress &&\n\t\t\t\t\t\t\t\tgetBlockControls( open ) }\n\t\t\t\t\t\t\t{ getMediaOptions() }\n\t\t\t\t\t\t\t<AudioPlayer\n\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\tisUploadFailed={ isUploadFailed }\n\t\t\t\t\t\t\t\tretryMessage={ retryMessage }\n\t\t\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\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} }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<TouchableWithoutFeedback\n\t\t\taccessible={ ! isSelected }\n\t\t\tonPress={ onAudioPress }\n\t\t\tdisabled={ ! isSelected }\n\t\t>\n\t\t\t<View>\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Autoplay' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'autoplay' ) }\n\t\t\t\t\t\t\tchecked={ autoplay }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Autoplay may cause usability issues for some users.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Loop' ) }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'loop' ) }\n\t\t\t\t\t\t\tchecked={ loop }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t'Preload',\n\t\t\t\t\t\t\t\t'noun; Audio block parameter'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ preload || '' }\n\t\t\t\t\t\t\t// `undefined` is required for the preload attribute to be unset.\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tpreload: value || undefined,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{ value: '', label: __( 'Browser default' ) },\n\t\t\t\t\t\t\t\t{ value: 'auto', label: __( 'Auto' ) },\n\t\t\t\t\t\t\t\t{ value: 'metadata', label: __( 'Metadata' ) },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t\t\t\t\tlabel: _x( 'None', '\"Preload\" 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\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ true }\n\t\t\t\t\tonSelect={ onSelectAudio }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\trender={ ( { open, getMediaOptions } ) => {\n\t\t\t\t\t\treturn getBlockUI( open, getMediaOptions );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t<BlockCaption\n\t\t\t\t\taccessible={ true }\n\t\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t\tisEmpty( caption )\n\t\t\t\t\t\t\t? /* translators: accessibility text. Empty Audio caption. */\n\t\t\t\t\t\t\t __( 'Audio caption. Empty' )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: Audio caption. */\n\t\t\t\t\t\t\t\t\t__( 'Audio caption. %s' ),\n\t\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\t\tonFocus={ onFocusCaption }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n}\nexport default AudioEdit;\n"]}
|
package/build/categories/edit.js
CHANGED
|
@@ -34,14 +34,15 @@ function CategoriesEdit(_ref) {
|
|
|
34
34
|
displayAsDropdown,
|
|
35
35
|
showHierarchy,
|
|
36
36
|
showPostCounts,
|
|
37
|
-
showOnlyTopLevel
|
|
37
|
+
showOnlyTopLevel,
|
|
38
|
+
showEmpty
|
|
38
39
|
},
|
|
39
40
|
setAttributes
|
|
40
41
|
} = _ref;
|
|
41
42
|
const selectId = (0, _compose.useInstanceId)(CategoriesEdit, 'blocks-category-select');
|
|
42
43
|
const query = {
|
|
43
44
|
per_page: -1,
|
|
44
|
-
hide_empty:
|
|
45
|
+
hide_empty: !showEmpty,
|
|
45
46
|
context: 'view'
|
|
46
47
|
};
|
|
47
48
|
|
|
@@ -135,7 +136,7 @@ function CategoriesEdit(_ref) {
|
|
|
135
136
|
};
|
|
136
137
|
|
|
137
138
|
return (0, _element.createElement)("div", (0, _blockEditor.useBlockProps)(), (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
138
|
-
title: (0, _i18n.__)('
|
|
139
|
+
title: (0, _i18n.__)('Settings')
|
|
139
140
|
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
140
141
|
label: (0, _i18n.__)('Display as dropdown'),
|
|
141
142
|
checked: displayAsDropdown,
|
|
@@ -148,6 +149,10 @@ function CategoriesEdit(_ref) {
|
|
|
148
149
|
label: (0, _i18n.__)('Show only top level categories'),
|
|
149
150
|
checked: showOnlyTopLevel,
|
|
150
151
|
onChange: toggleAttribute('showOnlyTopLevel')
|
|
152
|
+
}), (0, _element.createElement)(_components.ToggleControl, {
|
|
153
|
+
label: (0, _i18n.__)('Show empty categories'),
|
|
154
|
+
checked: showEmpty,
|
|
155
|
+
onChange: toggleAttribute('showEmpty')
|
|
151
156
|
}), !showOnlyTopLevel && (0, _element.createElement)(_components.ToggleControl, {
|
|
152
157
|
label: (0, _i18n.__)('Show hierarchy'),
|
|
153
158
|
checked: showHierarchy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/categories/edit.js"],"names":["CategoriesEdit","attributes","displayAsDropdown","showHierarchy","showPostCounts","showOnlyTopLevel","setAttributes","selectId","query","per_page","hide_empty","context","parent","records","categories","isResolving","getCategoriesList","parentId","length","filter","getCategoryListClassName","level","toggleAttribute","attributeName","newValue","renderCategoryName","name","trim","renderCategoryList","categoriesList","map","category","renderCategoryListItem","childCategories","id","link","count","childCategory","renderCategoryDropdown","renderCategoryDropdownItem","pin"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAce,SAASA,cAAT,OAQX;AAAA,MARoC;AACvCC,IAAAA,UAAU,EAAE;AACXC,MAAAA,iBADW;AAEXC,MAAAA,aAFW;AAGXC,MAAAA,cAHW;AAIXC,MAAAA;AAJW,KAD2B;AAOvCC,IAAAA;AAPuC,GAQpC;AACH,QAAMC,QAAQ,GAAG,4BAAeP,cAAf,EAA+B,wBAA/B,CAAjB;AACA,QAAMQ,KAAK,GAAG;AAAEC,IAAAA,QAAQ,EAAE,CAAC,CAAb;AAAgBC,IAAAA,UAAU,EAAE,IAA5B;AAAkCC,IAAAA,OAAO,EAAE;AAA3C,G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X;AAGC,IAAA,QAAQ,EAAGmB,eAAe,CAAE,eAAF;AAH3B,IAjBF,CADD,CADD,EA2BGP,WAAW,IACZ,4BAAC,uBAAD;AAAa,IAAA,IAAI,EAAGyB,UAApB;AAA0B,IAAA,KAAK,EAAG,cAAI,YAAJ;AAAlC,KACC,4BAAC,mBAAD,OADD,CA5BF,EAgCG,CAAEzB,WAAF,IAAiB,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,MAAuB,CAAxC,IACD,uCACG,cACD,uFADC,CADH,CAjCF,EAuCG,CAAEH,WAAF,IACD,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,IAAqB,CADpB,KAEChB,iBAAiB,GAChBoC,sBAAsB,EADN,GAEhBV,kBAAkB,EAJpB,CAvCH,CADD;AA+CA","sourcesContent":["/**\n * External dependencies\n */\nimport { times, unescape } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { __experimentalUseEntityRecords as useEntityRecords } from '@wordpress/core-data';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t},\n\tsetAttributes,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\tconst query = { per_page: -1, hide_empty: true, context: 'view' };\n\tif ( showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\t'category',\n\t\tquery\n\t);\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\tconst getCategoryListClassName = ( level ) => {\n\t\treturn `wp-block-categories__list wp-block-categories__list-level-${ level }`;\n\t};\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : unescape( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<ul className={ getCategoryListClassName( 0 ) }>\n\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\trenderCategoryListItem( category, 0 )\n\t\t\t\t) }\n\t\t\t</ul>\n\t\t);\n\t};\n\tconst renderCategoryListItem = ( category, level ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id }>\n\t\t\t\t<a href={ link } target=\"_blank\" rel=\"noreferrer noopener\">\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && (\n\t\t\t\t\t<span className=\"wp-block-categories__post-count\">\n\t\t\t\t\t\t{ ` (${ count })` }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ showHierarchy && !! childCategories.length && (\n\t\t\t\t\t<ul className={ getCategoryListClassName( level + 1 ) }>\n\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\trenderCategoryListItem( childCategory, level + 1 )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ul>\n\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t{ __( 'Categories' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<select\n\t\t\t\t\tid={ selectId }\n\t\t\t\t\tclassName=\"wp-block-categories__dropdown\"\n\t\t\t\t>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id }>\n\t\t\t\t{ times( level * 3, () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Categories settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show only top level categories' ) }\n\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showOnlyTopLevel' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Categories' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Your site does not have any posts, so there is nothing to display here at the moment.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/categories/edit.js"],"names":["CategoriesEdit","attributes","displayAsDropdown","showHierarchy","showPostCounts","showOnlyTopLevel","showEmpty","setAttributes","selectId","query","per_page","hide_empty","context","parent","records","categories","isResolving","getCategoriesList","parentId","length","filter","getCategoryListClassName","level","toggleAttribute","attributeName","newValue","renderCategoryName","name","trim","renderCategoryList","categoriesList","map","category","renderCategoryListItem","childCategories","id","link","count","childCategory","renderCategoryDropdown","renderCategoryDropdownItem","pin"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAce,SAASA,cAAT,OASX;AAAA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BAAJ,CADT;AAEC,IAAA,OAAO,EAAGnB,cAFX;AAGC,IAAA,QAAQ,EAAGmB,eAAe,CAAE,gBAAF;AAH3B,IAND,EAWC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,gCAAJ,CADT;AAEC,IAAA,OAAO,EAAGlB,gBAFX;AAGC,IAAA,QAAQ,EAAGkB,eAAe,CAAE,kBAAF;AAH3B,IAXD,EAgBC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,uBAAJ,CADT;AAEC,IAAA,OAAO,EAAGjB,SAFX;AAGC,IAAA,QAAQ,EAAGiB,eAAe,CAAE,WAAF;AAH3B,IAhBD,EAqBG,CAAElB,gBAAF,IACD,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,OAAO,EAAGF,aAFX;AAGC,IAAA,QAAQ,EAAGoB,eAAe,CAAE,eAAF;AAH3B,IAtBF,CADD,CADD,EAgCGP,WAAW,IACZ,4BAAC,uBAAD;AAAa,IAAA,IAAI,EAAGyB,UAApB;AAA0B,IAAA,KAAK,EAAG,cAAI,YAAJ;AAAlC,KACC,4BAAC,mBAAD,OADD,CAjCF,EAqCG,CAAEzB,WAAF,IAAiB,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,MAAuB,CAAxC,IACD,uCACG,cACD,uFADC,CADH,CAtCF,EA4CG,CAAEH,WAAF,IACD,CAAAD,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEI,MAAZ,IAAqB,CADpB,KAECjB,iBAAiB,GAChBqC,sBAAsB,EADN,GAEhBV,kBAAkB,EAJpB,CA5CH,CADD;AAoDA","sourcesContent":["/**\n * External dependencies\n */\nimport { times, unescape } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { __experimentalUseEntityRecords as useEntityRecords } from '@wordpress/core-data';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t\tshowEmpty,\n\t},\n\tsetAttributes,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\tconst query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };\n\tif ( showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\t'category',\n\t\tquery\n\t);\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\tconst getCategoryListClassName = ( level ) => {\n\t\treturn `wp-block-categories__list wp-block-categories__list-level-${ level }`;\n\t};\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : unescape( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<ul className={ getCategoryListClassName( 0 ) }>\n\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\trenderCategoryListItem( category, 0 )\n\t\t\t\t) }\n\t\t\t</ul>\n\t\t);\n\t};\n\tconst renderCategoryListItem = ( category, level ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id }>\n\t\t\t\t<a href={ link } target=\"_blank\" rel=\"noreferrer noopener\">\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && (\n\t\t\t\t\t<span className=\"wp-block-categories__post-count\">\n\t\t\t\t\t\t{ ` (${ count })` }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ showHierarchy && !! childCategories.length && (\n\t\t\t\t\t<ul className={ getCategoryListClassName( level + 1 ) }>\n\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\trenderCategoryListItem( childCategory, level + 1 )\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ul>\n\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t{ __( 'Categories' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<select\n\t\t\t\t\tid={ selectId }\n\t\t\t\t\tclassName=\"wp-block-categories__dropdown\"\n\t\t\t\t>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id }>\n\t\t\t\t{ times( level * 3, () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show only top level categories' ) }\n\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showOnlyTopLevel' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show empty categories' ) }\n\t\t\t\t\t\tchecked={ showEmpty }\n\t\t\t\t\t\tonChange={ toggleAttribute( 'showEmpty' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Categories' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Your site does not have any posts, so there is nothing to display here at the moment.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/categories/index.js"],"names":["name","metadata","settings","icon","example","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/categories/index.js"],"names":["name","metadata","settings","icon","example","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,eADuB;AAEvBC,EAAAA,OAAO,EAAE,EAFc;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { category as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {},\n\tedit,\n};\n"]}
|
package/build/column/index.js
CHANGED
|
@@ -65,6 +65,16 @@ const metadata = {
|
|
|
65
65
|
padding: true
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
+
__experimentalBorder: {
|
|
69
|
+
color: true,
|
|
70
|
+
style: true,
|
|
71
|
+
width: true,
|
|
72
|
+
__experimentalDefaultControls: {
|
|
73
|
+
color: true,
|
|
74
|
+
style: true,
|
|
75
|
+
width: true
|
|
76
|
+
}
|
|
77
|
+
},
|
|
68
78
|
__experimentalLayout: true
|
|
69
79
|
}
|
|
70
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/column/index.js"],"names":["name","metadata","settings","icon","edit","save","deprecated"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAEA;;AAXA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/column/index.js"],"names":["name","metadata","settings","icon","edit","save","deprecated"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAEA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA,aAHuB;AAIvBC,EAAAA,UAAU,EAAVA;AAJuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { column as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
|
|
@@ -275,7 +275,9 @@ function CommentTemplateEdit(_ref6) {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
if (!commentTree.length) {
|
|
278
|
-
return (0, _element.createElement)("p",
|
|
278
|
+
return (0, _element.createElement)("p", (0, _extends2.default)({}, blockProps, {
|
|
279
|
+
"data-testid": "noresults"
|
|
280
|
+
}), (0, _i18n.__)('No results found.'));
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
return (0, _element.createElement)(CommentsList, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAIxB;AAAA,MAJ0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,cAFgC;AAGhCC,IAAAA;AAHgC,GAI1B;AACN;AACA;AACA;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,GAAL,CAAUH,mBAAmB,IAAI,CAAjC,EAAoC,CAApC,CAAtB,CAJM,CAMN;;AACA,QAAMI,qBAAqB,GAC1BN,OAAO,IAAIG,aAAX,GAA2BH,OAA3B,GAAqCG,aADtC;;AAEA,MAAK,CAAEF,cAAF,IAAoBK,qBAAqB,KAAK,CAAnD,EAAuD;AACtD;AAC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IAAA,cAAc,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBvC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAIxB;AAAA,MAJ0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,cAFgC;AAGhCC,IAAAA;AAHgC,GAI1B;AACN;AACA;AACA;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,GAAL,CAAUH,mBAAmB,IAAI,CAAjC,EAAoC,CAApC,CAAtB,CAJM,CAMN;;AACA,QAAMI,qBAAqB,GAC1BN,OAAO,IAAIG,aAAX,GAA2BH,OAA3B,GAAqCG,aADtC;;AAEA,MAAK,CAAEF,cAAF,IAAoBK,qBAAqB,KAAK,CAAnD,EAAuD;AACtD;AACA;AACA,WAAO,CAAE;AAAEC,MAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,MAAAA,QAAQ,EAAE;AAA3B,KAAF,CAAP;AACA,GAJD,MAIO,IAAKF,qBAAqB,KAAK,CAA/B,EAAmC;AACzC,WAAO,CACN;AACCC,MAAAA,SAAS,EAAE,CAAC,CADb;AAECC,MAAAA,QAAQ,EAAE,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CAA5B;AACA,WAAO;AACN;AACAG,MAAAA,gBAAgB,EAAED,YAAY,GAC3BE,gBAAgB,CAAE,MAAF,EAAU,SAAV,EAAqBF,YAArB,CADW,GAE3B,IAJG;AAKN3B,MAAAA,MAAM,EAAE+B,SAAS,CAAEb,QAAF;AALX,KAAP;AAOA,GAXmC,EAYpC,CAAEA,QAAF,EAAYS,YAAZ,CAZoC,CAArC,CAlBG,CAiCH;;AACA,MAAIK,WAAW,GAAG,4BACjB;AACAX,EAAAA,YAAY,KAAK,MAAjB,IAA2BO,gBAA3B,GACG,CAAE,GAAGA,gBAAL,EAAwBK,OAAxB,EADH,GAEGL,gBAJc,CAAlB;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,iCAAQd,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfY,IAAAA,WAAW,GAAG/C,sBAAsB,CAAE;AACrCC,MAAAA,OAAO,EAAEoC,eAD4B;AAErCnC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE4C,WAAW,CAAC7B,MAAnB,EAA4B;AAC3B,WACC,4DAAQW,UAAR;AAAqB,qBAAY;AAAjC,QACG,cAAI,mBAAJ,CADH,CADD;AAKA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGkB,WADZ;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBvC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn (\n\t\t\t<p { ...blockProps } data-testid=\"noresults\">\n\t\t\t\t{ __( 'No results found.' ) }\n\t\t\t</p>\n\t\t);\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -20,7 +20,8 @@ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
|
20
20
|
/**
|
|
21
21
|
* WordPress dependencies
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
// This is limited by WP REST API
|
|
24
|
+
const MAX_COMMENTS_PER_PAGE = 100;
|
|
24
25
|
/**
|
|
25
26
|
* Return an object with the query args needed to fetch the default page of
|
|
26
27
|
* comments.
|
|
@@ -31,6 +32,7 @@ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
|
31
32
|
*
|
|
32
33
|
* @return {Object} Query args to retrieve the comments.
|
|
33
34
|
*/
|
|
35
|
+
|
|
34
36
|
const useCommentQueryArgs = _ref => {
|
|
35
37
|
let {
|
|
36
38
|
postId
|
|
@@ -45,7 +47,8 @@ const useCommentQueryArgs = _ref => {
|
|
|
45
47
|
}; // Get the Discussion settings that may be needed to query the comments.
|
|
46
48
|
|
|
47
49
|
const {
|
|
48
|
-
|
|
50
|
+
pageComments,
|
|
51
|
+
commentsPerPage,
|
|
49
52
|
defaultCommentsPage: defaultPage
|
|
50
53
|
} = (0, _data.useSelect)(select => {
|
|
51
54
|
const {
|
|
@@ -55,7 +58,12 @@ const useCommentQueryArgs = _ref => {
|
|
|
55
58
|
__experimentalDiscussionSettings
|
|
56
59
|
} = getSettings();
|
|
57
60
|
return __experimentalDiscussionSettings;
|
|
58
|
-
}); //
|
|
61
|
+
}); // WP REST API doesn't allow fetching more than max items limit set per single page of data.
|
|
62
|
+
// As for the editor performance is more important than completeness of data and fetching only the
|
|
63
|
+
// max allowed for single page should be enough for the purpose of design and laying out the page.
|
|
64
|
+
// Fetching over the limit would return an error here but would work with backend query.
|
|
65
|
+
|
|
66
|
+
const perPage = pageComments ? Math.min(commentsPerPage, MAX_COMMENTS_PER_PAGE) : MAX_COMMENTS_PER_PAGE; // Get the number of the default page.
|
|
59
67
|
|
|
60
68
|
const page = useDefaultPageIndex({
|
|
61
69
|
defaultPage,
|
|
@@ -119,8 +127,10 @@ const useDefaultPageIndex = _ref2 => {
|
|
|
119
127
|
method: 'HEAD',
|
|
120
128
|
parse: false
|
|
121
129
|
}).then(res => {
|
|
130
|
+
const pages = parseInt(res.headers.get('X-WP-TotalPages'));
|
|
122
131
|
setDefaultPages({ ...defaultPages,
|
|
123
|
-
[key]:
|
|
132
|
+
[key]: pages <= 1 ? 1 : pages // If there are 0 pages, it means that there are no comments, but there is no 0th page.
|
|
133
|
+
|
|
124
134
|
});
|
|
125
135
|
});
|
|
126
136
|
}, [defaultPage, postId, perPage, setDefaultPages]); // The oldest one is always the first one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["MAX_COMMENTS_PER_PAGE","useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","pageComments","commentsPerPage","defaultCommentsPage","defaultPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","perPage","Math","min","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","pages","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAPA;AACA;AACA;AAOA;AACA,MAAMA,qBAAqB,GAAG,GAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,mBAAmB,GAAG,QAAkB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACpD;AACA,QAAMC,SAAS,GAAG;AACjBC,IAAAA,MAAM,EAAE,SADS;AAEjBC,IAAAA,KAAK,EAAE,KAFU;AAGjBC,IAAAA,OAAO,EAAE,OAHQ;AAIjBC,IAAAA,MAAM,EAAE,CAJS;AAKjBC,IAAAA,MAAM,EAAE;AALS,GAAlB,CAFoD,CAUpD;;AACA,QAAM;AACLC,IAAAA,YADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA,mBAAmB,EAAEC;AAHhB,MAIF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAuCF,WAAW,EAAxD;AACA,WAAOE,gCAAP;AACA,GAJG,CAJJ,CAXoD,CAqBpD;AACA;AACA;AACA;;AACA,QAAMC,OAA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encies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n// This is limited by WP REST API\nconst MAX_COMMENTS_PER_PAGE = 100;\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( { postId } ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst {\n\t\tpageComments,\n\t\tcommentsPerPage,\n\t\tdefaultCommentsPage: defaultPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// WP REST API doesn't allow fetching more than max items limit set per single page of data.\n\t// As for the editor performance is more important than completeness of data and fetching only the\n\t// max allowed for single page should be enough for the purpose of design and laying out the page.\n\t// Fetching over the limit would return an error here but would work with backend query.\n\tconst perPage = pageComments\n\t\t? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )\n\t\t: MAX_COMMENTS_PER_PAGE;\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tconst pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"]}
|
|
@@ -64,7 +64,24 @@ function QueryPaginationEdit(_ref) {
|
|
|
64
64
|
template: TEMPLATE,
|
|
65
65
|
allowedBlocks: ['core/comments-pagination-previous', 'core/comments-pagination-numbers', 'core/comments-pagination-next'],
|
|
66
66
|
__experimentalLayout: usedLayout
|
|
67
|
-
});
|
|
67
|
+
}); // Get the Discussion settings
|
|
68
|
+
|
|
69
|
+
const pageComments = (0, _data.useSelect)(select => {
|
|
70
|
+
const {
|
|
71
|
+
getSettings
|
|
72
|
+
} = select(_blockEditor.store);
|
|
73
|
+
const {
|
|
74
|
+
__experimentalDiscussionSettings
|
|
75
|
+
} = getSettings();
|
|
76
|
+
return __experimentalDiscussionSettings === null || __experimentalDiscussionSettings === void 0 ? void 0 : __experimentalDiscussionSettings.pageComments;
|
|
77
|
+
}, []); // If paging comments is not enabled in the Discussion Settings then hide the pagination
|
|
78
|
+
// controls. We don't want to remove them from the template so that when the user enables
|
|
79
|
+
// paging comments, the controls will be visible.
|
|
80
|
+
|
|
81
|
+
if (!pageComments) {
|
|
82
|
+
return (0, _element.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Comments Pagination block: paging comments is disabled in the Discussion Settings'));
|
|
83
|
+
}
|
|
84
|
+
|
|
68
85
|
return (0, _element.createElement)(_element.Fragment, null, hasNextPreviousBlocks && (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
69
86
|
title: (0, _i18n.__)('Settings')
|
|
70
87
|
}, (0, _element.createElement)(_commentsPaginationArrowControls.CommentsPaginationArrowControls, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-pagination/edit.js"],"names":["TEMPLATE","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","QueryPaginationEdit","attributes","paginationArrow","layout","setAttributes","clientId","name","usedLayout","hasNextPreviousBlocks","select","getBlocks","blockEditorStore","innerBlocks","find","innerBlock","includes","blockProps","innerBlocksProps","template","allowedBlocks","__experimentalLayout","value"],"mappings":";;;;;;;;;AAGA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-pagination/edit.js"],"names":["TEMPLATE","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","QueryPaginationEdit","attributes","paginationArrow","layout","setAttributes","clientId","name","usedLayout","hasNextPreviousBlocks","select","getBlocks","blockEditorStore","innerBlocks","find","innerBlock","includes","blockProps","innerBlocksProps","template","allowedBlocks","__experimentalLayout","pageComments","getSettings","__experimentalDiscussionSettings","value"],"mappings":";;;;;;;;;AAGA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,mCAAF,CADgB,EAEhB,CAAE,kCAAF,CAFgB,EAGhB,CAAE,+BAAF,CAHgB,CAAjB;;AAMA,MAAMC,qBAAqB,GAAKC,eAAF,IAAuB;AACpD,QAAMC,wBAAwB,GAAG,6BAChCD,eADgC,EAEhC,sBAFgC,CAAjC;AAIA,SAAOC,wBAAP,aAAOA,wBAAP,uBAAOA,wBAAwB,CAAEC,OAAjC;AACA,CAND;;AAQe,SAASC,mBAAT,OAKX;AAAA,MALyC;AAC5CC,IAAAA,UAAU,EAAE;AAAEC,MAAAA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AAED,SACC,qDACGb,qBAAqB,IACtB,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,UAAJ;AAAnB,KACC,4BAAC,gEAAD;AACC,IAAA,KAAK,EAAGN,eADT;AAEC,IAAA,QAAQ,EAAKsB,KAAF,IAAa;AACvBpB,MAAAA,aAAa,CAAE;AAAEF,QAAAA,eAAe,EAAEsB;AAAnB,OAAF,CAAb;AACA;AAJF,IADD,CADD,CAFF,EAaC,mCAAUP,gBAAV,CAbD,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { PanelBody } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { CommentsPaginationArrowControls } from './comments-pagination-arrow-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comments-pagination-previous' ],\n\t[ 'core/comments-pagination-numbers' ],\n\t[ 'core/comments-pagination-next' ],\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport default function QueryPaginationEdit( {\n\tattributes: { paginationArrow, layout },\n\tsetAttributes,\n\tclientId,\n\tname,\n} ) {\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\tconst hasNextPreviousBlocks = useSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst innerBlocks = getBlocks( clientId );\n\t\t/**\n\t\t * Show the `paginationArrow` control only if a\n\t\t * Comments Pagination Next or Comments Pagination Previous\n\t\t * block exists.\n\t\t */\n\t\treturn innerBlocks?.find( ( innerBlock ) => {\n\t\t\treturn [\n\t\t\t\t'core/comments-pagination-previous',\n\t\t\t\t'core/comments-pagination-next',\n\t\t\t].includes( innerBlock.name );\n\t\t} );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\tallowedBlocks: [\n\t\t\t'core/comments-pagination-previous',\n\t\t\t'core/comments-pagination-numbers',\n\t\t\t'core/comments-pagination-next',\n\t\t],\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\t// Get the Discussion settings\n\tconst pageComments = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings?.pageComments;\n\t}, [] );\n\n\t// If paging comments is not enabled in the Discussion Settings then hide the pagination\n\t// controls. We don't want to remove them from the template so that when the user enables\n\t// paging comments, the controls will be visible.\n\tif ( ! pageComments ) {\n\t\treturn (\n\t\t\t<Warning>\n\t\t\t\t{ __(\n\t\t\t\t\t'Comments Pagination block: paging comments is disabled in the Discussion Settings'\n\t\t\t\t) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ hasNextPreviousBlocks && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t<CommentsPaginationArrowControls\n\t\t\t\t\t\t\tvalue={ paginationArrow }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { paginationArrow: value } );\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<div { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -20,7 +20,7 @@ var _commentsInspectorControls = _interopRequireDefault(require("./edit/comments
|
|
|
20
20
|
/**
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
|
-
const TEMPLATE = [['core/comment-template', {}, [['core/columns', {}, [['core/column', {
|
|
23
|
+
const TEMPLATE = [['core/comments-title'], ['core/comment-template', {}, [['core/columns', {}, [['core/column', {
|
|
24
24
|
width: '40px'
|
|
25
25
|
}, [['core/avatar', {
|
|
26
26
|
size: 40,
|