@wordpress/block-editor 15.22.1 → 16.0.1-next.v.202607070741.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 +27 -0
- package/build/autocompleters/block.cjs +10 -2
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +0 -2
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +3 -0
- package/build/components/block-inspector/edit-contents.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +18 -36
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-invalid-warning.cjs +8 -19
- package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
- package/build/components/block-styles/use-styles-for-block.cjs +2 -1
- package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
- package/build/components/block-title/use-block-display-title.cjs +7 -2
- package/build/components/block-title/use-block-display-title.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +0 -1
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +0 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -5
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +0 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-appearance-control/index.cjs +6 -25
- package/build/components/font-appearance-control/index.cjs.map +3 -3
- package/build/components/font-family/index.cjs +6 -15
- package/build/components/font-family/index.cjs.map +3 -3
- package/build/components/font-sizes/font-size-picker.cjs +1 -2
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +0 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +4 -10
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/height-control/index.cjs +0 -2
- package/build/components/height-control/index.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs +0 -1
- package/build/components/html-element-control/index.cjs.map +2 -2
- package/build/components/image-editor/index.cjs +5 -0
- package/build/components/image-editor/index.cjs.map +3 -3
- package/build/components/image-editor/zoom-dropdown.cjs +0 -1
- package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs +1 -3
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs +107 -0
- package/build/components/inner-content/index.cjs.map +7 -0
- package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +34 -6
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-list.cjs +3 -1
- package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +224 -27
- package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs +32 -17
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-tab.cjs +26 -6
- package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
- package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
- package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
- package/build/components/inserter/no-results.cjs +2 -2
- package/build/components/inserter/no-results.cjs.map +2 -2
- package/build/components/inserter/preview-panel.cjs +2 -1
- package/build/components/inserter/preview-panel.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs +8 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/letter-spacing-control/index.cjs +0 -24
- package/build/components/letter-spacing-control/index.cjs.map +3 -3
- package/build/components/line-height-control/index.cjs +7 -22
- package/build/components/line-height-control/index.cjs.map +3 -3
- package/build/components/list-view/block-select-button.cjs +90 -84
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +51 -20
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/expander.cjs +1 -1
- package/build/components/list-view/expander.cjs.map +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
- package/build/components/observe-typing/index.cjs +4 -3
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +1 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/resolution-tool/index.cjs +1 -2
- package/build/components/resolution-tool/index.cjs.map +2 -2
- package/build/components/text-alignment-control/index.cjs +0 -1
- package/build/components/text-alignment-control/index.cjs.map +2 -2
- package/build/components/text-decoration-control/index.cjs +0 -1
- package/build/components/text-decoration-control/index.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +0 -8
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/text-transform-control/index.cjs +0 -1
- package/build/components/text-transform-control/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -8
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +3 -7
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/use-resize-canvas/index.cjs +16 -53
- package/build/components/use-resize-canvas/index.cjs.map +3 -3
- package/build/components/writing-mode-control/index.cjs +0 -1
- package/build/components/writing-mode-control/index.cjs.map +2 -2
- package/build/hooks/font-size.cjs +1 -2
- package/build/hooks/font-size.cjs.map +2 -2
- package/build/hooks/layout.cjs +5 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/position.cjs +36 -16
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +10 -21
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +21 -21
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +0 -3
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +51 -9
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +4 -2
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +16 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -3
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +96 -10
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +19 -3
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +13 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/autocompleters/block.mjs +10 -2
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +0 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +4 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +18 -36
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
- package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
- package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
- package/build-module/components/block-title/use-block-display-title.mjs +7 -2
- package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +0 -1
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +0 -2
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -5
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-appearance-control/index.mjs +6 -15
- package/build-module/components/font-appearance-control/index.mjs.map +2 -2
- package/build-module/components/font-family/index.mjs +6 -15
- package/build-module/components/font-family/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +0 -1
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +4 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/height-control/index.mjs +0 -2
- package/build-module/components/height-control/index.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +0 -1
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/image-editor/index.mjs +5 -0
- package/build-module/components/image-editor/index.mjs.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
- package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +1 -3
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs +82 -0
- package/build-module/components/inner-content/index.mjs.map +7 -0
- package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +33 -6
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
- package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +227 -30
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
- package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
- package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
- package/build-module/components/inserter/no-results.mjs +2 -2
- package/build-module/components/inserter/no-results.mjs.map +2 -2
- package/build-module/components/inserter/preview-panel.mjs +2 -1
- package/build-module/components/inserter/preview-panel.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs +8 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/letter-spacing-control/index.mjs +0 -14
- package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +7 -12
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +90 -84
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +51 -20
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/expander.mjs +1 -1
- package/build-module/components/list-view/expander.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
- package/build-module/components/observe-typing/index.mjs +4 -3
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +1 -3
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/resolution-tool/index.mjs +1 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/text-alignment-control/index.mjs +0 -1
- package/build-module/components/text-alignment-control/index.mjs.map +2 -2
- package/build-module/components/text-decoration-control/index.mjs +0 -1
- package/build-module/components/text-decoration-control/index.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +0 -8
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/text-transform-control/index.mjs +0 -1
- package/build-module/components/text-transform-control/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -8
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +4 -7
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/use-resize-canvas/index.mjs +6 -53
- package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
- package/build-module/components/writing-mode-control/index.mjs +0 -1
- package/build-module/components/writing-mode-control/index.mjs.map +2 -2
- package/build-module/hooks/font-size.mjs +1 -2
- package/build-module/hooks/font-size.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +4 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +38 -18
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +10 -21
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +21 -21
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +0 -3
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +52 -9
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +5 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +14 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -2
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +93 -10
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +17 -3
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +13 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +11 -5
- package/build-style/content.css +11 -5
- package/build-style/style-rtl.css +113 -3
- package/build-style/style.css +113 -3
- package/package.json +43 -41
- package/src/autocompleters/block.js +10 -3
- package/src/autocompleters/test/block.js +53 -0
- package/src/components/background-image-control/index.js +0 -2
- package/src/components/block-inspector/edit-contents.js +5 -1
- package/src/components/block-inspector/index.js +25 -44
- package/src/components/block-list/block-invalid-warning.js +8 -19
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-styles/use-styles-for-block.js +1 -0
- package/src/components/block-title/use-block-display-title.js +7 -2
- package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
- package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
- package/src/components/block-variation-transforms/index.js +0 -1
- package/src/components/child-layout-control/index.js +0 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +11 -106
- package/src/components/colors-gradients/control.js +4 -4
- package/src/components/colors-gradients/style.scss +2 -2
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +0 -1
- package/src/components/dimensions-tool/width-height-tool.js +0 -2
- package/src/components/font-appearance-control/index.js +6 -19
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +6 -19
- package/src/components/font-family/stories/index.story.jsx +0 -1
- package/src/components/font-sizes/font-size-picker.js +0 -1
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/typography-panel.js +0 -6
- package/src/components/height-control/index.js +0 -2
- package/src/components/html-element-control/index.js +0 -1
- package/src/components/iframe/content.scss +3 -3
- package/src/components/image-editor/index.js +22 -0
- package/src/components/image-editor/zoom-dropdown.js +0 -1
- package/src/components/image-size-control/index.js +0 -2
- package/src/components/inner-content/index.js +119 -0
- package/src/components/inner-content/test/index.js +81 -0
- package/src/components/inserter/hooks/use-block-types-state.js +10 -2
- package/src/components/inserter/media-tab/hooks.js +59 -9
- package/src/components/inserter/media-tab/media-list.js +2 -0
- package/src/components/inserter/media-tab/media-panel.js +256 -17
- package/src/components/inserter/media-tab/media-preview.js +34 -17
- package/src/components/inserter/media-tab/media-tab.js +20 -2
- package/src/components/inserter/media-tab/test/hooks.js +204 -0
- package/src/components/inserter/mobile-tab-navigation.js +6 -1
- package/src/components/inserter/no-results.js +2 -2
- package/src/components/inserter/preview-panel.js +1 -0
- package/src/components/inserter/style.scss +110 -1
- package/src/components/inserter-list-item/index.js +8 -2
- package/src/components/letter-spacing-control/README.md +0 -8
- package/src/components/letter-spacing-control/index.js +5 -23
- package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +7 -16
- package/src/components/line-height-control/stories/index.story.jsx +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-picker/test/index.js +3 -1
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +57 -20
- package/src/components/list-view/expander.js +5 -1
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/observe-typing/index.js +9 -4
- package/src/components/preset-input-control/custom-value-controls.js +0 -2
- package/src/components/preset-input-control/index.js +0 -2
- package/src/components/resolution-tool/index.js +0 -1
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/text-alignment-control/index.js +0 -1
- package/src/components/text-decoration-control/index.js +0 -1
- package/src/components/text-indent-control/index.js +7 -16
- package/src/components/text-transform-control/index.js +0 -1
- package/src/components/use-block-display-information/index.js +9 -13
- package/src/components/use-block-display-information/test/index.js +47 -9
- package/src/components/use-on-block-drop/index.js +4 -7
- package/src/components/use-resize-canvas/index.js +10 -71
- package/src/components/writing-mode-control/index.js +0 -1
- package/src/hooks/block-hooks.scss +15 -0
- package/src/hooks/font-size.js +0 -1
- package/src/hooks/layout.js +5 -4
- package/src/hooks/position.js +44 -23
- package/src/hooks/states.js +24 -26
- package/src/hooks/test/cross-origin-isolation.js +0 -4
- package/src/hooks/test/layout.js +75 -1
- package/src/layouts/constrained.js +51 -28
- package/src/layouts/flex.js +0 -3
- package/src/layouts/grid.js +59 -7
- package/src/layouts/test/constrained.js +91 -0
- package/src/layouts/test/grid.js +71 -0
- package/src/private-apis.js +4 -2
- package/src/store/actions.js +1 -0
- package/src/store/private-actions.js +31 -0
- package/src/store/private-keys.js +1 -1
- package/src/store/private-selectors.js +184 -11
- package/src/store/reducer.js +37 -2
- package/src/store/selectors.js +41 -0
- package/src/store/test/private-selectors.js +436 -10
- package/src/store/test/reducer.js +41 -13
- package/src/store/test/selectors.js +133 -0
- package/src/style.scss +1 -0
- package/src/components/use-resize-canvas/README.md +0 -37
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/preset-input-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon as WCIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t/>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,OAAQ;AAAA,YACR,KAAM,QAAQ,SAAS;AAAA,YACvB;AAAA,YACA,KAAM;AAAA,YACN,QAAS;AAAA,YACT,UAAW,CAAE,aACZ,SAAU,kBAAmB,QAAS,CAAE;AAAA,YAEzC,SAAU;AAAA,YACV,aAAc,CAAE,UAAW;AAG1B,oBAAM,YAAY,OAAO,aAAa,UAAU;AAChD,kBAAK,aAAa,UAAU,QAAY;AACvC,yBAAU,GAAI;AAAA,cACf;AAAA,YACD;AAAA,YACA;AAAA,YACA;AAAA,YACA,sBAAuB;AAAA,YACvB,MAAO;AAAA,YACP,OAAQ;AAAA,YACR,gBAAiB;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCustomSelectControl,\n\tIcon as WCIcon,\n\tRangeControl,\n\t__experimentalHStack as HStack,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { usePrevious } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { settings } from '@wordpress/icons';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tICON_SIZE,\n\tRANGE_CONTROL_MAX_SIZE,\n} from './constants';\nimport {\n\tgetCustomValueFromPreset,\n\tgetPresetValueFromCustomValue,\n\tgetSliderValueFromPreset,\n\tisValuePreset,\n} from './utils';\nimport CustomValueControls from './custom-value-controls';\n\n/**\n * PresetInputControl component for selecting preset values or entering custom values.\n *\n * Displays preset values as either a slider (for <= 8 presets) or a select dropdown.\n * Allows toggling to custom value mode with a UnitControl and RangeControl.\n * Handles unit tracking and conversion between preset and custom values.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.allowNegativeOnDrag Whether to allow negative values during drag operations.\n * @param {string} props.ariaLabel Accessible label for the control.\n * @param {string} props.className Optional CSS class name.\n * @param {Object} props.customValueSettings Optional custom value settings for max/steps per unit.\n * @param {boolean} props.disableCustomValues Whether to disable custom value input.\n * @param {Object} props.icon Icon to display alongside the control.\n * @param {boolean} props.isMixed Whether the current value is mixed (multiple values).\n * @param {number} props.minimumCustomValue Minimum allowed custom value.\n * @param {Function} props.onChange Callback when value changes.\n * @param {Function} props.onMouseOut Callback for mouse out events.\n * @param {Function} props.onMouseOver Callback for mouse over events.\n * @param {Function} props.onUnitChange Callback when unit changes.\n * @param {Array} props.presets Array of preset objects with name, slug, and size.\n * @param {string} props.presetType Type of preset (e.g., 'spacing', 'border-radius').\n * @param {string} props.selectedUnit Currently selected unit (e.g., 'px', 'em').\n * @param {boolean} props.showTooltip Whether to show tooltip on custom UnitControl.\n * @param {Array} props.units Array of available unit objects (can include max and step).\n * @param {string} props.value Current value (preset or custom).\n *\n * @return {Element} The PresetInputControl component.\n */\nexport default function PresetInputControl( {\n\tallowNegativeOnDrag = false,\n\tariaLabel,\n\tclassName: classNameProp,\n\tcustomValueSettings = CUSTOM_VALUE_SETTINGS,\n\tdisableCustomValues,\n\ticon,\n\tisMixed,\n\tvalue: valueProp,\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tonUnitChange,\n\tpresets = [],\n\tpresetType,\n\tselectedUnit,\n\tshowTooltip,\n\tunits,\n} ) {\n\tconst value = useMemo(\n\t\t() => getPresetValueFromCustomValue( valueProp, presets, presetType ),\n\t\t[ valueProp, presets, presetType ]\n\t);\n\n\tconst className = classNameProp ?? 'preset-input-control';\n\n\tconst marks = presets\n\t\t.slice( 1, presets.length - 1 )\n\t\t.map( ( _newValue, index ) => ( {\n\t\t\tvalue: index + 1,\n\t\t\tlabel: undefined,\n\t\t} ) );\n\tconst hasPresets = marks.length > 0;\n\tconst showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE;\n\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\tconst [ minValue, setMinValue ] = useState( minimumCustomValue );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! disableCustomValues &&\n\t\t\tvalue !== undefined &&\n\t\t\t! isValuePreset( value, presetType )\n\t);\n\n\tlet currentValue = null;\n\n\tconst previousValue = usePrevious( value );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! value &&\n\t\t\tpreviousValue !== value &&\n\t\t\t! isValuePreset( value, presetType ) &&\n\t\t\tshowCustomValueControl !== true\n\t\t) {\n\t\t\tsetShowCustomValueControl( true );\n\t\t}\n\t}, [ value, previousValue, presetType, showCustomValueControl ] );\n\n\tconst showCustomValueInSelectList =\n\t\t! showRangeControl &&\n\t\t! showCustomValueControl &&\n\t\tvalue !== undefined &&\n\t\t( ! isValuePreset( value, presetType ) ||\n\t\t\t( isValuePreset( value, presetType ) && isMixed ) );\n\n\tlet selectListOptions = presets;\n\tif ( showCustomValueInSelectList ) {\n\t\tselectListOptions = [\n\t\t\t...presets,\n\t\t\t{\n\t\t\t\tname: ! isMixed\n\t\t\t\t\t? // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px.\n\t\t\t\t\t sprintf( __( 'Custom (%s)' ), value )\n\t\t\t\t\t: __( 'Mixed' ),\n\t\t\t\tslug: 'custom',\n\t\t\t\tsize: value,\n\t\t\t},\n\t\t];\n\t\tcurrentValue = selectListOptions.length - 1;\n\t} else if ( ! isMixed ) {\n\t\tcurrentValue = ! showCustomValueControl\n\t\t\t? getSliderValueFromPreset( value, presets, presetType )\n\t\t\t: getCustomValueFromPreset( value, presets, presetType );\n\t}\n\n\tconst options = selectListOptions.map( ( size, index ) => ( {\n\t\tkey: index,\n\t\tname: size.name,\n\t} ) );\n\n\tconst resolvedPresetValue = isValuePreset( value, presetType )\n\t\t? getCustomValueFromPreset( value, presets, presetType )\n\t\t: value;\n\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( resolvedPresetValue );\n\n\tconst computedUnit = parsedUnit || selectedUnit || 'px';\n\n\t// Get step and max from units prop, falling back to customValueSettings\n\tconst unitConfig = units?.find( ( item ) => item.value === computedUnit );\n\tconst step =\n\t\tunitConfig?.step ?? customValueSettings[ computedUnit ]?.steps ?? 0.1;\n\tconst max =\n\t\tunitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;\n\n\tconst handleCustomValueChange = ( newValue ) => {\n\t\t// Treat empty or undefined as an explicit clear and propagate undefined.\n\t\tif ( newValue === undefined || newValue === '' ) {\n\t\t\tonChange( undefined );\n\t\t\treturn;\n\t\t}\n\n\t\t// Ignore non-numeric intermediate input (e.g. just a unit).\n\t\tif ( isNaN( parseFloat( newValue ) ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChange( newValue );\n\t};\n\tconst handleCustomValueSliderChange = ( next ) => {\n\t\tonChange( [ next, computedUnit ].join( '' ) );\n\t};\n\tconst customTooltipContent = ( newValue ) =>\n\t\tvalue === undefined ? undefined : presets[ newValue ]?.name;\n\n\tconst getNewPresetValue = ( next, controlType ) => {\n\t\tconst newValue = parseInt( next, 10 );\n\n\t\tif ( controlType === 'selectList' ) {\n\t\t\tif ( newValue === 0 && presets[ 0 ]?.slug === '0' ) {\n\t\t\t\treturn '0';\n\t\t\t}\n\t\t\tif ( newValue === 0 ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if ( newValue === 0 ) {\n\t\t\treturn '0';\n\t\t}\n\t\treturn `var:preset|${ presetType }|${ presets[ next ]?.slug }`;\n\t};\n\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ `preset-input-control__wrapper ${ className }__wrapper` }\n\t\t>\n\t\t\t{ icon && (\n\t\t\t\t<WCIcon\n\t\t\t\t\tclassName=\"preset-input-control__icon\"\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tsize={ ICON_SIZE }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ( ! hasPresets || showCustomValueControl ) && (\n\t\t\t\t<CustomValueControls\n\t\t\t\t\tallowNegativeOnDrag={ allowNegativeOnDrag }\n\t\t\t\t\tariaLabel={ ariaLabel }\n\t\t\t\t\tallPlaceholder={ allPlaceholder }\n\t\t\t\t\tminValue={ minValue }\n\t\t\t\t\tparsedQuantity={ parsedQuantity }\n\t\t\t\t\tcomputedUnit={ computedUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tisMixed={ isMixed }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tshowTooltip={ showTooltip }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\tonCustomValueChange={ handleCustomValueChange }\n\t\t\t\t\tonCustomValueSliderChange={ handleCustomValueSliderChange }\n\t\t\t\t\tonUnitChange={ onUnitChange }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\tsetMinValue={ setMinValue }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<RangeControl\n\t\t\t\t\taria-valuenow={ currentValue }\n\t\t\t\t\taria-valuetext={ presets[ currentValue ]?.name }\n\t\t\t\t\tclassName=\"preset-input-control__preset-range\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tmax={ presets.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\tonChange( getNewPresetValue( newValue ) )\n\t\t\t\t\t}\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\t\t// If mouse down is near start of range set initial value to 0, which\n\t\t\t\t\t\t// prevents the user have to drag right then left to get 0 setting.\n\t\t\t\t\t\tconst nearStart = event?.nativeEvent?.offsetX < 35;\n\t\t\t\t\t\tif ( nearStart && value === undefined ) {\n\t\t\t\t\t\t\tonChange( '0' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\trenderTooltipContent={ customTooltipContent }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tvalue={ currentValue }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! showRangeControl && ! showCustomValueControl && (\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\tclassName=\"preset-input-control__custom-select-control\"\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ ariaLabel }\n\t\t\t\t\tonBlur={ onMouseOut }\n\t\t\t\t\tonChange={ ( selection ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshowCustomValueInSelectList &&\n\t\t\t\t\t\t\tselection.selectedItem.key === options.length - 1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsetShowCustomValueControl( true );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tgetNewPresetValue(\n\t\t\t\t\t\t\t\t\tselection.selectedItem.key,\n\t\t\t\t\t\t\t\t\t'selectList'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tonFocus={ onMouseOver }\n\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\t// passing empty string as a fallback to continue using the\n\t\t\t\t\t\t// component in controlled mode\n\t\t\t\t\t\toptions.find(\n\t\t\t\t\t\t\t( option ) => option.key === currentValue\n\t\t\t\t\t\t) || ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasPresets && ! disableCustomValues && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"preset-input-control__custom-toggle\"\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\ticonSize={ ICON_SIZE }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use preset' )\n\t\t\t\t\t\t\t: __( 'Set custom value' )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</HStack>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAOO;AACP,qBAA4B;AAC5B,kBAA4B;AAC5B,mBAAyB;AACzB,qBAA6C;AAK7C,uBAIO;AACP,mBAKO;AACP,mCAAgC;AAgL9B;AAjJa,SAAR,mBAAqC;AAAA,EAC3C,sBAAsB;AAAA,EACtB;AAAA,EACA,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,YAAQ;AAAA,IACb,UAAM,4CAA+B,WAAW,SAAS,UAAW;AAAA,IACpE,CAAE,WAAW,SAAS,UAAW;AAAA,EAClC;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAQ,QACZ,MAAO,GAAG,QAAQ,SAAS,CAAE,EAC7B,IAAK,CAAE,WAAW,WAAa;AAAA,IAC/B,OAAO,QAAQ;AAAA,IACf,OAAO;AAAA,EACR,EAAI;AACL,QAAM,aAAa,MAAM,SAAS;AAClC,QAAM,mBAAmB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AGC,QAAQ;AAAA,gBACP,CAAE,WAAY,OAAO,QAAQ;AAAA,cAC9B,KAAK;AAAA;AAAA;AAAA,QAEP;AAAA,QAEC,cAAc,CAAE,uBACjB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,UAAW;AAAA,YACX,WAAY;AAAA,YACZ,OACC,6BACG,gBAAI,YAAa,QACjB,gBAAI,kBAAmB;AAAA,YAE3B,SAAU,MAAM;AACf,wCAA2B,CAAE,sBAAuB;AAAA,YACrD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": ["parseQuantityAndUnitFromRawValue", "HStack", "WCIcon", "CustomValueControls"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/resolution-tool/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tSelectControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\nconst DEFAULT_SIZE_OPTIONS = [\n\t{\n\t\tlabel: _x( 'Thumbnail', 'Image size option for resolution control' ),\n\t\tvalue: 'thumbnail',\n\t},\n\t{\n\t\tlabel: _x( 'Medium', 'Image size option for resolution control' ),\n\t\tvalue: 'medium',\n\t},\n\t{\n\t\tlabel: _x( 'Large', 'Image size option for resolution control' ),\n\t\tvalue: 'large',\n\t},\n\t{\n\t\tlabel: _x( 'Full Size', 'Image size option for resolution control' ),\n\t\tvalue: 'full',\n\t},\n];\n\nexport default function ResolutionTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SIZE_OPTIONS,\n\tdefaultValue = DEFAULT_SIZE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n\tresetAllFilter,\n} ) {\n\tconst displayValue = value ?? defaultValue;\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\toptions={ options }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ __( 'Select the size of the source image.' ) }\n\t\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,kBAAuB;AAwCpB;AAtCH,IAAM,uBAAuB;AAAA,EAC5B;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,UAAU,0CAA2C;AAAA,IAChE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,SAAS,0CAA2C;AAAA,IAC/D,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AACD;AAEe,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,eAAe,qBAAsB,CAAE,EAAE;AAAA,EACzC,mBAAmB;AAAA,EACnB;AACD,GAAI;AACH,QAAM,eAAe,SAAS;AAC9B,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,UAAW,MAAM,iBAAiB;AAAA,MAClC,WAAQ,gBAAI,YAAa;AAAA,MACzB,YAAa,MAAM,SAAU,YAAa;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,WAAQ,gBAAI,YAAa;AAAA,UACzB,OAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,UAAO,gBAAI,sCAAuC;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tSelectControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\n\nconst DEFAULT_SIZE_OPTIONS = [\n\t{\n\t\tlabel: _x( 'Thumbnail', 'Image size option for resolution control' ),\n\t\tvalue: 'thumbnail',\n\t},\n\t{\n\t\tlabel: _x( 'Medium', 'Image size option for resolution control' ),\n\t\tvalue: 'medium',\n\t},\n\t{\n\t\tlabel: _x( 'Large', 'Image size option for resolution control' ),\n\t\tvalue: 'large',\n\t},\n\t{\n\t\tlabel: _x( 'Full Size', 'Image size option for resolution control' ),\n\t\tvalue: 'full',\n\t},\n];\n\nexport default function ResolutionTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SIZE_OPTIONS,\n\tdefaultValue = DEFAULT_SIZE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n\tresetAllFilter,\n} ) {\n\tconst displayValue = value ?? defaultValue;\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tpanelId={ panelId }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Resolution' ) }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\toptions={ options }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ __( 'Select the size of the source image.' ) }\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAGO;AACP,kBAAuB;AAwCpB;AAtCH,IAAM,uBAAuB;AAAA,EAC5B;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,UAAU,0CAA2C;AAAA,IAChE,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,SAAS,0CAA2C;AAAA,IAC/D,OAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,aAAa,0CAA2C;AAAA,IACnE,OAAO;AAAA,EACR;AACD;AAEe,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,eAAe,qBAAsB,CAAE,EAAE;AAAA,EACzC,mBAAmB;AAAA,EACnB;AACD,GAAI;AACH,QAAM,eAAe,SAAS;AAC9B,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,UAAW,MAAM,iBAAiB;AAAA,MAClC,WAAQ,gBAAI,YAAa;AAAA,MACzB,YAAa,MAAM,SAAU,YAAa;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,WAAQ,gBAAI,YAAa;AAAA,UACzB,OAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,UAAO,gBAAI,sCAAuC;AAAA;AAAA,MACnD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["ToolsPanelItem"]
|
|
7
7
|
}
|
|
@@ -81,7 +81,6 @@ function TextAlignmentControl({
|
|
|
81
81
|
import_components.__experimentalToggleGroupControl,
|
|
82
82
|
{
|
|
83
83
|
isDeselectable: true,
|
|
84
|
-
__next40pxDefaultSize: true,
|
|
85
84
|
label: (0, import_i18n.__)("Text alignment"),
|
|
86
85
|
className: (0, import_clsx.default)(
|
|
87
86
|
"block-editor-text-alignment-control",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/text-alignment-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\talignLeft,\n\talignCenter,\n\talignRight,\n\talignJustify,\n} from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst TEXT_ALIGNMENT_OPTIONS = [\n\t{\n\t\tlabel: __( 'Align text left' ),\n\t\tvalue: 'left',\n\t\ticon: alignLeft,\n\t},\n\t{\n\t\tlabel: __( 'Align text center' ),\n\t\tvalue: 'center',\n\t\ticon: alignCenter,\n\t},\n\t{\n\t\tlabel: __( 'Align text right' ),\n\t\tvalue: 'right',\n\t\ticon: alignRight,\n\t},\n\t{\n\t\tlabel: __( 'Justify text' ),\n\t\tvalue: 'justify',\n\t\ticon: alignJustify,\n\t},\n];\n\nconst DEFAULT_OPTIONS = [ 'left', 'center', 'right' ];\n\n/**\n * Control to facilitate text alignment selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected text alignment.\n * @param {Function} props.onChange Handles change in text alignment selection.\n * @param {string[]} props.options Array of text alignment options to display.\n *\n * @return {Element} Text alignment control.\n */\nexport default function TextAlignmentControl( {\n\tclassName,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_OPTIONS,\n} ) {\n\tconst validOptions = useMemo(\n\t\t() =>\n\t\t\tTEXT_ALIGNMENT_OPTIONS.filter( ( option ) =>\n\t\t\t\toptions.includes( option.value )\n\t\t\t),\n\t\t[ options ]\n\t);\n\n\tif ( ! validOptions.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,mBAKO;AACP,qBAAwB;AACxB,wBAGO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\talignLeft,\n\talignCenter,\n\talignRight,\n\talignJustify,\n} from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst TEXT_ALIGNMENT_OPTIONS = [\n\t{\n\t\tlabel: __( 'Align text left' ),\n\t\tvalue: 'left',\n\t\ticon: alignLeft,\n\t},\n\t{\n\t\tlabel: __( 'Align text center' ),\n\t\tvalue: 'center',\n\t\ticon: alignCenter,\n\t},\n\t{\n\t\tlabel: __( 'Align text right' ),\n\t\tvalue: 'right',\n\t\ticon: alignRight,\n\t},\n\t{\n\t\tlabel: __( 'Justify text' ),\n\t\tvalue: 'justify',\n\t\ticon: alignJustify,\n\t},\n];\n\nconst DEFAULT_OPTIONS = [ 'left', 'center', 'right' ];\n\n/**\n * Control to facilitate text alignment selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected text alignment.\n * @param {Function} props.onChange Handles change in text alignment selection.\n * @param {string[]} props.options Array of text alignment options to display.\n *\n * @return {Element} Text alignment control.\n */\nexport default function TextAlignmentControl( {\n\tclassName,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_OPTIONS,\n} ) {\n\tconst validOptions = useMemo(\n\t\t() =>\n\t\t\tTEXT_ALIGNMENT_OPTIONS.filter( ( option ) =>\n\t\t\t\toptions.includes( option.value )\n\t\t\t),\n\t\t[ options ]\n\t);\n\n\tif ( ! validOptions.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\tlabel={ __( 'Text alignment' ) }\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-text-alignment-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ ( newValue ) => {\n\t\t\t\tonChange( newValue === value ? undefined : newValue );\n\t\t\t} }\n\t\t>\n\t\t\t{ validOptions.map( ( option ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\tvalue={ option.value }\n\t\t\t\t\t\ticon={ option.icon }\n\t\t\t\t\t\tlabel={ option.label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,mBAKO;AACP,qBAAwB;AACxB,wBAGO;AAuEF;AArEL,IAAM,yBAAyB;AAAA,EAC9B;AAAA,IACC,WAAO,gBAAI,iBAAkB;AAAA,IAC7B,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,mBAAoB;AAAA,IAC/B,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,kBAAmB;AAAA,IAC9B,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,cAAe;AAAA,IAC1B,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AACD;AAEA,IAAM,kBAAkB,CAAE,QAAQ,UAAU,OAAQ;AAarC,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AACX,GAAI;AACH,QAAM,mBAAe;AAAA,IACpB,MACC,uBAAuB;AAAA,MAAQ,CAAE,WAChC,QAAQ,SAAU,OAAO,KAAM;AAAA,IAChC;AAAA,IACD,CAAE,OAAQ;AAAA,EACX;AAEA,MAAK,CAAE,aAAa,QAAS;AAC5B,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,gBAAc;AAAA,MACd,WAAQ,gBAAI,gBAAiB;AAAA,MAC7B,eAAY,YAAAC;AAAA,QACX;AAAA,QACA;AAAA,MACD;AAAA,MACA;AAAA,MACA,UAAW,CAAE,aAAc;AAC1B,iBAAU,aAAa,QAAQ,SAAY,QAAS;AAAA,MACrD;AAAA,MAEE,uBAAa,IAAK,CAAE,WAAY;AACjC,eACC;AAAA,UAAC,kBAAAC;AAAA,UAAA;AAAA,YAEA,OAAQ,OAAO;AAAA,YACf,MAAO,OAAO;AAAA,YACd,OAAQ,OAAO;AAAA;AAAA,UAHT,OAAO;AAAA,QAId;AAAA,MAEF,CAAE;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": ["ToggleGroupControl", "clsx", "ToggleGroupControlOptionIcon"]
|
|
7
7
|
}
|
|
@@ -64,7 +64,6 @@ function TextDecorationControl({
|
|
|
64
64
|
import_components.__experimentalToggleGroupControl,
|
|
65
65
|
{
|
|
66
66
|
isDeselectable: true,
|
|
67
|
-
__next40pxDefaultSize: true,
|
|
68
67
|
label: (0, import_i18n.__)("Decoration"),
|
|
69
68
|
className: (0, import_clsx.default)(
|
|
70
69
|
"block-editor-text-decoration-control",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/text-decoration-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { reset, formatStrikethrough, formatUnderline } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst TEXT_DECORATIONS = [\n\t{\n\t\tlabel: __( 'None' ),\n\t\tvalue: 'none',\n\t\ticon: reset,\n\t},\n\t{\n\t\tlabel: __( 'Underline' ),\n\t\tvalue: 'underline',\n\t\ticon: formatUnderline,\n\t},\n\t{\n\t\tlabel: __( 'Strikethrough' ),\n\t\tvalue: 'line-through',\n\t\ticon: formatStrikethrough,\n\t},\n];\n\n/**\n * Control to facilitate text decoration selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text decoration.\n * @param {Function} props.onChange Handles change in text decoration selection.\n * @param {string} props.className Additional class name to apply.\n *\n * @return {Element} Text decoration control.\n */\nexport default function TextDecorationControl( {\n\tvalue,\n\tonChange,\n\tclassName,\n} ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,mBAA4D;AAC5D,kBAAmB;AACnB,wBAGO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { reset, formatStrikethrough, formatUnderline } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst TEXT_DECORATIONS = [\n\t{\n\t\tlabel: __( 'None' ),\n\t\tvalue: 'none',\n\t\ticon: reset,\n\t},\n\t{\n\t\tlabel: __( 'Underline' ),\n\t\tvalue: 'underline',\n\t\ticon: formatUnderline,\n\t},\n\t{\n\t\tlabel: __( 'Strikethrough' ),\n\t\tvalue: 'line-through',\n\t\ticon: formatStrikethrough,\n\t},\n];\n\n/**\n * Control to facilitate text decoration selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text decoration.\n * @param {Function} props.onChange Handles change in text decoration selection.\n * @param {string} props.className Additional class name to apply.\n *\n * @return {Element} Text decoration control.\n */\nexport default function TextDecorationControl( {\n\tvalue,\n\tonChange,\n\tclassName,\n} ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\tlabel={ __( 'Decoration' ) }\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-text-decoration-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ ( newValue ) => {\n\t\t\t\tonChange( newValue === value ? undefined : newValue );\n\t\t\t} }\n\t\t>\n\t\t\t{ TEXT_DECORATIONS.map( ( option ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\tvalue={ option.value }\n\t\t\t\t\t\ticon={ option.icon }\n\t\t\t\t\t\tlabel={ option.label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,mBAA4D;AAC5D,kBAAmB;AACnB,wBAGO;AAkDF;AAhDL,IAAM,mBAAmB;AAAA,EACxB;AAAA,IACC,WAAO,gBAAI,MAAO;AAAA,IAClB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,WAAY;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,eAAgB;AAAA,IAC3B,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AACD;AAYe,SAAR,sBAAwC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,gBAAc;AAAA,MACd,WAAQ,gBAAI,YAAa;AAAA,MACzB,eAAY,YAAAC;AAAA,QACX;AAAA,QACA;AAAA,MACD;AAAA,MACA;AAAA,MACA,UAAW,CAAE,aAAc;AAC1B,iBAAU,aAAa,QAAQ,SAAY,QAAS;AAAA,MACrD;AAAA,MAEE,2BAAiB,IAAK,CAAE,WAAY;AACrC,eACC;AAAA,UAAC,kBAAAC;AAAA,UAAA;AAAA,YAEA,OAAQ,OAAO;AAAA,YACf,MAAO,OAAO;AAAA,YACd,OAAQ,OAAO;AAAA;AAAA,UAHT,OAAO;AAAA,QAId;AAAA,MAEF,CAAE;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": ["ToggleGroupControl", "clsx", "ToggleGroupControlOptionIcon"]
|
|
7
7
|
}
|
|
@@ -28,7 +28,6 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
28
28
|
var import_use_settings = require("../use-settings/index.cjs");
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
function TextIndentControl({
|
|
31
|
-
__next40pxDefaultSize = false,
|
|
32
31
|
value,
|
|
33
32
|
onChange,
|
|
34
33
|
__unstableInputWidth = "60px",
|
|
@@ -59,8 +58,6 @@ function TextIndentControl({
|
|
|
59
58
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
59
|
import_components.__experimentalUnitControl,
|
|
61
60
|
{
|
|
62
|
-
__next40pxDefaultSize,
|
|
63
|
-
__shouldNotWarnDeprecated36pxSize: true,
|
|
64
61
|
...otherProps,
|
|
65
62
|
label: (0, import_i18n.__)("Line indent"),
|
|
66
63
|
value,
|
|
@@ -77,14 +74,11 @@ function TextIndentControl({
|
|
|
77
74
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
75
|
import_components.__experimentalUnitControl,
|
|
79
76
|
{
|
|
80
|
-
__next40pxDefaultSize,
|
|
81
|
-
__shouldNotWarnDeprecated36pxSize: true,
|
|
82
77
|
label: (0, import_i18n.__)("Line indent"),
|
|
83
78
|
labelPosition: "top",
|
|
84
79
|
hideLabelFromVision: true,
|
|
85
80
|
value,
|
|
86
81
|
onChange,
|
|
87
|
-
size: otherProps.size,
|
|
88
82
|
units,
|
|
89
83
|
__unstableInputWidth,
|
|
90
84
|
min: 0
|
|
@@ -93,8 +87,6 @@ function TextIndentControl({
|
|
|
93
87
|
withSlider && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalSpacer, { marginX: 2, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
94
88
|
import_components.RangeControl,
|
|
95
89
|
{
|
|
96
|
-
__next40pxDefaultSize,
|
|
97
|
-
__shouldNotWarnDeprecated36pxSize: true,
|
|
98
90
|
label: (0, import_i18n.__)("Line indent"),
|
|
99
91
|
hideLabelFromVision: true,
|
|
100
92
|
value: valueQuantity,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/text-indent-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalView as View,\n\tRangeControl,\n\t__experimentalSpacer as Spacer,\n\tFlex,\n\tFlexItem,\n\tBaseControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../components/use-settings';\n\n/**\n * Control for line text indent.\n *\n * @param {Object} props
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAUO;AACP,kBAAmB;AAKnB,0BAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalView as View,\n\tRangeControl,\n\t__experimentalSpacer as Spacer,\n\tFlex,\n\tFlexItem,\n\tBaseControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../../components/use-settings';\n\n/**\n * Control for line text indent.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected text indent.\n * @param {Function} props.onChange Handles change in text indent selection.\n * @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.\n * @param {boolean} props.withSlider Whether to show the slider control.\n * @param {boolean} props.hasBottomMargin Whether to add bottom margin below the control.\n * @param {string} props.help Help text to display below the control.\n *\n * @return {Element} Text indent control.\n */\nexport default function TextIndentControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n\twithSlider = false,\n\thasBottomMargin = false,\n\thelp,\n\t...otherProps\n} ) {\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'ch',\n\t\t\t'%',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 16, em: 2, rem: 2, ch: 2 },\n\t} );\n\n\tconst [ valueQuantity, valueUnit ] = parseQuantityAndUnitFromRawValue(\n\t\tvalue,\n\t\tunits\n\t);\n\tconst isValueUnitRelative =\n\t\t!! valueUnit &&\n\t\t[ 'em', 'rem', '%', 'ch', 'vw', 'vh' ].includes( valueUnit );\n\n\tif ( ! withSlider ) {\n\t\treturn (\n\t\t\t<UnitControl\n\t\t\t\t{ ...otherProps }\n\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\tvalue={ value }\n\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\tunits={ units }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thelp={ help }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<View style={ hasBottomMargin ? { marginBottom: 12 } : undefined }>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Line indent' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t{ withSlider && (\n\t\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t\t<Spacer marginX={ 2 } marginBottom={ 0 }>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Line indent' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ valueQuantity }\n\t\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\tif ( newValue === undefined ) {\n\t\t\t\t\t\t\t\t\t\tonChange?.( undefined );\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tonChange?.(\n\t\t\t\t\t\t\t\t\t\t\tnewValue + ( valueUnit ?? 'px' )\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} }\n\t\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\t\tmax={ isValueUnitRelative ? 10 : 100 }\n\t\t\t\t\t\t\t\tstep={ isValueUnitRelative ? 0.1 : 1 }\n\t\t\t\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t\t{ help && (\n\t\t\t\t<p className=\"components-base-control__help\">{ help }</p>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAUO;AACP,kBAAmB;AAKnB,0BAA4B;AAgDzB;AAjCY,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,uBAAuB;AAAA,EACvB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,CAAE,cAAe,QAAI,iCAAa,eAAgB;AACxD,QAAM,YAAQ,kBAAAA,8BAAgB;AAAA,IAC7B,gBAAgB,kBAAkB;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,eAAe,EAAE,IAAI,IAAI,IAAI,GAAG,KAAK,GAAG,IAAI,EAAE;AAAA,EAC/C,CAAE;AAEF,QAAM,CAAE,eAAe,SAAU,QAAI,kBAAAC;AAAA,IACpC;AAAA,IACA;AAAA,EACD;AACA,QAAM,sBACL,CAAC,CAAE,aACH,CAAE,MAAM,OAAO,KAAK,MAAM,MAAM,IAAK,EAAE,SAAU,SAAU;AAE5D,MAAK,CAAE,YAAa;AACnB,WACC;AAAA,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formControl({ className, value, onChange }) {
|
|
|
65
65
|
import_components.__experimentalToggleGroupControl,
|
|
66
66
|
{
|
|
67
67
|
isDeselectable: true,
|
|
68
|
-
__next40pxDefaultSize: true,
|
|
69
68
|
label: (0, import_i18n.__)("Letter case"),
|
|
70
69
|
className: (0, import_clsx.default)(
|
|
71
70
|
"block-editor-text-transform-control",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/text-transform-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\treset,\n\tformatCapitalize,\n\tformatLowercase,\n\tformatUppercase,\n} from '@wordpress/icons';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst TEXT_TRANSFORMS = [\n\t{\n\t\tlabel: __( 'None' ),\n\t\tvalue: 'none',\n\t\ticon: reset,\n\t},\n\t{\n\t\tlabel: __( 'Uppercase' ),\n\t\tvalue: 'uppercase',\n\t\ticon: formatUppercase,\n\t},\n\t{\n\t\tlabel: __( 'Lowercase' ),\n\t\tvalue: 'lowercase',\n\t\ticon: formatLowercase,\n\t},\n\t{\n\t\tlabel: __( 'Capitalize' ),\n\t\tvalue: 'capitalize',\n\t\ticon: formatCapitalize,\n\t},\n];\n\n/**\n * Control to facilitate text transform selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected text transform.\n * @param {Function} props.onChange Handles change in text transform selection.\n *\n * @return {Element} Text transform control.\n */\nexport default function TextTransformControl( { className, value, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,mBAKO;AACP,wBAGO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\treset,\n\tformatCapitalize,\n\tformatLowercase,\n\tformatUppercase,\n} from '@wordpress/icons';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst TEXT_TRANSFORMS = [\n\t{\n\t\tlabel: __( 'None' ),\n\t\tvalue: 'none',\n\t\ticon: reset,\n\t},\n\t{\n\t\tlabel: __( 'Uppercase' ),\n\t\tvalue: 'uppercase',\n\t\ticon: formatUppercase,\n\t},\n\t{\n\t\tlabel: __( 'Lowercase' ),\n\t\tvalue: 'lowercase',\n\t\ticon: formatLowercase,\n\t},\n\t{\n\t\tlabel: __( 'Capitalize' ),\n\t\tvalue: 'capitalize',\n\t\ticon: formatCapitalize,\n\t},\n];\n\n/**\n * Control to facilitate text transform selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected text transform.\n * @param {Function} props.onChange Handles change in text transform selection.\n *\n * @return {Element} Text transform control.\n */\nexport default function TextTransformControl( { className, value, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\tlabel={ __( 'Letter case' ) }\n\t\t\tclassName={ clsx(\n\t\t\t\t'block-editor-text-transform-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ ( newValue ) => {\n\t\t\t\tonChange( newValue === value ? undefined : newValue );\n\t\t\t} }\n\t\t>\n\t\t\t{ TEXT_TRANSFORMS.map( ( option ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\tvalue={ option.value }\n\t\t\t\t\t\ticon={ option.icon }\n\t\t\t\t\t\tlabel={ option.label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,mBAKO;AACP,wBAGO;AAmDF;AAjDL,IAAM,kBAAkB;AAAA,EACvB;AAAA,IACC,WAAO,gBAAI,MAAO;AAAA,IAClB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,WAAY;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,WAAY;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,WAAO,gBAAI,YAAa;AAAA,IACxB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AACD;AAYe,SAAR,qBAAuC,EAAE,WAAW,OAAO,SAAS,GAAI;AAC9E,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,gBAAc;AAAA,MACd,WAAQ,gBAAI,aAAc;AAAA,MAC1B,eAAY,YAAAC;AAAA,QACX;AAAA,QACA;AAAA,MACD;AAAA,MACA;AAAA,MACA,UAAW,CAAE,aAAc;AAC1B,iBAAU,aAAa,QAAQ,SAAY,QAAS;AAAA,MACrD;AAAA,MAEE,0BAAgB,IAAK,CAAE,WAAY;AACpC,eACC;AAAA,UAAC,kBAAAC;AAAA,UAAA;AAAA,YAEA,OAAQ,OAAO;AAAA,YACf,MAAO,OAAO;AAAA,YACd,OAAQ,OAAO;AAAA;AAAA,UAHT,OAAO;AAAA,QAId;AAAA,MAEF,CAAE;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": ["ToggleGroupControl", "clsx", "ToggleGroupControlOptionIcon"]
|
|
7
7
|
}
|
|
@@ -29,7 +29,6 @@ var import_i18n = require("@wordpress/i18n");
|
|
|
29
29
|
var import_icons = require("@wordpress/icons");
|
|
30
30
|
var import_store = require("../../store/index.cjs");
|
|
31
31
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
32
|
-
var import_private_keys = require("../../store/private-keys.cjs");
|
|
33
32
|
function getPositionTypeLabel(attributes) {
|
|
34
33
|
const positionType = attributes?.style?.position?.type;
|
|
35
34
|
if (positionType === "sticky") {
|
|
@@ -50,8 +49,8 @@ function useBlockDisplayInformation(clientId) {
|
|
|
50
49
|
const {
|
|
51
50
|
getBlockName,
|
|
52
51
|
getBlockAttributes,
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
getBlock,
|
|
53
|
+
__experimentalGetParsedPattern
|
|
55
54
|
} = blockEditorSelect;
|
|
56
55
|
const { getBlockType, getActiveBlockVariation } = select(import_blocks.store);
|
|
57
56
|
const blockName = getBlockName(clientId);
|
|
@@ -60,11 +59,9 @@ function useBlockDisplayInformation(clientId) {
|
|
|
60
59
|
return null;
|
|
61
60
|
}
|
|
62
61
|
const attributes = getBlockAttributes(clientId);
|
|
63
|
-
const {
|
|
64
|
-
const isIsolatedEditor = !!getSettings()?.[import_private_keys.isIsolatedEditorKey];
|
|
62
|
+
const { isSectionBlock } = (0, import_lock_unlock.unlock)(blockEditorSelect);
|
|
65
63
|
const patternName = attributes?.metadata?.patternName;
|
|
66
|
-
|
|
67
|
-
if (patternName && !isEditedContentOnlySection && !isIsolatedEditor) {
|
|
64
|
+
if (patternName && isSectionBlock(clientId)) {
|
|
68
65
|
const pattern = __experimentalGetParsedPattern(patternName);
|
|
69
66
|
const positionLabel2 = getPositionTypeLabel(attributes);
|
|
70
67
|
return {
|
|
@@ -78,7 +75,12 @@ function useBlockDisplayInformation(clientId) {
|
|
|
78
75
|
name: pattern?.title || attributes?.metadata?.name
|
|
79
76
|
};
|
|
80
77
|
}
|
|
81
|
-
const match = getActiveBlockVariation(
|
|
78
|
+
const match = getActiveBlockVariation(
|
|
79
|
+
blockName,
|
|
80
|
+
attributes,
|
|
81
|
+
void 0,
|
|
82
|
+
getBlock?.(clientId)?.innerContent
|
|
83
|
+
);
|
|
82
84
|
const isSynced = (0, import_blocks.isReusableBlock)(blockType) || (0, import_blocks.isTemplatePart)(blockType);
|
|
83
85
|
const syncedTitle = isSynced ? (0, import_blocks.__experimentalGetBlockLabel)(blockType, attributes) : void 0;
|
|
84
86
|
const title = syncedTitle || blockType.title;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-block-display-information/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,oBAKO;AACP,kBAAmB;AACnB,mBAAuB;AAKvB,mBAA0C;AAC1C,yBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlock,\n\t\t\t\t__experimentalGetParsedPattern,\n\t\t\t} = blockEditorSelect;\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst { isSectionBlock } = unlock( blockEditorSelect );\n\n\t\t\t// Check if this block is a pattern\n\t\t\tconst patternName = attributes?.metadata?.patternName;\n\n\t\t\tif ( patternName && isSectionBlock( clientId ) ) {\n\t\t\t\tconst pattern = __experimentalGetParsedPattern( patternName );\n\t\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\t\treturn {\n\t\t\t\t\tisSynced: false,\n\t\t\t\t\ttitle: __( 'Pattern' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\tpattern?.description || __( 'A block pattern.' ),\n\t\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\t\tpositionLabel,\n\t\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\t\tname: pattern?.title || attributes?.metadata?.name,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst match = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tattributes,\n\t\t\t\tundefined,\n\t\t\t\tgetBlock?.( clientId )?.innerContent\n\t\t\t);\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) {\n\t\t\t\treturn blockTypeInfo;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,oBAKO;AACP,kBAAmB;AACnB,mBAAuB;AAKvB,mBAA0C;AAC1C,yBAAuB;AAuBvB,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAAU;AAElD,MAAK,iBAAiB,UAAW;AAChC,eAAO,gBAAI,QAAS;AAAA,EACrB;AAEA,MAAK,iBAAiB,SAAU;AAC/B,eAAO,gBAAI,OAAQ;AAAA,EACpB;AAEA,SAAO;AACR;AAiBe,SAAR,2BAA6C,UAAW;AAC9D,aAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AACA,YAAM,oBAAoB,OAAQ,aAAAA,KAAiB;AACnD,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI;AACJ,YAAM,EAAE,cAAc,wBAAwB,IAC7C,OAAQ,cAAAC,KAAY;AACrB,YAAM,YAAY,aAAc,QAAS;AACzC,YAAM,YAAY,aAAc,SAAU;AAC1C,UAAK,CAAE,WAAY;AAClB,eAAO;AAAA,MACR;AACA,YAAM,aAAa,mBAAoB,QAAS;AAChD,YAAM,EAAE,eAAe,QAAI,2BAAQ,iBAAkB;AAGrD,YAAM,cAAc,YAAY,UAAU;AAE1C,UAAK,eAAe,eAAgB,QAAS,GAAI;AAChD,cAAM,UAAU,+BAAgC,WAAY;AAC5D,cAAMC,iBAAgB,qBAAsB,UAAW;AACvD,eAAO;AAAA,UACN,UAAU;AAAA,UACV,WAAO,gBAAI,SAAU;AAAA,UACrB,MAAM;AAAA,UACN,aACC,SAAS,mBAAe,gBAAI,kBAAmB;AAAA,UAChD,QAAQ,YAAY;AAAA,UACpB,eAAAA;AAAA,UACA,cAAc,YAAY,OAAO,UAAU;AAAA,UAC3C,MAAM,SAAS,SAAS,YAAY,UAAU;AAAA,QAC/C;AAAA,MACD;AAEA,YAAM,QAAQ;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAY,QAAS,GAAG;AAAA,MACzB;AACA,YAAM,eACL,+BAAiB,SAAU,SAAK,8BAAgB,SAAU;AAC3D,YAAM,cAAc,eACjB,cAAAC,6BAAe,WAAW,UAAW,IACrC;AACH,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,gBAAgB,qBAAsB,UAAW;AACvD,YAAM,gBAAgB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,QACvB,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AACA,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,QACN;AAAA,QACA,OAAO,MAAM,SAAS,UAAU;AAAA,QAChC,MAAM,MAAM,QAAQ,UAAU;AAAA,QAC9B,aAAa,MAAM,eAAe,UAAU;AAAA,QAC5C,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;",
|
|
6
6
|
"names": ["blockEditorStore", "blocksStore", "positionLabel", "getBlockLabel"]
|
|
7
7
|
}
|
|
@@ -160,13 +160,9 @@ function useOnBlockDrop(targetRootClientId, targetBlockIndex, options = {}) {
|
|
|
160
160
|
} else {
|
|
161
161
|
blocks.unshift(targetBlock);
|
|
162
162
|
}
|
|
163
|
-
const groupInnerBlocks = blocks.map(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
block.attributes,
|
|
167
|
-
block.innerBlocks
|
|
168
|
-
);
|
|
169
|
-
});
|
|
163
|
+
const groupInnerBlocks = blocks.map(
|
|
164
|
+
(block) => (0, import_blocks.__experimentalCloneSanitizedBlock)(block)
|
|
165
|
+
);
|
|
170
166
|
const areAllImages = blocks.every((block) => {
|
|
171
167
|
return block.name === "core/image";
|
|
172
168
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-on-block-drop/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) => {\n\t\t\t\t\treturn createBlock(\n\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\t__experimentalCloneSanitizedBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) =>\n\t\t\t\t\t__experimentalCloneSanitizedBlock( block )\n\t\t\t\t);\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAQO;AACP,kBAAoD;AACpD,iBAAyC;AAKzC,mBAA0C;AAYnC,SAAS,eAAgB,OAAQ;AACvC,MAAI,SAAS;AAAA,IACZ,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAEA,MAAK,CAAE,MAAM,cAAe;AAC3B,WAAO;AAAA,EACR;AAEA,MAAI;AACH,aAAS,OAAO;AAAA,MACf;AAAA,MACA,KAAK,MAAO,MAAM,aAAa,QAAS,WAAY,CAAE;AAAA,IACvD;AAAA,EACD,QAAQ;AACP,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAgBO,SAAS,YACf,oBACA,kBACA,eACA,2BACA,YACA,uBACA,oBACA,WACA,UACC;AACD,SAAO,CAAE,UAAW;AACnB,UAAM;AAAA,MACL,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,MAAM;AAAA,MACN;AAAA,IACD,IAAI,eAAgB,KAAM;AAG1B,QAAK,aAAa,YAAa;AAC9B,yBAAmB;AACnB,YAAM,iBAAiB,OAAO;AAAA,QAAK,CAAE,cACpC,0BAAY,KAAM;AAAA,M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;AACnB,UAAM,YAAQ,qCAA0B,MAAM,YAAa;AAC3D,UAAM,OAAO,MAAM,aAAa,QAAS,WAAY;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorStore", "blocksStore"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// packages/block-editor/src/components/use-resize-canvas/index.js
|
|
@@ -23,58 +33,11 @@ __export(use_resize_canvas_exports, {
|
|
|
23
33
|
default: () => useResizeCanvas
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(use_resize_canvas_exports);
|
|
26
|
-
var
|
|
27
|
-
function useResizeCanvas(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
const resizeListener = () => updateActualWidth(window.innerWidth);
|
|
34
|
-
window.addEventListener("resize", resizeListener);
|
|
35
|
-
return () => {
|
|
36
|
-
window.removeEventListener("resize", resizeListener);
|
|
37
|
-
};
|
|
38
|
-
}, [deviceType]);
|
|
39
|
-
const getCanvasWidth = (device) => {
|
|
40
|
-
let deviceWidth;
|
|
41
|
-
switch (device) {
|
|
42
|
-
case "Tablet":
|
|
43
|
-
deviceWidth = 782 - 1;
|
|
44
|
-
break;
|
|
45
|
-
case "Mobile":
|
|
46
|
-
deviceWidth = 480 - 1;
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return deviceWidth < actualWidth ? deviceWidth : actualWidth;
|
|
52
|
-
};
|
|
53
|
-
const contentInlineStyles = (device) => {
|
|
54
|
-
const height = device === "Mobile" ? "768px" : "1024px";
|
|
55
|
-
const marginVertical = "40px";
|
|
56
|
-
const marginHorizontal = "auto";
|
|
57
|
-
switch (device) {
|
|
58
|
-
case "Tablet":
|
|
59
|
-
case "Mobile":
|
|
60
|
-
return {
|
|
61
|
-
width: getCanvasWidth(device),
|
|
62
|
-
// Keeping margin styles separate to avoid warnings
|
|
63
|
-
// when those props get overridden in the iframe component
|
|
64
|
-
marginTop: marginVertical,
|
|
65
|
-
marginBottom: marginVertical,
|
|
66
|
-
marginLeft: marginHorizontal,
|
|
67
|
-
marginRight: marginHorizontal,
|
|
68
|
-
height,
|
|
69
|
-
overflowY: "auto"
|
|
70
|
-
};
|
|
71
|
-
default:
|
|
72
|
-
return {
|
|
73
|
-
marginLeft: marginHorizontal,
|
|
74
|
-
marginRight: marginHorizontal
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
return contentInlineStyles(deviceType);
|
|
36
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
37
|
+
function useResizeCanvas() {
|
|
38
|
+
(0, import_deprecated.default)("wp.blockEditor.useResizeCanvas", {
|
|
39
|
+
since: "7.1",
|
|
40
|
+
hint: "Device preview is now handled by the editor canvas. This hook no longer does anything."
|
|
41
|
+
});
|
|
79
42
|
}
|
|
80
43
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/use-resize-canvas/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Previously returned inline styles that sized the editor canvas to emulate a\n * device preview width. Device preview is now handled by the editor's resizable\n * canvas, so this hook is a no-op kept for backward compatibility.\n *\n * @deprecated\n */\nexport default function useResizeCanvas() {\n\tdeprecated( 'wp.blockEditor.useResizeCanvas', {\n\t\tsince: '7.1',\n\t\thint: 'Device preview is now handled by the editor canvas. This hook no longer does anything.',\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AASR,SAAR,kBAAmC;AACzC,wBAAAA,SAAY,kCAAkC;AAAA,IAC7C,OAAO;AAAA,IACP,MAAM;AAAA,EACP,CAAE;AACH;",
|
|
6
|
+
"names": ["deprecated"]
|
|
7
7
|
}
|