@wordpress/block-editor 16.0.0 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +8 -0
- package/build/components/alignment-control/ui.cjs +2 -4
- package/build/components/alignment-control/ui.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +40 -10
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-alignment-control/ui.cjs +5 -3
- package/build/components/block-alignment-control/ui.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +73 -46
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +4 -1
- package/build/components/block-list/block-html.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +5 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +2 -3
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs +48 -0
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs.map +7 -0
- package/build/components/block-parent-selector/index.cjs +2 -2
- package/build/components/block-parent-selector/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs +4 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-tools/empty-block-inserter.cjs +2 -7
- package/build/components/block-tools/empty-block-inserter.cjs.map +2 -2
- package/build/components/block-vertical-alignment-control/ui.cjs +3 -5
- package/build/components/block-vertical-alignment-control/ui.cjs.map +2 -2
- package/build/components/border-radius-control/utils.cjs +8 -58
- package/build/components/border-radius-control/utils.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -3
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/dimension-control/index.cjs +30 -20
- package/build/components/dimension-control/index.cjs.map +3 -3
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +9 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
- package/build/components/editor-styles/index.cjs +9 -1
- package/build/components/editor-styles/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +66 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +153 -55
- package/build/components/global-styles/border-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +46 -14
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +63 -17
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +242 -64
- package/build/components/global-styles/dimensions-panel.cjs.map +3 -3
- package/build/components/global-styles/filters-panel.cjs +59 -20
- package/build/components/global-styles/filters-panel.cjs.map +3 -3
- package/build/components/global-styles/hooks.cjs +4 -1
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/inheritance/index.cjs +142 -0
- package/build/components/global-styles/inheritance/index.cjs.map +7 -0
- package/build/components/global-styles/inherited-value-context.cjs +173 -0
- package/build/components/global-styles/inherited-value-context.cjs.map +7 -0
- package/build/components/global-styles/shadow-panel-components.cjs +38 -20
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +1 -1
- package/build/components/global-styles/state-control.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +271 -78
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +10 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/line-height-control/index.cjs +1 -1
- package/build/components/line-height-control/index.cjs.map +2 -2
- package/build/components/link-control/index.cjs +3 -1
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +2 -1
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/provider/block-refs-provider.cjs +8 -2
- package/build/components/provider/block-refs-provider.cjs.map +2 -2
- package/build/components/provider/index.cjs +1 -1
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +18 -6
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/provider/use-media-upload-settings.cjs +3 -1
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +23 -13
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/spacing-sizes-control/utils.cjs +6 -19
- package/build/components/spacing-sizes-control/utils.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +8 -2
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/url-input/index.cjs +303 -344
- package/build/components/url-input/index.cjs.map +3 -3
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +24 -1
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +28 -2
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs +179 -0
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs.map +7 -0
- package/build/components/writing-flow/use-editable-root.cjs +5 -42
- package/build/components/writing-flow/use-editable-root.cjs.map +2 -2
- package/build/components/writing-flow/use-home-end.cjs +1 -1
- package/build/components/writing-flow/use-home-end.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +17 -13
- package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
- package/build/components/writing-flow/utils.cjs +3 -14
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/hooks/background.cjs +13 -10
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-style-variation.cjs +4 -45
- package/build/hooks/block-style-variation.cjs.map +3 -3
- package/build/hooks/border.cjs +19 -4
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +6 -2
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -4
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +26 -14
- package/build/hooks/duotone.cjs.map +3 -3
- package/build/hooks/elements.cjs +14 -4
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/line-height.cjs +1 -2
- package/build/hooks/line-height.cjs.map +2 -2
- package/build/hooks/typography.cjs +13 -4
- package/build/hooks/typography.cjs.map +2 -2
- package/build/private-apis.cjs +9 -5
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +9 -4
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +28 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +23 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/native-undo.cjs +55 -0
- package/build/utils/native-undo.cjs.map +7 -0
- package/build-module/components/alignment-control/ui.mjs +2 -4
- package/build-module/components/alignment-control/ui.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +43 -10
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-alignment-control/ui.mjs +5 -3
- package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +74 -46
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +4 -1
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +5 -2
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +2 -3
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs +28 -0
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs.map +7 -0
- package/build-module/components/block-parent-selector/index.mjs +2 -2
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +4 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-tools/empty-block-inserter.mjs +2 -7
- package/build-module/components/block-tools/empty-block-inserter.mjs.map +2 -2
- package/build-module/components/block-vertical-alignment-control/ui.mjs +4 -6
- package/build-module/components/block-vertical-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/border-radius-control/utils.mjs +11 -53
- package/build-module/components/border-radius-control/utils.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -3
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/dimension-control/index.mjs +30 -20
- package/build-module/components/dimension-control/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +10 -6
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/editor-styles/index.mjs +9 -1
- package/build-module/components/editor-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +71 -29
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +157 -56
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +51 -15
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +63 -17
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +248 -66
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +64 -21
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +4 -1
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs +108 -0
- package/build-module/components/global-styles/inheritance/index.mjs.map +7 -0
- package/build-module/components/global-styles/inherited-value-context.mjs +141 -0
- package/build-module/components/global-styles/inherited-value-context.mjs.map +7 -0
- package/build-module/components/global-styles/shadow-panel-components.mjs +38 -20
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +1 -1
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +276 -79
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +6 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +1 -1
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +4 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -1
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/block-refs-provider.mjs +8 -2
- package/build-module/components/provider/block-refs-provider.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +1 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +18 -6
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +3 -1
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +28 -14
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/spacing-sizes-control/utils.mjs +6 -18
- package/build-module/components/spacing-sizes-control/utils.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +8 -2
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +306 -353
- package/build-module/components/url-input/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +24 -1
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +28 -2
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs +154 -0
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs.map +7 -0
- package/build-module/components/writing-flow/use-editable-root.mjs +5 -37
- package/build-module/components/writing-flow/use-editable-root.mjs.map +2 -2
- package/build-module/components/writing-flow/use-home-end.mjs +1 -1
- package/build-module/components/writing-flow/use-home-end.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +18 -14
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +2 -11
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/hooks/background.mjs +13 -10
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-style-variation.mjs +8 -44
- package/build-module/hooks/block-style-variation.mjs.map +2 -2
- package/build-module/hooks/border.mjs +19 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +7 -3
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +15 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +20 -9
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +14 -4
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/line-height.mjs +1 -2
- package/build-module/hooks/line-height.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +13 -4
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/private-apis.mjs +7 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +9 -4
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +29 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +6 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +23 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/native-undo.mjs +29 -0
- package/build-module/utils/native-undo.mjs.map +7 -0
- package/build-style/content-rtl.css +10 -18
- package/build-style/content.css +10 -18
- package/build-style/style-rtl.css +150 -7
- package/build-style/style.css +150 -7
- package/package.json +40 -41
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +1 -1
- package/src/components/alignment-control/ui.js +2 -4
- package/src/components/background-image-control/index.js +74 -37
- package/src/components/background-image-control/style.scss +13 -4
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-alignment-control/ui.js +4 -2
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-inspector/index.js +60 -31
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/content.scss +1 -11
- package/src/components/block-list/use-block-props/index.js +5 -1
- package/src/components/block-list/use-block-props/use-focus-handler.js +9 -8
- package/src/components/block-list/use-block-props/use-register-block-event-handlers.js +45 -0
- package/src/components/block-parent-selector/index.js +5 -2
- package/src/components/block-toolbar/switch-section-style.js +5 -2
- package/src/components/block-tools/empty-block-inserter.js +3 -7
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-vertical-alignment-control/test/index.js +18 -2
- package/src/components/block-vertical-alignment-control/ui.js +3 -5
- package/src/components/border-radius-control/test/utils.js +0 -41
- package/src/components/border-radius-control/utils.js +16 -107
- package/src/components/button-block-appender/content.scss +6 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +6 -3
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +1 -1
- package/src/components/dimension-control/index.js +13 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +13 -6
- package/src/components/editor-styles/index.js +16 -1
- package/src/components/global-styles/background-panel.js +107 -34
- package/src/components/global-styles/border-panel.js +219 -48
- package/src/components/global-styles/color-gradient-dropdown-item.js +93 -28
- package/src/components/global-styles/color-panel.js +92 -11
- package/src/components/global-styles/dimensions-panel.js +422 -71
- package/src/components/global-styles/filters-panel.js +88 -28
- package/src/components/global-styles/hooks.js +8 -1
- package/src/components/global-styles/inheritance/index.js +204 -0
- package/src/components/global-styles/inheritance/style.scss +184 -0
- package/src/components/global-styles/inheritance/test/index.js +281 -0
- package/src/components/global-styles/inherited-value-context.js +271 -0
- package/src/components/global-styles/shadow-panel-components.js +48 -26
- package/src/components/global-styles/state-control.js +2 -2
- package/src/components/global-styles/test/background-panel.js +338 -1
- package/src/components/global-styles/test/border-panel.js +441 -0
- package/src/components/global-styles/test/color-panel.js +182 -2
- package/src/components/global-styles/test/dimensions-panel.js +753 -0
- package/src/components/global-styles/test/filters-panel.js +194 -0
- package/src/components/global-styles/test/inherited-value-context-core.js +98 -0
- package/src/components/global-styles/test/inherited-value-context.js +454 -0
- package/src/components/global-styles/test/typography-panel-core.js +185 -0
- package/src/components/global-styles/test/typography-panel.js +849 -12
- package/src/components/global-styles/typography-panel.js +449 -100
- package/src/components/image-editor/style.scss +33 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
- package/src/components/line-height-control/index.js +1 -1
- package/src/components/link-control/index.js +7 -2
- package/src/components/preset-input-control/index.js +4 -1
- package/src/components/provider/block-refs-provider.js +12 -2
- package/src/components/provider/index.js +2 -2
- package/src/components/provider/use-block-sync.js +18 -6
- package/src/components/provider/use-media-upload-settings.js +2 -0
- package/src/components/rich-text/index.js +37 -16
- package/src/components/spacing-sizes-control/test/utils.js +16 -5
- package/src/components/spacing-sizes-control/utils.js +11 -28
- package/src/components/text-indent-control/index.js +8 -0
- package/src/components/url-input/index.js +363 -431
- package/src/components/url-input/test/index.js +592 -0
- package/src/components/warning/test/__snapshots__/index.js.snap +1 -1
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +51 -1
- package/src/components/writing-flow/use-click-selection.js +54 -3
- package/src/components/writing-flow/use-editable-root-event-handlers.js +266 -0
- package/src/components/writing-flow/use-editable-root.js +7 -77
- package/src/components/writing-flow/use-home-end.js +17 -9
- package/src/components/writing-flow/use-selection-observer.js +32 -15
- package/src/components/writing-flow/utils.js +3 -24
- package/src/hooks/background.js +26 -21
- package/src/hooks/block-fields/rich-text/styles.scss +1 -1
- package/src/hooks/block-style-variation.js +8 -74
- package/src/hooks/border.js +19 -4
- package/src/hooks/custom-css.js +15 -6
- package/src/hooks/dimensions.js +17 -4
- package/src/hooks/duotone.js +26 -8
- package/src/hooks/elements.js +14 -3
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/test/inherited-value-wiring.js +411 -0
- package/src/hooks/test/preset-round-trip.js +456 -0
- package/src/hooks/typography.js +35 -23
- package/src/private-apis.js +11 -2
- package/src/store/actions.js +10 -4
- package/src/store/private-selectors.js +57 -1
- package/src/store/reducer.js +9 -9
- package/src/store/selectors.js +56 -8
- package/src/store/test/private-selectors.js +160 -1
- package/src/style.scss +2 -0
- package/src/utils/native-undo.js +56 -0
- package/build/components/duotone/utils.cjs +0 -87
- package/build/components/duotone/utils.cjs.map +0 -7
- package/build-module/components/duotone/utils.mjs +0 -59
- package/build-module/components/duotone/utils.mjs.map +0 -7
- package/src/components/duotone/utils.js +0 -90
- package/src/hooks/test/get-variation-styles-with-ref-values.js +0 -91
|
@@ -1,46 +1,16 @@
|
|
|
1
1
|
// packages/block-editor/src/components/writing-flow/use-editable-root.js
|
|
2
2
|
import { useRegistry, useSelect } from "@wordpress/data";
|
|
3
3
|
import { useRefEffect } from "@wordpress/compose";
|
|
4
|
-
import { hasBlockSupport } from "@wordpress/blocks";
|
|
5
4
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
6
5
|
import { setContentEditableWrapper } from "./utils.mjs";
|
|
7
6
|
import { getBlockClientId, getSelectionEditableElement } from "../../utils/dom.mjs";
|
|
8
7
|
import { unlock } from "../../lock-unlock.mjs";
|
|
9
|
-
function canHostEditableRoot(select, clientId) {
|
|
10
|
-
const {
|
|
11
|
-
getBlockName,
|
|
12
|
-
getBlockEditingMode,
|
|
13
|
-
getBlockMode,
|
|
14
|
-
getBlockRootClientId,
|
|
15
|
-
getBlockOrder
|
|
16
|
-
} = select;
|
|
17
|
-
if (!clientId || getBlockEditingMode(clientId) !== "default" || // Not when the block is edited as HTML: there is no rich text to
|
|
18
|
-
// host then, only a textarea, which the editing host would
|
|
19
|
-
// interfere with.
|
|
20
|
-
getBlockMode(clientId) !== "visual" || !hasBlockSupport(getBlockName(clientId), "editableRoot", false)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const siblings = getBlockOrder(getBlockRootClientId(clientId));
|
|
24
|
-
return siblings.length > 1 && siblings.every(
|
|
25
|
-
(siblingClientId) => getBlockEditingMode(siblingClientId) === "default"
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function useHasEditableRoot() {
|
|
29
|
-
return useSelect((select) => {
|
|
30
|
-
const selectors = select(blockEditorStore);
|
|
31
|
-
return canHostEditableRoot(
|
|
32
|
-
selectors,
|
|
33
|
-
selectors.getSelectedBlockClientId()
|
|
34
|
-
);
|
|
35
|
-
}, []);
|
|
36
|
-
}
|
|
37
8
|
function useEditableRoot() {
|
|
38
9
|
const registry = useRegistry();
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
43
|
-
const enabled = useHasEditableRoot() && !isZoomOut;
|
|
10
|
+
const enabled = useSelect((select) => {
|
|
11
|
+
const { getSelectedBlockClientId, canHostEditableRoot, isZoomOut } = unlock(select(blockEditorStore));
|
|
12
|
+
return !isZoomOut() && canHostEditableRoot(getSelectedBlockClientId());
|
|
13
|
+
}, []);
|
|
44
14
|
return useRefEffect(
|
|
45
15
|
(node) => {
|
|
46
16
|
if (!enabled) {
|
|
@@ -79,8 +49,6 @@ function useEditableRoot() {
|
|
|
79
49
|
);
|
|
80
50
|
}
|
|
81
51
|
export {
|
|
82
|
-
|
|
83
|
-
useEditableRoot as default,
|
|
84
|
-
useHasEditableRoot
|
|
52
|
+
useEditableRoot as default
|
|
85
53
|
};
|
|
86
54
|
//# sourceMappingURL=use-editable-root.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/writing-flow/use-editable-root.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Keeps the writing flow wrapper contentEditable while the selected block\n * supports `editableRoot`, so the native selection can extend across blocks.\n * While the wrapper is editable it must also hold focus: a nested editable\n * element cannot retain focus once an ancestor becomes an editing host (the\n * first DOM mutation moves focus to the host, inconsistently across\n * browsers).\n */\nexport default function useEditableRoot() {\n\tconst registry = useRegistry();\n\tconst enabled = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId, canHostEditableRoot, isZoomOut } =\n\t\t\tunlock( select( blockEditorStore ) );\n\t\treturn (\n\t\t\t! isZoomOut() && canHostEditableRoot( getSelectedBlockClientId() )\n\t\t);\n\t}, [] );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\thasMultiSelection,\n\t\t\t\tisMultiSelecting,\n\t\t\t} = registry.select( blockEditorStore );\n\n\t\t\t// Focus is moved separately below, only when an editable\n\t\t\t// element belonging to the selected block holds it.\n\t\t\tif ( ! setContentEditableWrapper( node, true, { focus: false } ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Move focus from the block's editable element to the wrapper,\n\t\t\t// but only when an editable element belonging to the selected\n\t\t\t// block has focus. Never steal focus from other regions (e.g.\n\t\t\t// List View), UI elements (e.g. buttons), or other editables\n\t\t\t// within the wrapper (e.g. the post title). The selection is\n\t\t\t// preserved. If the selection is still outside the focused\n\t\t\t// element, a mousedown just focused it and the browser has not\n\t\t\t// placed the caret yet; moving focus now would cancel the\n\t\t\t// pending caret placement. The selection observer moves focus\n\t\t\t// once the selection lands.\n\t\t\tconst { activeElement } = node.ownerDocument;\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\t\t\tif (\n\t\t\t\tactiveElement !== node &&\n\t\t\t\tactiveElement?.isContentEditable &&\n\t\t\t\tnode.contains( activeElement ) &&\n\t\t\t\tgetBlockClientId( activeElement ) ===\n\t\t\t\t\tgetSelectedBlockClientId() &&\n\t\t\t\tselection.anchorNode &&\n\t\t\t\tactiveElement.contains( selection.anchorNode )\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\t// A multi-selection owns the wrapper as its editing host\n\t\t\t\t// now: the host and its textbox semantics remain, and the\n\t\t\t\t// selection observer disables both together when the\n\t\t\t\t// selection collapses. Removing the attributes here would\n\t\t\t\t// strip the accessible name off the focused editing host at\n\t\t\t\t// the moment cross-block editing begins.\n\t\t\t\tif ( hasMultiSelection() || isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t// If the wrapper held focus, return focus to the editable\n\t\t\t\t// element containing the selection, which is focusable\n\t\t\t\t// again now that the wrapper is no longer an editing host.\n\t\t\t\t// Only do so if that element belongs to the selected block:\n\t\t\t\t// when the selection moved to another block through the\n\t\t\t\t// store, the stale DOM selection must not reclaim block\n\t\t\t\t// selection through its focus handler.\n\t\t\t\tif ( node.ownerDocument.activeElement === node ) {\n\t\t\t\t\tconst editable = getSelectionEditableElement(\n\t\t\t\t\t\tnode.ownerDocument.defaultView.getSelection(),\n\t\t\t\t\t\tnode\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\teditable &&\n\t\t\t\t\t\tgetBlockClientId( editable ) ===\n\t\t\t\t\t\t\tgetSelectedBlockClientId()\n\t\t\t\t\t) {\n\t\t\t\t\t\teditable.focus();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t[ enabled, registry ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc;AAUR,SAAR,kBAAmC;AACzC,QAAM,WAAW,YAAY;AAC7B,QAAM,UAAU,UAAW,CAAE,WAAY;AACxC,UAAM,EAAE,0BAA0B,qBAAqB,UAAU,IAChE,OAAQ,OAAQ,gBAAiB,CAAE;AACpC,WACC,CAAE,UAAU,KAAK,oBAAqB,yBAAyB,CAAE;AAAA,EAEnE,GAAG,CAAC,CAAE;AAEN,SAAO;AAAA,IACN,CAAE,SAAU;AACX,UAAK,CAAE,SAAU;AAChB;AAAA,MACD;AAEA,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,SAAS,OAAQ,gBAAiB;AAItC,UAAK,CAAE,0BAA2B,MAAM,MAAM,EAAE,OAAO,MAAM,CAAE,GAAI;AAClE;AAAA,MACD;AAYA,YAAM,EAAE,cAAc,IAAI,KAAK;AAC/B,YAAM,YAAY,KAAK,cAAc,YAAY,aAAa;AAC9D,UACC,kBAAkB,QAClB,eAAe,qBACf,KAAK,SAAU,aAAc,KAC7B,iBAAkB,aAAc,MAC/B,yBAAyB,KAC1B,UAAU,cACV,cAAc,SAAU,UAAU,UAAW,GAC5C;AACD,aAAK,MAAM;AAAA,MACZ;AAEA,aAAO,MAAM;AAOZ,YAAK,kBAAkB,KAAK,iBAAiB,GAAI;AAChD;AAAA,QACD;AAEA,kCAA2B,MAAM,KAAM;AASvC,YAAK,KAAK,cAAc,kBAAkB,MAAO;AAChD,gBAAM,WAAW;AAAA,YAChB,KAAK,cAAc,YAAY,aAAa;AAAA,YAC5C;AAAA,UACD;AACA,cACC,YACA,iBAAkB,QAAS,MAC1B,yBAAyB,GACzB;AACD,qBAAS,MAAM;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,SAAS,QAAS;AAAA,EACrB;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ function useHomeEnd() {
|
|
|
17
17
|
if (event.metaKey || event.ctrlKey || event.altKey) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
20
|
+
if (!event.target.isContentEditable || hasMultiSelection()) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const selection = node.ownerDocument.defaultView.getSelection();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/writing-flow/use-home-end.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { HOME, END } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getSelectionEditableElement } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * While the wrapper is the contentEditable editing host (a selected block\n *
|
|
5
|
-
"mappings": ";AAGA,SAAS,MAAM,WAAW;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAK7B,SAAS,mCAAmC;AAC5C,SAAS,SAAS,wBAAwB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { HOME, END } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getSelectionEditableElement } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Moves the caret to the start or end of the visual line for Home and End\n * with `Selection.modify()`, because the browser's default caret movement\n * cannot be relied on in two cases:\n *\n * - While the wrapper is the contentEditable editing host (a selected block\n * supports `editableRoot`), browsers don't perform the default caret\n * movement for Home and End.\n * - Chromium on macOS maps Home and End to scroll commands, so it never\n * moves the caret in editable content on that platform, including nested\n * editable elements like the tab labels in the tab-list block.\n */\nexport default function useHomeEnd() {\n\tconst { hasMultiSelection } = useSelect( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== HOME && event.keyCode !== END ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.metaKey || event.ctrlKey || event.altKey ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only handle keys pressed in editable content, in both of the\n\t\t\t// cases mentioned above: `event.target` is the focused element,\n\t\t\t// and `isContentEditable` is true both for the wrapper as the\n\t\t\t// editing host and for a nested editable element like a tab label.\n\t\t\t// Anything else that takes focus like inputs and textareas keep\n\t\t\t// default behavior.\n\t\t\tif ( ! event.target.isContentEditable || hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tselection.modify(\n\t\t\t\tevent.shiftKey ? 'extend' : 'move',\n\t\t\t\tevent.keyCode === HOME ? 'backward' : 'forward',\n\t\t\t\t'lineboundary'\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,MAAM,WAAW;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAK7B,SAAS,mCAAmC;AAC5C,SAAS,SAAS,wBAAwB;AAc3B,SAAR,aAA8B;AACpC,QAAM,EAAE,kBAAkB,IAAI,UAAW,gBAAiB;AAC1D,SAAO,aAAc,CAAE,SAAU;AAChC,aAAS,UAAW,OAAQ;AAC3B,UAAK,MAAM,kBAAmB;AAC7B;AAAA,MACD;AAEA,UAAK,MAAM,YAAY,QAAQ,MAAM,YAAY,KAAM;AACtD;AAAA,MACD;AAEA,UAAK,MAAM,WAAW,MAAM,WAAW,MAAM,QAAS;AACrD;AAAA,MACD;AAQA,UAAK,CAAE,MAAM,OAAO,qBAAqB,kBAAkB,GAAI;AAC9D;AAAA,MACD;AAEA,YAAM,YAAY,KAAK,cAAc,YAAY,aAAa;AAE9D,UAAK,CAAE,4BAA6B,WAAW,IAAK,GAAI;AACvD;AAAA,MACD;AAEA,YAAM,eAAe;AACrB,gBAAU;AAAA,QACT,MAAM,WAAW,WAAW;AAAA,QAC5B,MAAM,YAAY,OAAO,aAAa;AAAA,QACtC;AAAA,MACD;AAAA,IACD;AAEA,SAAK,iBAAkB,WAAW,SAAU;AAC5C,WAAO,MAAM;AACZ,WAAK,oBAAqB,WAAW,SAAU;AAAA,IAChD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
import { isSelectionForward } from "@wordpress/dom";
|
|
9
9
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
10
10
|
import { getBlockClientId } from "../../utils/dom.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import { setContentEditableWrapper, setShiftClickInProgress } from "./utils.mjs";
|
|
11
|
+
import { setContentEditableWrapper } from "./utils.mjs";
|
|
13
12
|
import { unlock } from "../../lock-unlock.mjs";
|
|
14
13
|
var { ownsSelection } = unlock(richTextPrivateApis);
|
|
15
14
|
function extractSelectionStartNode(selection) {
|
|
@@ -47,16 +46,22 @@ function getRichTextElement(node) {
|
|
|
47
46
|
return element?.closest("[data-wp-block-attribute-key]");
|
|
48
47
|
}
|
|
49
48
|
function useSelectionObserver() {
|
|
50
|
-
const {
|
|
51
|
-
|
|
49
|
+
const {
|
|
50
|
+
multiSelect,
|
|
51
|
+
selectBlock,
|
|
52
|
+
selectionChange,
|
|
53
|
+
startMultiSelect,
|
|
54
|
+
stopMultiSelect
|
|
55
|
+
} = useDispatch(blockEditorStore);
|
|
52
56
|
const {
|
|
53
57
|
getBlockParents,
|
|
54
58
|
getBlockSelectionStart,
|
|
55
59
|
isMultiSelecting,
|
|
56
60
|
getSelectionStart,
|
|
57
61
|
getSelectionEnd,
|
|
58
|
-
getSelectedBlockClientId
|
|
59
|
-
|
|
62
|
+
getSelectedBlockClientId,
|
|
63
|
+
canHostEditableRoot
|
|
64
|
+
} = unlock(useSelect(blockEditorStore));
|
|
60
65
|
return useRefEffect(
|
|
61
66
|
(node) => {
|
|
62
67
|
const { ownerDocument } = node;
|
|
@@ -64,11 +69,12 @@ function useSelectionObserver() {
|
|
|
64
69
|
let isTripleClick = false;
|
|
65
70
|
function onMouseDown(event) {
|
|
66
71
|
isTripleClick = event.detail === 3;
|
|
67
|
-
|
|
72
|
+
if (event.shiftKey) {
|
|
73
|
+
startMultiSelect();
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
function onKeyDown() {
|
|
70
77
|
isTripleClick = false;
|
|
71
|
-
setShiftClickInProgress(false);
|
|
72
78
|
}
|
|
73
79
|
function onSelectionChange(event) {
|
|
74
80
|
const selection = defaultView.getSelection();
|
|
@@ -92,10 +98,7 @@ function useSelectionObserver() {
|
|
|
92
98
|
// selected editable root block (e.g. Firefox does not
|
|
93
99
|
// always move it), which must not re-enable the wrapper
|
|
94
100
|
// after another block has been selected.
|
|
95
|
-
collapsedClientId === getSelectedBlockClientId() && canHostEditableRoot(
|
|
96
|
-
blockEditorSelectors,
|
|
97
|
-
collapsedClientId
|
|
98
|
-
)) {
|
|
101
|
+
collapsedClientId === getSelectedBlockClientId() && canHostEditableRoot(collapsedClientId)) {
|
|
99
102
|
setContentEditableWrapper(node, true);
|
|
100
103
|
const { activeElement } = ownerDocument;
|
|
101
104
|
if (activeElement !== node && activeElement?.isContentEditable && node.contains(activeElement) && getBlockClientId(activeElement) === collapsedClientId) {
|
|
@@ -193,7 +196,8 @@ function useSelectionObserver() {
|
|
|
193
196
|
endClientId
|
|
194
197
|
];
|
|
195
198
|
const depth = findDepth(startPath, endPath);
|
|
196
|
-
|
|
199
|
+
const isAncestorDescendant = depth >= startPath.length || depth >= endPath.length;
|
|
200
|
+
if (!isAncestorDescendant && (startPath[depth] !== startClientId || endPath[depth] !== endClientId)) {
|
|
197
201
|
multiSelect(startPath[depth], endPath[depth]);
|
|
198
202
|
return;
|
|
199
203
|
}
|
|
@@ -251,7 +255,7 @@ function useSelectionObserver() {
|
|
|
251
255
|
);
|
|
252
256
|
function onMouseUp(event) {
|
|
253
257
|
onSelectionChange(event);
|
|
254
|
-
|
|
258
|
+
stopMultiSelect();
|
|
255
259
|
}
|
|
256
260
|
defaultView.addEventListener("mouseup", onMouseUp);
|
|
257
261
|
node.addEventListener("mousedown", onMouseDown);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/writing-flow/use-selection-observer.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport {\n\tcreate,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\nimport { isSelectionForward } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\nimport { canHostEditableRoot } from './use-editable-root';\nimport { setContentEditableWrapper, setShiftClickInProgress } from './utils';\nimport { unlock } from '../../lock-unlock';\n\nconst { ownsSelection } = unlock( richTextPrivateApis );\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n * @param {boolean} isTripleClick Whether the selection comes from a triple\n * click.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection, isTripleClick ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\t// A triple click selects the paragraph, but the browser extends the\n\t// forward selection into the next element at an offset of 0. This may\n\t// trigger multi selection even though the selection does not visually end\n\t// in the next block. Keyboard selections that legitimately extend to the\n\t// same boundary (e.g. Shift+ArrowDown into a focusable block, where the\n\t// browser reports the boundary at the element instead of its first text\n\t// position) must not be corrected, so only do this for triple clicks.\n\tif (\n\t\tfocusOffset === 0 &&\n\t\tisSelectionForward( selection ) &&\n\t\tisTripleClick\n\t) {\n\t\treturn focusNode.previousSibling ?? focusNode.parentElement;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst blockEditorSelectors = useSelect( blockEditorStore );\n\tconst {\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tisMultiSelecting,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetSelectedBlockClientId,\n\t} = blockEditorSelectors;\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet isTripleClick = false;\n\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\tisTripleClick = event.detail === 3;\n\t\t\t\tsetShiftClickInProgress( event.shiftKey );\n\t\t\t}\n\n\t\t\tfunction onKeyDown() {\n\t\t\t\tisTripleClick = false;\n\t\t\t\tsetShiftClickInProgress( false );\n\t\t\t}\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode(\n\t\t\t\t\tselection,\n\t\t\t\t\tisTripleClick\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tconst collapsedClientId = getBlockClientId( startNode );\n\n\t\t\t\t\t// If the block supports an editable root, keep (or make)\n\t\t\t\t\t// the wrapper contentEditable so the native selection can\n\t\t\t\t\t// extend across blocks. The wrapper holds focus, so rich\n\t\t\t\t\t// text instances don't sync the selection; do it here.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isMultiSelecting() &&\n\t\t\t\t\t\tcollapsedClientId &&\n\t\t\t\t\t\t// Only keep the wrapper editable when the collapsed\n\t\t\t\t\t\t// selection is in the block that is actually selected.\n\t\t\t\t\t\t// A stale native selection may linger in a previously\n\t\t\t\t\t\t// selected editable root block (e.g. Firefox does not\n\t\t\t\t\t\t// always move it), which must not re-enable the wrapper\n\t\t\t\t\t\t// after another block has been selected.\n\t\t\t\t\t\tcollapsedClientId === getSelectedBlockClientId() &&\n\t\t\t\t\t\tcanHostEditableRoot(\n\t\t\t\t\t\t\tblockEditorSelectors,\n\t\t\t\t\t\t\tcollapsedClientId\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, true );\n\n\t\t\t\t\t\t// While the wrapper is editable it must hold focus: a\n\t\t\t\t\t\t// nested editable element cannot retain it (the first\n\t\t\t\t\t\t// DOM mutation moves focus to the host, inconsistently\n\t\t\t\t\t\t// across browsers). Don't steal focus from UI elements\n\t\t\t\t\t\t// (e.g. buttons) or editables outside the block (e.g.\n\t\t\t\t\t\t// the post title). The rich text instance owning the\n\t\t\t\t\t\t// selection syncs it to the store itself.\n\t\t\t\t\t\tconst { activeElement } = ownerDocument;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tactiveElement !== node &&\n\t\t\t\t\t\t\tactiveElement?.isContentEditable &&\n\t\t\t\t\t\t\tnode.contains( activeElement ) &&\n\t\t\t\t\t\t\tgetBlockClientId( activeElement ) ===\n\t\t\t\t\t\t\t\tcollapsedClientId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// On mouseup, if the native selection is within one block\n\t\t\t\t// but the click target is a different block, bail out\n\t\t\t\t// and let the clicked block's focus handler manage\n\t\t\t\t// selection.\n\t\t\t\tif (\n\t\t\t\t\tevent.type === 'mouseup' &&\n\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t! isMultiSelecting() &&\n\t\t\t\t\tstartClientId === endClientId\n\t\t\t\t) {\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\tif (\n\t\t\t\t\t\tclickedClientId &&\n\t\t\t\t\t\tclickedClientId !== startClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\t// If the selection is not collapsed and falls\n\t\t\t\t\t\t// within a RichText that doesn't have focus\n\t\t\t\t\t\t// (e.g. the user started dragging from the block\n\t\t\t\t\t\t// wrapper padding), dispatch a full\n\t\t\t\t\t\t// selectionChange so the format toolbar appears.\n\t\t\t\t\t\tconst richTextElement =\n\t\t\t\t\t\t\t! selection.isCollapsed &&\n\t\t\t\t\t\t\t( getRichTextElement( startNode ) ||\n\t\t\t\t\t\t\t\tgetRichTextElement( endNode ) );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\trichTextElement &&\n\t\t\t\t\t\t\t// The rich text instance syncs the selection\n\t\t\t\t\t\t\t// itself when its element is editable and owns the\n\t\t\t\t\t\t\t// selection (also through a focused editing host).\n\t\t\t\t\t\t\t// It may be temporarily non-editable while a drag\n\t\t\t\t\t\t\t// that started outside it is in progress (see\n\t\t\t\t\t\t\t// rich-text's preventFocusCapture).\n\t\t\t\t\t\t\t( richTextElement.contentEditable !== 'true' ||\n\t\t\t\t\t\t\t\t( ownerDocument.activeElement !==\n\t\t\t\t\t\t\t\t\trichTextElement &&\n\t\t\t\t\t\t\t\t\t! ownsSelection( richTextElement ) ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\t\tconst richTextData = create( {\n\t\t\t\t\t\t\t\telement: richTextElement,\n\t\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tconst selectionUpdate = {\n\t\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\t\trichTextElement.dataset\n\t\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\t\toffset: richTextData.start ?? 0,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\t\trichTextElement.dataset\n\t\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\t\t// Clamp the end offset to the element. A\n\t\t\t\t\t\t\t\t\t// forward selection can overshoot past the\n\t\t\t\t\t\t\t\t\t// rich text (e.g. a triple click extends\n\t\t\t\t\t\t\t\t\t// into the next block at offset 0), leaving\n\t\t\t\t\t\t\t\t\t// `end` undefined; that means the selection\n\t\t\t\t\t\t\t\t\t// reaches through the end of this element's\n\t\t\t\t\t\t\t\t\t// content.\n\t\t\t\t\t\t\t\t\toffset:\n\t\t\t\t\t\t\t\t\t\trichTextData.end ??\n\t\t\t\t\t\t\t\t\t\trichTextData.text.length,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst { start, end } = selectionUpdate;\n\t\t\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\t\t\t// Skip the dispatch when the store already holds\n\t\t\t\t\t\t\t// the same selection.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tselectionStart.clientId !== start.clientId ||\n\t\t\t\t\t\t\t\tselectionEnd.clientId !== end.clientId ||\n\t\t\t\t\t\t\t\tselectionStart.attributeKey !==\n\t\t\t\t\t\t\t\t\tstart.attributeKey ||\n\t\t\t\t\t\t\t\tselectionStart.offset !== start.offset ||\n\t\t\t\t\t\t\t\tselectionEnd.offset !== end.offset\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tselectionChange( selectionUpdate );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Native `selectionchange` events are asynchronous: a clipboard\n\t\t\t// event may fire before the store has been updated with a cross\n\t\t\t// block selection that was just made. Sync it before the clipboard\n\t\t\t// handlers (bubble phase) read the store.\n\t\t\tfunction ensureMultiBlockSelectionSync( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount || selection.isCollapsed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only a selection across different blocks needs to be synced\n\t\t\t\t// here; rich text owns selections within a single block.\n\t\t\t\tconst startClientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tconst endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection, isTripleClick )\n\t\t\t\t);\n\n\t\t\t\tif ( startClientId !== endClientId ) {\n\t\t\t\t\tonSelectionChange( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tfunction onMouseUp( event ) {\n\t\t\t\tonSelectionChange( event );\n\t\t\t\tsetShiftClickInProgress( false );\n\t\t\t}\n\n\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'copy',\n\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'cut',\n\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'paste',\n\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'copy',\n\t\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'cut',\n\t\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'paste',\n\t\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,0BAA0B;AAKnC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AACjC,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport {\n\tcreate,\n\tprivateApis as richTextPrivateApis,\n} from '@wordpress/rich-text';\nimport { isSelectionForward } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\nimport { setContentEditableWrapper } from './utils';\nimport { unlock } from '../../lock-unlock';\n\nconst { ownsSelection } = unlock( richTextPrivateApis );\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n * @param {boolean} isTripleClick Whether the selection comes from a triple\n * click.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection, isTripleClick ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\t// A triple click selects the paragraph, but the browser extends the\n\t// forward selection into the next element at an offset of 0. This may\n\t// trigger multi selection even though the selection does not visually end\n\t// in the next block. Keyboard selections that legitimately extend to the\n\t// same boundary (e.g. Shift+ArrowDown into a focusable block, where the\n\t// browser reports the boundary at the element instead of its first text\n\t// position) must not be corrected, so only do this for triple clicks.\n\tif (\n\t\tfocusOffset === 0 &&\n\t\tisSelectionForward( selection ) &&\n\t\tisTripleClick\n\t) {\n\t\treturn focusNode.previousSibling ?? focusNode.parentElement;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst {\n\t\tmultiSelect,\n\t\tselectBlock,\n\t\tselectionChange,\n\t\tstartMultiSelect,\n\t\tstopMultiSelect,\n\t} = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tisMultiSelecting,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetSelectedBlockClientId,\n\t\tcanHostEditableRoot,\n\t} = unlock( useSelect( blockEditorStore ) );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet isTripleClick = false;\n\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\tisTripleClick = event.detail === 3;\n\t\t\t\t// A shift+click makes a multi-selection: mark the gesture as\n\t\t\t\t// in progress so the clicked block's focus handler does not\n\t\t\t\t// select it (collapsing the native range being made), and so\n\t\t\t\t// use-multi-selection does not clear the native selection.\n\t\t\t\t// The selection is built on mouseup.\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tstartMultiSelect();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onKeyDown() {\n\t\t\t\tisTripleClick = false;\n\t\t\t}\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode(\n\t\t\t\t\tselection,\n\t\t\t\t\tisTripleClick\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tconst collapsedClientId = getBlockClientId( startNode );\n\n\t\t\t\t\t// If the block supports an editable root, keep (or make)\n\t\t\t\t\t// the wrapper contentEditable so the native selection can\n\t\t\t\t\t// extend across blocks. The wrapper holds focus, so rich\n\t\t\t\t\t// text instances don't sync the selection; do it here.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isMultiSelecting() &&\n\t\t\t\t\t\tcollapsedClientId &&\n\t\t\t\t\t\t// Only keep the wrapper editable when the collapsed\n\t\t\t\t\t\t// selection is in the block that is actually selected.\n\t\t\t\t\t\t// A stale native selection may linger in a previously\n\t\t\t\t\t\t// selected editable root block (e.g. Firefox does not\n\t\t\t\t\t\t// always move it), which must not re-enable the wrapper\n\t\t\t\t\t\t// after another block has been selected.\n\t\t\t\t\t\tcollapsedClientId === getSelectedBlockClientId() &&\n\t\t\t\t\t\tcanHostEditableRoot( collapsedClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, true );\n\n\t\t\t\t\t\t// While the wrapper is editable it must hold focus: a\n\t\t\t\t\t\t// nested editable element cannot retain it (the first\n\t\t\t\t\t\t// DOM mutation moves focus to the host, inconsistently\n\t\t\t\t\t\t// across browsers). Don't steal focus from UI elements\n\t\t\t\t\t\t// (e.g. buttons) or editables outside the block (e.g.\n\t\t\t\t\t\t// the post title). The rich text instance owning the\n\t\t\t\t\t\t// selection syncs it to the store itself.\n\t\t\t\t\t\tconst { activeElement } = ownerDocument;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tactiveElement !== node &&\n\t\t\t\t\t\t\tactiveElement?.isContentEditable &&\n\t\t\t\t\t\t\tnode.contains( activeElement ) &&\n\t\t\t\t\t\t\tgetBlockClientId( activeElement ) ===\n\t\t\t\t\t\t\t\tcollapsedClientId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// On mouseup, if the native selection is within one block\n\t\t\t\t// but the click target is a different block, bail out\n\t\t\t\t// and let the clicked block's focus handler manage\n\t\t\t\t// selection.\n\t\t\t\tif (\n\t\t\t\t\tevent.type === 'mouseup' &&\n\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t! isMultiSelecting() &&\n\t\t\t\t\tstartClientId === endClientId\n\t\t\t\t) {\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\tif (\n\t\t\t\t\t\tclickedClientId &&\n\t\t\t\t\t\tclickedClientId !== startClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\t// If the selection is not collapsed and falls\n\t\t\t\t\t\t// within a RichText that doesn't have focus\n\t\t\t\t\t\t// (e.g. the user started dragging from the block\n\t\t\t\t\t\t// wrapper padding), dispatch a full\n\t\t\t\t\t\t// selectionChange so the format toolbar appears.\n\t\t\t\t\t\tconst richTextElement =\n\t\t\t\t\t\t\t! selection.isCollapsed &&\n\t\t\t\t\t\t\t( getRichTextElement( startNode ) ||\n\t\t\t\t\t\t\t\tgetRichTextElement( endNode ) );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\trichTextElement &&\n\t\t\t\t\t\t\t// The rich text instance syncs the selection\n\t\t\t\t\t\t\t// itself when its element is editable and owns the\n\t\t\t\t\t\t\t// selection (also through a focused editing host).\n\t\t\t\t\t\t\t// It may be temporarily non-editable while a drag\n\t\t\t\t\t\t\t// that started outside it is in progress (see\n\t\t\t\t\t\t\t// rich-text's preventFocusCapture).\n\t\t\t\t\t\t\t( richTextElement.contentEditable !== 'true' ||\n\t\t\t\t\t\t\t\t( ownerDocument.activeElement !==\n\t\t\t\t\t\t\t\t\trichTextElement &&\n\t\t\t\t\t\t\t\t\t! ownsSelection( richTextElement ) ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\t\tconst richTextData = create( {\n\t\t\t\t\t\t\t\telement: richTextElement,\n\t\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tconst selectionUpdate = {\n\t\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\t\trichTextElement.dataset\n\t\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\t\toffset: richTextData.start ?? 0,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\t\trichTextElement.dataset\n\t\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\t\t// Clamp the end offset to the element. A\n\t\t\t\t\t\t\t\t\t// forward selection can overshoot past the\n\t\t\t\t\t\t\t\t\t// rich text (e.g. a triple click extends\n\t\t\t\t\t\t\t\t\t// into the next block at offset 0), leaving\n\t\t\t\t\t\t\t\t\t// `end` undefined; that means the selection\n\t\t\t\t\t\t\t\t\t// reaches through the end of this element's\n\t\t\t\t\t\t\t\t\t// content.\n\t\t\t\t\t\t\t\t\toffset:\n\t\t\t\t\t\t\t\t\t\trichTextData.end ??\n\t\t\t\t\t\t\t\t\t\trichTextData.text.length,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst { start, end } = selectionUpdate;\n\t\t\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\t\t\t// Skip the dispatch when the store already holds\n\t\t\t\t\t\t\t// the same selection.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tselectionStart.clientId !== start.clientId ||\n\t\t\t\t\t\t\t\tselectionEnd.clientId !== end.clientId ||\n\t\t\t\t\t\t\t\tselectionStart.attributeKey !==\n\t\t\t\t\t\t\t\t\tstart.attributeKey ||\n\t\t\t\t\t\t\t\tselectionStart.offset !== start.offset ||\n\t\t\t\t\t\t\t\tselectionEnd.offset !== end.offset\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tselectionChange( selectionUpdate );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\t// If one path ends before they diverge, one block\n\t\t\t\t\t// contains the other, so there are no sibling blocks\n\t\t\t\t\t// to promote the selection to. Record the selection as\n\t\t\t\t\t// is: it resolves to the outer block, which is treated\n\t\t\t\t\t// as fully selected. See `getSelectionNestingAncestor`\n\t\t\t\t\t// in the store.\n\t\t\t\t\tconst isAncestorDescendant =\n\t\t\t\t\t\tdepth >= startPath.length || depth >= endPath.length;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAncestorDescendant &&\n\t\t\t\t\t\t( startPath[ depth ] !== startClientId ||\n\t\t\t\t\t\t\tendPath[ depth ] !== endClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Native `selectionchange` events are asynchronous: a clipboard\n\t\t\t// event may fire before the store has been updated with a cross\n\t\t\t// block selection that was just made. Sync it before the clipboard\n\t\t\t// handlers (bubble phase) read the store.\n\t\t\tfunction ensureMultiBlockSelectionSync( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount || selection.isCollapsed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only a selection across different blocks needs to be synced\n\t\t\t\t// here; rich text owns selections within a single block.\n\t\t\t\tconst startClientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tconst endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection, isTripleClick )\n\t\t\t\t);\n\n\t\t\t\tif ( startClientId !== endClientId ) {\n\t\t\t\t\tonSelectionChange( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tfunction onMouseUp( event ) {\n\t\t\t\tonSelectionChange( event );\n\t\t\t\tstopMultiSelect();\n\t\t\t}\n\n\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'copy',\n\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'cut',\n\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'paste',\n\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'copy',\n\t\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'cut',\n\t\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'paste',\n\t\t\t\t\tensureMultiBlockSelectionSync,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EAC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A,UACb;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,aAAa,aAAa,iBAAiB,eAAgB;AAAA,EAC9D;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -66,13 +66,6 @@ function toPlainText(html) {
|
|
|
66
66
|
const plainText = stripHTML(html).trim();
|
|
67
67
|
return plainText.replace(/\n\n+/g, "\n\n");
|
|
68
68
|
}
|
|
69
|
-
var shiftClickInProgress = false;
|
|
70
|
-
function setShiftClickInProgress(value) {
|
|
71
|
-
shiftClickInProgress = value;
|
|
72
|
-
}
|
|
73
|
-
function isShiftClickInProgress() {
|
|
74
|
-
return shiftClickInProgress;
|
|
75
|
-
}
|
|
76
69
|
function setContentEditableWrapper(node, value, { focus = true } = {}) {
|
|
77
70
|
if (node.contentEditable === String(value)) {
|
|
78
71
|
return value;
|
|
@@ -92,16 +85,14 @@ function setContentEditableWrapper(node, value, { focus = true } = {}) {
|
|
|
92
85
|
node.setAttribute("aria-multiline", "true");
|
|
93
86
|
node.setAttribute("aria-label", __("Editor canvas"));
|
|
94
87
|
if (focus) {
|
|
95
|
-
node.focus();
|
|
88
|
+
node.focus({ preventScroll: true });
|
|
96
89
|
}
|
|
97
90
|
return true;
|
|
98
91
|
}
|
|
99
92
|
export {
|
|
100
93
|
getPasteBlocks,
|
|
101
|
-
isShiftClickInProgress,
|
|
102
94
|
requiresWrapperOnCopy,
|
|
103
95
|
setClipboardBlocks,
|
|
104
|
-
setContentEditableWrapper
|
|
105
|
-
setShiftClickInProgress
|
|
96
|
+
setContentEditableWrapper
|
|
106
97
|
};
|
|
107
98
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/writing-flow/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n\
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,uBAAuB,iBAAiB;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AAKP,SAAS,yBAAyB;AAClC,SAAS,SAAS,wBAAwB;AAEnC,IAAM,wBAAwB,uBAAQ,uBAAwB;AAU9D,SAAS,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5B,SAAO,KAAK,QAAS,SAAS,IAAK;AAEnC,QAAM,YAAY,UAAW,IAAK,EAAE,KAAK;AAGzC,SAAO,UAAU,QAAS,UAAU,MAAO;AAC5C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n\n/**\n * Makes the wrapper element an editing host, or stops it from being one. The\n * ARIA attributes travel with the editability: while the wrapper is the\n * active editing host it must present as a named multiline textbox, per the\n * WAI-ARIA textbox role, which requires an accessible name.\n *\n * @param {HTMLElement} node Wrapper element.\n * @param {boolean} value Whether the wrapper should be an\n * editing host.\n * @param {Object} options\n * @param {boolean} options.focus Move focus to the wrapper when it\n * becomes an editing host (Firefox does\n * not automatically move it). Default\n * true.\n *\n * @return {boolean} Whether the wrapper is an editing host now.\n */\nexport function setContentEditableWrapper(\n\tnode,\n\tvalue,\n\t{ focus = true } = {}\n) {\n\t// Check first: this is called on every selection change, and setting\n\t// contentEditable triggers a style recalculation.\n\tif ( node.contentEditable === String( value ) ) {\n\t\treturn value;\n\t}\n\n\tnode.contentEditable = value;\n\n\tif ( ! value ) {\n\t\tnode.removeAttribute( 'role' );\n\t\tnode.removeAttribute( 'aria-multiline' );\n\t\tnode.removeAttribute( 'aria-label' );\n\t\treturn false;\n\t}\n\n\t// Only act as an editing host if the environment supports it (JSDOM\n\t// does not implement contentEditable): without editing host semantics\n\t// the wrapper must not claim focus or textbox semantics.\n\tif ( ! node.isContentEditable ) {\n\t\tnode.removeAttribute( 'contenteditable' );\n\t\treturn false;\n\t}\n\n\t// Expose the host as a named multiline textbox so it has a role and\n\t// accessible name once it takes focus. The label is generic because the\n\t// host can span several blocks.\n\tnode.setAttribute( 'role', 'textbox' );\n\tnode.setAttribute( 'aria-multiline', 'true' );\n\tnode.setAttribute( 'aria-label', __( 'Editor canvas' ) );\n\n\tif ( focus ) {\n\t\t// Without preventScroll, focusing the wrapper scrolls the\n\t\t// viewport to the top of the wrapper.\n\t\tnode.focus( { preventScroll: true } );\n\t}\n\n\treturn true;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,uBAAuB,iBAAiB;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AAKP,SAAS,yBAAyB;AAClC,SAAS,SAAS,wBAAwB;AAEnC,IAAM,wBAAwB,uBAAQ,uBAAwB;AAU9D,SAAS,mBAAoB,OAAO,QAAQ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,SAAS,IAAK;AAEnC,QAAM,YAAY,UAAW,IAAK,EAAE,KAAK;AAGzC,SAAO,UAAU,QAAS,UAAU,MAAO;AAC5C;AAmBO,SAAS,0BACf,MACA,OACA,EAAE,QAAQ,KAAK,IAAI,CAAC,GACnB;AAGD,MAAK,KAAK,oBAAoB,OAAQ,KAAM,GAAI;AAC/C,WAAO;AAAA,EACR;AAEA,OAAK,kBAAkB;AAEvB,MAAK,CAAE,OAAQ;AACd,SAAK,gBAAiB,MAAO;AAC7B,SAAK,gBAAiB,gBAAiB;AACvC,SAAK,gBAAiB,YAAa;AACnC,WAAO;AAAA,EACR;AAKA,MAAK,CAAE,KAAK,mBAAoB;AAC/B,SAAK,gBAAiB,iBAAkB;AACxC,WAAO;AAAA,EACR;AAKA,OAAK,aAAc,QAAQ,SAAU;AACrC,OAAK,aAAc,kBAAkB,MAAO;AAC5C,OAAK,aAAc,cAAc,GAAI,eAAgB,CAAE;AAEvD,MAAK,OAAQ;AAGZ,SAAK,MAAO,EAAE,eAAe,KAAK,CAAE;AAAA,EACrC;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
hasBackgroundImageValue,
|
|
15
15
|
hasBackgroundGradientValue
|
|
16
16
|
} from "../components/global-styles/background-panel.mjs";
|
|
17
|
-
import { globalStylesDataKey } from "../store/private-keys.mjs";
|
|
18
17
|
import {
|
|
19
18
|
getStyleForState,
|
|
20
19
|
isDefaultBlockStyleState,
|
|
21
20
|
setStyleForState,
|
|
22
21
|
useBlockStyleState
|
|
23
22
|
} from "./block-style-state.mjs";
|
|
23
|
+
import { useResolvedStyle } from "../components/global-styles/inherited-value-context.mjs";
|
|
24
24
|
import { jsx } from "react/jsx-runtime";
|
|
25
25
|
var BACKGROUND_SUPPORT_KEY = "background";
|
|
26
26
|
var BACKGROUND_BLOCK_DEFAULT_VALUES = {
|
|
@@ -111,20 +111,23 @@ function BackgroundImagePanel({
|
|
|
111
111
|
asWrapper
|
|
112
112
|
}) {
|
|
113
113
|
const selectedState = useBlockStyleState();
|
|
114
|
-
const { style, className, backgroundColor, gradient
|
|
114
|
+
const { style, className, backgroundColor, gradient } = useSelect(
|
|
115
115
|
(select) => {
|
|
116
|
-
const { getBlockAttributes
|
|
117
|
-
const _settings = getSettings();
|
|
116
|
+
const { getBlockAttributes } = select(blockEditorStore);
|
|
118
117
|
const blockAttributes = getBlockAttributes(clientId);
|
|
119
118
|
return {
|
|
120
119
|
style: blockAttributes?.style,
|
|
121
120
|
className: blockAttributes?.className,
|
|
122
121
|
backgroundColor: blockAttributes?.backgroundColor,
|
|
123
|
-
gradient: blockAttributes?.gradient
|
|
124
|
-
inheritedValue: _settings[globalStylesDataKey]?.blocks?.[name]
|
|
122
|
+
gradient: blockAttributes?.gradient
|
|
125
123
|
};
|
|
126
124
|
},
|
|
127
|
-
[clientId
|
|
125
|
+
[clientId]
|
|
126
|
+
);
|
|
127
|
+
const { value: inheritedValue } = useResolvedStyle(
|
|
128
|
+
name,
|
|
129
|
+
className,
|
|
130
|
+
selectedState
|
|
128
131
|
);
|
|
129
132
|
const backgroundGradientSupported = hasBackgroundSupport(
|
|
130
133
|
name,
|
|
@@ -236,15 +239,15 @@ function BackgroundImagePanel({
|
|
|
236
239
|
return /* @__PURE__ */ jsx(
|
|
237
240
|
StylesBackgroundPanel,
|
|
238
241
|
{
|
|
239
|
-
inheritedValue,
|
|
240
242
|
as: Wrapper,
|
|
241
243
|
panelId: clientId,
|
|
242
244
|
defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES,
|
|
243
245
|
settings: updatedSettings,
|
|
244
246
|
onChange,
|
|
245
247
|
defaultControls,
|
|
246
|
-
value,
|
|
247
|
-
contrastWarning
|
|
248
|
+
value: isStateSelected ? getStyleForState(style, selectedState) : styleValue,
|
|
249
|
+
contrastWarning,
|
|
250
|
+
inheritedValue
|
|
248
251
|
}
|
|
249
252
|
);
|
|
250
253
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/background.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { extractPresetSlug } from '../utils/color-values';\nimport { store as blockEditorStore } from '../store';\nimport useBlockColorContrastWarning from './contrast-checker';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\n// Clears every control the Background panel owns: the background image,\n// background color, and the gradient. The Background panel owns the gradient\n// control for both the newer `background.gradient` support and the legacy\n// `color.gradient` path, so \"Reset all\" clears the legacy value too,\n// regardless of which path stored it.\nexport function backgroundResetAllFilter( attributes ) {\n\tconst updatedClassName = attributes.className?.includes( 'has-background' )\n\t\t? attributes.className\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t.join( ' ' ) || undefined\n\t\t: attributes.className;\n\treturn {\n\t\t...attributes,\n\t\tclassName: updatedClassName,\n\t\tbackgroundColor: undefined,\n\t\tgradient: undefined,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...attributes.style,\n\t\t\tbackground: undefined,\n\t\t\tcolor: {\n\t\t\t\t...attributes.style?.color,\n\t\t\t\tbackground: undefined,\n\t\t\t\tgradient: undefined,\n\t\t\t},\n\t\t} ),\n\t};\n}\n\nfunction BackgroundInspectorControl( { children } ) {\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"background\"\n\t\t\tresetAllFilter={ backgroundResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n\t// Allows rendering outside the `background` inspector group (e.g. section\n\t// blocks direct-render this panel because their support fills are gated\n\t// off by editing mode). Defaults to the slot-based wrapper.\n\tasWrapper,\n} ) {\n\tconst selectedState = useBlockStyleState();\n\tconst { style, className, backgroundColor, gradient, inheritedValue } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\t\tselect( blockEditorStore );\n\t\t\t\tconst _settings = getSettings();\n\t\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\t\treturn {\n\t\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t\tbackgroundColor: blockAttributes?.backgroundColor,\n\t\t\t\t\tgradient: blockAttributes?.gradient,\n\t\t\t\t\tinheritedValue:\n\t\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId, name ]\n\t\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\tconst colorSupport = getBlockSupport( name, 'color' );\n\tconst hasColorBackgroundSupport =\n\t\tcolorSupport && colorSupport.background !== false;\n\tconst hasColorGradientSupport = !! colorSupport?.gradients;\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\t// Fold the backgroundColor / gradient attribute slugs back into the style\n\t// object the panel consumes. When background.gradient is supported but not\n\t// yet explicitly set, fall back to color.gradient for display.\n\tconst styleValue = {\n\t\t...style,\n\t\tcolor: {\n\t\t\t...style?.color,\n\t\t\tbackground: backgroundColor\n\t\t\t\t? 'var:preset|color|' + backgroundColor\n\t\t\t\t: style?.color?.background,\n\t\t\tgradient:\n\t\t\t\t! backgroundGradientSupported && gradient\n\t\t\t\t\t? 'var:preset|gradient|' + gradient\n\t\t\t\t\t: style?.color?.gradient,\n\t\t},\n\t\t...( backgroundGradientSupported && {\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tgradient: gradient\n\t\t\t\t\t? 'var:preset|gradient|' + gradient\n\t\t\t\t\t: style?.background?.gradient ?? style?.color?.gradient,\n\t\t\t},\n\t\t} ),\n\t};\n\tconst value = isStateSelected\n\t\t? getStyleForState( style, selectedState )\n\t\t: styleValue;\n\n\t// Skipped for gradients, which can't be reliably evaluated for contrast.\n\tconst enableContrastChecking =\n\t\t! value?.color?.gradient &&\n\t\t! value?.background?.gradient &&\n\t\t!! value?.color?.background &&\n\t\t( settings?.color?.text || settings?.color?.link ) &&\n\t\tfalse !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );\n\n\tconst contrastWarning = useBlockColorContrastWarning( {\n\t\tclientId,\n\t\tname,\n\t\tenabled: !! enableContrastChecking,\n\t\tmessageOverride: __(\n\t\t\t'This color combination has poor contrast. Consider increasing contrast between background and foreground.'\n\t\t),\n\t} );\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t( ! hasBackgroundSupport( name ) &&\n\t\t\t! hasColorBackgroundSupport &&\n\t\t\t! hasColorGradientSupport )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tif ( isStateSelected ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Extract background color slug from style.color.background.\n\t\tconst newBackgroundColorValue = newStyle?.color?.background;\n\t\tconst newBackgroundColorSlug = extractPresetSlug(\n\t\t\tnewBackgroundColorValue,\n\t\t\t'color'\n\t\t);\n\n\t\t// Extract gradient slug — prefer the new background.gradient path\n\t\t// when backgroundGradientSupported, fall back to color.gradient.\n\t\tconst newGradientValue = backgroundGradientSupported\n\t\t\t? newStyle?.background?.gradient\n\t\t\t: newStyle?.color?.gradient;\n\t\tconst newGradientSlug = extractPresetSlug(\n\t\t\tnewGradientValue,\n\t\t\t'gradient'\n\t\t);\n\t\tconst cleanedColorGradient = newGradientSlug\n\t\t\t? undefined\n\t\t\t: newStyle?.color?.gradient;\n\n\t\t// Drop slug-resolved values so they aren't persisted inline alongside\n\t\t// the attribute slugs.\n\t\tconst cleanedStyle = {\n\t\t\t...newStyle,\n\t\t\tcolor: {\n\t\t\t\t...newStyle?.color,\n\t\t\t\tbackground: newBackgroundColorSlug\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newBackgroundColorValue,\n\t\t\t\tgradient: backgroundGradientSupported\n\t\t\t\t\t? undefined\n\t\t\t\t\t: cleanedColorGradient,\n\t\t\t},\n\t\t};\n\t\tif ( backgroundGradientSupported ) {\n\t\t\t// Background gradients are kept whole in `style.background.gradient`\n\t\t\t// rather than extracted to the legacy `gradient` attribute.\n\t\t\tcleanedStyle.background = {\n\t\t\t\t...cleanedStyle.background,\n\t\t\t\tgradient: newStyle?.background?.gradient,\n\t\t\t};\n\t\t}\n\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( cleanedStyle ),\n\t\t\tbackgroundColor: newBackgroundColorSlug,\n\t\t\t// The legacy `gradient` attribute is only used when the block does\n\t\t\t// not support `background.gradient`; otherwise the gradient is\n\t\t\t// stored in `style.background.gradient` above.\n\t\t\tgradient: backgroundGradientSupported ? undefined : newGradientSlug,\n\t\t};\n\n\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t// gradient value is being set — not when it is being cleared/reset.\n\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t// during a previous migration, remove it so it does not linger.\n\t\tconst hasNewGradient = !! newGradientSlug || !! newGradientValue;\n\t\tif ( isMigrating && hasNewGradient ) {\n\t\t\tnewAttributes.className = clsx( className, 'has-background' );\n\t\t} else if (\n\t\t\t! hasNewGradient &&\n\t\t\tclassName?.includes( 'has-background' )\n\t\t) {\n\t\t\tnewAttributes.className =\n\t\t\t\tclassName\n\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t}\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst backgroundDefaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst colorDefaultControls = getBlockSupport( name, [\n\t\t'color',\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t...backgroundDefaultControls,\n\t\tbackgroundColor: colorDefaultControls?.background,\n\t\t// Mirror the old combined control: show the gradient item by default\n\t\t// when background color was shown by default.\n\t\tgradient:\n\t\t\tbackgroundDefaultControls?.gradient ??\n\t\t\tcolorDefaultControls?.background,\n\t};\n\n\tconst Wrapper = asWrapper || BackgroundInspectorControl;\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ Wrapper }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={ value }\n\t\t\tcontrastWarning={ contrastWarning }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,kCAAkC;AACzC;AAAA,EACC,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { extractPresetSlug } from '../utils/color-values';\nimport { store as blockEditorStore } from '../store';\nimport useBlockColorContrastWarning from './contrast-checker';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\nimport { useResolvedStyle } from '../components/global-styles/inherited-value-context';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\n// Clears every control the Background panel owns: the background image,\n// background color, and the gradient. The Background panel owns the gradient\n// control for both the newer `background.gradient` support and the legacy\n// `color.gradient` path, so \"Reset all\" clears the legacy value too,\n// regardless of which path stored it.\nexport function backgroundResetAllFilter( attributes ) {\n\tconst updatedClassName = attributes.className?.includes( 'has-background' )\n\t\t? attributes.className\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t.join( ' ' ) || undefined\n\t\t: attributes.className;\n\treturn {\n\t\t...attributes,\n\t\tclassName: updatedClassName,\n\t\tbackgroundColor: undefined,\n\t\tgradient: undefined,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...attributes.style,\n\t\t\tbackground: undefined,\n\t\t\tcolor: {\n\t\t\t\t...attributes.style?.color,\n\t\t\t\tbackground: undefined,\n\t\t\t\tgradient: undefined,\n\t\t\t},\n\t\t} ),\n\t};\n}\n\nfunction BackgroundInspectorControl( { children } ) {\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"background\"\n\t\t\tresetAllFilter={ backgroundResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n\t// Allows rendering outside the `background` inspector group (e.g. section\n\t// blocks direct-render this panel because their support fills are gated\n\t// off by editing mode). Defaults to the slot-based wrapper.\n\tasWrapper,\n} ) {\n\tconst selectedState = useBlockStyleState();\n\tconst { style, className, backgroundColor, gradient } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\treturn {\n\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\tbackgroundColor: blockAttributes?.backgroundColor,\n\t\t\t\tgradient: blockAttributes?.gradient,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { value: inheritedValue } = useResolvedStyle(\n\t\tname,\n\t\tclassName,\n\t\tselectedState\n\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\tconst colorSupport = getBlockSupport( name, 'color' );\n\tconst hasColorBackgroundSupport =\n\t\tcolorSupport && colorSupport.background !== false;\n\tconst hasColorGradientSupport = !! colorSupport?.gradients;\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\t// Fold the backgroundColor / gradient attribute slugs back into the style\n\t// object the panel consumes. When background.gradient is supported but not\n\t// yet explicitly set, fall back to color.gradient for display.\n\tconst styleValue = {\n\t\t...style,\n\t\tcolor: {\n\t\t\t...style?.color,\n\t\t\tbackground: backgroundColor\n\t\t\t\t? 'var:preset|color|' + backgroundColor\n\t\t\t\t: style?.color?.background,\n\t\t\tgradient:\n\t\t\t\t! backgroundGradientSupported && gradient\n\t\t\t\t\t? 'var:preset|gradient|' + gradient\n\t\t\t\t\t: style?.color?.gradient,\n\t\t},\n\t\t...( backgroundGradientSupported && {\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tgradient: gradient\n\t\t\t\t\t? 'var:preset|gradient|' + gradient\n\t\t\t\t\t: style?.background?.gradient ?? style?.color?.gradient,\n\t\t\t},\n\t\t} ),\n\t};\n\tconst value = isStateSelected\n\t\t? getStyleForState( style, selectedState )\n\t\t: styleValue;\n\n\t// Skipped for gradients, which can't be reliably evaluated for contrast.\n\tconst enableContrastChecking =\n\t\t! value?.color?.gradient &&\n\t\t! value?.background?.gradient &&\n\t\t!! value?.color?.background &&\n\t\t( settings?.color?.text || settings?.color?.link ) &&\n\t\tfalse !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );\n\n\tconst contrastWarning = useBlockColorContrastWarning( {\n\t\tclientId,\n\t\tname,\n\t\tenabled: !! enableContrastChecking,\n\t\tmessageOverride: __(\n\t\t\t'This color combination has poor contrast. Consider increasing contrast between background and foreground.'\n\t\t),\n\t} );\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t( ! hasBackgroundSupport( name ) &&\n\t\t\t! hasColorBackgroundSupport &&\n\t\t\t! hasColorGradientSupport )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tif ( isStateSelected ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Extract background color slug from style.color.background.\n\t\tconst newBackgroundColorValue = newStyle?.color?.background;\n\t\tconst newBackgroundColorSlug = extractPresetSlug(\n\t\t\tnewBackgroundColorValue,\n\t\t\t'color'\n\t\t);\n\n\t\t// Extract gradient slug — prefer the new background.gradient path\n\t\t// when backgroundGradientSupported, fall back to color.gradient.\n\t\tconst newGradientValue = backgroundGradientSupported\n\t\t\t? newStyle?.background?.gradient\n\t\t\t: newStyle?.color?.gradient;\n\t\tconst newGradientSlug = extractPresetSlug(\n\t\t\tnewGradientValue,\n\t\t\t'gradient'\n\t\t);\n\t\tconst cleanedColorGradient = newGradientSlug\n\t\t\t? undefined\n\t\t\t: newStyle?.color?.gradient;\n\n\t\t// Drop slug-resolved values so they aren't persisted inline alongside\n\t\t// the attribute slugs.\n\t\tconst cleanedStyle = {\n\t\t\t...newStyle,\n\t\t\tcolor: {\n\t\t\t\t...newStyle?.color,\n\t\t\t\tbackground: newBackgroundColorSlug\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newBackgroundColorValue,\n\t\t\t\tgradient: backgroundGradientSupported\n\t\t\t\t\t? undefined\n\t\t\t\t\t: cleanedColorGradient,\n\t\t\t},\n\t\t};\n\t\tif ( backgroundGradientSupported ) {\n\t\t\t// Background gradients are kept whole in `style.background.gradient`\n\t\t\t// rather than extracted to the legacy `gradient` attribute.\n\t\t\tcleanedStyle.background = {\n\t\t\t\t...cleanedStyle.background,\n\t\t\t\tgradient: newStyle?.background?.gradient,\n\t\t\t};\n\t\t}\n\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( cleanedStyle ),\n\t\t\tbackgroundColor: newBackgroundColorSlug,\n\t\t\t// The legacy `gradient` attribute is only used when the block does\n\t\t\t// not support `background.gradient`; otherwise the gradient is\n\t\t\t// stored in `style.background.gradient` above.\n\t\t\tgradient: backgroundGradientSupported ? undefined : newGradientSlug,\n\t\t};\n\n\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t// gradient value is being set — not when it is being cleared/reset.\n\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t// during a previous migration, remove it so it does not linger.\n\t\tconst hasNewGradient = !! newGradientSlug || !! newGradientValue;\n\t\tif ( isMigrating && hasNewGradient ) {\n\t\t\tnewAttributes.className = clsx( className, 'has-background' );\n\t\t} else if (\n\t\t\t! hasNewGradient &&\n\t\t\tclassName?.includes( 'has-background' )\n\t\t) {\n\t\t\tnewAttributes.className =\n\t\t\t\tclassName\n\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t}\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst backgroundDefaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst colorDefaultControls = getBlockSupport( name, [\n\t\t'color',\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t...backgroundDefaultControls,\n\t\tbackgroundColor: colorDefaultControls?.background,\n\t\t// Mirror the old combined control: show the gradient item by default\n\t\t// when background color was shown by default.\n\t\tgradient:\n\t\t\tbackgroundDefaultControls?.gradient ??\n\t\t\tcolorDefaultControls?.background,\n\t};\n\n\tconst Wrapper = asWrapper || BackgroundInspectorControl;\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tas={ Wrapper }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={\n\t\t\t\tisStateSelected\n\t\t\t\t\t? getStyleForState( style, selectedState )\n\t\t\t\t\t: styleValue\n\t\t\t}\n\t\t\tcontrastWarning={ contrastWarning }\n\t\t\tinheritedValue={ inheritedValue }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,kCAAkC;AACzC;AAAA,EACC,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAiI/B;AA/HK,IAAM,yBAAyB;AAG/B,IAAM,kCAAkC;AAAA,EAC9C,gBAAgB;AAAA,EACh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