@wordpress/block-library 8.6.0 → 8.8.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/buttons/index.js +1 -0
- package/build/buttons/index.js.map +1 -1
- package/build/buttons/transforms.js +1 -0
- package/build/buttons/transforms.js.map +1 -1
- package/build/column/index.js +2 -1
- package/build/column/index.js.map +1 -1
- package/build/columns/edit.js +28 -8
- package/build/columns/edit.js.map +1 -1
- package/build/columns/index.js +6 -1
- package/build/columns/index.js.map +1 -1
- package/build/columns/utils.js +4 -9
- package/build/columns/utils.js.map +1 -1
- package/build/cover/edit/index.js +46 -50
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -2
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
- package/build/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build/cover/index.js +12 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/edit.js +67 -0
- package/build/details/edit.js.map +1 -0
- package/build/details/index.js +110 -0
- package/build/details/index.js.map +1 -0
- package/build/details/save.js +33 -0
- package/build/details/save.js.map +1 -0
- package/build/details-content/edit.js +34 -0
- package/build/details-content/edit.js.map +1 -0
- package/build/details-content/index.js +94 -0
- package/build/details-content/index.js.map +1 -0
- package/build/details-content/save.js +20 -0
- package/build/details-content/save.js.map +1 -0
- package/build/details-summary/edit.js +42 -0
- package/build/details-summary/edit.js.map +1 -0
- package/build/details-summary/index.js +97 -0
- package/build/details-summary/index.js.map +1 -0
- package/build/details-summary/save.js +24 -0
- package/build/details-summary/save.js.map +1 -0
- package/build/embed/deprecated.js +4 -1
- package/build/embed/deprecated.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +1 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/embed/embed-placeholder.js +1 -1
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/index.js +4 -1
- package/build/embed/index.js.map +1 -1
- package/build/embed/transforms.js +4 -1
- package/build/embed/transforms.js.map +1 -1
- package/build/embed/util.js +4 -1
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.native.js +0 -2
- package/build/file/edit.native.js.map +1 -1
- package/build/gallery/edit.js +8 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/use-get-media.native.js +2 -1
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/gallery/use-image-sizes.js +1 -1
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/group/deprecated.js +4 -2
- package/build/group/deprecated.js.map +1 -1
- package/build/group/edit.js +22 -5
- package/build/group/edit.js.map +1 -1
- package/build/group/placeholder.js +11 -1
- package/build/group/placeholder.js.map +1 -1
- package/build/group/variations.js +23 -3
- package/build/group/variations.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +8 -6
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +9 -2
- package/build/image/index.js.map +1 -1
- package/build/index.js +24 -6
- package/build/index.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/deprecated.js +228 -18
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +3 -3
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +1 -1
- package/build/media-text/media-container.js +2 -6
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -3
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/deprecated.js +8 -11
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +1 -12
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +1 -4
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/post-author/index.js +0 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-date/edit.js +2 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +4 -1
- package/build/post-date/index.js.map +1 -1
- package/build/post-date/variations.js +28 -0
- package/build/post-date/variations.js.map +1 -0
- package/build/post-excerpt/edit.js +39 -10
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +4 -3
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -22
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-time-to-read/edit.js +1 -1
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/post-time-to-read/index.js +24 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/spacer/controls.js +25 -6
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/edit.js +27 -7
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/save.js +2 -2
- package/build/spacer/save.js.map +1 -1
- package/build/table/state.js +35 -35
- package/build/table/state.js.map +1 -1
- package/build/term-description/index.js +1 -2
- package/build/term-description/index.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -2
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build-module/buttons/index.js +1 -0
- package/build-module/buttons/index.js.map +1 -1
- package/build-module/buttons/transforms.js +1 -0
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/column/index.js +2 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/edit.js +28 -8
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/index.js +6 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/columns/utils.js +4 -8
- package/build-module/columns/utils.js.map +1 -1
- package/build-module/cover/edit/index.js +48 -52
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
- package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build-module/cover/index.js +12 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/edit.js +52 -0
- package/build-module/details/edit.js.map +1 -0
- package/build-module/details/index.js +91 -0
- package/build-module/details/index.js.map +1 -0
- package/build-module/details/save.js +20 -0
- package/build-module/details/save.js.map +1 -0
- package/build-module/details-content/edit.js +23 -0
- package/build-module/details-content/edit.js.map +1 -0
- package/build-module/details-content/index.js +76 -0
- package/build-module/details-content/index.js.map +1 -0
- package/build-module/details-content/save.js +11 -0
- package/build-module/details-content/save.js.map +1 -0
- package/build-module/details-summary/edit.js +30 -0
- package/build-module/details-summary/edit.js.map +1 -0
- package/build-module/details-summary/index.js +79 -0
- package/build-module/details-summary/index.js.map +1 -0
- package/build-module/details-summary/save.js +16 -0
- package/build-module/details-summary/save.js.map +1 -0
- package/build-module/embed/deprecated.js +4 -1
- package/build-module/embed/deprecated.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +1 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +1 -1
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/index.js +4 -1
- package/build-module/embed/index.js.map +1 -1
- package/build-module/embed/transforms.js +4 -1
- package/build-module/embed/transforms.js.map +1 -1
- package/build-module/embed/util.js +4 -1
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.native.js +0 -2
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/gallery/edit.js +8 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +2 -1
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +1 -1
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/group/deprecated.js +4 -2
- package/build-module/group/deprecated.js.map +1 -1
- package/build-module/group/edit.js +21 -5
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/placeholder.js +11 -1
- package/build-module/group/placeholder.js.map +1 -1
- package/build-module/group/variations.js +24 -1
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +8 -6
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +9 -2
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +21 -6
- package/build-module/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/deprecated.js +227 -18
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +3 -3
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +1 -1
- package/build-module/media-text/media-container.js +1 -5
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/deprecated.js +8 -10
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -12
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +1 -4
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/post-author/index.js +0 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-date/edit.js +2 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +3 -1
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-date/variations.js +18 -0
- package/build-module/post-date/variations.js.map +1 -0
- package/build-module/post-excerpt/edit.js +38 -11
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +4 -3
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +8 -22
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-time-to-read/edit.js +1 -1
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/post-time-to-read/index.js +24 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/spacer/controls.js +27 -9
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/edit.js +27 -8
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/save.js +3 -3
- package/build-module/spacer/save.js.map +1 -1
- package/build-module/table/state.js +35 -33
- package/build-module/table/state.js.map +1 -1
- package/build-module/term-description/index.js +1 -2
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +6 -3
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-style/categories/editor-rtl.css +5 -0
- package/build-style/categories/editor.css +5 -0
- package/build-style/categories/style-rtl.css +4 -0
- package/build-style/categories/style.css +4 -0
- package/build-style/columns/style-rtl.css +4 -1
- package/build-style/columns/style.css +4 -1
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/editor-rtl.css +11 -12
- package/build-style/cover/editor.css +11 -12
- package/build-style/cover/style-rtl.css +3 -2
- package/build-style/cover/style.css +3 -2
- package/build-style/details/style-rtl.css +91 -0
- package/build-style/details/style.css +91 -0
- package/build-style/details-summary/editor-rtl.css +91 -0
- package/build-style/details-summary/editor.css +91 -0
- package/build-style/details-summary/style-rtl.css +91 -0
- package/build-style/details-summary/style.css +91 -0
- package/build-style/editor-rtl.css +40 -48
- package/build-style/editor.css +40 -48
- package/build-style/file/style-rtl.css +4 -3
- package/build-style/file/style.css +4 -3
- package/build-style/navigation/style-rtl.css +2 -0
- package/build-style/navigation/style.css +2 -0
- package/build-style/post-excerpt/style-rtl.css +1 -1
- package/build-style/post-excerpt/style.css +1 -1
- package/build-style/post-featured-image/editor-rtl.css +1 -0
- package/build-style/post-featured-image/editor.css +1 -0
- package/build-style/post-template/style-rtl.css +1 -1
- package/build-style/post-template/style.css +1 -1
- package/build-style/post-time-to-read/style-rtl.css +91 -0
- package/build-style/post-time-to-read/style.css +91 -0
- package/build-style/pullquote/style-rtl.css +4 -1
- package/build-style/pullquote/style.css +4 -1
- package/build-style/search/style-rtl.css +8 -7
- package/build-style/search/style.css +8 -7
- package/build-style/shortcode/editor-rtl.css +15 -34
- package/build-style/shortcode/editor.css +15 -34
- package/build-style/spacer/editor-rtl.css +4 -2
- package/build-style/spacer/editor.css +4 -2
- package/build-style/style-rtl.css +44 -17
- package/build-style/style.css +44 -17
- package/package.json +31 -31
- package/src/buttons/block.json +1 -0
- package/src/categories/editor.scss +5 -0
- package/src/categories/style.scss +4 -0
- package/src/column/block.json +2 -1
- package/src/columns/block.json +6 -1
- package/src/columns/edit.js +35 -10
- package/src/columns/style.scss +5 -1
- package/src/columns/utils.js +8 -9
- package/src/comments/index.php +1 -0
- package/src/common.scss +1 -1
- package/src/cover/block.json +12 -0
- package/src/cover/edit/index.js +44 -37
- package/src/cover/edit/inspector-controls.js +4 -5
- package/src/cover/edit/resizable-cover-popover.js +82 -0
- package/src/cover/editor.scss +20 -13
- package/src/cover/index.php +9 -10
- package/src/cover/style.scss +2 -1
- package/src/cover/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/cover/test/edit.js +324 -0
- package/src/details/block.json +54 -0
- package/src/details/edit.js +59 -0
- package/src/details/index.js +35 -0
- package/src/details/save.js +15 -0
- package/src/details/style.scss +3 -0
- package/src/details-content/block.json +50 -0
- package/src/details-content/edit.js +29 -0
- package/src/details-content/index.js +23 -0
- package/src/details-content/save.js +12 -0
- package/src/details-summary/block.json +53 -0
- package/src/details-summary/edit.js +27 -0
- package/src/details-summary/editor.scss +3 -0
- package/src/details-summary/index.js +23 -0
- package/src/details-summary/save.js +13 -0
- package/src/details-summary/style.scss +3 -0
- package/src/editor.scss +1 -0
- package/src/embed/block.json +4 -1
- package/src/embed/embed-link-settings.native.js +1 -1
- package/src/embed/embed-placeholder.js +1 -1
- package/src/file/edit.native.js +0 -2
- package/src/file/style.scss +5 -2
- package/src/gallery/edit.js +5 -2
- package/src/gallery/test/use-get-media.native.js +24 -0
- package/src/gallery/use-get-media.native.js +1 -1
- package/src/gallery/use-image-sizes.js +1 -1
- package/src/group/deprecated.js +4 -2
- package/src/group/edit.js +27 -9
- package/src/group/placeholder.js +13 -1
- package/src/group/variations.js +14 -1
- package/src/home-link/index.php +2 -2
- package/src/image/block.json +9 -2
- package/src/image/edit.js +1 -1
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +15 -7
- package/src/image/index.php +7 -2
- package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/index.js +13 -3
- package/src/latest-comments/style.scss +1 -1
- package/src/latest-posts/edit.js +3 -0
- package/src/media-text/block.json +1 -1
- package/src/media-text/deprecated.js +235 -3
- package/src/media-text/edit.js +7 -6
- package/src/media-text/media-container.js +1 -5
- package/src/media-text/media-container.native.js +1 -1
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +4 -4
- package/src/navigation/block.json +0 -1
- package/src/navigation/deprecated.js +15 -19
- package/src/navigation/edit/index.js +0 -13
- package/src/navigation/edit/inner-blocks.js +0 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
- package/src/navigation/index.php +0 -4
- package/src/navigation/style.scss +6 -4
- package/src/navigation-link/index.php +2 -1
- package/src/navigation-submenu/index.php +30 -76
- package/src/paragraph/test/edit.native.js +356 -1
- package/src/post-author/block.json +0 -1
- package/src/post-author/index.php +1 -1
- package/src/post-date/edit.js +4 -1
- package/src/post-date/index.js +2 -0
- package/src/post-date/variations.js +20 -0
- package/src/post-excerpt/edit.js +48 -16
- package/src/post-excerpt/index.php +3 -3
- package/src/post-excerpt/style.scss +2 -1
- package/src/post-featured-image/dimension-controls.js +7 -3
- package/src/post-featured-image/edit.js +8 -29
- package/src/post-featured-image/editor.scss +1 -0
- package/src/post-template/block.json +1 -1
- package/src/post-template/style.scss +1 -1
- package/src/post-time-to-read/block.json +24 -1
- package/src/post-time-to-read/edit.js +1 -1
- package/src/post-time-to-read/index.php +3 -3
- package/src/post-time-to-read/style.scss +4 -0
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/preformatted/test/edit.native.js +45 -2
- package/src/pullquote/style.scss +5 -1
- package/src/pullquote/test/edit.native.js +70 -0
- package/src/query-title/index.php +2 -5
- package/src/quote/block.json +1 -0
- package/src/quote/test/edit.native.js +92 -0
- package/src/search/index.php +1 -1
- package/src/search/style.scss +16 -12
- package/src/shortcode/editor.scss +26 -5
- package/src/spacer/controls.js +42 -17
- package/src/spacer/edit.js +41 -9
- package/src/spacer/editor.scss +2 -1
- package/src/spacer/save.js +3 -3
- package/src/style.scss +3 -0
- package/src/table/state.js +83 -66
- package/src/term-description/block.json +1 -2
- package/src/utils/clean-empty-object.js +4 -4
- package/src/verse/test/edit.native.js +33 -0
- package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/cover/edit/resizable-cover.js.map +0 -1
- package/build/media-text/media-container-icon.js +0 -27
- package/build/media-text/media-container-icon.js.map +0 -1
- package/build-module/cover/edit/resizable-cover.js.map +0 -1
- package/build-module/media-text/media-container-icon.js +0 -17
- package/build-module/media-text/media-container-icon.js.map +0 -1
- package/src/cover/edit/resizable-cover.js +0 -61
- package/src/cover/test/block-controls.js +0 -62
- package/src/media-text/media-container-icon.js +0 -12
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
addBlock,
|
|
6
|
+
getBlock,
|
|
7
|
+
initializeEditor,
|
|
8
|
+
setupCoreBlocks,
|
|
9
|
+
getEditorHtml,
|
|
10
|
+
fireEvent,
|
|
11
|
+
within,
|
|
12
|
+
waitFor,
|
|
13
|
+
changeAndSelectTextOfRichText,
|
|
14
|
+
} from 'test/helpers';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { ENTER } from '@wordpress/keycodes';
|
|
20
|
+
|
|
21
|
+
setupCoreBlocks();
|
|
22
|
+
|
|
23
|
+
describe( 'Quote', () => {
|
|
24
|
+
it( 'should produce expected markup for multiline text', async () => {
|
|
25
|
+
// Arrange
|
|
26
|
+
const screen = await initializeEditor();
|
|
27
|
+
await addBlock( screen, 'Quote' );
|
|
28
|
+
const quoteBlock = getBlock( screen, 'Quote' );
|
|
29
|
+
// A layout event must be explicitly dispatched in BlockList component,
|
|
30
|
+
// otherwise the inner blocks are not rendered.
|
|
31
|
+
fireEvent(
|
|
32
|
+
within( quoteBlock ).getByTestId( 'block-list-wrapper' ),
|
|
33
|
+
'layout',
|
|
34
|
+
{
|
|
35
|
+
nativeEvent: {
|
|
36
|
+
layout: {
|
|
37
|
+
width: 320,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
// Await inner blocks to be rendered
|
|
43
|
+
const citationBlock = await waitFor( () =>
|
|
44
|
+
screen.getByPlaceholderText( 'Add citation' )
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Act
|
|
48
|
+
fireEvent.press( quoteBlock );
|
|
49
|
+
// screen.debug();
|
|
50
|
+
let quoteTextInput =
|
|
51
|
+
within( quoteBlock ).getByPlaceholderText( 'Start writing…' );
|
|
52
|
+
const string = 'A great statement.';
|
|
53
|
+
changeAndSelectTextOfRichText( quoteTextInput, string, {
|
|
54
|
+
selectionStart: string.length,
|
|
55
|
+
selectionEnd: string.length,
|
|
56
|
+
} );
|
|
57
|
+
fireEvent( quoteTextInput, 'onKeyDown', {
|
|
58
|
+
nativeEvent: {},
|
|
59
|
+
preventDefault() {},
|
|
60
|
+
keyCode: ENTER,
|
|
61
|
+
} );
|
|
62
|
+
quoteTextInput =
|
|
63
|
+
within( quoteBlock ).getAllByPlaceholderText(
|
|
64
|
+
'Start writing…'
|
|
65
|
+
)[ 1 ];
|
|
66
|
+
changeAndSelectTextOfRichText( quoteTextInput, 'Again.' );
|
|
67
|
+
const citationTextInput =
|
|
68
|
+
within( citationBlock ).getByPlaceholderText( 'Add citation' );
|
|
69
|
+
changeAndSelectTextOfRichText( citationTextInput, 'A person', {
|
|
70
|
+
selectionStart: 2,
|
|
71
|
+
selectionEnd: 2,
|
|
72
|
+
} );
|
|
73
|
+
fireEvent( citationTextInput, 'onKeyDown', {
|
|
74
|
+
nativeEvent: {},
|
|
75
|
+
preventDefault() {},
|
|
76
|
+
keyCode: ENTER,
|
|
77
|
+
} );
|
|
78
|
+
|
|
79
|
+
// Assert
|
|
80
|
+
expect( getEditorHtml() ).toMatchInlineSnapshot( `
|
|
81
|
+
"<!-- wp:quote -->
|
|
82
|
+
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
|
83
|
+
<p>A great statement.</p>
|
|
84
|
+
<!-- /wp:paragraph -->
|
|
85
|
+
|
|
86
|
+
<!-- wp:paragraph -->
|
|
87
|
+
<p>Again.</p>
|
|
88
|
+
<!-- /wp:paragraph --><cite>A <br>person</cite></blockquote>
|
|
89
|
+
<!-- /wp:quote -->"
|
|
90
|
+
` );
|
|
91
|
+
} );
|
|
92
|
+
} );
|
package/src/search/index.php
CHANGED
|
@@ -116,7 +116,7 @@ function render_block_core_search( $attributes ) {
|
|
|
116
116
|
|
|
117
117
|
$button_internal_markup =
|
|
118
118
|
'<svg class="search-icon" viewBox="0 0 24 24" width="24" height="24">
|
|
119
|
-
<path d="M13
|
|
119
|
+
<path d="M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"></path>
|
|
120
120
|
</svg>';
|
|
121
121
|
}
|
|
122
122
|
|
package/src/search/style.scss
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
$button-spacing-x: $grid-unit-10 + math.div($grid-unit-05, 2); // 10px
|
|
2
|
+
$button-spacing-y: math.div($grid-unit-15, 2); // 6px
|
|
3
|
+
|
|
1
4
|
.wp-block-search__button {
|
|
2
|
-
margin-left:
|
|
5
|
+
margin-left: $button-spacing-x;
|
|
3
6
|
word-break: normal;
|
|
4
7
|
|
|
5
8
|
&.has-icon {
|
|
@@ -7,8 +10,8 @@
|
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
svg {
|
|
10
|
-
min-width:
|
|
11
|
-
min-height:
|
|
13
|
+
min-width: $grid-unit-30;
|
|
14
|
+
min-height: $grid-unit-30;
|
|
12
15
|
fill: currentColor;
|
|
13
16
|
vertical-align: text-bottom;
|
|
14
17
|
}
|
|
@@ -17,8 +20,8 @@
|
|
|
17
20
|
// These rules are set to zero specificity to keep the default styles for search buttons.
|
|
18
21
|
// They are needed for backwards compatibility.
|
|
19
22
|
:where(.wp-block-search__button) {
|
|
20
|
-
border: 1px solid
|
|
21
|
-
padding:
|
|
23
|
+
border: 1px solid $gray-400;
|
|
24
|
+
padding: $button-spacing-y $button-spacing-x;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
.wp-block-search__inside-wrapper {
|
|
@@ -33,12 +36,12 @@
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
.wp-block-search__input {
|
|
36
|
-
padding:
|
|
39
|
+
padding: $grid-unit-10;
|
|
37
40
|
flex-grow: 1;
|
|
38
41
|
margin-left: 0;
|
|
39
42
|
margin-right: 0;
|
|
40
|
-
min-width:
|
|
41
|
-
border: 1px solid
|
|
43
|
+
min-width: 3rem;
|
|
44
|
+
border: 1px solid $gray-600;
|
|
42
45
|
// !important used to forcibly prevent undesired application of
|
|
43
46
|
// text-decoration styles on the input field.
|
|
44
47
|
text-decoration: unset !important;
|
|
@@ -52,13 +55,14 @@
|
|
|
52
55
|
|
|
53
56
|
// We are lowering the specificity so that the button element can override the rule for the button inside the search block.
|
|
54
57
|
:where(.wp-block-search__button-inside .wp-block-search__inside-wrapper) {
|
|
55
|
-
padding:
|
|
56
|
-
border: 1px solid
|
|
58
|
+
padding: $grid-unit-05;
|
|
59
|
+
border: 1px solid $gray-600;
|
|
60
|
+
box-sizing: border-box;
|
|
57
61
|
|
|
58
62
|
.wp-block-search__input {
|
|
59
63
|
border-radius: 0;
|
|
60
64
|
border: none;
|
|
61
|
-
padding: 0
|
|
65
|
+
padding: 0 $grid-unit-05;
|
|
62
66
|
|
|
63
67
|
&:focus {
|
|
64
68
|
outline: none;
|
|
@@ -67,7 +71,7 @@
|
|
|
67
71
|
|
|
68
72
|
// For lower specificity.
|
|
69
73
|
:where(.wp-block-search__button) {
|
|
70
|
-
padding:
|
|
74
|
+
padding: $grid-unit-05 $grid-unit-10;
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
[data-type="core/shortcode"] {
|
|
2
|
-
.block-editor-plain-text {
|
|
3
|
-
max-height: 250px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
2
|
&.components-placeholder {
|
|
7
3
|
min-height: 0;
|
|
8
4
|
}
|
|
9
5
|
}
|
|
10
6
|
|
|
7
|
+
// The editing view for the Shortcode block is equivalent to block UI.
|
|
8
|
+
// Therefore we increase specificity to avoid theme styles bleeding in.
|
|
11
9
|
.blocks-shortcode__textarea {
|
|
12
|
-
|
|
10
|
+
font-family: $editor-html-font !important;
|
|
11
|
+
color: $gray-900 !important;
|
|
12
|
+
background: $white !important;
|
|
13
|
+
padding: $grid-unit-15 !important;
|
|
14
|
+
border: $border-width solid $gray-900 !important;
|
|
15
|
+
box-shadow: none !important;
|
|
16
|
+
border-radius: $radius-block-ui !important;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
max-height: 250px;
|
|
19
|
+
resize: none;
|
|
20
|
+
|
|
21
|
+
/* Fonts smaller than 16px causes mobile safari to zoom. */
|
|
22
|
+
font-size: $mobile-text-min-font-size !important;
|
|
23
|
+
@include break-small {
|
|
24
|
+
font-size: $default-font-size !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:focus {
|
|
28
|
+
border-color: var(--wp-admin-theme-color) !important;
|
|
29
|
+
box-shadow: 0 0 0 ($border-width-focus - $border-width) var(--wp-admin-theme-color) !important;
|
|
30
|
+
|
|
31
|
+
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
32
|
+
outline: 2px solid transparent !important;
|
|
33
|
+
}
|
|
13
34
|
}
|
package/src/spacer/controls.js
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { InspectorControls, useSetting } from '@wordpress/block-editor';
|
|
6
5
|
import {
|
|
6
|
+
InspectorControls,
|
|
7
|
+
useSetting,
|
|
8
|
+
__experimentalSpacingSizesControl as SpacingSizesControl,
|
|
9
|
+
isValueSpacingPreset,
|
|
10
|
+
} from '@wordpress/block-editor';
|
|
11
|
+
import {
|
|
12
|
+
BaseControl,
|
|
7
13
|
PanelBody,
|
|
8
14
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
9
15
|
__experimentalUnitControl as UnitControl,
|
|
10
16
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
11
17
|
} from '@wordpress/components';
|
|
12
18
|
import { useInstanceId } from '@wordpress/compose';
|
|
19
|
+
import { View } from '@wordpress/primitives';
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
* Internal dependencies
|
|
@@ -18,7 +25,7 @@ import { MIN_SPACER_SIZE } from './constants';
|
|
|
18
25
|
|
|
19
26
|
function DimensionInput( { label, onChange, isResizing, value = '' } ) {
|
|
20
27
|
const inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );
|
|
21
|
-
|
|
28
|
+
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
22
29
|
// In most contexts the spacer size cannot meaningfully be set to a
|
|
23
30
|
// percentage, since this is relative to the parent container. This
|
|
24
31
|
// unit is disabled from the UI.
|
|
@@ -38,28 +45,46 @@ function DimensionInput( { label, onChange, isResizing, value = '' } ) {
|
|
|
38
45
|
} );
|
|
39
46
|
|
|
40
47
|
const handleOnChange = ( unprocessedValue ) => {
|
|
41
|
-
onChange( unprocessedValue );
|
|
48
|
+
onChange( unprocessedValue.all );
|
|
42
49
|
};
|
|
43
50
|
|
|
44
51
|
// Force the unit to update to `px` when the Spacer is being resized.
|
|
45
52
|
const [ parsedQuantity, parsedUnit ] =
|
|
46
53
|
parseQuantityAndUnitFromRawValue( value );
|
|
47
|
-
const computedValue =
|
|
48
|
-
|
|
49
|
-
isResizing ? 'px' : parsedUnit
|
|
50
|
-
].join( '' );
|
|
54
|
+
const computedValue = isValueSpacingPreset( value )
|
|
55
|
+
? value
|
|
56
|
+
: [ parsedQuantity, isResizing ? 'px' : parsedUnit ].join( '' );
|
|
51
57
|
|
|
52
58
|
return (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
<>
|
|
60
|
+
{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (
|
|
61
|
+
<BaseControl label={ label } id={ inputId }>
|
|
62
|
+
<UnitControl
|
|
63
|
+
id={ inputId }
|
|
64
|
+
isResetValueOnUnitChange
|
|
65
|
+
min={ MIN_SPACER_SIZE }
|
|
66
|
+
onChange={ handleOnChange }
|
|
67
|
+
style={ { maxWidth: 80 } }
|
|
68
|
+
value={ computedValue }
|
|
69
|
+
units={ units }
|
|
70
|
+
/>
|
|
71
|
+
</BaseControl>
|
|
72
|
+
) }
|
|
73
|
+
|
|
74
|
+
{ spacingSizes?.length > 0 && (
|
|
75
|
+
<View className="tools-panel-item-spacing">
|
|
76
|
+
<SpacingSizesControl
|
|
77
|
+
values={ { all: computedValue } }
|
|
78
|
+
onChange={ handleOnChange }
|
|
79
|
+
label={ label }
|
|
80
|
+
sides={ [ 'all' ] }
|
|
81
|
+
units={ units }
|
|
82
|
+
allowReset={ false }
|
|
83
|
+
splitOnAxis={ false }
|
|
84
|
+
/>
|
|
85
|
+
</View>
|
|
86
|
+
) }
|
|
87
|
+
</>
|
|
63
88
|
);
|
|
64
89
|
}
|
|
65
90
|
|
package/src/spacer/edit.js
CHANGED
|
@@ -6,10 +6,15 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useBlockProps,
|
|
11
|
+
getSpacingPresetCssVar,
|
|
12
|
+
store as blockEditorStore,
|
|
13
|
+
} from '@wordpress/block-editor';
|
|
10
14
|
import { ResizableBox } from '@wordpress/components';
|
|
11
15
|
import { useState, useEffect } from '@wordpress/element';
|
|
12
16
|
import { View } from '@wordpress/primitives';
|
|
17
|
+
import { useSelect } from '@wordpress/data';
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* Internal dependencies
|
|
@@ -78,8 +83,21 @@ const SpacerEdit = ( {
|
|
|
78
83
|
setAttributes,
|
|
79
84
|
toggleSelection,
|
|
80
85
|
context,
|
|
86
|
+
__unstableParentLayout: parentLayout,
|
|
87
|
+
className,
|
|
81
88
|
} ) => {
|
|
89
|
+
const disableCustomSpacingSizes = useSelect( ( select ) => {
|
|
90
|
+
const editorSettings = select( blockEditorStore ).getSettings();
|
|
91
|
+
return editorSettings?.disableCustomSpacingSizes;
|
|
92
|
+
} );
|
|
82
93
|
const { orientation } = context;
|
|
94
|
+
const { orientation: parentOrientation, type } = parentLayout || {};
|
|
95
|
+
// If the spacer is inside a flex container, it should either inherit the orientation
|
|
96
|
+
// of the parent or use the flex default orientation.
|
|
97
|
+
const inheritedOrientation =
|
|
98
|
+
! parentOrientation && type === 'flex'
|
|
99
|
+
? 'horizontal'
|
|
100
|
+
: parentOrientation || orientation;
|
|
83
101
|
const { height, width } = attributes;
|
|
84
102
|
|
|
85
103
|
const [ isResizing, setIsResizing ] = useState( false );
|
|
@@ -104,12 +122,19 @@ const SpacerEdit = ( {
|
|
|
104
122
|
|
|
105
123
|
const style = {
|
|
106
124
|
height:
|
|
107
|
-
|
|
125
|
+
inheritedOrientation === 'horizontal'
|
|
108
126
|
? 24
|
|
109
|
-
: temporaryHeight ||
|
|
127
|
+
: temporaryHeight ||
|
|
128
|
+
getSpacingPresetCssVar( height ) ||
|
|
129
|
+
undefined,
|
|
110
130
|
width:
|
|
111
|
-
|
|
112
|
-
? temporaryWidth || width || undefined
|
|
131
|
+
inheritedOrientation === 'horizontal'
|
|
132
|
+
? temporaryWidth || getSpacingPresetCssVar( width ) || undefined
|
|
133
|
+
: undefined,
|
|
134
|
+
// In vertical flex containers, the spacer shrinks to nothing without a minimum width.
|
|
135
|
+
minWidth:
|
|
136
|
+
inheritedOrientation === 'vertical' && type === 'flex'
|
|
137
|
+
? 48
|
|
113
138
|
: undefined,
|
|
114
139
|
};
|
|
115
140
|
|
|
@@ -166,7 +191,7 @@ const SpacerEdit = ( {
|
|
|
166
191
|
};
|
|
167
192
|
|
|
168
193
|
useEffect( () => {
|
|
169
|
-
if (
|
|
194
|
+
if ( inheritedOrientation === 'horizontal' && ! width ) {
|
|
170
195
|
setAttributes( {
|
|
171
196
|
height: '0px',
|
|
172
197
|
width: '72px',
|
|
@@ -176,14 +201,21 @@ const SpacerEdit = ( {
|
|
|
176
201
|
|
|
177
202
|
return (
|
|
178
203
|
<>
|
|
179
|
-
<View
|
|
180
|
-
{
|
|
204
|
+
<View
|
|
205
|
+
{ ...useBlockProps( {
|
|
206
|
+
style,
|
|
207
|
+
className: classnames( className, {
|
|
208
|
+
'custom-sizes-disabled': disableCustomSpacingSizes,
|
|
209
|
+
} ),
|
|
210
|
+
} ) }
|
|
211
|
+
>
|
|
212
|
+
{ resizableBoxWithOrientation( inheritedOrientation ) }
|
|
181
213
|
</View>
|
|
182
214
|
<SpacerControls
|
|
183
215
|
setAttributes={ setAttributes }
|
|
184
216
|
height={ temporaryHeight || height }
|
|
185
217
|
width={ temporaryWidth || width }
|
|
186
|
-
orientation={
|
|
218
|
+
orientation={ inheritedOrientation }
|
|
187
219
|
isResizing={ isResizing }
|
|
188
220
|
/>
|
|
189
221
|
</>
|
package/src/spacer/editor.scss
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.wp-block-spacer.is-hovered .block-library-spacer__resize-container,
|
|
20
|
-
.block-library-spacer__resize-container.has-show-handle
|
|
20
|
+
.block-library-spacer__resize-container.has-show-handle,
|
|
21
|
+
.wp-block-spacer.is-selected.custom-sizes-disabled {
|
|
21
22
|
background: rgba($black, 0.1);
|
|
22
23
|
|
|
23
24
|
.is-dark-theme & {
|
package/src/spacer/save.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
4
|
+
import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';
|
|
5
5
|
|
|
6
6
|
export default function save( { attributes: { height, width } } ) {
|
|
7
7
|
return (
|
|
8
8
|
<div
|
|
9
9
|
{ ...useBlockProps.save( {
|
|
10
10
|
style: {
|
|
11
|
-
height,
|
|
12
|
-
width,
|
|
11
|
+
height: getSpacingPresetCssVar( height ),
|
|
12
|
+
width: getSpacingPresetCssVar( width ),
|
|
13
13
|
},
|
|
14
14
|
'aria-hidden': true,
|
|
15
15
|
} ) }
|
package/src/style.scss
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
@import "./comments-pagination/style.scss";
|
|
12
12
|
@import "./comment-template/style.scss";
|
|
13
13
|
@import "./cover/style.scss";
|
|
14
|
+
@import "./details/style.scss";
|
|
15
|
+
@import "./details-summary/style.scss";
|
|
14
16
|
@import "./embed/style.scss";
|
|
15
17
|
@import "./file/style.scss";
|
|
16
18
|
@import "./gallery/style.scss";
|
|
@@ -32,6 +34,7 @@
|
|
|
32
34
|
@import "./post-featured-image/style.scss";
|
|
33
35
|
@import "./post-navigation-link/style.scss";
|
|
34
36
|
@import "./post-terms/style.scss";
|
|
37
|
+
@import "./post-time-to-read/style.scss";
|
|
35
38
|
@import "./post-title/style.scss";
|
|
36
39
|
@import "./preformatted/style.scss";
|
|
37
40
|
@import "./pullquote/style.scss";
|
package/src/table/state.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { mapValues } from 'lodash';
|
|
5
|
-
|
|
6
1
|
const INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];
|
|
7
2
|
|
|
8
3
|
/**
|
|
@@ -82,33 +77,45 @@ export function updateSelectedCell( state, selection, updateCell ) {
|
|
|
82
77
|
const { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =
|
|
83
78
|
selection;
|
|
84
79
|
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return row;
|
|
80
|
+
return Object.fromEntries(
|
|
81
|
+
Object.entries( tableSections ).map( ( [ sectionName, section ] ) => {
|
|
82
|
+
if (
|
|
83
|
+
selectionSectionName &&
|
|
84
|
+
selectionSectionName !== sectionName
|
|
85
|
+
) {
|
|
86
|
+
return [ sectionName, section ];
|
|
93
87
|
}
|
|
94
88
|
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
rowIndex,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
if ( ! isCellSelected( cellLocation, selection ) ) {
|
|
104
|
-
return cellAttributes;
|
|
89
|
+
return [
|
|
90
|
+
sectionName,
|
|
91
|
+
section.map( ( row, rowIndex ) => {
|
|
92
|
+
if ( selectionRowIndex && selectionRowIndex !== rowIndex ) {
|
|
93
|
+
return row;
|
|
105
94
|
}
|
|
106
95
|
|
|
107
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
cells: row.cells.map(
|
|
98
|
+
( cellAttributes, columnIndex ) => {
|
|
99
|
+
const cellLocation = {
|
|
100
|
+
sectionName,
|
|
101
|
+
columnIndex,
|
|
102
|
+
rowIndex,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
! isCellSelected( cellLocation, selection )
|
|
107
|
+
) {
|
|
108
|
+
return cellAttributes;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return updateCell( cellAttributes );
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
};
|
|
108
115
|
} ),
|
|
109
|
-
|
|
110
|
-
} )
|
|
111
|
-
|
|
116
|
+
];
|
|
117
|
+
} )
|
|
118
|
+
);
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
/**
|
|
@@ -224,31 +231,36 @@ export function insertColumn( state, { columnIndex } ) {
|
|
|
224
231
|
)
|
|
225
232
|
);
|
|
226
233
|
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return section.map( ( row ) => {
|
|
234
|
-
// Bail early if the row is empty or it's an attempt to insert past
|
|
235
|
-
// the last possible index of the array.
|
|
236
|
-
if ( isEmptyRow( row ) || row.cells.length < columnIndex ) {
|
|
237
|
-
return row;
|
|
234
|
+
return Object.fromEntries(
|
|
235
|
+
Object.entries( tableSections ).map( ( [ sectionName, section ] ) => {
|
|
236
|
+
// Bail early if the table section is empty.
|
|
237
|
+
if ( isEmptyTableSection( section ) ) {
|
|
238
|
+
return [ sectionName, section ];
|
|
238
239
|
}
|
|
239
240
|
|
|
240
|
-
return
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
241
|
+
return [
|
|
242
|
+
sectionName,
|
|
243
|
+
section.map( ( row ) => {
|
|
244
|
+
// Bail early if the row is empty or it's an attempt to insert past
|
|
245
|
+
// the last possible index of the array.
|
|
246
|
+
if ( isEmptyRow( row ) || row.cells.length < columnIndex ) {
|
|
247
|
+
return row;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
cells: [
|
|
252
|
+
...row.cells.slice( 0, columnIndex ),
|
|
253
|
+
{
|
|
254
|
+
content: '',
|
|
255
|
+
tag: sectionName === 'head' ? 'th' : 'td',
|
|
256
|
+
},
|
|
257
|
+
...row.cells.slice( columnIndex ),
|
|
258
|
+
],
|
|
259
|
+
};
|
|
260
|
+
} ),
|
|
261
|
+
];
|
|
262
|
+
} )
|
|
263
|
+
);
|
|
252
264
|
}
|
|
253
265
|
|
|
254
266
|
/**
|
|
@@ -267,23 +279,28 @@ export function deleteColumn( state, { columnIndex } ) {
|
|
|
267
279
|
)
|
|
268
280
|
);
|
|
269
281
|
|
|
270
|
-
return
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
282
|
+
return Object.fromEntries(
|
|
283
|
+
Object.entries( tableSections ).map( ( [ sectionName, section ] ) => {
|
|
284
|
+
// Bail early if the table section is empty.
|
|
285
|
+
if ( isEmptyTableSection( section ) ) {
|
|
286
|
+
return [ sectionName, section ];
|
|
287
|
+
}
|
|
275
288
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
return [
|
|
290
|
+
sectionName,
|
|
291
|
+
section
|
|
292
|
+
.map( ( row ) => ( {
|
|
293
|
+
cells:
|
|
294
|
+
row.cells.length >= columnIndex
|
|
295
|
+
? row.cells.filter(
|
|
296
|
+
( cell, index ) => index !== columnIndex
|
|
297
|
+
)
|
|
298
|
+
: row.cells,
|
|
299
|
+
} ) )
|
|
300
|
+
.filter( ( row ) => row.cells.length ),
|
|
301
|
+
];
|
|
302
|
+
} )
|
|
303
|
+
);
|
|
287
304
|
}
|
|
288
305
|
|
|
289
306
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { isEmpty
|
|
4
|
+
import { isEmpty } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Removed empty nodes from nested objects.
|
|
@@ -18,9 +18,9 @@ const cleanEmptyObject = ( object ) => {
|
|
|
18
18
|
return object;
|
|
19
19
|
}
|
|
20
20
|
const cleanedNestedObjects = Object.fromEntries(
|
|
21
|
-
Object.entries(
|
|
22
|
-
( [ , value ] ) =>
|
|
23
|
-
|
|
21
|
+
Object.entries( object )
|
|
22
|
+
.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )
|
|
23
|
+
.filter( ( [ , value ] ) => Boolean( value ) )
|
|
24
24
|
);
|
|
25
25
|
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
|
|
26
26
|
};
|