@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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store } from '@wordpress/interactivity';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { browserSupportsPdfs as hasPdfPreview } from './utils';
|
|
10
|
+
store({
|
|
11
|
+
selectors: {
|
|
12
|
+
core: {
|
|
13
|
+
file: {
|
|
14
|
+
hasPdfPreview
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=view-interactivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/file/view-interactivity.js"],"names":["store","browserSupportsPdfs","hasPdfPreview","selectors","core","file"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,0BAAtB;AACA;AACA;AACA;;AACA,SAASC,mBAAmB,IAAIC,aAAhC,QAAqD,SAArD;AAEAF,KAAK,CAAE;AACNG,EAAAA,SAAS,EAAE;AACVC,IAAAA,IAAI,EAAE;AACLC,MAAAA,IAAI,EAAE;AACLH,QAAAA;AADK;AADD;AADI;AADL,CAAF,CAAL","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store } from '@wordpress/interactivity';\n/**\n * Internal dependencies\n */\nimport { browserSupportsPdfs as hasPdfPreview } from './utils';\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tfile: {\n\t\t\t\thasPdfPreview,\n\t\t\t},\n\t\t},\n\t},\n} );\n"]}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { store } from '@wordpress/interactivity';
|
|
5
1
|
/**
|
|
6
2
|
* Internal dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
store({
|
|
11
|
-
selectors: {
|
|
12
|
-
core: {
|
|
13
|
-
file: {
|
|
14
|
-
hasPdfPreview
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
4
|
+
import { hidePdfEmbedsOnUnsupportedBrowsers } from './utils';
|
|
5
|
+
document.addEventListener('DOMContentLoaded', hidePdfEmbedsOnUnsupportedBrowsers);
|
|
19
6
|
//# sourceMappingURL=view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/file/view.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/file/view.js"],"names":["hidePdfEmbedsOnUnsupportedBrowsers","document","addEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,kCAAT,QAAmD,SAAnD;AAEAC,QAAQ,CAACC,gBAAT,CACC,kBADD,EAECF,kCAFD","sourcesContent":["/**\n * Internal dependencies\n */\nimport { hidePdfEmbedsOnUnsupportedBrowsers } from './utils';\n\ndocument.addEventListener(\n\t'DOMContentLoaded',\n\thidePdfEmbedsOnUnsupportedBrowsers\n);\n"]}
|
|
@@ -3,8 +3,11 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
6
|
+
import { BlockIcon, RichText, useBlockProps } from '@wordpress/block-editor';
|
|
7
7
|
import { useEntityProp } from '@wordpress/core-data';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { Placeholder } from '@wordpress/components';
|
|
10
|
+
import { formatListNumbered as icon } from '@wordpress/icons';
|
|
8
11
|
export default function FootnotesEdit({
|
|
9
12
|
context: {
|
|
10
13
|
postType,
|
|
@@ -13,7 +16,31 @@ export default function FootnotesEdit({
|
|
|
13
16
|
}) {
|
|
14
17
|
const [meta, updateMeta] = useEntityProp('postType', postType, 'meta', postId);
|
|
15
18
|
const footnotes = meta?.footnotes ? JSON.parse(meta.footnotes) : [];
|
|
16
|
-
|
|
19
|
+
const blockProps = useBlockProps();
|
|
20
|
+
|
|
21
|
+
if (postType !== 'post' && postType !== 'page') {
|
|
22
|
+
return createElement("div", { ...blockProps
|
|
23
|
+
}, createElement(Placeholder, {
|
|
24
|
+
icon: createElement(BlockIcon, {
|
|
25
|
+
icon: icon
|
|
26
|
+
}),
|
|
27
|
+
label: __('Footnotes') // To do: add instructions. We can't add new string in RC.
|
|
28
|
+
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!footnotes.length) {
|
|
33
|
+
return createElement("div", { ...blockProps
|
|
34
|
+
}, createElement(Placeholder, {
|
|
35
|
+
icon: createElement(BlockIcon, {
|
|
36
|
+
icon: icon
|
|
37
|
+
}),
|
|
38
|
+
label: __('Footnotes'),
|
|
39
|
+
instructions: __('Footnotes found in blocks within this document will be displayed here.')
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return createElement("ol", { ...blockProps
|
|
17
44
|
}, footnotes.map(({
|
|
18
45
|
id,
|
|
19
46
|
content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/edit.js"],"names":["RichText","useBlockProps","useEntityProp","FootnotesEdit","context","postType","postId","meta","updateMeta","footnotes","JSON","parse","map","id","content","event","target","textContent","trim","scrollIntoView","nextFootnote","stringify","footnote"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/edit.js"],"names":["BlockIcon","RichText","useBlockProps","useEntityProp","__","Placeholder","formatListNumbered","icon","FootnotesEdit","context","postType","postId","meta","updateMeta","footnotes","JSON","parse","blockProps","length","map","id","content","event","target","textContent","trim","scrollIntoView","nextFootnote","stringify","footnote"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,aAA9B,QAAmD,yBAAnD;AACA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAAS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AAGC,IAAA,KAAK,EAAGC,OAHT;AAIC,IAAA,UAAU,EAAGD,EAJd,CAKC;AACA;AAND;AAOC,IAAA,OAAO,EAAKE,KAAF,IAAa;AACtB,UAAK,CAAEA,KAAK,CAACC,MAAN,CAAaC,WAAb,CAAyBC,IAAzB,EAAP,EAAyC;AACxCH,QAAAA,KAAK,CAACC,MAAN,CAAaG,cAAb;AACA;AACD,KAXF;AAYC,IAAA,QAAQ,EAAKC,YAAF,IAAoB;AAC9Bd,MAAAA,UAAU,CAAE,EACX,GAAGD,IADQ;AAEXE,QAAAA,SAAS,EAAEC,IAAI,CAACa,SAAL,CACVd,SAAS,CAACK,GAAV,CAAiBU,QAAF,IAAgB;AAC9B,iBAAOA,QAAQ,CAACT,EAAT,KAAgBA,EAAhB,GACJ;AACAC,YAAAA,OAAO,EAAEM,YADT;AAEAP,YAAAA;AAFA,WADI,GAKJS,QALH;AAMA,SAPD,CADU;AAFA,OAAF,CAAV;AAaA;AA1BF,IADD,EA4BK,GA5BL,EA6BC;AAAG,IAAA,IAAI,EAAI,IAAIT,EAAI;AAAnB,oBA7BD,CADC,CADH,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockIcon, RichText, useBlockProps } from '@wordpress/block-editor';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { Placeholder } from '@wordpress/components';\nimport { formatListNumbered as icon } from '@wordpress/icons';\n\nexport default function FootnotesEdit( { context: { postType, postId } } ) {\n\tconst [ meta, updateMeta ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'meta',\n\t\tpostId\n\t);\n\tconst footnotes = meta?.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst blockProps = useBlockProps();\n\n\tif ( postType !== 'post' && postType !== 'page' ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabel={ __( 'Footnotes' ) }\n\t\t\t\t\t// To do: add instructions. We can't add new string in RC.\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! footnotes.length ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tlabel={ __( 'Footnotes' ) }\n\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t'Footnotes found in blocks within this document will be displayed here.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ol { ...blockProps }>\n\t\t\t{ footnotes.map( ( { id, content } ) => (\n\t\t\t\t<li key={ id }>\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\tvalue={ content }\n\t\t\t\t\t\tidentifier={ id }\n\t\t\t\t\t\t// To do: figure out why the browser is not scrolling\n\t\t\t\t\t\t// into view when it receives focus.\n\t\t\t\t\t\tonFocus={ ( event ) => {\n\t\t\t\t\t\t\tif ( ! event.target.textContent.trim() ) {\n\t\t\t\t\t\t\t\tevent.target.scrollIntoView();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( nextFootnote ) => {\n\t\t\t\t\t\t\tupdateMeta( {\n\t\t\t\t\t\t\t\t...meta,\n\t\t\t\t\t\t\t\tfootnotes: JSON.stringify(\n\t\t\t\t\t\t\t\t\tfootnotes.map( ( footnote ) => {\n\t\t\t\t\t\t\t\t\t\treturn footnote.id === id\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\tcontent: nextFootnote,\n\t\t\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t: footnote;\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<a href={ `#${ id }-link` }>↩︎</a>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ol>\n\t);\n}\n"]}
|
|
@@ -11,9 +11,9 @@ import { v4 as createId } from 'uuid';
|
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { formatListNumbered as icon } from '@wordpress/icons';
|
|
13
13
|
import { insertObject } from '@wordpress/rich-text';
|
|
14
|
-
import { RichTextToolbarButton, store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
|
+
import { RichTextToolbarButton, store as blockEditorStore, privateApis } from '@wordpress/block-editor';
|
|
15
15
|
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
16
|
-
import { createBlock } from '@wordpress/blocks';
|
|
16
|
+
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
@@ -31,59 +31,155 @@ const {
|
|
|
31
31
|
textdomain: "default",
|
|
32
32
|
usesContext: ["postId", "postType"],
|
|
33
33
|
supports: {
|
|
34
|
+
__experimentalBorder: {
|
|
35
|
+
radius: true,
|
|
36
|
+
color: true,
|
|
37
|
+
width: true,
|
|
38
|
+
style: true,
|
|
39
|
+
__experimentalDefaultControls: {
|
|
40
|
+
radius: false,
|
|
41
|
+
color: false,
|
|
42
|
+
width: false,
|
|
43
|
+
style: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
color: {
|
|
47
|
+
background: true,
|
|
48
|
+
link: true,
|
|
49
|
+
text: true,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
link: true,
|
|
52
|
+
text: true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
34
55
|
html: false,
|
|
35
56
|
multiple: false,
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
reusable: false,
|
|
58
|
+
spacing: {
|
|
59
|
+
margin: true,
|
|
60
|
+
padding: true,
|
|
61
|
+
__experimentalDefaultControls: {
|
|
62
|
+
margin: false,
|
|
63
|
+
padding: false
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
typography: {
|
|
67
|
+
fontSize: true,
|
|
68
|
+
lineHeight: true,
|
|
69
|
+
__experimentalFontFamily: true,
|
|
70
|
+
__experimentalTextDecoration: true,
|
|
71
|
+
__experimentalFontStyle: true,
|
|
72
|
+
__experimentalFontWeight: true,
|
|
73
|
+
__experimentalLetterSpacing: true,
|
|
74
|
+
__experimentalTextTransform: true,
|
|
75
|
+
__experimentalWritingMode: true,
|
|
76
|
+
__experimentalDefaultControls: {
|
|
77
|
+
fontSize: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
38
80
|
},
|
|
39
81
|
style: "wp-block-footnotes"
|
|
40
82
|
};
|
|
83
|
+
import { unlock } from '../lock-unlock';
|
|
84
|
+
const {
|
|
85
|
+
usesContextKey
|
|
86
|
+
} = unlock(privateApis);
|
|
41
87
|
export const formatName = 'core/footnote';
|
|
88
|
+
const POST_CONTENT_BLOCK_NAME = 'core/post-content';
|
|
89
|
+
const SYNCED_PATTERN_BLOCK_NAME = 'core/block';
|
|
42
90
|
export const format = {
|
|
43
91
|
title: __('Footnote'),
|
|
44
|
-
tagName: '
|
|
92
|
+
tagName: 'sup',
|
|
45
93
|
className: 'fn',
|
|
46
94
|
attributes: {
|
|
47
|
-
id: 'id',
|
|
48
|
-
href: 'href',
|
|
49
95
|
'data-fn': 'data-fn'
|
|
50
96
|
},
|
|
51
97
|
contentEditable: false,
|
|
98
|
+
[usesContextKey]: ['postType'],
|
|
52
99
|
edit: function Edit({
|
|
53
100
|
value,
|
|
54
101
|
onChange,
|
|
55
|
-
isObjectActive
|
|
102
|
+
isObjectActive,
|
|
103
|
+
context: {
|
|
104
|
+
postType
|
|
105
|
+
}
|
|
56
106
|
}) {
|
|
57
107
|
const registry = useRegistry();
|
|
58
108
|
const {
|
|
59
109
|
getSelectedBlockClientId,
|
|
110
|
+
getBlocks,
|
|
60
111
|
getBlockRootClientId,
|
|
61
112
|
getBlockName,
|
|
62
|
-
|
|
113
|
+
getBlockParentsByBlockName
|
|
63
114
|
} = useSelect(blockEditorStore);
|
|
115
|
+
const footnotesBlockType = useSelect(select => select(blocksStore).getBlockType(name));
|
|
116
|
+
/*
|
|
117
|
+
* This useSelect exists because we need to use its return value
|
|
118
|
+
* outside the event callback.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
const isBlockWithinPattern = useSelect(select => {
|
|
122
|
+
const {
|
|
123
|
+
getBlockParentsByBlockName: _getBlockParentsByBlockName,
|
|
124
|
+
getSelectedBlockClientId: _getSelectedBlockClientId
|
|
125
|
+
} = select(blockEditorStore);
|
|
126
|
+
|
|
127
|
+
const parentCoreBlocks = _getBlockParentsByBlockName(_getSelectedBlockClientId(), SYNCED_PATTERN_BLOCK_NAME);
|
|
128
|
+
|
|
129
|
+
return parentCoreBlocks && parentCoreBlocks.length > 0;
|
|
130
|
+
}, []);
|
|
64
131
|
const {
|
|
65
132
|
selectionChange,
|
|
66
133
|
insertBlock
|
|
67
134
|
} = useDispatch(blockEditorStore);
|
|
68
135
|
|
|
136
|
+
if (!footnotesBlockType) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (postType !== 'post' && postType !== 'page') {
|
|
141
|
+
return null;
|
|
142
|
+
} // Checks if the selected block lives within a pattern.
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (isBlockWithinPattern) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
69
149
|
function onClick() {
|
|
70
150
|
registry.batch(() => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
151
|
+
let id;
|
|
152
|
+
|
|
153
|
+
if (isObjectActive) {
|
|
154
|
+
const object = value.replacements[value.start];
|
|
155
|
+
id = object?.attributes?.['data-fn'];
|
|
156
|
+
} else {
|
|
157
|
+
id = createId();
|
|
158
|
+
const newValue = insertObject(value, {
|
|
159
|
+
type: formatName,
|
|
160
|
+
attributes: {
|
|
161
|
+
'data-fn': id
|
|
162
|
+
},
|
|
163
|
+
innerHTML: `<a href="#${id}" id="${id}-link">*</a>`
|
|
164
|
+
}, value.end, value.end);
|
|
165
|
+
newValue.start = newValue.end - 1;
|
|
166
|
+
onChange(newValue);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const selectedClientId = getSelectedBlockClientId();
|
|
170
|
+
/*
|
|
171
|
+
* Attempts to find a common parent post content block.
|
|
172
|
+
* This allows for locating blocks within a page edited in the site editor.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
const parentPostContent = getBlockParentsByBlockName(selectedClientId, POST_CONTENT_BLOCK_NAME); // When called with a post content block, getBlocks will return
|
|
176
|
+
// the block with controlled inner blocks included.
|
|
177
|
+
|
|
178
|
+
const blocks = parentPostContent.length ? getBlocks(parentPostContent[0]) : getBlocks(); // BFS search to find the first footnote block.
|
|
83
179
|
|
|
84
180
|
let fnBlock = null;
|
|
85
181
|
{
|
|
86
|
-
const queue = [...
|
|
182
|
+
const queue = [...blocks];
|
|
87
183
|
|
|
88
184
|
while (queue.length) {
|
|
89
185
|
const block = queue.shift();
|
|
@@ -100,10 +196,9 @@ export const format = {
|
|
|
100
196
|
// insert it at the bottom.
|
|
101
197
|
|
|
102
198
|
if (!fnBlock) {
|
|
103
|
-
|
|
104
|
-
let rootClientId = getBlockRootClientId(clientId);
|
|
199
|
+
let rootClientId = getBlockRootClientId(selectedClientId);
|
|
105
200
|
|
|
106
|
-
while (rootClientId && getBlockName(rootClientId) !==
|
|
201
|
+
while (rootClientId && getBlockName(rootClientId) !== POST_CONTENT_BLOCK_NAME) {
|
|
107
202
|
rootClientId = getBlockRootClientId(rootClientId);
|
|
108
203
|
}
|
|
109
204
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","useSelect","useDispatch","useRegistry","createBlock","formatName","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/format.js"],"names":["v4","createId","__","formatListNumbered","icon","insertObject","RichTextToolbarButton","store","blockEditorStore","privateApis","useSelect","useDispatch","useRegistry","createBlock","blocksStore","unlock","usesContextKey","formatName","POST_CONTENT_BLOCK_NAME","SYNCED_PATTERN_BLOCK_NAME","format","title","tagName","className","attributes","contentEditable","edit","Edit","value","onChange","isObjectActive","context","postType","registry","getSelectedBlockClientId","getBlocks","getBlockRootClientId","getBlockName","getBlockParentsByBlockName","footnotesBlockType","select","getBlockType","name","isBlockWithinPattern","_getBlockParentsByBlockName","_getSelectedBlockClientId","parentCoreBlocks","length","selectionChange","insertBlock","onClick","batch","id","object","replacements","start","newValue","type","innerHTML","end","selectedClientId","parentPostContent","blocks","fnBlock","queue","block","shift","push","innerBlocks","rootClientId","undefined","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,QAAf,QAA+B,MAA/B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SACCC,qBADD,EAECC,KAAK,IAAIC,gBAFV,EAGCC,WAHD,QAIO,yBAJP;AAKA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,WAAjC,QAAoD,iBAApD;AACA,SAASC,WAAT,EAAsBN,KAAK,IAAIO,WAA/B,QAAkD,mBAAlD;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS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,OAHX;AAIC,MAAA,QAAQ,EAAGpB;AAJZ,MADD;AAQA;AA/IoB,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as createId } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { formatListNumbered as icon } from '@wordpress/icons';\nimport { insertObject } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tstore as blockEditorStore,\n\tprivateApis,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\nimport { unlock } from '../lock-unlock';\n\nconst { usesContextKey } = unlock( privateApis );\n\nexport const formatName = 'core/footnote';\n\nconst POST_CONTENT_BLOCK_NAME = 'core/post-content';\nconst SYNCED_PATTERN_BLOCK_NAME = 'core/block';\n\nexport const format = {\n\ttitle: __( 'Footnote' ),\n\ttagName: 'sup',\n\tclassName: 'fn',\n\tattributes: {\n\t\t'data-fn': 'data-fn',\n\t},\n\tcontentEditable: false,\n\t[ usesContextKey ]: [ 'postType' ],\n\tedit: function Edit( {\n\t\tvalue,\n\t\tonChange,\n\t\tisObjectActive,\n\t\tcontext: { postType },\n\t} ) {\n\t\tconst registry = useRegistry();\n\t\tconst {\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetBlocks,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockName,\n\t\t\tgetBlockParentsByBlockName,\n\t\t} = useSelect( blockEditorStore );\n\t\tconst footnotesBlockType = useSelect( ( select ) =>\n\t\t\tselect( blocksStore ).getBlockType( name )\n\t\t);\n\t\t/*\n\t\t * This useSelect exists because we need to use its return value\n\t\t * outside the event callback.\n\t\t */\n\t\tconst isBlockWithinPattern = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName: _getBlockParentsByBlockName,\n\t\t\t\tgetSelectedBlockClientId: _getSelectedBlockClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst parentCoreBlocks = _getBlockParentsByBlockName(\n\t\t\t\t_getSelectedBlockClientId(),\n\t\t\t\tSYNCED_PATTERN_BLOCK_NAME\n\t\t\t);\n\t\t\treturn parentCoreBlocks && parentCoreBlocks.length > 0;\n\t\t}, [] );\n\n\t\tconst { selectionChange, insertBlock } =\n\t\t\tuseDispatch( blockEditorStore );\n\n\t\tif ( ! footnotesBlockType ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( postType !== 'post' && postType !== 'page' ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Checks if the selected block lives within a pattern.\n\t\tif ( isBlockWithinPattern ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tregistry.batch( () => {\n\t\t\t\tlet id;\n\t\t\t\tif ( isObjectActive ) {\n\t\t\t\t\tconst object = value.replacements[ value.start ];\n\t\t\t\t\tid = object?.attributes?.[ 'data-fn' ];\n\t\t\t\t} else {\n\t\t\t\t\tid = createId();\n\t\t\t\t\tconst newValue = insertObject(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: formatName,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t'data-fn': id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinnerHTML: `<a href=\"#${ id }\" id=\"${ id }-link\">*</a>`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalue.end,\n\t\t\t\t\t\tvalue.end\n\t\t\t\t\t);\n\t\t\t\t\tnewValue.start = newValue.end - 1;\n\t\t\t\t\tonChange( newValue );\n\t\t\t\t}\n\n\t\t\t\tconst selectedClientId = getSelectedBlockClientId();\n\n\t\t\t\t/*\n\t\t\t\t * Attempts to find a common parent post content block.\n\t\t\t\t * This allows for locating blocks within a page edited in the site editor.\n\t\t\t\t */\n\t\t\t\tconst parentPostContent = getBlockParentsByBlockName(\n\t\t\t\t\tselectedClientId,\n\t\t\t\t\tPOST_CONTENT_BLOCK_NAME\n\t\t\t\t);\n\n\t\t\t\t// When called with a post content block, getBlocks will return\n\t\t\t\t// the block with controlled inner blocks included.\n\t\t\t\tconst blocks = parentPostContent.length\n\t\t\t\t\t? getBlocks( parentPostContent[ 0 ] )\n\t\t\t\t\t: getBlocks();\n\n\t\t\t\t// BFS search to find the first footnote block.\n\t\t\t\tlet fnBlock = null;\n\t\t\t\t{\n\t\t\t\t\tconst queue = [ ...blocks ];\n\t\t\t\t\twhile ( queue.length ) {\n\t\t\t\t\t\tconst block = queue.shift();\n\t\t\t\t\t\tif ( block.name === name ) {\n\t\t\t\t\t\t\tfnBlock = block;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqueue.push( ...block.innerBlocks );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Maybe this should all also be moved to the entity provider.\n\t\t\t\t// When there is no footnotes block in the post, create one and\n\t\t\t\t// insert it at the bottom.\n\t\t\t\tif ( ! fnBlock ) {\n\t\t\t\t\tlet rootClientId = getBlockRootClientId( selectedClientId );\n\n\t\t\t\t\twhile (\n\t\t\t\t\t\trootClientId &&\n\t\t\t\t\t\tgetBlockName( rootClientId ) !== POST_CONTENT_BLOCK_NAME\n\t\t\t\t\t) {\n\t\t\t\t\t\trootClientId = getBlockRootClientId( rootClientId );\n\t\t\t\t\t}\n\n\t\t\t\t\tfnBlock = createBlock( name );\n\n\t\t\t\t\tinsertBlock( fnBlock, undefined, rootClientId );\n\t\t\t\t}\n\n\t\t\t\tselectionChange( fnBlock.clientId, id, 0, 0 );\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ icon }\n\t\t\t\ttitle={ __( 'Footnote' ) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isObjectActive }\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
|
|
@@ -20,10 +20,52 @@ const metadata = {
|
|
|
20
20
|
textdomain: "default",
|
|
21
21
|
usesContext: ["postId", "postType"],
|
|
22
22
|
supports: {
|
|
23
|
+
__experimentalBorder: {
|
|
24
|
+
radius: true,
|
|
25
|
+
color: true,
|
|
26
|
+
width: true,
|
|
27
|
+
style: true,
|
|
28
|
+
__experimentalDefaultControls: {
|
|
29
|
+
radius: false,
|
|
30
|
+
color: false,
|
|
31
|
+
width: false,
|
|
32
|
+
style: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
color: {
|
|
36
|
+
background: true,
|
|
37
|
+
link: true,
|
|
38
|
+
text: true,
|
|
39
|
+
__experimentalDefaultControls: {
|
|
40
|
+
link: true,
|
|
41
|
+
text: true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
23
44
|
html: false,
|
|
24
45
|
multiple: false,
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
reusable: false,
|
|
47
|
+
spacing: {
|
|
48
|
+
margin: true,
|
|
49
|
+
padding: true,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
margin: false,
|
|
52
|
+
padding: false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
typography: {
|
|
56
|
+
fontSize: true,
|
|
57
|
+
lineHeight: true,
|
|
58
|
+
__experimentalFontFamily: true,
|
|
59
|
+
__experimentalTextDecoration: true,
|
|
60
|
+
__experimentalFontStyle: true,
|
|
61
|
+
__experimentalFontWeight: true,
|
|
62
|
+
__experimentalLetterSpacing: true,
|
|
63
|
+
__experimentalTextTransform: true,
|
|
64
|
+
__experimentalWritingMode: true,
|
|
65
|
+
__experimentalDefaultControls: {
|
|
66
|
+
fontSize: true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
27
69
|
},
|
|
28
70
|
style: "wp-block-footnotes"
|
|
29
71
|
};
|
|
@@ -35,8 +77,7 @@ export { metadata, name };
|
|
|
35
77
|
export const settings = {
|
|
36
78
|
icon,
|
|
37
79
|
edit
|
|
38
|
-
};
|
|
39
|
-
|
|
80
|
+
};
|
|
40
81
|
registerFormatType(formatName, format);
|
|
41
82
|
export const init = () => {
|
|
42
83
|
initBlock({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/footnotes/index.js"],"names":["formatListNumbered","icon","registerFormatType","initBlock","edit","formatName","format","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/footnotes/index.js"],"names":["formatListNumbered","icon","registerFormatType","initBlock","edit","formatName","format","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,kBAAkB,IAAIC,IAA/B,QAA2C,kBAA3C;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAASC,UAAT,EAAqBC,MAArB,QAAmC,UAAnC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBR,EAAAA,IADuB;AAEvBG,EAAAA;AAFuB,CAAjB;AAKPF,kBAAkB,CAAEG,UAAF,EAAcC,MAAd,CAAlB;AAEA,OAAO,MAAMI,IAAI,GAAG,MAAM;AACzBP,EAAAA,SAAS,CAAE;AAAEI,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAF,CAAT;AACA,CAFM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { formatListNumbered as icon } from '@wordpress/icons';\nimport { registerFormatType } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport edit from './edit';\nimport metadata from './block.json';\nimport { formatName, format } from './format';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nregisterFormatType( formatName, format );\n\nexport const init = () => {\n\tinitBlock( { name, metadata, settings } );\n};\n"]}
|
|
@@ -60,7 +60,8 @@ function GalleryEdit(props) {
|
|
|
60
60
|
clientId,
|
|
61
61
|
isSelected,
|
|
62
62
|
insertBlocksAfter,
|
|
63
|
-
isContentLocked
|
|
63
|
+
isContentLocked,
|
|
64
|
+
onFocus
|
|
64
65
|
} = props;
|
|
65
66
|
const {
|
|
66
67
|
columns,
|
|
@@ -361,7 +362,8 @@ function GalleryEdit(props) {
|
|
|
361
362
|
isAppender: hasImages,
|
|
362
363
|
disableMediaButtons: hasImages && !isSelected || imagesUploading,
|
|
363
364
|
value: hasImageIds ? images : {},
|
|
364
|
-
autoOpenMediaUpload: !hasImages && isSelected && wasBlockJustInserted
|
|
365
|
+
autoOpenMediaUpload: !hasImages && isSelected && wasBlockJustInserted,
|
|
366
|
+
onFocus
|
|
365
367
|
}
|
|
366
368
|
});
|
|
367
369
|
const mediaPlaceholder = createElement(MediaPlaceholder, {
|
|
@@ -409,7 +411,7 @@ function GalleryEdit(props) {
|
|
|
409
411
|
max: Math.min(MAX_COLUMNS, images.length),
|
|
410
412
|
...MOBILE_CONTROL_PROPS_RANGE_CONTROL,
|
|
411
413
|
required: true,
|
|
412
|
-
|
|
414
|
+
__next40pxDefaultSize: true
|
|
413
415
|
}), createElement(ToggleControl, {
|
|
414
416
|
__nextHasNoMarginBottom: true,
|
|
415
417
|
label: __('Crop images'),
|
|
@@ -442,7 +444,7 @@ function GalleryEdit(props) {
|
|
|
442
444
|
className: 'gallery-image-sizes'
|
|
443
445
|
}, createElement(BaseControl.VisualLabel, null, __('Resolution')), createElement(View, {
|
|
444
446
|
className: 'gallery-image-sizes__loading'
|
|
445
|
-
}, createElement(Spinner, null), __('Loading options…'))))), createElement(BlockControls, {
|
|
447
|
+
}, createElement(Spinner, null), __('Loading options…'))))), Platform.isWeb && createElement(Fragment, null, createElement(BlockControls, {
|
|
446
448
|
group: "block"
|
|
447
449
|
}, !isContentLocked && createElement(ToolbarButton, {
|
|
448
450
|
onClick: () => {
|
|
@@ -468,10 +470,10 @@ function GalleryEdit(props) {
|
|
|
468
470
|
multiple: true,
|
|
469
471
|
mediaIds: images.filter(image => image.id).map(image => image.id),
|
|
470
472
|
addToGallery: hasImageIds
|
|
471
|
-
})),
|
|
473
|
+
})), createElement(GapStyles, {
|
|
472
474
|
blockGap: attributes.style?.spacing?.blockGap,
|
|
473
475
|
clientId: clientId
|
|
474
|
-
}), createElement(Gallery, { ...props,
|
|
476
|
+
})), createElement(Gallery, { ...props,
|
|
475
477
|
showCaption: showCaption,
|
|
476
478
|
ref: Platform.isWeb ? captionRef : undefined,
|
|
477
479
|
images: images,
|