@wordpress/block-library 8.14.0 → 8.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/avatar/edit.js +1 -0
- package/build/avatar/edit.js.map +1 -1
- package/build/avatar/index.js +3 -0
- package/build/avatar/index.js.map +1 -1
- package/build/block/edit.js +2 -30
- package/build/block/edit.js.map +1 -1
- package/build/block/index.js +2 -1
- package/build/block/index.js.map +1 -1
- package/build/buttons/edit.js +2 -2
- package/build/buttons/edit.js.map +1 -1
- package/build/column/edit.native.js +1 -4
- package/build/column/edit.native.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/comment-author-avatar/edit.js +1 -0
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/cover/deprecated.js +4 -2
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/index.js +2 -1
- package/build/cover/index.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +37 -13
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/file/index.js +1 -2
- package/build/file/index.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/file/view-interactivity.js +23 -0
- package/build/file/view-interactivity.js.map +1 -0
- package/build/file/view.js +1 -15
- package/build/file/view.js.map +1 -1
- package/build/footnotes/edit.js +31 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +119 -23
- package/build/footnotes/format.js.map +1 -1
- package/build/footnotes/index.js +45 -4
- package/build/footnotes/index.js.map +1 -1
- package/build/gallery/edit.js +8 -6
- package/build/gallery/edit.js.map +1 -1
- package/build/image/deprecated.js +106 -2
- package/build/image/deprecated.js.map +1 -1
- package/build/image/image.js +2 -2
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -1
- package/build/image/index.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/latest-comments/edit.js +1 -0
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.js +2 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/edit.js +4 -4
- package/build/list/edit.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +10 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/missing/edit.native.js +7 -5
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/constants.js +10 -4
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +16 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +2 -2
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +1 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +4 -4
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/index.js +2 -3
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +33 -45
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view-interactivity.js +185 -0
- package/build/navigation/view-interactivity.js.map +1 -0
- package/build/navigation/view-modal.js +125 -0
- package/build/navigation/view-modal.js.map +1 -0
- package/build/navigation/view.js +71 -163
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +12 -7
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/edit.js +28 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/preformatted/index.js +4 -0
- package/build/preformatted/index.js.map +1 -1
- package/build/query-pagination/edit.js +1 -1
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-title/edit.js +43 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/quote/transforms.js +8 -0
- package/build/quote/transforms.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +4 -3
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/search/view.js +166 -62
- package/build/search/view.js.map +1 -1
- package/build/site-logo/edit.js +1 -0
- package/build/site-logo/edit.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/threads.js +25 -0
- package/build/social-link/icons/threads.js.map +1 -0
- package/build/social-link/variations.js +7 -0
- package/build/social-link/variations.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/import-controls.js +1 -1
- package/build/template-part/edit/import-controls.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/text-columns/edit.js +1 -0
- package/build/text-columns/edit.js.map +1 -1
- package/build-module/avatar/edit.js +1 -0
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/avatar/index.js +3 -0
- package/build-module/avatar/index.js.map +1 -1
- package/build-module/block/edit.js +4 -29
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/index.js +2 -1
- package/build-module/block/index.js.map +1 -1
- package/build-module/buttons/edit.js +2 -2
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/column/edit.native.js +1 -4
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +1 -0
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/cover/deprecated.js +4 -2
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/index.js +2 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +37 -14
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/file/index.js +1 -2
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/file/view-interactivity.js +19 -0
- package/build-module/file/view-interactivity.js.map +1 -0
- package/build-module/file/view.js +2 -15
- package/build-module/file/view.js.map +1 -1
- package/build-module/footnotes/edit.js +29 -2
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +120 -25
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/footnotes/index.js +45 -4
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/gallery/edit.js +8 -6
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/image/deprecated.js +107 -3
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/image.js +2 -2
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -1
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +3 -1
- package/build-module/index.js.map +1 -1
- package/build-module/latest-comments/edit.js +1 -0
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/edit.js +4 -4
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +10 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/missing/edit.native.js +8 -6
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/constants.js +8 -3
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -3
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +2 -2
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +4 -4
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/index.js +2 -3
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +35 -47
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view-interactivity.js +182 -0
- package/build-module/navigation/view-interactivity.js.map +1 -0
- package/build-module/navigation/view-modal.js +120 -0
- package/build-module/navigation/view-modal.js.map +1 -0
- package/build-module/navigation/view.js +72 -163
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +12 -7
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -2
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/edit.js +27 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/preformatted/index.js +4 -0
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/query-pagination/edit.js +1 -1
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-title/edit.js +44 -3
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/quote/transforms.js +8 -0
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +4 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/search/view.js +166 -62
- package/build-module/search/view.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -0
- package/build-module/site-logo/edit.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/threads.js +15 -0
- package/build-module/social-link/icons/threads.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/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +2 -2
- package/build-module/template-part/edit/import-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/text-columns/edit.js +1 -0
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-style/details/style-rtl.css +4 -2
- package/build-style/details/style.css +4 -2
- package/build-style/footnotes/style-rtl.css +4 -3
- package/build-style/footnotes/style.css +4 -3
- package/build-style/navigation/style-rtl.css +14 -2
- package/build-style/navigation/style.css +14 -2
- package/build-style/preformatted/style-rtl.css +2 -1
- package/build-style/preformatted/style.css +2 -1
- package/build-style/query-pagination/style-rtl.css +4 -2
- package/build-style/query-pagination/style.css +4 -2
- package/build-style/social-links/style-rtl.css +7 -0
- package/build-style/social-links/style.css +7 -0
- package/build-style/style-rtl.css +36 -10
- package/build-style/style.css +36 -10
- package/build-style/video/style-rtl.css +1 -0
- package/build-style/video/style.css +1 -0
- package/package.json +33 -32
- package/src/audio/test/__snapshots__/edit.native.js.snap +118 -33
- package/src/avatar/block.json +3 -0
- package/src/avatar/edit.js +1 -0
- package/src/block/block.json +2 -1
- package/src/block/edit.js +1 -39
- package/src/block/editor.native.scss +2 -2
- package/src/buttons/edit.js +2 -2
- package/src/buttons/test/edit.native.js +4 -0
- package/src/column/edit.native.js +4 -10
- package/src/column/editor.native.scss +0 -4
- package/src/columns/edit.js +1 -0
- package/src/columns/test/edit.native.js +5 -0
- package/src/comment-author-avatar/edit.js +1 -0
- package/src/comment-template/index.php +7 -2
- package/src/cover/block.json +2 -1
- package/src/cover/deprecated.js +2 -0
- package/src/cover/test/edit.native.js +8 -0
- package/src/embed/embed-placeholder.native.js +80 -47
- package/src/embed/styles.native.scss +54 -18
- package/src/embed/test/index.native.js +13 -5
- package/src/file/block.json +1 -2
- package/src/file/index.php +20 -2
- package/src/file/inspector.js +1 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +119 -33
- package/src/file/view-interactivity.js +18 -0
- package/src/file/view.js +5 -14
- package/src/footnotes/block.json +44 -2
- package/src/footnotes/edit.js +33 -2
- package/src/footnotes/format.js +90 -25
- package/src/footnotes/index.js +0 -1
- package/src/footnotes/index.php +207 -0
- package/src/footnotes/style.scss +6 -3
- package/src/gallery/edit.js +42 -38
- package/src/gallery/test/index.native.js +31 -18
- package/src/heading/test/index.native.js +4 -0
- package/src/home-link/index.php +15 -2
- package/src/image/block.json +2 -1
- package/src/image/deprecated.js +109 -3
- package/src/image/image.js +2 -2
- package/src/image/index.php +45 -8
- package/src/image/test/edit.native.js +1 -2
- package/src/index.js +5 -1
- package/src/latest-comments/edit.js +1 -0
- package/src/latest-posts/edit.js +2 -0
- package/src/list/edit.js +6 -4
- package/src/list/test/edit.native.js +134 -33
- package/src/list-item/hooks/use-merge.js +12 -5
- package/src/media-text/media-container.native.js +1 -0
- package/src/missing/edit.native.js +12 -10
- package/src/missing/style.native.scss +19 -12
- package/src/missing/test/__snapshots__/edit.native.js.snap +42 -13
- package/src/navigation/block.json +2 -3
- package/src/navigation/constants.js +12 -6
- package/src/navigation/edit/index.js +29 -1
- package/src/navigation/edit/inner-blocks.js +2 -2
- package/src/navigation/edit/menu-inspector-controls.js +1 -1
- package/src/navigation/edit/navigation-menu-selector.js +8 -4
- package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
- package/src/navigation/index.php +50 -18
- package/src/navigation/style.scss +27 -8
- package/src/navigation/use-navigation-menu.js +39 -63
- package/src/navigation/view-interactivity.js +196 -0
- package/src/navigation/view-modal.js +127 -0
- package/src/navigation/view.js +96 -185
- package/src/navigation-link/edit.js +61 -47
- package/src/navigation-submenu/edit.js +2 -2
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
- package/src/paragraph/test/edit.native.js +81 -35
- package/src/pattern/edit.js +21 -0
- package/src/pattern/index.php +13 -1
- package/src/post-template/index.php +6 -2
- package/src/post-title/index.php +8 -3
- package/src/preformatted/block.json +4 -0
- package/src/preformatted/style.scss +4 -1
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
- package/src/pullquote/test/edit.native.js +12 -4
- package/src/query-pagination/edit.js +17 -14
- package/src/query-title/edit.js +48 -6
- package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
- package/src/quote/test/edit.native.js +12 -4
- package/src/quote/test/transforms.native.js +5 -1
- package/src/quote/transforms.js +13 -0
- package/src/rss/edit.js +3 -0
- package/src/search/block.json +1 -0
- package/src/search/edit.js +4 -3
- package/src/search/index.php +26 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +70 -0
- package/src/search/view.js +171 -67
- package/src/site-logo/edit.js +1 -0
- package/src/social-link/icons/index.js +1 -0
- package/src/social-link/icons/threads.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 +4 -0
- package/src/social-link/variations.js +7 -0
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/import-controls.js +2 -2
- package/src/template-part/edit/index.js +1 -1
- package/src/template-part/index.php +7 -16
- package/src/text-columns/edit.js +1 -0
- package/src/video/style.scss +1 -0
- package/build/gallery/shared-icon.native.js +0 -38
- package/build/gallery/shared-icon.native.js.map +0 -1
- package/build-module/gallery/shared-icon.native.js +0 -24
- package/build-module/gallery/shared-icon.native.js.map +0 -1
- package/src/gallery/shared-icon.native.js +0 -23
package/src/footnotes/block.json
CHANGED
|
@@ -9,10 +9,52 @@
|
|
|
9
9
|
"textdomain": "default",
|
|
10
10
|
"usesContext": [ "postId", "postType" ],
|
|
11
11
|
"supports": {
|
|
12
|
+
"__experimentalBorder": {
|
|
13
|
+
"radius": true,
|
|
14
|
+
"color": true,
|
|
15
|
+
"width": true,
|
|
16
|
+
"style": true,
|
|
17
|
+
"__experimentalDefaultControls": {
|
|
18
|
+
"radius": false,
|
|
19
|
+
"color": false,
|
|
20
|
+
"width": false,
|
|
21
|
+
"style": false
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"color": {
|
|
25
|
+
"background": true,
|
|
26
|
+
"link": true,
|
|
27
|
+
"text": true,
|
|
28
|
+
"__experimentalDefaultControls": {
|
|
29
|
+
"link": true,
|
|
30
|
+
"text": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
12
33
|
"html": false,
|
|
13
34
|
"multiple": false,
|
|
14
|
-
"
|
|
15
|
-
"
|
|
35
|
+
"reusable": false,
|
|
36
|
+
"spacing": {
|
|
37
|
+
"margin": true,
|
|
38
|
+
"padding": true,
|
|
39
|
+
"__experimentalDefaultControls": {
|
|
40
|
+
"margin": false,
|
|
41
|
+
"padding": false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"typography": {
|
|
45
|
+
"fontSize": true,
|
|
46
|
+
"lineHeight": true,
|
|
47
|
+
"__experimentalFontFamily": true,
|
|
48
|
+
"__experimentalTextDecoration": true,
|
|
49
|
+
"__experimentalFontStyle": true,
|
|
50
|
+
"__experimentalFontWeight": true,
|
|
51
|
+
"__experimentalLetterSpacing": true,
|
|
52
|
+
"__experimentalTextTransform": true,
|
|
53
|
+
"__experimentalWritingMode": true,
|
|
54
|
+
"__experimentalDefaultControls": {
|
|
55
|
+
"fontSize": true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
16
58
|
},
|
|
17
59
|
"style": "wp-block-footnotes"
|
|
18
60
|
}
|
package/src/footnotes/edit.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
4
|
+
import { BlockIcon, RichText, useBlockProps } from '@wordpress/block-editor';
|
|
5
5
|
import { useEntityProp } from '@wordpress/core-data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { Placeholder } from '@wordpress/components';
|
|
8
|
+
import { formatListNumbered as icon } from '@wordpress/icons';
|
|
6
9
|
|
|
7
10
|
export default function FootnotesEdit( { context: { postType, postId } } ) {
|
|
8
11
|
const [ meta, updateMeta ] = useEntityProp(
|
|
@@ -12,8 +15,36 @@ export default function FootnotesEdit( { context: { postType, postId } } ) {
|
|
|
12
15
|
postId
|
|
13
16
|
);
|
|
14
17
|
const footnotes = meta?.footnotes ? JSON.parse( meta.footnotes ) : [];
|
|
18
|
+
const blockProps = useBlockProps();
|
|
19
|
+
|
|
20
|
+
if ( postType !== 'post' && postType !== 'page' ) {
|
|
21
|
+
return (
|
|
22
|
+
<div { ...blockProps }>
|
|
23
|
+
<Placeholder
|
|
24
|
+
icon={ <BlockIcon icon={ icon } /> }
|
|
25
|
+
label={ __( 'Footnotes' ) }
|
|
26
|
+
// To do: add instructions. We can't add new string in RC.
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ( ! footnotes.length ) {
|
|
33
|
+
return (
|
|
34
|
+
<div { ...blockProps }>
|
|
35
|
+
<Placeholder
|
|
36
|
+
icon={ <BlockIcon icon={ icon } /> }
|
|
37
|
+
label={ __( 'Footnotes' ) }
|
|
38
|
+
instructions={ __(
|
|
39
|
+
'Footnotes found in blocks within this document will be displayed here.'
|
|
40
|
+
) }
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
15
46
|
return (
|
|
16
|
-
<ol { ...
|
|
47
|
+
<ol { ...blockProps }>
|
|
17
48
|
{ footnotes.map( ( { id, content } ) => (
|
|
18
49
|
<li key={ id }>
|
|
19
50
|
<RichText
|
package/src/footnotes/format.js
CHANGED
|
@@ -12,61 +12,127 @@ import { insertObject } from '@wordpress/rich-text';
|
|
|
12
12
|
import {
|
|
13
13
|
RichTextToolbarButton,
|
|
14
14
|
store as blockEditorStore,
|
|
15
|
+
privateApis,
|
|
15
16
|
} from '@wordpress/block-editor';
|
|
16
17
|
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
17
|
-
import { createBlock } from '@wordpress/blocks';
|
|
18
|
+
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
21
22
|
*/
|
|
22
23
|
import { name } from './block.json';
|
|
24
|
+
import { unlock } from '../lock-unlock';
|
|
25
|
+
|
|
26
|
+
const { usesContextKey } = unlock( privateApis );
|
|
23
27
|
|
|
24
28
|
export const formatName = 'core/footnote';
|
|
29
|
+
|
|
30
|
+
const POST_CONTENT_BLOCK_NAME = 'core/post-content';
|
|
31
|
+
const SYNCED_PATTERN_BLOCK_NAME = 'core/block';
|
|
32
|
+
|
|
25
33
|
export const format = {
|
|
26
34
|
title: __( 'Footnote' ),
|
|
27
|
-
tagName: '
|
|
35
|
+
tagName: 'sup',
|
|
28
36
|
className: 'fn',
|
|
29
37
|
attributes: {
|
|
30
|
-
id: 'id',
|
|
31
|
-
href: 'href',
|
|
32
38
|
'data-fn': 'data-fn',
|
|
33
39
|
},
|
|
34
40
|
contentEditable: false,
|
|
35
|
-
|
|
41
|
+
[ usesContextKey ]: [ 'postType' ],
|
|
42
|
+
edit: function Edit( {
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
isObjectActive,
|
|
46
|
+
context: { postType },
|
|
47
|
+
} ) {
|
|
36
48
|
const registry = useRegistry();
|
|
37
49
|
const {
|
|
38
50
|
getSelectedBlockClientId,
|
|
51
|
+
getBlocks,
|
|
39
52
|
getBlockRootClientId,
|
|
40
53
|
getBlockName,
|
|
41
|
-
|
|
54
|
+
getBlockParentsByBlockName,
|
|
42
55
|
} = useSelect( blockEditorStore );
|
|
56
|
+
const footnotesBlockType = useSelect( ( select ) =>
|
|
57
|
+
select( blocksStore ).getBlockType( name )
|
|
58
|
+
);
|
|
59
|
+
/*
|
|
60
|
+
* This useSelect exists because we need to use its return value
|
|
61
|
+
* outside the event callback.
|
|
62
|
+
*/
|
|
63
|
+
const isBlockWithinPattern = useSelect( ( select ) => {
|
|
64
|
+
const {
|
|
65
|
+
getBlockParentsByBlockName: _getBlockParentsByBlockName,
|
|
66
|
+
getSelectedBlockClientId: _getSelectedBlockClientId,
|
|
67
|
+
} = select( blockEditorStore );
|
|
68
|
+
const parentCoreBlocks = _getBlockParentsByBlockName(
|
|
69
|
+
_getSelectedBlockClientId(),
|
|
70
|
+
SYNCED_PATTERN_BLOCK_NAME
|
|
71
|
+
);
|
|
72
|
+
return parentCoreBlocks && parentCoreBlocks.length > 0;
|
|
73
|
+
}, [] );
|
|
74
|
+
|
|
43
75
|
const { selectionChange, insertBlock } =
|
|
44
76
|
useDispatch( blockEditorStore );
|
|
77
|
+
|
|
78
|
+
if ( ! footnotesBlockType ) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if ( postType !== 'post' && postType !== 'page' ) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Checks if the selected block lives within a pattern.
|
|
87
|
+
if ( isBlockWithinPattern ) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
45
91
|
function onClick() {
|
|
46
92
|
registry.batch( () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
93
|
+
let id;
|
|
94
|
+
if ( isObjectActive ) {
|
|
95
|
+
const object = value.replacements[ value.start ];
|
|
96
|
+
id = object?.attributes?.[ 'data-fn' ];
|
|
97
|
+
} else {
|
|
98
|
+
id = createId();
|
|
99
|
+
const newValue = insertObject(
|
|
100
|
+
value,
|
|
101
|
+
{
|
|
102
|
+
type: formatName,
|
|
103
|
+
attributes: {
|
|
104
|
+
'data-fn': id,
|
|
105
|
+
},
|
|
106
|
+
innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
|
|
56
107
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
108
|
+
value.end,
|
|
109
|
+
value.end
|
|
110
|
+
);
|
|
111
|
+
newValue.start = newValue.end - 1;
|
|
112
|
+
onChange( newValue );
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const selectedClientId = getSelectedBlockClientId();
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Attempts to find a common parent post content block.
|
|
119
|
+
* This allows for locating blocks within a page edited in the site editor.
|
|
120
|
+
*/
|
|
121
|
+
const parentPostContent = getBlockParentsByBlockName(
|
|
122
|
+
selectedClientId,
|
|
123
|
+
POST_CONTENT_BLOCK_NAME
|
|
61
124
|
);
|
|
62
|
-
newValue.start = newValue.end - 1;
|
|
63
125
|
|
|
64
|
-
|
|
126
|
+
// When called with a post content block, getBlocks will return
|
|
127
|
+
// the block with controlled inner blocks included.
|
|
128
|
+
const blocks = parentPostContent.length
|
|
129
|
+
? getBlocks( parentPostContent[ 0 ] )
|
|
130
|
+
: getBlocks();
|
|
65
131
|
|
|
66
132
|
// BFS search to find the first footnote block.
|
|
67
133
|
let fnBlock = null;
|
|
68
134
|
{
|
|
69
|
-
const queue = [ ...
|
|
135
|
+
const queue = [ ...blocks ];
|
|
70
136
|
while ( queue.length ) {
|
|
71
137
|
const block = queue.shift();
|
|
72
138
|
if ( block.name === name ) {
|
|
@@ -81,12 +147,11 @@ export const format = {
|
|
|
81
147
|
// When there is no footnotes block in the post, create one and
|
|
82
148
|
// insert it at the bottom.
|
|
83
149
|
if ( ! fnBlock ) {
|
|
84
|
-
|
|
85
|
-
let rootClientId = getBlockRootClientId( clientId );
|
|
150
|
+
let rootClientId = getBlockRootClientId( selectedClientId );
|
|
86
151
|
|
|
87
152
|
while (
|
|
88
153
|
rootClientId &&
|
|
89
|
-
getBlockName( rootClientId ) !==
|
|
154
|
+
getBlockName( rootClientId ) !== POST_CONTENT_BLOCK_NAME
|
|
90
155
|
) {
|
|
91
156
|
rootClientId = getBlockRootClientId( rootClientId );
|
|
92
157
|
}
|
package/src/footnotes/index.js
CHANGED
package/src/footnotes/index.php
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/footnotes` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.3.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
* @param string $content Block default content.
|
|
13
15
|
* @param WP_Block $block Block instance.
|
|
@@ -57,6 +59,8 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
|
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
61
|
* Registers the `core/footnotes` block on the server.
|
|
62
|
+
*
|
|
63
|
+
* @since 6.3.0
|
|
60
64
|
*/
|
|
61
65
|
function register_block_core_footnotes() {
|
|
62
66
|
foreach ( array( 'post', 'page' ) as $post_type ) {
|
|
@@ -78,3 +82,206 @@ function register_block_core_footnotes() {
|
|
|
78
82
|
);
|
|
79
83
|
}
|
|
80
84
|
add_action( 'init', 'register_block_core_footnotes' );
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Saves the footnotes meta value to the revision.
|
|
88
|
+
*
|
|
89
|
+
* @since 6.3.0
|
|
90
|
+
*
|
|
91
|
+
* @param int $revision_id The revision ID.
|
|
92
|
+
*/
|
|
93
|
+
function wp_save_footnotes_meta( $revision_id ) {
|
|
94
|
+
$post_id = wp_is_post_revision( $revision_id );
|
|
95
|
+
|
|
96
|
+
if ( $post_id ) {
|
|
97
|
+
$footnotes = get_post_meta( $post_id, 'footnotes', true );
|
|
98
|
+
|
|
99
|
+
if ( $footnotes ) {
|
|
100
|
+
// Can't use update_post_meta() because it doesn't allow revisions.
|
|
101
|
+
update_metadata( 'post', $revision_id, 'footnotes', $footnotes );
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
add_action( 'wp_after_insert_post', 'wp_save_footnotes_meta' );
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Keeps track of the revision ID for "rest_after_insert_{$post_type}".
|
|
109
|
+
*
|
|
110
|
+
* @since 6.3.0
|
|
111
|
+
*
|
|
112
|
+
* @global int $wp_temporary_footnote_revision_id The footnote revision ID.
|
|
113
|
+
*
|
|
114
|
+
* @param int $revision_id The revision ID.
|
|
115
|
+
*/
|
|
116
|
+
function wp_keep_footnotes_revision_id( $revision_id ) {
|
|
117
|
+
global $wp_temporary_footnote_revision_id;
|
|
118
|
+
$wp_temporary_footnote_revision_id = $revision_id;
|
|
119
|
+
}
|
|
120
|
+
add_action( '_wp_put_post_revision', 'wp_keep_footnotes_revision_id' );
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* This is a specific fix for the REST API. The REST API doesn't update
|
|
124
|
+
* the post and post meta in one go (through `meta_input`). While it
|
|
125
|
+
* does fix the `wp_after_insert_post` hook to be called correctly after
|
|
126
|
+
* updating meta, it does NOT fix hooks such as post_updated and
|
|
127
|
+
* save_post, which are normally also fired after post meta is updated
|
|
128
|
+
* in `wp_insert_post()`. Unfortunately, `wp_save_post_revision` is
|
|
129
|
+
* added to the `post_updated` action, which means the meta is not
|
|
130
|
+
* available at the time, so we have to add it afterwards through the
|
|
131
|
+
* `"rest_after_insert_{$post_type}"` action.
|
|
132
|
+
*
|
|
133
|
+
* @since 6.3.0
|
|
134
|
+
*
|
|
135
|
+
* @global int $wp_temporary_footnote_revision_id The footnote revision ID.
|
|
136
|
+
*
|
|
137
|
+
* @param WP_Post $post The post object.
|
|
138
|
+
*/
|
|
139
|
+
function wp_add_footnotes_revisions_to_post_meta( $post ) {
|
|
140
|
+
global $wp_temporary_footnote_revision_id;
|
|
141
|
+
|
|
142
|
+
if ( $wp_temporary_footnote_revision_id ) {
|
|
143
|
+
$revision = get_post( $wp_temporary_footnote_revision_id );
|
|
144
|
+
|
|
145
|
+
if ( ! $revision ) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
$post_id = $revision->post_parent;
|
|
150
|
+
|
|
151
|
+
// Just making sure we're updating the right revision.
|
|
152
|
+
if ( $post->ID === $post_id ) {
|
|
153
|
+
$footnotes = get_post_meta( $post_id, 'footnotes', true );
|
|
154
|
+
|
|
155
|
+
if ( $footnotes ) {
|
|
156
|
+
// Can't use update_post_meta() because it doesn't allow revisions.
|
|
157
|
+
update_metadata( 'post', $wp_temporary_footnote_revision_id, 'footnotes', $footnotes );
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
foreach ( array( 'post', 'page' ) as $post_type ) {
|
|
164
|
+
add_action( "rest_after_insert_{$post_type}", 'wp_add_footnotes_revisions_to_post_meta' );
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Restores the footnotes meta value from the revision.
|
|
169
|
+
*
|
|
170
|
+
* @since 6.3.0
|
|
171
|
+
*
|
|
172
|
+
* @param int $post_id The post ID.
|
|
173
|
+
* @param int $revision_id The revision ID.
|
|
174
|
+
*/
|
|
175
|
+
function wp_restore_footnotes_from_revision( $post_id, $revision_id ) {
|
|
176
|
+
$footnotes = get_post_meta( $revision_id, 'footnotes', true );
|
|
177
|
+
|
|
178
|
+
if ( $footnotes ) {
|
|
179
|
+
update_post_meta( $post_id, 'footnotes', $footnotes );
|
|
180
|
+
} else {
|
|
181
|
+
delete_post_meta( $post_id, 'footnotes' );
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
add_action( 'wp_restore_post_revision', 'wp_restore_footnotes_from_revision', 10, 2 );
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Adds the footnotes field to the revision.
|
|
188
|
+
*
|
|
189
|
+
* @since 6.3.0
|
|
190
|
+
*
|
|
191
|
+
* @param array $fields The revision fields.
|
|
192
|
+
* @return array The revision fields.
|
|
193
|
+
*/
|
|
194
|
+
function wp_add_footnotes_to_revision( $fields ) {
|
|
195
|
+
$fields['footnotes'] = __( 'Footnotes' );
|
|
196
|
+
return $fields;
|
|
197
|
+
}
|
|
198
|
+
add_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' );
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Gets the footnotes field from the revision.
|
|
202
|
+
*
|
|
203
|
+
* @since 6.3.0
|
|
204
|
+
*
|
|
205
|
+
* @param string $revision_field The field value, but $revision->$field
|
|
206
|
+
* (footnotes) does not exist.
|
|
207
|
+
* @param string $field The field name, in this case "footnotes".
|
|
208
|
+
* @param object $revision The revision object to compare against.
|
|
209
|
+
* @return string The field value.
|
|
210
|
+
*/
|
|
211
|
+
function wp_get_footnotes_from_revision( $revision_field, $field, $revision ) {
|
|
212
|
+
return get_metadata( 'post', $revision->ID, $field, true );
|
|
213
|
+
}
|
|
214
|
+
add_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision', 10, 3 );
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The REST API autosave endpoint doesn't save meta, so we can use the
|
|
218
|
+
* `wp_creating_autosave` when it updates an exiting autosave, and
|
|
219
|
+
* `_wp_put_post_revision` when it creates a new autosave.
|
|
220
|
+
*
|
|
221
|
+
* @since 6.3.0
|
|
222
|
+
*
|
|
223
|
+
* @param int|array $autosave The autosave ID or array.
|
|
224
|
+
*/
|
|
225
|
+
function _wp_rest_api_autosave_meta( $autosave ) {
|
|
226
|
+
// Ensure it's a REST API request.
|
|
227
|
+
if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
$body = rest_get_server()->get_raw_data();
|
|
232
|
+
$body = json_decode( $body, true );
|
|
233
|
+
|
|
234
|
+
if ( ! isset( $body['meta']['footnotes'] ) ) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// `wp_creating_autosave` passes the array,
|
|
239
|
+
// `_wp_put_post_revision` passes the ID.
|
|
240
|
+
$id = is_int( $autosave ) ? $autosave : $autosave['ID'];
|
|
241
|
+
|
|
242
|
+
if ( ! $id ) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
update_post_meta( $id, 'footnotes', $body['meta']['footnotes'] );
|
|
247
|
+
}
|
|
248
|
+
// See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L391C1-L391C1.
|
|
249
|
+
add_action( 'wp_creating_autosave', '_wp_rest_api_autosave_meta' );
|
|
250
|
+
// See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L398.
|
|
251
|
+
// Then https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/revision.php#L367.
|
|
252
|
+
add_action( '_wp_put_post_revision', '_wp_rest_api_autosave_meta' );
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* This is a workaround for the autosave endpoint returning early if the
|
|
256
|
+
* revision field are equal. The problem is that "footnotes" is not real
|
|
257
|
+
* revision post field, so there's nothing to compare against.
|
|
258
|
+
*
|
|
259
|
+
* This trick sets the "footnotes" field (value doesn't matter), which will
|
|
260
|
+
* cause the autosave endpoint to always update the latest revision. That should
|
|
261
|
+
* be fine, it should be ok to update the revision even if nothing changed. Of
|
|
262
|
+
* course, this is temporary fix.
|
|
263
|
+
*
|
|
264
|
+
* @since 6.3.0
|
|
265
|
+
*
|
|
266
|
+
* @param WP_Post $prepared_post The prepared post object.
|
|
267
|
+
* @param WP_REST_Request $request The request object.
|
|
268
|
+
*
|
|
269
|
+
* See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L365-L384.
|
|
270
|
+
* See https://github.com/WordPress/wordpress-develop/blob/2103cb9966e57d452c94218bbc3171579b536a40/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php#L219.
|
|
271
|
+
*/
|
|
272
|
+
function _wp_rest_api_force_autosave_difference( $prepared_post, $request ) {
|
|
273
|
+
// We only want to be altering POST requests.
|
|
274
|
+
if ( $request->get_method() !== 'POST' ) {
|
|
275
|
+
return $prepared_post;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Only alter requests for the '/autosaves' route.
|
|
279
|
+
if ( substr( $request->get_route(), -strlen( '/autosaves' ) ) !== '/autosaves' ) {
|
|
280
|
+
return $prepared_post;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
$prepared_post->footnotes = '[]';
|
|
284
|
+
return $prepared_post;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
add_filter( 'rest_pre_insert_post', '_wp_rest_api_force_autosave_difference', 10, 2 );
|
package/src/footnotes/style.scss
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
// These styles are for backwards compatibility with the old footnotes anchors.
|
|
2
|
+
// Can be removed in the future.
|
|
1
3
|
.editor-styles-wrapper,
|
|
2
4
|
.entry-content {
|
|
3
5
|
counter-reset: footnotes;
|
|
4
6
|
}
|
|
5
7
|
|
|
6
|
-
[data-fn].fn {
|
|
8
|
+
a[data-fn].fn {
|
|
7
9
|
vertical-align: super;
|
|
8
10
|
font-size: smaller;
|
|
9
11
|
counter-increment: footnotes;
|
|
10
|
-
display: inline-
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
text-decoration: none;
|
|
11
14
|
text-indent: -9999999px;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
[data-fn].fn::after {
|
|
17
|
+
a[data-fn].fn::after {
|
|
15
18
|
content: "[" counter(footnotes) "]";
|
|
16
19
|
text-indent: 0;
|
|
17
20
|
float: left;
|
package/src/gallery/edit.js
CHANGED
|
@@ -91,6 +91,7 @@ function GalleryEdit( props ) {
|
|
|
91
91
|
isSelected,
|
|
92
92
|
insertBlocksAfter,
|
|
93
93
|
isContentLocked,
|
|
94
|
+
onFocus,
|
|
94
95
|
} = props;
|
|
95
96
|
|
|
96
97
|
const { columns, imageCrop, linkTarget, linkTo, sizeSlug, caption } =
|
|
@@ -498,6 +499,7 @@ function GalleryEdit( props ) {
|
|
|
498
499
|
value: hasImageIds ? images : {},
|
|
499
500
|
autoOpenMediaUpload:
|
|
500
501
|
! hasImages && isSelected && wasBlockJustInserted,
|
|
502
|
+
onFocus,
|
|
501
503
|
},
|
|
502
504
|
} );
|
|
503
505
|
const mediaPlaceholder = (
|
|
@@ -562,7 +564,7 @@ function GalleryEdit( props ) {
|
|
|
562
564
|
max={ Math.min( MAX_COLUMNS, images.length ) }
|
|
563
565
|
{ ...MOBILE_CONTROL_PROPS_RANGE_CONTROL }
|
|
564
566
|
required
|
|
565
|
-
|
|
567
|
+
__next40pxDefaultSize
|
|
566
568
|
/>
|
|
567
569
|
) }
|
|
568
570
|
<ToggleControl
|
|
@@ -616,44 +618,46 @@ function GalleryEdit( props ) {
|
|
|
616
618
|
) }
|
|
617
619
|
</PanelBody>
|
|
618
620
|
</InspectorControls>
|
|
619
|
-
<BlockControls group="block">
|
|
620
|
-
{ ! isContentLocked && (
|
|
621
|
-
<ToolbarButton
|
|
622
|
-
onClick={ () => {
|
|
623
|
-
setShowCaption( ! showCaption );
|
|
624
|
-
if ( showCaption && caption ) {
|
|
625
|
-
setAttributes( { caption: undefined } );
|
|
626
|
-
}
|
|
627
|
-
} }
|
|
628
|
-
icon={ captionIcon }
|
|
629
|
-
isPressed={ showCaption }
|
|
630
|
-
label={
|
|
631
|
-
showCaption
|
|
632
|
-
? __( 'Remove caption' )
|
|
633
|
-
: __( 'Add caption' )
|
|
634
|
-
}
|
|
635
|
-
/>
|
|
636
|
-
) }
|
|
637
|
-
</BlockControls>
|
|
638
|
-
<BlockControls group="other">
|
|
639
|
-
<MediaReplaceFlow
|
|
640
|
-
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
641
|
-
accept="image/*"
|
|
642
|
-
handleUpload={ false }
|
|
643
|
-
onSelect={ updateImages }
|
|
644
|
-
name={ __( 'Add' ) }
|
|
645
|
-
multiple={ true }
|
|
646
|
-
mediaIds={ images
|
|
647
|
-
.filter( ( image ) => image.id )
|
|
648
|
-
.map( ( image ) => image.id ) }
|
|
649
|
-
addToGallery={ hasImageIds }
|
|
650
|
-
/>
|
|
651
|
-
</BlockControls>
|
|
652
621
|
{ Platform.isWeb && (
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
622
|
+
<>
|
|
623
|
+
<BlockControls group="block">
|
|
624
|
+
{ ! isContentLocked && (
|
|
625
|
+
<ToolbarButton
|
|
626
|
+
onClick={ () => {
|
|
627
|
+
setShowCaption( ! showCaption );
|
|
628
|
+
if ( showCaption && caption ) {
|
|
629
|
+
setAttributes( { caption: undefined } );
|
|
630
|
+
}
|
|
631
|
+
} }
|
|
632
|
+
icon={ captionIcon }
|
|
633
|
+
isPressed={ showCaption }
|
|
634
|
+
label={
|
|
635
|
+
showCaption
|
|
636
|
+
? __( 'Remove caption' )
|
|
637
|
+
: __( 'Add caption' )
|
|
638
|
+
}
|
|
639
|
+
/>
|
|
640
|
+
) }
|
|
641
|
+
</BlockControls>
|
|
642
|
+
<BlockControls group="other">
|
|
643
|
+
<MediaReplaceFlow
|
|
644
|
+
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
645
|
+
accept="image/*"
|
|
646
|
+
handleUpload={ false }
|
|
647
|
+
onSelect={ updateImages }
|
|
648
|
+
name={ __( 'Add' ) }
|
|
649
|
+
multiple={ true }
|
|
650
|
+
mediaIds={ images
|
|
651
|
+
.filter( ( image ) => image.id )
|
|
652
|
+
.map( ( image ) => image.id ) }
|
|
653
|
+
addToGallery={ hasImageIds }
|
|
654
|
+
/>
|
|
655
|
+
</BlockControls>
|
|
656
|
+
<GapStyles
|
|
657
|
+
blockGap={ attributes.style?.spacing?.blockGap }
|
|
658
|
+
clientId={ clientId }
|
|
659
|
+
/>
|
|
660
|
+
</>
|
|
657
661
|
) }
|
|
658
662
|
<Gallery
|
|
659
663
|
{ ...props }
|