@wordpress/block-editor 12.17.0 → 12.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +32 -0
- package/build/components/block-draggable/index.js +11 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/context.js +3 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +6 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +9 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +30 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/private-block-context.js +1 -1
- package/build/components/block-list/private-block-context.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/toolbar.js +8 -2
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +15 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +3 -2
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +12 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +119 -90
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js +2 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +7 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -14
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +30 -5
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +7 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +11 -8
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +31 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +6 -0
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +99 -0
- package/build/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build/components/iframe/index.js +2 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +16 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +16 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/link-preview.js +30 -26
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -9
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +29 -8
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +100 -32
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +52 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-block-indexes.js +30 -0
- package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build/components/list-view/use-list-view-drop-zone.js +56 -5
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +92 -0
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +21 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +30 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +9 -9
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -7
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +50 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/hooks/block-hooks.js +5 -14
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/content-lock-ui.js +17 -42
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +71 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/effects.js +66 -0
- package/build/hooks/effects.js.map +1 -0
- package/build/hooks/index.js +17 -4
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +13 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/style.js +9 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +2 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.native.js +2 -2
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +115 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -0
- package/build/hooks/use-shadow-props.js +46 -0
- package/build/hooks/use-shadow-props.js.map +1 -0
- package/build/hooks/utils.js +12 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +10 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +37 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +60 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +44 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +27 -0
- package/build/store/resolvers.js.map +1 -0
- package/build/store/selectors.js +94 -56
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -26
- package/build/store/utils.js.map +1 -1
- package/build/utils/index.js +0 -16
- package/build/utils/index.js.map +1 -1
- package/build/utils/math.js +13 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/object.js +17 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +37 -27
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +11 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +5 -3
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +7 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +6 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +11 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +31 -5
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +1 -1
- package/build-module/components/block-list/private-block-context.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +8 -2
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +15 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -2
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +116 -86
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +10 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js +2 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +7 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -14
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +30 -5
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +7 -1
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +11 -8
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +32 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +6 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +93 -0
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build-module/components/iframe/index.js +2 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +32 -28
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -8
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +10 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +30 -9
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +99 -32
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +54 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
- package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +91 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +17 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +30 -6
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +9 -9
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +31 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +51 -9
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -14
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +19 -43
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +70 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/effects.js +51 -0
- package/build-module/hooks/effects.js.map +1 -0
- package/build-module/hooks/index.js +5 -3
- 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/style.js +9 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +2 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -2
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +112 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -0
- package/build-module/hooks/use-shadow-props.js +39 -0
- package/build-module/hooks/use-shadow-props.js.map +1 -0
- package/build-module/hooks/utils.js +14 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +10 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +53 -8
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +43 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +20 -0
- package/build-module/store/resolvers.js.map +1 -0
- package/build-module/store/selectors.js +89 -52
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -23
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/object.js +16 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +36 -27
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +33 -16
- package/build-style/content.css +33 -16
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +169 -114
- package/build-style/style.css +169 -114
- package/package.json +31 -31
- package/src/components/block-canvas/style.scss +8 -1
- package/src/components/block-draggable/index.js +16 -5
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +4 -0
- package/src/components/block-editing-mode/index.js +12 -7
- package/src/components/block-inspector/index.js +5 -2
- package/src/components/block-list/block.js +5 -4
- package/src/components/block-list/block.native.js +13 -3
- package/src/components/block-list/content.scss +34 -5
- package/src/components/block-list/index.js +52 -16
- package/src/components/block-list/private-block-context.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +1 -2
- package/src/components/block-lock/toolbar.js +10 -2
- package/src/components/block-popover/inbetween.js +22 -2
- package/src/components/block-preview/auto.js +3 -3
- package/src/components/block-removal-warning-modal/index.js +3 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/src/components/block-switcher/block-transformations-menu.js +18 -1
- package/src/components/block-switcher/index.js +133 -111
- package/src/components/block-switcher/style.scss +6 -4
- package/src/components/block-switcher/test/index.js +113 -230
- package/src/components/block-toolbar/style.scss +22 -18
- package/src/components/block-tools/insertion-point.js +15 -2
- package/src/components/block-tools/style.scss +8 -7
- package/src/components/dimensions-tool/aspect-ratio-tool.js +4 -1
- package/src/components/font-sizes/fluid-utils.js +8 -2
- package/src/components/font-sizes/test/fluid-utils.js +9 -0
- package/src/components/global-styles/border-panel.js +7 -17
- package/src/components/global-styles/dimensions-panel.js +50 -1
- package/src/components/global-styles/effects-panel.js +16 -1
- package/src/components/global-styles/hooks.js +11 -6
- package/src/components/global-styles/typography-panel.js +45 -13
- package/src/components/global-styles/use-global-styles-output.js +6 -0
- package/src/components/iframe/get-compatibility-styles.js +120 -0
- package/src/components/iframe/index.js +2 -3
- package/src/components/index.js +4 -2
- package/src/components/index.native.js +4 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
- package/src/components/link-control/link-preview.js +31 -55
- package/src/components/link-control/search-input.js +1 -9
- package/src/components/link-control/style.scss +31 -85
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/list-view/block-contents.js +5 -1
- package/src/components/list-view/block.js +9 -0
- package/src/components/list-view/branch.js +30 -10
- package/src/components/list-view/drop-indicator.js +139 -46
- package/src/components/list-view/index.js +74 -3
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/style.scss +102 -13
- package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
- package/src/components/list-view/test/utils.js +218 -1
- package/src/components/list-view/use-list-view-block-indexes.js +29 -0
- package/src/components/list-view/use-list-view-drop-zone.js +78 -6
- package/src/components/list-view/utils.js +116 -0
- package/src/components/provider/index.js +3 -1
- package/src/components/recursion-provider/README.md +2 -2
- package/src/components/recursion-provider/index.js +17 -0
- package/src/components/rich-text/index.js +48 -10
- package/src/components/rich-text/native/index.native.js +10 -10
- package/src/components/use-block-drop-zone/index.js +60 -19
- package/src/components/use-block-drop-zone/test/index.js +32 -61
- package/src/components/use-on-block-drop/index.js +92 -11
- package/src/hooks/block-hooks.js +5 -17
- package/src/hooks/content-lock-ui.js +15 -55
- package/src/hooks/dimensions.js +74 -3
- package/src/hooks/effects.js +57 -0
- package/src/hooks/index.js +4 -2
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/style.js +12 -0
- package/src/hooks/supports.js +2 -0
- package/src/hooks/test/effects.js +39 -0
- package/src/hooks/typography.native.js +2 -2
- package/src/hooks/use-bindings-attributes.js +148 -0
- package/src/hooks/use-shadow-props.js +37 -0
- package/src/hooks/utils.js +30 -10
- package/src/index.js +2 -0
- package/src/store/actions.js +9 -4
- package/src/store/index.js +2 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-selectors.js +78 -21
- package/src/store/reducer.js +49 -2
- package/src/store/resolvers.js +17 -0
- package/src/store/selectors.js +169 -161
- package/src/store/test/registry-selectors.js +431 -0
- package/src/store/test/selectors.js +14 -400
- package/src/store/utils.js +10 -33
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/math.js +12 -0
- package/src/utils/object.js +16 -0
- package/src/utils/transform-styles/index.js +52 -37
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/iframe/use-compatibility-styles.js +0 -100
- package/build/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -106
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/block-variation-transforms.js +0 -42
- package/build/utils/block-variation-transforms.js.map +0 -1
- package/build-module/components/iframe/use-compatibility-styles.js +0 -94
- package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -99
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/block-variation-transforms.js +0 -35
- package/build-module/utils/block-variation-transforms.js.map +0 -1
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
- package/src/components/contrast-checker/style.scss +0 -3
- package/src/components/iframe/use-compatibility-styles.js +0 -122
- package/src/hooks/custom-fields.js +0 -115
- package/src/utils/block-variation-transforms.js +0 -38
- package/src/utils/test/block-variation-transforms.js +0 -94
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { useState, useCallback } from '@wordpress/element';
|
|
5
|
+
import { useState, useCallback, useEffect } from '@wordpress/element';
|
|
6
6
|
import {
|
|
7
7
|
useThrottle,
|
|
8
8
|
__experimentalUseDropZone as useDropZone,
|
|
9
|
+
usePrevious,
|
|
9
10
|
} from '@wordpress/compose';
|
|
10
11
|
import { isRTL } from '@wordpress/i18n';
|
|
11
12
|
|
|
@@ -304,6 +305,7 @@ export function getListViewDropTarget( blocksData, position, rtl = false ) {
|
|
|
304
305
|
|
|
305
306
|
return {
|
|
306
307
|
rootClientId: candidateBlockData.clientId,
|
|
308
|
+
clientId: candidateBlockData.clientId,
|
|
307
309
|
blockIndex: newBlockIndex,
|
|
308
310
|
dropPosition: 'inside',
|
|
309
311
|
};
|
|
@@ -396,15 +398,30 @@ export function getListViewDropTarget( blocksData, position, rtl = false ) {
|
|
|
396
398
|
};
|
|
397
399
|
}
|
|
398
400
|
|
|
401
|
+
// Throttle options need to be defined outside of the hook to avoid
|
|
402
|
+
// re-creating the object on every render. This is due to a limitation
|
|
403
|
+
// of the `useThrottle` hook, where the options object is included
|
|
404
|
+
// in the dependency array for memoization.
|
|
405
|
+
const EXPAND_THROTTLE_OPTIONS = {
|
|
406
|
+
leading: false, // Don't call the function immediately on the first call.
|
|
407
|
+
trailing: true, // Do call the function on the last call.
|
|
408
|
+
};
|
|
409
|
+
|
|
399
410
|
/**
|
|
400
411
|
* A react hook for implementing a drop zone in list view.
|
|
401
412
|
*
|
|
402
|
-
* @param {Object} props
|
|
403
|
-
* @param {?HTMLElement} [props.dropZoneElement]
|
|
413
|
+
* @param {Object} props Named parameters.
|
|
414
|
+
* @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone.
|
|
415
|
+
* @param {Object} [props.expandedState] The expanded state of the blocks in the list view.
|
|
416
|
+
* @param {Function} [props.setExpandedState] Function to set the expanded state of a list of block clientIds.
|
|
404
417
|
*
|
|
405
418
|
* @return {WPListViewDropZoneTarget} The drop target.
|
|
406
419
|
*/
|
|
407
|
-
export default function useListViewDropZone( {
|
|
420
|
+
export default function useListViewDropZone( {
|
|
421
|
+
dropZoneElement,
|
|
422
|
+
expandedState,
|
|
423
|
+
setExpandedState,
|
|
424
|
+
} ) {
|
|
408
425
|
const {
|
|
409
426
|
getBlockRootClientId,
|
|
410
427
|
getBlockIndex,
|
|
@@ -420,6 +437,55 @@ export default function useListViewDropZone( { dropZoneElement } ) {
|
|
|
420
437
|
|
|
421
438
|
const rtl = isRTL();
|
|
422
439
|
|
|
440
|
+
const previousRootClientId = usePrevious( targetRootClientId );
|
|
441
|
+
|
|
442
|
+
const maybeExpandBlock = useCallback(
|
|
443
|
+
( _expandedState, _target ) => {
|
|
444
|
+
// If the user is attempting to drop a block inside a collapsed block,
|
|
445
|
+
// that is, using a nesting gesture flagged by 'inside' dropPosition,
|
|
446
|
+
// expand the block within the list view, if it isn't already.
|
|
447
|
+
const { rootClientId } = _target || {};
|
|
448
|
+
if ( ! rootClientId ) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (
|
|
452
|
+
_target?.dropPosition === 'inside' &&
|
|
453
|
+
! _expandedState[ rootClientId ]
|
|
454
|
+
) {
|
|
455
|
+
setExpandedState( {
|
|
456
|
+
type: 'expand',
|
|
457
|
+
clientIds: [ rootClientId ],
|
|
458
|
+
} );
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
[ setExpandedState ]
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
// Throttle the maybeExpandBlock function to avoid expanding the block
|
|
465
|
+
// too quickly when the user is dragging over the block. This is to
|
|
466
|
+
// avoid expanding the block when the user is just passing over it.
|
|
467
|
+
const throttledMaybeExpandBlock = useThrottle(
|
|
468
|
+
maybeExpandBlock,
|
|
469
|
+
500,
|
|
470
|
+
EXPAND_THROTTLE_OPTIONS
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
useEffect( () => {
|
|
474
|
+
if (
|
|
475
|
+
target?.dropPosition !== 'inside' ||
|
|
476
|
+
previousRootClientId !== target?.rootClientId
|
|
477
|
+
) {
|
|
478
|
+
throttledMaybeExpandBlock.cancel();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
throttledMaybeExpandBlock( expandedState, target );
|
|
482
|
+
}, [
|
|
483
|
+
expandedState,
|
|
484
|
+
previousRootClientId,
|
|
485
|
+
target,
|
|
486
|
+
throttledMaybeExpandBlock,
|
|
487
|
+
] );
|
|
488
|
+
|
|
423
489
|
const draggedBlockClientIds = getDraggedBlockClientIds();
|
|
424
490
|
const throttled = useThrottle(
|
|
425
491
|
useCallback(
|
|
@@ -484,7 +550,7 @@ export default function useListViewDropZone( { dropZoneElement } ) {
|
|
|
484
550
|
rtl,
|
|
485
551
|
]
|
|
486
552
|
),
|
|
487
|
-
|
|
553
|
+
50
|
|
488
554
|
);
|
|
489
555
|
|
|
490
556
|
const ref = useDropZone( {
|
|
@@ -496,6 +562,9 @@ export default function useListViewDropZone( { dropZoneElement } ) {
|
|
|
496
562
|
},
|
|
497
563
|
onDragLeave() {
|
|
498
564
|
throttled.cancel();
|
|
565
|
+
// Use `null` value to indicate that the drop target is not valid,
|
|
566
|
+
// but that the drag is still active. This allows for styling rules
|
|
567
|
+
// that are active only when a user drags outside of the list view.
|
|
499
568
|
setTarget( null );
|
|
500
569
|
},
|
|
501
570
|
onDragOver( event ) {
|
|
@@ -506,7 +575,10 @@ export default function useListViewDropZone( { dropZoneElement } ) {
|
|
|
506
575
|
},
|
|
507
576
|
onDragEnd() {
|
|
508
577
|
throttled.cancel();
|
|
509
|
-
|
|
578
|
+
// Use `undefined` value to indicate that the drag has concluded.
|
|
579
|
+
// This allows styling rules that are active only when a user is
|
|
580
|
+
// dragging to be removed.
|
|
581
|
+
setTarget( undefined );
|
|
510
582
|
},
|
|
511
583
|
} );
|
|
512
584
|
|
|
@@ -93,3 +93,119 @@ export function focusListItem( focusClientId, treeGridElementRef ) {
|
|
|
93
93
|
} );
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get values for the block that flag whether the block should be displaced up or down,
|
|
99
|
+
* whether the block is being nested, and whether the block appears after the dragged
|
|
100
|
+
* blocks. These values are used to determine the class names to apply to the block.
|
|
101
|
+
* The list view rows are displaced visually via CSS rules. Displacement rules:
|
|
102
|
+
* - `normal`: no displacement — used to apply a translateY of `0` so that the block
|
|
103
|
+
* appears in its original position, and moves to that position smoothly when dragging
|
|
104
|
+
* outside of the list view area.
|
|
105
|
+
* - `up`: the block should be displaced up, creating room beneath the block for the drop indicator.
|
|
106
|
+
* - `down`: the block should be displaced down, creating room above the block for the drop indicator.
|
|
107
|
+
*
|
|
108
|
+
* @param {Object} props
|
|
109
|
+
* @param {Object} props.blockIndexes The indexes of all the blocks in the list view, keyed by clientId.
|
|
110
|
+
* @param {number|null|undefined} props.blockDropTargetIndex The index of the block that the user is dropping to.
|
|
111
|
+
* @param {?string} props.blockDropPosition The position relative to the block that the user is dropping to.
|
|
112
|
+
* @param {string} props.clientId The client id for the current block.
|
|
113
|
+
* @param {?number} props.firstDraggedBlockIndex The index of the first dragged block.
|
|
114
|
+
* @param {?boolean} props.isDragged Whether the current block is being dragged. Dragged blocks skip displacement.
|
|
115
|
+
* @return {Object} An object containing the `displacement`, `isAfterDraggedBlocks` and `isNesting` values.
|
|
116
|
+
*/
|
|
117
|
+
export function getDragDisplacementValues( {
|
|
118
|
+
blockIndexes,
|
|
119
|
+
blockDropTargetIndex,
|
|
120
|
+
blockDropPosition,
|
|
121
|
+
clientId,
|
|
122
|
+
firstDraggedBlockIndex,
|
|
123
|
+
isDragged,
|
|
124
|
+
} ) {
|
|
125
|
+
let displacement;
|
|
126
|
+
let isNesting;
|
|
127
|
+
let isAfterDraggedBlocks;
|
|
128
|
+
|
|
129
|
+
if ( ! isDragged ) {
|
|
130
|
+
isNesting = false;
|
|
131
|
+
const thisBlockIndex = blockIndexes[ clientId ];
|
|
132
|
+
isAfterDraggedBlocks = thisBlockIndex > firstDraggedBlockIndex;
|
|
133
|
+
|
|
134
|
+
// Determine where to displace the position of the current block, relative
|
|
135
|
+
// to the blocks being dragged (in their original position) and the drop target
|
|
136
|
+
// (the position where a user is currently dragging the blocks to).
|
|
137
|
+
if (
|
|
138
|
+
blockDropTargetIndex !== undefined &&
|
|
139
|
+
blockDropTargetIndex !== null &&
|
|
140
|
+
firstDraggedBlockIndex !== undefined
|
|
141
|
+
) {
|
|
142
|
+
// If the block is being dragged and there is a valid drop target,
|
|
143
|
+
// determine if the block being rendered should be displaced up or down.
|
|
144
|
+
|
|
145
|
+
if ( thisBlockIndex !== undefined ) {
|
|
146
|
+
if (
|
|
147
|
+
thisBlockIndex >= firstDraggedBlockIndex &&
|
|
148
|
+
thisBlockIndex < blockDropTargetIndex
|
|
149
|
+
) {
|
|
150
|
+
// If the current block appears after the set of dragged blocks
|
|
151
|
+
// (in their original position), but is before the drop target,
|
|
152
|
+
// then the current block should be displaced up.
|
|
153
|
+
displacement = 'up';
|
|
154
|
+
} else if (
|
|
155
|
+
thisBlockIndex < firstDraggedBlockIndex &&
|
|
156
|
+
thisBlockIndex >= blockDropTargetIndex
|
|
157
|
+
) {
|
|
158
|
+
// If the current block appears before the set of dragged blocks
|
|
159
|
+
// (in their original position), but is after the drop target,
|
|
160
|
+
// then the current block should be displaced down.
|
|
161
|
+
displacement = 'down';
|
|
162
|
+
} else {
|
|
163
|
+
displacement = 'normal';
|
|
164
|
+
}
|
|
165
|
+
isNesting =
|
|
166
|
+
typeof blockDropTargetIndex === 'number' &&
|
|
167
|
+
blockDropTargetIndex - 1 === thisBlockIndex &&
|
|
168
|
+
blockDropPosition === 'inside';
|
|
169
|
+
}
|
|
170
|
+
} else if (
|
|
171
|
+
blockDropTargetIndex === null &&
|
|
172
|
+
firstDraggedBlockIndex !== undefined
|
|
173
|
+
) {
|
|
174
|
+
// A `null` value for `blockDropTargetIndex` indicates that the
|
|
175
|
+
// drop target is outside of the valid areas within the list view.
|
|
176
|
+
// In this case, the drag is still active, but as there is no
|
|
177
|
+
// valid drop target, we should remove the gap indicating where
|
|
178
|
+
// the block would be inserted.
|
|
179
|
+
if (
|
|
180
|
+
thisBlockIndex !== undefined &&
|
|
181
|
+
thisBlockIndex >= firstDraggedBlockIndex
|
|
182
|
+
) {
|
|
183
|
+
displacement = 'up';
|
|
184
|
+
} else {
|
|
185
|
+
displacement = 'normal';
|
|
186
|
+
}
|
|
187
|
+
} else if (
|
|
188
|
+
blockDropTargetIndex !== undefined &&
|
|
189
|
+
blockDropTargetIndex !== null &&
|
|
190
|
+
firstDraggedBlockIndex === undefined
|
|
191
|
+
) {
|
|
192
|
+
// If the blockdrop target is defined, but there are no dragged blocks,
|
|
193
|
+
// then the block should be displaced relative to the drop target.
|
|
194
|
+
if ( thisBlockIndex !== undefined ) {
|
|
195
|
+
if ( thisBlockIndex < blockDropTargetIndex ) {
|
|
196
|
+
displacement = 'normal';
|
|
197
|
+
} else {
|
|
198
|
+
displacement = 'down';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else if ( blockDropTargetIndex === null ) {
|
|
202
|
+
displacement = 'normal';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
displacement,
|
|
208
|
+
isNesting,
|
|
209
|
+
isAfterDraggedBlocks,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
@@ -46,7 +46,9 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<SlotFillProvider passthrough>
|
|
49
|
-
|
|
49
|
+
{ ! settings.__unstableIsPreviewMode && (
|
|
50
|
+
<KeyboardShortcuts.Register />
|
|
51
|
+
) }
|
|
50
52
|
<BlockRefsProvider>{ children }</BlockRefsProvider>
|
|
51
53
|
</SlotFillProvider>
|
|
52
54
|
);
|
|
@@ -11,8 +11,8 @@ To help with detecting infinite loops on the client, the `RecursionProvider` com
|
|
|
11
11
|
* WordPress dependencies
|
|
12
12
|
*/
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
RecursionProvider,
|
|
15
|
+
useHasRecursion,
|
|
16
16
|
useBlockProps,
|
|
17
17
|
Warning,
|
|
18
18
|
} from '@wordpress/block-editor';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createContext, useContext, useMemo } from '@wordpress/element';
|
|
5
|
+
import deprecated from '@wordpress/deprecated';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -82,3 +83,19 @@ export function useHasRecursion( uniqueId, blockName = '' ) {
|
|
|
82
83
|
blockName = blockName || name;
|
|
83
84
|
return Boolean( previouslyRenderedBlocks[ blockName ]?.has( uniqueId ) );
|
|
84
85
|
}
|
|
86
|
+
|
|
87
|
+
export const DeprecatedExperimentalRecursionProvider = ( props ) => {
|
|
88
|
+
deprecated( 'wp.blockEditor.__experimentalRecursionProvider', {
|
|
89
|
+
since: '6.5',
|
|
90
|
+
alternative: 'wp.blockEditor.RecursionProvider',
|
|
91
|
+
} );
|
|
92
|
+
return <RecursionProvider { ...props } />;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const DeprecatedExperimentalUseHasRecursion = ( props ) => {
|
|
96
|
+
deprecated( 'wp.blockEditor.__experimentalUseHasRecursion', {
|
|
97
|
+
since: '6.5',
|
|
98
|
+
alternative: 'wp.blockEditor.useHasRecursion',
|
|
99
|
+
} );
|
|
100
|
+
return useHasRecursion( ...props );
|
|
101
|
+
};
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
removeFormat,
|
|
20
20
|
} from '@wordpress/rich-text';
|
|
21
21
|
import { Popover } from '@wordpress/components';
|
|
22
|
+
import { getBlockType } from '@wordpress/blocks';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Internal dependencies
|
|
@@ -44,6 +45,7 @@ import FormatEdit from './format-edit';
|
|
|
44
45
|
import { getAllowedFormats } from './utils';
|
|
45
46
|
import { Content } from './content';
|
|
46
47
|
import { withDeprecations } from './with-deprecations';
|
|
48
|
+
import { unlock } from '../../lock-unlock';
|
|
47
49
|
|
|
48
50
|
export const keyboardShortcutContext = createContext();
|
|
49
51
|
export const inputEventContext = createContext();
|
|
@@ -113,7 +115,11 @@ export function RichTextWrapper(
|
|
|
113
115
|
props = removeNativeProps( props );
|
|
114
116
|
|
|
115
117
|
const anchorRef = useRef();
|
|
116
|
-
const {
|
|
118
|
+
const {
|
|
119
|
+
clientId,
|
|
120
|
+
isSelected: isBlockSelected,
|
|
121
|
+
name: blockName,
|
|
122
|
+
} = useBlockEditContext();
|
|
117
123
|
const selector = ( select ) => {
|
|
118
124
|
// Avoid subscribing to the block editor store if the block is not
|
|
119
125
|
// selected.
|
|
@@ -121,10 +127,12 @@ export function RichTextWrapper(
|
|
|
121
127
|
return { isSelected: false };
|
|
122
128
|
}
|
|
123
129
|
|
|
124
|
-
const { getSelectionStart, getSelectionEnd } =
|
|
130
|
+
const { getSelectionStart, getSelectionEnd, getBlockAttributes } =
|
|
125
131
|
select( blockEditorStore );
|
|
126
132
|
const selectionStart = getSelectionStart();
|
|
127
133
|
const selectionEnd = getSelectionEnd();
|
|
134
|
+
const blockBindings =
|
|
135
|
+
getBlockAttributes( clientId )?.metadata?.bindings;
|
|
128
136
|
|
|
129
137
|
let isSelected;
|
|
130
138
|
|
|
@@ -137,18 +145,44 @@ export function RichTextWrapper(
|
|
|
137
145
|
isSelected = selectionStart.clientId === clientId;
|
|
138
146
|
}
|
|
139
147
|
|
|
148
|
+
// Disable Rich Text editing if block bindings specify that.
|
|
149
|
+
let shouldDisableEditing = false;
|
|
150
|
+
if ( blockBindings ) {
|
|
151
|
+
const blockTypeAttributes = getBlockType( blockName ).attributes;
|
|
152
|
+
const { getBlockBindingsSource } = unlock(
|
|
153
|
+
select( blockEditorStore )
|
|
154
|
+
);
|
|
155
|
+
for ( const [ attribute, args ] of Object.entries(
|
|
156
|
+
blockBindings
|
|
157
|
+
) ) {
|
|
158
|
+
// If any of the attributes with source "rich-text" is part of the bindings,
|
|
159
|
+
// has a source with `lockAttributesEditing`, disable it.
|
|
160
|
+
if (
|
|
161
|
+
blockTypeAttributes?.[ attribute ]?.source ===
|
|
162
|
+
'rich-text' &&
|
|
163
|
+
getBlockBindingsSource( args.source.name )
|
|
164
|
+
?.lockAttributesEditing
|
|
165
|
+
) {
|
|
166
|
+
shouldDisableEditing = true;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
140
172
|
return {
|
|
141
173
|
selectionStart: isSelected ? selectionStart.offset : undefined,
|
|
142
174
|
selectionEnd: isSelected ? selectionEnd.offset : undefined,
|
|
143
175
|
isSelected,
|
|
176
|
+
shouldDisableEditing,
|
|
144
177
|
};
|
|
145
178
|
};
|
|
146
|
-
const { selectionStart, selectionEnd, isSelected } =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
179
|
+
const { selectionStart, selectionEnd, isSelected, shouldDisableEditing } =
|
|
180
|
+
useSelect( selector, [
|
|
181
|
+
clientId,
|
|
182
|
+
identifier,
|
|
183
|
+
originalIsSelected,
|
|
184
|
+
isBlockSelected,
|
|
185
|
+
] );
|
|
152
186
|
const { getSelectionStart, getSelectionEnd, getBlockRootClientId } =
|
|
153
187
|
useSelect( blockEditorStore );
|
|
154
188
|
const { selectionChange } = useDispatch( blockEditorStore );
|
|
@@ -376,7 +410,7 @@ export function RichTextWrapper(
|
|
|
376
410
|
useFirefoxCompat(),
|
|
377
411
|
anchorRef,
|
|
378
412
|
] ) }
|
|
379
|
-
contentEditable={
|
|
413
|
+
contentEditable={ ! shouldDisableEditing }
|
|
380
414
|
suppressContentEditableWarning={ true }
|
|
381
415
|
className={ classnames(
|
|
382
416
|
'block-editor-rich-text__editable',
|
|
@@ -389,7 +423,11 @@ export function RichTextWrapper(
|
|
|
389
423
|
// select blocks when Shift Clicking into an element with
|
|
390
424
|
// tabIndex because Safari will focus the element. However,
|
|
391
425
|
// Safari will correctly ignore nested contentEditable elements.
|
|
392
|
-
tabIndex={
|
|
426
|
+
tabIndex={
|
|
427
|
+
props.tabIndex === 0 && ! shouldDisableEditing
|
|
428
|
+
? null
|
|
429
|
+
: props.tabIndex
|
|
430
|
+
}
|
|
393
431
|
data-wp-block-attribute-key={ identifier }
|
|
394
432
|
/>
|
|
395
433
|
</>
|
|
@@ -264,7 +264,7 @@ export class RichText extends Component {
|
|
|
264
264
|
onCreateUndoLevel() {
|
|
265
265
|
const { __unstableOnCreateUndoLevel: onCreateUndoLevel } = this.props;
|
|
266
266
|
// If the content is the same, no level needs to be created.
|
|
267
|
-
if ( this.lastHistoryValue
|
|
267
|
+
if ( this.lastHistoryValue?.toString() === this.value?.toString() ) {
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -317,7 +317,7 @@ export class RichText extends Component {
|
|
|
317
317
|
event.nativeEvent.text
|
|
318
318
|
);
|
|
319
319
|
// On iOS, onChange can be triggered after selection changes, even though there are no content changes.
|
|
320
|
-
if ( contentWithoutRootTag === this.value
|
|
320
|
+
if ( contentWithoutRootTag === this.value?.toString() ) {
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
323
|
this.lastEventCount = event.nativeEvent.eventCount;
|
|
@@ -333,7 +333,7 @@ export class RichText extends Component {
|
|
|
333
333
|
);
|
|
334
334
|
|
|
335
335
|
this.debounceCreateUndoLevel();
|
|
336
|
-
const refresh = this.value
|
|
336
|
+
const refresh = this.value?.toString() !== contentWithoutRootTag;
|
|
337
337
|
this.value = contentWithoutRootTag;
|
|
338
338
|
|
|
339
339
|
// We don't want to refresh if our goal is just to create a record.
|
|
@@ -564,7 +564,7 @@ export class RichText extends Component {
|
|
|
564
564
|
// Check if value is up to date with latest state of native AztecView.
|
|
565
565
|
if (
|
|
566
566
|
event.nativeEvent.text &&
|
|
567
|
-
event.nativeEvent.text !== this.props.value
|
|
567
|
+
event.nativeEvent.text !== this.props.value?.toString()
|
|
568
568
|
) {
|
|
569
569
|
this.onTextUpdate( event );
|
|
570
570
|
}
|
|
@@ -589,7 +589,7 @@ export class RichText extends Component {
|
|
|
589
589
|
// this approach is not perfectly reliable.
|
|
590
590
|
const isManual =
|
|
591
591
|
this.lastAztecEventType !== 'input' &&
|
|
592
|
-
this.props.value
|
|
592
|
+
this.props.value?.toString() === this.value?.toString();
|
|
593
593
|
if ( hasChanged && isManual ) {
|
|
594
594
|
const value = this.createRecord();
|
|
595
595
|
const activeFormats = getActiveFormats( value );
|
|
@@ -659,7 +659,7 @@ export class RichText extends Component {
|
|
|
659
659
|
event.nativeEvent.text
|
|
660
660
|
);
|
|
661
661
|
if (
|
|
662
|
-
contentWithoutRootTag === this.value
|
|
662
|
+
contentWithoutRootTag === this.value?.toString() &&
|
|
663
663
|
realStart === this.selectionStart &&
|
|
664
664
|
realEnd === this.selectionEnd
|
|
665
665
|
) {
|
|
@@ -756,7 +756,7 @@ export class RichText extends Component {
|
|
|
756
756
|
typeof nextProps.value !== 'undefined' &&
|
|
757
757
|
typeof this.props.value !== 'undefined' &&
|
|
758
758
|
( ! this.comesFromAztec || ! this.firedAfterTextChanged ) &&
|
|
759
|
-
nextProps.value
|
|
759
|
+
nextProps.value?.toString() !== this.props.value?.toString()
|
|
760
760
|
) {
|
|
761
761
|
// Gutenberg seems to try to mirror the caret state even on events that only change the content so,
|
|
762
762
|
// let's force caret update if state has selection set.
|
|
@@ -824,7 +824,7 @@ export class RichText extends Component {
|
|
|
824
824
|
const { style, tagName } = this.props;
|
|
825
825
|
const { currentFontSize } = this.state;
|
|
826
826
|
|
|
827
|
-
if ( this.props.value
|
|
827
|
+
if ( this.props.value?.toString() !== this.value?.toString() ) {
|
|
828
828
|
this.value = this.props.value;
|
|
829
829
|
}
|
|
830
830
|
const { __unstableIsSelected: prevIsSelected } = prevProps;
|
|
@@ -884,8 +884,8 @@ export class RichText extends Component {
|
|
|
884
884
|
// On android if content is empty we need to send no content or else the placeholder will not show.
|
|
885
885
|
if (
|
|
886
886
|
! this.isIOS &&
|
|
887
|
-
( value
|
|
888
|
-
value
|
|
887
|
+
( value?.toString() === '' ||
|
|
888
|
+
value?.toString() === EMPTY_PARAGRAPH_TAGS )
|
|
889
889
|
) {
|
|
890
890
|
return '';
|
|
891
891
|
}
|
|
@@ -20,6 +20,7 @@ import useOnBlockDrop from '../use-on-block-drop';
|
|
|
20
20
|
import {
|
|
21
21
|
getDistanceToNearestEdge,
|
|
22
22
|
isPointContainedByRect,
|
|
23
|
+
isPointWithinTopAndBottomBoundariesOfRect,
|
|
23
24
|
} from '../../utils/math';
|
|
24
25
|
import { store as blockEditorStore } from '../../store';
|
|
25
26
|
|
|
@@ -72,6 +73,8 @@ export function getDropTargetPosition(
|
|
|
72
73
|
let nearestIndex = 0;
|
|
73
74
|
let insertPosition = 'before';
|
|
74
75
|
let minDistance = Infinity;
|
|
76
|
+
let targetBlockIndex = null;
|
|
77
|
+
let nearestSide = 'right';
|
|
75
78
|
|
|
76
79
|
const {
|
|
77
80
|
dropZoneElement,
|
|
@@ -136,7 +139,12 @@ export function getDropTargetPosition(
|
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
blocksData.forEach(
|
|
139
|
-
( {
|
|
142
|
+
( {
|
|
143
|
+
isUnmodifiedDefaultBlock,
|
|
144
|
+
getBoundingClientRect,
|
|
145
|
+
blockIndex,
|
|
146
|
+
blockOrientation,
|
|
147
|
+
} ) => {
|
|
140
148
|
const rect = getBoundingClientRect();
|
|
141
149
|
|
|
142
150
|
let [ distance, edge ] = getDistanceToNearestEdge(
|
|
@@ -144,12 +152,35 @@ export function getDropTargetPosition(
|
|
|
144
152
|
rect,
|
|
145
153
|
allowedEdges
|
|
146
154
|
);
|
|
155
|
+
// If the the point is close to a side, prioritize that side.
|
|
156
|
+
const [ sideDistance, sideEdge ] = getDistanceToNearestEdge(
|
|
157
|
+
position,
|
|
158
|
+
rect,
|
|
159
|
+
[ 'left', 'right' ]
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const isPointInsideRect = isPointContainedByRect( position, rect );
|
|
163
|
+
|
|
147
164
|
// Prioritize the element if the point is inside of an unmodified default block.
|
|
148
|
-
if (
|
|
149
|
-
isUnmodifiedDefaultBlock &&
|
|
150
|
-
isPointContainedByRect( position, rect )
|
|
151
|
-
) {
|
|
165
|
+
if ( isUnmodifiedDefaultBlock && isPointInsideRect ) {
|
|
152
166
|
distance = 0;
|
|
167
|
+
} else if (
|
|
168
|
+
orientation === 'vertical' &&
|
|
169
|
+
blockOrientation !== 'horizontal' &&
|
|
170
|
+
( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||
|
|
171
|
+
( ! isPointInsideRect &&
|
|
172
|
+
isPointWithinTopAndBottomBoundariesOfRect(
|
|
173
|
+
position,
|
|
174
|
+
rect
|
|
175
|
+
) ) )
|
|
176
|
+
) {
|
|
177
|
+
/**
|
|
178
|
+
* This condition should only apply when the layout is vertical (otherwise there's
|
|
179
|
+
* no need to create a Row) and dropzones should only activate when the block is
|
|
180
|
+
* either within and close to the sides of the target block or on its outer sides.
|
|
181
|
+
*/
|
|
182
|
+
targetBlockIndex = blockIndex;
|
|
183
|
+
nearestSide = sideEdge;
|
|
153
184
|
}
|
|
154
185
|
|
|
155
186
|
if ( distance < minDistance ) {
|
|
@@ -175,6 +206,10 @@ export function getDropTargetPosition(
|
|
|
175
206
|
const isAdjacentBlockUnmodifiedDefaultBlock =
|
|
176
207
|
!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;
|
|
177
208
|
|
|
209
|
+
// If the target index is set then group with the block at that index.
|
|
210
|
+
if ( targetBlockIndex !== null ) {
|
|
211
|
+
return [ targetBlockIndex, 'group', nearestSide ];
|
|
212
|
+
}
|
|
178
213
|
// If both blocks are not unmodified default blocks then just insert between them.
|
|
179
214
|
if (
|
|
180
215
|
! isNearestBlockUnmodifiedDefaultBlock &&
|
|
@@ -284,6 +319,7 @@ export default function useBlockDropZone( {
|
|
|
284
319
|
dropTarget.index,
|
|
285
320
|
{
|
|
286
321
|
operation: dropTarget.operation,
|
|
322
|
+
nearestSide: dropTarget.nearestSide,
|
|
287
323
|
}
|
|
288
324
|
);
|
|
289
325
|
const throttled = useThrottle(
|
|
@@ -333,28 +369,32 @@ export default function useBlockDropZone( {
|
|
|
333
369
|
.getElementById( `block-${ clientId }` )
|
|
334
370
|
.getBoundingClientRect(),
|
|
335
371
|
blockIndex: getBlockIndex( clientId ),
|
|
372
|
+
blockOrientation:
|
|
373
|
+
getBlockListSettings( clientId )?.orientation,
|
|
336
374
|
};
|
|
337
375
|
} );
|
|
338
376
|
|
|
339
|
-
const [ targetIndex, operation ] =
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
377
|
+
const [ targetIndex, operation, nearestSide ] =
|
|
378
|
+
getDropTargetPosition(
|
|
379
|
+
blocksData,
|
|
380
|
+
{ x: event.clientX, y: event.clientY },
|
|
381
|
+
getBlockListSettings( targetRootClientId )?.orientation,
|
|
382
|
+
{
|
|
383
|
+
dropZoneElement,
|
|
384
|
+
parentBlockClientId,
|
|
385
|
+
parentBlockOrientation: parentBlockClientId
|
|
386
|
+
? getBlockListSettings( parentBlockClientId )
|
|
387
|
+
?.orientation
|
|
388
|
+
: undefined,
|
|
389
|
+
rootBlockIndex: getBlockIndex( targetRootClientId ),
|
|
390
|
+
}
|
|
391
|
+
);
|
|
353
392
|
|
|
354
393
|
registry.batch( () => {
|
|
355
394
|
setDropTarget( {
|
|
356
395
|
index: targetIndex,
|
|
357
396
|
operation,
|
|
397
|
+
nearestSide,
|
|
358
398
|
} );
|
|
359
399
|
|
|
360
400
|
const insertionPointClientId = [
|
|
@@ -366,6 +406,7 @@ export default function useBlockDropZone( {
|
|
|
366
406
|
|
|
367
407
|
showInsertionPoint( insertionPointClientId, targetIndex, {
|
|
368
408
|
operation,
|
|
409
|
+
nearestSide,
|
|
369
410
|
} );
|
|
370
411
|
} );
|
|
371
412
|
},
|