@wordpress/block-editor 7.0.1-next.5df0cd52b7.0 → 7.0.4
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/README.md +16 -4
- package/build/components/alignment-control/ui.js +2 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/autocomplete/index.js +1 -1
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +8 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +61 -14
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +25 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-content-overlay/index.js +2 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-controls/fill.js +6 -6
- package/build/components/block-controls/fill.js.map +1 -1
- package/build/components/block-controls/groups.js +3 -1
- package/build/components/block-controls/groups.js.map +1 -1
- package/build/components/block-controls/hook.js +57 -0
- package/build/components/block-controls/hook.js.map +1 -0
- package/build/components/block-edit/context.js +6 -5
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/edit.js +1 -1
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-icon/index.native.js +13 -9
- package/build/components/block-icon/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +10 -7
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-html.js +5 -0
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +31 -12
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js +4 -4
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.js +15 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +6 -7
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/grid-item.native.js +68 -0
- package/build/components/block-list/grid-item.native.js.map +1 -0
- package/build/components/block-list/index.js +19 -15
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +12 -8
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +6 -6
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +4 -6
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +1 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +4 -2
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +9 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +9 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mover/index.js +4 -4
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +4 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-preview/auto.js +42 -14
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -3
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +10 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +5 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +1 -1
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +3 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +3 -0
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-popover.js +8 -7
- package/build/components/block-tools/block-popover.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +2 -4
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +96 -7
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-types-list/index.native.js +3 -2
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +17 -8
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/utils.js +11 -3
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +17 -13
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/contrast-checker/index.js +18 -12
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/copy-handler/index.js +9 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +2 -2
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/duotone-control/index.js +38 -39
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/editor-styles/index.js +9 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +27 -7
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/font-sizes/index.native.js +24 -0
- package/build/components/font-sizes/index.native.js.map +1 -1
- package/build/components/iframe/index.js +45 -62
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +126 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
- package/build/components/image-editor/constants.js +16 -0
- package/build/components/image-editor/constants.js.map +1 -0
- package/build/components/image-editor/context.js +59 -0
- package/build/components/image-editor/context.js.map +1 -0
- package/build/components/image-editor/cropper.js +83 -0
- package/build/components/image-editor/cropper.js.map +1 -0
- package/build/components/image-editor/form-controls.js +36 -0
- package/build/components/image-editor/form-controls.js.map +1 -0
- package/build/components/image-editor/index.js +60 -0
- package/build/components/image-editor/index.js.map +1 -0
- package/build/components/image-editor/rotation-button.js +37 -0
- package/build/components/image-editor/rotation-button.js.map +1 -0
- package/build/components/image-editor/use-save-image.js +84 -0
- package/build/components/image-editor/use-save-image.js.map +1 -0
- package/build/components/image-editor/use-transform-image.js +135 -0
- package/build/components/image-editor/use-transform-image.js.map +1 -0
- package/build/components/image-editor/zoom-dropdown.js +55 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -0
- package/build/components/image-size-control/use-dimension-handler.js +14 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +22 -35
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +12 -7
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/button-block-appender.js +11 -1
- package/build/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +23 -6
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +38 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +24 -13
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +11 -1
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +3 -6
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build/components/inserter/index.js +12 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -7
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +2 -0
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +2 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js +18 -17
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/preview-panel.js +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -6
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +9 -2
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/tabs.native.js +1 -4
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +44 -0
- package/build/components/inserter/utils.native.js.map +1 -0
- package/build/components/inspector-controls/block-support-slot-container.js +28 -0
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +78 -0
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -0
- package/build/components/inspector-controls/fill.js +64 -0
- package/build/components/inspector-controls/fill.js.map +1 -0
- package/build/components/inspector-controls/{index.native.js → fill.native.js} +20 -19
- package/build/components/inspector-controls/fill.native.js.map +1 -0
- package/build/components/inspector-controls/groups.js +23 -0
- package/build/components/inspector-controls/groups.js.map +1 -0
- package/build/components/inspector-controls/index.js +22 -20
- package/build/components/inspector-controls/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +67 -0
- package/build/components/inspector-controls/slot.js.map +1 -0
- package/build/components/inspector-controls/slot.native.js +38 -0
- package/build/components/inspector-controls/slot.native.js.map +1 -0
- package/build/components/line-height-control/index.native.js +39 -0
- package/build/components/line-height-control/index.native.js.map +1 -0
- package/build/components/link-control/index.js +11 -5
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +26 -9
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +13 -4
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +1 -20
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +7 -48
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +20 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +21 -14
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +1 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/list-item.js +3 -2
- package/build/components/list-view/list-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +24 -15
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/media-placeholder/index.js +35 -21
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +2 -1
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +1 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/observe-typing/index.js +1 -1
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +30 -1
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +65 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +31 -11
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +29 -7
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +43 -5
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/input-event.js +25 -24
- package/build/components/rich-text/input-event.js.map +1 -1
- package/build/components/rich-text/shortcut.js +23 -9
- package/build/components/rich-text/shortcut.js.map +1 -1
- package/build/components/rich-text/use-input-events.js +27 -0
- package/build/components/rich-text/use-input-events.js.map +1 -0
- package/build/components/rich-text/use-paste-handler.js +45 -10
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/use-shortcuts.js +27 -0
- package/build/components/rich-text/use-shortcuts.js.map +1 -0
- package/build/components/rich-text/utils.js +22 -0
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-input/index.js +14 -7
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-display-block-controls/index.js +5 -7
- package/build/components/use-display-block-controls/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +13 -10
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +2 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +2 -13
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-setting/index.js +3 -7
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +6 -0
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +18 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +14 -14
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +4 -2
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border-color.js +9 -5
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/color-panel.js +4 -2
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +6 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/compat.js +23 -0
- package/build/hooks/compat.js.map +1 -0
- package/build/hooks/custom-class-name.js +3 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/dimensions.js +63 -28
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +47 -13
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +93 -23
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/gap.js +163 -0
- package/build/hooks/gap.js.map +1 -0
- package/build/hooks/index.js +4 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +2 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.js +47 -30
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/lock.js +43 -0
- package/build/hooks/lock.js.map +1 -0
- package/build/hooks/margin.js +5 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +5 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +39 -11
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/typography.native.js +60 -0
- package/build/hooks/typography.native.js.map +1 -0
- package/build/layouts/flex.js +121 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +99 -6
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +40 -13
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +16 -1
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/reducer.js +164 -114
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +161 -82
- package/build/store/selectors.js.map +1 -1
- package/build/utils/index.js +10 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +295 -0
- package/build/utils/parse-css-unit-to-px.js.map +1 -0
- package/build/utils/transform-styles/transforms/wrap.js +16 -0
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +2 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -2
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +8 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +64 -17
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +25 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +2 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-controls/fill.js +6 -5
- package/build-module/components/block-controls/fill.js.map +1 -1
- package/build-module/components/block-controls/groups.js +3 -1
- package/build-module/components/block-controls/groups.js.map +1 -1
- package/build-module/components/block-controls/hook.js +42 -0
- package/build-module/components/block-controls/hook.js.map +1 -0
- package/build-module/components/block-edit/context.js +4 -4
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/edit.js +1 -1
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-icon/index.native.js +14 -9
- package/build-module/components/block-icon/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +8 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-html.js +5 -0
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +30 -12
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js +3 -4
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.js +16 -10
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +6 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/grid-item.native.js +57 -0
- package/build-module/components/block-list/grid-item.native.js.map +1 -0
- package/build-module/components/block-list/index.js +17 -14
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +12 -8
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +7 -7
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +5 -7
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +2 -2
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +4 -2
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +9 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +9 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -4
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +4 -4
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-preview/auto.js +40 -16
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +10 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +5 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -3
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +3 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +3 -0
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-popover.js +9 -8
- package/build-module/components/block-tools/block-popover.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +2 -4
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +96 -8
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +3 -2
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +16 -9
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/utils.js +9 -3
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +18 -14
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +2 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +13 -10
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/copy-handler/index.js +9 -3
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +2 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +40 -39
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +7 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +27 -7
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/font-sizes/index.native.js +3 -1
- package/build-module/components/font-sizes/index.native.js.map +1 -1
- package/build-module/components/iframe/index.js +46 -64
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +115 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
- package/build-module/components/image-editor/constants.js +7 -0
- package/build-module/components/image-editor/constants.js.map +1 -0
- package/build-module/components/image-editor/context.js +44 -0
- package/build-module/components/image-editor/context.js.map +1 -0
- package/build-module/components/image-editor/cropper.js +69 -0
- package/build-module/components/image-editor/cropper.js.map +1 -0
- package/build-module/components/image-editor/form-controls.js +26 -0
- package/build-module/components/image-editor/form-controls.js.map +1 -0
- package/build-module/components/image-editor/index.js +37 -0
- package/build-module/components/image-editor/index.js.map +1 -0
- package/build-module/components/image-editor/rotation-button.js +26 -0
- package/build-module/components/image-editor/rotation-button.js.map +1 -0
- package/build-module/components/image-editor/use-save-image.js +70 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -0
- package/build-module/components/image-editor/use-transform-image.js +127 -0
- package/build-module/components/image-editor/use-transform-image.js.map +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js +43 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -0
- package/build-module/components/image-size-control/use-dimension-handler.js +13 -2
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +2 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -3
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/button-block-appender.js +10 -1
- package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +24 -7
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +36 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +24 -13
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +11 -1
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +2 -5
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build-module/components/inserter/index.js +12 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -7
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -0
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +17 -17
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -1
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +4 -5
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +8 -2
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +1 -4
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +35 -0
- package/build-module/components/inserter/utils.native.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +67 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -0
- package/build-module/components/inspector-controls/fill.js +50 -0
- package/build-module/components/inspector-controls/fill.js.map +1 -0
- package/build-module/components/inspector-controls/{index.native.js → fill.native.js} +16 -18
- package/build-module/components/inspector-controls/fill.native.js.map +1 -0
- package/build-module/components/inspector-controls/groups.js +14 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -0
- package/build-module/components/inspector-controls/index.js +16 -17
- package/build-module/components/inspector-controls/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +52 -0
- package/build-module/components/inspector-controls/slot.js.map +1 -0
- package/build-module/components/inspector-controls/slot.native.js +27 -0
- package/build-module/components/inspector-controls/slot.native.js.map +1 -0
- package/build-module/components/line-height-control/index.native.js +29 -0
- package/build-module/components/line-height-control/index.native.js.map +1 -0
- package/build-module/components/link-control/index.js +11 -5
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +28 -11
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +13 -4
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -18
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +9 -49
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +20 -15
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +22 -17
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +1 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/list-item.js +3 -2
- package/build-module/components/list-view/list-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +24 -15
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +35 -21
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +2 -1
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +1 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +1 -1
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +29 -2
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +53 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +28 -11
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +22 -6
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +43 -6
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/input-event.js +24 -22
- package/build-module/components/rich-text/input-event.js.map +1 -1
- package/build-module/components/rich-text/shortcut.js +22 -9
- package/build-module/components/rich-text/shortcut.js.map +1 -1
- package/build-module/components/rich-text/use-input-events.js +19 -0
- package/build-module/components/rich-text/use-input-events.js.map +1 -0
- package/build-module/components/rich-text/use-paste-handler.js +44 -10
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/use-shortcuts.js +19 -0
- package/build-module/components/rich-text/use-shortcuts.js.map +1 -0
- package/build-module/components/rich-text/utils.js +20 -0
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-input/index.js +14 -7
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-display-block-controls/index.js +5 -7
- package/build-module/components/use-display-block-controls/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +13 -10
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -2
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +2 -10
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -6
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +6 -0
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +18 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +15 -15
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +5 -3
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border-color.js +10 -5
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/color-panel.js +5 -3
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +6 -4
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/compat.js +20 -0
- package/build-module/hooks/compat.js.map +1 -0
- package/build-module/hooks/custom-class-name.js +4 -2
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/dimensions.js +57 -26
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +46 -13
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +91 -24
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/gap.js +140 -0
- package/build-module/hooks/gap.js.map +1 -0
- package/build-module/hooks/index.js +2 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.js +47 -30
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/lock.js +33 -0
- package/build-module/hooks/lock.js.map +1 -0
- package/build-module/hooks/margin.js +6 -3
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +6 -3
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +39 -11
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +1 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/typography.native.js +41 -0
- package/build-module/hooks/typography.native.js.map +1 -0
- package/build-module/layouts/flex.js +115 -9
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +99 -7
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +40 -13
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +15 -1
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/reducer.js +166 -115
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +148 -75
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +285 -0
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -0
- package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/default-editor-styles-rtl.css +114 -0
- package/build-style/default-editor-styles.css +114 -0
- package/build-style/style-rtl.css +136 -128
- package/build-style/style.css +136 -128
- package/build-types/components/block-context/index.d.ts +1 -1
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/package.json +31 -29
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +2 -0
- package/src/components/alignment-control/ui.js +4 -1
- package/src/components/autocomplete/index.js +5 -2
- package/src/components/block-actions/index.js +9 -5
- package/src/components/block-alignment-control/style.scss +5 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +15 -1
- package/src/components/block-alignment-control/test/index.native.js +37 -0
- package/src/components/block-alignment-control/ui.js +98 -27
- package/src/components/block-alignment-control/use-available-alignments.js +31 -10
- package/src/components/block-content-overlay/index.js +3 -6
- package/src/components/block-content-overlay/style.scss +9 -21
- package/src/components/block-controls/fill.js +7 -4
- package/src/components/block-controls/groups.js +2 -0
- package/src/components/block-controls/hook.js +44 -0
- package/src/components/block-edit/context.js +4 -3
- package/src/components/block-edit/edit.js +1 -4
- package/src/components/block-icon/index.native.js +11 -12
- package/src/components/block-inspector/index.js +14 -9
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/block-list-item.native.js +34 -11
- package/src/components/block-list/block-list-item.native.scss +4 -0
- package/src/components/block-list/block-selection-button.native.js +8 -5
- package/src/components/block-list/block.js +13 -9
- package/src/components/block-list/block.native.js +7 -5
- package/src/components/block-list/grid-item.native.js +58 -0
- package/src/components/block-list/index.js +33 -27
- package/src/components/block-list/index.native.js +9 -3
- package/src/components/block-list/style.native.scss +0 -1
- package/src/components/block-list/style.scss +15 -0
- package/src/components/block-list/use-block-props/index.js +4 -7
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +5 -7
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +2 -8
- package/src/components/block-list/use-block-props/use-multi-selection.js +7 -1
- package/src/components/block-list/use-in-between-inserter.js +9 -0
- package/src/components/block-list-appender/index.js +8 -0
- package/src/components/block-mover/index.js +4 -4
- package/src/components/block-mover/index.native.js +4 -4
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -6
- package/src/components/block-mover/test/index.native.js +26 -28
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-preview/auto.js +36 -18
- package/src/components/block-preview/style.scss +0 -20
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -6
- package/src/components/block-settings-menu-controls/index.js +9 -6
- package/src/components/block-styles/index.js +6 -1
- package/src/components/block-styles/preview.native.js +1 -1
- package/src/components/block-switcher/block-styles-menu.js +1 -1
- package/src/components/block-switcher/index.js +7 -3
- package/src/components/block-switcher/test/index.js +3 -0
- package/src/components/block-title/index.js +5 -2
- package/src/components/block-toolbar/index.js +4 -0
- package/src/components/block-tools/block-contextual-toolbar.js +7 -5
- package/src/components/block-tools/block-popover.js +8 -8
- package/src/components/block-tools/block-selection-button.js +2 -4
- package/src/components/block-tools/index.js +5 -2
- package/src/components/block-tools/insertion-point.js +97 -9
- package/src/components/block-tools/style.scss +4 -35
- package/src/components/block-types-list/index.native.js +8 -2
- package/src/components/block-types-list/style.scss +0 -3
- package/src/components/block-variation-picker/README.md +47 -14
- package/src/components/block-variation-picker/style.native.scss +4 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/test/utils.js +216 -0
- package/src/components/border-radius-control/utils.js +18 -10
- package/src/components/color-palette/test/__snapshots__/control.js.snap +103 -71
- package/src/components/colors/test/utils.js +41 -0
- package/src/components/colors/utils.js +9 -5
- package/src/components/colors-gradients/control.js +64 -61
- package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -1
- package/src/components/colors-gradients/style.scss +8 -5
- package/src/components/colors-gradients/test/control.js +43 -52
- package/src/components/contrast-checker/index.js +14 -10
- package/src/components/copy-handler/index.js +6 -1
- package/src/components/default-block-appender/index.js +2 -2
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
- package/src/components/duotone-control/index.js +43 -41
- package/src/components/editor-styles/index.js +8 -4
- package/src/components/font-appearance-control/index.js +49 -19
- package/src/components/font-appearance-control/style.scss +1 -1
- package/src/components/font-sizes/index.native.js +7 -1
- package/src/components/iframe/index.js +63 -74
- package/src/components/image-editor/aspect-ratio-dropdown.js +129 -0
- package/src/components/image-editor/constants.js +6 -0
- package/src/components/image-editor/context.js +56 -0
- package/src/components/image-editor/cropper.js +74 -0
- package/src/components/image-editor/form-controls.js +22 -0
- package/src/components/image-editor/index.js +52 -0
- package/src/components/image-editor/rotation-button.js +24 -0
- package/src/components/image-editor/use-save-image.js +97 -0
- package/src/components/image-editor/use-transform-image.js +162 -0
- package/src/components/image-editor/zoom-dropdown.js +40 -0
- package/src/components/image-size-control/use-dimension-handler.js +18 -1
- package/src/components/index.js +8 -5
- package/src/components/index.native.js +8 -3
- package/src/components/inner-blocks/button-block-appender.js +9 -0
- package/src/components/inner-blocks/index.js +40 -11
- package/src/components/inner-blocks/index.native.js +41 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +26 -11
- package/src/components/inserter/block-patterns-tab.js +11 -4
- package/src/components/inserter/block-types-tab.native.js +3 -6
- package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
- package/src/components/inserter/index.js +15 -3
- package/src/components/inserter/index.native.js +2 -19
- package/src/components/inserter/library.js +2 -0
- package/src/components/inserter/menu.js +4 -1
- package/src/components/inserter/menu.native.js +18 -15
- package/src/components/inserter/preview-panel.js +1 -1
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -6
- package/src/components/inserter/search-results.native.js +8 -1
- package/src/components/inserter/style.native.scss +8 -5
- package/src/components/inserter/style.scss +16 -15
- package/src/components/inserter/tabs.native.js +1 -7
- package/src/components/inserter/test/block-types-tab.native.js +2 -1
- package/src/components/inserter/utils.native.js +35 -0
- package/src/components/inserter-list-item/style.scss +4 -2
- package/src/components/inspector-controls/README.md +43 -198
- package/src/components/inspector-controls/block-support-slot-container.js +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +60 -0
- package/src/components/inspector-controls/fill.js +53 -0
- package/src/components/inspector-controls/{index.native.js → fill.native.js} +14 -14
- package/src/components/inspector-controls/groups.js +18 -0
- package/src/components/inspector-controls/index.js +16 -18
- package/src/components/inspector-controls/slot.js +45 -0
- package/src/components/inspector-controls/slot.native.js +22 -0
- package/src/components/line-height-control/index.native.js +25 -0
- package/src/components/link-control/README.md +40 -14
- package/src/components/link-control/index.js +7 -1
- package/src/components/link-control/link-preview.js +36 -15
- package/src/components/link-control/search-input.js +12 -4
- package/src/components/link-control/style.scss +36 -5
- package/src/components/link-control/test/index.js +132 -0
- package/src/components/list-view/block-contents.js +17 -38
- package/src/components/list-view/block.js +8 -63
- package/src/components/list-view/branch.js +19 -12
- package/src/components/list-view/index.js +45 -26
- package/src/components/list-view/leaf.js +1 -1
- package/src/components/list-view/list-item.js +5 -4
- package/src/components/list-view/style.scss +56 -30
- package/src/components/list-view/use-list-view-client-ids.js +22 -22
- package/src/components/media-placeholder/README.md +9 -0
- package/src/components/media-placeholder/index.js +31 -20
- package/src/components/media-placeholder/index.native.js +2 -1
- package/src/components/media-placeholder/style.scss +2 -0
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +4 -1
- package/src/components/media-replace-flow/style.scss +11 -12
- package/src/components/media-upload/README.md +1 -1
- package/src/components/navigable-toolbar/index.js +1 -4
- package/src/components/observe-typing/index.js +3 -2
- package/src/components/plain-text/index.native.js +26 -4
- package/src/components/rich-text/embed-handler-picker.native.js +67 -0
- package/src/components/rich-text/format-toolbar/index.js +22 -6
- package/src/components/rich-text/index.js +38 -12
- package/src/components/rich-text/index.native.js +37 -4
- package/src/components/rich-text/input-event.js +21 -20
- package/src/components/rich-text/shortcut.js +24 -9
- package/src/components/rich-text/style.scss +7 -5
- package/src/components/rich-text/use-input-events.js +19 -0
- package/src/components/rich-text/use-paste-handler.js +47 -12
- package/src/components/rich-text/use-shortcuts.js +19 -0
- package/src/components/rich-text/utils.js +16 -0
- package/src/components/skip-to-selected-block/README.md +39 -0
- package/src/components/tool-selector/style.scss +5 -5
- package/src/components/typewriter/index.js +3 -2
- package/src/components/url-input/index.js +12 -6
- package/src/components/use-display-block-controls/index.js +7 -10
- package/src/components/use-moving-animation/index.js +9 -8
- package/src/components/use-on-block-drop/index.js +5 -1
- package/src/components/use-resize-canvas/index.js +2 -17
- package/src/components/use-setting/index.js +1 -7
- package/src/components/writing-flow/use-multi-selection.js +6 -0
- package/src/components/writing-flow/use-tab-nav.js +21 -11
- package/src/default-editor-styles.scss +24 -0
- package/src/hooks/align.js +28 -20
- package/src/hooks/anchor.js +5 -5
- package/src/hooks/border-color.js +12 -1
- package/src/hooks/color-panel.js +3 -1
- package/src/hooks/color.js +11 -4
- package/src/hooks/compat.js +23 -0
- package/src/hooks/custom-class-name.js +3 -3
- package/src/hooks/dimensions.js +94 -50
- package/src/hooks/duotone.js +49 -14
- package/src/hooks/font-family.js +107 -27
- package/src/hooks/gap.js +146 -0
- package/src/hooks/index.js +2 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.js +82 -56
- package/src/hooks/layout.scss +6 -0
- package/src/hooks/letter-spacing.js +2 -1
- package/src/hooks/lock.js +34 -0
- package/src/hooks/margin.js +12 -2
- package/src/hooks/padding.js +12 -2
- package/src/hooks/style.js +57 -18
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/typography.js +2 -6
- package/src/hooks/typography.native.js +64 -0
- package/src/layouts/flex.js +139 -12
- package/src/layouts/flow.js +81 -14
- package/src/store/actions.js +54 -16
- package/src/store/defaults.js +2 -0
- package/src/store/defaults.native.js +15 -0
- package/src/store/reducer.js +230 -145
- package/src/store/selectors.js +164 -115
- package/src/store/test/actions.js +89 -88
- package/src/store/test/reducer.js +184 -146
- package/src/store/test/selectors.js +118 -156
- package/src/style.scss +1 -14
- package/src/utils/index.js +1 -0
- package/src/utils/parse-css-unit-to-px.js +272 -0
- package/src/utils/test/parse-css-unit-to-px.js +206 -0
- package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
- package/src/utils/transform-styles/transforms/wrap.js +16 -0
- package/tsconfig.tsbuildinfo +1 -466
- package/build/components/block-list/head.js +0 -27
- package/build/components/block-list/head.js.map +0 -1
- package/build/components/duotone-control/duotone-picker-popover.js +0 -44
- package/build/components/duotone-control/duotone-picker-popover.js.map +0 -1
- package/build/components/inspector-advanced-controls/index.js +0 -46
- package/build/components/inspector-advanced-controls/index.js.map +0 -1
- package/build/components/inspector-controls/index.native.js.map +0 -1
- package/build/components/list-view/block-slot.js +0 -121
- package/build/components/list-view/block-slot.js.map +0 -1
- package/build/components/list-view/editor.js +0 -35
- package/build/components/list-view/editor.js.map +0 -1
- package/build/components/use-simulated-media-query/index.js +0 -137
- package/build/components/use-simulated-media-query/index.js.map +0 -1
- package/build-module/components/block-list/head.js +0 -19
- package/build-module/components/block-list/head.js.map +0 -1
- package/build-module/components/duotone-control/duotone-picker-popover.js +0 -35
- package/build-module/components/duotone-control/duotone-picker-popover.js.map +0 -1
- package/build-module/components/inspector-advanced-controls/index.js +0 -36
- package/build-module/components/inspector-advanced-controls/index.js.map +0 -1
- package/build-module/components/inspector-controls/index.native.js.map +0 -1
- package/build-module/components/list-view/block-slot.js +0 -96
- package/build-module/components/list-view/block-slot.js.map +0 -1
- package/build-module/components/list-view/editor.js +0 -25
- package/build-module/components/list-view/editor.js.map +0 -1
- package/build-module/components/use-simulated-media-query/index.js +0 -126
- package/build-module/components/use-simulated-media-query/index.js.map +0 -1
- package/src/components/block-list/head.js +0 -18
- package/src/components/duotone-control/duotone-picker-popover.js +0 -36
- package/src/components/inspector-advanced-controls/README.md +0 -72
- package/src/components/inspector-advanced-controls/index.js +0 -32
- package/src/components/list-view/block-slot.js +0 -120
- package/src/components/list-view/editor.js +0 -29
- package/src/components/use-simulated-media-query/index.js +0 -144
|
@@ -228,19 +228,19 @@ describe( 'selectors', () => {
|
|
|
228
228
|
parents: {
|
|
229
229
|
123: '',
|
|
230
230
|
},
|
|
231
|
-
|
|
232
|
-
123: {
|
|
231
|
+
tree: {
|
|
232
|
+
123: {
|
|
233
|
+
clientId: 123,
|
|
234
|
+
name: 'core/paragraph',
|
|
235
|
+
attributes: {},
|
|
236
|
+
innerBlocks: [],
|
|
237
|
+
},
|
|
233
238
|
},
|
|
234
239
|
controlledInnerBlocks: {},
|
|
235
240
|
},
|
|
236
241
|
};
|
|
237
242
|
|
|
238
|
-
expect( getBlock( state, 123 ) ).
|
|
239
|
-
clientId: 123,
|
|
240
|
-
name: 'core/paragraph',
|
|
241
|
-
attributes: {},
|
|
242
|
-
innerBlocks: [],
|
|
243
|
-
} );
|
|
243
|
+
expect( getBlock( state, 123 ) ).toBe( state.blocks.tree[ 123 ] );
|
|
244
244
|
} );
|
|
245
245
|
|
|
246
246
|
it( 'should return null if the block is not present in state', () => {
|
|
@@ -250,55 +250,19 @@ describe( 'selectors', () => {
|
|
|
250
250
|
attributes: {},
|
|
251
251
|
order: {},
|
|
252
252
|
parents: {},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
it( 'should include inner blocks', () => {
|
|
262
|
-
const state = {
|
|
263
|
-
blocks: {
|
|
264
|
-
byClientId: {
|
|
265
|
-
123: { clientId: 123, name: 'core/paragraph' },
|
|
266
|
-
456: { clientId: 456, name: 'core/paragraph' },
|
|
267
|
-
},
|
|
268
|
-
attributes: {
|
|
269
|
-
123: {},
|
|
270
|
-
456: {},
|
|
271
|
-
},
|
|
272
|
-
order: {
|
|
273
|
-
'': [ 123 ],
|
|
274
|
-
123: [ 456 ],
|
|
275
|
-
456: [],
|
|
276
|
-
},
|
|
277
|
-
parents: {
|
|
278
|
-
123: '',
|
|
279
|
-
456: 123,
|
|
280
|
-
},
|
|
281
|
-
cache: {
|
|
282
|
-
123: {},
|
|
283
|
-
456: {},
|
|
253
|
+
tree: {
|
|
254
|
+
123: {
|
|
255
|
+
clientId: 123,
|
|
256
|
+
name: 'core/paragraph',
|
|
257
|
+
attributes: {},
|
|
258
|
+
innerBlocks: [],
|
|
259
|
+
},
|
|
284
260
|
},
|
|
285
261
|
controlledInnerBlocks: {},
|
|
286
262
|
},
|
|
287
263
|
};
|
|
288
264
|
|
|
289
|
-
expect( getBlock( state, 123 ) ).
|
|
290
|
-
clientId: 123,
|
|
291
|
-
name: 'core/paragraph',
|
|
292
|
-
attributes: {},
|
|
293
|
-
innerBlocks: [
|
|
294
|
-
{
|
|
295
|
-
clientId: 456,
|
|
296
|
-
name: 'core/paragraph',
|
|
297
|
-
attributes: {},
|
|
298
|
-
innerBlocks: [],
|
|
299
|
-
},
|
|
300
|
-
],
|
|
301
|
-
} );
|
|
265
|
+
expect( getBlock( state, 123 ) ).toBe( null );
|
|
302
266
|
} );
|
|
303
267
|
} );
|
|
304
268
|
|
|
@@ -321,7 +285,23 @@ describe( 'selectors', () => {
|
|
|
321
285
|
123: '',
|
|
322
286
|
23: '',
|
|
323
287
|
},
|
|
324
|
-
|
|
288
|
+
tree: {
|
|
289
|
+
'': {
|
|
290
|
+
innerBlocks: [
|
|
291
|
+
{
|
|
292
|
+
clientId: 123,
|
|
293
|
+
name: 'core/paragraph',
|
|
294
|
+
attributes: {},
|
|
295
|
+
innerBlocks: [],
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
clientId: 23,
|
|
299
|
+
name: 'core/heading',
|
|
300
|
+
attributes: {},
|
|
301
|
+
innerBlocks: [],
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
},
|
|
325
305
|
123: {},
|
|
326
306
|
23: {},
|
|
327
307
|
},
|
|
@@ -329,92 +309,9 @@ describe( 'selectors', () => {
|
|
|
329
309
|
},
|
|
330
310
|
};
|
|
331
311
|
|
|
332
|
-
expect( getBlocks( state ) ).
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
name: 'core/paragraph',
|
|
336
|
-
attributes: {},
|
|
337
|
-
innerBlocks: [],
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
clientId: 23,
|
|
341
|
-
name: 'core/heading',
|
|
342
|
-
attributes: {},
|
|
343
|
-
innerBlocks: [],
|
|
344
|
-
},
|
|
345
|
-
] );
|
|
346
|
-
} );
|
|
347
|
-
it( 'only returns a new value if the cache key of a direct child changes', () => {
|
|
348
|
-
const cacheRef = {};
|
|
349
|
-
const state = {
|
|
350
|
-
blocks: {
|
|
351
|
-
byClientId: {
|
|
352
|
-
23: { clientId: 23, name: 'core/heading' },
|
|
353
|
-
},
|
|
354
|
-
attributes: {
|
|
355
|
-
23: {},
|
|
356
|
-
},
|
|
357
|
-
order: {
|
|
358
|
-
'': [ 23 ],
|
|
359
|
-
},
|
|
360
|
-
parents: {
|
|
361
|
-
23: '',
|
|
362
|
-
},
|
|
363
|
-
cache: {
|
|
364
|
-
23: cacheRef,
|
|
365
|
-
},
|
|
366
|
-
controlledInnerBlocks: {},
|
|
367
|
-
},
|
|
368
|
-
};
|
|
369
|
-
const oldBlocks = getBlocks( state );
|
|
370
|
-
|
|
371
|
-
const newStateSameCache = {
|
|
372
|
-
blocks: {
|
|
373
|
-
byClientId: {
|
|
374
|
-
23: { clientId: 23, name: 'core/heading' },
|
|
375
|
-
},
|
|
376
|
-
attributes: {
|
|
377
|
-
23: {},
|
|
378
|
-
},
|
|
379
|
-
order: {
|
|
380
|
-
'': [ 23 ],
|
|
381
|
-
},
|
|
382
|
-
parents: {
|
|
383
|
-
23: '',
|
|
384
|
-
},
|
|
385
|
-
cache: {
|
|
386
|
-
23: cacheRef,
|
|
387
|
-
},
|
|
388
|
-
controlledInnerBlocks: {},
|
|
389
|
-
},
|
|
390
|
-
};
|
|
391
|
-
// Makes sure blocks are referentially equal if the cache key stays the same.
|
|
392
|
-
const newBlocks = getBlocks( newStateSameCache );
|
|
393
|
-
expect( oldBlocks ).toBe( newBlocks );
|
|
394
|
-
|
|
395
|
-
const newStateNewCache = {
|
|
396
|
-
blocks: {
|
|
397
|
-
byClientId: {
|
|
398
|
-
23: { clientId: 23, name: 'core/heading' },
|
|
399
|
-
},
|
|
400
|
-
attributes: {
|
|
401
|
-
23: {},
|
|
402
|
-
},
|
|
403
|
-
order: {
|
|
404
|
-
'': [ 23 ],
|
|
405
|
-
},
|
|
406
|
-
parents: {
|
|
407
|
-
23: '',
|
|
408
|
-
},
|
|
409
|
-
cache: {
|
|
410
|
-
23: {},
|
|
411
|
-
},
|
|
412
|
-
controlledInnerBlocks: {},
|
|
413
|
-
},
|
|
414
|
-
};
|
|
415
|
-
// Blocks are referentially different if the cache key changes.
|
|
416
|
-
const newBlocksNewCache = getBlocks( newStateNewCache );
|
|
417
|
-
expect( oldBlocks ).not.toBe( newBlocksNewCache );
|
|
312
|
+
expect( getBlocks( state ) ).toBe(
|
|
313
|
+
state.blocks.tree[ '' ].innerBlocks
|
|
314
|
+
);
|
|
418
315
|
} );
|
|
419
316
|
} );
|
|
420
317
|
|
|
@@ -963,6 +860,14 @@ describe( 'selectors', () => {
|
|
|
963
860
|
23: '',
|
|
964
861
|
123: '',
|
|
965
862
|
},
|
|
863
|
+
tree: {
|
|
864
|
+
23: {
|
|
865
|
+
clientId: 23,
|
|
866
|
+
name: 'core/heading',
|
|
867
|
+
attributes: {},
|
|
868
|
+
innerBlocks: [],
|
|
869
|
+
},
|
|
870
|
+
},
|
|
966
871
|
},
|
|
967
872
|
selection: {
|
|
968
873
|
selectionStart: {},
|
|
@@ -993,6 +898,14 @@ describe( 'selectors', () => {
|
|
|
993
898
|
123: '',
|
|
994
899
|
23: '',
|
|
995
900
|
},
|
|
901
|
+
tree: {
|
|
902
|
+
23: {
|
|
903
|
+
clientId: 23,
|
|
904
|
+
name: 'core/heading',
|
|
905
|
+
attributes: {},
|
|
906
|
+
innerBlocks: [],
|
|
907
|
+
},
|
|
908
|
+
},
|
|
996
909
|
},
|
|
997
910
|
selection: {
|
|
998
911
|
selectionStart: { clientId: 23 },
|
|
@@ -1023,8 +936,13 @@ describe( 'selectors', () => {
|
|
|
1023
936
|
123: '',
|
|
1024
937
|
23: '',
|
|
1025
938
|
},
|
|
1026
|
-
|
|
1027
|
-
23: {
|
|
939
|
+
tree: {
|
|
940
|
+
23: {
|
|
941
|
+
clientId: 23,
|
|
942
|
+
name: 'core/heading',
|
|
943
|
+
attributes: {},
|
|
944
|
+
innerBlocks: [],
|
|
945
|
+
},
|
|
1028
946
|
},
|
|
1029
947
|
controlledInnerBlocks: {},
|
|
1030
948
|
},
|
|
@@ -1034,12 +952,9 @@ describe( 'selectors', () => {
|
|
|
1034
952
|
},
|
|
1035
953
|
};
|
|
1036
954
|
|
|
1037
|
-
expect( getSelectedBlock( state ) ).toEqual(
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
attributes: {},
|
|
1041
|
-
innerBlocks: [],
|
|
1042
|
-
} );
|
|
955
|
+
expect( getSelectedBlock( state ) ).toEqual(
|
|
956
|
+
getBlock( state, 23 )
|
|
957
|
+
);
|
|
1043
958
|
} );
|
|
1044
959
|
} );
|
|
1045
960
|
|
|
@@ -2560,7 +2475,11 @@ describe( 'selectors', () => {
|
|
|
2560
2475
|
attributes: {},
|
|
2561
2476
|
order: {},
|
|
2562
2477
|
parents: {},
|
|
2563
|
-
|
|
2478
|
+
tree: {
|
|
2479
|
+
'': {
|
|
2480
|
+
innerBlocks: [],
|
|
2481
|
+
},
|
|
2482
|
+
},
|
|
2564
2483
|
},
|
|
2565
2484
|
settings: {
|
|
2566
2485
|
__experimentalReusableBlocks: [
|
|
@@ -2636,9 +2555,19 @@ describe( 'selectors', () => {
|
|
|
2636
2555
|
block3: '',
|
|
2637
2556
|
block4: '',
|
|
2638
2557
|
},
|
|
2639
|
-
|
|
2640
|
-
block3: {
|
|
2641
|
-
|
|
2558
|
+
tree: {
|
|
2559
|
+
block3: {
|
|
2560
|
+
clientId: 'block3',
|
|
2561
|
+
name: 'core/test-block-a',
|
|
2562
|
+
attributes: {},
|
|
2563
|
+
innerBlocks: [],
|
|
2564
|
+
},
|
|
2565
|
+
block4: {
|
|
2566
|
+
clientId: 'block4',
|
|
2567
|
+
name: 'core/test-block-a',
|
|
2568
|
+
attributes: {},
|
|
2569
|
+
innerBlocks: [],
|
|
2570
|
+
},
|
|
2642
2571
|
},
|
|
2643
2572
|
controlledInnerBlocks: {},
|
|
2644
2573
|
},
|
|
@@ -2726,8 +2655,13 @@ describe( 'selectors', () => {
|
|
|
2726
2655
|
order: {
|
|
2727
2656
|
'': [ 'block1' ],
|
|
2728
2657
|
},
|
|
2729
|
-
|
|
2730
|
-
block1: {
|
|
2658
|
+
tree: {
|
|
2659
|
+
block1: {
|
|
2660
|
+
clientId: 'block1',
|
|
2661
|
+
name: 'core/test-block-b',
|
|
2662
|
+
attributes: {},
|
|
2663
|
+
innerBlocks: [],
|
|
2664
|
+
},
|
|
2731
2665
|
},
|
|
2732
2666
|
controlledInnerBlocks: {},
|
|
2733
2667
|
},
|
|
@@ -2929,8 +2863,13 @@ describe( 'selectors', () => {
|
|
|
2929
2863
|
order: {
|
|
2930
2864
|
'': [ 'block1' ],
|
|
2931
2865
|
},
|
|
2932
|
-
|
|
2933
|
-
block1: {
|
|
2866
|
+
tree: {
|
|
2867
|
+
block1: {
|
|
2868
|
+
clientId: 'block1',
|
|
2869
|
+
name: 'core/with-tranforms-c',
|
|
2870
|
+
attributes: {},
|
|
2871
|
+
innerBlocks: [],
|
|
2872
|
+
},
|
|
2934
2873
|
},
|
|
2935
2874
|
controlledInnerBlocks: {},
|
|
2936
2875
|
},
|
|
@@ -3725,6 +3664,13 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
3725
3664
|
title: 'Another Plugin Block B',
|
|
3726
3665
|
icon: 'test',
|
|
3727
3666
|
} );
|
|
3667
|
+
registerBlockType( 'plugin/block-c-with-variations', {
|
|
3668
|
+
save() {},
|
|
3669
|
+
category: 'text',
|
|
3670
|
+
title: 'Plugin Block C with variations',
|
|
3671
|
+
icon: 'test',
|
|
3672
|
+
variations: [ { name: 'variation-a' }, { name: 'variation-b' } ],
|
|
3673
|
+
} );
|
|
3728
3674
|
registerBlockType( 'core/block', {
|
|
3729
3675
|
save() {},
|
|
3730
3676
|
category: 'text',
|
|
@@ -3737,13 +3683,23 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
3737
3683
|
icon: 'test',
|
|
3738
3684
|
keywords: [ 'testing' ],
|
|
3739
3685
|
} );
|
|
3686
|
+
registerBlockType( 'core/test-block-with-variations', {
|
|
3687
|
+
save() {},
|
|
3688
|
+
category: 'text',
|
|
3689
|
+
title: 'Core Block C with variations',
|
|
3690
|
+
icon: 'test',
|
|
3691
|
+
keywords: [ 'testing' ],
|
|
3692
|
+
variations: [ { name: 'variation-a' }, { name: 'variation-b' } ],
|
|
3693
|
+
} );
|
|
3740
3694
|
} );
|
|
3741
3695
|
afterEach( () => {
|
|
3742
3696
|
[
|
|
3743
3697
|
'plugin/block-a',
|
|
3744
3698
|
'another-plugin/block-b',
|
|
3699
|
+
'plugin/block-c-with-variations',
|
|
3745
3700
|
'core/block',
|
|
3746
3701
|
'core/test-block-a',
|
|
3702
|
+
'core/test-block-with-variations',
|
|
3747
3703
|
].forEach( unregisterBlockType );
|
|
3748
3704
|
} );
|
|
3749
3705
|
it( 'should prioritize core blocks by sorting them at the top of the returned list', () => {
|
|
@@ -3763,10 +3719,16 @@ describe( 'getInserterItems with core blocks prioritization', () => {
|
|
|
3763
3719
|
const expectedResult = [
|
|
3764
3720
|
'core/block',
|
|
3765
3721
|
'core/test-block-a',
|
|
3722
|
+
'core/test-block-with-variations',
|
|
3723
|
+
'core/test-block-with-variations/variation-a',
|
|
3724
|
+
'core/test-block-with-variations/variation-b',
|
|
3766
3725
|
'plugin/block-a',
|
|
3767
3726
|
'another-plugin/block-b',
|
|
3727
|
+
'plugin/block-c-with-variations',
|
|
3728
|
+
'plugin/block-c-with-variations/variation-a',
|
|
3729
|
+
'plugin/block-c-with-variations/variation-b',
|
|
3768
3730
|
];
|
|
3769
|
-
expect( items.map( ( {
|
|
3731
|
+
expect( items.map( ( { id } ) => id ) ).toEqual( expectedResult );
|
|
3770
3732
|
} );
|
|
3771
3733
|
} );
|
|
3772
3734
|
|
package/src/style.scss
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
// This tag marks the start of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
|
|
2
|
-
#start-resizable-editor-section {
|
|
3
|
-
display: none;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// Only add styles for components that are used inside the editing canvas here:
|
|
7
|
-
|
|
8
1
|
@import "./autocompleters/style.scss";
|
|
2
|
+
@import "./components/block-alignment-control/style.scss";
|
|
9
3
|
@import "./components/block-alignment-matrix-control/style.scss";
|
|
10
4
|
@import "./components/block-icon/style.scss";
|
|
11
5
|
@import "./components/block-inspector/style.scss";
|
|
@@ -63,13 +57,6 @@
|
|
|
63
57
|
@import "./hooks/layout.scss";
|
|
64
58
|
@import "./hooks/border.scss";
|
|
65
59
|
|
|
66
|
-
// This tag marks the end of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
|
|
67
|
-
#end-resizable-editor-section {
|
|
68
|
-
display: none;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Styles for components that are used outside of the editing canvas go here:
|
|
72
|
-
|
|
73
60
|
@import "./components/block-toolbar/style.scss";
|
|
74
61
|
@import "./components/inserter/style.scss";
|
|
75
62
|
@import "./components/preview-options/style.scss";
|
package/src/utils/index.js
CHANGED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts string to object { value, unit }.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} cssUnit
|
|
5
|
+
* @return {Object} parsedUnit
|
|
6
|
+
*/
|
|
7
|
+
function parseUnit( cssUnit ) {
|
|
8
|
+
const match = cssUnit
|
|
9
|
+
?.trim()
|
|
10
|
+
.match(
|
|
11
|
+
/^(0?[-.]?\d+)(r?e[m|x]|v[h|w|min|max]+|p[x|t|c]|[c|m]m|%|in|ch|Q|lh)$/
|
|
12
|
+
);
|
|
13
|
+
if ( ! isNaN( cssUnit ) && ! isNaN( parseFloat( cssUnit ) ) ) {
|
|
14
|
+
return { value: parseFloat( cssUnit ), unit: 'px' };
|
|
15
|
+
}
|
|
16
|
+
return match
|
|
17
|
+
? { value: parseFloat( match[ 1 ] ) || match[ 1 ], unit: match[ 2 ] }
|
|
18
|
+
: { value: cssUnit, unit: undefined };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Evaluate a math expression.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} expression
|
|
24
|
+
* @return {number} evaluated expression.
|
|
25
|
+
*/
|
|
26
|
+
function calculate( expression ) {
|
|
27
|
+
return Function( `'use strict'; return (${ expression })` )();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Calculates the css function value for the supported css functions such as max, min, clamp and calc.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} functionUnitValue string should be in a particular format (for example min(12px,12px) ) no nested loops.
|
|
34
|
+
* @param {Object} options
|
|
35
|
+
* @return {string} unit containing the unit in PX.
|
|
36
|
+
*/
|
|
37
|
+
function getFunctionUnitValue( functionUnitValue, options ) {
|
|
38
|
+
const functionUnit = functionUnitValue.split( /[(),]/g ).filter( Boolean );
|
|
39
|
+
|
|
40
|
+
const units = functionUnit
|
|
41
|
+
.slice( 1 )
|
|
42
|
+
.map( ( unit ) => parseUnit( getPxFromCssUnit( unit, options ) ).value )
|
|
43
|
+
.filter( Boolean );
|
|
44
|
+
|
|
45
|
+
switch ( functionUnit[ 0 ] ) {
|
|
46
|
+
case 'min':
|
|
47
|
+
return Math.min( ...units ) + 'px';
|
|
48
|
+
case 'max':
|
|
49
|
+
return Math.max( ...units ) + 'px';
|
|
50
|
+
case 'clamp':
|
|
51
|
+
if ( units.length !== 3 ) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if ( units[ 1 ] < units[ 0 ] ) {
|
|
55
|
+
return units[ 0 ] + 'px';
|
|
56
|
+
}
|
|
57
|
+
if ( units[ 1 ] > units[ 2 ] ) {
|
|
58
|
+
return units[ 2 ] + 'px';
|
|
59
|
+
}
|
|
60
|
+
return units[ 1 ] + 'px';
|
|
61
|
+
case 'calc':
|
|
62
|
+
return units[ 0 ] + 'px';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Take a css function such as min, max, calc, clamp and returns parsedUnit
|
|
68
|
+
*
|
|
69
|
+
* How this works for the nested function is that it first replaces the inner function call.
|
|
70
|
+
* Then it tackles the outer onces.
|
|
71
|
+
* So for example: min( max(25px, 35px), 40px )
|
|
72
|
+
* in the first pass we would replace max(25px, 35px) with 35px.
|
|
73
|
+
* then we would try to evaluate min( 35px, 40px )
|
|
74
|
+
* and then finally return 35px.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} cssUnit
|
|
77
|
+
* @return {Object} parsedUnit object.
|
|
78
|
+
*/
|
|
79
|
+
function parseUnitFunction( cssUnit ) {
|
|
80
|
+
while ( true ) {
|
|
81
|
+
const currentCssUnit = cssUnit;
|
|
82
|
+
const regExp = /(max|min|calc|clamp)\(([^()]*)\)/g;
|
|
83
|
+
const matches = regExp.exec( cssUnit ) || [];
|
|
84
|
+
if ( matches[ 0 ] ) {
|
|
85
|
+
const functionUnitValue = getFunctionUnitValue( matches[ 0 ] );
|
|
86
|
+
cssUnit = cssUnit.replace( matches[ 0 ], functionUnitValue );
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// if the unit hasn't been modified or we have a single value break free.
|
|
90
|
+
if ( cssUnit === currentCssUnit || parseFloat( cssUnit ) ) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return parseUnit( cssUnit );
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Return true if we think this is a math expression.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} cssUnit the cssUnit value being evaluted.
|
|
101
|
+
* @return {boolean} Whether the cssUnit is a math expression.
|
|
102
|
+
*/
|
|
103
|
+
function isMathExpression( cssUnit ) {
|
|
104
|
+
for ( let i = 0; i < cssUnit.length; i++ ) {
|
|
105
|
+
if ( [ '+', '-', '/', '*' ].includes( cssUnit[ i ] ) ) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Evaluates the math expression and return a px value.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} cssUnit the cssUnit value being evaluted.
|
|
115
|
+
* @return {string} return a converfted value to px.
|
|
116
|
+
*/
|
|
117
|
+
function evalMathExpression( cssUnit ) {
|
|
118
|
+
let errorFound = false;
|
|
119
|
+
// Convert every part of the expression to px values.
|
|
120
|
+
const cssUnitsBits = cssUnit.split( /[+-/*/]/g ).filter( Boolean );
|
|
121
|
+
for ( const unit of cssUnitsBits ) {
|
|
122
|
+
// Standardize the unit to px and extract the value.
|
|
123
|
+
const parsedUnit = parseUnit( getPxFromCssUnit( unit ) );
|
|
124
|
+
if ( ! parseFloat( parsedUnit.value ) ) {
|
|
125
|
+
errorFound = true;
|
|
126
|
+
// end early since we are dealing with a null value.
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
cssUnit = cssUnit.replace( unit, parsedUnit.value );
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return errorFound ? null : calculate( cssUnit ).toFixed( 0 ) + 'px';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Convert a parsedUnit object to px value.
|
|
137
|
+
*
|
|
138
|
+
* @param {Object} parsedUnit
|
|
139
|
+
* @param {Object} options
|
|
140
|
+
* @return {string} or {null} returns the converted with in a px value format.
|
|
141
|
+
*/
|
|
142
|
+
function convertParsedUnitToPx( parsedUnit, options ) {
|
|
143
|
+
const PIXELS_PER_INCH = 96;
|
|
144
|
+
const ONE_PERCENT = 0.01;
|
|
145
|
+
|
|
146
|
+
const defaultProperties = {
|
|
147
|
+
fontSize: 16,
|
|
148
|
+
lineHeight: 16,
|
|
149
|
+
width: 375,
|
|
150
|
+
height: 812,
|
|
151
|
+
type: 'font',
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const setOptions = Object.assign( {}, defaultProperties, options );
|
|
155
|
+
|
|
156
|
+
const relativeUnits = {
|
|
157
|
+
em: setOptions.fontSize,
|
|
158
|
+
rem: setOptions.fontSize,
|
|
159
|
+
vh: setOptions.height * ONE_PERCENT,
|
|
160
|
+
vw: setOptions.width * ONE_PERCENT,
|
|
161
|
+
vmin:
|
|
162
|
+
( setOptions.width < setOptions.height
|
|
163
|
+
? setOptions.width
|
|
164
|
+
: setOptions.height ) * ONE_PERCENT,
|
|
165
|
+
vmax:
|
|
166
|
+
( setOptions.width > setOptions.height
|
|
167
|
+
? setOptions.width
|
|
168
|
+
: setOptions.height ) * ONE_PERCENT,
|
|
169
|
+
'%':
|
|
170
|
+
( setOptions.type === 'font'
|
|
171
|
+
? setOptions.fontSize
|
|
172
|
+
: setOptions.width ) * ONE_PERCENT,
|
|
173
|
+
ch: 8, // The advance measure (width) of the glyph "0" of the element's font. Approximate
|
|
174
|
+
ex: 7.15625, // x-height of the element's font. Approximate
|
|
175
|
+
lh: setOptions.lineHeight,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const absoluteUnits = {
|
|
179
|
+
in: PIXELS_PER_INCH,
|
|
180
|
+
cm: PIXELS_PER_INCH / 2.54,
|
|
181
|
+
mm: PIXELS_PER_INCH / 25.4,
|
|
182
|
+
pt: PIXELS_PER_INCH / 72,
|
|
183
|
+
pc: PIXELS_PER_INCH / 6,
|
|
184
|
+
px: 1,
|
|
185
|
+
Q: PIXELS_PER_INCH / 2.54 / 40,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if ( relativeUnits[ parsedUnit.unit ] ) {
|
|
189
|
+
return (
|
|
190
|
+
( relativeUnits[ parsedUnit.unit ] * parsedUnit.value ).toFixed(
|
|
191
|
+
0
|
|
192
|
+
) + 'px'
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if ( absoluteUnits[ parsedUnit.unit ] ) {
|
|
197
|
+
return (
|
|
198
|
+
( absoluteUnits[ parsedUnit.unit ] * parsedUnit.value ).toFixed(
|
|
199
|
+
0
|
|
200
|
+
) + 'px'
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Returns the px value of a cssUnit.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} cssUnit
|
|
211
|
+
* @param {Object} options
|
|
212
|
+
* @return {string} returns the cssUnit value in a simple px format.
|
|
213
|
+
*/
|
|
214
|
+
export function getPxFromCssUnit( cssUnit, options = {} ) {
|
|
215
|
+
if ( Number.isFinite( cssUnit ) ) {
|
|
216
|
+
return cssUnit.toFixed( 0 ) + 'px';
|
|
217
|
+
}
|
|
218
|
+
if ( cssUnit === undefined ) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
let parsedUnit = parseUnit( cssUnit );
|
|
222
|
+
|
|
223
|
+
if ( ! parsedUnit.unit ) {
|
|
224
|
+
parsedUnit = parseUnitFunction( cssUnit, options );
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if ( isMathExpression( cssUnit ) && ! parsedUnit.unit ) {
|
|
228
|
+
return evalMathExpression( cssUnit );
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return convertParsedUnitToPx( parsedUnit, options );
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Use simple cache.
|
|
235
|
+
const cache = {};
|
|
236
|
+
/**
|
|
237
|
+
* Returns the px value of a cssUnit. The memoized version of getPxFromCssUnit;
|
|
238
|
+
*
|
|
239
|
+
* @param {string} cssUnit
|
|
240
|
+
* @param {Object} options
|
|
241
|
+
* @return {string} returns the cssUnit value in a simple px format.
|
|
242
|
+
*/
|
|
243
|
+
function memoizedGetPxFromCssUnit( cssUnit, options = {} ) {
|
|
244
|
+
const hash = cssUnit + hashOptions( options );
|
|
245
|
+
|
|
246
|
+
if ( ! cache[ hash ] ) {
|
|
247
|
+
cache[ hash ] = getPxFromCssUnit( cssUnit, options );
|
|
248
|
+
}
|
|
249
|
+
return cache[ hash ];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function hashOptions( options ) {
|
|
253
|
+
let hash = '';
|
|
254
|
+
if ( options.hasOwnProperty( 'fontSize' ) ) {
|
|
255
|
+
hash = ':' + options.width;
|
|
256
|
+
}
|
|
257
|
+
if ( options.hasOwnProperty( 'lineHeight' ) ) {
|
|
258
|
+
hash = ':' + options.lineHeight;
|
|
259
|
+
}
|
|
260
|
+
if ( options.hasOwnProperty( 'width' ) ) {
|
|
261
|
+
hash = ':' + options.width;
|
|
262
|
+
}
|
|
263
|
+
if ( options.hasOwnProperty( 'height' ) ) {
|
|
264
|
+
hash = ':' + options.height;
|
|
265
|
+
}
|
|
266
|
+
if ( options.hasOwnProperty( 'type' ) ) {
|
|
267
|
+
hash = ':' + options.type;
|
|
268
|
+
}
|
|
269
|
+
return hash;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export default memoizedGetPxFromCssUnit;
|