@wordpress/block-library 7.16.0 → 7.17.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 -1
- package/build/archives/edit.js +1 -0
- package/build/archives/edit.js.map +1 -1
- package/build/comment-template/edit.js +40 -32
- package/build/comment-template/edit.js.map +1 -1
- package/build/comments/edit/placeholder.js +1 -4
- package/build/comments/edit/placeholder.js.map +1 -1
- package/build/comments/index.js +5 -1
- package/build/comments/index.js.map +1 -1
- package/build/comments-title/edit.js +18 -1
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit/index.js +2 -2
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/use-cover-is-dark.js +8 -7
- package/build/cover/edit/use-cover-is-dark.js.map +1 -1
- package/build/embed/variations.js +1 -1
- package/build/embed/variations.js.map +1 -1
- package/build/gallery/transforms.js +3 -3
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/v1/edit.js +1 -1
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/image/image.js +34 -10
- package/build/image/image.js.map +1 -1
- package/build/image/transforms.js +1 -7
- package/build/image/transforms.js.map +1 -1
- package/build/list/transforms.js +9 -1
- package/build/list/transforms.js.map +1 -1
- package/build/list-item/edit.js +3 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +3 -2
- package/build/list-item/edit.native.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +19 -22
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +19 -3
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/index.js +14 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +14 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/navigation/edit/index.js +35 -22
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +3 -5
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/index.js +4 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation-link/edit.js +1 -1
- package/build/navigation-link/edit.js.map +1 -1
- package/build/page-list/index.js +1 -5
- package/build/page-list/index.js.map +1 -1
- package/build/paragraph/edit.js +3 -11
- package/build/paragraph/edit.js.map +1 -1
- package/build/pattern/edit.js +11 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/post-comments-form/form.js +1 -2
- package/build/post-comments-form/form.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -2
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -104
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/search/edit.js +2 -1
- package/build/search/edit.js.map +1 -1
- package/build/site-logo/edit.js +6 -9
- package/build/site-logo/edit.js.map +1 -1
- package/build/table/state.js +1 -1
- package/build/table/state.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -4
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/tag-cloud/index.js +8 -0
- package/build/tag-cloud/index.js.map +1 -1
- package/build-module/archives/edit.js +1 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +38 -30
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comments/edit/placeholder.js +1 -3
- package/build-module/comments/edit/placeholder.js.map +1 -1
- package/build-module/comments/index.js +5 -1
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments-title/edit.js +18 -2
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/use-cover-is-dark.js +7 -7
- package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
- package/build-module/embed/variations.js +1 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/gallery/transforms.js +4 -4
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/v1/edit.js +2 -2
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/image/image.js +35 -11
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/transforms.js +1 -6
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/list/transforms.js +9 -1
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +3 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +3 -2
- package/build-module/list-item/edit.native.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +19 -21
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +19 -3
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/index.js +14 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +14 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/navigation/edit/index.js +35 -22
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +3 -5
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/index.js +4 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +1 -1
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/page-list/index.js +1 -5
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -10
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/pattern/edit.js +10 -3
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +2 -3
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -102
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/search/edit.js +3 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +6 -9
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/table/state.js +2 -2
- package/build-module/table/state.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -3
- package/build-module/table-of-contents/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/tag-cloud/index.js +8 -0
- package/build-module/tag-cloud/index.js.map +1 -1
- package/build-style/archives/style-rtl.css +4 -0
- package/build-style/archives/style.css +4 -0
- package/build-style/comments/editor-rtl.css +1 -0
- package/build-style/comments/editor.css +1 -0
- package/build-style/comments/style-rtl.css +1 -0
- package/build-style/comments/style.css +1 -0
- package/build-style/cover/editor-rtl.css +4 -0
- package/build-style/cover/editor.css +4 -0
- package/build-style/editor-rtl.css +9 -17
- package/build-style/editor.css +9 -17
- package/build-style/group/editor-rtl.css +1 -0
- package/build-style/group/editor.css +1 -0
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/navigation/editor-rtl.css +1 -0
- package/build-style/navigation/editor.css +1 -0
- package/build-style/paragraph/editor-rtl.css +0 -16
- package/build-style/paragraph/editor.css +0 -16
- package/build-style/site-logo/editor-rtl.css +1 -0
- package/build-style/site-logo/editor.css +1 -0
- package/build-style/style-rtl.css +8 -0
- package/build-style/style.css +8 -0
- package/build-style/tag-cloud/style-rtl.css +3 -0
- package/build-style/tag-cloud/style.css +3 -0
- package/package.json +28 -28
- package/src/archives/edit.js +1 -0
- package/src/archives/style.scss +5 -0
- package/src/avatar/index.php +1 -1
- package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
- package/src/code/test/edit.native.js +46 -32
- package/src/comment-template/edit.js +47 -34
- package/src/comments/block.json +5 -1
- package/src/comments/edit/placeholder.js +1 -7
- package/src/comments/style.scss +2 -0
- package/src/comments-title/edit.js +24 -1
- package/src/cover/edit/index.js +2 -7
- package/src/cover/edit/use-cover-is-dark.js +11 -11
- package/src/cover/editor.scss +7 -0
- package/src/embed/variations.js +1 -1
- package/src/gallery/transforms.js +8 -5
- package/src/gallery/v1/edit.js +2 -2
- package/src/group/editor.scss +1 -0
- package/src/image/editor.scss +4 -1
- package/src/image/image.js +59 -29
- package/src/image/transforms.js +1 -7
- package/src/list/test/edit.native.js +102 -3
- package/src/list/transforms.js +11 -0
- package/src/list-item/block.json +14 -1
- package/src/list-item/edit.js +2 -1
- package/src/list-item/edit.native.js +2 -1
- package/src/list-item/hooks/use-merge.js +4 -23
- package/src/list-item/hooks/use-outdent-list-item.js +6 -2
- package/src/navigation/block.json +4 -1
- package/src/navigation/edit/index.js +49 -23
- package/src/navigation/edit/inner-blocks.js +2 -5
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
- package/src/navigation/edit/use-create-navigation-menu.js +2 -5
- package/src/navigation/editor.scss +1 -0
- package/src/navigation/index.php +103 -6
- package/src/navigation-link/edit.js +1 -1
- package/src/navigation-link/index.php +8 -1
- package/src/navigation-submenu/index.php +8 -1
- package/src/page-list/block.json +1 -5
- package/src/page-list/index.php +8 -6
- package/src/paragraph/edit.js +1 -14
- package/src/paragraph/editor.scss +0 -20
- package/src/pattern/edit.js +10 -3
- package/src/post-comments-form/form.js +2 -3
- package/src/query/edit/inspector-controls/index.js +4 -3
- package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -87
- package/src/rss/index.php +3 -3
- package/src/search/edit.js +6 -1
- package/src/search/index.php +21 -13
- package/src/site-logo/edit.js +10 -8
- package/src/site-logo/editor.scss +1 -0
- package/src/table/state.js +2 -2
- package/src/table-of-contents/edit.js +1 -3
- package/src/tag-cloud/block.json +8 -0
- package/src/tag-cloud/edit.js +1 -1
- package/src/tag-cloud/style.scss +3 -0
- package/src/template-part/index.php +4 -0
- package/build/paragraph/drop-zone.js +0 -99
- package/build/paragraph/drop-zone.js.map +0 -1
- package/build-module/paragraph/drop-zone.js +0 -88
- package/build-module/paragraph/drop-zone.js.map +0 -1
- package/src/paragraph/drop-zone.js +0 -105
package/build/tag-cloud/index.js
CHANGED
|
@@ -68,6 +68,14 @@ const metadata = {
|
|
|
68
68
|
spacing: {
|
|
69
69
|
margin: true,
|
|
70
70
|
padding: true
|
|
71
|
+
},
|
|
72
|
+
typography: {
|
|
73
|
+
lineHeight: true,
|
|
74
|
+
__experimentalFontFamily: true,
|
|
75
|
+
__experimentalFontWeight: true,
|
|
76
|
+
__experimentalFontStyle: true,
|
|
77
|
+
__experimentalTextTransform: true,
|
|
78
|
+
__experimentalLetterSpacing: true
|
|
71
79
|
}
|
|
72
80
|
},
|
|
73
81
|
editorStyle: "wp-block-tag-cloud-editor"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/tag-cloud/index.js"],"names":["name","metadata","settings","icon","example","edit","transforms","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAEA;;AAXA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/tag-cloud/index.js"],"names":["name","metadata","settings","icon","example","edit","transforms","init"],"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,UADuB;AAEvBC,EAAAA,OAAO,EAAE,EAFc;AAGvBC,EAAAA,IAAI,EAAJA,aAHuB;AAIvBC,EAAAA,UAAU,EAAVA;AAJuB,CAAjB;;;AAOA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEP,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { tag as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport transforms from './transforms';\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\ttransforms,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -59,6 +59,7 @@ export default function ArchivesEdit(_ref) {
|
|
|
59
59
|
})
|
|
60
60
|
}))), createElement("div", useBlockProps(), createElement(Disabled, null, createElement(ServerSideRender, {
|
|
61
61
|
block: "core/archives",
|
|
62
|
+
skipBlockSupportAttributes: true,
|
|
62
63
|
attributes: attributes
|
|
63
64
|
}))));
|
|
64
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/archives/edit.js"],"names":["PanelBody","ToggleControl","SelectControl","Disabled","__","InspectorControls","useBlockProps","ServerSideRender","ArchivesEdit","attributes","setAttributes","showLabel","showPostCounts","displayAsDropdown","type","label","value"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,QAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,yBAAjD;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AAEA,eAAe,SAASC,YAAT,OAAuD;AAAA,MAAhC;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E;AAA9B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAEX,EAAE,CAAE,KAAF,CAAX;AAAsBY,MAAAA,KAAK,EAAE;AAA7B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAGF,IART;AASC,IAAA,QAAQ,EAAKE,KAAF,IACVN,aAAa,CAAE;AAAEI,MAAAA,IAAI,EAAEE;AAAR,KAAF;AAVf,IA9BD,CADD,CADD,EA+CC,qBAAUV,aAAa,EAAvB,EACC,cAAC,QAAD,QACC,cAAC,gBAAD;AACC,IAAA,KAAK,EAAC,eADP;AAEC,IAAA,UAAU,EAAGG;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/archives/edit.js"],"names":["PanelBody","ToggleControl","SelectControl","Disabled","__","InspectorControls","useBlockProps","ServerSideRender","ArchivesEdit","attributes","setAttributes","showLabel","showPostCounts","displayAsDropdown","type","label","value"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,QAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,EAA4BC,aAA5B,QAAiD,yBAAjD;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AAEA,eAAe,SAASC,YAAT,OAAuD;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AACrE,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,cAAb;AAA6BC,IAAAA,iBAA7B;AAAgDC,IAAAA;AAAhD,MAAyDL,UAA/D;AAEA,SACC,8BACC,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGL,EAAE,CAAE,UAAF;AAArB,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGA,EAAE,CAAE,qBAAF,CADX;AAEC,IAAA,OAAO,EAAGS,iBAFX;AAGC,IAAA,QAAQ,EAAG,MACVH,aAAa,CAAE;AACdG,MAAAA,iBAAiB,EAAE,CAAE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A2DA","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 { showLabel, 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{ displayAsDropdown && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowLabel: ! showLabel,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\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\tskipBlockSupportAttributes\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"]}
|
|
@@ -25,6 +25,7 @@ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-
|
|
|
25
25
|
*
|
|
26
26
|
* @param {Object} settings Discussion Settings.
|
|
27
27
|
* @param {number} [settings.perPage] - Comments per page setting or block attribute.
|
|
28
|
+
* @param {boolean} [settings.pageComments] - Enable break comments into pages setting.
|
|
28
29
|
* @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
|
|
29
30
|
* @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.
|
|
30
31
|
*
|
|
@@ -35,44 +36,49 @@ const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-
|
|
|
35
36
|
const getCommentsPlaceholder = _ref => {
|
|
36
37
|
let {
|
|
37
38
|
perPage,
|
|
39
|
+
pageComments,
|
|
38
40
|
threadComments,
|
|
39
41
|
threadCommentsDepth
|
|
40
42
|
} = _ref;
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
// In case that the value is set but larger than 3 we truncate it to 3.
|
|
44
|
-
const commentsDepth = Math.min(threadCommentsDepth || 3, 3); // We set a limit in order not to overload the editor of empty comments.
|
|
43
|
+
// Limit commentsDepth to 3
|
|
44
|
+
const commentsDepth = !threadComments ? 1 : Math.min(threadCommentsDepth, 3);
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const buildChildrenComment = commentsLevel => {
|
|
47
|
+
// Render children comments until commentsDepth is reached
|
|
48
|
+
if (commentsLevel < commentsDepth) {
|
|
49
|
+
const nextLevel = commentsLevel + 1;
|
|
50
|
+
return [{
|
|
51
|
+
commentId: -(commentsLevel + 3),
|
|
52
|
+
children: buildChildrenComment(nextLevel)
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// A commentId is negative in order to avoid conflicts with the actual comments.
|
|
51
|
-
return [{
|
|
52
|
-
commentId: -1,
|
|
53
|
-
children: []
|
|
54
|
-
}];
|
|
55
|
-
} else if (defaultCommentsToShow === 2) {
|
|
56
|
-
return [{
|
|
57
|
-
commentId: -1,
|
|
58
|
-
children: [{
|
|
59
|
-
commentId: -2,
|
|
60
|
-
children: []
|
|
61
|
-
}]
|
|
62
|
-
}];
|
|
63
|
-
} // In case that the value is set but larger than 3 we truncate it to 3.
|
|
56
|
+
return [];
|
|
57
|
+
}; // Add the first comment and its children
|
|
64
58
|
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
const placeholderComments = [{
|
|
67
61
|
commentId: -1,
|
|
68
|
-
children:
|
|
62
|
+
children: buildChildrenComment(1)
|
|
63
|
+
}]; // Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max
|
|
64
|
+
|
|
65
|
+
if ((!pageComments || perPage >= 2) && commentsDepth < 3) {
|
|
66
|
+
placeholderComments.push({
|
|
69
67
|
commentId: -2,
|
|
70
|
-
children: [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
children: []
|
|
69
|
+
});
|
|
70
|
+
} // Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if ((!pageComments || perPage >= 3) && commentsDepth < 2) {
|
|
74
|
+
placeholderComments.push({
|
|
75
|
+
commentId: -3,
|
|
76
|
+
children: []
|
|
77
|
+
});
|
|
78
|
+
} // In case that the value is set but larger than 3 we truncate it to 3.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
return placeholderComments;
|
|
76
82
|
};
|
|
77
83
|
/**
|
|
78
84
|
* Component which renders the inner blocks of the Comment Template.
|
|
@@ -217,7 +223,8 @@ export default function CommentTemplateEdit(_ref6) {
|
|
|
217
223
|
commentOrder,
|
|
218
224
|
threadCommentsDepth,
|
|
219
225
|
threadComments,
|
|
220
|
-
commentsPerPage
|
|
226
|
+
commentsPerPage,
|
|
227
|
+
pageComments
|
|
221
228
|
} = useSelect(select => {
|
|
222
229
|
const {
|
|
223
230
|
getSettings
|
|
@@ -254,6 +261,7 @@ export default function CommentTemplateEdit(_ref6) {
|
|
|
254
261
|
if (!postId) {
|
|
255
262
|
commentTree = getCommentsPlaceholder({
|
|
256
263
|
perPage: commentsPerPage,
|
|
264
|
+
pageComments,
|
|
257
265
|
threadComments,
|
|
258
266
|
threadCommentsDepth
|
|
259
267
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["useState","memo","useSelect","__","BlockContextProvider","useBlockProps","useInnerBlocksProps","store","blockEditorStore","__experimentalUseBlockPreview","useBlockPreview","Spinner","coreStore","useCommentQueryArgs","useCommentTree","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","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","getBlocks","commentTree","reverse"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,oBAA/B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,oBADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,KAAK,IAAIC,gBAJV,EAKCC,6BAA6B,IAAIC,eALlC,QAMO,yBANP;AAOA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,EAA8BC,cAA9B,QAAoD,SAApD;AAEA,MAAMC,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,SA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eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGgC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBrC;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 <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":["useState","memo","useSelect","__","BlockContextProvider","useBlockProps","useInnerBlocksProps","store","blockEditorStore","__experimentalUseBlockPreview","useBlockPreview","Spinner","coreStore","useCommentQueryArgs","useCommentTree","TEMPLATE","getCommentsPlaceholder","perPage","pageComments","threadComments","threadCommentsDepth","commentsDepth","Math","min","buildChildrenComment","commentsLevel","nextLevel","commentId","children","placeholderComments","push","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","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","getBlocks","commentTree","reverse"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,IAAnB,QAA+B,oBAA/B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,oBADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,KAAK,IAAIC,gBAJV,EAKCC,6BAA6B,IAAIC,eALlC,QAMO,yBANP;AAOA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,EAA8BC,cAA9B,QAAoD,SAApD;AAEA,MAAMC,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;;AACA,MAAMC,sBAAsB,GAAG,QAKxB;AAAA,MAL0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,YAFgC;AAGhCC,IAAAA,cAHgC;AAIhCC,IAAAA;AAJgC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,GAEGJ,gBAJ4B,CAAhC;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,mBAAQb,UAAR,EACC,cAAC,OAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfU,IAAAA,WAAW,GAAGlD,sBAAsB,CAAE;AACrCC,MAAAA,OAAO,EAAEyC,eAD4B;AAErCxC,MAAAA,YAFqC;AAGrCC,MAAAA,cAHqC;AAIrCC,MAAAA;AAJqC,KAAF,CAApC;AAMA;;AAED,MAAK,CAAE8C,WAAW,CAAC3B,MAAnB,EAA4B;AAC3B,WAAO,mBAAQW,UAAR,EAAuB/C,EAAE,CAAE,mBAAF,CAAzB,CAAP;AACA;;AAED,SACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAG+D,WADZ;AAEC,IAAA,UAAU,EAAGhB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGgC,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.pageComments] - Enable break comments into pages setting.\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\tpageComments,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// Limit commentsDepth to 3\n\tconst commentsDepth = ! threadComments\n\t\t? 1\n\t\t: Math.min( threadCommentsDepth, 3 );\n\n\tconst buildChildrenComment = ( commentsLevel ) => {\n\t\t// Render children comments until commentsDepth is reached\n\t\tif ( commentsLevel < commentsDepth ) {\n\t\t\tconst nextLevel = commentsLevel + 1;\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -( commentsLevel + 3 ),\n\t\t\t\t\tchildren: buildChildrenComment( nextLevel ),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t};\n\n\t// Add the first comment and its children\n\tconst placeholderComments = [\n\t\t{ commentId: -1, children: buildChildrenComment( 1 ) },\n\t];\n\n\t// Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max\n\tif ( ( ! pageComments || perPage >= 2 ) && commentsDepth < 3 ) {\n\t\tplaceholderComments.push( {\n\t\t\tcommentId: -2,\n\t\t\tchildren: [],\n\t\t} );\n\t}\n\n\t// Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments\n\tif ( ( ! pageComments || perPage >= 3 ) && commentsDepth < 2 ) {\n\t\tplaceholderComments.push( {\n\t\t\tcommentId: -3,\n\t\t\tchildren: [],\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 placeholderComments;\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\t is ALWAYS rendered and the preview for the active block is hidden.\n\t\t\t This ensures that when switching the active block, the component is not\n\t\t\t mounted again but rather it only toggles the `isHidden` prop.\n\t\t\t The same strategy is used for preventing the flicker in the Post Template\n\t\t\t block. */ }\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\tpageComments,\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\tpageComments,\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"]}
|
|
@@ -7,7 +7,6 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
7
7
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
9
9
|
import { useEntityProp } from '@wordpress/core-data';
|
|
10
|
-
import { useDisabled } from '@wordpress/compose';
|
|
11
10
|
/**
|
|
12
11
|
* Internal dependencies
|
|
13
12
|
*/
|
|
@@ -23,10 +22,9 @@ export default function PostCommentsPlaceholder(_ref) {
|
|
|
23
22
|
const {
|
|
24
23
|
avatarURL
|
|
25
24
|
} = useSelect(select => select(blockEditorStore).getSettings().__experimentalDiscussionSettings);
|
|
26
|
-
const disabledRef = useDisabled();
|
|
27
25
|
return createElement("div", {
|
|
28
26
|
className: "wp-block-comments__legacy-placeholder",
|
|
29
|
-
|
|
27
|
+
inert: "true"
|
|
30
28
|
}, createElement("h3", null,
|
|
31
29
|
/* translators: %s: Post title. */
|
|
32
30
|
sprintf(__('One response to %s'), postTitle)), createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments/edit/placeholder.js"],"names":["store","blockEditorStore","__","sprintf","useSelect","useEntityProp","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments/edit/placeholder.js"],"names":["store","blockEditorStore","__","sprintf","useSelect","useEntityProp","CommentsForm","PostCommentsPlaceholder","postType","postId","postTitle","avatarURL","select","getSettings","__experimentalDiscussionSettings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,aAAT,QAA8B,sBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,+BAAzB;AAEA,eAAe,SAASC,uBAAT,OAAyD;AAAA,MAAvB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAuB;AACvE,MAAI,CAAEC,SAAF,IAAgBL,aAAa,CAAE,UAAF,EAAcG,QAAd,EAAwB,OAAxB,EAAiCC,MAAjC,CAAjC;AACAC,EAAAA,SAAS,GAAGA,SAAS,IAAIR,EAAE,CAAE,YAAF,CAA3B;AAEA,QAAM;AAAES,IAAAA;AAAF,MAAgBP,SAAS,CAC5BQ,MAAF,IACCA,MAAM,CAAEX,gBAAF,CAAN,CAA2BY,WAA3B,GACEC,gCAH2B,CAA/B;AAMA,SACC;AAAK,IAAA,SAAS,EAAC,uCAAf;AAAuD,IAAA,KAAK,EAAC;AAA7D,KACC;AAEE;AACAX,EAAAA,OAAO,CAAED,EAAE,CAAE,oBAAF,CAAJ,EAA8BQ,SAA9B,CAHT,CADD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,IAAI,EAAC;AAAR,cAA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,CAPL,EAO0C,GAP1C,EAQC;AAAG,IAAA,IAAI,EAAC;AAAR,gBARD,MADD,CApCD,EAiDC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,SAAS,EAAC,oBADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,kBAAW;AAHZ,KAKGA,EAAE,CAAE,OAAF,CALL,CADD,CAjDD,CADD,CADD,CAjBD,EAiFC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,IAAI,EAAC;AAAR,cAAmBA,EAAE,CAAE,gBAAF,CAArB,CADD,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,IAAI,EAAC;AAAR,KAAiBA,EAAE,CAAE,gBAAF,CAAnB,UADD,CAJD,CAjFD,EA0FC,cAAC,YAAD;AAAc,IAAA,MAAM,EAAGO,MAAvB;AAAgC,IAAA,QAAQ,EAAGD;AAA3C,IA1FD,CADD;AA8FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityProp } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport CommentsForm from '../../post-comments-form/form';\n\nexport default function PostCommentsPlaceholder( { postType, postId } ) {\n\tlet [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tpostTitle = postTitle || __( 'Post Title' );\n\n\tconst { avatarURL } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalDiscussionSettings\n\t);\n\n\treturn (\n\t\t<div className=\"wp-block-comments__legacy-placeholder\" inert=\"true\">\n\t\t\t<h3>\n\t\t\t\t{\n\t\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\t\tsprintf( __( 'One response to %s' ), postTitle )\n\t\t\t\t}\n\t\t\t</h3>\n\n\t\t\t<div className=\"navigation\">\n\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t<a href=\"#top\">« { __( 'Older Comments' ) }</a>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } »</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<ol className=\"commentlist\">\n\t\t\t\t<li className=\"comment even thread-even depth-1\">\n\t\t\t\t\t<article className=\"comment-body\">\n\t\t\t\t\t\t<footer className=\"comment-meta\">\n\t\t\t\t\t\t\t<div className=\"comment-author vcard\">\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\talt=\"Commenter Avatar\"\n\t\t\t\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t\t\t\t\tclassName=\"avatar avatar-32 photo\"\n\t\t\t\t\t\t\t\t\theight=\"32\"\n\t\t\t\t\t\t\t\t\twidth=\"32\"\n\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<b className=\"fn\">\n\t\t\t\t\t\t\t\t\t<a href=\"#top\" className=\"url\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'A WordPress Commenter' ) }\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</b>{ ' ' }\n\t\t\t\t\t\t\t\t<span className=\"says\">{ __( 'says' ) }:</span>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div className=\"comment-metadata\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">\n\t\t\t\t\t\t\t\t\t<time dateTime=\"2000-01-01T00:00:00+00:00\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'January 1, 2000 at 00:00 am' ) }\n\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t\t\t\t<span className=\"edit-link\">\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\tclassName=\"comment-edit-link\"\n\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</footer>\n\n\t\t\t\t\t\t<div className=\"comment-content\">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ __( 'Hi, this is a comment.' ) }\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t{ __( 'Commenter avatars come from' ) }{ ' ' }\n\t\t\t\t\t\t\t\t<a href=\"https://gravatar.com/\">Gravatar</a>.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div className=\"reply\">\n\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\tclassName=\"comment-reply-link\"\n\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\taria-label=\"Reply to A WordPress Commenter\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Reply' ) }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</article>\n\t\t\t\t</li>\n\t\t\t</ol>\n\n\t\t\t<div className=\"navigation\">\n\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t<a href=\"#top\">« { __( 'Older Comments' ) }</a>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } »</a>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<CommentsForm postId={ postId } postType={ postType } />\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -27,7 +27,6 @@ const metadata = {
|
|
|
27
27
|
},
|
|
28
28
|
supports: {
|
|
29
29
|
align: ["wide", "full"],
|
|
30
|
-
html: false,
|
|
31
30
|
color: {
|
|
32
31
|
gradients: true,
|
|
33
32
|
link: true,
|
|
@@ -37,6 +36,11 @@ const metadata = {
|
|
|
37
36
|
link: true
|
|
38
37
|
}
|
|
39
38
|
},
|
|
39
|
+
html: false,
|
|
40
|
+
spacing: {
|
|
41
|
+
margin: true,
|
|
42
|
+
padding: true
|
|
43
|
+
},
|
|
40
44
|
typography: {
|
|
41
45
|
fontSize: true,
|
|
42
46
|
lineHeight: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments/index.js"],"names":["postComments","icon","initBlock","deprecated","edit","save","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments/index.js"],"names":["postComments","icon","initBlock","deprecated","edit","save","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBP,EAAAA,IADuB;AAEvBG,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBF,EAAAA;AAJuB,CAAjB;AAOP,OAAO,MAAMM,IAAI,GAAG,MAAMP,SAAS,CAAE;AAAEI,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -8,11 +8,12 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { AlignmentControl, BlockControls, useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
|
11
|
+
import { AlignmentControl, BlockControls, useBlockProps, InspectorControls, store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
12
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
13
13
|
import { useEntityProp } from '@wordpress/core-data';
|
|
14
14
|
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
15
15
|
import { useState, useEffect } from '@wordpress/element';
|
|
16
|
+
import { useSelect } from '@wordpress/data';
|
|
16
17
|
import apiFetch from '@wordpress/api-fetch';
|
|
17
18
|
import { addQueryArgs } from '@wordpress/url';
|
|
18
19
|
/**
|
|
@@ -43,9 +44,24 @@ export default function Edit(_ref) {
|
|
|
43
44
|
[`has-text-align-${textAlign}`]: textAlign
|
|
44
45
|
})
|
|
45
46
|
});
|
|
47
|
+
const {
|
|
48
|
+
threadCommentsDepth,
|
|
49
|
+
threadComments,
|
|
50
|
+
commentsPerPage,
|
|
51
|
+
pageComments
|
|
52
|
+
} = useSelect(select => {
|
|
53
|
+
const {
|
|
54
|
+
getSettings
|
|
55
|
+
} = select(blockEditorStore);
|
|
56
|
+
return getSettings().__experimentalDiscussionSettings;
|
|
57
|
+
});
|
|
46
58
|
useEffect(() => {
|
|
47
59
|
if (isSiteEditor) {
|
|
48
|
-
|
|
60
|
+
// Match the number of comments that will be shown in the comment-template/edit.js placeholder
|
|
61
|
+
const nestedCommentsNumber = threadComments ? Math.min(threadCommentsDepth, 3) - 1 : 0;
|
|
62
|
+
const topLevelCommentsNumber = pageComments ? commentsPerPage : 3;
|
|
63
|
+
const commentsNumber = parseInt(nestedCommentsNumber) + parseInt(topLevelCommentsNumber);
|
|
64
|
+
setCommentsCount(Math.min(commentsNumber, 3));
|
|
49
65
|
return;
|
|
50
66
|
}
|
|
51
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-title/edit.js"],"names":["classnames","AlignmentControl","BlockControls","useBlockProps","InspectorControls","__","_n","sprintf","useEntityProp","PanelBody","ToggleControl","useState","useEffect","apiFetch","addQueryArgs","HeadingLevelDropdown","Edit","attributes","textAlign","showPostTitle","showCommentsCount","level","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","rawTitle","isSiteEditor","blockProps","className","currentPostId","path","post","_fields","method","parse","then","res","parseInt","headers","get","catch","blockControls","newAlign","newLevel","inspectorControls","value","postTitle","placeholder","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,aAFD,EAGCC,aAHD,EAICC,iBAJD,QAKO,yBALP;AAMA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,SAAT,EAAoBC,aAApB,QAAyC,uBAAzC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;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ADD;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport HeadingLevelDropdown from '../heading/heading-level-dropdown';\n\nexport default function Edit( {\n\tattributes: { textAlign, showPostTitle, showCommentsCount, level },\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\tsetCommentsCount( 3 );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tselectedLevel={ level }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '“Post Title”' ) : `\"${ rawTitle }\"`;\n\n\tlet placeholder;\n\tif ( showCommentsCount && commentsCount !== undefined ) {\n\t\tif ( showPostTitle ) {\n\t\t\tif ( commentsCount === 1 ) {\n\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\tplaceholder = sprintf( __( 'One response to %s' ), postTitle );\n\t\t\t} else {\n\t\t\t\tplaceholder = sprintf(\n\t\t\t\t\t/* translators: 1: Number of comments, 2: Post title. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%1$s response to %2$s',\n\t\t\t\t\t\t'%1$s responses to %2$s',\n\t\t\t\t\t\tcommentsCount\n\t\t\t\t\t),\n\t\t\t\t\tcommentsCount,\n\t\t\t\t\tpostTitle\n\t\t\t\t);\n\t\t\t}\n\t\t} else if ( commentsCount === 1 ) {\n\t\t\tplaceholder = __( 'One response' );\n\t\t} else {\n\t\t\tplaceholder = sprintf(\n\t\t\t\t/* translators: %s: Number of comments. */\n\t\t\t\t_n( '%s response', '%s responses', commentsCount ),\n\t\t\t\tcommentsCount\n\t\t\t);\n\t\t}\n\t} else if ( showPostTitle ) {\n\t\tif ( commentsCount === 1 ) {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Response to %s' ), postTitle );\n\t\t} else {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Responses to %s' ), postTitle );\n\t\t}\n\t} else if ( commentsCount === 1 ) {\n\t\tplaceholder = __( 'Response' );\n\t} else {\n\t\tplaceholder = __( 'Responses' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>{ placeholder }</TagName>\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-title/edit.js"],"names":["classnames","AlignmentControl","BlockControls","useBlockProps","InspectorControls","store","blockEditorStore","__","_n","sprintf","useEntityProp","PanelBody","ToggleControl","useState","useEffect","useSelect","apiFetch","addQueryArgs","HeadingLevelDropdown","Edit","attributes","textAlign","showPostTitle","showCommentsCount","level","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","rawTitle","isSiteEditor","blockProps","className","threadCommentsDepth","threadComments","commentsPerPage","pageComments","select","getSettings","__experimentalDiscussionSettings","nestedCommentsNumber","Math","min","topLevelCommentsNumber","commentsNumber","parseInt","currentPostId","path","post","_fields","method","parse","then","res","headers","get","catch","blockControls","newAlign","newLevel","inspectorControls","value","postTitle","placeholder","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA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A,OAHD,MAGO;AACNC,QAAAA,WAAW,GAAGzD,OAAO;AACpB;AACAD,QAAAA,EAAE,CACD,uBADC,EAED,wBAFC,EAGDsB,aAHC,CAFkB,EAOpBA,aAPoB,EAQpBmC,SARoB,CAArB;AAUA;AACD,KAhBD,MAgBO,IAAKnC,aAAa,KAAK,CAAvB,EAA2B;AACjCoC,MAAAA,WAAW,GAAG3D,EAAE,CAAE,cAAF,CAAhB;AACA,KAFM,MAEA;AACN2D,MAAAA,WAAW,GAAGzD,OAAO;AACpB;AACAD,MAAAA,EAAE,CAAE,aAAF,EAAiB,cAAjB,EAAiCsB,aAAjC,CAFkB,EAGpBA,aAHoB,CAArB;AAKA;AACD,GA1BD,MA0BO,IAAKR,aAAL,EAAqB;AAC3B,QAAKQ,aAAa,KAAK,CAAvB,EAA2B;AAC1B;AACAoC,MAAAA,WAAW,GAAGzD,OAAO,CAAEF,EAAE,CAAE,gBAAF,CAAJ,EAA0B0D,SAA1B,CAArB;AACA,KAHD,MAGO;AACN;AACAC,MAAAA,WAAW,GAAGzD,OAAO,CAAEF,EAAE,CAAE,iBAAF,CAAJ,EAA2B0D,SAA3B,CAArB;AACA;AACD,GARM,MAQA,IAAKnC,aAAa,KAAK,CAAvB,EAA2B;AACjCoC,IAAAA,WAAW,GAAG3D,EAAE,CAAE,UAAF,CAAhB;AACA,GAFM,MAEA;AACN2D,IAAAA,WAAW,GAAG3D,EAAE,CAAE,WAAF,CAAhB;AACA;;AAED,SACC,8BACGqD,aADH,EAEGG,iBAFH,EAGC,cAAC,OAAD,EAAc7B,UAAd,EAA6BgC,WAA7B,CAHD,CADD;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { PanelBody, ToggleControl } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport HeadingLevelDropdown from '../heading/heading-level-dropdown';\n\nexport default function Edit( {\n\tattributes: { textAlign, showPostTitle, showCommentsCount, level },\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst {\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t\tpageComments,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\t// Match the number of comments that will be shown in the comment-template/edit.js placeholder\n\n\t\t\tconst nestedCommentsNumber = threadComments\n\t\t\t\t? Math.min( threadCommentsDepth, 3 ) - 1\n\t\t\t\t: 0;\n\t\t\tconst topLevelCommentsNumber = pageComments ? commentsPerPage : 3;\n\n\t\t\tconst commentsNumber =\n\t\t\t\tparseInt( nestedCommentsNumber ) +\n\t\t\t\tparseInt( topLevelCommentsNumber );\n\n\t\t\tsetCommentsCount( Math.min( commentsNumber, 3 ) );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tselectedLevel={ level }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '“Post Title”' ) : `\"${ rawTitle }\"`;\n\n\tlet placeholder;\n\tif ( showCommentsCount && commentsCount !== undefined ) {\n\t\tif ( showPostTitle ) {\n\t\t\tif ( commentsCount === 1 ) {\n\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\tplaceholder = sprintf( __( 'One response to %s' ), postTitle );\n\t\t\t} else {\n\t\t\t\tplaceholder = sprintf(\n\t\t\t\t\t/* translators: 1: Number of comments, 2: Post title. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%1$s response to %2$s',\n\t\t\t\t\t\t'%1$s responses to %2$s',\n\t\t\t\t\t\tcommentsCount\n\t\t\t\t\t),\n\t\t\t\t\tcommentsCount,\n\t\t\t\t\tpostTitle\n\t\t\t\t);\n\t\t\t}\n\t\t} else if ( commentsCount === 1 ) {\n\t\t\tplaceholder = __( 'One response' );\n\t\t} else {\n\t\t\tplaceholder = sprintf(\n\t\t\t\t/* translators: %s: Number of comments. */\n\t\t\t\t_n( '%s response', '%s responses', commentsCount ),\n\t\t\t\tcommentsCount\n\t\t\t);\n\t\t}\n\t} else if ( showPostTitle ) {\n\t\tif ( commentsCount === 1 ) {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Response to %s' ), postTitle );\n\t\t} else {\n\t\t\t/* translators: %s: Post title. */\n\t\t\tplaceholder = sprintf( __( 'Responses to %s' ), postTitle );\n\t\t}\n\t} else if ( commentsCount === 1 ) {\n\t\tplaceholder = __( 'Response' );\n\t} else {\n\t\tplaceholder = __( 'Responses' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>{ placeholder }</TagName>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -115,8 +115,7 @@ function CoverEdit(_ref) {
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
const
|
|
119
|
-
const isCoverDark = useCoverIsDark(url, dimRatio, overlayColor.color, mediaElement);
|
|
118
|
+
const isCoverDark = useCoverIsDark(url, dimRatio, overlayColor.color);
|
|
120
119
|
useEffect(() => {
|
|
121
120
|
// This side-effect should not create an undo level.
|
|
122
121
|
__unstableMarkNextChangeAsNotPersistent();
|
|
@@ -159,6 +158,7 @@ function CoverEdit(_ref) {
|
|
|
159
158
|
allowedBlocks,
|
|
160
159
|
templateLock
|
|
161
160
|
});
|
|
161
|
+
const mediaElement = useRef();
|
|
162
162
|
const currentSettings = {
|
|
163
163
|
isVideoBackground,
|
|
164
164
|
isImageBackground,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/cover/edit/index.js"],"names":["classnames","extend","namesPlugin","useEntityProp","store","coreStore","useEffect","useRef","Placeholder","Spinner","compose","withColors","ColorPalette","useBlockProps","useSetting","useInnerBlocksProps","__experimentalUseGradient","blockEditorStore","__","useSelect","useDispatch","isBlobURL","noticesStore","attributesFromMedia","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","dimRatioToClass","isContentPositionCenter","getPositionClassName","mediaPosition","useCoverIsDark","CoverInspectorControls","CoverBlockControls","CoverPlaceholder","ResizableCover","getInnerBlocksTemplate","attributes","align","placeholder","isTemporaryMedia","id","url","CoverEdit","clientId","isSelected","overlayColor","setAttributes","setOverlayColor","toggleSelection","context","postId","postType","contentPosition","useFeaturedImage","dimRatio","focalPoint","hasParallax","isDark","isRepeated","minHeight","minHeightUnit","alt","allowedBlocks","templateLock","featuredImage","media","select","getMedia","mediaUrl","source_url","backgroundType","__unstableMarkNextChangeAsNotPersistent","createErrorNotice","gradientClass","gradientValue","onSelectMedia","isUploadingMedia","onUploadError","message","type","mediaElement","isCoverDark","color","isImageBackground","isVideoBackground","minHeightWithUnit","isImgElement","style","undefined","backgroundImage","backgroundPosition","bgStyle","backgroundColor","mediaStyle","objectPosition","hasBackground","hasInnerBlocks","getBlock","innerBlocks","length","ref","blockProps","hasFontSizes","innerBlocksTemplate","fontSize","innerBlocksProps","className","template","templateInsertUpdatesSelection","currentSettings","toggleUseFeaturedImage","blockControls","inspectorControls","value","newMinHeight","classes","class"],"mappings":";;;A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EC,IAAA,gBAAgB,EAAG;AAFpB,IA7CF,EAmDGZ,GAAG,IACJ0C,iBADC,KAECG,YAAY,GACb;AACC,IAAA,GAAG,EAAGN,YADP;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,GAAG,EAAGnB,GAHP;AAIC,IAAA,GAAG,EAAGpB,GAJP;AAKC,IAAA,KAAK,EAAGoD;AALT,IADa,GASb;AACC,IAAA,GAAG,EAAGb,YADP;AAEC,IAAA,IAAI,EAAC,KAFN;AAGC,IAAA,SAAS,EAAGhF,UAAU,CACrBmH,OADqB,EAErB,kCAFqB,CAHvB;AAOC,IAAA,KAAK,EAAG;AAAE1B,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB;AAPT,IAXA,CAnDH,EAwEGjD,GAAG,IAAI2C,iBAAP,IACD;AACC,IAAA,GAAG,EAAGJ,YADP;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,QAAQ,MAHT;AAIC,IAAA,KAAK,MAJN;AAKC,IAAA,IAAI,MALL;AAMC,IAAA,GAAG,EAAGvC,GANP;AAOC,IAAA,KAAK,EAAGoD;AAPT,IAzEF,EAmFGjB,gBAAgB,IAAI,cAAC,OAAD,OAnFvB,EAoFC,cAAC,gBAAD;AACC,IAAA,mBAAmB,MADpB;AAEC,IAAA,aAAa,EAAGD,aAFjB;AAGC,IAAA,OAAO,EAAGE,aAHX;AAIC,IAAA,sBAAsB,EAAGiC;AAJ1B,IApFD,EA0FC,qBAAUL,gBAAV,CA1FD,CAHD,CADD;AAkGA;;AAED,eAAe/F,OAAO,CAAE,CACvBC,UAAU,CAAE;AAAEkC,EAAAA,YAAY,EAAE;AAAhB,CAAF,CADa,CAAF,CAAP,CAEVH,SAFU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { Placeholder, Spinner } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport {\n\twithColors,\n\tColorPalette,\n\tuseBlockProps,\n\tuseSetting,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from '../shared';\nimport useCoverIsDark from './use-cover-is-dark';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCover from './resizable-cover';\n\nextend( [ namesPlugin ] );\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\talign: 'center',\n\t\t\t\tplaceholder: __( 'Write title…' ),\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t],\n\t];\n}\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily while\n * the media (image or video) is being uploaded and will not have an id allocated yet.\n *\n * @param {number} id The id of the media.\n * @param {string} url The url of the media.\n *\n * @return {boolean} Is the URL a Blob URL.\n */\nconst isTemporaryMedia = ( id, url ) => ! id && isBlobURL( url );\n\nfunction CoverEdit( {\n\tattributes,\n\tclientId,\n\tisSelected,\n\toverlayColor,\n\tsetAttributes,\n\tsetOverlayColor,\n\ttoggleSelection,\n\tcontext: { postId, postType },\n} ) {\n\tconst {\n\t\tcontentPosition,\n\t\tid,\n\t\tuseFeaturedImage,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\tminHeight,\n\t\tminHeightUnit,\n\t\talt,\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst media = useSelect(\n\t\t( select ) =>\n\t\t\tfeaturedImage &&\n\t\t\tselect( coreStore ).getMedia( featuredImage, { context: 'view' } ),\n\t\t[ featuredImage ]\n\t);\n\tconst mediaUrl = media?.source_url;\n\n\t// instead of destructuring the attributes\n\t// we define the url and background type\n\t// depending on the value of the useFeaturedImage flag\n\t// to preview in edit the dynamic featured image\n\tconst url = useFeaturedImage ? mediaUrl : attributes.url;\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: attributes.backgroundType;\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\tconst onSelectMedia = attributesFromMedia( setAttributes, dimRatio );\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst mediaElement = useRef();\n\tconst isCoverDark = useCoverIsDark(\n\t\turl,\n\t\tdimRatio,\n\t\toverlayColor.color,\n\t\tmediaElement\n\t);\n\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isDark: isCoverDark } );\n\t}, [ isCoverDark ] );\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst minHeightWithUnit =\n\t\tminHeight && minHeightUnit\n\t\t\t? `${ minHeight }${ minHeightUnit }`\n\t\t\t: minHeight;\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst style = {\n\t\tminHeight: minHeightWithUnit || undefined,\n\t};\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst bgStyle = { backgroundColor: overlayColor.color };\n\tconst mediaStyle = {\n\t\tobjectPosition:\n\t\t\tfocalPoint && isImgElement\n\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t: undefined,\n\t};\n\n\tconst hasBackground = !! ( url || overlayColor.color || gradientValue );\n\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlock( clientId ).innerBlocks.length >\n\t\t\t0,\n\t\t[ clientId ]\n\t);\n\n\tconst ref = useRef();\n\tconst blockProps = useBlockProps( { ref } );\n\n\t// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.\n\tconst hasFontSizes = !! useSetting( 'typography.fontSizes' )?.length;\n\tconst innerBlocksTemplate = getInnerBlocksTemplate( {\n\t\tfontSize: hasFontSizes ? 'large' : undefined,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t},\n\t\t{\n\t\t\ttemplate: innerBlocksTemplate,\n\t\t\ttemplateInsertUpdatesSelection: true,\n\t\t\tallowedBlocks,\n\t\t\ttemplateLock,\n\t\t}\n\t);\n\n\tconst currentSettings = {\n\t\tisVideoBackground,\n\t\tisImageBackground,\n\t\tmediaElement,\n\t\thasInnerBlocks,\n\t\turl,\n\t\tisImgElement,\n\t\toverlayColor,\n\t};\n\n\tconst toggleUseFeaturedImage = () => {\n\t\tsetAttributes( {\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tuseFeaturedImage: ! useFeaturedImage,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t: undefined,\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t/>\n\t);\n\n\tconst inspectorControls = (\n\t\t<CoverInspectorControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tclientId={ clientId }\n\t\t\tsetOverlayColor={ setOverlayColor }\n\t\t\tcoverRef={ ref }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t/>\n\t);\n\n\tif ( ! useFeaturedImage && ! hasInnerBlocks && ! hasBackground ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockControls }\n\t\t\t\t{ inspectorControls }\n\t\t\t\t<div\n\t\t\t\t\t{ ...blockProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'is-placeholder',\n\t\t\t\t\t\tblockProps.className\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<CoverPlaceholder\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\tminHeight: minHeightWithUnit || undefined,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"wp-block-cover__placeholder-background-options\">\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tdisableCustomColors={ true }\n\t\t\t\t\t\t\t\tvalue={ overlayColor.color }\n\t\t\t\t\t\t\t\tonChange={ setOverlayColor }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</CoverPlaceholder>\n\t\t\t\t\t<ResizableCover\n\t\t\t\t\t\tclassName=\"block-library-cover__resize-container\"\n\t\t\t\t\t\tonResizeStart={ () => {\n\t\t\t\t\t\t\tsetAttributes( { minHeightUnit: 'px' } );\n\t\t\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResize={ ( value ) => {\n\t\t\t\t\t\t\tsetAttributes( { minHeight: value } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStop={ ( newMinHeight ) => {\n\t\t\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t\t\t\tsetAttributes( { minHeight: newMinHeight } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst classes = classnames(\n\t\t{\n\t\t\t'is-dark-theme': isDark,\n\t\t\t'is-light': ! isDark,\n\t\t\t'is-transient': isUploadingMedia,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( classes, blockProps.className ) }\n\t\t\t\tstyle={ { ...style, ...blockProps.style } }\n\t\t\t\tdata-url={ url }\n\t\t\t>\n\t\t\t\t<ResizableCover\n\t\t\t\t\tclassName=\"block-library-cover__resize-container\"\n\t\t\t\t\tonResizeStart={ () => {\n\t\t\t\t\t\tsetAttributes( { minHeightUnit: 'px' } );\n\t\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonResize={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( { minHeight: value } );\n\t\t\t\t\t} }\n\t\t\t\t\tonResizeStop={ ( newMinHeight ) => {\n\t\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t\t\tsetAttributes( { minHeight: newMinHeight } );\n\t\t\t\t\t} }\n\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t/>\n\n\t\t\t\t{ ( ! useFeaturedImage || url ) && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ { backgroundImage: gradientValue, ...bgStyle } }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ ! url && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-cover__image--placeholder-image\"\n\t\t\t\t\t\twithIllustration={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ url &&\n\t\t\t\t\tisImageBackground &&\n\t\t\t\t\t( isImgElement ? (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\tclassName=\"wp-block-cover__image-background\"\n\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t'wp-block-cover__image-background'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ { backgroundImage, backgroundPosition } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ url && isVideoBackground && (\n\t\t\t\t\t<video\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background\"\n\t\t\t\t\t\tautoPlay\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tloop\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isUploadingMedia && <Spinner /> }\n\t\t\t\t<CoverPlaceholder\n\t\t\t\t\tdisableMediaButtons\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( CoverEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/cover/edit/index.js"],"names":["classnames","extend","namesPlugin","useEntityProp","store","coreStore","useEffect","useRef","Placeholder","Spinner","compose","withColors","ColorPalette","useBlockProps","useSetting","useInnerBlocksProps","__experimentalUseGradient","blockEditorStore","__","useSelect","useDispatch","isBlobURL","noticesStore","attributesFromMedia","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","dimRatioToClass","isContentPositionCenter","getPositionClassName","mediaPosition","useCoverIsDark","CoverInspectorControls","CoverBlockControls","CoverPlaceholder","ResizableCover","getInnerBlocksTemplate","attributes","align","placeholder","isTemporaryMedia","id","url","CoverEdit","clientId","isSelected","overlayColor","setAttributes","setOverlayColor","toggleSelection","context","postId","postType","contentPosition","useFeaturedImage","dimRatio","focalPoint","hasParallax","isDark","isRepeated","minHeight","minHeightUnit","alt","allowedBlocks","templateLock","featuredImage","media","select","getMedia","mediaUrl","source_url","backgroundType","__unstableMarkNextChangeAsNotPersistent","createErrorNotice","gradientClass","gradientValue","onSelectMedia","isUploadingMedia","onUploadError","message","type","isCoverDark","color","isImageBackground","isVideoBackground","minHeightWithUnit","isImgElement","style","undefined","backgroundImage","backgroundPosition","bgStyle","backgroundColor","mediaStyle","objectPosition","hasBackground","hasInnerBlocks","getBlock","innerBlocks","length","ref","blockProps","hasFontSizes","innerBlocksTemplate","fontSize","innerBlocksProps","className","template","templateInsertUpdatesSelection","mediaElement","currentSettings","toggleUseFeaturedImage","blockControls","inspectorControls","value","newMinHeight","classes","class"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,EAAwBC,KAAK,IAAIC,SAAjC,QAAkD,sBAAlD;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,uBAArC;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SACCC,UADD,EAECC,YAFD,EAGCC,aAHD,EAICC,UAJD,EAKCC,mBALD,EAMCC,yBAND,EAOCZ,KAAK,IAAIa,gBAPV,QAQO,yBARP;AASA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAu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AG,EAAGyB,YADP;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,QAAQ,MAHT;AAIC,IAAA,KAAK,MAJN;AAKC,IAAA,IAAI,MALL;AAMC,IAAA,GAAG,EAAGnE,GANP;AAOC,IAAA,KAAK,EAAGmD;AAPT,IAzEF,EAmFGhB,gBAAgB,IAAI,cAAC,OAAD,OAnFvB,EAoFC,cAAC,gBAAD;AACC,IAAA,mBAAmB,MADpB;AAEC,IAAA,aAAa,EAAGD,aAFjB;AAGC,IAAA,OAAO,EAAGE,aAHX;AAIC,IAAA,sBAAsB,EAAGiC;AAJ1B,IApFD,EA0FC,qBAAUN,gBAAV,CA1FD,CAHD,CADD;AAkGA;;AAED,eAAe9F,OAAO,CAAE,CACvBC,UAAU,CAAE;AAAEkC,EAAAA,YAAY,EAAE;AAAhB,CAAF,CADa,CAAF,CAAP,CAEVH,SAFU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { Placeholder, Spinner } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\nimport {\n\twithColors,\n\tColorPalette,\n\tuseBlockProps,\n\tuseSetting,\n\tuseInnerBlocksProps,\n\t__experimentalUseGradient,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tattributesFromMedia,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n\tdimRatioToClass,\n\tisContentPositionCenter,\n\tgetPositionClassName,\n\tmediaPosition,\n} from '../shared';\nimport useCoverIsDark from './use-cover-is-dark';\nimport CoverInspectorControls from './inspector-controls';\nimport CoverBlockControls from './block-controls';\nimport CoverPlaceholder from './cover-placeholder';\nimport ResizableCover from './resizable-cover';\n\nextend( [ namesPlugin ] );\n\nfunction getInnerBlocksTemplate( attributes ) {\n\treturn [\n\t\t[\n\t\t\t'core/paragraph',\n\t\t\t{\n\t\t\t\talign: 'center',\n\t\t\t\tplaceholder: __( 'Write title…' ),\n\t\t\t\t...attributes,\n\t\t\t},\n\t\t],\n\t];\n}\n\n/**\n * Is the URL a temporary blob URL? A blob URL is one that is used temporarily while\n * the media (image or video) is being uploaded and will not have an id allocated yet.\n *\n * @param {number} id The id of the media.\n * @param {string} url The url of the media.\n *\n * @return {boolean} Is the URL a Blob URL.\n */\nconst isTemporaryMedia = ( id, url ) => ! id && isBlobURL( url );\n\nfunction CoverEdit( {\n\tattributes,\n\tclientId,\n\tisSelected,\n\toverlayColor,\n\tsetAttributes,\n\tsetOverlayColor,\n\ttoggleSelection,\n\tcontext: { postId, postType },\n} ) {\n\tconst {\n\t\tcontentPosition,\n\t\tid,\n\t\tuseFeaturedImage,\n\t\tdimRatio,\n\t\tfocalPoint,\n\t\thasParallax,\n\t\tisDark,\n\t\tisRepeated,\n\t\tminHeight,\n\t\tminHeightUnit,\n\t\talt,\n\t\tallowedBlocks,\n\t\ttemplateLock,\n\t} = attributes;\n\n\tconst [ featuredImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst media = useSelect(\n\t\t( select ) =>\n\t\t\tfeaturedImage &&\n\t\t\tselect( coreStore ).getMedia( featuredImage, { context: 'view' } ),\n\t\t[ featuredImage ]\n\t);\n\tconst mediaUrl = media?.source_url;\n\n\t// instead of destructuring the attributes\n\t// we define the url and background type\n\t// depending on the value of the useFeaturedImage flag\n\t// to preview in edit the dynamic featured image\n\tconst url = useFeaturedImage ? mediaUrl : attributes.url;\n\tconst backgroundType = useFeaturedImage\n\t\t? IMAGE_BACKGROUND_TYPE\n\t\t: attributes.backgroundType;\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { gradientClass, gradientValue } = __experimentalUseGradient();\n\tconst onSelectMedia = attributesFromMedia( setAttributes, dimRatio );\n\tconst isUploadingMedia = isTemporaryMedia( id, url );\n\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst isCoverDark = useCoverIsDark( url, dimRatio, overlayColor.color );\n\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isDark: isCoverDark } );\n\t}, [ isCoverDark ] );\n\n\tconst isImageBackground = IMAGE_BACKGROUND_TYPE === backgroundType;\n\tconst isVideoBackground = VIDEO_BACKGROUND_TYPE === backgroundType;\n\n\tconst minHeightWithUnit =\n\t\tminHeight && minHeightUnit\n\t\t\t? `${ minHeight }${ minHeightUnit }`\n\t\t\t: minHeight;\n\n\tconst isImgElement = ! ( hasParallax || isRepeated );\n\n\tconst style = {\n\t\tminHeight: minHeightWithUnit || undefined,\n\t};\n\n\tconst backgroundImage = url ? `url(${ url })` : undefined;\n\n\tconst backgroundPosition = mediaPosition( focalPoint );\n\n\tconst bgStyle = { backgroundColor: overlayColor.color };\n\tconst mediaStyle = {\n\t\tobjectPosition:\n\t\t\tfocalPoint && isImgElement\n\t\t\t\t? mediaPosition( focalPoint )\n\t\t\t\t: undefined,\n\t};\n\n\tconst hasBackground = !! ( url || overlayColor.color || gradientValue );\n\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlock( clientId ).innerBlocks.length >\n\t\t\t0,\n\t\t[ clientId ]\n\t);\n\n\tconst ref = useRef();\n\tconst blockProps = useBlockProps( { ref } );\n\n\t// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.\n\tconst hasFontSizes = !! useSetting( 'typography.fontSizes' )?.length;\n\tconst innerBlocksTemplate = getInnerBlocksTemplate( {\n\t\tfontSize: hasFontSizes ? 'large' : undefined,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'wp-block-cover__inner-container',\n\t\t},\n\t\t{\n\t\t\ttemplate: innerBlocksTemplate,\n\t\t\ttemplateInsertUpdatesSelection: true,\n\t\t\tallowedBlocks,\n\t\t\ttemplateLock,\n\t\t}\n\t);\n\n\tconst mediaElement = useRef();\n\tconst currentSettings = {\n\t\tisVideoBackground,\n\t\tisImageBackground,\n\t\tmediaElement,\n\t\thasInnerBlocks,\n\t\turl,\n\t\tisImgElement,\n\t\toverlayColor,\n\t};\n\n\tconst toggleUseFeaturedImage = () => {\n\t\tsetAttributes( {\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tuseFeaturedImage: ! useFeaturedImage,\n\t\t\tdimRatio: dimRatio === 100 ? 50 : dimRatio,\n\t\t\tbackgroundType: useFeaturedImage\n\t\t\t\t? IMAGE_BACKGROUND_TYPE\n\t\t\t\t: undefined,\n\t\t} );\n\t};\n\n\tconst blockControls = (\n\t\t<CoverBlockControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t/>\n\t);\n\n\tconst inspectorControls = (\n\t\t<CoverInspectorControls\n\t\t\tattributes={ attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tclientId={ clientId }\n\t\t\tsetOverlayColor={ setOverlayColor }\n\t\t\tcoverRef={ ref }\n\t\t\tcurrentSettings={ currentSettings }\n\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t/>\n\t);\n\n\tif ( ! useFeaturedImage && ! hasInnerBlocks && ! hasBackground ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockControls }\n\t\t\t\t{ inspectorControls }\n\t\t\t\t<div\n\t\t\t\t\t{ ...blockProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'is-placeholder',\n\t\t\t\t\t\tblockProps.className\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<CoverPlaceholder\n\t\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\tminHeight: minHeightWithUnit || undefined,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"wp-block-cover__placeholder-background-options\">\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tdisableCustomColors={ true }\n\t\t\t\t\t\t\t\tvalue={ overlayColor.color }\n\t\t\t\t\t\t\t\tonChange={ setOverlayColor }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</CoverPlaceholder>\n\t\t\t\t\t<ResizableCover\n\t\t\t\t\t\tclassName=\"block-library-cover__resize-container\"\n\t\t\t\t\t\tonResizeStart={ () => {\n\t\t\t\t\t\t\tsetAttributes( { minHeightUnit: 'px' } );\n\t\t\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResize={ ( value ) => {\n\t\t\t\t\t\t\tsetAttributes( { minHeight: value } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonResizeStop={ ( newMinHeight ) => {\n\t\t\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t\t\t\tsetAttributes( { minHeight: newMinHeight } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst classes = classnames(\n\t\t{\n\t\t\t'is-dark-theme': isDark,\n\t\t\t'is-light': ! isDark,\n\t\t\t'is-transient': isUploadingMedia,\n\t\t\t'has-parallax': hasParallax,\n\t\t\t'is-repeated': isRepeated,\n\t\t\t'has-custom-content-position':\n\t\t\t\t! isContentPositionCenter( contentPosition ),\n\t\t},\n\t\tgetPositionClassName( contentPosition )\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<div\n\t\t\t\t{ ...blockProps }\n\t\t\t\tclassName={ classnames( classes, blockProps.className ) }\n\t\t\t\tstyle={ { ...style, ...blockProps.style } }\n\t\t\t\tdata-url={ url }\n\t\t\t>\n\t\t\t\t<ResizableCover\n\t\t\t\t\tclassName=\"block-library-cover__resize-container\"\n\t\t\t\t\tonResizeStart={ () => {\n\t\t\t\t\t\tsetAttributes( { minHeightUnit: 'px' } );\n\t\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonResize={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( { minHeight: value } );\n\t\t\t\t\t} }\n\t\t\t\t\tonResizeStop={ ( newMinHeight ) => {\n\t\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t\t\tsetAttributes( { minHeight: newMinHeight } );\n\t\t\t\t\t} }\n\t\t\t\t\tshowHandle={ isSelected }\n\t\t\t\t/>\n\n\t\t\t\t{ ( ! useFeaturedImage || url ) && (\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'wp-block-cover__background',\n\t\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t\t// For backwards compatibility. Former versions of the Cover Block applied\n\t\t\t\t\t\t\t\t// `.wp-block-cover__gradient-background` in the presence of\n\t\t\t\t\t\t\t\t// media, a gradient and a dim.\n\t\t\t\t\t\t\t\t'wp-block-cover__gradient-background':\n\t\t\t\t\t\t\t\t\turl && gradientValue && dimRatio !== 0,\n\t\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tstyle={ { backgroundImage: gradientValue, ...bgStyle } }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ ! url && useFeaturedImage && (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\tclassName=\"wp-block-cover__image--placeholder-image\"\n\t\t\t\t\t\twithIllustration={ true }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ url &&\n\t\t\t\t\tisImageBackground &&\n\t\t\t\t\t( isImgElement ? (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\tclassName=\"wp-block-cover__image-background\"\n\t\t\t\t\t\t\talt={ alt }\n\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\t\trole=\"img\"\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\tclasses,\n\t\t\t\t\t\t\t\t'wp-block-cover__image-background'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tstyle={ { backgroundImage, backgroundPosition } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ url && isVideoBackground && (\n\t\t\t\t\t<video\n\t\t\t\t\t\tref={ mediaElement }\n\t\t\t\t\t\tclassName=\"wp-block-cover__video-background\"\n\t\t\t\t\t\tautoPlay\n\t\t\t\t\t\tmuted\n\t\t\t\t\t\tloop\n\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\tstyle={ mediaStyle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isUploadingMedia && <Spinner /> }\n\t\t\t\t<CoverPlaceholder\n\t\t\t\t\tdisableMediaButtons\n\t\t\t\t\tonSelectMedia={ onSelectMedia }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\ttoggleUseFeaturedImage={ toggleUseFeaturedImage }\n\t\t\t\t/>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( CoverEdit );\n"]}
|
|
@@ -8,6 +8,7 @@ import { colord } from 'colord';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { useEffect, useState } from '@wordpress/element';
|
|
11
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
11
12
|
|
|
12
13
|
function retrieveFastAverageColor() {
|
|
13
14
|
if (!retrieveFastAverageColor.fastAverageColor) {
|
|
@@ -25,8 +26,6 @@ function retrieveFastAverageColor() {
|
|
|
25
26
|
* color are set, dimRatio is used to decide what is used
|
|
26
27
|
* for background darkness checking purposes.
|
|
27
28
|
* @param {?string} overlayColor String containing the overlay color value if one exists.
|
|
28
|
-
* @param {?Object} elementRef If a media background is set, elementRef should contain a reference to a
|
|
29
|
-
* dom element that renders that media.
|
|
30
29
|
*
|
|
31
30
|
* @return {boolean} True if the cover background is considered "dark" and false otherwise.
|
|
32
31
|
*/
|
|
@@ -35,22 +34,23 @@ function retrieveFastAverageColor() {
|
|
|
35
34
|
export default function useCoverIsDark(url) {
|
|
36
35
|
let dimRatio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
|
|
37
36
|
let overlayColor = arguments.length > 2 ? arguments[2] : undefined;
|
|
38
|
-
let elementRef = arguments.length > 3 ? arguments[3] : undefined;
|
|
39
37
|
const [isDark, setIsDark] = useState(false);
|
|
40
38
|
useEffect(() => {
|
|
41
39
|
// If opacity is lower than 50 the dominant color is the image or video color,
|
|
42
40
|
// so use that color for the dark mode computation.
|
|
43
|
-
if (url && dimRatio <= 50
|
|
44
|
-
|
|
41
|
+
if (url && dimRatio <= 50) {
|
|
42
|
+
const imgCrossOrigin = applyFilters('media.crossOrigin', undefined, url);
|
|
43
|
+
retrieveFastAverageColor().getColorAsync(url, {
|
|
45
44
|
// Previously the default color was white, but that changed
|
|
46
45
|
// in v6.0.0 so it has to be manually set now.
|
|
47
46
|
defaultColor: [255, 255, 255, 255],
|
|
48
47
|
// Errors that come up don't reject the promise, so error
|
|
49
48
|
// logging has to be silenced with this option.
|
|
50
|
-
silent: process.env.NODE_ENV === 'production'
|
|
49
|
+
silent: process.env.NODE_ENV === 'production',
|
|
50
|
+
crossOrigin: imgCrossOrigin
|
|
51
51
|
}).then(color => setIsDark(color.isDark));
|
|
52
52
|
}
|
|
53
|
-
}, [url, url && dimRatio <= 50
|
|
53
|
+
}, [url, url && dimRatio <= 50, setIsDark]);
|
|
54
54
|
useEffect(() => {
|
|
55
55
|
// If opacity is greater than 50 the dominant color is the overlay color,
|
|
56
56
|
// so use that color for the dark mode computation.
|