@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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/writing-flow/use-editable-root-event-handlers.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';\nimport { BlockRefs } from '../provider/block-refs-provider';\n\n// The React `on*` props the host bridges, mapped to their DOM event type. Only\n// editing events are redirected under `editableRoot` (the wrapper becomes the\n// editing host, so keyboard, input and composition events target it instead of\n// the block); pointer and other events still reach the block and need no\n// bridging. React prop names don't map to DOM types by lowercasing in general\n// (onChange is `input`, onDoubleClick is `dblclick`), so the mapping is\n// explicit, which also locks the bridged surface to events React actually fires.\nconst SUPPORTED_EVENTS = {\n\tonKeyDown: 'keydown',\n\tonKeyUp: 'keyup',\n\tonBeforeInput: 'beforeinput',\n\tonInput: 'input',\n\tonCompositionStart: 'compositionstart',\n\tonCompositionUpdate: 'compositionupdate',\n\tonCompositionEnd: 'compositionend',\n};\n\n// The DOM event types the host listens for. Fixed, so the host attaches these\n// listeners once rather than tracking which types are in use.\nconst EVENT_TYPES = Object.values( SUPPORTED_EVENTS );\n\n/**\n * Collects the supported `on*` event handlers from a set of props, e.g. a\n * block's merged `wrapperProps`, keyed by DOM event type. Used by the block to\n * register them (see `useRegisterBlockEventHandlers`).\n *\n * @param {Object} props Props to read handlers from.\n *\n * @return {Object|undefined} The handlers by event type, or undefined when\n * there are none.\n */\nexport function getEventHandlers( props ) {\n\tlet handlers;\n\n\tfor ( const name in SUPPORTED_EVENTS ) {\n\t\tif ( typeof props[ name ] === 'function' ) {\n\t\t\thandlers = handlers || {};\n\t\t\thandlers[ SUPPORTED_EVENTS[ name ] ] = props[ name ];\n\t\t}\n\t}\n\n\treturn handlers;\n}\n\n// The native properties React copies onto its SyntheticEvent for each event\n// type (the *EventInterface tables in react-dom), so the wrapper exposes exactly\n// what a React handler would see and nothing more. Values are copied straight\n// from the native event; React's normalizers only paper over browsers we don't\n// support, and anything omitted stays reachable through `nativeEvent`, as in\n// React (e.g. `getTargetRanges` on a `beforeinput`).\nconst EVENT_INTERFACE = [\n\t'eventPhase',\n\t'bubbles',\n\t'cancelable',\n\t'timeStamp',\n\t'defaultPrevented',\n\t'isTrusted',\n];\nconst KEYBOARD_EVENT_INTERFACE = [\n\t...EVENT_INTERFACE,\n\t'view',\n\t'detail',\n\t'key',\n\t'code',\n\t'location',\n\t'ctrlKey',\n\t'shiftKey',\n\t'altKey',\n\t'metaKey',\n\t'repeat',\n\t'locale',\n\t'getModifierState',\n\t'charCode',\n\t'keyCode',\n\t'which',\n];\nconst INPUT_EVENT_INTERFACE = [ ...EVENT_INTERFACE, 'data' ];\nconst EVENT_INTERFACES = {\n\tkeydown: KEYBOARD_EVENT_INTERFACE,\n\tkeyup: KEYBOARD_EVENT_INTERFACE,\n\tbeforeinput: INPUT_EVENT_INTERFACE,\n\tinput: INPUT_EVENT_INTERFACE,\n\tcompositionstart: INPUT_EVENT_INTERFACE,\n\tcompositionupdate: INPUT_EVENT_INTERFACE,\n\tcompositionend: INPUT_EVENT_INTERFACE,\n};\n\n/**\n * Builds a React `SyntheticEvent`-like object for an extension handler, which\n * expects one. It mirrors what react-dom does: a plain object wrapping the real\n * native event, eagerly copying the same interface properties React exposes for\n * the event type, so a handler sees exactly React's surface and nothing more.\n *\n * `preventDefault` and `stopPropagation` forward to the native event, so they\n * behave as through React; `stopPropagation` also flags the walk through block\n * ancestors to stop. `target` is the editable inside the block rather than the\n * real target (the editing host above it), and `currentTarget` is reassigned as\n * the event bubbles from block to block.\n *\n * @param {Event} nativeEvent The event to wrap.\n * @param {HTMLElement} target The element to report as the target.\n *\n * @return {Object} The synthetic event.\n */\nfunction createBlockSyntheticEvent( nativeEvent, target ) {\n\tlet propagationStopped = false;\n\n\tconst syntheticEvent = {\n\t\tnativeEvent,\n\t\ttype: nativeEvent.type,\n\t\ttarget,\n\t\tcurrentTarget: null,\n\t\tpreventDefault() {\n\t\t\tnativeEvent.preventDefault();\n\t\t\tsyntheticEvent.defaultPrevented = true;\n\t\t},\n\t\tisDefaultPrevented() {\n\t\t\treturn syntheticEvent.defaultPrevented;\n\t\t},\n\t\tstopPropagation() {\n\t\t\tnativeEvent.stopPropagation();\n\t\t\tpropagationStopped = true;\n\t\t},\n\t\tisPropagationStopped() {\n\t\t\treturn propagationStopped;\n\t\t},\n\t\t// The modern event system doesn't pool, so persistence is a no-op.\n\t\tpersist() {},\n\t\tisPersistent() {\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tfor ( const property of EVENT_INTERFACES[ nativeEvent.type ] ) {\n\t\tconst value = nativeEvent[ property ];\n\t\tsyntheticEvent[ property ] =\n\t\t\ttypeof value === 'function' ? value.bind( nativeEvent ) : value;\n\t}\n\n\treturn syntheticEvent;\n}\n\n/**\n * Backwards compatibility for block event handlers under `editableRoot`.\n *\n * When a block supports `editableRoot`, the writing flow wrapper is the\n * contentEditable editing host, so keyboard, input and composition events\n * target the wrapper instead of the block. React `on*` handlers a third party\n * added to a block through `wrapperProps` (e.g. via an `editor.BlockListBlock`\n * filter) are on the block element, below the target, so they stop firing.\n *\n * The block registers those handlers (see `useBlockProps`), and this hook\n * calls them from the host: it resolves the block that owns the selection and\n * every block ancestor, and invokes each registered handler with a synthetic\n * event, innermost first, like a bubbling event. The listeners are attached\n * where React attaches its own (the portal container, the iframe's document\n * element), so a block's handler runs and its `preventDefault` /\n * `stopPropagation` behave as they would through React, without editableRoot.\n *\n * This does not cover handlers a filter puts on its own wrapping element rather\n * than the block's `wrapperProps`; the block element is the supported event\n * surface. It can be removed once input handling is lifted to the host.\n */\nexport default function useEditableRootEventHandlers() {\n\tconst { hasMultiSelection, getBlockParents } =\n\t\tuseSelect( blockEditorStore );\n\tconst { refsMap, eventHandlers } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onEvent( event ) {\n\t\t\t\t// Only act on real events targeting the host itself, while it\n\t\t\t\t// is the editing host for a single block and some block has a\n\t\t\t\t// handler to call.\n\t\t\t\tif (\n\t\t\t\t\t! eventHandlers.size ||\n\t\t\t\t\tevent.target !== node ||\n\t\t\t\t\t! event.isTrusted ||\n\t\t\t\t\tnode.contentEditable !== 'true' ||\n\t\t\t\t\thasMultiSelection()\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = node.ownerDocument.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 editable = getSelectionEditableElement( selection, node );\n\t\t\t\tconst clientId = getBlockClientId( editable );\n\n\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Call the handler on the block that owns the selection and each\n\t\t\t\t// of its block ancestors, innermost first, like a bubbling\n\t\t\t\t// event. The hierarchy comes from the store rather than the DOM,\n\t\t\t\t// and one synthetic event, wrapping the real event, is reused\n\t\t\t\t// for the whole chain, its currentTarget moved from block to\n\t\t\t\t// block. The element is only resolved for blocks with a handler.\n\t\t\t\tconst clientIds = [\n\t\t\t\t\tclientId,\n\t\t\t\t\t...getBlockParents( clientId, true ),\n\t\t\t\t];\n\n\t\t\t\tlet syntheticEvent;\n\t\t\t\tfor ( const ancestorClientId of clientIds ) {\n\t\t\t\t\tconst handler =\n\t\t\t\t\t\teventHandlers.get( ancestorClientId )?.current?.[\n\t\t\t\t\t\t\tevent.type\n\t\t\t\t\t\t];\n\t\t\t\t\tconst element = handler && refsMap.get( ancestorClientId );\n\n\t\t\t\t\tif ( ! element ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! syntheticEvent ) {\n\t\t\t\t\t\tsyntheticEvent = createBlockSyntheticEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\teditable\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tsyntheticEvent.currentTarget = element;\n\t\t\t\t\thandler( syntheticEvent );\n\n\t\t\t\t\tif ( syntheticEvent.isPropagationStopped() ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Attach where React attaches its own event system: the portal\n\t\t\t// container, which for the iframed canvas is the document element\n\t\t\t// (see `preparePortalMount` in react-dom). Listening at the same\n\t\t\t// node, non-capture, means a block's handler runs in the bubbling\n\t\t\t// phase after core, and its stopPropagation stops at the same point\n\t\t\t// React's would, as its `on*` handler would without editableRoot.\n\t\t\tconst root = node.ownerDocument.documentElement;\n\t\t\tconst unsubscribers = EVENT_TYPES.map( ( type ) => {\n\t\t\t\troot.addEventListener( type, onEvent );\n\t\t\t\treturn () => root.removeEventListener( type, onEvent );\n\t\t\t} );\n\t\t\treturn () =>\n\t\t\t\tunsubscribers.forEach( ( unsubscribe ) => unsubscribe() );\n\t\t},\n\t\t[ hasMultiSelection, getBlockParents, refsMap, eventHandlers ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAA6B;AAC7B,qBAA2B;AAK3B,mBAA0C;AAC1C,iBAA8D;AAC9D,iCAA0B;AAS1B,IAAM,mBAAmB;AAAA,EACxB,WAAW;AAAA,EACX,SAAS;AAAA,EACT,eAAe;AAAA,EACf,SAAS;AAAA,EACT,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,kBAAkB;AACnB;AAIA,IAAM,cAAc,OAAO,OAAQ,gBAAiB;AAY7C,SAAS,iBAAkB,OAAQ;AACzC,MAAI;AAEJ,aAAY,QAAQ,kBAAmB;AACtC,QAAK,OAAO,MAAO,IAAK,MAAM,YAAa;AAC1C,iBAAW,YAAY,CAAC;AACxB,eAAU,iBAAkB,IAAK,CAAE,IAAI,MAAO,IAAK;AAAA,IACpD;AAAA,EACD;AAEA,SAAO;AACR;AAQA,IAAM,kBAAkB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AACA,IA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IzB,YACC,CAAE,cAAc,QAChB,MAAM,WAAW,QACjB,CAAE,MAAM,aACR,KAAK,oBAAoB,UACzB,kBAAkB,GACjB;AACD;AAAA,QACD;AAEA,cAAM,YAAY,KAAK,cAAc,YAAY,aAAa;AAE9D,YAAK,CAAE,UAAU,YAAa;AAC7B;AAAA,QACD;AAEA,cAAM,eAAW,wCAA6B,WAAW,IAAK;AAC9D,cAAM,eAAW,6BAAkB,QAAS;AAE5C,YAAK,CAAE,UAAW;AACjB;AAAA,QACD;AAQA,cAAM,YAAY;AAAA,UACjB;AAAA,UACA,GAAG,gBAAiB,UAAU,IAAK;AAAA,QACpC;AAEA,YAAI;AACJ,mBAAY,oBAAoB,WAAY;AAC3C,gBAAM,UACL,cAAc,IAAK,gBAAiB,GAAG,UACtC,MAAM,IACP;AACD,gBAAM,UAAU,WAAW,QAAQ,IAAK,gBAAiB;AAEzD,cAAK,CAAE,SAAU;AAChB;AAAA,UACD;AAEA,cAAK,CAAE,gBAAiB;AACvB,6BAAiB;AAAA,cAChB;AAAA,cACA;AAAA,YACD;AAAA,UACD;AAEA,yBAAe,gBAAgB;AAC/B,kBAAS,cAAe;AAExB,cAAK,eAAe,qBAAqB,GAAI;AAC5C;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAQA,YAAM,OAAO,KAAK,cAAc;AAChC,YAAM,gBAAgB,YAAY,IAAK,CAAE,SAAU;AAClD,aAAK,iBAAkB,MAAM,OAAQ;AACrC,eAAO,MAAM,KAAK,oBAAqB,MAAM,OAAQ;AAAA,MACtD,CAAE;AACF,aAAO,MACN,cAAc,QAAS,CAAE,gBAAiB,YAAY,CAAE;AAAA,IAC1D;AAAA,IACA,CAAE,mBAAmB,iBAAiB,SAAS,aAAc;AAAA,EAC9D;AACD;",
|
|
6
|
+
"names": ["blockEditorStore"]
|
|
7
|
+
}
|
|
@@ -20,53 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// packages/block-editor/src/components/writing-flow/use-editable-root.js
|
|
21
21
|
var use_editable_root_exports = {};
|
|
22
22
|
__export(use_editable_root_exports, {
|
|
23
|
-
|
|
24
|
-
default: () => useEditableRoot,
|
|
25
|
-
useHasEditableRoot: () => useHasEditableRoot
|
|
23
|
+
default: () => useEditableRoot
|
|
26
24
|
});
|
|
27
25
|
module.exports = __toCommonJS(use_editable_root_exports);
|
|
28
26
|
var import_data = require("@wordpress/data");
|
|
29
27
|
var import_compose = require("@wordpress/compose");
|
|
30
|
-
var import_blocks = require("@wordpress/blocks");
|
|
31
28
|
var import_store = require("../../store/index.cjs");
|
|
32
29
|
var import_utils = require("./utils.cjs");
|
|
33
30
|
var import_dom = require("../../utils/dom.cjs");
|
|
34
31
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
35
|
-
function canHostEditableRoot(select, clientId) {
|
|
36
|
-
const {
|
|
37
|
-
getBlockName,
|
|
38
|
-
getBlockEditingMode,
|
|
39
|
-
getBlockMode,
|
|
40
|
-
getBlockRootClientId,
|
|
41
|
-
getBlockOrder
|
|
42
|
-
} = select;
|
|
43
|
-
if (!clientId || getBlockEditingMode(clientId) !== "default" || // Not when the block is edited as HTML: there is no rich text to
|
|
44
|
-
// host then, only a textarea, which the editing host would
|
|
45
|
-
// interfere with.
|
|
46
|
-
getBlockMode(clientId) !== "visual" || !(0, import_blocks.hasBlockSupport)(getBlockName(clientId), "editableRoot", false)) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
const siblings = getBlockOrder(getBlockRootClientId(clientId));
|
|
50
|
-
return siblings.length > 1 && siblings.every(
|
|
51
|
-
(siblingClientId) => getBlockEditingMode(siblingClientId) === "default"
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
function useHasEditableRoot() {
|
|
55
|
-
return (0, import_data.useSelect)((select) => {
|
|
56
|
-
const selectors = select(import_store.store);
|
|
57
|
-
return canHostEditableRoot(
|
|
58
|
-
selectors,
|
|
59
|
-
selectors.getSelectedBlockClientId()
|
|
60
|
-
);
|
|
61
|
-
}, []);
|
|
62
|
-
}
|
|
63
32
|
function useEditableRoot() {
|
|
64
33
|
const registry = (0, import_data.useRegistry)();
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
69
|
-
const enabled = useHasEditableRoot() && !isZoomOut;
|
|
34
|
+
const enabled = (0, import_data.useSelect)((select) => {
|
|
35
|
+
const { getSelectedBlockClientId, canHostEditableRoot, isZoomOut } = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
36
|
+
return !isZoomOut() && canHostEditableRoot(getSelectedBlockClientId());
|
|
37
|
+
}, []);
|
|
70
38
|
return (0, import_compose.useRefEffect)(
|
|
71
39
|
(node) => {
|
|
72
40
|
if (!enabled) {
|
|
@@ -104,9 +72,4 @@ function useEditableRoot() {
|
|
|
104
72
|
[enabled, registry]
|
|
105
73
|
);
|
|
106
74
|
}
|
|
107
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
-
0 && (module.exports = {
|
|
109
|
-
canHostEditableRoot,
|
|
110
|
-
useHasEditableRoot
|
|
111
|
-
});
|
|
112
75
|
//# sourceMappingURL=use-editable-root.cjs.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,mBAA0C;AAC1C,iBAA8D;AAC9D,yBAAuB;AAUR,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Key || event.ctrlKey || event.altKey) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
44
|
+
if (!event.target.isContentEditable || hasMultiSelection()) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAA0B;AAC1B,kBAA0B;AAC1B,qBAA6B;AAK7B,iBAA4C;AAC5C,mBAA0C;
|
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAA0B;AAC1B,kBAA0B;AAC1B,qBAA6B;AAK7B,iBAA4C;AAC5C,mBAA0C;AAc3B,SAAR,aAA8B;AACpC,QAAM,EAAE,kBAAkB,QAAI,uBAAW,aAAAA,KAAiB;AAC1D,aAAO,6BAAc,CAAE,SAAU;AAChC,aAAS,UAAW,OAAQ;AAC3B,UAAK,MAAM,kBAAmB;AAC7B;AAAA,MACD;AAEA,UAAK,MAAM,YAAY,wBAAQ,MAAM,YAAY,qBAAM;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,KAAE,wCAA6B,WAAW,IAAK,GAAI;AACvD;AAAA,MACD;AAEA,YAAM,eAAe;AACrB,gBAAU;AAAA,QACT,MAAM,WAAW,WAAW;AAAA,QAC5B,MAAM,YAAY,uBAAO,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": ["blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -29,7 +29,6 @@ var import_rich_text = require("@wordpress/rich-text");
|
|
|
29
29
|
var import_dom = require("@wordpress/dom");
|
|
30
30
|
var import_store = require("../../store/index.cjs");
|
|
31
31
|
var import_dom2 = require("../../utils/dom.cjs");
|
|
32
|
-
var import_use_editable_root = require("./use-editable-root.cjs");
|
|
33
32
|
var import_utils = require("./utils.cjs");
|
|
34
33
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
35
34
|
var { ownsSelection } = (0, import_lock_unlock.unlock)(import_rich_text.privateApis);
|
|
@@ -68,16 +67,22 @@ function getRichTextElement(node) {
|
|
|
68
67
|
return element?.closest("[data-wp-block-attribute-key]");
|
|
69
68
|
}
|
|
70
69
|
function useSelectionObserver() {
|
|
71
|
-
const {
|
|
72
|
-
|
|
70
|
+
const {
|
|
71
|
+
multiSelect,
|
|
72
|
+
selectBlock,
|
|
73
|
+
selectionChange,
|
|
74
|
+
startMultiSelect,
|
|
75
|
+
stopMultiSelect
|
|
76
|
+
} = (0, import_data.useDispatch)(import_store.store);
|
|
73
77
|
const {
|
|
74
78
|
getBlockParents,
|
|
75
79
|
getBlockSelectionStart,
|
|
76
80
|
isMultiSelecting,
|
|
77
81
|
getSelectionStart,
|
|
78
82
|
getSelectionEnd,
|
|
79
|
-
getSelectedBlockClientId
|
|
80
|
-
|
|
83
|
+
getSelectedBlockClientId,
|
|
84
|
+
canHostEditableRoot
|
|
85
|
+
} = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store));
|
|
81
86
|
return (0, import_compose.useRefEffect)(
|
|
82
87
|
(node) => {
|
|
83
88
|
const { ownerDocument } = node;
|
|
@@ -85,11 +90,12 @@ function useSelectionObserver() {
|
|
|
85
90
|
let isTripleClick = false;
|
|
86
91
|
function onMouseDown(event) {
|
|
87
92
|
isTripleClick = event.detail === 3;
|
|
88
|
-
|
|
93
|
+
if (event.shiftKey) {
|
|
94
|
+
startMultiSelect();
|
|
95
|
+
}
|
|
89
96
|
}
|
|
90
97
|
function onKeyDown() {
|
|
91
98
|
isTripleClick = false;
|
|
92
|
-
(0, import_utils.setShiftClickInProgress)(false);
|
|
93
99
|
}
|
|
94
100
|
function onSelectionChange(event) {
|
|
95
101
|
const selection = defaultView.getSelection();
|
|
@@ -113,10 +119,7 @@ function useSelectionObserver() {
|
|
|
113
119
|
// selected editable root block (e.g. Firefox does not
|
|
114
120
|
// always move it), which must not re-enable the wrapper
|
|
115
121
|
// after another block has been selected.
|
|
116
|
-
collapsedClientId === getSelectedBlockClientId() && (
|
|
117
|
-
blockEditorSelectors,
|
|
118
|
-
collapsedClientId
|
|
119
|
-
)) {
|
|
122
|
+
collapsedClientId === getSelectedBlockClientId() && canHostEditableRoot(collapsedClientId)) {
|
|
120
123
|
(0, import_utils.setContentEditableWrapper)(node, true);
|
|
121
124
|
const { activeElement } = ownerDocument;
|
|
122
125
|
if (activeElement !== node && activeElement?.isContentEditable && node.contains(activeElement) && (0, import_dom2.getBlockClientId)(activeElement) === collapsedClientId) {
|
|
@@ -214,7 +217,8 @@ function useSelectionObserver() {
|
|
|
214
217
|
endClientId
|
|
215
218
|
];
|
|
216
219
|
const depth = findDepth(startPath, endPath);
|
|
217
|
-
|
|
220
|
+
const isAncestorDescendant = depth >= startPath.length || depth >= endPath.length;
|
|
221
|
+
if (!isAncestorDescendant && (startPath[depth] !== startClientId || endPath[depth] !== endClientId)) {
|
|
218
222
|
multiSelect(startPath[depth], endPath[depth]);
|
|
219
223
|
return;
|
|
220
224
|
}
|
|
@@ -272,7 +276,7 @@ function useSelectionObserver() {
|
|
|
272
276
|
);
|
|
273
277
|
function onMouseUp(event) {
|
|
274
278
|
onSelectionChange(event);
|
|
275
|
-
(
|
|
279
|
+
stopMultiSelect();
|
|
276
280
|
}
|
|
277
281
|
defaultView.addEventListener("mouseup", onMouseUp);
|
|
278
282
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAC7B,uBAGO;AACP,iBAAmC;AAKnC,mBAA0C;AAC1C,IAAAA,cAAiC;AACjC
|
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAC7B,uBAGO;AACP,iBAAmC;AAKnC,mBAA0C;AAC1C,IAAAA,cAAiC;AACjC,mBAA0C;AAC1C,yBAAuB;AAEvB,IAAM,EAAE,cAAc,QAAI,2BAAQ,iBAAAC,WAAoB;AAUtD,SAAS,0BAA2B,WAAY;AAC/C,QAAM,EAAE,YAAY,aAAa,IAAI;AAErC,MAAK,WAAW,aAAa,WAAW,WAAY;AACnD,WAAO;AAAA,EACR;AAEA,MAAK,iBAAiB,GAAI;AACzB,WAAO;AAAA,EACR;AAEA,SAAO,WAAW,WAAY,eAAe,CAAE;AAChD;AAaA,SAAS,wBAAyB,WAAW,eAAgB;AAC5D,QAAM,EAAE,WAAW,YAAY,IAAI;AAEnC,MAAK,UAAU,aAAa,UAAU,WAAY;AACjD,WAAO;AAAA,EACR;AAEA,MAAK,gBAAgB,UAAU,WAAW,QAAS;AAClD,WAAO;AAAA,EACR;AASA,MACC,gBAAgB,SAChB,+BAAoB,SAAU,KAC9B,eACC;AACD,WAAO,UAAU,mBAAmB,UAAU;AAAA,EAC/C;AAEA,SAAO,UAAU,WAAY,WAAY;AAC1C;AA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AmB,KAAM;AACzB,wBAAgB;AAAA,MACjB;AAEA,kBAAY,iBAAkB,WAAW,SAAU;AACnD,WAAK,iBAAkB,aAAa,WAAY;AAChD,WAAK,iBAAkB,WAAW,SAAU;AAC5C,oBAAc;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,oBAAc;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,oBAAc;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,MAAM;AACZ,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,QACD;AACA,oBAAY,oBAAqB,WAAW,SAAU;AACtD,aAAK,oBAAqB,aAAa,WAAY;AACnD,aAAK,oBAAqB,WAAW,SAAU;AAC/C,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,sBAAc;AAAA,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": ["import_dom", "richTextPrivateApis", "blockEditorStore"]
|
|
7
7
|
}
|
|
@@ -21,11 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
23
|
getPasteBlocks: () => getPasteBlocks,
|
|
24
|
-
isShiftClickInProgress: () => isShiftClickInProgress,
|
|
25
24
|
requiresWrapperOnCopy: () => requiresWrapperOnCopy,
|
|
26
25
|
setClipboardBlocks: () => setClipboardBlocks,
|
|
27
|
-
setContentEditableWrapper: () => setContentEditableWrapper
|
|
28
|
-
setShiftClickInProgress: () => setShiftClickInProgress
|
|
26
|
+
setContentEditableWrapper: () => setContentEditableWrapper
|
|
29
27
|
});
|
|
30
28
|
module.exports = __toCommonJS(utils_exports);
|
|
31
29
|
var import_i18n = require("@wordpress/i18n");
|
|
@@ -88,13 +86,6 @@ function toPlainText(html) {
|
|
|
88
86
|
const plainText = (0, import_dom.__unstableStripHTML)(html).trim();
|
|
89
87
|
return plainText.replace(/\n\n+/g, "\n\n");
|
|
90
88
|
}
|
|
91
|
-
var shiftClickInProgress = false;
|
|
92
|
-
function setShiftClickInProgress(value) {
|
|
93
|
-
shiftClickInProgress = value;
|
|
94
|
-
}
|
|
95
|
-
function isShiftClickInProgress() {
|
|
96
|
-
return shiftClickInProgress;
|
|
97
|
-
}
|
|
98
89
|
function setContentEditableWrapper(node, value, { focus = true } = {}) {
|
|
99
90
|
if (node.contentEditable === String(value)) {
|
|
100
91
|
return value;
|
|
@@ -114,17 +105,15 @@ function setContentEditableWrapper(node, value, { focus = true } = {}) {
|
|
|
114
105
|
node.setAttribute("aria-multiline", "true");
|
|
115
106
|
node.setAttribute("aria-label", (0, import_i18n.__)("Editor canvas"));
|
|
116
107
|
if (focus) {
|
|
117
|
-
node.focus();
|
|
108
|
+
node.focus({ preventScroll: true });
|
|
118
109
|
}
|
|
119
110
|
return true;
|
|
120
111
|
}
|
|
121
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
122
113
|
0 && (module.exports = {
|
|
123
114
|
getPasteBlocks,
|
|
124
|
-
isShiftClickInProgress,
|
|
125
115
|
requiresWrapperOnCopy,
|
|
126
116
|
setClipboardBlocks,
|
|
127
|
-
setContentEditableWrapper
|
|
128
|
-
setShiftClickInProgress
|
|
117
|
+
setContentEditableWrapper
|
|
129
118
|
});
|
|
130
119
|
//# sourceMappingURL=utils.cjs.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,iBAAiD;AACjD,oBAOO;AAKP,qBAAkC;AAClC,mBAA0C;AAEnC,IAAM,wBAAwB,uBAAQ,uBAAwB;AAU9D,SAAS,mBAAoB,OAAO,QAAQ,UAAW;AAC7D,MAAI,UAAU;AAEd,QAAM,CAAE,UAAW,IAAI;AAEvB,MAAK,YAAa;AACjB,UAAM,iBAAiB,SACrB,OAAQ,cAAAA,KAAY,EACpB,aAAc,WAAW,IAAK;AAEhC,QAAK,eAAgB,qBAAsB,GAAI;AAC9C,YAAM,EAAE,sBAAsB,cAAc,mBAAmB,IAC9D,SAAS,OAAQ,aAAAC,KAAiB;AACnC,YAAM,uBAAuB;AAAA,QAC5B,WAAW;AAAA,MACZ;AACA,YAAM,mBAAmB,aAAc,oBAAqB;AAE5D,UAAK,kBAAmB;AACvB,sBAAU;AAAA,UACT;AAAA,UACA,mBAAoB,oB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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,kBAAc,gBAAI,eAAgB,CAAE;AAEvD,MAAK,OAAQ;AAGZ,SAAK,MAAO,EAAE,eAAe,KAAK,CAAE;AAAA,EACrC;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": ["blocksStore", "blockEditorStore", "stripHTML"]
|
|
7
7
|
}
|
|
@@ -50,8 +50,8 @@ var import_color_values = require("../utils/color-values.cjs");
|
|
|
50
50
|
var import_store = require("../store/index.cjs");
|
|
51
51
|
var import_contrast_checker = __toESM(require("./contrast-checker.cjs"));
|
|
52
52
|
var import_background_panel = __toESM(require("../components/global-styles/background-panel.cjs"));
|
|
53
|
-
var import_private_keys = require("../store/private-keys.cjs");
|
|
54
53
|
var import_block_style_state = require("./block-style-state.cjs");
|
|
54
|
+
var import_inherited_value_context = require("../components/global-styles/inherited-value-context.cjs");
|
|
55
55
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
56
56
|
var BACKGROUND_SUPPORT_KEY = "background";
|
|
57
57
|
var BACKGROUND_BLOCK_DEFAULT_VALUES = {
|
|
@@ -142,20 +142,23 @@ function BackgroundImagePanel({
|
|
|
142
142
|
asWrapper
|
|
143
143
|
}) {
|
|
144
144
|
const selectedState = (0, import_block_style_state.useBlockStyleState)();
|
|
145
|
-
const { style, className, backgroundColor, gradient
|
|
145
|
+
const { style, className, backgroundColor, gradient } = (0, import_data.useSelect)(
|
|
146
146
|
(select) => {
|
|
147
|
-
const { getBlockAttributes
|
|
148
|
-
const _settings = getSettings();
|
|
147
|
+
const { getBlockAttributes } = select(import_store.store);
|
|
149
148
|
const blockAttributes = getBlockAttributes(clientId);
|
|
150
149
|
return {
|
|
151
150
|
style: blockAttributes?.style,
|
|
152
151
|
className: blockAttributes?.className,
|
|
153
152
|
backgroundColor: blockAttributes?.backgroundColor,
|
|
154
|
-
gradient: blockAttributes?.gradient
|
|
155
|
-
inheritedValue: _settings[import_private_keys.globalStylesDataKey]?.blocks?.[name]
|
|
153
|
+
gradient: blockAttributes?.gradient
|
|
156
154
|
};
|
|
157
155
|
},
|
|
158
|
-
[clientId
|
|
156
|
+
[clientId]
|
|
157
|
+
);
|
|
158
|
+
const { value: inheritedValue } = (0, import_inherited_value_context.useResolvedStyle)(
|
|
159
|
+
name,
|
|
160
|
+
className,
|
|
161
|
+
selectedState
|
|
159
162
|
);
|
|
160
163
|
const backgroundGradientSupported = hasBackgroundSupport(
|
|
161
164
|
name,
|
|
@@ -267,15 +270,15 @@ function BackgroundImagePanel({
|
|
|
267
270
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
268
271
|
import_background_panel.default,
|
|
269
272
|
{
|
|
270
|
-
inheritedValue,
|
|
271
273
|
as: Wrapper,
|
|
272
274
|
panelId: clientId,
|
|
273
275
|
defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES,
|
|
274
276
|
settings: updatedSettings,
|
|
275
277
|
onChange,
|
|
276
278
|
defaultControls,
|
|
277
|
-
value,
|
|
278
|
-
contrastWarning
|
|
279
|
+
value: isStateSelected ? (0, import_block_style_state.getStyleForState)(style, selectedState) : styleValue,
|
|
280
|
+
contrastWarning,
|
|
281
|
+
inheritedValue
|
|
279
282
|
}
|
|
280
283
|
);
|
|
281
284
|
}
|