@wordpress/block-editor 8.5.7 → 9.1.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 +11 -0
- package/README.md +5 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -6
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-content-overlay/index.js +5 -74
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +64 -0
- package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build/components/block-draggable/index.native.js +484 -0
- package/build/components/block-draggable/index.native.js.map +1 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build/components/block-list/block-list-context.native.js +195 -0
- package/build/components/block-list/block-list-context.native.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +67 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build/components/block-list/block-list-item.native.js +12 -9
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block.native.js +29 -6
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +75 -23
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -4
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +9 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +17 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +191 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +85 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +216 -0
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/border-radius-control/input-controls.js +10 -3
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +149 -44
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +3 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/index.js +5 -23
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +31 -9
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/link-control/constants.js +11 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-results.js +4 -3
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +4 -4
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +0 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +1 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +167 -0
- package/build/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.native.js +95 -0
- package/build/components/use-on-block-drop/index.native.js.map +1 -0
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +463 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +14 -7
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/style.js +14 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +6 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-alignment-matrix-control/index.js +1 -6
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +4 -70
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +50 -0
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build-module/components/block-draggable/index.native.js +449 -0
- package/build-module/components/block-draggable/index.native.js.map +1 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build-module/components/block-list/block-list-context.native.js +179 -0
- package/build-module/components/block-list/block-list-context.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item.native.js +12 -9
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +28 -6
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +72 -23
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -5
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +8 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +18 -5
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +173 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +72 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-preview/index.js +1 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +199 -0
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/border-radius-control/input-controls.js +11 -4
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +151 -46
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/index.js +1 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +32 -11
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/link-control/constants.js +5 -0
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -4
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +5 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +0 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -5
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +148 -0
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.native.js +83 -0
- package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +453 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +11 -6
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/dimensions.js +5 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/style.js +15 -14
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +6 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +148 -410
- package/build-style/style.css +148 -410
- package/package.json +28 -28
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-content-overlay/index.js +9 -79
- package/src/components/block-content-overlay/style.scss +2 -11
- package/src/components/block-draggable/draggable-chip.native.js +49 -0
- package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
- package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
- package/src/components/block-draggable/index.native.js +458 -0
- package/src/components/block-draggable/style.native.scss +19 -0
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
- package/src/components/block-list/block-list-context.native.js +175 -0
- package/src/components/block-list/block-list-item-cell.native.js +49 -0
- package/src/components/block-list/block-list-item.native.js +7 -11
- package/src/components/block-list/block.native.js +38 -8
- package/src/components/block-list/index.native.js +54 -13
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/test/block-list-context.native.js +253 -0
- package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
- package/src/components/block-list/use-block-props/index.js +10 -5
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- package/src/components/block-mobile-toolbar/index.native.js +8 -1
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/index.native.js +22 -6
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +6 -0
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +188 -0
- package/src/components/block-popover/index.js +75 -0
- package/src/components/block-popover/style.scss +28 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +2 -43
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -151
- package/src/components/block-tools/style.scss +12 -135
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +7 -3
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/colors-gradients/dropdown.js +156 -62
- package/src/components/colors-gradients/style.scss +51 -23
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/gradients/README.md +29 -0
- package/src/components/image-editor/use-save-image.js +2 -1
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +1 -3
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- package/src/components/inserter/style.scss +2 -1
- package/src/components/link-control/constants.js +11 -0
- package/src/components/link-control/search-results.js +4 -5
- package/src/components/link-control/use-search-handler.js +11 -5
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/drop-indicator.js +0 -1
- package/src/components/list-view/index.js +11 -41
- package/src/components/list-view/style.scss +2 -1
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/navigable-toolbar/index.js +12 -2
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +1 -3
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/url-input/index.js +9 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/components/use-block-drop-zone/index.native.js +173 -0
- package/src/components/use-on-block-drop/index.native.js +119 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +429 -72
- package/src/hooks/color-panel.js +13 -9
- package/src/hooks/color.scss +0 -62
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/style.js +25 -39
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/typography.js +2 -0
- package/src/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js +0 -327
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js +0 -306
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"names":["has","addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","createHigherOrderComponent","Platform","InspectorControls","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","attributes","anchor","withInspectorControl","BlockEdit","props","hasAnchor","name","isSelected","isWeb","OS","textControl","nextValue","replace","setAttributes","addSaveProps","extraProps","blockType","id"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( has( settings.attributes, [ 'anchor', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning the anchor ID, if block supports anchor.\n *\n * @param {WPComponent} BlockEdit Original component.\n *\n * @return {WPComponent} Wrapped component.\n */\nexport const withInspectorControl = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\tconst hasAnchor = hasBlockSupport( props.name, 'anchor' );\n\n\t\t\tif ( hasAnchor && props.isSelected ) {\n\t\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\t\tconst textControl = (\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/page-jumps/'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ props.attributes.anchor || '' }\n\t\t\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\t\t\tprops.setAttributes( {\n\t\t\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t\t\t\t */ }\n\t\t\t\t\t\t{ ! isWeb && props.name === 'core/heading' && (\n\t\t\t\t\t\t\t<InspectorControls>\n\t\t\t\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t\t\t\t</PanelBody>\n\t\t\t\t\t\t\t</InspectorControls>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t};\n\t},\n\t'withInspectorControl'\n);\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/anchor/with-inspector-control',\n\twithInspectorControl\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/anchor/save-props',\n\taddSaveProps\n);\n"]}
|
|
@@ -1,89 +1,317 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import { createElement } from "@wordpress/element";
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import classnames from 'classnames';
|
|
3
8
|
/**
|
|
4
9
|
* WordPress dependencies
|
|
5
10
|
*/
|
|
11
|
+
|
|
6
12
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
|
-
import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
13
|
+
import { __experimentalBorderBoxControl as BorderBoxControl, __experimentalHasSplitBorders as hasSplitBorders, __experimentalIsDefinedBorder as isDefinedBorder, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
14
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
8
15
|
import { Platform } from '@wordpress/element';
|
|
16
|
+
import { addFilter } from '@wordpress/hooks';
|
|
9
17
|
import { __ } from '@wordpress/i18n';
|
|
10
18
|
/**
|
|
11
19
|
* Internal dependencies
|
|
12
20
|
*/
|
|
13
21
|
|
|
14
|
-
import { BorderColorEdit, hasBorderColorValue, resetBorderColor } from './border-color';
|
|
15
22
|
import { BorderRadiusEdit, hasBorderRadiusValue, resetBorderRadius } from './border-radius';
|
|
16
|
-
import {
|
|
17
|
-
import { BorderWidthEdit, hasBorderWidthValue, resetBorderWidth } from './border-width';
|
|
23
|
+
import { getColorClassName } from '../components/colors';
|
|
18
24
|
import InspectorControls from '../components/inspector-controls';
|
|
25
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
19
26
|
import useSetting from '../components/use-setting';
|
|
20
|
-
import { cleanEmptyObject } from './utils';
|
|
27
|
+
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
21
28
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
29
|
+
const borderSides = ['top', 'right', 'bottom', 'left'];
|
|
30
|
+
|
|
31
|
+
const hasBorderValue = props => {
|
|
32
|
+
const {
|
|
33
|
+
borderColor,
|
|
34
|
+
style
|
|
35
|
+
} = props.attributes;
|
|
36
|
+
return isDefinedBorder(style === null || style === void 0 ? void 0 : style.border) || !!borderColor;
|
|
37
|
+
}; // The border color, style, and width are omitted so they get undefined. The
|
|
38
|
+
// border radius is separate and must retain its selection.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const resetBorder = _ref => {
|
|
42
|
+
var _style$border;
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
attributes = {},
|
|
46
|
+
setAttributes
|
|
47
|
+
} = _ref;
|
|
48
|
+
const {
|
|
49
|
+
style
|
|
50
|
+
} = attributes;
|
|
51
|
+
setAttributes({
|
|
52
|
+
borderColor: undefined,
|
|
53
|
+
style: { ...style,
|
|
54
|
+
border: cleanEmptyObject({
|
|
55
|
+
radius: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const resetBorderFilter = newAttributes => {
|
|
62
|
+
var _newAttributes$style, _newAttributes$style$;
|
|
63
|
+
|
|
64
|
+
return { ...newAttributes,
|
|
65
|
+
borderColor: undefined,
|
|
66
|
+
style: { ...newAttributes.style,
|
|
67
|
+
border: {
|
|
68
|
+
radius: (_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : (_newAttributes$style$ = _newAttributes$style.border) === null || _newAttributes$style$ === void 0 ? void 0 : _newAttributes$style$.radius
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const getColorByProperty = (colors, property, value) => {
|
|
75
|
+
let matchedColor;
|
|
76
|
+
colors.some(origin => origin.colors.some(color => {
|
|
77
|
+
if (color[property] === value) {
|
|
78
|
+
matchedColor = color;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
}));
|
|
84
|
+
return matchedColor;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const getMultiOriginColor = _ref2 => {
|
|
88
|
+
let {
|
|
89
|
+
colors,
|
|
90
|
+
namedColor,
|
|
91
|
+
customColor
|
|
92
|
+
} = _ref2;
|
|
93
|
+
|
|
94
|
+
// Search each origin (default, theme, or user) for matching color by name.
|
|
95
|
+
if (namedColor) {
|
|
96
|
+
const colorObject = getColorByProperty(colors, 'slug', namedColor);
|
|
97
|
+
|
|
98
|
+
if (colorObject) {
|
|
99
|
+
return colorObject;
|
|
100
|
+
}
|
|
101
|
+
} // Skip if no custom color or matching named color.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (!customColor) {
|
|
105
|
+
return {
|
|
106
|
+
color: undefined
|
|
107
|
+
};
|
|
108
|
+
} // Attempt to find color via custom color value or build new object.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
const colorObject = getColorByProperty(colors, 'color', customColor);
|
|
112
|
+
return colorObject ? colorObject : {
|
|
113
|
+
color: customColor
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const getBorderObject = (attributes, colors) => {
|
|
118
|
+
const {
|
|
119
|
+
borderColor,
|
|
120
|
+
style
|
|
121
|
+
} = attributes;
|
|
122
|
+
const {
|
|
123
|
+
border: borderStyles
|
|
124
|
+
} = style || {}; // If we have a named color for a flat border. Fetch that color object and
|
|
125
|
+
// apply that color's value to the color property within the style object.
|
|
126
|
+
|
|
127
|
+
if (borderColor) {
|
|
128
|
+
const {
|
|
129
|
+
color
|
|
130
|
+
} = getMultiOriginColor({
|
|
131
|
+
colors,
|
|
132
|
+
namedColor: borderColor
|
|
133
|
+
});
|
|
134
|
+
return color ? { ...borderStyles,
|
|
135
|
+
color
|
|
136
|
+
} : borderStyles;
|
|
137
|
+
} // Individual side border color slugs are stored within the border style
|
|
138
|
+
// object. If we don't have a border styles object we have nothing further
|
|
139
|
+
// to hydrate.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if (!borderStyles) {
|
|
143
|
+
return borderStyles;
|
|
144
|
+
} // If we have named colors for the individual side borders, retrieve their
|
|
145
|
+
// related color objects and apply the real color values to the split
|
|
146
|
+
// border objects.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
const hydratedBorderStyles = { ...borderStyles
|
|
150
|
+
};
|
|
151
|
+
borderSides.forEach(side => {
|
|
152
|
+
var _hydratedBorderStyles;
|
|
153
|
+
|
|
154
|
+
const colorSlug = getColorSlugFromVariable((_hydratedBorderStyles = hydratedBorderStyles[side]) === null || _hydratedBorderStyles === void 0 ? void 0 : _hydratedBorderStyles.color);
|
|
155
|
+
|
|
156
|
+
if (colorSlug) {
|
|
157
|
+
const {
|
|
158
|
+
color
|
|
159
|
+
} = getMultiOriginColor({
|
|
160
|
+
colors,
|
|
161
|
+
namedColor: colorSlug
|
|
162
|
+
});
|
|
163
|
+
hydratedBorderStyles[side] = { ...hydratedBorderStyles[side],
|
|
164
|
+
color
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return hydratedBorderStyles;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
function getColorSlugFromVariable(value) {
|
|
172
|
+
const namedColor = /var:preset\|color\|(.+)/.exec(value);
|
|
173
|
+
|
|
174
|
+
if (namedColor && namedColor[1]) {
|
|
175
|
+
return namedColor[1];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
22
181
|
export function BorderPanel(props) {
|
|
23
182
|
const {
|
|
24
|
-
|
|
183
|
+
attributes,
|
|
184
|
+
clientId,
|
|
185
|
+
setAttributes
|
|
25
186
|
} = props;
|
|
187
|
+
const {
|
|
188
|
+
style
|
|
189
|
+
} = attributes;
|
|
190
|
+
const {
|
|
191
|
+
colors
|
|
192
|
+
} = useMultipleOriginColorsAndGradients();
|
|
193
|
+
const isSupported = hasBorderSupport(props.name);
|
|
26
194
|
const isColorSupported = useSetting('border.color') && hasBorderSupport(props.name, 'color');
|
|
27
195
|
const isRadiusSupported = useSetting('border.radius') && hasBorderSupport(props.name, 'radius');
|
|
28
196
|
const isStyleSupported = useSetting('border.style') && hasBorderSupport(props.name, 'style');
|
|
29
197
|
const isWidthSupported = useSetting('border.width') && hasBorderSupport(props.name, 'width');
|
|
30
198
|
const isDisabled = [!isColorSupported, !isRadiusSupported, !isStyleSupported, !isWidthSupported].every(Boolean);
|
|
31
199
|
|
|
32
|
-
if (isDisabled) {
|
|
200
|
+
if (isDisabled || !isSupported) {
|
|
33
201
|
return null;
|
|
34
202
|
}
|
|
35
203
|
|
|
36
204
|
const defaultBorderControls = getBlockSupport(props.name, [BORDER_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
205
|
+
const showBorderByDefault = (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color) || (defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.width);
|
|
37
206
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
return newAttributes => {
|
|
41
|
-
var _newAttributes$style;
|
|
207
|
+
const onBorderChange = newBorder => {
|
|
208
|
+
var _style$border2;
|
|
42
209
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
210
|
+
// Filter out named colors and apply them to appropriate block
|
|
211
|
+
// attributes so that CSS classes can be used to apply those colors.
|
|
212
|
+
// e.g. has-primary-border-top-color.
|
|
213
|
+
let newBorderStyles = { ...newBorder
|
|
214
|
+
};
|
|
215
|
+
let newBorderColor;
|
|
216
|
+
|
|
217
|
+
if (hasSplitBorders(newBorder)) {
|
|
218
|
+
// For each side check if the side has a color value set
|
|
219
|
+
// If so, determine if it belongs to a named color, in which case
|
|
220
|
+
// we update the color property.
|
|
221
|
+
//
|
|
222
|
+
// This deliberately overwrites `newBorderStyles` to avoid mutating
|
|
223
|
+
// the passed object which causes problems otherwise.
|
|
224
|
+
newBorderStyles = {
|
|
225
|
+
top: { ...newBorder.top
|
|
226
|
+
},
|
|
227
|
+
right: { ...newBorder.right
|
|
228
|
+
},
|
|
229
|
+
bottom: { ...newBorder.bottom
|
|
230
|
+
},
|
|
231
|
+
left: { ...newBorder.left
|
|
49
232
|
}
|
|
50
233
|
};
|
|
51
|
-
|
|
234
|
+
borderSides.forEach(side => {
|
|
235
|
+
var _newBorder$side;
|
|
236
|
+
|
|
237
|
+
if ((_newBorder$side = newBorder[side]) !== null && _newBorder$side !== void 0 && _newBorder$side.color) {
|
|
238
|
+
var _newBorder$side2;
|
|
239
|
+
|
|
240
|
+
const colorObject = getMultiOriginColor({
|
|
241
|
+
colors,
|
|
242
|
+
customColor: (_newBorder$side2 = newBorder[side]) === null || _newBorder$side2 === void 0 ? void 0 : _newBorder$side2.color
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
if (colorObject.slug) {
|
|
246
|
+
newBorderStyles[side].color = `var:preset|color|${colorObject.slug}`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
} else if (newBorder !== null && newBorder !== void 0 && newBorder.color) {
|
|
251
|
+
// We have a flat border configuration. Apply named color slug to
|
|
252
|
+
// `borderColor` attribute and clear color style property if found.
|
|
253
|
+
const customColor = newBorder === null || newBorder === void 0 ? void 0 : newBorder.color;
|
|
254
|
+
const colorObject = getMultiOriginColor({
|
|
255
|
+
colors,
|
|
256
|
+
customColor
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
if (colorObject.slug) {
|
|
260
|
+
newBorderColor = colorObject.slug;
|
|
261
|
+
newBorderStyles.color = undefined;
|
|
262
|
+
}
|
|
263
|
+
} // Ensure previous border radius styles are maintained and clean
|
|
264
|
+
// overall result for empty objects or properties.
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
const newStyle = cleanEmptyObject({ ...style,
|
|
268
|
+
border: {
|
|
269
|
+
radius: style === null || style === void 0 ? void 0 : (_style$border2 = style.border) === null || _style$border2 === void 0 ? void 0 : _style$border2.radius,
|
|
270
|
+
...newBorderStyles
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
setAttributes({
|
|
274
|
+
style: newStyle,
|
|
275
|
+
borderColor: newBorderColor
|
|
276
|
+
});
|
|
52
277
|
};
|
|
53
278
|
|
|
279
|
+
const hydratedBorder = getBorderObject(attributes, colors);
|
|
54
280
|
return createElement(InspectorControls, {
|
|
55
281
|
__experimentalGroup: "border"
|
|
56
|
-
}, isWidthSupported && createElement(ToolsPanelItem, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
resetAllFilter: createResetAllFilter('width'),
|
|
63
|
-
panelId: clientId
|
|
64
|
-
}, createElement(BorderWidthEdit, props)), isStyleSupported && createElement(ToolsPanelItem, {
|
|
65
|
-
className: "single-column",
|
|
66
|
-
hasValue: () => hasBorderStyleValue(props),
|
|
67
|
-
label: __('Style'),
|
|
68
|
-
onDeselect: () => resetBorderStyle(props),
|
|
69
|
-
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.style,
|
|
70
|
-
resetAllFilter: createResetAllFilter('style'),
|
|
71
|
-
panelId: clientId
|
|
72
|
-
}, createElement(BorderStyleEdit, props)), isColorSupported && createElement(ToolsPanelItem, {
|
|
73
|
-
hasValue: () => hasBorderColorValue(props),
|
|
74
|
-
label: __('Color'),
|
|
75
|
-
onDeselect: () => resetBorderColor(props),
|
|
76
|
-
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.color,
|
|
77
|
-
resetAllFilter: createResetAllFilter('color', {
|
|
78
|
-
borderColor: undefined
|
|
79
|
-
}),
|
|
282
|
+
}, (isWidthSupported || isColorSupported) && createElement(ToolsPanelItem, {
|
|
283
|
+
hasValue: () => hasBorderValue(props),
|
|
284
|
+
label: __('Border'),
|
|
285
|
+
onDeselect: () => resetBorder(props),
|
|
286
|
+
isShownByDefault: showBorderByDefault,
|
|
287
|
+
resetAllFilter: resetBorderFilter,
|
|
80
288
|
panelId: clientId
|
|
81
|
-
}, createElement(
|
|
289
|
+
}, createElement(BorderBoxControl, {
|
|
290
|
+
colors: colors,
|
|
291
|
+
enableAlpha: true,
|
|
292
|
+
onChange: onBorderChange,
|
|
293
|
+
popoverPlacement: "left-start",
|
|
294
|
+
popoverOffset: 40,
|
|
295
|
+
showStyle: isStyleSupported,
|
|
296
|
+
value: hydratedBorder,
|
|
297
|
+
__experimentalHasMultipleOrigins: true,
|
|
298
|
+
__experimentalIsRenderedInSidebar: true
|
|
299
|
+
})), isRadiusSupported && createElement(ToolsPanelItem, {
|
|
82
300
|
hasValue: () => hasBorderRadiusValue(props),
|
|
83
301
|
label: __('Radius'),
|
|
84
302
|
onDeselect: () => resetBorderRadius(props),
|
|
85
303
|
isShownByDefault: defaultBorderControls === null || defaultBorderControls === void 0 ? void 0 : defaultBorderControls.radius,
|
|
86
|
-
resetAllFilter:
|
|
304
|
+
resetAllFilter: newAttributes => {
|
|
305
|
+
var _newAttributes$style2;
|
|
306
|
+
|
|
307
|
+
return { ...newAttributes,
|
|
308
|
+
style: { ...newAttributes.style,
|
|
309
|
+
border: { ...((_newAttributes$style2 = newAttributes.style) === null || _newAttributes$style2 === void 0 ? void 0 : _newAttributes$style2.border),
|
|
310
|
+
radius: undefined
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
},
|
|
87
315
|
panelId: clientId
|
|
88
316
|
}, createElement(BorderRadiusEdit, props)));
|
|
89
317
|
}
|
|
@@ -132,4 +360,185 @@ export function removeBorderAttribute(style, attribute) {
|
|
|
132
360
|
}
|
|
133
361
|
});
|
|
134
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Filters registered block settings, extending attributes to include
|
|
365
|
+
* `borderColor` if needed.
|
|
366
|
+
*
|
|
367
|
+
* @param {Object} settings Original block settings.
|
|
368
|
+
*
|
|
369
|
+
* @return {Object} Updated block settings.
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
function addAttributes(settings) {
|
|
373
|
+
if (!hasBorderSupport(settings, 'color')) {
|
|
374
|
+
return settings;
|
|
375
|
+
} // Allow blocks to specify default value if needed.
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
if (settings.attributes.borderColor) {
|
|
379
|
+
return settings;
|
|
380
|
+
} // Add new borderColor attribute to block settings.
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
return { ...settings,
|
|
384
|
+
attributes: { ...settings.attributes,
|
|
385
|
+
borderColor: {
|
|
386
|
+
type: 'string'
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Override props assigned to save component to inject border color.
|
|
393
|
+
*
|
|
394
|
+
* @param {Object} props Additional props applied to save element.
|
|
395
|
+
* @param {Object} blockType Block type definition.
|
|
396
|
+
* @param {Object} attributes Block's attributes.
|
|
397
|
+
*
|
|
398
|
+
* @return {Object} Filtered props to apply to save element.
|
|
399
|
+
*/
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
function addSaveProps(props, blockType, attributes) {
|
|
403
|
+
if (!hasBorderSupport(blockType, 'color') || shouldSkipSerialization(blockType, BORDER_SUPPORT_KEY, 'color')) {
|
|
404
|
+
return props;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const borderClasses = getBorderClasses(attributes);
|
|
408
|
+
const newClassName = classnames(props.className, borderClasses); // If we are clearing the last of the previous classes in `className`
|
|
409
|
+
// set it to `undefined` to avoid rendering empty DOM attributes.
|
|
410
|
+
|
|
411
|
+
props.className = newClassName ? newClassName : undefined;
|
|
412
|
+
return props;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Generates a CSS class name consisting of all the applicable border color
|
|
416
|
+
* classes given the current block attributes.
|
|
417
|
+
*
|
|
418
|
+
* @param {Object} attributes Block's attributes.
|
|
419
|
+
*
|
|
420
|
+
* @return {string} CSS class name.
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
export function getBorderClasses(attributes) {
|
|
425
|
+
var _style$border3;
|
|
426
|
+
|
|
427
|
+
const {
|
|
428
|
+
borderColor,
|
|
429
|
+
style
|
|
430
|
+
} = attributes;
|
|
431
|
+
const borderColorClass = getColorClassName('border-color', borderColor);
|
|
432
|
+
return classnames({
|
|
433
|
+
'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border3 = style.border) === null || _style$border3 === void 0 ? void 0 : _style$border3.color),
|
|
434
|
+
[borderColorClass]: !!borderColorClass
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Filters the registered block settings to apply border color styles and
|
|
439
|
+
* classnames to the block edit wrapper.
|
|
440
|
+
*
|
|
441
|
+
* @param {Object} settings Original block settings.
|
|
442
|
+
*
|
|
443
|
+
* @return {Object} Filtered block settings.
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
function addEditProps(settings) {
|
|
447
|
+
if (!hasBorderSupport(settings, 'color') || shouldSkipSerialization(settings, BORDER_SUPPORT_KEY, 'color')) {
|
|
448
|
+
return settings;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const existingGetEditWrapperProps = settings.getEditWrapperProps;
|
|
452
|
+
|
|
453
|
+
settings.getEditWrapperProps = attributes => {
|
|
454
|
+
let props = {};
|
|
455
|
+
|
|
456
|
+
if (existingGetEditWrapperProps) {
|
|
457
|
+
props = existingGetEditWrapperProps(attributes);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return addSaveProps(props, settings, attributes);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
return settings;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* This adds inline styles for color palette colors.
|
|
467
|
+
* Ideally, this is not needed and themes should load their palettes on the editor.
|
|
468
|
+
*
|
|
469
|
+
* @param {Function} BlockListBlock Original component.
|
|
470
|
+
*
|
|
471
|
+
* @return {Function} Wrapped component.
|
|
472
|
+
*/
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
export const withBorderColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
|
|
476
|
+
var _style$border4, _style$border4$top, _style$border5, _style$border5$right, _style$border6, _style$border6$bottom, _style$border7, _style$border7$left, _props$wrapperProps;
|
|
477
|
+
|
|
478
|
+
const {
|
|
479
|
+
name,
|
|
480
|
+
attributes
|
|
481
|
+
} = props;
|
|
482
|
+
const {
|
|
483
|
+
borderColor,
|
|
484
|
+
style
|
|
485
|
+
} = attributes;
|
|
486
|
+
const {
|
|
487
|
+
colors
|
|
488
|
+
} = useMultipleOriginColorsAndGradients();
|
|
489
|
+
|
|
490
|
+
if (!hasBorderSupport(name, 'color') || shouldSkipSerialization(name, BORDER_SUPPORT_KEY, 'color')) {
|
|
491
|
+
return createElement(BlockListBlock, props);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const {
|
|
495
|
+
color: borderColorValue
|
|
496
|
+
} = getMultiOriginColor({
|
|
497
|
+
colors,
|
|
498
|
+
namedColor: borderColor
|
|
499
|
+
});
|
|
500
|
+
const {
|
|
501
|
+
color: borderTopColor
|
|
502
|
+
} = getMultiOriginColor({
|
|
503
|
+
colors,
|
|
504
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border4 = style.border) === null || _style$border4 === void 0 ? void 0 : (_style$border4$top = _style$border4.top) === null || _style$border4$top === void 0 ? void 0 : _style$border4$top.color)
|
|
505
|
+
});
|
|
506
|
+
const {
|
|
507
|
+
color: borderRightColor
|
|
508
|
+
} = getMultiOriginColor({
|
|
509
|
+
colors,
|
|
510
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border5 = style.border) === null || _style$border5 === void 0 ? void 0 : (_style$border5$right = _style$border5.right) === null || _style$border5$right === void 0 ? void 0 : _style$border5$right.color)
|
|
511
|
+
});
|
|
512
|
+
const {
|
|
513
|
+
color: borderBottomColor
|
|
514
|
+
} = getMultiOriginColor({
|
|
515
|
+
colors,
|
|
516
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border6 = style.border) === null || _style$border6 === void 0 ? void 0 : (_style$border6$bottom = _style$border6.bottom) === null || _style$border6$bottom === void 0 ? void 0 : _style$border6$bottom.color)
|
|
517
|
+
});
|
|
518
|
+
const {
|
|
519
|
+
color: borderLeftColor
|
|
520
|
+
} = getMultiOriginColor({
|
|
521
|
+
colors,
|
|
522
|
+
namedColor: getColorSlugFromVariable(style === null || style === void 0 ? void 0 : (_style$border7 = style.border) === null || _style$border7 === void 0 ? void 0 : (_style$border7$left = _style$border7.left) === null || _style$border7$left === void 0 ? void 0 : _style$border7$left.color)
|
|
523
|
+
});
|
|
524
|
+
const extraStyles = {
|
|
525
|
+
borderTopColor: borderTopColor || borderColorValue,
|
|
526
|
+
borderRightColor: borderRightColor || borderColorValue,
|
|
527
|
+
borderBottomColor: borderBottomColor || borderColorValue,
|
|
528
|
+
borderLeftColor: borderLeftColor || borderColorValue
|
|
529
|
+
};
|
|
530
|
+
let wrapperProps = props.wrapperProps;
|
|
531
|
+
wrapperProps = { ...props.wrapperProps,
|
|
532
|
+
style: { ...((_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style),
|
|
533
|
+
...extraStyles
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
return createElement(BlockListBlock, _extends({}, props, {
|
|
537
|
+
wrapperProps: wrapperProps
|
|
538
|
+
}));
|
|
539
|
+
});
|
|
540
|
+
addFilter('blocks.registerBlockType', 'core/border/addAttributes', addAttributes);
|
|
541
|
+
addFilter('blocks.getSaveContent.extraProps', 'core/border/addSaveProps', addSaveProps);
|
|
542
|
+
addFilter('blocks.registerBlockType', 'core/border/addEditProps', addEditProps);
|
|
543
|
+
addFilter('editor.BlockListBlock', 'core/border/with-border-color-palette-styles', withBorderColorPaletteStyles);
|
|
135
544
|
//# sourceMappingURL=border.js.map
|