@wordpress/block-library 7.10.0 → 7.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/button/edit.js +2 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/edit.js +1 -1
- package/build/buttons/edit.js.map +1 -1
- package/build/columns/edit.native.js +1 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/comments/edit/comments-legacy.js +73 -0
- package/build/comments/edit/comments-legacy.js.map +1 -0
- package/build/comments/{edit.js → edit/index.js} +17 -38
- package/build/comments/edit/index.js.map +1 -0
- package/build/comments/edit/placeholder.js +117 -0
- package/build/comments/edit/placeholder.js.map +1 -0
- package/build/comments/edit/template.js +39 -0
- package/build/comments/edit/template.js.map +1 -0
- package/build/comments/index.js +6 -1
- package/build/comments/index.js.map +1 -1
- package/build/comments/save.js +12 -4
- package/build/comments/save.js.map +1 -1
- package/build/cover/transforms.js +3 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +1 -3
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/gallery/edit.js +2 -2
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/use-get-media.native.js +59 -0
- package/build/gallery/use-get-media.native.js.map +1 -0
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +1 -1
- package/build/group/variations.js.map +1 -1
- package/build/image/deprecated.js +77 -9
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +3 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +18 -8
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +27 -20
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +7 -1
- package/build/image/index.js.map +1 -1
- package/build/image/save.js +8 -2
- package/build/image/save.js.map +1 -1
- package/build/index.js +1 -3
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -13
- package/build/index.native.js.map +1 -1
- package/build/list/transforms.js +4 -63
- package/build/list/transforms.js.map +1 -1
- package/build/list/v2/transforms.js +0 -27
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +14 -9
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +8 -8
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +174 -0
- package/build/list-item/hooks/use-merge.js.map +1 -0
- package/build/list-item/hooks/use-outdent-list-item.js +86 -50
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/utils.js +125 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/deprecated.js +134 -7
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +2 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/save.js +13 -0
- package/build/media-text/save.js.map +1 -1
- package/build/more/save.js +1 -7
- package/build/more/save.js.map +1 -1
- package/build/navigation-link/edit.js +5 -4
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -1
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +8 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/edit.js +7 -11
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +4 -45
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +47 -3
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-terms/edit.js +3 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/query-pagination-next/edit.js +2 -1
- package/build/query-pagination-next/edit.js.map +1 -1
- package/build/query-pagination-previous/edit.js +2 -1
- package/build/query-pagination-previous/edit.js.map +1 -1
- package/build/quote/deprecated.js +168 -36
- package/build/quote/deprecated.js.map +1 -1
- package/build/quote/edit.js +76 -39
- package/build/quote/edit.js.map +1 -1
- package/build/quote/index.js +9 -45
- package/build/quote/index.js.map +1 -1
- package/build/quote/save.js +1 -5
- package/build/quote/save.js.map +1 -1
- package/build/quote/transforms.js +110 -158
- package/build/quote/transforms.js.map +1 -1
- package/build/social-link/icons/index.js +13 -0
- package/build/social-link/icons/index.js.map +1 -1
- package/build/social-link/icons/whatsapp.js +25 -0
- package/build/social-link/icons/whatsapp.js.map +1 -0
- package/build/social-link/variations.js +7 -0
- package/build/social-link/variations.js.map +1 -1
- package/build/template-part/edit/index.js +17 -8
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +33 -13
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/search.js +94 -0
- package/build/template-part/edit/utils/search.js.map +1 -0
- package/build-module/button/edit.js +2 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/edit.js +2 -2
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +2 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/comments/edit/comments-legacy.js +59 -0
- package/build-module/comments/edit/comments-legacy.js.map +1 -0
- package/build-module/comments/edit/index.js +37 -0
- package/build-module/comments/edit/index.js.map +1 -0
- package/build-module/comments/edit/placeholder.js +102 -0
- package/build-module/comments/edit/placeholder.js.map +1 -0
- package/build-module/comments/edit/template.js +32 -0
- package/build-module/comments/edit/template.js.map +1 -0
- package/build-module/comments/index.js +6 -1
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments/save.js +9 -4
- package/build-module/comments/save.js.map +1 -1
- package/build-module/cover/transforms.js +3 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +1 -2
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/gallery/edit.js +2 -2
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +50 -0
- package/build-module/gallery/use-get-media.native.js.map +1 -0
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +2 -2
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/deprecated.js +77 -9
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +5 -3
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +18 -8
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +29 -22
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +7 -1
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/save.js +9 -3
- package/build-module/image/save.js.map +1 -1
- package/build-module/index.js +1 -2
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +3 -13
- package/build-module/index.native.js.map +1 -1
- package/build-module/list/transforms.js +4 -63
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/v2/transforms.js +2 -29
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +14 -10
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +1 -1
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +160 -0
- package/build-module/list-item/hooks/use-merge.js.map +1 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js +82 -46
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/utils.js +123 -2
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/deprecated.js +134 -8
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +2 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/save.js +13 -0
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/more/save.js +1 -6
- package/build-module/more/save.js.map +1 -1
- package/build-module/navigation-link/edit.js +5 -4
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -1
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +8 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +8 -12
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +5 -42
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +46 -5
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-terms/edit.js +3 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/query-no-results/edit.js +2 -2
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/query-pagination-next/edit.js +2 -1
- package/build-module/query-pagination-next/edit.js.map +1 -1
- package/build-module/query-pagination-previous/edit.js +2 -1
- package/build-module/query-pagination-previous/edit.js.map +1 -1
- package/build-module/quote/deprecated.js +162 -36
- package/build-module/quote/deprecated.js.map +1 -1
- package/build-module/quote/edit.js +77 -43
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/quote/index.js +9 -39
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/save.js +4 -8
- package/build-module/quote/save.js.map +1 -1
- package/build-module/quote/transforms.js +111 -158
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/social-link/icons/index.js +1 -0
- package/build-module/social-link/icons/index.js.map +1 -1
- package/build-module/social-link/icons/whatsapp.js +15 -0
- package/build-module/social-link/icons/whatsapp.js.map +1 -0
- package/build-module/social-link/variations.js +8 -1
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/template-part/edit/index.js +20 -11
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +33 -15
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/search.js +84 -0
- package/build-module/template-part/edit/utils/search.js.map +1 -0
- package/build-style/button/style-rtl.css +1 -1
- package/build-style/button/style.css +1 -1
- package/build-style/comments/editor-rtl.css +122 -0
- package/build-style/comments/editor.css +122 -0
- package/build-style/{post-comments → comments}/style-rtl.css +1 -0
- package/build-style/{post-comments → comments}/style.css +1 -0
- package/build-style/common-rtl.css +7 -0
- package/build-style/common.css +7 -0
- package/build-style/cover/style-rtl.css +2 -2
- package/build-style/cover/style.css +2 -2
- package/build-style/{post-comments/editor.css → editor-elements-rtl.css} +8 -2
- package/build-style/{post-comments/editor-rtl.css → editor-elements.css} +8 -2
- package/build-style/editor-rtl.css +151 -10
- package/build-style/editor.css +151 -10
- package/build-style/gallery/style-rtl.css +7 -2
- package/build-style/gallery/style.css +7 -2
- package/build-style/image/editor-rtl.css +4 -3
- package/build-style/image/editor.css +4 -3
- package/build-style/image/style-rtl.css +33 -3
- package/build-style/image/style.css +33 -3
- package/build-style/post-comments-form/style-rtl.css +0 -1
- package/build-style/post-comments-form/style.css +0 -1
- package/build-style/social-link/editor-rtl.css +1 -0
- package/build-style/social-link/editor.css +1 -0
- package/build-style/social-links/style-rtl.css +8 -0
- package/build-style/social-links/style.css +8 -0
- package/build-style/style-rtl.css +170 -127
- package/build-style/style.css +170 -127
- package/build-style/template-part/editor-rtl.css +14 -3
- package/build-style/template-part/editor.css +14 -3
- package/package.json +28 -28
- package/src/button/edit.js +1 -0
- package/src/button/style.scss +3 -1
- package/src/buttons/edit.js +1 -5
- package/src/columns/edit.native.js +2 -2
- package/src/comments/block.json +6 -1
- package/src/comments/edit/comments-legacy.js +71 -0
- package/src/comments/edit/index.js +35 -0
- package/src/comments/edit/placeholder.js +124 -0
- package/src/comments/{edit.js → edit/template.js} +1 -28
- package/src/comments/editor.scss +9 -0
- package/src/comments/index.php +219 -0
- package/src/comments/save.js +8 -7
- package/src/{post-comments → comments}/style.scss +7 -0
- package/src/common.scss +2 -0
- package/src/cover/style.scss +2 -2
- package/src/cover/transforms.js +2 -2
- package/src/editor-elements.scss +10 -0
- package/src/editor.scss +2 -1
- package/src/embed/embed-placeholder.native.js +2 -3
- package/src/gallery/edit.js +4 -2
- package/src/gallery/style.scss +10 -1
- package/src/gallery/use-get-media.native.js +44 -0
- package/src/group/block.json +1 -0
- package/src/group/variations.js +2 -2
- package/src/image/block.json +7 -1
- package/src/image/deprecated.js +86 -0
- package/src/image/edit.js +6 -1
- package/src/image/edit.native.js +18 -7
- package/src/image/editor.scss +9 -4
- package/src/image/image.js +26 -16
- package/src/image/save.js +10 -1
- package/src/image/style.scss +39 -3
- package/src/index.js +0 -2
- package/src/index.native.js +2 -11
- package/src/list/transforms.js +0 -47
- package/src/list/v2/transforms.js +2 -40
- package/src/list-item/edit.js +10 -12
- package/src/list-item/hooks/index.js +1 -1
- package/src/list-item/hooks/use-merge.js +141 -0
- package/src/list-item/hooks/use-outdent-list-item.js +72 -74
- package/src/list-item/utils.js +27 -3
- package/src/media-text/deprecated.js +148 -1
- package/src/media-text/edit.js +2 -1
- package/src/media-text/save.js +18 -0
- package/src/more/save.js +3 -6
- package/src/navigation-link/edit.js +4 -3
- package/src/navigation-submenu/edit.js +1 -0
- package/src/page-list/edit.js +9 -0
- package/src/paragraph/edit.js +8 -14
- package/src/post-comments-form/edit.js +2 -71
- package/src/post-comments-form/form.js +80 -5
- package/src/post-comments-form/index.php +1 -1
- package/src/post-comments-form/style.scss +0 -1
- package/src/post-terms/edit.js +3 -2
- package/src/query-no-results/edit.js +2 -5
- package/src/query-pagination-next/edit.js +1 -0
- package/src/query-pagination-previous/edit.js +1 -0
- package/src/quote/deprecated.js +213 -99
- package/src/quote/edit.js +77 -52
- package/src/quote/index.js +10 -33
- package/src/quote/save.js +5 -5
- package/src/quote/{v2/test → test}/migrate.js +2 -7
- package/src/quote/transforms.js +117 -147
- package/src/social-link/editor.scss +3 -0
- package/src/social-link/icons/index.js +1 -0
- package/src/social-link/icons/whatsapp.js +10 -0
- package/src/social-link/index.php +4 -0
- package/src/social-link/socials-with-bg.scss +5 -0
- package/src/social-link/socials-without-bg.scss +5 -0
- package/src/social-link/variations.js +7 -0
- package/src/style.scss +1 -2
- package/src/template-part/edit/index.js +37 -24
- package/src/template-part/edit/selection-modal.js +68 -40
- package/src/template-part/edit/utils/search.js +76 -0
- package/src/template-part/editor.scss +21 -9
- package/src/template-part/index.php +56 -2
- package/build/comments/edit.js.map +0 -1
- package/build/list-item/hooks/use-backspace.js +0 -59
- package/build/list-item/hooks/use-backspace.js.map +0 -1
- package/build/post-comments/edit.js +0 -184
- package/build/post-comments/edit.js.map +0 -1
- package/build/post-comments/index.js +0 -72
- package/build/post-comments/index.js.map +0 -1
- package/build/quote/v2/deprecated.js +0 -133
- package/build/quote/v2/deprecated.js.map +0 -1
- package/build/quote/v2/edit.js +0 -139
- package/build/quote/v2/edit.js.map +0 -1
- package/build/quote/v2/index.js +0 -49
- package/build/quote/v2/index.js.map +0 -1
- package/build/quote/v2/save.js +0 -43
- package/build/quote/v2/save.js.map +0 -1
- package/build/quote/v2/transforms.js +0 -156
- package/build/quote/v2/transforms.js.map +0 -1
- package/build-module/comments/edit.js +0 -59
- package/build-module/comments/edit.js.map +0 -1
- package/build-module/list-item/hooks/use-backspace.js +0 -44
- package/build-module/list-item/hooks/use-backspace.js.map +0 -1
- package/build-module/post-comments/edit.js +0 -171
- package/build-module/post-comments/edit.js.map +0 -1
- package/build-module/post-comments/index.js +0 -59
- package/build-module/post-comments/index.js.map +0 -1
- package/build-module/quote/v2/deprecated.js +0 -116
- package/build-module/quote/v2/deprecated.js.map +0 -1
- package/build-module/quote/v2/edit.js +0 -122
- package/build-module/quote/v2/edit.js.map +0 -1
- package/build-module/quote/v2/index.js +0 -33
- package/build-module/quote/v2/index.js.map +0 -1
- package/build-module/quote/v2/save.js +0 -30
- package/build-module/quote/v2/save.js.map +0 -1
- package/build-module/quote/v2/transforms.js +0 -147
- package/build-module/quote/v2/transforms.js.map +0 -1
- package/src/list-item/hooks/use-backspace.js +0 -51
- package/src/post-comments/block.json +0 -45
- package/src/post-comments/edit.js +0 -247
- package/src/post-comments/editor.scss +0 -3
- package/src/post-comments/index.js +0 -18
- package/src/post-comments/index.php +0 -87
- package/src/quote/v2/deprecated.js +0 -107
- package/src/quote/v2/edit.js +0 -139
- package/src/quote/v2/index.js +0 -36
- package/src/quote/v2/save.js +0 -26
- package/src/quote/v2/transforms.js +0 -155
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useCallback, useMemo } from '@wordpress/element';
|
|
4
|
+
import { useCallback, useMemo, useState } from '@wordpress/element';
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { store as noticesStore } from '@wordpress/notices';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
@@ -11,6 +11,10 @@ import {
|
|
|
11
11
|
__experimentalBlockPatternsList as BlockPatternsList,
|
|
12
12
|
store as blockEditorStore,
|
|
13
13
|
} from '@wordpress/block-editor';
|
|
14
|
+
import {
|
|
15
|
+
SearchControl,
|
|
16
|
+
__experimentalHStack as HStack,
|
|
17
|
+
} from '@wordpress/components';
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* Internal dependencies
|
|
@@ -21,6 +25,7 @@ import {
|
|
|
21
25
|
useCreateTemplatePartFromBlocks,
|
|
22
26
|
} from './utils/hooks';
|
|
23
27
|
import { createTemplatePartId } from './utils/create-template-part-id';
|
|
28
|
+
import { searchPatterns } from './utils/search';
|
|
24
29
|
|
|
25
30
|
export default function TemplatePartSelectionModal( {
|
|
26
31
|
setAttributes,
|
|
@@ -29,6 +34,8 @@ export default function TemplatePartSelectionModal( {
|
|
|
29
34
|
area,
|
|
30
35
|
clientId,
|
|
31
36
|
} ) {
|
|
37
|
+
const [ searchValue, setSearchValue ] = useState( '' );
|
|
38
|
+
|
|
32
39
|
// When the templatePartId is undefined,
|
|
33
40
|
// it means the user is creating a new one from the placeholder.
|
|
34
41
|
const isReplacingTemplatePartContent = !! templatePartId;
|
|
@@ -37,18 +44,24 @@ export default function TemplatePartSelectionModal( {
|
|
|
37
44
|
templatePartId
|
|
38
45
|
);
|
|
39
46
|
// We can map template parts to block patters to reuse the BlockPatternsList UI
|
|
40
|
-
const
|
|
41
|
-
|
|
47
|
+
const filteredTemplateParts = useMemo( () => {
|
|
48
|
+
const partsAsPatterns = templateParts.map( ( templatePart ) => ( {
|
|
42
49
|
name: createTemplatePartId( templatePart.theme, templatePart.slug ),
|
|
43
50
|
title: templatePart.title.rendered,
|
|
44
51
|
blocks: parse( templatePart.content.raw ),
|
|
45
52
|
templatePart,
|
|
46
53
|
} ) );
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
|
|
55
|
+
return searchPatterns( partsAsPatterns, searchValue );
|
|
56
|
+
}, [ templateParts, searchValue ] );
|
|
57
|
+
const shownTemplateParts = useAsyncList( filteredTemplateParts );
|
|
50
58
|
const blockPatterns = useAlternativeBlockPatterns( area, clientId );
|
|
51
|
-
const
|
|
59
|
+
const filteredBlockPatterns = useMemo( () => {
|
|
60
|
+
return searchPatterns( blockPatterns, searchValue );
|
|
61
|
+
}, [ blockPatterns, searchValue ] );
|
|
62
|
+
const shownBlockPatterns = useAsyncList( filteredBlockPatterns );
|
|
63
|
+
|
|
64
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
52
65
|
const { replaceInnerBlocks } = useDispatch( blockEditorStore );
|
|
53
66
|
|
|
54
67
|
const onTemplatePartSelect = useCallback( ( templatePart ) => {
|
|
@@ -75,41 +88,56 @@ export default function TemplatePartSelectionModal( {
|
|
|
75
88
|
setAttributes
|
|
76
89
|
);
|
|
77
90
|
|
|
91
|
+
const hasTemplateParts = !! filteredTemplateParts.length;
|
|
92
|
+
const hasBlockPatterns = !! filteredBlockPatterns.length;
|
|
93
|
+
|
|
78
94
|
return (
|
|
79
|
-
|
|
80
|
-
<div className="block-library-template-part__selection-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
<div className="block-library-template-part__selection-content">
|
|
96
|
+
<div className="block-library-template-part__selection-search">
|
|
97
|
+
<SearchControl
|
|
98
|
+
onChange={ setSearchValue }
|
|
99
|
+
value={ searchValue }
|
|
100
|
+
label={ __( 'Search for replacements' ) }
|
|
101
|
+
placeholder={ __( 'Search' ) }
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
{ hasTemplateParts && (
|
|
105
|
+
<div>
|
|
106
|
+
<h2>{ __( 'Existing template parts' ) }</h2>
|
|
107
|
+
<BlockPatternsList
|
|
108
|
+
blockPatterns={ filteredTemplateParts }
|
|
109
|
+
shownPatterns={ shownTemplateParts }
|
|
110
|
+
onClickPattern={ ( pattern ) => {
|
|
111
|
+
onTemplatePartSelect( pattern.templatePart );
|
|
112
|
+
} }
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
) }
|
|
93
116
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
117
|
+
{ hasBlockPatterns && (
|
|
118
|
+
<div>
|
|
119
|
+
<h2>{ __( 'Patterns' ) }</h2>
|
|
120
|
+
<BlockPatternsList
|
|
121
|
+
blockPatterns={ filteredBlockPatterns }
|
|
122
|
+
shownPatterns={ shownBlockPatterns }
|
|
123
|
+
onClickPattern={ ( pattern, blocks ) => {
|
|
124
|
+
if ( isReplacingTemplatePartContent ) {
|
|
125
|
+
replaceInnerBlocks( clientId, blocks );
|
|
126
|
+
} else {
|
|
127
|
+
createFromBlocks( blocks, pattern.title );
|
|
128
|
+
}
|
|
106
129
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
onClose();
|
|
131
|
+
} }
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
) }
|
|
135
|
+
|
|
136
|
+
{ ! hasTemplateParts && ! hasBlockPatterns && (
|
|
137
|
+
<HStack alignment="center">
|
|
138
|
+
<p>{ __( 'No results found.' ) }</p>
|
|
139
|
+
</HStack>
|
|
140
|
+
) }
|
|
141
|
+
</div>
|
|
114
142
|
);
|
|
115
143
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import removeAccents from 'remove-accents';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sanitizes the search input string.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} input The search input to normalize.
|
|
10
|
+
*
|
|
11
|
+
* @return {string} The normalized search input.
|
|
12
|
+
*/
|
|
13
|
+
function normalizeSearchInput( input = '' ) {
|
|
14
|
+
// Disregard diacritics.
|
|
15
|
+
input = removeAccents( input );
|
|
16
|
+
|
|
17
|
+
// Trim & Lowercase.
|
|
18
|
+
input = input.trim().toLowerCase();
|
|
19
|
+
|
|
20
|
+
return input;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get the search rank for a given pattern and a specific search term.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} pattern Pattern to rank
|
|
27
|
+
* @param {string} searchValue Search term
|
|
28
|
+
* @return {number} A pattern search rank
|
|
29
|
+
*/
|
|
30
|
+
function getPatternSearchRank( pattern, searchValue ) {
|
|
31
|
+
const normalizedSearchValue = normalizeSearchInput( searchValue );
|
|
32
|
+
const normalizedTitle = normalizeSearchInput( pattern.title );
|
|
33
|
+
|
|
34
|
+
let rank = 0;
|
|
35
|
+
|
|
36
|
+
if ( normalizedSearchValue === normalizedTitle ) {
|
|
37
|
+
rank += 30;
|
|
38
|
+
} else if ( normalizedTitle.startsWith( normalizedSearchValue ) ) {
|
|
39
|
+
rank += 20;
|
|
40
|
+
} else {
|
|
41
|
+
const searchTerms = normalizedSearchValue.split( ' ' );
|
|
42
|
+
const hasMatchedTerms = searchTerms.every( ( searchTerm ) =>
|
|
43
|
+
normalizedTitle.includes( searchTerm )
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Prefer pattern with every search word in the title.
|
|
47
|
+
if ( hasMatchedTerms ) {
|
|
48
|
+
rank += 10;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return rank;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Filters an pattern list given a search term.
|
|
57
|
+
*
|
|
58
|
+
* @param {Array} patterns Item list
|
|
59
|
+
* @param {string} searchValue Search input.
|
|
60
|
+
*
|
|
61
|
+
* @return {Array} Filtered pattern list.
|
|
62
|
+
*/
|
|
63
|
+
export function searchPatterns( patterns = [], searchValue = '' ) {
|
|
64
|
+
if ( ! searchValue ) {
|
|
65
|
+
return patterns;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const rankedPatterns = patterns
|
|
69
|
+
.map( ( pattern ) => {
|
|
70
|
+
return [ pattern, getPatternSearchRank( pattern, searchValue ) ];
|
|
71
|
+
} )
|
|
72
|
+
.filter( ( [ , rank ] ) => rank > 0 );
|
|
73
|
+
|
|
74
|
+
rankedPatterns.sort( ( [ , rank1 ], [ , rank2 ] ) => rank2 - rank1 );
|
|
75
|
+
return rankedPatterns.map( ( [ pattern ] ) => pattern );
|
|
76
|
+
}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
.block-editor-template-part__selection-modal {
|
|
2
|
+
z-index: z-index(".block-editor-template-part__selection-modal");
|
|
3
|
+
|
|
2
4
|
// To keep modal dimensions consistent as subsections are navigated, width
|
|
3
5
|
// and height are used instead of max-(width/height).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
.components-modal__frame {
|
|
7
|
+
@include break-small() {
|
|
8
|
+
width: calc(100% - #{ $grid-unit-20 * 2 });
|
|
9
|
+
height: calc(100% - #{ $header-height * 2 });
|
|
10
|
+
}
|
|
11
|
+
@include break-medium() {
|
|
12
|
+
width: $break-medium - $grid-unit-20 * 2;
|
|
13
|
+
}
|
|
14
|
+
@include break-large() {
|
|
15
|
+
height: 70%;
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
}
|
|
19
|
+
|
|
20
|
+
.block-library-template-part__selection-search {
|
|
21
|
+
background: $white;
|
|
22
|
+
position: sticky;
|
|
23
|
+
top: 0;
|
|
24
|
+
padding: $grid-unit-20 0;
|
|
25
|
+
z-index: z-index(".block-library-template-part__selection-search");
|
|
26
|
+
}
|
|
@@ -159,11 +159,11 @@ function render_block_core_template_part( $attributes ) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
|
-
* Returns an array of variation objects for the template part block.
|
|
162
|
+
* Returns an array of area variation objects for the template part block.
|
|
163
163
|
*
|
|
164
164
|
* @return array Array containing the block variation objects.
|
|
165
165
|
*/
|
|
166
|
-
function
|
|
166
|
+
function build_template_part_block_area_variations() {
|
|
167
167
|
$variations = array();
|
|
168
168
|
$defined_areas = get_allowed_block_template_part_areas();
|
|
169
169
|
foreach ( $defined_areas as $area ) {
|
|
@@ -183,6 +183,60 @@ function build_template_part_block_variations() {
|
|
|
183
183
|
return $variations;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Returns an array of instance variation objects for the template part block
|
|
188
|
+
*
|
|
189
|
+
* @return array Array containing the block variation objects.
|
|
190
|
+
*/
|
|
191
|
+
function build_template_part_block_instance_variations() {
|
|
192
|
+
$variations = array();
|
|
193
|
+
$template_parts = get_block_templates(
|
|
194
|
+
array(
|
|
195
|
+
'post_type' => 'wp_template_part',
|
|
196
|
+
),
|
|
197
|
+
'wp_template_part'
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
$defined_areas = get_allowed_block_template_part_areas();
|
|
201
|
+
$icon_by_area = array_combine( array_column( $defined_areas, 'area' ), array_column( $defined_areas, 'icon' ) );
|
|
202
|
+
|
|
203
|
+
foreach ( $template_parts as $template_part ) {
|
|
204
|
+
$variations[] = array(
|
|
205
|
+
'name' => sanitize_title( $template_part->slug ),
|
|
206
|
+
'title' => $template_part->title,
|
|
207
|
+
// If there's no description for the template part don't show the
|
|
208
|
+
// block description. This is a bit hacky, but prevent the fallback
|
|
209
|
+
// by using a non-breaking space so that the value of description
|
|
210
|
+
// isn't falsey.
|
|
211
|
+
'description' => $template_part->description || ' ',
|
|
212
|
+
'attributes' => array(
|
|
213
|
+
'slug' => $template_part->slug,
|
|
214
|
+
'theme' => $template_part->theme,
|
|
215
|
+
'area' => $template_part->area,
|
|
216
|
+
),
|
|
217
|
+
'scope' => array( 'inserter' ),
|
|
218
|
+
'icon' => $icon_by_area[ $template_part->area ],
|
|
219
|
+
'example' => array(
|
|
220
|
+
'attributes' => array(
|
|
221
|
+
'slug' => $template_part->slug,
|
|
222
|
+
'theme' => $template_part->theme,
|
|
223
|
+
'area' => $template_part->area,
|
|
224
|
+
),
|
|
225
|
+
),
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
return $variations;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Returns an array of all template part block variations.
|
|
233
|
+
*
|
|
234
|
+
* @return array Array containing the block variation objects.
|
|
235
|
+
*/
|
|
236
|
+
function build_template_part_block_variations() {
|
|
237
|
+
return array_merge( build_template_part_block_area_variations(), build_template_part_block_instance_variations() );
|
|
238
|
+
}
|
|
239
|
+
|
|
186
240
|
/**
|
|
187
241
|
* Registers the `core/template-part` block on the server.
|
|
188
242
|
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments/edit.js"],"names":["TEMPLATE","width","size","style","border","radius","fontSize","layout","type","spacing","margin","top","bottom","CommentsEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,C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B,EAAiC;AACzDE,IAAAA,QAAQ,EAAEpB;AAD+C,GAAjC,CAAzB;AAIA,SACC,qDACC,4BAAC,kCAAD;AACC,IAAA,UAAU,EAAGc,UADd;AAEC,IAAA,aAAa,EAAGC;AAFjB,IADD,EAKC,4BAAC,OAAD,EAAcI,gBAAd,CALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comments-title' ],\n\t[\n\t\t'core/comment-template',\n\t\t{},\n\t\t[\n\t\t\t[\n\t\t\t\t'core/columns',\n\t\t\t\t{},\n\t\t\t\t[\n\t\t\t\t\t[\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{ width: '40px' },\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'core/avatar',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsize: 40,\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tborder: { radius: '20px' },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t],\n\t\t\t\t\t],\n\t\t\t\t\t[\n\t\t\t\t\t\t'core/column',\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'core/comment-author-name',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfontSize: 'small',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlayout: { type: 'flex' },\n\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\t\t\t\ttop: '0px',\n\t\t\t\t\t\t\t\t\t\t\t\tbottom: '0px',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t'core/comment-date',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tfontSize: 'small',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t'core/comment-edit-link',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tfontSize: 'small',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t[ 'core/comment-content' ],\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'core/comment-reply-link',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfontSize: 'small',\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],\n\t\t\t],\n\t\t],\n\t],\n\t[ 'core/comments-pagination' ],\n\t[ 'core/post-comments-form' ],\n];\n\nexport default function CommentsEdit( { attributes, setAttributes } ) {\n\tconst { tagName: TagName } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<CommentsInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = useBackspace;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _compose = require("@wordpress/compose");
|
|
13
|
-
|
|
14
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
19
|
-
|
|
20
|
-
var _useOutdentListItem = _interopRequireDefault(require("./use-outdent-list-item"));
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* WordPress dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Internal dependencies
|
|
28
|
-
*/
|
|
29
|
-
function useBackspace(props) {
|
|
30
|
-
const {
|
|
31
|
-
getSelectionStart,
|
|
32
|
-
getSelectionEnd
|
|
33
|
-
} = (0, _data.useSelect)(_blockEditor.store);
|
|
34
|
-
const propsRef = (0, _element.useRef)(props);
|
|
35
|
-
propsRef.current = props;
|
|
36
|
-
const [canOutdent, outdentListItem] = (0, _useOutdentListItem.default)(propsRef.current.clientId);
|
|
37
|
-
return (0, _compose.useRefEffect)(element => {
|
|
38
|
-
function onKeyDown(event) {
|
|
39
|
-
if (event.defaultPrevented || event.keyCode !== _keycodes.BACKSPACE) {
|
|
40
|
-
return;
|
|
41
|
-
} // Handle only if we have a collapsed selection at the
|
|
42
|
-
// start of a list item and we can outdent.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!canOutdent || [getSelectionStart().offset, getSelectionEnd().offset].some(offset => offset !== 0)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
outdentListItem();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
element.addEventListener('keydown', onKeyDown);
|
|
54
|
-
return () => {
|
|
55
|
-
element.removeEventListener('keydown', onKeyDown);
|
|
56
|
-
};
|
|
57
|
-
}, [canOutdent]);
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=use-backspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-backspace.js"],"names":["useBackspace","props","getSelectionStart","getSelectionEnd","blockEditorStore","propsRef","current","canOutdent","outdentListItem","clientId","element","onKeyDown","event","defaultPrevented","keyCode","BACKSPACE","offset","some","preventDefault","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MACL,qBAAWC,kBAAX,CADD;AAEA,QAAMC,QAAQ,GAAG,qBAAQJ,KAAR,CAAjB;AACAI,EAAAA,QAAQ,CAACC,OAAT,GAAmBL,KAAnB;AACA,QAAM,CAAEM,UAAF,EAAcC,eAAd,IAAkC,iCACvCH,QAAQ,CAACC,OAAT,CAAiBG,QADsB,CAAxC;AAGA,SAAO,2BACJC,OAAF,IAAe;AACd,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAKA,KAAK,CAACC,gBAAN,IAA0BD,KAAK,CAACE,OAAN,KAAkBC,mBAAjD,EAA6D;AAC5D;AACA,OAH0B,CAI3B;AACA;;;AACA,UACC,CAAER,UAAF,IACA,CACCL,iBAAiB,GAAGc,MADrB,EAECb,eAAe,GAAGa,MAFnB,EAGEC,IAHF,CAGUD,MAAF,IAAcA,MAAM,KAAK,CAHjC,CAFD,EAME;AACD;AACA;;AACDJ,MAAAA,KAAK,CAACM,cAAN;AACAV,MAAAA,eAAe;AACf;;AAEDE,IAAAA,OAAO,CAACS,gBAAR,CAA0B,SAA1B,EAAqCR,SAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACU,mBAAR,CAA6B,SAA7B,EAAwCT,SAAxC;AACA,KAFD;AAGA,GAzBK,EA0BN,CAAEJ,UAAF,CA1BM,CAAP;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { BACKSPACE } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useOutdentListItem from './use-outdent-list-item';\n\nexport default function useBackspace( props ) {\n\tconst { getSelectionStart, getSelectionEnd } =\n\t\tuseSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem(\n\t\tpropsRef.current.clientId\n\t);\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tif ( event.defaultPrevented || event.keyCode !== BACKSPACE ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Handle only if we have a collapsed selection at the\n\t\t\t\t// start of a list item and we can outdent.\n\t\t\t\tif (\n\t\t\t\t\t! canOutdent ||\n\t\t\t\t\t[\n\t\t\t\t\t\tgetSelectionStart().offset,\n\t\t\t\t\t\tgetSelectionEnd().offset,\n\t\t\t\t\t].some( ( offset ) => offset !== 0 )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.preventDefault();\n\t\t\t\toutdentListItem();\n\t\t\t}\n\n\t\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t\t};\n\t\t},\n\t\t[ canOutdent ]\n\t);\n}\n"]}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = PostCommentsEdit;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
15
|
-
|
|
16
|
-
var _i18n = require("@wordpress/i18n");
|
|
17
|
-
|
|
18
|
-
var _data = require("@wordpress/data");
|
|
19
|
-
|
|
20
|
-
var _coreData = require("@wordpress/core-data");
|
|
21
|
-
|
|
22
|
-
var _compose = require("@wordpress/compose");
|
|
23
|
-
|
|
24
|
-
var _form = _interopRequireDefault(require("../post-comments-form/form"));
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* External dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* WordPress dependencies
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Internal dependencies
|
|
36
|
-
*/
|
|
37
|
-
function PostCommentsEdit(_ref) {
|
|
38
|
-
let {
|
|
39
|
-
attributes: {
|
|
40
|
-
textAlign
|
|
41
|
-
},
|
|
42
|
-
setAttributes,
|
|
43
|
-
context: {
|
|
44
|
-
postType,
|
|
45
|
-
postId
|
|
46
|
-
}
|
|
47
|
-
} = _ref;
|
|
48
|
-
let [postTitle] = (0, _coreData.useEntityProp)('postType', postType, 'title', postId);
|
|
49
|
-
postTitle = postTitle || (0, _i18n.__)('Post Title');
|
|
50
|
-
const [commentStatus] = (0, _coreData.useEntityProp)('postType', postType, 'comment_status', postId);
|
|
51
|
-
const {
|
|
52
|
-
avatarURL,
|
|
53
|
-
defaultCommentStatus
|
|
54
|
-
} = (0, _data.useSelect)(select => select(_blockEditor.store).getSettings().__experimentalDiscussionSettings);
|
|
55
|
-
const isSiteEditor = postType === undefined || postId === undefined;
|
|
56
|
-
const postTypeSupportsComments = (0, _data.useSelect)(select => {
|
|
57
|
-
var _select$getPostType;
|
|
58
|
-
|
|
59
|
-
return postType ? !!((_select$getPostType = select(_coreData.store).getPostType(postType)) !== null && _select$getPostType !== void 0 && _select$getPostType.supports.comments) : false;
|
|
60
|
-
});
|
|
61
|
-
let warning = (0, _i18n.__)('Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the "Comments" block.');
|
|
62
|
-
let showPlaceholder = true;
|
|
63
|
-
|
|
64
|
-
if (!isSiteEditor && 'open' !== commentStatus) {
|
|
65
|
-
if ('closed' === commentStatus) {
|
|
66
|
-
warning = (0, _i18n.sprintf)(
|
|
67
|
-
/* translators: 1: Post type (i.e. "post", "page") */
|
|
68
|
-
(0, _i18n.__)('Post Comments block: Comments to this %s are not allowed.'), postType);
|
|
69
|
-
showPlaceholder = false;
|
|
70
|
-
} else if (!postTypeSupportsComments) {
|
|
71
|
-
warning = (0, _i18n.sprintf)(
|
|
72
|
-
/* translators: 1: Post type (i.e. "post", "page") */
|
|
73
|
-
(0, _i18n.__)('Post Comments block: Comments for this post type (%s) are not enabled.'), postType);
|
|
74
|
-
showPlaceholder = false;
|
|
75
|
-
} else if ('open' !== defaultCommentStatus) {
|
|
76
|
-
warning = (0, _i18n.__)('Post Comments block: Comments are not enabled.');
|
|
77
|
-
showPlaceholder = false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
82
|
-
className: (0, _classnames.default)({
|
|
83
|
-
[`has-text-align-${textAlign}`]: textAlign
|
|
84
|
-
})
|
|
85
|
-
});
|
|
86
|
-
const disabledRef = (0, _compose.useDisabled)();
|
|
87
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
|
|
88
|
-
group: "block"
|
|
89
|
-
}, (0, _element.createElement)(_blockEditor.AlignmentControl, {
|
|
90
|
-
value: textAlign,
|
|
91
|
-
onChange: nextAlign => {
|
|
92
|
-
setAttributes({
|
|
93
|
-
textAlign: nextAlign
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
})), (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_blockEditor.Warning, null, warning), showPlaceholder && (0, _element.createElement)("div", {
|
|
97
|
-
className: "wp-block-post-comments__placeholder",
|
|
98
|
-
ref: disabledRef
|
|
99
|
-
}, (0, _element.createElement)("h3", null,
|
|
100
|
-
/* translators: %s: Post title. */
|
|
101
|
-
(0, _i18n.sprintf)((0, _i18n.__)('One response to %s'), postTitle)), (0, _element.createElement)("div", {
|
|
102
|
-
className: "navigation"
|
|
103
|
-
}, (0, _element.createElement)("div", {
|
|
104
|
-
className: "alignleft"
|
|
105
|
-
}, (0, _element.createElement)("a", {
|
|
106
|
-
href: "#top"
|
|
107
|
-
}, "\xAB ", (0, _i18n.__)('Older Comments'))), (0, _element.createElement)("div", {
|
|
108
|
-
className: "alignright"
|
|
109
|
-
}, (0, _element.createElement)("a", {
|
|
110
|
-
href: "#top"
|
|
111
|
-
}, (0, _i18n.__)('Newer Comments'), " \xBB"))), (0, _element.createElement)("ol", {
|
|
112
|
-
className: "commentlist"
|
|
113
|
-
}, (0, _element.createElement)("li", {
|
|
114
|
-
className: "comment even thread-even depth-1"
|
|
115
|
-
}, (0, _element.createElement)("article", {
|
|
116
|
-
className: "comment-body"
|
|
117
|
-
}, (0, _element.createElement)("footer", {
|
|
118
|
-
className: "comment-meta"
|
|
119
|
-
}, (0, _element.createElement)("div", {
|
|
120
|
-
className: "comment-author vcard"
|
|
121
|
-
}, (0, _element.createElement)("img", {
|
|
122
|
-
alt: "Commenter Avatar",
|
|
123
|
-
src: avatarURL,
|
|
124
|
-
className: "avatar avatar-32 photo",
|
|
125
|
-
height: "32",
|
|
126
|
-
width: "32",
|
|
127
|
-
loading: "lazy"
|
|
128
|
-
}), (0, _element.createInterpolateElement)((0, _i18n.sprintf)(
|
|
129
|
-
/* translators: %s: Comment author link. */
|
|
130
|
-
(0, _i18n.__)('%s <span>says:</span>'), (0, _i18n.sprintf)('<cite><a>%s</a></cite>', (0, _i18n.__)('A WordPress Commenter'))), {
|
|
131
|
-
span: (0, _element.createElement)("span", {
|
|
132
|
-
className: "says"
|
|
133
|
-
}),
|
|
134
|
-
a:
|
|
135
|
-
/* eslint-disable jsx-a11y/anchor-has-content */
|
|
136
|
-
(0, _element.createElement)("a", {
|
|
137
|
-
href: "#top",
|
|
138
|
-
className: "url"
|
|
139
|
-
})
|
|
140
|
-
/* eslint-enable jsx-a11y/anchor-has-content */
|
|
141
|
-
,
|
|
142
|
-
cite: (0, _element.createElement)("cite", {
|
|
143
|
-
className: "fn"
|
|
144
|
-
})
|
|
145
|
-
})), (0, _element.createElement)("div", {
|
|
146
|
-
className: "comment-metadata"
|
|
147
|
-
}, (0, _element.createElement)("a", {
|
|
148
|
-
href: "#top"
|
|
149
|
-
}, (0, _element.createElement)("time", {
|
|
150
|
-
dateTime: "2000-01-01T12:00:00+00:00"
|
|
151
|
-
}, (0, _i18n.__)('January 1, 2000 at 12:00 am'))), ' ', (0, _element.createElement)("span", {
|
|
152
|
-
className: "edit-link"
|
|
153
|
-
}, (0, _element.createElement)("a", {
|
|
154
|
-
className: "comment-edit-link",
|
|
155
|
-
href: "#top"
|
|
156
|
-
}, (0, _i18n.__)('Edit'))))), (0, _element.createElement)("div", {
|
|
157
|
-
className: "comment-content"
|
|
158
|
-
}, (0, _element.createElement)("p", null, (0, _i18n.__)('Hi, this is a comment.'), (0, _element.createElement)("br", null), (0, _i18n.__)('To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'), (0, _element.createElement)("br", null), (0, _element.createInterpolateElement)((0, _i18n.__)('Commenter avatars come from <a>Gravatar</a>'), {
|
|
159
|
-
a:
|
|
160
|
-
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
|
|
161
|
-
(0, _element.createElement)("a", {
|
|
162
|
-
href: "https://gravatar.com/"
|
|
163
|
-
})
|
|
164
|
-
}))), (0, _element.createElement)("div", {
|
|
165
|
-
className: "reply"
|
|
166
|
-
}, (0, _element.createElement)("a", {
|
|
167
|
-
className: "comment-reply-link",
|
|
168
|
-
href: "#top",
|
|
169
|
-
"aria-label": (0, _i18n.sprintf)(
|
|
170
|
-
/* translators: Comment reply button text. %s: Comment author name. */
|
|
171
|
-
(0, _i18n.__)('Reply to %s'), (0, _i18n.__)('A WordPress Commenter'))
|
|
172
|
-
}, (0, _i18n.__)('Reply')))))), (0, _element.createElement)("div", {
|
|
173
|
-
className: "navigation"
|
|
174
|
-
}, (0, _element.createElement)("div", {
|
|
175
|
-
className: "alignleft"
|
|
176
|
-
}, (0, _element.createElement)("a", {
|
|
177
|
-
href: "#top"
|
|
178
|
-
}, "\xAB ", (0, _i18n.__)('Older Comments'))), (0, _element.createElement)("div", {
|
|
179
|
-
className: "alignright"
|
|
180
|
-
}, (0, _element.createElement)("a", {
|
|
181
|
-
href: "#top"
|
|
182
|
-
}, (0, _i18n.__)('Newer Comments'), " \xBB"))), (0, _element.createElement)(_form.default, null))));
|
|
183
|
-
}
|
|
184
|
-
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments/edit.js"],"names":["PostCommentsEdit","attributes","textAlign","setAttributes","context","postType","postId","postTitle","commentStatus","avatarURL","defaultCommentStatus","select","blockEditorStore","getSettings","__experimentalDiscussionSettings","isSiteEditor","undefined","postTypeSupportsComments","coreStore","getPostType","supports","comments","warning","showPlaceholder","blockProps","className","disabledRef","nextAlign","span","a","cite"],"mappings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CADD,CA9DD,EAoFC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AACC,IAAA,SAAS,EAAC,oBADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,kBAAa;AACZ;AACA,kBAAI,aAAJ,CAFY,EAGZ,cAAI,uBAAJ,CAHY;AAHd,KASG,cAAI,OAAJ,CATH,CADD,CApFD,CADD,CADD,CApBD,EA2HC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,IAAI,EAAC;AAAR,cAAmB,cAAI,gBAAJ,CAAnB,CADD,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,IAAI,EAAC;AAAR,KAAiB,cAAI,gBAAJ,CAAjB,UADD,CAJD,CA3HD,EAoIC,4BAAC,aAAD,OApID,CAJF,CAVD,CADD;AAyJA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useDisabled } from '@wordpress/compose';\nimport { createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport CommentsForm from '../post-comments-form/form';\n\nexport default function PostCommentsEdit( {\n\tattributes: { textAlign },\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tlet [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tpostTitle = postTitle || __( 'Post Title' );\n\n\tconst [ commentStatus ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'comment_status',\n\t\tpostId\n\t);\n\n\tconst { avatarURL, defaultCommentStatus } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalDiscussionSettings\n\t);\n\n\tconst isSiteEditor = postType === undefined || postId === undefined;\n\n\tconst postTypeSupportsComments = useSelect( ( select ) =>\n\t\tpostType\n\t\t\t? !! select( coreStore ).getPostType( postType )?.supports.comments\n\t\t\t: false\n\t);\n\n\tlet warning = __(\n\t\t'Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the \"Comments\" block.'\n\t);\n\tlet showPlaceholder = true;\n\n\tif ( ! isSiteEditor && 'open' !== commentStatus ) {\n\t\tif ( 'closed' === commentStatus ) {\n\t\t\twarning = sprintf(\n\t\t\t\t/* translators: 1: Post type (i.e. \"post\", \"page\") */\n\t\t\t\t__(\n\t\t\t\t\t'Post Comments block: Comments to this %s are not allowed.'\n\t\t\t\t),\n\t\t\t\tpostType\n\t\t\t);\n\t\t\tshowPlaceholder = false;\n\t\t} else if ( ! postTypeSupportsComments ) {\n\t\t\twarning = sprintf(\n\t\t\t\t/* translators: 1: Post type (i.e. \"post\", \"page\") */\n\t\t\t\t__(\n\t\t\t\t\t'Post Comments block: Comments for this post type (%s) are not enabled.'\n\t\t\t\t),\n\t\t\t\tpostType\n\t\t\t);\n\t\t\tshowPlaceholder = false;\n\t\t} else if ( 'open' !== defaultCommentStatus ) {\n\t\t\twarning = __( 'Post Comments block: Comments are not enabled.' );\n\t\t\tshowPlaceholder = false;\n\t\t}\n\t}\n\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 disabledRef = useDisabled();\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>{ warning }</Warning>\n\n\t\t\t\t{ showPlaceholder && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"wp-block-post-comments__placeholder\"\n\t\t\t\t\t\tref={ disabledRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<h3>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* translators: %s: Post title. */\n\t\t\t\t\t\t\t\tsprintf( __( 'One response to %s' ), postTitle )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</h3>\n\n\t\t\t\t\t\t<div className=\"navigation\">\n\t\t\t\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">« { __( 'Older Comments' ) }</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } »</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<ol className=\"commentlist\">\n\t\t\t\t\t\t\t<li className=\"comment even thread-even depth-1\">\n\t\t\t\t\t\t\t\t<article className=\"comment-body\">\n\t\t\t\t\t\t\t\t\t<footer className=\"comment-meta\">\n\t\t\t\t\t\t\t\t\t\t<div className=\"comment-author vcard\">\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"Commenter Avatar\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ avatarURL }\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"avatar avatar-32 photo\"\n\t\t\t\t\t\t\t\t\t\t\t\theight=\"32\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth=\"32\"\n\t\t\t\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: Comment author link. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'%s <span>says:</span>'\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'<cite><a>%s</a></cite>',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'A WordPress Commenter'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span className=\"says\" />\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* eslint-disable jsx-a11y/anchor-has-content */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"url\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* eslint-enable jsx-a11y/anchor-has-content */\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\tcite: (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<cite className=\"fn\" />\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t\t<div className=\"comment-metadata\">\n\t\t\t\t\t\t\t\t\t\t\t<a href=\"#top\">\n\t\t\t\t\t\t\t\t\t\t\t\t<time dateTime=\"2000-01-01T12:00:00+00:00\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'January 1, 2000 at 12:00 am'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"edit-link\">\n\t\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"comment-edit-link\"\n\t\t\t\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</footer>\n\n\t\t\t\t\t\t\t\t\t<div className=\"comment-content\">\n\t\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Hi, this is a comment.' ) }\n\t\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\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\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Commenter avatars come from <a>Gravatar</a>'\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/anchor-has-content */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https://gravatar.com/\" />\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t<div className=\"reply\">\n\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"comment-reply-link\"\n\t\t\t\t\t\t\t\t\t\t\thref=\"#top\"\n\t\t\t\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: Comment reply button text. %s: Comment author name. */\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'Reply to %s' ),\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'A WordPress Commenter' )\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Reply' ) }\n\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</article>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ol>\n\n\t\t\t\t\t\t<div className=\"navigation\">\n\t\t\t\t\t\t\t<div className=\"alignleft\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">« { __( 'Older Comments' ) }</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"alignright\">\n\t\t\t\t\t\t\t\t<a href=\"#top\">{ __( 'Newer Comments' ) } »</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<CommentsForm />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|