@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
package/src/list-item/edit.js
CHANGED
|
@@ -22,12 +22,13 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
22
22
|
*/
|
|
23
23
|
import {
|
|
24
24
|
useEnter,
|
|
25
|
-
useBackspace,
|
|
26
25
|
useSpace,
|
|
27
26
|
useIndentListItem,
|
|
28
27
|
useOutdentListItem,
|
|
29
28
|
useSplit,
|
|
29
|
+
useMerge,
|
|
30
30
|
} from './hooks';
|
|
31
|
+
import { convertToListItems } from './utils';
|
|
31
32
|
|
|
32
33
|
function IndentUI( { clientId } ) {
|
|
33
34
|
const [ canIndent, indentListItem ] = useIndentListItem( clientId );
|
|
@@ -40,14 +41,14 @@ function IndentUI( { clientId } ) {
|
|
|
40
41
|
title={ __( 'Outdent' ) }
|
|
41
42
|
describedBy={ __( 'Outdent list item' ) }
|
|
42
43
|
disabled={ ! canOutdent }
|
|
43
|
-
onClick={ outdentListItem }
|
|
44
|
+
onClick={ () => outdentListItem() }
|
|
44
45
|
/>
|
|
45
46
|
<ToolbarButton
|
|
46
47
|
icon={ isRTL() ? formatIndentRTL : formatIndent }
|
|
47
48
|
title={ __( 'Indent' ) }
|
|
48
49
|
describedBy={ __( 'Indent list item' ) }
|
|
49
50
|
isDisabled={ ! canIndent }
|
|
50
|
-
onClick={ indentListItem }
|
|
51
|
+
onClick={ () => indentListItem() }
|
|
51
52
|
/>
|
|
52
53
|
</>
|
|
53
54
|
);
|
|
@@ -56,7 +57,6 @@ function IndentUI( { clientId } ) {
|
|
|
56
57
|
export default function ListItemEdit( {
|
|
57
58
|
attributes,
|
|
58
59
|
setAttributes,
|
|
59
|
-
mergeBlocks,
|
|
60
60
|
onReplace,
|
|
61
61
|
clientId,
|
|
62
62
|
} ) {
|
|
@@ -66,18 +66,14 @@ export default function ListItemEdit( {
|
|
|
66
66
|
allowedBlocks: [ 'core/list' ],
|
|
67
67
|
} );
|
|
68
68
|
const useEnterRef = useEnter( { content, clientId } );
|
|
69
|
-
const useBackspaceRef = useBackspace( { clientId } );
|
|
70
69
|
const useSpaceRef = useSpace( clientId );
|
|
71
70
|
const onSplit = useSplit( clientId );
|
|
71
|
+
const onMerge = useMerge( clientId );
|
|
72
72
|
return (
|
|
73
73
|
<>
|
|
74
74
|
<li { ...innerBlocksProps }>
|
|
75
75
|
<RichText
|
|
76
|
-
ref={ useMergeRefs( [
|
|
77
|
-
useEnterRef,
|
|
78
|
-
useBackspaceRef,
|
|
79
|
-
useSpaceRef,
|
|
80
|
-
] ) }
|
|
76
|
+
ref={ useMergeRefs( [ useEnterRef, useSpaceRef ] ) }
|
|
81
77
|
identifier="content"
|
|
82
78
|
tagName="div"
|
|
83
79
|
onChange={ ( nextContent ) =>
|
|
@@ -87,8 +83,10 @@ export default function ListItemEdit( {
|
|
|
87
83
|
aria-label={ __( 'List text' ) }
|
|
88
84
|
placeholder={ placeholder || __( 'List' ) }
|
|
89
85
|
onSplit={ onSplit }
|
|
90
|
-
onMerge={
|
|
91
|
-
onReplace={
|
|
86
|
+
onMerge={ onMerge }
|
|
87
|
+
onReplace={ ( blocks, ...args ) => {
|
|
88
|
+
onReplace( convertToListItems( blocks ), ...args );
|
|
89
|
+
} }
|
|
92
90
|
/>
|
|
93
91
|
{ innerBlocksProps.children }
|
|
94
92
|
</li>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as useOutdentListItem } from './use-outdent-list-item';
|
|
2
2
|
export { default as useIndentListItem } from './use-indent-list-item';
|
|
3
3
|
export { default as useEnter } from './use-enter';
|
|
4
|
-
export { default as useBackspace } from './use-backspace';
|
|
5
4
|
export { default as useSpace } from './use-space';
|
|
6
5
|
export { default as useSplit } from './use-split';
|
|
6
|
+
export { default as useMerge } from './use-merge';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRegistry, useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
+
import { getDefaultBlockName, switchToBlockType } from '@wordpress/blocks';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import useOutdentListItem from './use-outdent-list-item';
|
|
12
|
+
|
|
13
|
+
import { name as listItemName } from '../block.json';
|
|
14
|
+
|
|
15
|
+
export default function useMerge( clientId ) {
|
|
16
|
+
const registry = useRegistry();
|
|
17
|
+
const {
|
|
18
|
+
getPreviousBlockClientId,
|
|
19
|
+
getNextBlockClientId,
|
|
20
|
+
getBlockOrder,
|
|
21
|
+
getBlockRootClientId,
|
|
22
|
+
getBlockName,
|
|
23
|
+
getBlock,
|
|
24
|
+
} = useSelect( blockEditorStore );
|
|
25
|
+
const { mergeBlocks, moveBlocksToPosition, replaceBlock, selectBlock } =
|
|
26
|
+
useDispatch( blockEditorStore );
|
|
27
|
+
const [ , outdentListItem ] = useOutdentListItem( clientId );
|
|
28
|
+
|
|
29
|
+
function getTrailingId( id ) {
|
|
30
|
+
const order = getBlockOrder( id );
|
|
31
|
+
|
|
32
|
+
if ( ! order.length ) {
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return getTrailingId( order[ order.length - 1 ] );
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getParentListItemId( id ) {
|
|
40
|
+
const listId = getBlockRootClientId( id );
|
|
41
|
+
const parentListItemId = getBlockRootClientId( listId );
|
|
42
|
+
if ( ! parentListItemId ) return;
|
|
43
|
+
if ( getBlockName( parentListItemId ) !== listItemName ) return;
|
|
44
|
+
return parentListItemId;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Return the next list item with respect to the given list item. If none,
|
|
49
|
+
* return the next list item of the parent list item if it exists.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} id A list item client ID.
|
|
52
|
+
* @return {string?} The client ID of the next list item.
|
|
53
|
+
*/
|
|
54
|
+
function _getNextId( id ) {
|
|
55
|
+
const next = getNextBlockClientId( id );
|
|
56
|
+
if ( next ) return next;
|
|
57
|
+
const parentListItemId = getParentListItemId( id );
|
|
58
|
+
if ( ! parentListItemId ) return;
|
|
59
|
+
return _getNextId( parentListItemId );
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Given a client ID, return the client ID of the list item on the next
|
|
64
|
+
* line, regardless of indentation level.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} id The client ID of the current list item.
|
|
67
|
+
* @return {string?} The client ID of the next list item.
|
|
68
|
+
*/
|
|
69
|
+
function getNextId( id ) {
|
|
70
|
+
const order = getBlockOrder( id );
|
|
71
|
+
|
|
72
|
+
// If the list item does not have a nested list, return the next list
|
|
73
|
+
// item.
|
|
74
|
+
if ( ! order.length ) {
|
|
75
|
+
return _getNextId( id );
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Get the first list item in the nested list.
|
|
79
|
+
return getBlockOrder( order[ 0 ] )[ 0 ];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function switchToDefaultBlockType( forward ) {
|
|
83
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
84
|
+
const replacement = switchToBlockType(
|
|
85
|
+
getBlock( rootClientId ),
|
|
86
|
+
getDefaultBlockName()
|
|
87
|
+
);
|
|
88
|
+
const indexToSelect = forward ? replacement.length - 1 : 0;
|
|
89
|
+
const initialPosition = forward ? -1 : 0;
|
|
90
|
+
registry.batch( () => {
|
|
91
|
+
replaceBlock( rootClientId, replacement );
|
|
92
|
+
selectBlock(
|
|
93
|
+
replacement[ indexToSelect ].clientId,
|
|
94
|
+
initialPosition
|
|
95
|
+
);
|
|
96
|
+
} );
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return ( forward ) => {
|
|
100
|
+
if ( forward ) {
|
|
101
|
+
const nextBlockClientId = getNextId( clientId );
|
|
102
|
+
|
|
103
|
+
if ( ! nextBlockClientId ) {
|
|
104
|
+
switchToDefaultBlockType( forward );
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if ( getParentListItemId( nextBlockClientId ) ) {
|
|
109
|
+
outdentListItem( nextBlockClientId );
|
|
110
|
+
} else {
|
|
111
|
+
registry.batch( () => {
|
|
112
|
+
moveBlocksToPosition(
|
|
113
|
+
getBlockOrder( nextBlockClientId ),
|
|
114
|
+
nextBlockClientId,
|
|
115
|
+
getPreviousBlockClientId( nextBlockClientId )
|
|
116
|
+
);
|
|
117
|
+
mergeBlocks( clientId, nextBlockClientId );
|
|
118
|
+
} );
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
// Merging is only done from the top level. For lowel levels, the
|
|
122
|
+
// list item is outdented instead.
|
|
123
|
+
const previousBlockClientId = getPreviousBlockClientId( clientId );
|
|
124
|
+
if ( getParentListItemId( clientId ) ) {
|
|
125
|
+
outdentListItem( clientId );
|
|
126
|
+
} else if ( previousBlockClientId ) {
|
|
127
|
+
const trailingId = getTrailingId( previousBlockClientId );
|
|
128
|
+
registry.batch( () => {
|
|
129
|
+
moveBlocksToPosition(
|
|
130
|
+
getBlockOrder( clientId ),
|
|
131
|
+
clientId,
|
|
132
|
+
previousBlockClientId
|
|
133
|
+
);
|
|
134
|
+
mergeBlocks( trailingId, clientId );
|
|
135
|
+
} );
|
|
136
|
+
} else {
|
|
137
|
+
switchToDefaultBlockType( forward );
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { first, last } from 'lodash';
|
|
4
|
+
import { first, last, castArray } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useCallback } from '@wordpress/element';
|
|
10
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
11
11
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
12
|
import { cloneBlock } from '@wordpress/blocks';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { name as listItemName } from '../block.json';
|
|
18
18
|
|
|
19
19
|
export default function useOutdentListItem( clientId ) {
|
|
20
|
+
const registry = useRegistry();
|
|
20
21
|
const { canOutdent } = useSelect(
|
|
21
22
|
( innerSelect ) => {
|
|
22
23
|
const { getBlockRootClientId } = innerSelect( blockEditorStore );
|
|
@@ -29,93 +30,90 @@ export default function useOutdentListItem( clientId ) {
|
|
|
29
30
|
},
|
|
30
31
|
[ clientId ]
|
|
31
32
|
);
|
|
32
|
-
const {
|
|
33
|
-
|
|
33
|
+
const {
|
|
34
|
+
moveBlocksToPosition,
|
|
35
|
+
removeBlock,
|
|
36
|
+
insertBlock,
|
|
37
|
+
updateBlockListSettings,
|
|
38
|
+
} = useDispatch( blockEditorStore );
|
|
34
39
|
const {
|
|
35
40
|
getBlockRootClientId,
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
getBlockName,
|
|
42
|
+
getBlockOrder,
|
|
38
43
|
getBlockIndex,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
getMultiSelectedBlockClientIds,
|
|
44
|
+
getSelectedBlockClientIds,
|
|
45
|
+
getBlock,
|
|
46
|
+
getBlockListSettings,
|
|
43
47
|
} = useSelect( blockEditorStore );
|
|
44
48
|
|
|
49
|
+
function getParentListItemId( id ) {
|
|
50
|
+
const listId = getBlockRootClientId( id );
|
|
51
|
+
const parentListItemId = getBlockRootClientId( listId );
|
|
52
|
+
if ( ! parentListItemId ) return;
|
|
53
|
+
if ( getBlockName( parentListItemId ) !== listItemName ) return;
|
|
54
|
+
return parentListItemId;
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
return [
|
|
46
58
|
canOutdent,
|
|
47
|
-
useCallback( () => {
|
|
48
|
-
|
|
49
|
-
const clientIds = _hasMultiSelection
|
|
50
|
-
? getMultiSelectedBlockClientIds()
|
|
51
|
-
: [ clientId ];
|
|
59
|
+
useCallback( ( clientIds = getSelectedBlockClientIds() ) => {
|
|
60
|
+
clientIds = castArray( clientIds );
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
const selectionEnd = getSelectionEnd();
|
|
62
|
+
if ( ! clientIds.length ) return;
|
|
55
63
|
|
|
56
|
-
const
|
|
57
|
-
const listAttributes = getBlockAttributes( listParentId );
|
|
58
|
-
const listItemParentId = getBlockRootClientId( listParentId );
|
|
59
|
-
const listItemParentAttributes =
|
|
60
|
-
getBlockAttributes( listItemParentId );
|
|
64
|
+
const firstClientId = first( clientIds );
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const siblingBlocks = getBlock( listParentId ).innerBlocks;
|
|
65
|
-
const previousSiblings = siblingBlocks.slice( 0, firstIndex );
|
|
66
|
-
const afterSiblings = siblingBlocks.slice( lastIndex + 1 );
|
|
66
|
+
// Can't outdent if it's not a list item.
|
|
67
|
+
if ( getBlockName( firstClientId ) !== listItemName ) return;
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
// that existed before the first child item being outdent.
|
|
70
|
-
const newListItemParent = createListItem(
|
|
71
|
-
listItemParentAttributes,
|
|
72
|
-
listAttributes,
|
|
73
|
-
previousSiblings
|
|
74
|
-
);
|
|
69
|
+
const parentListItemId = getParentListItemId( firstClientId );
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const childItems = childList?.innerBlocks || [];
|
|
79
|
-
const hasChildItems = !! childItems.length;
|
|
71
|
+
// Can't outdent if it's at the top level.
|
|
72
|
+
if ( ! parentListItemId ) return;
|
|
80
73
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// last block being outdent and whose children are the children that it had (if any)
|
|
87
|
-
// followed by the siblings that existed after it.
|
|
88
|
-
const newLastItem = createListItem(
|
|
89
|
-
lastBlock.attributes,
|
|
90
|
-
hasChildItems ? childList.attributes : listAttributes,
|
|
91
|
-
[ ...childItems, ...afterSiblings ]
|
|
74
|
+
const parentListId = getBlockRootClientId( firstClientId );
|
|
75
|
+
const lastClientId = last( clientIds );
|
|
76
|
+
const order = getBlockOrder( parentListId );
|
|
77
|
+
const followingListItems = order.slice(
|
|
78
|
+
getBlockIndex( lastClientId ) + 1
|
|
92
79
|
);
|
|
93
80
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// as children of the last block.
|
|
98
|
-
replaceBlocks(
|
|
99
|
-
[ listItemParentId ],
|
|
100
|
-
[ newListItemParent, ...newBlocksExcludingLast, newLastItem ]
|
|
101
|
-
);
|
|
81
|
+
registry.batch( () => {
|
|
82
|
+
if ( followingListItems.length ) {
|
|
83
|
+
let nestedListId = first( getBlockOrder( firstClientId ) );
|
|
102
84
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
85
|
+
if ( ! nestedListId ) {
|
|
86
|
+
const nestedListBlock = cloneBlock(
|
|
87
|
+
getBlock( parentListId ),
|
|
88
|
+
{},
|
|
89
|
+
[]
|
|
90
|
+
);
|
|
91
|
+
nestedListId = nestedListBlock.clientId;
|
|
92
|
+
insertBlock( nestedListBlock, 0, firstClientId, false );
|
|
93
|
+
// Immediately update the block list settings, otherwise
|
|
94
|
+
// blocks can't be moved here due to canInsert checks.
|
|
95
|
+
updateBlockListSettings(
|
|
96
|
+
nestedListId,
|
|
97
|
+
getBlockListSettings( parentListId )
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
moveBlocksToPosition(
|
|
102
|
+
followingListItems,
|
|
103
|
+
parentListId,
|
|
104
|
+
nestedListId
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
moveBlocksToPosition(
|
|
108
|
+
clientIds,
|
|
109
|
+
parentListId,
|
|
110
|
+
getBlockRootClientId( parentListItemId ),
|
|
111
|
+
getBlockIndex( parentListItemId ) + 1
|
|
117
112
|
);
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
if ( ! getBlockOrder( parentListId ).length ) {
|
|
114
|
+
removeBlock( parentListId );
|
|
115
|
+
}
|
|
116
|
+
} );
|
|
117
|
+
}, [] ),
|
|
120
118
|
];
|
|
121
119
|
}
|
package/src/list-item/utils.js
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createBlock } from '@wordpress/blocks';
|
|
4
|
+
import { createBlock, switchToBlockType } from '@wordpress/blocks';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { name as listItemName } from './block.json';
|
|
10
|
+
import { name as listName } from '../list/block.json';
|
|
5
11
|
|
|
6
12
|
export function createListItem( listItemAttributes, listAttributes, children ) {
|
|
7
13
|
return createBlock(
|
|
8
|
-
|
|
14
|
+
listItemName,
|
|
9
15
|
listItemAttributes,
|
|
10
16
|
! children?.length
|
|
11
17
|
? []
|
|
12
|
-
: [ createBlock(
|
|
18
|
+
: [ createBlock( listName, listAttributes, children ) ]
|
|
13
19
|
);
|
|
14
20
|
}
|
|
21
|
+
|
|
22
|
+
export function convertToListItems( blocks ) {
|
|
23
|
+
const listItems = [];
|
|
24
|
+
|
|
25
|
+
for ( let block of blocks ) {
|
|
26
|
+
if ( block.name === listItemName ) {
|
|
27
|
+
listItems.push( block );
|
|
28
|
+
} else if ( block.name === listName ) {
|
|
29
|
+
listItems.push( ...block.innerBlocks );
|
|
30
|
+
} else if ( ( block = switchToBlockType( block, listName ) ) ) {
|
|
31
|
+
for ( const { innerBlocks } of block ) {
|
|
32
|
+
listItems.push( ...innerBlocks );
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return listItems;
|
|
38
|
+
}
|
|
@@ -7,12 +7,18 @@ import { isEmpty, omit } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
InnerBlocks,
|
|
12
|
+
getColorClassName,
|
|
13
|
+
useInnerBlocksProps,
|
|
14
|
+
useBlockProps,
|
|
15
|
+
} from '@wordpress/block-editor';
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
18
|
* Internal dependencies
|
|
14
19
|
*/
|
|
15
20
|
import { imageFillStyles } from './media-container';
|
|
21
|
+
import { DEFAULT_MEDIA_SIZE_SLUG } from './constants';
|
|
16
22
|
|
|
17
23
|
const DEFAULT_MEDIA_WIDTH = 50;
|
|
18
24
|
const noop = () => {};
|
|
@@ -68,6 +74,147 @@ const baseAttributes = {
|
|
|
68
74
|
};
|
|
69
75
|
|
|
70
76
|
export default [
|
|
77
|
+
// Version with CSS grid
|
|
78
|
+
{
|
|
79
|
+
attributes: {
|
|
80
|
+
...baseAttributes,
|
|
81
|
+
mediaUrl: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
source: 'attribute',
|
|
84
|
+
selector: 'figure video,figure img',
|
|
85
|
+
attribute: 'src',
|
|
86
|
+
},
|
|
87
|
+
mediaLink: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
},
|
|
90
|
+
linkDestination: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
},
|
|
93
|
+
linkTarget: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
source: 'attribute',
|
|
96
|
+
selector: 'figure a',
|
|
97
|
+
attribute: 'target',
|
|
98
|
+
},
|
|
99
|
+
href: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
source: 'attribute',
|
|
102
|
+
selector: 'figure a',
|
|
103
|
+
attribute: 'href',
|
|
104
|
+
},
|
|
105
|
+
rel: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
source: 'attribute',
|
|
108
|
+
selector: 'figure a',
|
|
109
|
+
attribute: 'rel',
|
|
110
|
+
},
|
|
111
|
+
linkClass: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
source: 'attribute',
|
|
114
|
+
selector: 'figure a',
|
|
115
|
+
attribute: 'class',
|
|
116
|
+
},
|
|
117
|
+
verticalAlignment: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
},
|
|
120
|
+
imageFill: {
|
|
121
|
+
type: 'boolean',
|
|
122
|
+
},
|
|
123
|
+
focalPoint: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
save( { attributes } ) {
|
|
128
|
+
const {
|
|
129
|
+
isStackedOnMobile,
|
|
130
|
+
mediaAlt,
|
|
131
|
+
mediaPosition,
|
|
132
|
+
mediaType,
|
|
133
|
+
mediaUrl,
|
|
134
|
+
mediaWidth,
|
|
135
|
+
mediaId,
|
|
136
|
+
verticalAlignment,
|
|
137
|
+
imageFill,
|
|
138
|
+
focalPoint,
|
|
139
|
+
linkClass,
|
|
140
|
+
href,
|
|
141
|
+
linkTarget,
|
|
142
|
+
rel,
|
|
143
|
+
} = attributes;
|
|
144
|
+
const mediaSizeSlug =
|
|
145
|
+
attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
|
|
146
|
+
const newRel = isEmpty( rel ) ? undefined : rel;
|
|
147
|
+
|
|
148
|
+
const imageClasses = classnames( {
|
|
149
|
+
[ `wp-image-${ mediaId }` ]: mediaId && mediaType === 'image',
|
|
150
|
+
[ `size-${ mediaSizeSlug }` ]: mediaId && mediaType === 'image',
|
|
151
|
+
} );
|
|
152
|
+
|
|
153
|
+
let image = (
|
|
154
|
+
<img
|
|
155
|
+
src={ mediaUrl }
|
|
156
|
+
alt={ mediaAlt }
|
|
157
|
+
className={ imageClasses || null }
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if ( href ) {
|
|
162
|
+
image = (
|
|
163
|
+
<a
|
|
164
|
+
className={ linkClass }
|
|
165
|
+
href={ href }
|
|
166
|
+
target={ linkTarget }
|
|
167
|
+
rel={ newRel }
|
|
168
|
+
>
|
|
169
|
+
{ image }
|
|
170
|
+
</a>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const mediaTypeRenders = {
|
|
175
|
+
image: () => image,
|
|
176
|
+
video: () => <video controls src={ mediaUrl } />,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const className = classnames( {
|
|
180
|
+
'has-media-on-the-right': 'right' === mediaPosition,
|
|
181
|
+
'is-stacked-on-mobile': isStackedOnMobile,
|
|
182
|
+
[ `is-vertically-aligned-${ verticalAlignment }` ]:
|
|
183
|
+
verticalAlignment,
|
|
184
|
+
'is-image-fill': imageFill,
|
|
185
|
+
} );
|
|
186
|
+
const backgroundStyles = imageFill
|
|
187
|
+
? imageFillStyles( mediaUrl, focalPoint )
|
|
188
|
+
: {};
|
|
189
|
+
|
|
190
|
+
let gridTemplateColumns;
|
|
191
|
+
if ( mediaWidth !== DEFAULT_MEDIA_WIDTH ) {
|
|
192
|
+
gridTemplateColumns =
|
|
193
|
+
'right' === mediaPosition
|
|
194
|
+
? `auto ${ mediaWidth }%`
|
|
195
|
+
: `${ mediaWidth }% auto`;
|
|
196
|
+
}
|
|
197
|
+
const style = {
|
|
198
|
+
gridTemplateColumns,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<div { ...useBlockProps.save( { className, style } ) }>
|
|
203
|
+
<figure
|
|
204
|
+
className="wp-block-media-text__media"
|
|
205
|
+
style={ backgroundStyles }
|
|
206
|
+
>
|
|
207
|
+
{ ( mediaTypeRenders[ mediaType ] || noop )() }
|
|
208
|
+
</figure>
|
|
209
|
+
<div
|
|
210
|
+
{ ...useInnerBlocksProps.save( {
|
|
211
|
+
className: 'wp-block-media-text__content',
|
|
212
|
+
} ) }
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
);
|
|
216
|
+
},
|
|
217
|
+
},
|
|
71
218
|
{
|
|
72
219
|
attributes: {
|
|
73
220
|
...baseAttributes,
|
package/src/media-text/edit.js
CHANGED
|
@@ -354,6 +354,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
|
|
|
354
354
|
) }
|
|
355
355
|
</BlockControls>
|
|
356
356
|
<div { ...blockProps }>
|
|
357
|
+
{ mediaPosition === 'right' && <div { ...innerBlocksProps } /> }
|
|
357
358
|
<MediaContainer
|
|
358
359
|
className="wp-block-media-text__media"
|
|
359
360
|
onSelectMedia={ onSelectMedia }
|
|
@@ -373,7 +374,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
|
|
|
373
374
|
mediaWidth,
|
|
374
375
|
} }
|
|
375
376
|
/>
|
|
376
|
-
<div { ...innerBlocksProps } />
|
|
377
|
+
{ mediaPosition !== 'right' && <div { ...innerBlocksProps } /> }
|
|
377
378
|
</div>
|
|
378
379
|
</>
|
|
379
380
|
);
|
package/src/media-text/save.js
CHANGED
|
@@ -88,6 +88,24 @@ export default function save( { attributes } ) {
|
|
|
88
88
|
const style = {
|
|
89
89
|
gridTemplateColumns,
|
|
90
90
|
};
|
|
91
|
+
|
|
92
|
+
if ( 'right' === mediaPosition ) {
|
|
93
|
+
return (
|
|
94
|
+
<div { ...useBlockProps.save( { className, style } ) }>
|
|
95
|
+
<div
|
|
96
|
+
{ ...useInnerBlocksProps.save( {
|
|
97
|
+
className: 'wp-block-media-text__content',
|
|
98
|
+
} ) }
|
|
99
|
+
/>
|
|
100
|
+
<figure
|
|
101
|
+
className="wp-block-media-text__media"
|
|
102
|
+
style={ backgroundStyles }
|
|
103
|
+
>
|
|
104
|
+
{ ( mediaTypeRenders[ mediaType ] || noop )() }
|
|
105
|
+
</figure>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
91
109
|
return (
|
|
92
110
|
<div { ...useBlockProps.save( { className, style } ) }>
|
|
93
111
|
<figure
|
package/src/more/save.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { compact } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -14,6 +9,8 @@ export default function save( { attributes: { customText, noTeaser } } ) {
|
|
|
14
9
|
const noTeaserTag = noTeaser ? '<!--noteaser-->' : '';
|
|
15
10
|
|
|
16
11
|
return (
|
|
17
|
-
<RawHTML>
|
|
12
|
+
<RawHTML>
|
|
13
|
+
{ [ moreTag, noTeaserTag ].filter( Boolean ).join( '\n' ) }
|
|
14
|
+
</RawHTML>
|
|
18
15
|
);
|
|
19
16
|
}
|