@wordpress/block-editor 15.20.0 → 15.21.1
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 +18 -0
- package/build/components/block-compare/index.cjs +2 -2
- package/build/components/block-compare/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +1 -1
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-patterns-list/index.cjs +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
- package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +4 -4
- package/build/components/block-switcher/index.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +10 -5
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +23 -15
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +2 -2
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +2 -0
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +5 -4
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/iframe/index.cjs +3 -0
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +179 -220
- package/build/components/inserter/index.cjs.map +3 -3
- package/build/components/inserter/media-tab/utils.cjs +1 -1
- package/build/components/inserter/media-tab/utils.cjs.map +2 -2
- package/build/components/inserter/search-results.cjs +1 -1
- package/build/components/inserter/search-results.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +10 -12
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +11 -2
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +4 -4
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +4 -4
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +7 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +1 -23
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +5 -5
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/anchor.cjs +11 -15
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/border.cjs +0 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +1 -4
- package/build/hooks/color.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +0 -3
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/fit-text.cjs +11 -0
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/position.cjs +19 -22
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/supports.cjs +0 -7
- package/build/hooks/supports.cjs.map +2 -2
- package/build/store/actions.cjs +7 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +1 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +29 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +14 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +60 -41
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-compare/index.mjs +1 -1
- package/build-module/components/block-compare/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +1 -1
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
- package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +4 -4
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +10 -5
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +23 -15
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +3 -3
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -0
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +9 -6
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs +3 -0
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +185 -222
- package/build-module/components/inserter/index.mjs.map +3 -3
- package/build-module/components/inserter/media-tab/utils.mjs +1 -1
- package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
- package/build-module/components/inserter/search-results.mjs +1 -1
- package/build-module/components/inserter/search-results.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +10 -12
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +11 -2
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -23
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +5 -5
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +11 -15
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/border.mjs +1 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -5
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +1 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs +11 -0
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/position.mjs +20 -23
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/supports.mjs +0 -7
- package/build-module/hooks/supports.mjs.map +2 -2
- package/build-module/store/actions.mjs +7 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +1 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +26 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +14 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +62 -42
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +12 -0
- package/build-style/content.css +12 -0
- package/build-style/style-rtl.css +26 -8
- package/build-style/style.css +26 -8
- package/package.json +51 -48
- package/src/components/block-breadcrumb/README.md +2 -2
- package/src/components/block-compare/README.md +6 -6
- package/src/components/block-compare/index.js +1 -3
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-switcher/block-transformations-menu.js +16 -18
- package/src/components/block-switcher/index.js +4 -4
- package/src/components/block-types-list/README.md +0 -19
- package/src/components/child-layout-control/index.js +15 -8
- package/src/components/child-layout-control/test/index.js +126 -0
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/global-styles/advanced-panel.js +5 -1
- package/src/components/global-styles/background-panel.js +3 -3
- package/src/components/global-styles/border-panel.js +2 -0
- package/src/components/global-styles/dimensions-panel.js +23 -16
- package/src/components/iframe/index.js +3 -0
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
- package/src/components/inserter/hooks/use-patterns-state.js +1 -1
- package/src/components/inserter/index.js +257 -288
- package/src/components/inserter/media-tab/utils.js +1 -1
- package/src/components/inserter/search-results.js +1 -3
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/list-view/block-select-button.js +9 -13
- package/src/components/list-view/block.js +1 -0
- package/src/components/media-placeholder/README.md +1 -29
- package/src/components/media-upload/README.md +0 -19
- package/src/components/provider/test/use-block-sync.js +40 -0
- package/src/components/provider/use-block-sync.js +12 -2
- package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
- package/src/components/rich-text/event-listeners/delete.js +9 -4
- package/src/components/rich-text/event-listeners/enter.js +9 -2
- package/src/components/rich-text/event-listeners/input-events.js +13 -4
- package/src/components/rich-text/event-listeners/input-rules.js +20 -4
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
- package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
- package/src/components/rich-text/index.js +1 -33
- package/src/components/unit-control/README.md +1 -1
- package/src/components/url-popover/README.md +1 -1
- package/src/components/use-block-commands/index.js +5 -5
- package/src/hooks/anchor.js +9 -17
- package/src/hooks/border.js +1 -5
- package/src/hooks/color.js +1 -6
- package/src/hooks/dimensions.js +1 -5
- package/src/hooks/fit-text.js +16 -0
- package/src/hooks/position.js +23 -27
- package/src/hooks/supports.js +0 -9
- package/src/store/actions.js +13 -3
- package/src/store/private-actions.js +1 -4
- package/src/store/private-selectors.js +59 -0
- package/src/store/reducer.js +19 -7
- package/src/store/selectors.js +91 -53
- package/src/store/test/actions.js +21 -0
- package/src/store/test/private-selectors.js +53 -0
- package/src/store/test/reducer.js +46 -0
- package/src/store/test/selectors.js +77 -0
- package/build/components/media-upload-progress/constants.cjs +0 -46
- package/build/components/media-upload-progress/constants.cjs.map +0 -7
- package/build/components/rich-text/native/format-edit.cjs +0 -60
- package/build/components/rich-text/native/format-edit.cjs.map +0 -7
- package/build/components/rich-text/native/index.cjs +0 -28
- package/build/components/rich-text/native/index.cjs.map +0 -7
- package/build/components/rich-text/native/use-format-types.cjs +0 -139
- package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
- package/build-module/components/media-upload-progress/constants.mjs +0 -16
- package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
- package/build-module/components/rich-text/native/format-edit.mjs +0 -39
- package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
- package/build-module/components/rich-text/native/index.mjs +0 -7
- package/build-module/components/rich-text/native/index.mjs.map +0 -7
- package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
- package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
- package/src/components/audio-player/audio-url-parser.native.js +0 -20
- package/src/components/audio-player/index.native.js +0 -225
- package/src/components/audio-player/styles.native.scss +0 -114
- package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
- package/src/components/block-alignment-control/test/index.native.js +0 -37
- package/src/components/block-alignment-control/ui.native.js +0 -86
- package/src/components/block-caption/README.md +0 -104
- package/src/components/block-caption/index.native.js +0 -89
- package/src/components/block-caption/styles.native.scss +0 -7
- package/src/components/block-controls/slot.native.js +0 -33
- package/src/components/block-draggable/draggable-chip.native.js +0 -49
- package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
- package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
- package/src/components/block-draggable/index.native.js +0 -467
- package/src/components/block-draggable/style.native.scss +0 -19
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
- package/src/components/block-draggable/test/helpers.native.js +0 -182
- package/src/components/block-draggable/test/index.native.js +0 -419
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
- package/src/components/block-edit/edit.native.js +0 -49
- package/src/components/block-edit/test/edit.native.js +0 -65
- package/src/components/block-heading-level-dropdown/index.native.js +0 -68
- package/src/components/block-icon/index.native.js +0 -47
- package/src/components/block-icon/style.native.scss +0 -7
- package/src/components/block-list/block-crash-boundary.native.js +0 -43
- package/src/components/block-list/block-crash-warning.native.js +0 -21
- package/src/components/block-list/block-invalid-warning.native.js +0 -70
- package/src/components/block-list/block-list-context.native.js +0 -172
- package/src/components/block-list/block-list-item-cell.native.js +0 -62
- package/src/components/block-list/block-list-item.native.js +0 -209
- package/src/components/block-list/block-list-item.native.scss +0 -16
- package/src/components/block-list/block-outline.native.js +0 -77
- package/src/components/block-list/block-selection-button.native.js +0 -100
- package/src/components/block-list/block-selection-button.native.scss +0 -34
- package/src/components/block-list/block.native.js +0 -716
- package/src/components/block-list/block.native.scss +0 -62
- package/src/components/block-list/grid-item.native.js +0 -58
- package/src/components/block-list/index.native.js +0 -437
- package/src/components/block-list/insertion-point.native.js +0 -36
- package/src/components/block-list/style.native.scss +0 -117
- package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
- package/src/components/block-list/test/block-list-context.native.js +0 -243
- package/src/components/block-list/test/block-outline.native.js +0 -255
- package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
- package/src/components/block-list/test/index.native.js +0 -205
- package/src/components/block-list/use-block-props/index.native.js +0 -10
- package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
- package/src/components/block-list-appender/index.native.js +0 -70
- package/src/components/block-list-appender/style.native.scss +0 -8
- package/src/components/block-media-update-progress/README.md +0 -100
- package/src/components/block-media-update-progress/index.native.js +0 -299
- package/src/components/block-media-update-progress/styles.native.scss +0 -9
- package/src/components/block-media-update-progress/test/index.native.js +0 -543
- package/src/components/block-mover/index.native.js +0 -193
- package/src/components/block-mover/mover-description.native.js +0 -155
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
- package/src/components/block-mover/test/index.native.js +0 -186
- package/src/components/block-settings/button.native.js +0 -41
- package/src/components/block-settings/container.native.js +0 -91
- package/src/components/block-settings/container.native.scss +0 -4
- package/src/components/block-settings/index.native.js +0 -5
- package/src/components/block-styles/index.native.js +0 -94
- package/src/components/block-styles/preview.native.js +0 -109
- package/src/components/block-styles/style.native.scss +0 -64
- package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
- package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
- package/src/components/block-toolbar/index.native.js +0 -126
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
- package/src/components/block-toolbar/test/index.native.js +0 -36
- package/src/components/block-types-list/index.native.js +0 -175
- package/src/components/block-types-list/style.native.scss +0 -25
- package/src/components/block-variation-picker/index.native.js +0 -107
- package/src/components/block-variation-picker/style.native.scss +0 -32
- package/src/components/button-block-appender/index.native.js +0 -92
- package/src/components/button-block-appender/styles.native.scss +0 -43
- package/src/components/caption/README.md +0 -44
- package/src/components/caption/index.native.js +0 -61
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
- package/src/components/contrast-checker/index.native.js +0 -113
- package/src/components/contrast-checker/style.native.scss +0 -26
- package/src/components/convert-to-group-buttons/index.native.js +0 -79
- package/src/components/default-block-appender/index.native.js +0 -113
- package/src/components/default-block-appender/style.native.scss +0 -18
- package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
- package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
- package/src/components/floating-toolbar/index.native.js +0 -141
- package/src/components/floating-toolbar/styles.native.scss +0 -43
- package/src/components/font-sizes/index.native.js +0 -7
- package/src/components/global-styles/color-panel.native.js +0 -207
- package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
- package/src/components/global-styles/use-global-styles-context.native.js +0 -592
- package/src/components/gradients/index.native.js +0 -2
- package/src/components/image-link-destinations/index.native.js +0 -152
- package/src/components/image-link-destinations/style.native.scss +0 -16
- package/src/components/index.native.js +0 -108
- package/src/components/inner-blocks/constants.native.js +0 -5
- package/src/components/inner-blocks/index.native.js +0 -221
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
- package/src/components/inserter/block-types-tab.native.js +0 -76
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
- package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
- package/src/components/inserter/index.native.js +0 -424
- package/src/components/inserter/menu.native.js +0 -237
- package/src/components/inserter/no-results.native.js +0 -49
- package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
- package/src/components/inserter/search-results.native.js +0 -67
- package/src/components/inserter/style.native.scss +0 -83
- package/src/components/inserter/tabs.native.js +0 -152
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
- package/src/components/inserter/test/fixtures/index.native.js +0 -12
- package/src/components/inserter/test/index.native.js +0 -273
- package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
- package/src/components/inserter/test/utils.native.js +0 -37
- package/src/components/inserter/utils.native.js +0 -46
- package/src/components/inserter-button/index.native.js +0 -108
- package/src/components/inserter-button/style.native.scss +0 -72
- package/src/components/inspector-controls/fill.native.js +0 -62
- package/src/components/inspector-controls/slot.native.js +0 -35
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
- package/src/components/line-height-control/index.native.js +0 -28
- package/src/components/media-placeholder/index.native.js +0 -258
- package/src/components/media-placeholder/styles.native.scss +0 -108
- package/src/components/media-replace-flow/index.native.js +0 -12
- package/src/components/media-upload/constants.native.js +0 -14
- package/src/components/media-upload/index.native.js +0 -356
- package/src/components/media-upload/style.native.scss +0 -4
- package/src/components/media-upload/test/index.native.js +0 -172
- package/src/components/media-upload-progress/README.md +0 -100
- package/src/components/media-upload-progress/constants.js +0 -6
- package/src/components/media-upload-progress/index.native.js +0 -233
- package/src/components/media-upload-progress/styles.native.scss +0 -15
- package/src/components/media-upload-progress/test/index.native.js +0 -220
- package/src/components/plain-text/index.native.js +0 -164
- package/src/components/plain-text/style.native.scss +0 -10
- package/src/components/provider/index.native.js +0 -32
- package/src/components/rich-text/embed-handler-picker.native.js +0 -65
- package/src/components/rich-text/file-paste-handler.native.js +0 -3
- package/src/components/rich-text/format-toolbar/index.native.js +0 -21
- package/src/components/rich-text/format-toolbar-container.native.js +0 -16
- package/src/components/rich-text/index.native.js +0 -701
- package/src/components/rich-text/input-event.native.js +0 -10
- package/src/components/rich-text/native/format-edit.js +0 -44
- package/src/components/rich-text/native/get-format-colors.native.js +0 -47
- package/src/components/rich-text/native/index.js +0 -1
- package/src/components/rich-text/native/index.native.js +0 -1389
- package/src/components/rich-text/native/style.native.scss +0 -28
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
- package/src/components/rich-text/native/test/index.native.js +0 -345
- package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
- package/src/components/rich-text/native/use-format-types.js +0 -146
- package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
- package/src/components/rich-text/shortcut.native.js +0 -10
- package/src/components/ungroup-button/README.md +0 -23
- package/src/components/ungroup-button/index.native.js +0 -77
- package/src/components/unsupported-block-details/index.native.js +0 -187
- package/src/components/unsupported-block-details/style.native.scss +0 -56
- package/src/components/url-input/index.native.js +0 -33
- package/src/components/use-block-drop-zone/index.native.js +0 -207
- package/src/components/use-on-block-drop/index.native.js +0 -115
- package/src/components/use-unsupported-block-editor/index.native.js +0 -59
- package/src/components/video-player/gridicon-play.native.js +0 -13
- package/src/components/video-player/index.native.js +0 -133
- package/src/components/video-player/styles.native.scss +0 -29
- package/src/components/warning/index.native.js +0 -64
- package/src/components/warning/style.native.scss +0 -47
- package/src/hooks/align.native.js +0 -49
- package/src/hooks/custom-class-name.native.js +0 -70
- package/src/hooks/index.native.js +0 -36
- package/src/hooks/layout.native.js +0 -23
- package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
- package/src/hooks/test/align.native.js +0 -134
- package/src/hooks/test/anchor.native.js +0 -32
- package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
- package/src/hooks/typography.native.js +0 -60
- package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
- package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
- package/src/index.native.js +0 -6
- package/src/private-apis.native.js +0 -21
- package/src/store/defaults.native.js +0 -23
|
@@ -1,592 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { camelCase } from 'change-case';
|
|
5
|
-
import { Dimensions } from 'react-native';
|
|
6
|
-
import { colord } from 'colord';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* WordPress dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
12
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
13
|
-
import { getPxFromCssUnit } from '@wordpress/components';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import useMultipleOriginColorsAndGradients from '../colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
19
|
-
import { useSettings } from '../use-settings';
|
|
20
|
-
import { SETTINGS_DEFAULTS } from '../../store/defaults';
|
|
21
|
-
|
|
22
|
-
const BLOCK_STYLE_ATTRIBUTES = [
|
|
23
|
-
'textColor',
|
|
24
|
-
'backgroundColor',
|
|
25
|
-
'style',
|
|
26
|
-
'color',
|
|
27
|
-
'fontSize',
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
export const GlobalStylesContext = createContext( { style: {} } );
|
|
31
|
-
GlobalStylesContext.BLOCK_STYLE_ATTRIBUTES = BLOCK_STYLE_ATTRIBUTES;
|
|
32
|
-
|
|
33
|
-
// Mapping style properties name to native.
|
|
34
|
-
const BLOCK_STYLE_ATTRIBUTES_MAPPING = {
|
|
35
|
-
textColor: 'color',
|
|
36
|
-
text: 'color',
|
|
37
|
-
background: 'backgroundColor',
|
|
38
|
-
link: 'linkColor',
|
|
39
|
-
placeholder: 'placeholderColor',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const PADDING = 12; // $solid-border-space
|
|
43
|
-
const UNKNOWN_VALUE = 'undefined';
|
|
44
|
-
const DEFAULT_FONT_SIZE = 16;
|
|
45
|
-
|
|
46
|
-
export function getBlockPaddings(
|
|
47
|
-
mergedStyle,
|
|
48
|
-
wrapperPropsStyle,
|
|
49
|
-
blockStyleAttributes,
|
|
50
|
-
blockColors
|
|
51
|
-
) {
|
|
52
|
-
const blockPaddings = {};
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
! mergedStyle.padding &&
|
|
56
|
-
( wrapperPropsStyle?.backgroundColor ||
|
|
57
|
-
blockStyleAttributes?.backgroundColor ||
|
|
58
|
-
blockColors?.backgroundColor )
|
|
59
|
-
) {
|
|
60
|
-
blockPaddings.padding = PADDING;
|
|
61
|
-
return blockPaddings;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Prevent adding extra paddings to inner blocks without background colors.
|
|
65
|
-
if (
|
|
66
|
-
mergedStyle?.padding &&
|
|
67
|
-
! wrapperPropsStyle?.backgroundColor &&
|
|
68
|
-
! blockStyleAttributes?.backgroundColor &&
|
|
69
|
-
! blockColors?.backgroundColor
|
|
70
|
-
) {
|
|
71
|
-
blockPaddings.padding = undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return blockPaddings;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function getBlockColors(
|
|
78
|
-
blockStyleAttributes,
|
|
79
|
-
defaultColors,
|
|
80
|
-
blockName,
|
|
81
|
-
baseGlobalStyles
|
|
82
|
-
) {
|
|
83
|
-
const blockStyles = {};
|
|
84
|
-
const customBlockStyles = blockStyleAttributes?.style?.color || {};
|
|
85
|
-
const blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];
|
|
86
|
-
|
|
87
|
-
// Global styles colors.
|
|
88
|
-
if ( blockGlobalStyles?.color ) {
|
|
89
|
-
Object.entries( blockGlobalStyles.color ).forEach(
|
|
90
|
-
( [ key, value ] ) => {
|
|
91
|
-
const styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING[ key ];
|
|
92
|
-
|
|
93
|
-
if ( styleKey && value !== UNKNOWN_VALUE ) {
|
|
94
|
-
const color = customBlockStyles[ key ] ?? value;
|
|
95
|
-
blockStyles[ styleKey ] = color;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
} else if ( baseGlobalStyles?.styles?.color?.text ) {
|
|
100
|
-
blockStyles[ BLOCK_STYLE_ATTRIBUTES_MAPPING.text ] =
|
|
101
|
-
baseGlobalStyles?.styles?.color?.text;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Global styles elements.
|
|
105
|
-
if ( blockGlobalStyles?.elements ) {
|
|
106
|
-
const linkColor = blockGlobalStyles.elements?.link?.color?.text;
|
|
107
|
-
const styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING.link;
|
|
108
|
-
|
|
109
|
-
if ( styleKey && linkColor && linkColor !== UNKNOWN_VALUE ) {
|
|
110
|
-
blockStyles[ styleKey ] = linkColor;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Custom colors.
|
|
115
|
-
Object.entries( blockStyleAttributes ).forEach( ( [ key, value ] ) => {
|
|
116
|
-
const isCustomColor = value?.startsWith?.( '#' );
|
|
117
|
-
let styleKey = key;
|
|
118
|
-
|
|
119
|
-
if ( BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ] ) {
|
|
120
|
-
styleKey = BLOCK_STYLE_ATTRIBUTES_MAPPING[ styleKey ];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if ( ! isCustomColor ) {
|
|
124
|
-
const mappedColor = Object.values( defaultColors ?? {} ).find(
|
|
125
|
-
( { slug } ) => slug === value
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
if ( mappedColor ) {
|
|
129
|
-
blockStyles[ styleKey ] = mappedColor.color;
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
blockStyles[ styleKey ] = value;
|
|
133
|
-
}
|
|
134
|
-
} );
|
|
135
|
-
|
|
136
|
-
// Color placeholder.
|
|
137
|
-
if ( blockStyles?.color ) {
|
|
138
|
-
blockStyles[ BLOCK_STYLE_ATTRIBUTES_MAPPING.placeholder ] =
|
|
139
|
-
blockStyles.color;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return blockStyles;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function getBlockTypography(
|
|
146
|
-
blockStyleAttributes,
|
|
147
|
-
fontSizes,
|
|
148
|
-
blockName,
|
|
149
|
-
baseGlobalStyles
|
|
150
|
-
) {
|
|
151
|
-
const typographyStyles = {};
|
|
152
|
-
const customBlockStyles = blockStyleAttributes?.style?.typography || {};
|
|
153
|
-
const blockGlobalStyles = baseGlobalStyles?.blocks?.[ blockName ];
|
|
154
|
-
const parsedFontSizes = Object.values( fontSizes ?? {} );
|
|
155
|
-
|
|
156
|
-
// Global styles.
|
|
157
|
-
if ( blockGlobalStyles?.typography ) {
|
|
158
|
-
const fontSize = blockGlobalStyles?.typography?.fontSize;
|
|
159
|
-
const lineHeight = blockGlobalStyles?.typography?.lineHeight;
|
|
160
|
-
|
|
161
|
-
if ( fontSize ) {
|
|
162
|
-
if ( parseInt( fontSize, 10 ) ) {
|
|
163
|
-
typographyStyles.fontSize = fontSize;
|
|
164
|
-
} else {
|
|
165
|
-
const mappedFontSize = parsedFontSizes.find(
|
|
166
|
-
( { slug } ) => slug === fontSize
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
if ( mappedFontSize ) {
|
|
170
|
-
typographyStyles.fontSize = mappedFontSize?.size;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if ( lineHeight ) {
|
|
176
|
-
typographyStyles.lineHeight = lineHeight;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if ( blockStyleAttributes?.fontSize && baseGlobalStyles ) {
|
|
181
|
-
const mappedFontSize = parsedFontSizes.find(
|
|
182
|
-
( { slug } ) => slug === blockStyleAttributes?.fontSize
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
if ( mappedFontSize ) {
|
|
186
|
-
typographyStyles.fontSize = mappedFontSize?.size;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Custom styles.
|
|
191
|
-
if ( customBlockStyles?.fontSize ) {
|
|
192
|
-
typographyStyles.fontSize = customBlockStyles?.fontSize;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if ( customBlockStyles?.lineHeight ) {
|
|
196
|
-
typographyStyles.lineHeight = customBlockStyles?.lineHeight;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return typographyStyles;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Return a value from a certain path of the object.
|
|
204
|
-
* Path is specified as an array of properties, like: [ 'parent', 'child' ].
|
|
205
|
-
*
|
|
206
|
-
* @param {Object} object Input object.
|
|
207
|
-
* @param {Array} path Path to the object property.
|
|
208
|
-
* @return {*} Value of the object property at the specified path.
|
|
209
|
-
*/
|
|
210
|
-
const getValueFromObjectPath = ( object, path ) => {
|
|
211
|
-
let value = object;
|
|
212
|
-
path.forEach( ( fieldName ) => {
|
|
213
|
-
value = value?.[ fieldName ];
|
|
214
|
-
} );
|
|
215
|
-
return value;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
219
|
-
let stylesBase = styles;
|
|
220
|
-
const variables = [ 'preset', 'custom', 'var', 'fontSize' ];
|
|
221
|
-
|
|
222
|
-
if ( ! stylesBase ) {
|
|
223
|
-
return styles;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
variables.forEach( ( variable ) => {
|
|
227
|
-
// Examples
|
|
228
|
-
// var(--wp--preset--color--gray)
|
|
229
|
-
// var(--wp--custom--body--typography--font-family)
|
|
230
|
-
// var:preset|color|custom-color-2
|
|
231
|
-
const regex = new RegExp( `var\\(--wp--${ variable }--(.*?)\\)`, 'g' );
|
|
232
|
-
const varRegex = /\"var:preset\|color\|(.*?)\"/gm;
|
|
233
|
-
const fontSizeRegex = /"fontSize":"(.*?)"/gm;
|
|
234
|
-
|
|
235
|
-
if ( variable === 'preset' ) {
|
|
236
|
-
stylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {
|
|
237
|
-
const path = $2.split( '--' );
|
|
238
|
-
const mappedPresetValue = mappedValues[ path[ 0 ] ];
|
|
239
|
-
if ( mappedPresetValue && mappedPresetValue.slug ) {
|
|
240
|
-
const matchedValue = Object.values(
|
|
241
|
-
mappedPresetValue.values ?? {}
|
|
242
|
-
).find( ( { slug } ) => slug === path[ 1 ] );
|
|
243
|
-
return matchedValue?.[ mappedPresetValue.slug ];
|
|
244
|
-
}
|
|
245
|
-
return UNKNOWN_VALUE;
|
|
246
|
-
} );
|
|
247
|
-
}
|
|
248
|
-
if ( variable === 'custom' ) {
|
|
249
|
-
const customValuesData = customValues ?? JSON.parse( stylesBase );
|
|
250
|
-
stylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {
|
|
251
|
-
const path = $2.split( '--' );
|
|
252
|
-
|
|
253
|
-
// Supports cases for variables like var(--wp--custom--color--background)
|
|
254
|
-
if ( path[ 0 ] === 'color' ) {
|
|
255
|
-
const colorKey = path[ path.length - 1 ];
|
|
256
|
-
if ( mappedValues?.color ) {
|
|
257
|
-
const matchedValue = mappedValues.color?.values?.find(
|
|
258
|
-
( { slug } ) => slug === colorKey
|
|
259
|
-
);
|
|
260
|
-
if ( matchedValue ) {
|
|
261
|
-
return `${ matchedValue?.color }`;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
path.reduce(
|
|
268
|
-
( prev, curr ) => prev && prev[ curr ],
|
|
269
|
-
customValuesData
|
|
270
|
-
)
|
|
271
|
-
) {
|
|
272
|
-
return getValueFromObjectPath( customValuesData, path );
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Check for camelcase properties.
|
|
276
|
-
return getValueFromObjectPath( customValuesData, [
|
|
277
|
-
...path.slice( 0, path.length - 1 ),
|
|
278
|
-
camelCase( path[ path.length - 1 ] ),
|
|
279
|
-
] );
|
|
280
|
-
} );
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if ( variable === 'var' ) {
|
|
284
|
-
stylesBase = stylesBase.replace( varRegex, ( _$1, $2 ) => {
|
|
285
|
-
if ( mappedValues?.color ) {
|
|
286
|
-
const matchedValue = mappedValues.color?.values?.find(
|
|
287
|
-
( { slug } ) => slug === $2
|
|
288
|
-
);
|
|
289
|
-
return `"${ matchedValue?.color }"`;
|
|
290
|
-
}
|
|
291
|
-
return UNKNOWN_VALUE;
|
|
292
|
-
} );
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if ( variable === 'fontSize' ) {
|
|
296
|
-
const { width, height } = Dimensions.get( 'window' );
|
|
297
|
-
|
|
298
|
-
stylesBase = stylesBase.replace( fontSizeRegex, ( _$1, $2 ) => {
|
|
299
|
-
const parsedFontSize =
|
|
300
|
-
getPxFromCssUnit( $2, {
|
|
301
|
-
width,
|
|
302
|
-
height,
|
|
303
|
-
fontSize: DEFAULT_FONT_SIZE,
|
|
304
|
-
} ) || `${ DEFAULT_FONT_SIZE }px`;
|
|
305
|
-
|
|
306
|
-
return `"fontSize":"${ parsedFontSize }"`;
|
|
307
|
-
} );
|
|
308
|
-
}
|
|
309
|
-
} );
|
|
310
|
-
|
|
311
|
-
return JSON.parse( stylesBase );
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function getMappedValues( features, palette ) {
|
|
315
|
-
const typography = features?.typography;
|
|
316
|
-
const colors = [
|
|
317
|
-
...( palette?.theme || [] ),
|
|
318
|
-
...( palette?.custom || [] ),
|
|
319
|
-
...( palette?.default || [] ),
|
|
320
|
-
];
|
|
321
|
-
|
|
322
|
-
const fontSizes = {
|
|
323
|
-
...typography?.fontSizes?.theme,
|
|
324
|
-
...typography?.fontSizes?.custom,
|
|
325
|
-
};
|
|
326
|
-
const mappedValues = {
|
|
327
|
-
color: {
|
|
328
|
-
values: colors,
|
|
329
|
-
slug: 'color',
|
|
330
|
-
},
|
|
331
|
-
'font-size': {
|
|
332
|
-
values: fontSizes,
|
|
333
|
-
slug: 'size',
|
|
334
|
-
},
|
|
335
|
-
};
|
|
336
|
-
return mappedValues;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Returns the normalized fontSizes to include the sizePx value for each of the different sizes.
|
|
341
|
-
*
|
|
342
|
-
* @param {Object} fontSizes found in global styles.
|
|
343
|
-
* @return {Object} normalized sizes.
|
|
344
|
-
*/
|
|
345
|
-
function normalizeFontSizes( fontSizes ) {
|
|
346
|
-
if ( ! fontSizes ) {
|
|
347
|
-
return fontSizes;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const dimensions = Dimensions.get( 'window' );
|
|
351
|
-
const normalizedFontSizes = {};
|
|
352
|
-
const keysToProcess = [];
|
|
353
|
-
|
|
354
|
-
// Check if 'theme' or 'custom' keys exist and add them to keysToProcess array
|
|
355
|
-
if ( fontSizes?.theme ) {
|
|
356
|
-
keysToProcess.push( 'theme' );
|
|
357
|
-
}
|
|
358
|
-
if ( fontSizes?.custom ) {
|
|
359
|
-
keysToProcess.push( 'custom' );
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// If neither 'theme' nor 'custom' exist, add 'default' if it exists
|
|
363
|
-
if ( keysToProcess.length === 0 && fontSizes?.default ) {
|
|
364
|
-
keysToProcess.push( 'default' );
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
keysToProcess.forEach( ( key ) => {
|
|
368
|
-
normalizedFontSizes[ key ] = fontSizes[ key ].map(
|
|
369
|
-
( fontSizeObject ) => {
|
|
370
|
-
fontSizeObject.sizePx = getPxFromCssUnit( fontSizeObject.size, {
|
|
371
|
-
width: dimensions.width,
|
|
372
|
-
height: dimensions.height,
|
|
373
|
-
fontSize: DEFAULT_FONT_SIZE,
|
|
374
|
-
} );
|
|
375
|
-
return fontSizeObject;
|
|
376
|
-
}
|
|
377
|
-
);
|
|
378
|
-
} );
|
|
379
|
-
|
|
380
|
-
return normalizedFontSizes;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export function useMobileGlobalStylesColors( type = 'colors' ) {
|
|
384
|
-
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
385
|
-
const availableThemeColors = colorGradientSettings?.[ type ]?.reduce(
|
|
386
|
-
( colors, origin ) => colors.concat( origin?.[ type ] ),
|
|
387
|
-
[]
|
|
388
|
-
);
|
|
389
|
-
// Default editor colors/gradients if it's not a block-based theme.
|
|
390
|
-
const defaultPaletteSetting =
|
|
391
|
-
type === 'colors' ? 'color.palette' : 'color.gradients';
|
|
392
|
-
const [ defaultPaletteValue ] = useSettings( defaultPaletteSetting );
|
|
393
|
-
// In edge cases, the default palette might be undefined. To avoid
|
|
394
|
-
// exceptions across the editor in that case, we explicitly return
|
|
395
|
-
// the default editor colors.
|
|
396
|
-
const defaultPalette = defaultPaletteValue ?? SETTINGS_DEFAULTS.colors;
|
|
397
|
-
|
|
398
|
-
return availableThemeColors.length >= 1
|
|
399
|
-
? availableThemeColors
|
|
400
|
-
: defaultPalette;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export function getColorsAndGradients(
|
|
404
|
-
defaultEditorColors = [],
|
|
405
|
-
defaultEditorGradients = [],
|
|
406
|
-
rawFeatures
|
|
407
|
-
) {
|
|
408
|
-
const features = rawFeatures ? JSON.parse( rawFeatures ) : {};
|
|
409
|
-
|
|
410
|
-
return {
|
|
411
|
-
__experimentalGlobalStylesBaseStyles: null,
|
|
412
|
-
__experimentalFeatures: {
|
|
413
|
-
// Set an empty object to avoid errors from shared web components relying
|
|
414
|
-
// upon block settings. E.g., the Gallery block.
|
|
415
|
-
blocks: {},
|
|
416
|
-
color: {
|
|
417
|
-
...( ! features?.color
|
|
418
|
-
? {
|
|
419
|
-
text: true,
|
|
420
|
-
background: true,
|
|
421
|
-
palette: {
|
|
422
|
-
default: defaultEditorColors,
|
|
423
|
-
},
|
|
424
|
-
gradients: {
|
|
425
|
-
default: defaultEditorGradients,
|
|
426
|
-
},
|
|
427
|
-
}
|
|
428
|
-
: features?.color ),
|
|
429
|
-
defaultPalette: defaultEditorColors?.length > 0,
|
|
430
|
-
defaultGradients: defaultEditorGradients?.length > 0,
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export function getGlobalStyles( rawStyles, rawFeatures ) {
|
|
437
|
-
const features = rawFeatures ? JSON.parse( rawFeatures ) : {};
|
|
438
|
-
const mappedValues = getMappedValues( features, features?.color?.palette );
|
|
439
|
-
const colors = parseStylesVariables(
|
|
440
|
-
JSON.stringify( features?.color ),
|
|
441
|
-
mappedValues
|
|
442
|
-
);
|
|
443
|
-
const gradients = parseStylesVariables(
|
|
444
|
-
JSON.stringify( features?.color?.gradients ),
|
|
445
|
-
mappedValues
|
|
446
|
-
);
|
|
447
|
-
const customValues = parseStylesVariables(
|
|
448
|
-
JSON.stringify( features?.custom ),
|
|
449
|
-
mappedValues
|
|
450
|
-
);
|
|
451
|
-
const globalStyles = parseStylesVariables(
|
|
452
|
-
rawStyles,
|
|
453
|
-
mappedValues,
|
|
454
|
-
customValues
|
|
455
|
-
);
|
|
456
|
-
|
|
457
|
-
const fontSizes = normalizeFontSizes( features?.typography?.fontSizes );
|
|
458
|
-
|
|
459
|
-
return {
|
|
460
|
-
__experimentalFeatures: {
|
|
461
|
-
// Set an empty object to avoid errors from shared web components relying
|
|
462
|
-
// upon block settings. E.g., the Gallery block.
|
|
463
|
-
blocks: {},
|
|
464
|
-
color: {
|
|
465
|
-
palette: colors?.palette,
|
|
466
|
-
gradients,
|
|
467
|
-
text: features?.color?.text ?? true,
|
|
468
|
-
background: features?.color?.background ?? true,
|
|
469
|
-
defaultPalette: features?.color?.defaultPalette ?? true,
|
|
470
|
-
defaultGradients: features?.color?.defaultGradients ?? true,
|
|
471
|
-
},
|
|
472
|
-
typography: {
|
|
473
|
-
fontSizes,
|
|
474
|
-
customLineHeight: features?.custom?.[ 'line-height' ],
|
|
475
|
-
},
|
|
476
|
-
spacing: features?.spacing,
|
|
477
|
-
},
|
|
478
|
-
__experimentalGlobalStylesBaseStyles: globalStyles,
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
export const getMergedGlobalStyles = (
|
|
483
|
-
baseGlobalStyles,
|
|
484
|
-
globalStyle,
|
|
485
|
-
wrapperPropsStyle,
|
|
486
|
-
blockAttributes,
|
|
487
|
-
defaultColors,
|
|
488
|
-
blockName,
|
|
489
|
-
fontSizes
|
|
490
|
-
) => {
|
|
491
|
-
// Current support for general styles and blocks.
|
|
492
|
-
const baseGlobalColors = {
|
|
493
|
-
baseColors: {
|
|
494
|
-
color: baseGlobalStyles?.color,
|
|
495
|
-
typography: baseGlobalStyles?.typography,
|
|
496
|
-
elements: {
|
|
497
|
-
link: baseGlobalStyles?.elements?.link,
|
|
498
|
-
},
|
|
499
|
-
blocks: {
|
|
500
|
-
'core/button': baseGlobalStyles?.blocks?.[ 'core/button' ],
|
|
501
|
-
},
|
|
502
|
-
},
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
const blockStyleAttributes = Object.fromEntries(
|
|
506
|
-
Object.entries( blockAttributes ?? {} ).filter( ( [ key ] ) =>
|
|
507
|
-
BLOCK_STYLE_ATTRIBUTES.includes( key )
|
|
508
|
-
)
|
|
509
|
-
);
|
|
510
|
-
|
|
511
|
-
// This prevents certain wrapper styles from being applied to blocks that
|
|
512
|
-
// don't support them yet.
|
|
513
|
-
const wrapperPropsStyleFiltered = Object.fromEntries(
|
|
514
|
-
Object.entries( wrapperPropsStyle ?? {} ).filter( ( [ key ] ) =>
|
|
515
|
-
BLOCK_STYLE_ATTRIBUTES.includes( key )
|
|
516
|
-
)
|
|
517
|
-
);
|
|
518
|
-
|
|
519
|
-
const mergedStyle = {
|
|
520
|
-
...baseGlobalColors,
|
|
521
|
-
...globalStyle,
|
|
522
|
-
...wrapperPropsStyleFiltered,
|
|
523
|
-
};
|
|
524
|
-
const blockColors = getBlockColors(
|
|
525
|
-
blockStyleAttributes,
|
|
526
|
-
defaultColors,
|
|
527
|
-
blockName,
|
|
528
|
-
baseGlobalStyles
|
|
529
|
-
);
|
|
530
|
-
const blockPaddings = getBlockPaddings(
|
|
531
|
-
mergedStyle,
|
|
532
|
-
wrapperPropsStyle,
|
|
533
|
-
blockStyleAttributes,
|
|
534
|
-
blockColors
|
|
535
|
-
);
|
|
536
|
-
const blockTypography = getBlockTypography(
|
|
537
|
-
blockStyleAttributes,
|
|
538
|
-
fontSizes,
|
|
539
|
-
blockName,
|
|
540
|
-
baseGlobalStyles
|
|
541
|
-
);
|
|
542
|
-
|
|
543
|
-
return {
|
|
544
|
-
...mergedStyle,
|
|
545
|
-
...blockPaddings,
|
|
546
|
-
...blockColors,
|
|
547
|
-
...blockTypography,
|
|
548
|
-
};
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
export const useGlobalStyles = () => {
|
|
552
|
-
const globalStyles = useContext( GlobalStylesContext );
|
|
553
|
-
|
|
554
|
-
return globalStyles;
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Determine and apply appropriate color scheme based on global styles or device's light/dark mode.
|
|
559
|
-
*
|
|
560
|
-
* The function first attempts to retrieve the editor's background color from global styles.
|
|
561
|
-
* If the detected background color is light, light styles are applied, and dark styles otherwise.
|
|
562
|
-
* If no custom background color is defined, styles are applied using the device's dark/light setting.
|
|
563
|
-
*
|
|
564
|
-
* @param {Object} baseStyle - An object representing the base (light theme) styles for the editor.
|
|
565
|
-
* @param {Object} darkStyle - An object representing the additional styles to apply when the editor is in dark mode.
|
|
566
|
-
*
|
|
567
|
-
* @return {Object} - The combined style object that should be applied to the editor.
|
|
568
|
-
*/
|
|
569
|
-
export const useEditorColorScheme = ( baseStyle, darkStyle ) => {
|
|
570
|
-
const globalStyles = useGlobalStyles();
|
|
571
|
-
|
|
572
|
-
const deviceColorScheme = usePreferredColorSchemeStyle(
|
|
573
|
-
baseStyle,
|
|
574
|
-
darkStyle
|
|
575
|
-
);
|
|
576
|
-
|
|
577
|
-
const editorColors = globalStyles?.baseColors?.color;
|
|
578
|
-
const editorBackgroundColor = editorColors?.background;
|
|
579
|
-
|
|
580
|
-
const isBackgroundColorDefined =
|
|
581
|
-
typeof editorBackgroundColor !== 'undefined' &&
|
|
582
|
-
editorBackgroundColor !== 'undefined';
|
|
583
|
-
|
|
584
|
-
if ( isBackgroundColorDefined ) {
|
|
585
|
-
const isEditorBackgroundDark = colord( editorBackgroundColor ).isDark();
|
|
586
|
-
return isEditorBackgroundDark
|
|
587
|
-
? { ...baseStyle, ...darkStyle }
|
|
588
|
-
: baseStyle;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
return deviceColorScheme;
|
|
592
|
-
};
|